problem_id
stringlengths
32
32
name
stringlengths
2
54
problem
stringlengths
204
5.28k
solutions
sequencelengths
1
5.17k
test_cases
stringlengths
38
86.7k
difficulty
stringclasses
1 value
language
stringclasses
1 value
source
stringclasses
1 value
num_solutions
int64
1
5.17k
starter_code
stringclasses
1 value
dfd3423b46d9ac875c40fdb6e3391bae
Vasya and Basketball
Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of *d* meters, and a throw is worth 3 points if the distance is larger than *d* meters, where *d* is some non-negative integer. Vasya would like the advantage of the points scored by the first team (the points of the first team minus the points of the second team) to be maximum. For that he can mentally choose the value of *d*. Help him to do that. The first line contains integer *n* (1<=≤<=*n*<=≤<=2·105) — the number of throws of the first team. Then follow *n* integer numbers — the distances of throws *a**i* (1<=≤<=*a**i*<=≤<=2·109). Then follows number *m* (1<=≤<=*m*<=≤<=2·105) — the number of the throws of the second team. Then follow *m* integer numbers — the distances of throws of *b**i* (1<=≤<=*b**i*<=≤<=2·109). Print two numbers in the format a:b — the score that is possible considering the problem conditions where the result of subtraction *a*<=-<=*b* is maximum. If there are several such scores, find the one in which number *a* is maximum. Sample Input 3 1 2 3 2 5 6 5 6 7 8 9 10 5 1 2 3 4 5 Sample Output 9:6 15:10
[ "def merge(l1,l2):\r\n p1 = 0\r\n p2 = 0\r\n l = []\r\n while ((p1 < len(l1)) and (p2 < len(l2))):\r\n if l1[p1] < l2[p2]:\r\n l.append(l1[p1])\r\n p1 += 1\r\n else:\r\n l.append(l2[p2])\r\n p2 += 1\r\n if p1 < len(l1):\r\n l.extend(l1[p1:len(l1)])\r\n if p2 < len(l2):\r\n l.extend(l2[p2:len(l2)])\r\n return l\r\n\r\ndef merge_sort(l):\r\n if len(l) == 1:\r\n return l\r\n else:\r\n l1 = merge_sort(l[0:len(l)//2])\r\n l2 = merge_sort(l[len(l)//2:len(l)])\r\n return merge(l1, l2)\r\n\r\n\r\nn = int(input()) \r\ndist_str = input()\r\nfirst_dist = list(map(lambda s: int(s), dist_str.split(' ')))\r\nm = int(input())\r\ndist_str = input()\r\nsecond_dist = list(map(lambda s: int(s), dist_str.split(' ')))\r\n\r\n#merge_sort(first_dist)\r\n#merge_sort(second_dist)\r\nfirst_dist.sort()\r\nsecond_dist.sort()\r\nfirst_sum = 3 * n\r\nsecond_sum = 3 * m\r\ndiff = first_sum - second_sum\r\n\r\nthr_p1 = 0\r\nthr_p2 = 0\r\n\r\nfirst_sum_temp = first_sum\r\nsecond_sum_temp = second_sum\r\ndiff_temp = diff\r\n\r\nwhile ((thr_p1 < n) and (thr_p2 < m)):\r\n if first_dist[thr_p1] < second_dist[thr_p2]:\r\n first_sum_temp -= 1\r\n thr_p1 += 1\r\n elif first_dist[thr_p1] > second_dist[thr_p2]:\r\n second_sum_temp -= 1\r\n thr_p2 += 1\r\n else:\r\n first_sum_temp -= 1\r\n second_sum_temp -= 1\r\n thr_p2 += 1\r\n thr_p1 += 1\r\n \r\n diff_temp = first_sum_temp - second_sum_temp\r\n\r\n if diff_temp > diff:\r\n diff = diff_temp\r\n first_sum = first_sum_temp\r\n second_sum = second_sum_temp\r\n\r\n\r\nwhile thr_p1 < n:\r\n first_sum_temp -= 1\r\n thr_p1 += 1\r\n diff_temp = first_sum_temp - second_sum_temp\r\n\r\n if diff_temp > diff:\r\n diff = diff_temp\r\n first_sum = first_sum_temp\r\n second_sum = second_sum_temp\r\n\r\nwhile thr_p2 < m:\r\n second_sum_temp -= 1\r\n thr_p2 += 1\r\n diff_temp = first_sum_temp - second_sum_temp\r\n\r\n if diff_temp > diff:\r\n diff = diff_temp\r\n first_sum = first_sum_temp\r\n second_sum = second_sum_temp\r\n\r\nans = str(first_sum) + ':' + str(second_sum)\r\nprint(ans)\r\n\r\n\r\n", "import bisect\r\n\r\nR = lambda: map(int, input().split())\r\nn = int(input())\r\nar1 = sorted(R())\r\nm = int(input())\r\nar2 = sorted(R())\r\nsa, sb = 0, 10 ** 10\r\nfor x in (set(ar1) | set(ar2 + [0, 10 ** 10])):\r\n acnt = bisect.bisect_right(ar1, x)\r\n bcnt = bisect.bisect_right(ar2, x)\r\n tmpsa = acnt * 2 + (n - acnt) * 3\r\n tmpsb = bcnt * 2 + (m - bcnt) * 3\r\n if tmpsa - tmpsb > sa - sb or (tmpsa - tmpsb == sa - sb and tmpsa > sa):\r\n sa, sb = tmpsa, tmpsb\r\nprint(sa, sb, sep=':')", "n1=int(input())\nd1=list(map(lambda x:int(x),input().split(' ')))\n\nn2=int(input())\nd2=list(map(lambda x:int(x),input().split(' ')))\n\n\ndl=list(set([0]+d1+d2))\ndl.sort()\n\ndd=dict()\nfor i in range(0,len(dl)):\n dd[dl[i]]=i\n\nc1=[0 for i in range(0,len(dl))]\nc2=[0 for i in range(0,len(dl))]\n\ns1=[0 for i in range(0,len(dl))]\ns2=[0 for i in range(0,len(dl))]\n\nfor d in d1:\n c1[dd[d]]+=1\n\nfor d in d2:\n c2[dd[d]]+=1\n\nfor i in range(len(dl)-2,-1,-1):\n s1[i]=s1[i+1]+c1[i+1]\n s2[i]=s2[i+1]+c2[i+1]\n\nmaxsub=s1[0]-s2[0]\nmaxi=0\nmaxa=s1[0]\nfor i in range(0,len(dl)):\n sub=s1[i]-s2[i]\n if sub>maxsub or (sub==maxsub and s1[i]>maxa):\n maxsub=sub\n maxa=s1[i]\n maxi=i\n\nprint(str(n1*2+s1[maxi])+':'+str(n2*2+s2[maxi]))\n\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nm=int(input())\r\nb=list(map(int,input().split()))\r\nc=sorted([[a[i],1] for i in range(n)]+[[b[i],2] for i in range(m)])\r\nx=x0=2*n\r\ny=y0=2*m\r\nfor i in range(n+m-1,-1,-1):\r\n if c[i][1]==1:\r\n x+=1\r\n else:\r\n y+=1\r\n if x-y>=x0-y0:\r\n x0,y0=x,y\r\nprint(x0,y0,sep=':')", "from bisect import bisect_left\nn = int(input())\na = [int(x) for x in input().split()]\nm = int(input())\nb = [int(x) for x in input().split()]\na.sort()\nb.sort()\nthree = 0\nmaxdif = -(10**10)\nfor i in range(n):\n bi = bisect_left(b, a[i])\n dif = ((n-i)*3 + (i+1)*2) - ((m-bi)*3 + (bi+1)*2)\n if dif > maxdif:\n three = a[i]\n maxdif = dif\nif n*2 - m*2 > maxdif:\n three = 10**10\nsa, sb = 0,0\nfor x in a:\n if x >= three: sa += 3\n else: sa += 2\nfor x in b:\n if x >= three: sb += 3\n else: sb += 2\nprint(str(sa) + \":\" + str(sb))\n\n\n \t \t\t \t \t \t\t \t\t \t\t \t\t \t \t\t", "n=int(input())\r\na=list(map(int,input().split()))\r\nm=int(input())\r\nb=list(map(int,input().split()))\r\na.sort();b.sort()\r\nx,y=0,-1\r\nu,v=n*3,m*3\r\nq=[u,v]\r\nwhile 1:\r\n if y!=m-1:\r\n y+=1\r\n v-=1\r\n while x<n and a[x]<=b[y]:\r\n x+=1\r\n u-=1\r\n if u-v>q[0]-q[1]:q=[u,v]\r\n if (x==n or a[x]>b[y]) and y==m-1:break\r\nprint('%i:%i' %(q[0],q[1]))\r\n", "first = []\r\nsecond = []\r\n \r\nn = int(input())\r\nline = input().split()\r\nfor i in range(n):\r\n first.append(int(line[i]))\r\nfirst.sort()\r\n \r\nm = int(input())\r\nline = input().split()\r\nfor i in range(m):\r\n second.append(int(line[i]))\r\nsecond.sort()\r\n \r\n \r\na = 3 * n\r\nb = 3 * m\r\nd = a - b\r\npenalty = [0, 0]\r\ni = 0\r\nj = 0\r\n \r\nwhile i < n and j < m:\r\n t = min(first[i], second[j])\r\n while i < n and first[i] <= t:\r\n i += 1\r\n penalty[0] += 1\r\n while j < m and second[j] <= t:\r\n j += 1\r\n penalty[1] += 1\r\n if 3*n - penalty[0] - 3*m + penalty[1] > d:\r\n a = 3 * n - penalty[0]\r\n b = 3 * m - penalty[1]\r\n d = 3*n - penalty[0] - 3*m + penalty[1]\r\n \r\nif 2 * n - 2 * m > d:\r\n a = 2 * n\r\n b = 2 * m\r\n \r\nprint(str(a)+\":\"+str(b))", "from sys import stdin\r\nfrom math import inf\r\n\r\ndef score(d, lst):\r\n d += 0.1\r\n l = 0\r\n r = len(lst)-1\r\n while l < r:\r\n mid = (l+r)//2\r\n if lst[mid] < d: l = mid+1\r\n else: r = mid\r\n if lst[r] < d:\r\n r += 1\r\n return r*2 + 3*(len(lst)-r)\r\n\r\nn = int(stdin.readline())\r\na = list(map(int, stdin.readline().split()))\r\na.sort()\r\nm = int(stdin.readline())\r\nb = list(map(int, stdin.readline().split()))\r\nb.sort()\r\nd = 0\r\ncurm = -inf\r\ncura = 0\r\nfor ele in a:\r\n sa = score(ele, a)\r\n sb = score(ele, b)\r\n if sa - sb > curm or (curm == sa-sb and cura < sa):\r\n curm = sa-sb\r\n cura = sa\r\n d = ele\r\nfor ele in b:\r\n sa = score(ele, a)\r\n sb = score(ele, b)\r\n if sa - sb > curm or (curm == sa-sb and cura < sa):\r\n curm = sa-sb\r\n cura = sa\r\n d = ele\r\nele = a[0]-0.1\r\nsa = score(ele, a)\r\nsb = score(ele, b)\r\nif sa - sb > curm or (curm == sa-sb and cura < sa):\r\n curm = sa-sb\r\n cura = sa\r\n d = ele\r\nele = b[0]-0.1\r\nsa = score(ele, a)\r\nsb = score(ele, b)\r\nif sa - sb > curm or (curm == sa-sb and cura < sa):\r\n curm = sa-sb\r\n cura = sa\r\n d = ele\r\nprint(score(d, a), \":\", score(d, b), sep=\"\")", "import bisect\r\nt=1\r\nwhile t>0:\r\n t-=1\r\n cnt=0\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 a.sort()\r\n b.sort()\r\n cnt0=0\r\n cnt1=3*n\r\n cnt2=3*m\r\n for i in a:\r\n num1=bisect.bisect(a,i)\r\n num2=bisect.bisect(b,i)\r\n if 2*(num1-num2)+3*(n-m-num1+num2)>cnt1-cnt2 or (2*(num1-num2)+3*(n-m-num1+num2)==cnt1-cnt2 and i<cnt0):\r\n cnt0=i\r\n cnt1=2*num1+3*(n-num1)\r\n cnt2=2*num2+3*(m-num2)\r\n for i in b:\r\n num1=bisect.bisect(a,i)\r\n num2=bisect.bisect(b,i)\r\n if 2*(num1-num2)+3*(n-m-num1+num2)>cnt1-cnt2 or (2*(num1-num2)+3*(n-m-num1+num2)==cnt1-cnt2 and i<cnt0):\r\n cnt0=i\r\n cnt1=2*num1+3*(n-num1)\r\n cnt2=2*num2+3*(m-num2)\r\n print(cnt1,end='')\r\n print(':',end='')\r\n print(cnt2)", "import random\r\n\r\nba,bb=-1,-1\r\nbd=-100000000000000\r\nca,cb=0,0\r\n\r\ndef solve():\r\n global ba,bb,bd,ca,cb\r\n if (ca-cb==bd and ca>ba) or ca-cb>bd:\r\n ba=ca\r\n bb=cb\r\n bd=ca-cb\r\n\r\ndef line(lst1, lst2):\r\n global ca,cb,ba,bb,bd\r\n lst=[]\r\n for i in range(len(lst1)):\r\n ca+=3\r\n lst.append([lst1[i],0])\r\n for i in range(len(lst2)):\r\n cb+=3\r\n lst.append([lst2[i],1])\r\n lst=sorted(lst)\r\n for i in range(len(lst)+1):\r\n if i==0 or i==len(lst) or lst[i][0]!=lst[i-1][0]:\r\n solve()\r\n if i==len(lst): break\r\n if lst[i][1]==0:\r\n ca-=1\r\n else:\r\n cb-=1\r\n ans=str(ba)+\":\"+str(bb)\r\n return ans\r\n #return [ba,bb]\r\n\r\nn=int(input())\r\nlst1=list(map(int,input().split()))\r\nm=int(input())\r\nlst2=list(map(int,input().split()))\r\nprint(line(lst1,lst2))\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nm=int(input())\r\nb=list(map(int,input().split()))\r\nc=[]\r\nfor i in range(len(a)):\r\n c.append([a[i],0])\r\nfor i in range(len(b)):\r\n c.append([b[i],1])\r\nv=[n,m]\r\ntp0=3*n\r\ntp1=3*m\r\ndif=tp0-tp1\r\nx=tp0\r\ny=tp1\r\nc.sort()\r\nfor i in range(len(c)):\r\n v[c[i][1]]-=1\r\n np0=2*(n-v[0])+3*v[0]\r\n np1=2*(m-v[1])+3*v[1]\r\n if dif<=(np0-np1):\r\n if dif==(np0-np1):\r\n if x<np0:\r\n x=np0\r\n y=np1\r\n else:\r\n x=np0\r\n y=np1\r\n dif=np0-np1\r\n # print(x,y,v)\r\nprint(str(x)+\":\"+str(y))", "import os, sys, atexit\nfrom io import BytesIO, StringIO\n \ninput = BytesIO(os.read(0, os.fstat(0).st_size)).readline\n_OUTPUT_BUFFER = StringIO()\nsys.stdout = _OUTPUT_BUFFER\n \[email protected]\ndef write():\n sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())\nn = int(input())\na = list(map(int, input().split()))\nm = int(input())\nb = list(map(int, input().split()))\na.sort()\nb.sort()\nscorea = 3 * n\nscoreb = 3 * m\nans = scorea - scoreb\nansa = scorea\nansb = scoreb\ni = 0\nj = 0\nwhile 1:\n if i == n or j == m: break\n mn = min(a[i], b[j])\n while 1:\n if i == n: break\n if a[i] == mn: scorea += -1\n else: break\n i -= -1\n while 1:\n if j == m: break\n if b[j] == mn: scoreb += -1\n else: break\n j -= -1\n if scorea - scoreb > ans:\n ans = scorea - scoreb\n ansa = scorea\n ansb = scoreb\nif ansa - ansb < 2 * n - 2 * m: ansa, ansb = 2 * n, 2 * m\nprint(ansa, \":\", ansb, sep = \"\") \n \t\t\t \t \t \t \t\t\t \t\t\t \t \t\t \t \t", "n = int(input())\na = []\na += list(map(lambda x: [int(x), 0], input().split()))\nm = int(input())\na += list(map(lambda x: [int(x), 1], input().split()))\na = sorted(a)\nx = 3 * n\ny = 3 * m\nsx = x\nsy = y\nfor i in a:\n if i[1] == 0:\n x-= 1\n else:\n y-= 1\n if (x - y > sx - sy):\n sx = x\n sy = y\nprint(f\"{sx}:{sy}\")\n \t \t \t \t \t\t \t \t \t \t \t\t\t", "#------------------------template--------------------------#\r\nimport os\r\nimport sys\r\nfrom math import *\r\nfrom collections import *\r\nfrom fractions import *\r\nfrom bisect import *\r\nfrom heapq import*\r\nfrom io import BytesIO, IOBase\r\ndef vsInput():\r\n sys.stdin = open('input.txt', 'r')\r\n sys.stdout = open('output.txt', 'w')\r\nBUFSIZE = 8192\r\nclass FastIO(IOBase):\r\n newlines = 0\r\n def __init__(self, file):\r\n self._fd = file.fileno()\r\n self.buffer = BytesIO()\r\n self.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n self.write = self.buffer.write if self.writable else None\r\n def read(self):\r\n while True:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n if not b:\r\n break\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines = 0\r\n return self.buffer.read()\r\n def readline(self):\r\n while self.newlines == 0:\r\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n self.newlines = b.count(b\"\\n\") + (not b)\r\n ptr = self.buffer.tell()\r\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n self.newlines -= 1\r\n return self.buffer.readline()\r\n def flush(self):\r\n if self.writable:\r\n os.write(self._fd, self.buffer.getvalue())\r\n self.buffer.truncate(0), self.buffer.seek(0)\r\nclass IOWrapper(IOBase):\r\n def __init__(self, file):\r\n self.buffer = FastIO(file)\r\n self.flush = self.buffer.flush\r\n self.writable = self.buffer.writable\r\n self.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n self.read = lambda: self.buffer.read().decode(\"ascii\")\r\n self.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\nALPHA='abcdefghijklmnopqrstuvwxyz'\r\nM=998244353\r\nEPS=1e-6\r\ndef value():return tuple(map(int,input().split()))\r\ndef array():return [int(i) for i in input().split()]\r\ndef Int():return int(input())\r\ndef Str():return input()\r\ndef arrayS():return [i for i in input().split()]\r\n\r\n\r\n#-------------------------code---------------------------#\r\n# vsInput()\r\n \r\n\r\nn=Int()\r\na=array()\r\na=[(1,i) for i in a]\r\n\r\nm=Int()\r\nb=array()\r\nb=[(2,i) for i in b]\r\n\r\noverall=a+b+[(0,0)]\r\noverall.sort(key= lambda x:x[1])\r\noverall.append((inf,0))\r\n\r\ndistances={1:0,2:0,0:0}\r\ntotal={}\r\n\r\n# print(overall)\r\n\r\nans=[-inf,-inf,-inf]\r\n\r\nfor i in range(n+m+1):\r\n team,cur_dist=overall[i]\r\n _,next_dist=overall[i+1]\r\n\r\n distances[team]+=1\r\n\r\n if(cur_dist!=next_dist):\r\n\r\n scoreA=distances[1]*2 + (n-distances[1])*3\r\n scoreB=distances[2]*2 + (m-distances[2])*3\r\n dif=scoreA-scoreB\r\n\r\n if(dif>ans[0]):\r\n ans=[dif,scoreA,scoreB]\r\n if(dif==ans[0] and scoreA>ans[1]):\r\n ans=[dif,scoreA,scoreB]\r\n # print(scoreA,scoreB)\r\n\r\nprint(*ans[1:],sep=':')\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n ", "n=int(input())\r\nlia=list(map(int,input().split(\" \",n)[:n]))\r\nm=int(input())\r\nlib=list(map(int,input().split(\" \",m)[:m]))\r\na=[[ai,0] for ai in lia] + [[bi,1] for bi in lib]\r\na.sort()\r\nx,y=3*n,3*m\r\nX,Y=3*n,3*m\r\nfor i in range(n+m):\r\n if a[i][1]==0:\r\n X-=1\r\n else:\r\n Y-=1\r\n if X-Y>x-y:\r\n x,y=X,Y\r\nprint(x,y,sep=\":\")\r\n", "def read_pack():\n\n c = int(input())\n x = list(map(int, str.split(input())))\n x.sort()\n return c, x + [0]\n\nn, a = read_pack()\nm, b = read_pack()\n\ni = j = 0\npa = pb = None\nwhile i <= n and j <= m:\n\n ca = (n - i) * 3 + i * 2\n cb = (m - j) * 3 + j * 2\n\n if pa is None or (ca - cb > pa - pb) or (ca - cb == pa - pb and ca > pa):\n\n pa, pb = ca, cb\n\n if j == m:\n\n i += 1\n\n elif i == n:\n\n j += 1\n\n elif a[i] < b[j]:\n\n i += 1\n\n elif a[i] > b[j]:\n\n j += 1\n\n else:\n\n i += 1\n j += 1\n\nprint(str.format(\"{}:{}\", pa, pb))\n", "import sys\r\n#sys.setrecursionlimit(10**7)\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############ ---- Input Functions ---- ############\r\n\r\ndef Vasya_and_Basketball():\r\n n = inp()\r\n team_a_dist = inlt()\r\n m = inp()\r\n team_b_dist = inlt()\r\n team_b_counter = 0\r\n\r\n team_a_dist_sorted = sorted(team_a_dist)\r\n team_b_dist_sorted = sorted(team_b_dist)\r\n\r\n team_a_points = []\r\n team_b_points = []\r\n diff = []\r\n\r\n for index,a_dist in enumerate(team_a_dist_sorted):\r\n d = a_dist - 1 \r\n three_pointer_a = n - index\r\n two_pointer_a = n - three_pointer_a\r\n\r\n while team_b_counter <= (m-1) and team_b_dist_sorted[team_b_counter] <= d:\r\n team_b_counter += 1\r\n \r\n two_pointer_b = team_b_counter\r\n three_pointer_b = m - two_pointer_b\r\n\r\n points_a = (3*three_pointer_a) + (2*two_pointer_a)\r\n points_b = (3*three_pointer_b) + (2*two_pointer_b)\r\n team_a_points.append(points_a)\r\n team_b_points.append(points_b)\r\n diff.append(points_a-points_b)\r\n \r\n all_two_pointer_a = 2*n\r\n all_two_pointer_b = 2*m\r\n team_a_points.append(all_two_pointer_a)\r\n team_b_points.append(all_two_pointer_b)\r\n diff.append(all_two_pointer_a-all_two_pointer_b)\r\n\r\n # print(team_a_points)\r\n # print(team_b_points)\r\n # print(diff)\r\n\r\n max_index = diff.index(max(diff))\r\n print(str(team_a_points[max_index]) + ':' + str(team_b_points[max_index]))\r\n return \r\n\r\nVasya_and_Basketball()", "n=int(input())\r\na=sorted([int(i) for i in input().split()])\r\nm=int(input())\r\nb=sorted([int(i) for i in input().split()])\r\n\r\nma=a1=3*n; mb=b1=3*m; rast=a1-b1; i,j=0,0\r\nwhile i<n and j<m:\r\n z=min(a[i],b[j])\r\n while i<n and a[i]<=z:\r\n i+=1; ma-=1\r\n while j<m and b[j]<=z:\r\n j+=1; mb-=1\r\n if ma-mb > rast:\r\n a1, b1= ma, mb\r\n rast=a1-b1\r\nif 2*n-2*m>rast:\r\n a1,b1=2*n, 2*m\r\nprint(\"%d:%d\"%(a1,b1))\r\n\r\n", "from collections import defaultdict, deque\nfrom functools import lru_cache\nfrom heapq import heappush, heappop\nfrom typing import Counter\nfrom bisect import bisect_right, bisect_left\nimport math\nhpop = heappop\nhpush = heappush\n\ndef dopath(start, end):\n sx,sy = start\n ex,ey = end\n res = []\n if abs(ex-sx) > 0:\n res.append(\"1 \"+str(abs(ex-sx))+(\" R\" if ex > sx else \" L\"))\n\n if abs(ey-sy) > 0:\n res.append('1 '+str(abs(ey-sy))+(\" U\" if ey > sy else \" D\"))\n return res\n\ndef solution():\n # a - b maximam and a maximam\n # sort them both\n # for all a\n # bisect aby a[i] - 1\n # bisect by inf\n\n # then sa = 2*(i+1) + 3*(len(a) - i -1)\n # then sb = 2*(index) + 3*(len(a) - index)\n n = int(input())\n a = list(map(int, input().split()))\n\n m = int(input())\n b = list(map(int, input().split()))\n \n x=3*n; y=3*m;\n a.sort(); b.sort()\n a.append(float(\"inf\"))\n for i in range(len(a)):\n sa = 2*i + 3*(n-i)\n index = bisect_right(b,a[i]-1)\n sb = 2*index + 3*(m - index)\n\n if (sa - sb) > (x-y):\n x = sa; y = sb\n elif ((sa - sb) == (x-y)) and sa > x:\n x = sa; y = sb\n print(str(x)+\":\" + str(y))\n\n # if sa - sb is greater \n # chang it\n # if equal and sa > xa.. take it\n\n\ndef main():\n t = 1\n #t = int(input())\n for _ in range(t):\n solution()\n \nimport sys\nimport threading\nsys.setrecursionlimit(1 << 30)\nthreading.stack_size(1 << 27)\nthread = threading.Thread(target=main)\nthread.start(); thread.join()\n#main()\n\n\n\n\n\"\"\"\n num = int(input())\n arr = list(map(int, input().split()))\n a,b = map(int, input().split())\n graph = defaultdict(list)\n for i in range(#)\n graph[a].append(b)\n graph[b].append(a)\n MOD = 10**9 + 7\n\nfor di,dj in [(0,1),(1,0),(0,-1),(-1,0)]:\n ni = i + di\n nj = j + dj\n if not (0<= ni < len(grid) and 0<= nj < len(grid[0])):\n continue\n\ndef gcd(a,b):\n if a < b:\n a,b = b,a\n if b == 0:\n return a\n\n return gcd(a%b,b)\n\n\"\"\"\n", "N = int(input())\r\na = list(map(int, input().split()))\r\n\r\nM = int(input())\r\nb = list(map(int, input().split()))\r\n\r\na.sort()\r\nb.sort()\r\n\r\np = [0, 2e9]\r\np += a + b\r\np.sort()\r\np = list(set(p))\r\n\r\nbesta, bestb = 0, 0\r\nbest = -2e9\r\n\r\nai, bi = 0, 0\r\n\r\nfor i in range(len(p)):\r\n while ai < len(a) and a[ai] <= p[i]:\r\n ai += 1\r\n while bi < len(b) and b[bi] <= p[i]:\r\n bi += 1\r\n \r\n ascore = ai * 2 + (len(a) - ai) * 3\r\n bscore = bi * 2 + (len(b) - bi) * 3\r\n \r\n diff = ascore - bscore\r\n if diff > best or (diff == best and ascore > besta):\r\n best = diff\r\n besta = ascore\r\n bestb = bscore\r\n\r\nprint(f\"{besta}:{bestb}\")\r\n", "from math import sqrt, ceil, log\r\nfrom heapq import heapify, heappush, heappop\r\nfrom collections import defaultdict\r\nfrom bisect import bisect_left, bisect_right\r\n\r\nioint = lambda: int(input())\r\nioarr = lambda: list(map(int, input().split(\" \")))\r\nprnys = lambda: print(\"YES\")\r\nprnno = lambda: print(\"NO\")\r\n\r\nna = ioint()\r\narra = ioarr()\r\nnb = ioint()\r\narrb = ioarr()\r\n\r\narr = sorted([(x, 1) for x in arra] + [(x, 2) for x in arrb])\r\nx, y = 3 * na, 3 * nb\r\nfx, fy = x, y\r\n\r\nfor _, p in arr:\r\n if p == 1:\r\n x -= 1\r\n else:\r\n y -= 1\r\n\r\n if x - y > fx - fy:\r\n fx, fy = x, y\r\n\r\nprint(fx, fy, sep=\":\")\r\n", "n,a=int(input()),list(map(int,input().split()))\r\nm,b=int(input()),list(map(int,input().split()))\r\np=[(i,0) for i in a]+[(i,1) for i in b]\r\np.sort()\r\ni=0\r\nscore=[n*3,m*3]\r\nscore_temp=list(score)\r\nwhile i<m+n:\r\n d=p[i][0]\r\n while i<m+n and p[i][0]==d:\r\n score_temp[p[i][1]]-=1\r\n i+=1\r\n if score_temp[0]-score_temp[1]>score[0]-score[1]:\r\n score=list(score_temp)\r\nprint(*score,sep=\":\")", "\"\"\"\r\n\tAuthor\t\t: Arif Ahmad\r\n\tDate \t\t: \r\n\tAlgo \t\t: \r\n\tDifficulty\t: \r\n\"\"\"\r\n\r\ndef main():\r\n\tn = int(input())\r\n\tt1 = [int(_) for _ in input().split()]\r\n\tt1 = sorted(t1)\r\n\r\n\tm = int(input())\r\n\tt2 = [int(_) for _ in input().split()]\r\n\tt2 = sorted(t2)\r\n\r\n\ta = x = 3 * n\r\n\tb = y = 3 * m\r\n\tadvantage = a - b\r\n\ti = 0\r\n\tj = 0\r\n\twhile i<n or j<m:\r\n\t\tif i<n and j<m:\r\n\t\t\tif t1[i] < t2[j]:\r\n\t\t\t\tx -= 1\r\n\t\t\t\ti += 1\r\n\t\t\telif t2[j] < t1[i]:\r\n\t\t\t\ty -= 1\r\n\t\t\t\tj += 1\r\n\t\t\telse:\r\n\t\t\t\tx -= 1\r\n\t\t\t\ty -= 1\r\n\t\t\t\ti += 1\r\n\t\t\t\tj += 1\r\n\t\telif i < n:\r\n\t\t\tx -= 1\r\n\t\t\ti += 1\r\n\t\telse:\r\n\t\t\ty -= 1\r\n\t\t\tj += 1\r\n\r\n\t\tif (x - y) > advantage:\r\n\t\t\ta = x\r\n\t\t\tb = y\r\n\t\t\tadvantage = a - b\r\n\r\n\tprint('%d:%d' % (a, b))\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n \r\n", "from bisect import bisect_left\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\nm = int(input())\r\nb = [int(x) for x in input().split()]\r\na.sort()\r\nb.sort()\r\nthree = 0\r\nmaxdif = -(10**10)\r\nfor i in range(n):\r\n bi = bisect_left(b, a[i])\r\n dif = ((n-i)*3 + (i+1)*2) - ((m-bi)*3 + (bi+1)*2)\r\n if dif > maxdif:\r\n three = a[i]\r\n maxdif = dif\r\nif n*2 - m*2 > maxdif:\r\n three = 10**10\r\nsa, sb = 0,0\r\nfor x in a:\r\n if x >= three: sa += 3\r\n else: sa += 2\r\nfor x in b:\r\n if x >= three: sb += 3\r\n else: sb += 2\r\nprint(str(sa) + \":\" + str(sb))", "\"\"\"\r\nCodeforces Contest 281 Div 2 Problem C\r\n\r\nAuthor : chaotic_iak\r\nLanguage: Python 3.3.4\r\n\"\"\"\r\n\r\ndef main():\r\n n, = read()\r\n a = read()\r\n res = [(i,0) for i in a]\r\n m, = read()\r\n b = read()\r\n res.extend((i,1) for i in b)\r\n res.sort()\r\n mxa = 3*n\r\n mnb = 3*m\r\n cra = 3*n\r\n crb = 3*m\r\n for _,i in res:\r\n if i:\r\n crb -= 1\r\n if cra-crb > mxa-mnb:\r\n mxa = cra\r\n mnb = crb\r\n else:\r\n cra -= 1\r\n print(str(mxa) + \":\" + str(mnb))\r\n\r\n################################### NON-SOLUTION STUFF BELOW\r\n\r\ndef read(mode=2):\r\n # 0: String\r\n # 1: List of strings\r\n # 2: List of integers\r\n inputs = input().strip()\r\n if mode == 0: return inputs\r\n if mode == 1: return inputs.split()\r\n if mode == 2: return list(map(int, inputs.split()))\r\n\r\ndef write(s=\"\\n\"):\r\n if s is None: s = \"\"\r\n if isinstance(s, list): s = \" \".join(map(str, s))\r\n s = str(s)\r\n print(s, end=\"\")\r\n\r\nwrite(main())", "n, a = int(input()), list(map(int, input().split()))\r\nm, b = int(input()), list(map(int, input().split()))\r\n\r\na.sort()\r\nb.sort()\r\n\r\nA, B = len(a) * 3, len(b) * 3\r\ni = j = 0\r\ntA, tB = A, B\r\n\r\nwhile (i < len(a) and j < len(b)):\r\n d = min(a[i], b[j])\r\n while (i < len(a) and a[i] == d):\r\n i += 1\r\n tA -= 1\r\n while (j < len(b) and b[j] == d):\r\n j += 1\r\n tB -= 1\r\n if (tA - tB > A - B):\r\n A, B = tA, tB\r\n\r\nif (j < len(b)):\r\n tB = len(b) * 2\r\n if (tA - tB > A - B):\r\n A, B = tA, tB\r\n\r\nprint(A, ':', B, sep = '')\r\n\r\n \r\n", "import sys\r\ninput=sys.stdin.readline\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nm=int(input())\r\nb=list(map(int,input().split()))\r\na.sort()\r\nb.sort()\r\nj,k=0,0\r\nc=[]\r\nwhile j<=n and k<=m:\r\n if j==n and k==m:\r\n break\r\n elif j==n:\r\n c.append([b[k],1])\r\n k+=1\r\n elif k==m:\r\n c.append([a[j],0])\r\n j+=1\r\n elif a[j]<=b[k]:\r\n c.append([a[j],0])\r\n j+=1\r\n elif a[j]>=b[k]:\r\n c.append([b[k],1])\r\n k+=1\r\ncnt_a=0\r\ncnt_b=0\r\nans=3*n-3*m\r\nres=[3*n,3*m]\r\nfor i in range(len(c)):\r\n num,id=c[i]\r\n if id==0:\r\n cnt_a+=1\r\n else:\r\n cnt_b+=1\r\n tmp_a=cnt_a*2+(n-cnt_a)*3\r\n tmp_b=cnt_b*2+(m-cnt_b)*3\r\n if ans<tmp_a-tmp_b:\r\n res=[tmp_a,tmp_b]\r\n ans=tmp_a-tmp_b\r\nprint(str(res[0])+\":\"+str(res[1]))", "from sys import stdin, stdout\r\n\r\n\r\ndef solution():\r\n n = int(stdin.readline().rstrip())\r\n a = list(map(lambda x: (int(x), 1), stdin.readline().rstrip().split()))\r\n m = int(stdin.readline().rstrip())\r\n b = list(map(lambda x: (int(x), 2), stdin.readline().rstrip().split()))\r\n c = a+b\r\n c.sort(key=lambda tup: tup[0])\r\n aa = n*3\r\n af = n*3\r\n bf = m*3\r\n bb = m*3\r\n d = aa-bb\r\n\r\n prev = -1\r\n for elem in c:\r\n if prev != elem[0]:\r\n prev = elem[0]\r\n if aa-bb > d:\r\n d = aa-bb\r\n af = aa\r\n bf = bb\r\n if elem[1] == 1:\r\n aa -= 1\r\n else:\r\n bb -= 1\r\n if aa - bb > d:\r\n d = aa - bb\r\n af = aa\r\n bf = bb\r\n stdout.write(\"{}:{}\".format(af, bf))\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n solution()", "from bisect import bisect_right\r\n\r\nn = int(input())\r\nA = list(map(int, input().split()))\r\nm = int(input())\r\nB = list(map(int, input().split()))\r\n\r\nA.sort()\r\nB.sort()\r\n\r\nCCC = set(A)\r\nCC = set(B)\r\nC: list = list(CC) + list(CCC)\r\nC.sort()\r\nsumA = n*3\r\nsumB = m*3\r\nc1 = sumA-sumB\r\nc2 = sumA\r\nc3 = sumB\r\nfor i in range(len(C)):\r\n elem = C[i]\r\n it = bisect_right(A, elem)\r\n jt = bisect_right(B, elem)\r\n\r\n sumAt = sumA - it\r\n sumBt = sumB - jt\r\n raznitsa = sumAt-sumBt\r\n\r\n if raznitsa > c1:\r\n c1 = raznitsa\r\n c2 = sumAt\r\n c3 = sumBt\r\n\r\n elif raznitsa == c1:\r\n if sumAt > c2:\r\n c1 = raznitsa\r\n c2 = sumAt\r\n c3 = sumBt\r\n\r\nprint(str(c2)+\":\"+str(c3))\r\n", "import itertools\r\nimport math\r\nimport threading\r\nimport time\r\nfrom builtins import input, range\r\nfrom math import gcd as gcd\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nimport queue\r\nimport itertools\r\nimport collections\r\nfrom heapq import heappop, heappush\r\nimport random\r\nimport os\r\nfrom random import randint\r\nimport decimal\r\nfrom math import factorial as fac\r\n\r\n\r\ndef solve():\r\n n = int(sys.stdin.readline())\r\n a = list(map(int, sys.stdin.readline().split()))\r\n\r\n all_shots = set()\r\n\r\n aa = {}\r\n for i in range(n):\r\n all_shots.add(a[i])\r\n if a[i] not in aa:\r\n aa[a[i]] = 1\r\n else:\r\n aa[a[i]] += 1\r\n\r\n m = int(sys.stdin.readline())\r\n b = list(map(int, sys.stdin.readline().split()))\r\n\r\n bb = {}\r\n for i in range(m):\r\n all_shots.add(b[i])\r\n if b[i] not in bb:\r\n bb[b[i]] = 1\r\n else:\r\n bb[b[i]] += 1\r\n\r\n max_diff = 3 * (n - m)\r\n score = [3 * n, 3 * m]\r\n\r\n all_shots = list(all_shots)\r\n all_shots.sort()\r\n\r\n score_1 = 3 * n\r\n score_2 = 3 * m\r\n\r\n for d in all_shots:\r\n if d in aa:\r\n score_1 -= aa[d]\r\n if d in bb:\r\n score_2 -= bb[d]\r\n\r\n if score_1 - score_2 > max_diff:\r\n max_diff = score_1 - score_2\r\n score = [score_1, score_2]\r\n\r\n print(score[0], \":\", score[1], sep=\"\")\r\n\r\n\r\nif __name__ == '__main__':\r\n multytest = False\r\n\r\n if multytest:\r\n t = int(input())\r\n for i in range(t):\r\n solve()\r\n else:\r\n solve()\r\n", "\r\n\r\nn = int(input())\r\na = [int(s) for s in input().split()]\r\nm = int(input())\r\nb = [int(s) for s in input().split()]\r\n\r\nINF = 3000000000\r\na.sort()\r\nb.sort()\r\n\r\na.append(INF)\r\nb.append(INF)\r\ni = 0\r\nj = 0\r\n\r\nbestd = 0\r\nbestadv = (n-m)*3\r\nbesta = 3*n\r\nbestb = 3*m\r\ncura = 3*n\r\ncurb = 3*m\r\nwhile i<n or j<m:\r\n d = min(a[i],b[j])\r\n while i<n and a[i]<=d:\r\n cura-=1\r\n i+=1\r\n while j<m and b[j]<=d:\r\n curb-=1\r\n j+=1\r\n \r\n if cura - curb>bestadv:\r\n bestadv = cura-curb\r\n besta = cura\r\n bestb = curb\r\n## print(d,i,j,cura,curb,bestadv)\r\n\r\nprint('{0}:{1}'.format(besta,bestb))\r\n\r\n \r\n \r\n \r\n\r\n", "from itertools import chain\nfrom bisect import bisect_left as bisect\n\n\ndef main():\n n = int(input().strip())\n aa = list(map(int, input().strip().split()))\n aa.sort()\n m = int(input().strip())\n bb = list(map(int, input().strip().split()))\n bb.sort()\n res = []\n dd = set(chain(aa, bb))\n for d in chain(aa, bb):\n dd.add(d + 1)\n la = len(aa) * 3\n lb = len(bb) * 3\n for d in dd:\n a = la - bisect(aa, d)\n b = lb - bisect(bb, d)\n res.append((a - b, a))\n b, a = max(res)\n print('{:n}:{:n}'.format(a, a - b))\n\n\nmain()", "import sys\r\n\r\n\r\ndef read_input(input_path=None):\r\n if input_path is None:\r\n f = sys.stdin\r\n else:\r\n f = open(input_path, 'r')\r\n\r\n n = int(f.readline())\r\n a = list(map(int, f.readline().split()))\r\n m = int(f.readline())\r\n b = list(map(int, f.readline().split()))\r\n\r\n return n, m, a, b\r\n\r\n\r\ndef sol(n, m, first, second):\r\n first = sorted(first)\r\n second = sorted(second)\r\n\r\n a = 3 * n\r\n b = 3 * m\r\n d = a - b\r\n penalty = [0, 0]\r\n i = 0\r\n j = 0\r\n\r\n while i < n and j < m:\r\n t = min(first[i], second[j])\r\n while i < n and first[i] <= t:\r\n i += 1\r\n penalty[0] += 1\r\n while j < m and second[j] <= t:\r\n j += 1\r\n penalty[1] += 1\r\n if 3 * n - penalty[0] - 3 * m + penalty[1] > d:\r\n a = 3 * n - penalty[0]\r\n b = 3 * m - penalty[1]\r\n d = 3 * n - penalty[0] - 3 * m + penalty[1]\r\n\r\n if 2 * n - 2 * m > d:\r\n a = 2 * n\r\n b = 2 * m\r\n\r\n return [f\"{a}:{b}\"]\r\n\r\n\r\ndef solve(input_path=None):\r\n return sol(*read_input(input_path))\r\n\r\n\r\ndef main():\r\n for line in sol(*read_input()):\r\n print(f\"{line}\")\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "I = lambda: list(map(int, input().split()))\r\nn = I()[0]\r\nd1 = [0]+sorted(I())\r\nm = I()[0]\r\nd2 = [0]+sorted(I())\r\n\r\nindex1, index2 = {}, {}\r\nindex1[0], index2[0] = n, m\r\ni, j = n, m\r\nwhile (i>=0 and j>=0):\r\n maxd = max(d1[i], d2[j])\r\n if not(maxd in index1):\r\n index1[maxd] = n - i \r\n if not(maxd in index2):\r\n index2[maxd] = m - j \r\n if d1[i] == maxd:\r\n i -= 1\r\n if d2[j] == maxd:\r\n j -= 1\r\nwhile (i>=0):\r\n if not(d1[i] in index1):\r\n index1[d1[i]] = n - i\r\n i -= 1\r\nwhile (j>=0):\r\n if not(d2[j] in index2):\r\n index2[d2[j]] = m - j\r\n j -= 1 \r\n \r\na, b, maxdiff = 0, 0, -1e100\r\nfor foo in [0] + d1 + d2:\r\n i = index1[foo]\r\n j = index2[foo]\r\n _a, _b = i * 3 + (n - i) * 2, j * 3 + (m - j) * 2\r\n diff = _a - _b\r\n if (diff > maxdiff) or (diff == maxdiff and _a > a):\r\n maxdiff = diff\r\n a, b = _a, _b\r\nprint('%d:%d' % (a,b))", "n = int(input())\r\na = list(map(int, input().split()))\r\nm = int(input())\r\nb = list(map(int, input().split()))\r\n\r\na = sorted(a)\r\nb = sorted(b)\r\n\r\nimport bisect\r\n\r\nmx = -5555555555555\r\naa = -5555555555555555\r\nbb = -5555555555555555\r\n\r\ncands = list(a + b)\r\ncands.append(0)\r\ncands.append(3000000009)\r\n\r\nfor v in cands:\r\n q1 = len(a) - bisect.bisect_left(a, v)\r\n q2 = len(b) - bisect.bisect_left(b, v)\r\n c1 = q1 * 3 + 2 * (len(a) - q1)\r\n c2 = q2 * 3 + 2 * (len(b) - q2)\r\n if (c1 - c2 > mx) or (c1 - c2 == mx and c1 > aa):\r\n mx = c1 - c2\r\n aa = c1\r\n bb = c2\r\n\r\nprint(str(aa)+':'+str(bb))\r\n\r\n \r\n\r\n \r\n", "from sys import stdout, stdin, maxsize\r\n\r\nn = int(input())\r\nteam1 = list(map(int, input().split()))\r\nm = int(input())\r\nteam2 = list(map(int, input().split()))\r\nls = []\r\nfor i in range(n):\r\n\tls.append([team1[i], 1])\r\nfor i in range(m):\r\n\tls.append([team2[i], 2])\r\nls.sort()\r\nscore1 = 3 * n\r\nscore2 = 3 * m\r\nans = [score1, score2]\r\nmx = score1-score2\r\n\r\nfor i in range(m + n):\r\n\tif ls[i][1] == 1:\r\n\t\tscore1 -= 1\r\n\telse:\r\n\t\tscore2 -= 1\r\n\tif score1 - score2 > mx:\r\n\t\tans = [score1, score2]\r\n\t\tmx = score1 - score2\r\nprint(f'{ans[0]}:{ans[1]}')", "import os, sys, atexit\r\nfrom io import BytesIO, StringIO\r\n \r\ninput = BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n_OUTPUT_BUFFER = StringIO()\r\nsys.stdout = _OUTPUT_BUFFER\r\n \r\[email protected]\r\ndef write():\r\n sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nm = int(input())\r\nb = list(map(int, input().split()))\r\na.sort()\r\nb.sort()\r\nscorea = 3 * n\r\nscoreb = 3 * m\r\nans = scorea - scoreb\r\nansa = scorea\r\nansb = scoreb\r\ni = 0\r\nj = 0\r\nwhile 1:\r\n if i == n or j == m: break\r\n mn = min(a[i], b[j])\r\n while 1:\r\n if i == n: break\r\n if a[i] == mn: scorea += -1\r\n else: break\r\n i -= -1\r\n while 1:\r\n if j == m: break\r\n if b[j] == mn: scoreb += -1\r\n else: break\r\n j -= -1\r\n if scorea - scoreb > ans:\r\n ans = scorea - scoreb\r\n ansa = scorea\r\n ansb = scoreb\r\nif ansa - ansb < 2 * n - 2 * m: ansa, ansb = 2 * n, 2 * m\r\nprint(ansa, \":\", ansb, sep = \"\")", "__author__ = 'zhan'\n\nn = int(input())\nfirst = sorted([int(i) for i in input().split()])\n\nm = int(input())\nsecond = sorted([int(i) for i in input().split()])\n\na = pa = 3 * n\nb = pb = 3 * m\nd = a - b\n\ni = 0\nj = 0\n\nwhile i < n and j < m:\n t = min(first[i], second[j])\n while i < n and first[i] <= t:\n i += 1\n pa -= 1\n while j < m and second[j] <= t:\n j += 1\n pb -= 1\n if pa - pb > d:\n a = pa\n b = pb\n d = pa - pb\n\nif 2 * n - 2 * m > d:\n a = 2 * n\n b = 2 * m\n\nprint(str(a)+\":\"+str(b))\n\n", "n,_a=int(input()),list(map(int,input().split()))\r\nm,_b=int(input()),list(map(int,input().split()))\r\np=[(ai,0) for ai in _a] + [(bi,1) for bi in _b]\r\np.sort()\r\ni=0\r\nR=[len(_a)*3,len(_b)*3]\r\nr=list(R)\r\nwhile i<len(p):\r\n d = p[i][0]\r\n while i<len(p) and p[i][0]==d:\r\n r[p[i][1]] -= 1\r\n i += 1\r\n if (r[0]-r[1] > R[0]-R[1]):\r\n R=list(r)\r\nprint(*R,sep=':')\r\n", "input()\r\na = list(map(int, input().split()))\r\ninput()\r\nb = list(map(int,input().split()))\r\nall_scores = [(x,0) for x in a]+[(x,1) for x in b]\r\nall_scores.sort()\r\nscore = [3*len(a),3*len(b)]\r\nbest_score = score.copy()\r\nfor k in all_scores:\r\n if k[1] == 0:\r\n score[0] -= 1\r\n else:\r\n score [1] -= 1\r\n if score[0]-score[1] > best_score[0]-best_score[1]:\r\n best_score = score.copy()\r\nprint(str(best_score[0])+\":\"+str(best_score[1]))", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\nw = list(map(int, input().split()))\r\nm = int(input())\r\ns = list(map(int, input().split()))\r\nd = []\r\nfor i in w:\r\n d.append((i, 1))\r\nfor i in s:\r\n d.append((i, 2))\r\na, b = 0, 0\r\nd.sort()\r\nc = n*3-m*3\r\nq = (0, 0)\r\nfor i, j in d:\r\n if j == 1:\r\n a += 1\r\n else:\r\n b += 1\r\n x = a*2 + (n-a)*3 - b*2 - (m-b)*3\r\n if c < x:\r\n c = x\r\n q = (a, b)\r\nx = q[0]*2 + (n-q[0])*3\r\ny = q[1]*2 + (m-q[1])*3\r\nprint(f'{x}:{y}')\r\n" ]
{"inputs": ["3\n1 2 3\n2\n5 6", "5\n6 7 8 9 10\n5\n1 2 3 4 5", "5\n1 2 3 4 5\n5\n6 7 8 9 10", "3\n1 2 3\n3\n6 4 5", "10\n1 2 3 4 5 6 7 8 9 10\n1\n11", "10\n1 2 3 4 5 6 7 8 9 11\n1\n10", "3\n1 2 3\n3\n1 2 3", "3\n1 2 3\n3\n3 4 5", "4\n2 5 3 2\n4\n1 5 6 2", "2\n3 3\n3\n1 3 3", "3\n1 1 1\n4\n1 3 1 1", "4\n4 2 1 1\n4\n3 2 2 2", "3\n3 9 4\n2\n10 1", "14\n4336 24047 24846 25681 28597 30057 32421 34446 48670 67750 68185 69661 85721 89013\n30\n8751 10576 14401 22336 22689 35505 38649 43073 43176 44359 44777 50210 50408 51361 53181 60095 65554 68201 68285 68801 72501 75881 80251 80509 83306 93167 95365 95545 97201 97731", "1\n1\n2\n1 2", "18\n450 3726 12063 27630 29689 30626 33937 35015 45951 46217 53004 59541 75551 75836 78996 81297 93876 96211\n47\n3393 5779 6596 7935 9549 10330 11145 13121 14801 15578 24104 24125 25871 31280 35036 38969 40077 41342 42708 46033 47491 48451 49152 51905 55002 55689 56565 57901 59481 60017 66075 67081 68397 71122 74961 78501 84098 87083 87893 89281 89739 90321 92046 95821 96717 96921 96951", "3\n3 3 4\n6\n2 2 3 3 3 3", "3\n2 2 2\n3\n1 1 1", "2\n2 2\n2\n2 2", "1\n7\n6\n6 7 8 9 10 11", "1\n1\n2\n1 1", "3\n1 2 3\n1\n1", "3\n3 3 4\n6\n3 2 2 2 3 2", "1\n3\n1\n3", "1\n1\n5\n1 1 1 1 1", "2\n1 999999999\n2\n2 4"], "outputs": ["9:6", "15:10", "15:15", "9:9", "30:3", "30:3", "9:9", "9:9", "12:11", "6:8", "6:8", "9:8", "9:5", "28:60", "2:4", "36:94", "7:12", "9:6", "6:6", "2:12", "2:4", "9:3", "9:14", "3:3", "2:10", "5:4"]}
UNKNOWN
PYTHON3
CODEFORCES
41
dfdb6ca43f21c375705818cab533efac
Follow Traffic Rules
Everybody knows that the capital of Berland is connected to Bercouver (the Olympic capital) by a direct road. To improve the road's traffic capacity, there was placed just one traffic sign, limiting the maximum speed. Traffic signs in Berland are a bit peculiar, because they limit the speed only at that point on the road where they are placed. Right after passing the sign it is allowed to drive at any speed. It is known that the car of an average Berland citizen has the acceleration (deceleration) speed of *a* km/h2, and has maximum speed of *v* km/h. The road has the length of *l* km, and the speed sign, limiting the speed to *w* km/h, is placed *d* km (1<=≤<=*d*<=&lt;<=*l*) away from the capital of Berland. The car has a zero speed at the beginning of the journey. Find the minimum time that an average Berland citizen will need to get from the capital to Bercouver, if he drives at the optimal speed. The car can enter Bercouver at any speed. The first line of the input file contains two integer numbers *a* and *v* (1<=≤<=*a*,<=*v*<=≤<=10000). The second line contains three integer numbers *l*, *d* and *w* (2<=≤<=*l*<=≤<=10000; 1<=≤<=*d*<=&lt;<=*l*; 1<=≤<=*w*<=≤<=10000). Print the answer with at least five digits after the decimal point. Sample Input 1 1 2 1 3 5 70 200 170 40 Sample Output 2.500000000000 8.965874696353
[ "import math\r\ndef getdt():\r\n return map(int, input().split())\r\ndef calc(v0, v, a, x):\r\n t = (v - v0) / a\r\n x0 = v0 * t + 0.5 * a * t * t\r\n if x0 >= x:\r\n return (x, (math.sqrt(v0 * v0 + 2 * a * x) - v0) / a)\r\n return (x0, t)\r\ndef go(v0, v, a, x):\r\n x0, t = calc(v0, v, a, x)\r\n return t + (x - x0) / v\r\na, v = getdt()\r\nl, d, w = getdt()\r\nif w > v:\r\n w = v\r\nx, t = calc(0, w, a, d)\r\nif x == d:\r\n print(go(0, v, a, l))\r\nelse:\r\n print(t + go(w, v, a, (d - x) * 0.5) * 2 + go(w, v, a, l - d))\r\n", "from math import sqrt\r\n\r\na, v = map(int, input().split())\r\nl, d, w = map(int, input().split())\r\n\r\ndef findt(u, v, a, dist):\r\n\tfront = (v*v-u*u)/(2*a)\r\n\tif front > dist:\r\n\t\treturn (sqrt(u*u+2*a*dist)-u)/a\r\n\treturn (v-u)/a + (dist-front)/v\r\n\r\ndef solve(a, v, l, d, w):\r\n\tif v <= w or 2*a*d <= w*w:\r\n\t\treturn findt(0, v, a, l)\r\n\tafter = findt(w, v, a, l-d)\r\n\tpeak = sqrt(a*d + w*w/2)\r\n\tif peak > v:\r\n\t\ttravel = (v*v-w*w/2)/a\r\n\t\tbefore = (2*v-w)/a + (d-travel)/v\r\n\telse:\r\n\t\tbefore = (2*peak-w)/a\r\n\treturn before + after\r\n\r\nprint(f'{solve(a, v, l, d, w):.8f}')", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sun Mar 4 22:28:47 2018\r\n\r\n@author: hp\r\n\"\"\"\r\n\r\n[a,v] = [eval(x) for x in str.split(input())]\r\n[l,d,w] = [eval(x) for x in str.split(input())]\r\n\r\nif v <= w:\r\n if v ** 2 >= 2 * a *l:\r\n #accer all the way\r\n t = (2 * l / a) ** 0.5\r\n else:\r\n #accer to v,then drive with v\r\n s1 = v ** 2 / (2 * a)\r\n t1 = v / a\r\n s2 = l - s1\r\n t2 = s2 / v\r\n t = t1 + t2\r\nelse:\r\n if w ** 2 >= 2 * a * d:\r\n #accer all the way to d\r\n if v ** 2 >= 2 * a *l:\r\n #accer all the way\r\n t = (2 * l / a) ** 0.5\r\n else:\r\n #accer to v,then drive with v\r\n s1 = v ** 2 / (2 * a)\r\n t1 = v / a\r\n s2 = l - s1\r\n t2 = s2 / v\r\n t = t1 + t2\r\n else:\r\n if (2 * a * d + w ** 2) / 2 <= v ** 2:\r\n #drive to speed v1 and dec to w,after drive to d,then accer\r\n v1 = ((2 * a * d + w ** 2) / 2) ** 0.5\r\n t1 = v1 / a\r\n t2 = (v1 - w) / a\r\n else:\r\n #accer to v,then keep,then dec to w\r\n t1 = v / a + (v - w) / a\r\n t2 = (d - v ** 2 / (2 * a) - (v ** 2 - w ** 2) / (2 * a)) / v\r\n #judge if we can accer to v\r\n if v ** 2 - w ** 2 >= 2 * a * (l - d):\r\n #accer all the left\r\n t3 = ( -w + (w ** 2 + 2 * a * (l - d)) ** 0.5) / a\r\n t = t1 + t2 + t3\r\n else:\r\n #accert to v,then v\r\n t3 = (v - w) / a\r\n s3 = w * t3 + a * t3 ** 2 / 2\r\n t4 = (l - d - s3) / v\r\n t = t1 + t2 + t3 + t4\r\n \r\nprint(\"%.10f\" %(t))\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ", "import math\r\ndef getdt():\r\n return map(int,input().split())\r\ndef calc(v0,v,a,x):\r\n t = (v - v0)/a\r\n x0 = v0 * t + 0.5*a*t*t\r\n if x0>=x:\r\n return (x,(math.sqrt(v0*v0 + 2*a*x)-v0)/a)\r\n return (x0,t)\r\ndef go(v0,v,a,x):\r\n x0,t = calc(v0,v,a,x)\r\n return t + (x-x0)/v\r\na,v = getdt()\r\nl,d,w = getdt()\r\nif w>v:\r\n w = v\r\nx,t = calc(0,w,a,d)\r\nif x==d:\r\n print(go(0,v,a,l))\r\nelse:\r\n print(t+go(w,v,a,(d-x)*0.5) * 2 + go(w,v,a,l-d))\r\n", "a,v=map(int,input().split())\nl,d,w=map(int,input().split())\ndef p(v0,v,w,d,a):\n b=2*a*d+w**2\n S=(b-v0**2)/4/a\n r=[[0,d],[0,0,0],v]\n V1=(2*a*S+v0**2)**.5\n if S < d and v >= V1:\n return([(V1-v0+V1-w)/a],w)\n else:\n S=(v**2-v0**2)/2/a\n if S <= d:\n r[0][0]=S\n r[1][0]=(v-v0)/a\n else:\n V1=(2*a*d+v0**2)**.5\n return ([(V1-v0)/a],V1)\n S=(b-v**2)/2/a\n if S < d:\n r[0][1]=S\n r[1][2]=(v-w)/a\n r[2]=w\n r[1][1]=(r[0][1]-r[0][0])/v\n return([r[1],r[2]])\nc=p(0, v, w, d, a)\nprint(sum(c[0]+p(c[1],v,v,l-d,a)[0]))\n\n\n", "import math\r\na0,v0=input().split()\r\na,v,t=float(a0),float(v0),0#a为车的最大加速度 v为车的最大速度\r\nl0,d0,w0=input().split()\r\nl,d,w=float(l0),float(d0),float(w0)#l,d,w分别为总路程、限速牌距离起点的距离、限制速度\r\n#在限制点后直接以最大加速度行驶即可\r\n#在限制点前,汽车可能一直加速,也可能先加速后减速,临界状况在 min(v,w)^2=2*a*d\r\nif v>w:\r\n if w**2>=2*a*d:#一直加速到限制点即可的情况\r\n t+=math.sqrt(2*a*d)/a\r\n v_now=math.sqrt(2*a*d)\r\n else:#先加速到达w\r\n t+=w/a#加速时间\r\n v_now=w\r\n if (v**2-w**2)/a<=(d-v_now**2/(2*a)):#可以直接先加速到v再匀速最后减速到w的情况\r\n t+=2*(v-w)/a#加速\r\n t+=(d-v_now**2/(2*a)-(v**2-w**2)/a)/v#匀速\r\n else:\r\n #最大速度计算:a*(d-(w**2/(2*a)))=vm**2-w**2\r\n vm=math.sqrt((w**2+a*(d-(v_now**2/(2*a)))))\r\n t+=2*((vm-w)/a)\r\n if v**2-v_now**2>2*a*(l-d):#后程一直加速的情况\r\n t+=(math.sqrt(v_now**2+2*a*(l-d))-v_now)/a\r\n else:\r\n t+=(v-v_now)/a#加速时间\r\n t+=(l-d-(v**2-v_now**2)/(2*a))/v#匀速时间\r\nelse:#v<w的情况,只需要一直加速后匀速即可\r\n if v**2/(2*a)>=l:#一直加速\r\n t+=math.sqrt(2*l/a)\r\n else:\r\n t+=v/a#加速\r\n t+=(l-v**2/(2*a))/v#匀速\r\nprint('%.5f'%t)", "\"\"\"\nCodeforces\n5D - Follow Traffic Rules\nhttp://codeforces.com/contest/5/problem/D\n\nHéctor González Belver\n../07/2018\n\"\"\"\nimport sys\n\ndef time_distance(v0, a, d):\n #quadratic equation. Time is positive ==> root with (+discriminant) in quadratic formula\n #d = v0*t + (a/2)*t^2\n return (-v0 + (v0**2 + 2*a*d)**0.5)/a\n\ndef time_accelerating(v0, v1, a):\n return (v1 - v0)/a\n\ndef time_speed(v, d):\n return d/v\n\ndef distance_travelled(v0, t, a):\n return v0*t + (a/2)*t**2\n \ndef main():\n a, v = map(int,sys.stdin.readline().strip().split())\n l, d, w = map(int,sys.stdin.readline().strip().split())\n\n time = 0\n\n time_to_d = time_distance(0, a, d)\n time_to_v = time_accelerating(0, v, a)\n\n if (v if time_to_v <= time_to_d else time_to_d * a) <= w:\n #Accelerating 0-v\n acceleration_time = time_to_v\n acceleration_distance = distance_travelled(0, acceleration_time, a)\n\n if acceleration_distance >= l:\n #Accelerating 0-?\n time = time_distance(0, a, l)\n else:\n #Accelerating 0-v\n time = acceleration_time\n #Max speed v\n time += time_speed(v, l - acceleration_distance)\n\n else: \n if time_to_v <= time_to_d:\n #Accelerating 0-v\n acceleration_time = time_to_v\n acceleration_distance = distance_travelled(0, acceleration_time, a)\n\n #Decelerating v-w\n deceleration_time = time_accelerating(v, w, -a)\n deceleration_distance = distance_travelled(v, deceleration_time, -a)\n \n if time_to_v > time_to_d or acceleration_distance + deceleration_distance > d:\n #Accelerating 0-w\n acceleration_time = time_accelerating(0, w, a)\n acceleration_distance = distance_travelled(0, acceleration_time, a)\n \n remaining_distance = d - acceleration_distance\n #Remaining distance --> Acceleration = -Deceleration ==> half remaining distance each action \n delta_time = time_distance(w, a, remaining_distance/2)\n #Accelerating 0-? and Decelerating ?-w\n time = acceleration_time + 2*delta_time\n else:\n #Accelerating 0-v\n time = time_to_v\n #Max speed v\n time += time_speed(v, d - deceleration_distance - acceleration_distance)\n #Decelerating v-w\n time += deceleration_time\n \n #Accelerating w-v\n acceleration_time = time_accelerating(w, v, a)\n acceleration_distance = distance_travelled(w, acceleration_time, a)\n if acceleration_distance >= l - d:\n #Accelerating w-?\n time += time_distance(w, a, l - d)\n else:\n #Accelerating w-v\n time += acceleration_time\n #Max speed v\n time += time_speed(v, l - (d + acceleration_distance))\n \n sys.stdout.write('{0:.5f}'.format(time) + '\\n')\n\nif __name__ == '__main__': \n main()", "import math\r\n\r\n\r\ndef main():\r\n a, v = map(int, input().split())\r\n l, d, w = map(int, input().split())\r\n\r\n if v < w:\r\n if l < 1 / 2 * v ** 2 / a:\r\n t = math.sqrt(2 * l / a)\r\n else:\r\n t = v / a + (l - 1 / 2 * v ** 2 / a) / v\r\n else:\r\n t = 0\r\n v_lower = 1000000\r\n if d < 1 / 2 * w ** 2 / a:\r\n t += math.sqrt(2 * d / a)\r\n v_lower = a * math.sqrt(2 * d / a)\r\n elif d > 1 / 2 * v ** 2 / a + (v + w) * (v - w) / a / 2:\r\n t = v / a + (d - 1 / 2 * v ** 2 / a - (v + w) * (v - w) / a / 2) / v + (v - w) / a\r\n else:\r\n t_ = math.sqrt(1 / 2 * w ** 2 / a ** 2 + d / a)\r\n t += 2 * t_ - w / a\r\n remaining = l - d\r\n w = min(w, v_lower)\r\n if remaining < (v + w) * (v - w) / a / 2:\r\n t += (-w + math.sqrt(w ** 2 + 2 * a * remaining)) / a\r\n else:\r\n t += (v - w) / a + (remaining - (v + w) * (v - w) / a / 2) / v\r\n\r\n print(f\"{t:.6f}\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "import logging\r\nlogging.basicConfig(level=logging.INFO)\r\n\r\ndef readintGenerator():\r\n\twhile (True):\r\n\t\tn=0\r\n\t\ttmp=list(map(lambda x:int(x), input().split()))\r\n\t\tm=len(tmp)\r\n\t\twhile (n<m):\r\n\t\t\tyield(tmp[n])\r\n\t\t\tn+=1\r\n\t\r\nreadint=readintGenerator()\r\na=next(readint)\r\nv=next(readint)\r\nl=next(readint)\r\nd=next(readint)\r\nw=next(readint)\r\n\r\ndef sqrt(x): return x**0.5\r\n\r\ndef cost(v0,l,v,a):\r\n\ts0=(v**2 - v0**2)/(2*a)\r\n\tif (s0<=l):\r\n\t\treturn (v-v0)/a + (l-s0)/v\r\n\telse:\r\n\t\tv1=sqrt(v0**2+2*a*l)\r\n\t\treturn (v1-v0)/a\r\n\t\r\ndef calc(a,v,l,d,w):\r\n\tif (v<=w):\r\n\t\treturn cost(0,l,v,a)\r\n\telse:\r\n\t\tv0=sqrt(2*a*d)\r\n\t\tif (v0<=w):\r\n\t\t\treturn cost(0,l,v,a)\r\n\t\telse:\r\n\t\t\tv1=sqrt((2*a*d+w**2)/2)\r\n\t\t\tt0=(2*v1-w)/a\r\n\t\t\tif (v1<=v):\r\n\t\t\t\treturn t0+cost(w,l-d,v,a)\r\n\t\t\telse:\r\n\t\t\t\tt0=(d+(2*v**2-2*v*w+w**2)/(2*a))/v\r\n\t\t\t\treturn t0+cost(w,l-d,v,a)\r\n\t\r\nprint(\"%.8f\" %calc(a,v,l,d,w))\r\n", "a,v=map(int,input().split())\r\nl,d,w=map(int,input().split())\r\nt=0\r\ndef gett(a,b,c):\r\n delta=b**2-4*a*c\r\n t1=(-b+delta**(1/2))/(2*a)\r\n t2=(-b-delta**(1/2))/(2*a)\r\n if min(t1,t2)>0:\r\n return min(t1,t2)\r\n else:\r\n return max(t1,t2)\r\nif 2*a*d<=w*w or v<=w:\r\n if 2*a*l<=v*v:\r\n t=(2*l/a)**(1/2)\r\n else:\r\n t=l/v+v/a/2\r\nelse:\r\n tmp=d-1/2*v*v/a+1/2*(v-w)**2/a-v*(v-w)/a\r\n if tmp<=0:\r\n tmp2=l-d-(1/2*(v-w)**2/a+w*(v-w)/a)\r\n if tmp2>=0:\r\n t=tmp2/v+(v-w)/a+2*gett(a,2*w,w*w/(2*a)-d)+w/a\r\n else:\r\n t=gett(a/2,w,d-l)+2*gett(a,2*w,w*w/(2*a)-d)+w/a\r\n else:\r\n tmp2=l-d-(1/2*(v-w)**2/a+w*(v-w)/a)\r\n if tmp2>=0:\r\n t=tmp2/v+(v-w)/a+(2*v-w)/a+tmp/v\r\n else:\r\n t=gett(a/2,w,d-l)+(2*v-w)/a+tmp/v\r\nprint(\"%.12f\" %(t))", "import math\r\n\r\n\r\ndef initial_calc_time(init_velocity, v, a, x):\r\n t = (v - init_velocity)/a\r\n init_distance = init_velocity * t + 0.5*a*t*t\r\n if init_distance >= x:\r\n return (x, (math.sqrt(init_velocity*init_velocity + 2*a*x)-init_velocity)/a)\r\n return (init_distance, t)\r\n\r\n\r\ndef calc_time(init_velocity, v, a, x):\r\n init_distance, t = initial_calc_time(init_velocity, v, a, x)\r\n return t + (x-init_distance)/v\r\n\r\n\r\na, v = map(int, input().split())\r\nl, d, w = map(int, input().split())\r\n\r\nif w > v:\r\n w = v\r\nx, t = initial_calc_time(0, w, a, d)\r\n\r\nif x == d:\r\n print(\"%.5f\" % calc_time(0, v, a, l))\r\nelse:\r\n print(\"%.5f\" % (t+calc_time(w, v, a, (d-x)*0.5) * 2 + calc_time(w, v, a, l-d)))\r\n", "a,v = map(int,input().split())\r\nl,d,w = map(int,input().split())\r\n\r\nif v<=w or (w*w/2/a)>=d:\r\n if (v*v/2/a)<=l: print(l/v+v/2/a)\r\n else: print((2*l/a)**.5)\r\nelse:\r\n if ((2*v*v-w*w)/2/a)<=d: left = (v-w)/a+d/v+w*w/2/a/v\r\n else: left = (2*(a*d+w*w/2)**.5-w)/a \r\n if (v*v-w*w)/2/a<=l-d: right = (v-2*w)/2/a+(l-d)/v+w*w/2/a/v\r\n else: right = ((2*a*(l-d)+w*w)**.5-w)/a\r\n print(left+right) ", "import math\r\nfrom sys import stdin\r\ninput = stdin.buffer.readline\r\n\r\ndef calc(v0, mx, a, x):\r\n t = (mx - v0) / a\r\n x0 = v0 * t + 0.5 * a * t * t\r\n if x0 >= x: return (x, (math.sqrt(v0 * v0 + 2 * a * x) - v0) / a)\r\n return (x0, t)\r\n\r\ndef go(v0, mx, a, x):\r\n x0, t = calc(v0, mx, a, x)\r\n return t + (x - x0) / mx\r\n\r\na, mx = map(int, input().split())\r\nn, p, lim = map(int, input().split())\r\nlim = min(lim, mx)\r\nx, t = calc(0, lim, a, p)\r\nif x == p: print(go(0, mx, a, n))\r\nelse: print(t + go(lim, mx, a, (p - x) * 0.5) * 2 + go(lim, mx, a, n - p))" ]
{"inputs": ["1 1\n2 1 3", "5 70\n200 170 40", "6 80\n100 50 10", "7 80\n100 50 50", "8 80\n100 50 199", "200 1000\n3 2 1", "200 1000\n3 2 10000", "200 1000\n1000 500 1023", "200 1000\n1000 999 10", "20 40\n10000 1 30", "20 40\n10000 799 30", "20 40\n9958 9799 30", "9998 9999\n3 2 1", "9998 9999\n3 2 6580", "9998 9999\n800 40 10000", "9998 9999\n800 516 124", "4 120\n5112 3000 130", "4 120\n5112 3000 113", "9000 1\n10000 9999 1", "2 10000\n270 64 16", "2 20\n270 64 16", "2 16\n270 64 16", "2000 10000\n8000 4000 4000", "2000 4000\n8000 4000 4000", "2000 10\n8000 4000 4000", "7143 4847\n4193 2677 1991", "5744 5873\n3706 1656 8898", "7992 3250\n9987 6772 5806", "240 4275\n6270 1836 6361", "5369 9035\n1418 879 3344", "7062 9339\n2920 1289 8668", "8755 9643\n1193 27 3992", "448 3595\n2696 1020 5667", "2141 3899\n968 262 991", "3834 4202\n2471 607 6315", "5527 8154\n3974 3550 1639", "7220 8458\n2246 1326 6963", "8914 8762\n3749 1899 2287", "607 2714\n2021 1483 3963", "9788 8432\n2795 2025 3436", "26 12\n17 13 29", "12 42\n6 5 19", "50 22\n42 1 12", "38 3\n47 16 4", "24 33\n35 2 45", "11 13\n24 15 37", "49 43\n12 6 30", "35 23\n17 12 20", "23 4\n5 2 13", "8 28\n22 4 29", "38 35\n16 12 38", "21 41\n26 18 47", "2 50\n21 1 6", "32 7\n15 6 17", "15 13\n10 3 26", "46 20\n4 2 35", "26 28\n46 9 44", "9 35\n41 22 3", "39 42\n35 19 12", "28 24\n31 13 21"], "outputs": ["2.500000000000", "8.965874696353", "7.312347829731", "5.345224838248", "5.000000000000", "0.290249882934", "0.173205080757", "3.162277660168", "4.482261988326", "251.000000000000", "251.125000000000", "250.075000000000", "0.042231317453", "0.024497347285", "0.400040006001", "0.668565367679", "57.600000000000", "57.702083333333", "10000.000055555556", "16.431676725155", "18.500000000000", "20.875000000000", "2.828427124746", "3.000000000000", "800.002500000000", "1.438097228927", "1.142252435725", "3.276251405251", "7.228416147400", "0.726785762909", "0.909374070882", "0.522044043034", "3.469252698452", "0.967126013479", "1.136044961574", "1.555031897139", "0.788771617656", "1.172208101814", "2.580499677039", "0.863942827831", "1.647435897436", "1.000000000000", "2.129090909091", "15.706140350877", "1.748106060606", "2.437062937063", "0.699854212224", "1.078881987578", "1.336956521739", "2.345207879912", "0.917662935482", "1.573591584939", "4.582575694956", "2.252232142857", "1.202564102564", "0.417028828114", "2.181318681319", "4.577276992968", "1.803482716151", "1.733630952381"]}
UNKNOWN
PYTHON3
CODEFORCES
13
dff35cfccaed3049a7d8dbccfbbaef3d
Divisibility
Find the number of *k*-divisible numbers on the segment [*a*,<=*b*]. In other words you need to find the number of such integer values *x* that *a*<=≤<=*x*<=≤<=*b* and *x* is divisible by *k*. The only line contains three space-separated integers *k*, *a* and *b* (1<=≤<=*k*<=≤<=1018;<=-<=1018<=≤<=*a*<=≤<=*b*<=≤<=1018). Print the required number. Sample Input 1 1 10 2 -4 4 Sample Output 10 5
[ "print((lambda x : (x[2]//x[0])-((x[1]-1)//x[0]))(list(map(int,input().split()))))", "k,a,b = list(map(int,input().split(\" \")))\r\na -= 1\r\nprint(b//k-a//k)", "inD = str(input()).split()\r\ninD = [int(val) for val in inD]\r\nk = inD[0]\r\na = inD[1]\r\nb = inD[2]\r\nN = 0\r\na = a - k if a % k == 0 else a - a % k\r\nb = b - b % k\r\nN = (b - a) // k\r\nprint(N)\r\n\r\n\r\n\r\n\r\n", "k,a,b = map(int, input().split())\r\nans = 0\r\nif a% k == 0:\r\n ans = 1\r\na += k - a%k\r\nb -= b %k;\r\nif b >= a:\r\n ans += (b - a) // k + 1\r\nprint(ans)", "k, a, b = map(int, input().split())\r\nif(a % k != 0):\r\n x = k - (a % k) + a\r\n y = b - (b % k)\r\nelse:\r\n x = a\r\n y = b\r\nif(x > b or x < a or y > b or y < a):\r\n print (0)\r\nelse:\r\n print ((y - x) // k + 1)\r\n", "k, a, b = map(int, input().split())\n\nprint( (b // k) - ((a - 1) // k)\n\t)\n", "k, a, b = map(int, input().split())\r\nans = 0\r\nif b < 0:\r\n a *= -1\r\n b *= -1\r\n (b, a) = (a, b)\r\nif a > 0 and b >= 0:\r\n ans += b // k - (a - 1) // k\r\nelse:\r\n ans += b // k\r\n ans += 1\r\n ans += (-a)//k\r\n \r\nprint(ans)", "def f(a, b, k):\r\n if a == 0:\r\n res = b // k + 1\r\n else:\r\n res = b // k - (a - 1) // k\r\n return res\r\n\r\nk, a, b = [int(i) for i in input().split()]\r\nif b <= 0:\r\n res = f(-b, -a, k)\r\nelif a < 0:\r\n res = f(1, -a, k) + f(0, b, k)\r\nelse:\r\n res = f(a, b, k)\r\nprint(res)\r\n \r\n", "k, a, b = map(int, input().split())\r\n\r\ndef f(n):\r\n return n // k\r\n\r\nresult = f(b) - f(a-1)\r\nprint(result)\r\n", "k,a,b = (int(x) for x in input().split())\r\nprint(b//k-(a-1)//k)", "k,a,b=map(int,input().split())\r\nprint(b//k-(a-1)//k)\r\n", "#!/usr/bin/env python3\r\n#fileencoding: utf-8\r\n\r\ndef solver(n, k):\r\n return n // k\r\n\r\nk, a, b = map(int, input().strip().split())\r\n\r\nif k == 1:\r\n print(b-a+1)\r\nelif a == 0:\r\n print(solver(b, k)+1)\r\nelif a > 0:\r\n print(solver(b, k)-solver(a-1, k))\r\nelse:\r\n print(solver(b, k)+solver(-a, k)+1)\r\n", "import math\r\n\r\ndef main():\r\n k, a, b = map(int, input().split())\r\n\r\n low = (a+k-1)//k\r\n big = b//k\r\n\r\n ans = big - low+1\r\n\r\n # if a<0 and b>0:\r\n # ans += 1\r\n print(int(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\nif __name__ == '__main__':\r\n main()\r\n", "k,a,b=map(int,input().split())\r\nif a>=0 and b>=0 :\r\n ans1 = b//k # de 0 à b\r\n ans2 = a//k # de 0 à a\r\n if a % k == 0:\r\n ans = ans1 - ans2 +1\r\n else :\r\n ans = ans1 - ans2\r\nelif a <= 0 and b <= 0:\r\n a=-a\r\n b=-b\r\n a,b=b,a\r\n ans1 = b//k # de 0 à b\r\n ans2 = a//k # de 0 à a\r\n if a % k == 0:\r\n ans = ans1 - ans2 +1\r\n else :\r\n ans = ans1 - ans2\r\nelse:\r\n ans1 = b//k +1\r\n a=-a\r\n ans2 = a //k\r\n ans =ans1+ans2 \r\n \r\nprint(ans)", "k,a,b=input().split(' ')\r\nk=int(k)\r\na=int(a)\r\nb=int(b)\r\nif a%k!=0 :\r\n a=a+k-a%k\r\nprint(max(0,1+(b-a)//k))", "k,x,y=map(int,input().split())\r\nprint(y//k-(x-1)//k)\r\n", "# your code goes here\r\nk, a, b = map(int, input().split())\r\n#//=floor division\r\nfloor_a = a//k\r\nfloor_b = b//k\r\nans = floor_b - floor_a\r\nif a%k==0:\r\n ans += 1\r\nprint(ans)", "a=input().split()\r\n\r\nif int(a[1])%int(a[0])==0:\r\n b=int(a[1])\r\nelse:\r\n b=int(a[1])-int(a[1])%int(a[0])+int(a[0])\r\nc=int(a[2])-int(a[2])%int(a[0])\r\n\r\nprint((c-b)//int(a[0])+1)\r\n", "c,a,b=map(int,input().split())\nif a%c==0:\n d=int(b//c)-int(a//c)+1\nelse:\n d=int(b//c)-int(a//c)\nprint(d)", "(k,a,b)=map(int, input().split())\r\nprint(b//k-(a-1)//k)", "k,a,b=map(int,input().split())\r\nif (a>=0 and b>=0) or (a<0 and b<0):\r\n if a<0 and b<0:\r\n temp=-b\r\n b=-a\r\n a=temp\r\n c=b//k-a//k\r\n if a%k==0:\r\n c+=1\r\nelif a<0 and b>=0:\r\n a=-a\r\n c=a//k+b//k+1\r\nprint(c)\r\n \r\n", "k,a,b = map(int, input().split())\r\nprint(b//k-(a-1)//k)", "k, a, b = map(int, input().split())\r\nif (a >= 0 and b > 0) or (a < 0 and b <= 0):\r\n print(max(abs(a), abs(b)) // k - ((min(abs(a), abs(b))) - 1) // k)\r\nelse:\r\n print(abs(a) // k + abs(b) // k + 1)", "k, a, b = map(int, input().split())\r\nans = 0\r\nif a < 0 and b <= 0:\r\n a, b = abs(b), abs(a)\r\nif a > 0 and a % k:\r\n a = a + k - a % k\r\n if a <= b:\r\n ans += ((b - a) // k + 1)\r\nelif a >= 0:\r\n ans += ((b - a) // k + 1)\r\nelif a < 0 and abs(a) % k:\r\n a = abs(a) - abs(a) % k\r\n ans += (a // k + 1)\r\n ans += (b // k)\r\nelif a < 0:\r\n ans += (abs(a) // k + 1)\r\n ans += (b // k)\r\nprint(ans)", "k, a, b = list(map(int, input().split()))\r\n\r\n\r\nif a == b and a % k == 0:\r\n print(1)\r\nelse:\r\n total = 0\r\n if a % k == 0:\r\n total = 1\r\n \r\n else:\r\n a -= a % k\r\n \r\n total += (b - a) // k\r\n print(total)", "k, a, b = map(int, input().split())\r\nf = (a + k - 1) // k\r\nl = b // k\r\nprint(l - f + 1)\r\n", "k, a, b = map(int, input().split())\r\n\r\nif a < 0 and b > 0:\r\n print(-a // k + b // k + 1)\r\nelif a > 0 and b > 0:\r\n print(b // k - (a - 1) // k)\r\nelif a < 0 and b < 0:\r\n print(-a // k - (-b - 1) // k)\r\nelif a < 0 and b == 0:\r\n print(-a // k + 1)\r\nelif b > 0 and a == 0:\r\n print(b // k + 1)\r\nelse:\r\n print(1)\r\n", "import math\r\ninp = [int(i) for i in input().split()]\r\nfactor = inp[2] // inp[0]\r\nlimit = (inp[1] // inp[0] + 1) if inp[1] % inp[0] != 0 else (inp[1] // inp[0])\r\nprint(factor - limit + 1)\r\n", "k,a,b = [int(x) for x in input().split(\" \")]\r\na -= 1\r\nprint(b//k-a//k)", "k,a,b=map(int,input().split())\r\ncount = (b // k) - ((a - 1) // k)\r\nprint(count)", "k, a, b = map(int, input().split())\r\nprint(b//k - (a-1)//k)", "k, a, b = [int(i) for i in input().split()]\nif a % k != 0:\n a += k - a % k\nif (b - a + 1) % k == 0:\n print((b-a+1)//k)\nelse:\n print((b-a+1)//k+1)\n\n", "\"\"\"\nCodeforces Testing Round #12\n\nProblem 597A Divisibility\n\n@author yamaton\n@date 2015-11-11\n\"\"\"\n\nimport math\nimport random\nimport sys\n\nimport functools\n\n\ndef solve(k, a, b):\n return b // k - (a - 1) // k\n\n\ndef p(*args, **kwargs):\n return print(file=sys.stderr, *args, **kwargs)\n\n\ndef main():\n [k, a, b] = [int(i) for i in input().strip().split()]\n result = solve(k, a, b)\n print(result)\n\n\nif __name__ == '__main__':\n main()\n", "k, a, b = map(int, input().split())\nans = 0\nif b < 0:\n a *= -1\n b *= -1\n (b, a) = (a, b)\nif a > 0 and b >= 0:\n ans += b // k - (a - 1) // k\nelse:\n ans += b // k\n ans += 1\n ans += (-a)//k\n\nprint(ans)\n \n \n \n", "k,a,b = [int(c) for c in input().split()]\r\nprint(b//k-(a-1)//k)", "k,a,b = map(int,input().split())\r\nx = b//k - (a-1)//k \r\nprint(x)", "k,a,b=map(int,input().split())\r\nif a<=0 and b>=0:\r\n res=abs(a)//k+b//k+1\r\n print(res)\r\nelse:\r\n a,b=abs(a),abs(b)\r\n a,b=max(a,b),min(a,b)-1\r\n res=a//k-(b//k)\r\n print(res)", "k,a,b=map(int,input().split())\r\nif a>0:\r\n print(b//k-(a-1)//k)\r\nelif a==0:\r\n print(b//k+1)\r\nelif b<0:\r\n a=-a\r\n b=-b\r\n print(a//k-(b-1)//k)\r\nelif b==0:\r\n print(-a//k+1)\r\nelse:\r\n print(b//k+(-a)//k+1)", "from functools import reduce\nfrom operator import *\nfrom math import *\nfrom sys import setrecursionlimit\nsetrecursionlimit(10**7)\n#################################################\nk,a,b = map(int, input().split())\nprint(b//k - (a-1)//k)\n", "def delimost(k, a, b):\r\n return b // k - (a - 1) // k\r\n\r\n\r\nK, A, B = [int(j) for j in input().split()]\r\nprint(delimost(K, A, B))\r\n", "k, a, b = map(int, input().split())\n\nmax_divisible = b - (b % k)\nmin_divisible = a - (a % k)\nif a % k != 0:\n min_divisible += k\n\ncount = (max_divisible - min_divisible) // k + 1\nprint(count)\n", "k, a, b = map(int, input().split())\r\nif a % k:\r\n a += k - a % k\r\nb -= b % k\r\nprint(b // k - a // k + 1)", "c,a,b=map(int,input().split())\r\nif a%c==0:\r\n d=int(b//c)-int(a//c)+1\r\nelse:\r\n d=int(b//c)-int(a//c)\r\nprint(d)", "k,a,b=map(int,input().split())\r\nif a%k==0:\r\n print(abs((a//k)-(b//k))+1)\r\nelse:\r\n print(abs((a//k)-(b//k)))", "cin = lambda:map(int,input().split())\r\ndef solve():\r\n k,a,b = cin()\r\n print(b//k-(a-1)//k)\r\nsolve()", "k,a,b = [int(x) for x in input().split()]\r\nans = 0\r\nif(a <= 0 and b <= 0):\r\n a = -a\r\n b = -b\r\n a,b = b,a\r\nif(a <= 0 and b >=0 ):\r\n a = -a\r\n ans = b // k + a // k + 1\r\nelse :\r\n ans = b // k - ((a - 1) // k)\r\nprint(ans)", "from math import ceil,floor\r\nk,a,b=tuple(map(int,input().split()))\r\nx=(b-a)//k\r\nif b%k<a%k or a%k==0:\r\n x+=1\r\nprint(x)\r\n", "k, a, b = map(int, input().split())\nfirst = a // k * k\nif first < a: first += k\nlast = b // k * k\nif last > b: last -= k\n# print(first, last)\nif last < first:\n print(0)\nelif last == first:\n print(1)\nelse:\n print((last - first) // k + 1)\n", "k, l, r = [int(x) for x in input().split()]\r\nif (l <= 0) and (r <= 0):\r\n l, r = -r, -l\r\nif l == 0:\r\n print(r // k + 1)\r\nelif l < 0:\r\n print(r // k + 1 + (-l) // k)\r\nelse:\r\n print(r // k - (l - 1) // k)", "n=list(map(int, input().split()))\r\n\r\np=[n[1]//n[0], n[2]//n[0]]\r\n#3 cases if p[0]*n[0]<n[1] and p[1]*n[1]<n[2]:\r\nif p[0]*n[0]<n[1]:\r\n if p[1]*n[0]<n[2]:\r\n print(p[1]-p[0])\r\n else:\r\n print(p[1]-p[0])\r\nelse:\r\n if p[1]*n[0]<n[2]:\r\n print(p[1]-p[0]+1)\r\n else:\r\n print(p[1]-p[0]+1)", "import math\r\n\r\nx = [int(i) for i in input().split()]\r\nf = x[2] // x[0]\r\nl = (x[1] // x[0] + 1) if x[1] % x[0] != 0 else (x[1] // x[0])\r\nprint(f - l + 1)\r\n", "#!/usr/bin/python3\n\nk, a, b = map(int, input().split())\nprint((b // k) - (a - 1) // k)\n", "s = input()\r\nm = s.split(' ')\r\nk = int(m[0])\r\na = int(m[1])\r\nb = int(m[2])\r\nost = a % k\r\nif ost == 0:\r\n f2 = a\r\nelse:\r\n f2 = a + (k-ost)\r\nans = ((b-f2)//k)+1\r\nprint(ans)\r\n", "k, a, b = map(int, input().split())\r\nx, y = a - (a % k), b - (b % k)\r\nprint((y - x)//k + (1 if a % k == 0 else 0))\r\n", "import sys\r\n\r\n\r\nk, a, b = map(int, sys.stdin.readline().split())\r\n\r\nif a >= 0:\r\n\ta += k - 1\r\n\tr = a % k\r\nelse:\r\n\tr = -(-a % k)\r\na -= r\r\n\r\nif b >= 0:\r\n\tr = b % k\r\nelse:\r\n\tb -= k - 1\r\n\tr = -(-b % k)\r\nb -= r\r\n\r\ncount = ((b - a) // k) + 1\r\nprint(count)", "\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\n\r\nk, a, b = map(int, input().split())\r\n\r\nb1 = b//k * k\r\na1 = (a//k + (1 if a%k!=0 else 0))*k\r\nif b1 < a or a1 > b:\r\n print(0)\r\nelse:\r\n print((b1-a1)//k+1)", "k,a,b=map(int,input().split())\r\nif a%k==0:\r\n c=b//k - a//k+1\r\nelse:\r\n c = b//k - a//k\r\n \r\n \r\nprint(c)", "import sys\r\n\r\n# sys.stdin = open(\"1.in\", \"r\")\r\n\r\nk, a, b = map(int, input().split())\r\n\r\nprint(b//k - (a-1)//k)", "import sys\r\n\r\nk, a, b = [int(x) for x in sys.stdin.readline().split(\" \")]\r\n\r\ndef f(n):\r\n return n // k\r\n\r\nres = 0\r\nif a == 0 and b == 0:\r\n res = 1\r\nelif a < 0 and b == 0:\r\n res = f(-a) + 1\r\nelif a < 0 and b < 0:\r\n res = f(-a) - f(-b - 1)\r\nelif a < 0 and b > 0:\r\n res = f(-a) + 1 + f(b)\r\nelif a == 0 and b > 0:\r\n res = f(b) + 1\r\nelif a > 0 and b > 0:\r\n res = f(b) - f(a - 1)\r\n\r\nprint(res)\r\n", "import sys\r\n\r\nk, a, b = map(int, sys.stdin.readline().rsplit())\r\n\r\nm = a%k\r\nc = 0\r\nif m == 0 or k <= m + abs(b - a)%k:\r\n\tc += 1\r\nc += (abs(b - a))//k\r\n\r\nprint(c)", "\n\n\nk,a,b =map(int,input().split())\nprint(b//k-(a-1)//k)\n \t\t \t \t\t \t \t \t \t \t \t", "k,a,b=map(int,input().split())\r\na1= (a-1)// k\r\nb1= b // k\r\nprint(b1-a1)", "k,a,b = list(map(int,input().split()))\r\nif a%k!=0:\r\n n1 = a+k-(a%k)\r\nelse:\r\n n1 = a\r\nn2 = b-b%k\r\nn = ((n2-n1)//k)+1\r\nprint(n)", "k,a,b=map(int,input().split())\r\nprint( b//k - (a-1)//k )", "#!/usr/bin/env python3\r\n\r\nfrom decimal import *\r\n\r\nk, a, b = map(Decimal, input().strip().split(\" \"))\r\n\r\nif b <= 0:\r\n a, b = -b, -a\r\nsmall = (a / k).quantize(Decimal('1.'), rounding=ROUND_DOWN)\r\nlarge = (b / k).quantize(Decimal('1.'), rounding=ROUND_DOWN)\r\n\r\nif a % k == 0 or (a <= 0 and b >= 0):\r\n offset = Decimal(1)\r\nelse:\r\n offset = Decimal(0)\r\nprint(large - small + offset)", "k, a, b =map(int,input().split())\r\nc=(b//k)-(a-1)//k\r\nprint(c)", "k, a, b=input().split()\r\nk=int(k)\r\na=int(a)\r\nb=int(b)\r\nif a>0:\r\n if a%k==0:\r\n a-=1\r\n o=int(b//k-a//k)\r\nelse:\r\n o=int(abs(a)//k+b//k)+1\r\nprint(o)\r\n", "def solve(a, l, r):\r\n ans=0\r\n if r<0:\r\n l*=-1\r\n r*=-1\r\n l,r=r,l\r\n if r>=0:\r\n ans=r//a\r\n if l<=0:\r\n l*=-1\r\n ans+=l//a+1\r\n else:\r\n l-=1\r\n ans-=l//a\r\n return ans\r\n\r\n\r\na,l,r=map(int,input().split())\r\nprint(solve(a,l,r))\r\n", "k,a,b=map(int,input().split())\r\nu=b//k-(a-1)//k\r\nprint(u)", "k, a, b = map(int,input().split())\r\na_mod = k - (a%k)\r\nif(a%k):\r\n a += a_mod\r\nb -= b%k\r\nprint((b-a)//k + 1)", "k,a,b = map(int,input().split())\r\n\r\nfa = a//k * k\r\nif fa < a : fa += k\r\nfb = b//k * k\r\nif fb > b : fb -= k\r\nr = (fb-fa)//k + 1\r\nprint(r)\r\n", "k , a , b = map(int,input().split())\r\nprint(b//k - (a-1)//k)\r\n\r\n", "a,b,c=map(int,input().split())\r\nb+=[(a-abs(b)%a)*(abs(b)%a!=0),abs(b)%a][b<0]\r\nc-=[(a-abs(c)%a)*(abs(c)%a!=0),abs(c)%a][c>0]\r\nprint((c-b)//a+1)\r\n", "def solver(start, end, k):\r\n return (end//k) - ((start-1)//k)\r\n\r\nk, a, b = map(int, input().strip().split(\" \"))\r\nans = 0\r\nif a == 0 and b == 0:\r\n ans = 1\r\nelif a == 0 and b != 0:\r\n ans = solver(1, b, k) + 1\r\nelif a != 0 and b == 0:\r\n ans = solver(1, -a, k) + 1\r\nelif a < 0 and b < 0:\r\n ans = solver(-b, -a, k)\r\nelif a < 0 and b > 0:\r\n ans = solver(1, -a, k) + solver(1, b, k) + 1\r\nelse:\r\n ans = solver(a, b, k)\r\nprint(ans)", "k,a,b= map(int,input().split())\r\nprint(b//k-(a-1)//k)", "k, a, b = map(int, input().split())\r\nn1 = b//k\r\nn2 = (a-1)//k\r\nres = n1 - n2\r\nprint(res)\r\n\r\n", "k, a, b = map(int, input().split())\r\nprint(((k - a) // k) + 1 + ((b - k) // k))", "k,a,b=[int(e) for e in input().split()]\r\na+=k*10**19\r\nb+=k*10**19\r\nprint(b//k-(a-1)//k)", "k, a, b = map(int, input().strip().split())\r\nm = 0\r\nif k == 1:\r\n\tm = (b - a) + 1\r\nelse:\r\n\tif a % k != 0: a += (k - a % k)\r\n\tif b % k != 0: b -= (b % k)\r\n\tm = (b - a) // k\r\n\tif a % k < b % k or a % k == 0: m += 1\r\nprint(m)", "from sys import stdin\r\ninp = stdin.readline\r\n\r\nk, a, b = map(int, inp().split())\r\nnr = b-a+1\r\nrest = nr % k\r\nif (b-rest) % k + rest >= k:\r\n print(nr//k + 1)\r\nelse:\r\n print(nr//k)\r\n\r\n", "k, a, b = map(int, input().split())\nprint(b // k - ((a - 1) // k))", " \r\n\r\n \r\nk, a, b = map(int, input().split())\r\na += min(1, a%k)*(k - a%k)\r\n \r\nif a <= b: print(1 + (b - a)//k)\r\nelse: print(0)", "k, a, b = input().split(' ')\r\nk = int(k)\r\na = int(a)\r\nb = int(b)\r\nif (a == b) and (a % k == 0):\r\n print('1')\r\nelse:\r\n if (a * b > 0):\r\n a = abs(a)\r\n b = abs(b)\r\n if (a > b):\r\n tmp = a\r\n a = b\r\n b = tmp\r\n print((b // k) - ((a - 1) // k))\r\n elif (a * b < 0):\r\n if (a > 0):\r\n tmp = a\r\n a = b\r\n b = tmp\r\n print((b // k) + (abs(a) // k) + 1)\r\n else:\r\n a = abs(a)\r\n b = abs(b)\r\n if (a != 0):\r\n tmp = a\r\n a = b\r\n b = tmp\r\n print((b // k) + 1)\r\n", "k, a,b = map(int, input().split())\r\nadd = (int(2* 10**18) // k ) * k;\r\n\r\na += add\r\nb += add\r\n\r\nprint(b//k - (a-1)//k) \r\n", "k, a, b = map(int, input().split())\na = ((a - 1) // k + 1) * k\nb -= b % k\nprint(max(0, (b - a + 1) // k + (k != 1)))", "k, a, b = map(int, input().split())\r\nif a % k != 0:\r\n a += k - a % k\r\nb -= b % k\r\nif a <= b:\r\n print((b - a) // k + 1)\r\nelse:\r\n print(0)", "k,a,b=map(int,input().split())\nkk=k*2000000000000000000\na+=kk\nb+=kk\na-=1\nprint(b//k-a//k)", "X = input().split()\r\nk = int(X[0])\r\na = int(X[1])\r\nb = int(X[2])\r\nif a>0 and b >0:\r\n if a%k == 0:\r\n print(abs(b)//k - abs(a)//k +1)\r\n else:\r\n print(abs(b)//k - abs(a)//k)\r\nelif a<0 and b <0:\r\n if abs(b)%k == 0:\r\n print(abs(a)//k - abs(b)//k +1)\r\n else:\r\n print(abs(a)//k - abs(b)//k)\r\nelse:\r\n print(abs(b)//k + abs(a)//k + 1)\r\n", "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\n\r\nk,a,b = map(int, input().split())\r\n\r\nif a==0 or b==0:\r\n print(max(abs(a)//k,abs(b)//k)+1)\r\nelif a*b>0:\r\n a=abs(a)\r\n b=abs(b)\r\n if a>b:\r\n a,b=b,a\r\n print(abs(b)//k-abs(a-1)//k)\r\nelse:\r\n a=abs(a)\r\n b=abs(b)\r\n print(abs(a)//k+abs(b)//k+1)" ]
{"inputs": ["1 1 10", "2 -4 4", "1 1 1", "1 0 0", "1 0 1", "1 10181 10182", "1 10182 10183", "1 -191 1011", "2 0 0", "2 0 1", "2 1 2", "2 2 3", "2 -1 0", "2 -1 1", "2 -7 -6", "2 -7 -5", "2 -6 -6", "2 -6 -4", "2 -6 13", "2 -19171 1911", "3 123 456", "3 124 456", "3 125 456", "3 381 281911", "3 381 281912", "3 381 281913", "3 382 281911", "3 382 281912", "3 382 281913", "3 383 281911", "3 383 281912", "3 383 281913", "3 -381 281911", "3 -381 281912", "3 -381 281913", "3 -380 281911", "3 -380 281912", "3 -380 281913", "3 -379 281911", "3 -379 281912", "3 -379 281913", "3 -191381 -1911", "3 -191381 -1910", "3 -191381 -1909", "3 -191380 -1911", "3 -191380 -1910", "3 -191380 -1909", "3 -191379 -1911", "3 -191379 -1910", "3 -191379 -1909", "3 -2810171 0", "3 0 29101", "3 -2810170 0", "3 0 29102", "3 -2810169 0", "3 0 29103", "1 -1000000000000000000 1000000000000000000", "2 -1000000000000000000 1000000000000000000", "3 -1000000000000000000 1000000000000000000", "4 -1000000000000000000 1000000000000000000", "5 -1000000000000000000 1000000000000000000", "6 -1000000000000000000 1000000000000000000", "7 -1000000000000000000 1000000000000000000", "1 -1000000000000000000 -100000000000000000", "2 -1000000000000000000 -10000000000000000", "3 -1000000000000000000 -10218000000000000", "4 -1000000000000000000 -320110181919100", "5 -1000000000000000000 -402710171917", "6 -1000000000000000000 -6666666666", "7 -1000000000000000000 -77777777777778", "1000000000000000000 -1000000000000000000 1000000000000000000", "1000000000000000000 0 1000000000000000000", "1000000000000000000 1000000000000000000 1000000000000000000", "100000000000000321 1000000000000000000 1000000000000000000", "100000000000000321 -1000000000000000000 1000000000000000000", "1000000000000000000 0 0", "1000000000000000000 1 1", "1000000000000000000 -1 -1", "1000000000000000000 -2 -1", "142000000000000271 -228118171 -1382811", "1 1 1000000000000000000"], "outputs": ["10", "5", "1", "1", "2", "2", "2", "1203", "1", "1", "1", "1", "1", "1", "1", "1", "1", "2", "10", "10541", "112", "111", "111", "93844", "93844", "93845", "93843", "93843", "93844", "93843", "93843", "93844", "94098", "94098", "94099", "94097", "94097", "94098", "94097", "94097", "94098", "63157", "63157", "63157", "63157", "63157", "63157", "63157", "63157", "63157", "936724", "9701", "936724", "9701", "936724", "9702", "2000000000000000001", "1000000000000000001", "666666666666666667", "500000000000000001", "400000000000000001", "333333333333333333", "285714285714285715", "900000000000000001", "495000000000000001", "329927333333333334", "249919972454520226", "199999919457965617", "166666665555555556", "142846031746031746", "3", "2", "1", "0", "19", "1", "0", "0", "0", "0", "1000000000000000000"]}
UNKNOWN
PYTHON3
CODEFORCES
89
e002199dc05266707d905a6b35037cc1
Multiplication Table
Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1. You are given a positive integer *x*. Your task is to count the number of cells in a table that contain number *x*. The single line contains numbers *n* and *x* (1<=≤<=*n*<=≤<=105, 1<=≤<=*x*<=≤<=109) — the size of the table and the number that we are looking for in the table. Print a single number: the number of times *x* occurs in the table. Sample Input 10 5 6 12 5 13 Sample Output 2 4 0
[ "n,x=map(int,input().split())\r\n\r\nans=0\r\n\r\nfor i in range(1,n+1):\r\n if x%i==0 and x//i<=n:\r\n ans+=1 \r\nprint(ans)", "n,x=map(int,input().split())\r\ndem=0\r\nif x==1:\r\n print(\"1\")\r\n exit()\r\nfor i in range(1,n+1):\r\n if x%i==0 and int(x/i)<=n :\r\n dem=dem+1\r\nprint(dem)", "import math\r\nn, x = list(map(int, input().split()))\r\nnb = 0\r\nsq = int(math.sqrt(x))\r\nif sq**2 == x and sq<=n: # is square\r\n nb += 1\r\n# trig sup\r\ni = 1\r\nwhile i*i < x and i<n:\r\n if x%i == 0 and x//i <= n:\r\n nb += 2\r\n i += 1\r\nprint(nb)", "N, X = map(int, input().split())\nc = 0\nfor m in range(1, N+1) :\n if X%m==0 and X//m<=N :\n c += 1\nprint(c)\n", "n, x = list(map(int, input().rstrip().split()))\r\nans = 0\r\nfactors = []\r\n\r\nfor i in range(1, n + 1):\r\n if x % i == 0:\r\n factors.append(i)\r\n\r\nfor i in factors:\r\n if x / i in factors:\r\n ans += 1\r\n\r\nprint(ans)", "a,b=map(int,input().split())\r\nc=0\r\nfor x in range(1,a+1):\r\n if b%x==0 and b//x<=a:\r\n c+=1\r\nprint(c)", "#http://codeforces.com/problemset/problem/577/A\r\n\r\nn, x = map(int, input().split())\r\n\r\na = 0\r\n\r\nfor i in range(1, n + 1):\r\n if x % i == 0 and x/i <=n:\r\n a+=1\r\n\r\nprint(a)\r\n\r\n", "table_size, number = map(int, input().split())\n\nnumber_of_times = 0\nfor i in range(1, int(number ** 0.5) + 1):\n if number % i == 0:\n j = number // i\n if i <= table_size and j <= table_size:\n if i == j:\n number_of_times += 1\n else:\n number_of_times += 2\n\nprint(number_of_times)\n\n", "n,x = map(int,input().split())\n\ntot = 0\n\nfor i in range(1,n+1):\n if x%i==0:\n if x//i<=n:\n tot+=1\nprint(tot)\n\n", "n,x = map(int,input().split(\" \"))\r\ncount = 0\r\nfor i in range(1,n+1):\r\n if(x%i==0 and x//i<=n):\r\n count += 1\r\nprint(count)", "x, n = map(int, input().split())\n\ni = 1\ncount = 0\nwhile i * i <= n:\n if n % i == 0:\n if i <= x and n // i <= x:\n if i == n // i:\n count += 1\n else:\n count += 2\n i += 1\nif n == 1:\n print(int(1))\nelse:\n print(count)\n", "import bisect\r\nleft = lambda l,a : bisect.bisect_left(l,a) #returns index of value>=a\r\nright = lambda l,a : bisect.bisect_right(l,a) #returns index of value >a\r\nimport sys\r\ndef input(): return sys.stdin.readline().strip()\r\ndef getints(): return map(int,sys.stdin.readline().strip().split())\r\n\r\nn,x = getints()\r\nans = 0\r\nfor i in range(1,int(x**0.5)+1):\r\n if i<=n and x%i == 0 and x/i<=n:\r\n ans += 2 if i != x/i else 1\r\nprint(ans)", "n,x=map(int,input().split(' '))\r\nlst=[]\r\nval=0\r\nfor i in range (1,round(x**(1/2))+1):\r\n if x%i==0:\r\n lst.append([i,x//i])\r\nfor sub in lst:\r\n if sub[0]>n or sub[1]>n:\r\n continue\r\n else:\r\n if sub[0]==sub[1]:\r\n val +=1\r\n else:\r\n val +=2\r\n\r\nprint(val)\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n, x = map(int, input().split())\r\nfactors = 0\r\nfor i in range(1, int(x ** 0.5) + 1):\r\n if x % i == 0 and i <= n and x // i <= n:\r\n if i * i == x:\r\n factors = factors + 1\r\n else:\r\n factors = factors + 2\r\nprint(factors)", "import math\r\n(n, x) = map(int, input().split(' '))\r\nres = 0\r\nfor i in range(1, int(math.sqrt(x)) + 1):\r\n if x % i == 0 and i <= n and int(x/i) <= n:\r\n if i * i == x:\r\n res += 1\r\n else:\r\n res += 2\r\nprint(res)\r\n", "n , x = map(int,input().split())\r\ncnt = 0\r\nfor i in range(1,n+1):\r\n if x % i == 0 and x / i <= n:\r\n cnt += 1\r\nprint(cnt)", "n, x = map(int, input().split())\r\ns=0\r\nfor i in range(n):\r\n if x%(i+1)==0 and x//(i+1)<=n:\r\n s=s+1\r\nprint(s)", "a,b = list(map(int, input().split()))\r\n\r\ntotal = 0\r\n\r\nfor i in range(1,a+1):\r\n\tif b%i==0 and b/i<= a:\r\n\t\ttotal = total + 1\r\n\telse:\r\n\t\tpass\r\n\r\n\r\n\r\n\r\nprint(total)", "n,x=[int(i) for i in input().split()]\r\nsum=0\r\nfor i in range(1,n+1):\r\n if x%i==0 and x/i <= n:\r\n sum=sum+1\r\nprint(sum)", "n, x = map(int, input().split()); t=0\r\nif x>n**2:\r\n print(0)\r\nelse:\r\n for i in range(1, n+1):\r\n if x%i==0 and n*i>=x:\r\n t+=1\r\n print(t)", "a,b = list(map(int,input().split()))\r\nans = 0\r\nfor i in range(1,a+1):\r\n if b % i == 0 and b // i <= a:\r\n ans += 1\r\nprint(ans)\r\n", "n, x = list(map(int, input().split()))\r\ncounter = 0\r\nfor i in range(1, n + 1):\r\n if i ** 2 > x:\r\n break\r\n if i ** 2 == x:\r\n counter += 1\r\n elif x % i == 0 and x // i <= n:\r\n counter += 2\r\nprint(counter)\r\n", "n,x = map(int,input().split())\r\ncount =0\r\nfor i in range(1,n+1):\r\n if x%i == 0 and x//i <= n:\r\n count+=1\r\n \r\nprint(count)\r\n ", "n, x = map(int, input().split())\r\na = []\r\n\r\ncount = 0\r\ni = 1\r\n\r\nwhile i * i <= x:\r\n if x % i == 0 and i <= n and x // i <= n:\r\n if i != x // i:\r\n count += 2\r\n else:\r\n count += 1\r\n i += 1\r\n\r\nprint(count)\r\n", "n,x = input().split()\r\nn = int(n)\r\nx = int(x)\r\ni = 1\r\ncount = 0\r\nwhile i <= n:\r\n if x%i == 0 and x/i <= n:\r\n count += 1\r\n i += 1\r\nprint(count)", "n, x = map(int, input().split())\r\ncount = 0\r\nfor i in range(1, n+1):\r\n if x%i==0 and 1<=x//i<=n: count+=1\r\nprint(count)", "n, x = map(int, input().split())\r\n\r\nnm = 0\r\n\r\nif x <= n:\r\n nm +=1\r\n\r\nfor i in range(2, n+1):\r\n\r\n if x % i == 0 and x//i <= n:\r\n nm += 1\r\n\r\nprint(nm)", "n, x = map(int, input().split())\r\nres = 0\r\nfor i in range(1, n+1):\r\n if x%i==0 and n*i>=x:\r\n res = res+1\r\nprint(\"%d\" %res)\r\n", "# 5.7.16 A.Таблица умножения-2\n# https://stepik.org/lesson/296964/step/16?thread=solutions&unit=278692\n# codeforces: https://codeforces.com/problemset/problem/577/A\n\n\"\"\"\nA. Таблица умножения\nРассмотрим таблицу из n строк и n столбцов.\nИзвестно, что в клетке, образованной пересечением i-й строки и j-го столбца,\nзаписано число i × j. Строки и столбцы нумеруются с единицы.\n\nДано целое положительное число x.\nТребуется посчитать количество клеток таблицы, в которых находится число x.\n\nВходные данные\nВ единственной строке находятся числа n и x (1 ≤ n ≤ 10^5, 1 ≤ x ≤ 10^9) —\nразмер таблицы и число, которое мы ищем в таблице.\n\nВыходные данные\nВыведите единственное число:\nколичество раз, которое число x встречается в таблице.\n\nРешение задачи Youtube Patreon Boosty\n\n\"\"\"\n\nn, x = map(int, input().split())\nres = sum((x % i == 0 and x // i <= n) for i in range(1, n + 1))\nprint(res)\n", "n, x = list(map(int, input().split()))\r\nans = 0\r\nfor i in range(1, n+1):\r\n if x%i==0 and x/i<=n:\r\n ans += 1\r\nprint(ans)", "count = 0\r\ngrid_size, target = map(int, input().split())\r\nfor number in range(1, grid_size + 1):\r\n if target % number == 0 and target // number <= grid_size:\r\n # This formula gives us the factors of the target that do not fall out of the table's range!\r\n count += 1\r\nprint(count)", "n,x=[int(i)for i in input().split()]\r\nd=0\r\nfor i in range(1,n+1):\r\n if x%i==0 and x/i <=n :\r\n d+=1\r\nprint(d)", "n, x = map(int, input().split())\r\n\r\ncount = 0\r\nfor i in range(1, int(x**0.5) + 1):\r\n other = x//i\r\n if x%i == 0 and max(other, i) <= n:\r\n count += 1 if other != i else 0.5\r\n\r\nprint(int(2*count))", "x,y=list(map(int,input().split()))\r\ncount=0\r\nfor i in range(1,x+1):\r\n if y%i==0 and y//i<=x:\r\n count+=1\r\nprint(count)", "n,m=map(int,input().split())\r\ns=0\r\nfor i in range(1,n+1):\r\n if n*i>=m and m%i==0:\r\n s+=1\r\nprint(s)\r\n", "n,x=list(map(int,input().split()))\r\ns=0\r\nfor i in range(1,n+1):\r\n if x%i==0 and x//i<=n:\r\n #print(i,x//i)\r\n s+=1\r\nprint(s)\r\n", "a,b=map(int,input().split())\r\ntemp=a\r\ncount=0\r\nfor i in range(1,a+1):\r\n if b//i<=temp and b%i==0:\r\n count+=1\r\nprint(count)", "n, x = map(int, input().split())\nnum = 0\nfor i in range(1, n + 1):\n if x % i == 0:\n q = x // i\n if q <= n:\n num += 1\n\nprint(num)", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(1,n+1):\r\n if(m/i==m//i and m/i<=n):\r\n c+=1\r\nprint(c)", "a, b = map(int, input().split())\r\nd = 0\r\nc = 0\r\nif a >= b:\r\n c += 1\r\n\r\nfor i in range(2, a+1):\r\n if b / i <= a and b % i == 0:\r\n #print(i)\r\n c += 1\r\nprint(c)\r\n\n# Wed Dec 22 2021 18:37:20 GMT+0000 (Coordinated Universal Time)\n", "a,b=map(int,input().split())\r\ns=0\r\nfor i in range(1,a+1):\r\n if(b%i==0 and b//i<=a):\r\n s=s+1\r\nprint(s)", "n,k=map(int,input().split())\r\ncount=0\r\nfor i in range(1,n+1):\r\n if k//i<=n:\r\n if k%i==0:\r\n count+=1\r\nprint(count)\r\n", "l=list(map(int,input().split()))\r\nn=l[0]\r\nk=l[1]\r\ncount=0\r\nfor i in range(1,n+1):\r\n if (i<=k and k%i==0 and k/i<=n):\r\n count+=1\r\nprint(count)", "n, x = map(int, input().split())\r\ni = 1\r\nres = []\r\nwhile i*i<=x:\r\n if x%i==0 and x//i<=n:\r\n res.append(i)\r\n if i!=x//i:\r\n res.append(x//i)\r\n i+=1\r\nres.sort()\r\nprint(len(res))", "import math\r\na=list(map(int,input().split()))\r\nk=math.floor(math.sqrt(a[1]))\r\nc=0\r\nfor i in range(1,k+1):\r\n if a[1]%i==0 and a[1]//i<=a[0]:\r\n if i**2==a[1]:\r\n c+=1\r\n else:\r\n c+=2\r\nprint(c)\r\n\r\n", "#Ram\r\nfrom sys import stdin,stdout\r\ninput = stdin.readline\r\n\r\ndef print(n):\r\n stdout.write(str(n)+\"\\n\")\r\n\r\ndef printl(l):\r\n for i in l:\r\n stdout.write(str(i)+\" \")\r\n\r\n\r\nn,x=map(int,input().split())\r\n\r\n\r\nc=0\r\nfor i in range(1,n+1):\r\n if x%i==0 and i*n>=x:\r\n c+=1\r\nprint(c)", "n, p = map(int, input().split())\r\nl=0\r\nfor i in range(1,n+1):\r\n\tif p%i==0 and p/i<=n:\r\n\t\tl+=1\r\nprint(l)", "n, x = list(map(int, input().split()))\r\n\r\nif x == 1 or x == n * n:\r\n print(1)\r\nelse:\r\n out = 0\r\n for i in range(1, n + 1):\r\n if x % i == 0 and x // i <= n:\r\n out += 1\r\n\r\n print(out)\r\n", "from math import*\r\nn,x=list(map(int,input().split()))\r\ndef cal(a,n):\r\n j=[]\r\n for i in range(1,int(sqrt(a))+1):\r\n if a%i==0:\r\n if i<=n and a/i<=n:\r\n u=(2,1)[a/i==i]\r\n j.append(u)\r\n return j\r\nif x==n**2 or x==1:\r\n print(1)\r\nelse:\r\n print(sum(cal(x,n)))", "n, x = map(int, input().split())\r\nc = 0\r\nfor i in range(1,n+1):\r\n if x%i==0 and x//i <= n:\r\n c+=1\r\nprint(c)", "n, x = map(int, input().split())\r\n\r\ncount = 0\r\ni=1\r\nwhile i <= n and i * i <= x:\r\n if x % i == 0 and x // i <= n:\r\n if i * i == x:\r\n count += 1\r\n else:\r\n count += 2\r\n i += 1\r\nprint(count)", "def ans(n,x):\r\n if x > n**2:\r\n return 0\r\n ans = 0\r\n for i in range(1,n+1):\r\n if not x % i and x <= i*n:\r\n ans += 1\r\n if i > x:\r\n break\r\n return ans\r\na,b = list(map(int,input().split()))\r\nprint(ans(a,b))", "import math\r\n\r\nn,x=map(int,input().split(\" \"))\r\ncount=0\r\nfor i in range(1,int(math.sqrt(x))+1):\r\n a=i\r\n b=int(x/i)\r\n if a>n:\r\n break\r\n if a*b==x and a<=n and b<=n:\r\n if a==b:\r\n count+=1\r\n else:\r\n count+=2\r\nprint(count)", "def check_bit(number,bit_index):\r\n return number | (1<<bit_index-1)==number\r\n\r\ndef update_bit(number,i,is_bit=True):\r\n value = 1 if is_bit else 0\r\n mask = ~(1<<i)\r\n return (number & mask) | (value<<i)\r\n\r\ndef main():\r\n n,m = map(int,input().split())\r\n count =0\r\n for i in range(1,n+1): \r\n if i*n>=m and m%i==0:\r\n count+=1\r\n print(count)\r\n\r\nif __name__==\"__main__\":\r\n main()", "n,x=map(int,input().split())\r\ncount=0\r\nfor i in range(1,n+1):\r\n if x%i==0 and x//i<=n:\r\n count+=1\r\nprint(count)", "from math import sqrt\r\nn, x = map(int,input().split())\r\ncount = 0\r\nfor i in range(1,int(sqrt(x))+1):\r\n if(x%i==0):\r\n if((x//i)<=n):\r\n if((x//i)==i):\r\n count += 1\r\n else:\r\n count += 2\r\nprint(count)", "n,x=map(int,input().split())\r\nprint(sum((x%i==0and x/i<=n)for i in range(1,n+1)))", "# 18. Цикл While\r\n# Задача#1 - ряд чисел 1\r\n# i=50\r\n# while i>=50 and i<=150:\r\n# print(i,end=' ')\r\n# i+=1\r\n\r\n# Задача#2 - ряд чисел 2\r\n# i=13\r\n# while i>=13 and i<=349:\r\n# print(i,end=' ')\r\n# i+=7\r\n\r\n# Задача#3 - Поехали\r\n# i = 15\r\n# while i<=15 and i>=0:\r\n# print(i)\r\n# i = i - 1\r\n# print('Поехали!')\r\n\r\n# Задача#4 - Я последняя буква в алфавите\r\n# y=input()\r\n# while y[0]=='я' or y[0]=='Я':\r\n# print(y)\r\n# y=input()\r\n\r\n# Задача#5 - Список квадратов\r\n# i = int(input())\r\n# n = 1\r\n# while i>=n**2:\r\n# print(n**2)\r\n# n+=1\r\n\r\n# 21. Цикл While. Нахождение всех делителей числа\r\n# Задача#1 - Таблица умножения - вараинт 1 долгий\r\n# n,x = map (int,input().split())\r\n# count = 0\r\n# for i in range (1, n+1):\r\n# for j in range(1, n + 1):\r\n# if i*j == x:\r\n# # print(f'{i}*{j}={i*j}')\r\n# count+=1\r\n# print(count)\r\n\r\n# Вариант 2 - быстрый\r\nn, x = map(int, input().split())\r\ncount = 0\r\ni = 1\r\nwhile i * i <= x:\r\n if x % i == 0 and i<=n and x//i <=n:\r\n # print(i, x//i)\r\n if i != x//i:\r\n count += 2\r\n else:\r\n count += 1\r\n i += 1\r\nprint(count)", "N, X = map(int, input().split())\r\ncnt = 0\r\nfor i in range(1, N+1):\r\n\tif X % i == 0:\r\n\t\tif X // i <= N: cnt += 1\r\nprint(cnt)\r\n", "n,x = map(int,input().split())\n\namt = 0\nfor i in range(n):\n endNumber = (i+1)*n\n if(x % (i+1) == 0):\n if(x / (i+1) <= n):\n amt += 1\n\nprint(amt)\n\n#check: 12\n#1 2 3 4 5 6\n#2 4 6 8 1012\n#3 6 9 121518\n#4 8 12162024\n#5 1015202532\n#6 1218243036\n", "n, x = map(int, input().split(' '))\r\ncnt = 0\r\nfor i in range(1, n+1):\r\n\tif x%i == 0 and x//i <= n:\r\n\t\tcnt+=1\r\n\r\nprint(cnt)", "\n\nn, x = map(int,list(input().split()))\nc = 0\n\n\nfor i in range(1, n+1):\n if x / i <= n and x % i == 0:\n c+= 1\n\nprint(c)\n", "n, x = map(int, input().split())\ncount = 0\nfor i in range(1,n+1):\n if x%i == 0 and x/i<=n:\n count += 1\nprint(count)\n\n \t\t\t \t\t\t\t \t\t\t \t \t \t", "def factors(z,y):\r\n answer = 0\r\n for i in range(1,y+1):\r\n if z % i == 0 and z//i <= y:\r\n answer += 1\r\n return answer\r\nl = [int(x) for x in input().split()]\r\nprint(factors(l[1],l[0]))", "n, x = map(int, input().split())\r\nans = 0\r\nfor i in range(1, n+1):\r\n ans += (x % i == 0) and (x <= i*n)\r\nprint(ans)", "n,m = [int(x) for x in input().split()]\r\nprint(len([x for x in range(1,n+1) if m%x==0 and (m/x) <= n]))\r\n", "n, x = [int(x) for x in input().split()]\r\nc = 0\r\nr = min(n, x)+1\r\nfor i in range(1, r):\r\n if x%i==0 and x//i<=n:\r\n #print(i)\r\n c+=1\r\nprint(c)", "n, m = map(int,input().split())\r\nans = 0\r\ni = 1\r\nwhile i*i <=m :\r\n if m%i == 0:\r\n if i<=n and m//i<=n:\r\n if i ==m//i:\r\n ans+=1\r\n else:\r\n ans+=2\r\n i+=1\r\nprint(ans)", "n = list(map(int, input().split()))\r\nappear = 0\r\nfor i in range(1,n[0]+1):\r\n if n[1] % i ==0 and n[1] >= i:\r\n if n[1]/i <= n[0]:\r\n appear += 1\r\n elif n[1] <i:\r\n break\r\nprint(appear)\r\n\r\n\r\n", "from math import sqrt\r\ndef solve():\r\n n,k=map(int,input().split());c=0\r\n for i in range(1,n+1):\r\n if k%i==0 and (k//i)<=n:c+=1\r\n print(c)\r\nsolve()", "n,x= map(int,input().split())\r\nprint(sum((x%i == 0) and (x<=(n*i)) for i in range(1,n+1)))", "s = list(map(int, input().split(\" \")))\r\nn, x = s[0], s[1]\r\ncount=0\r\nfor i in range(n):\r\n if(i+1<=x and x%(i+1)==0 and x/(i+1)<=n):\r\n count+=1\r\nprint(count)", "n, x=map(int, input().split())\r\nf=0\r\nfor i in range(1, n+1):\r\n if(x%i==0):\r\n# print(x//i)\r\n if(x//i<=n):\r\n f+=1\r\nprint(f)\r\n\r\n \r\n ", "def main():\n divisors = []\n take = input().split()\n n = int(take[0])\n x = int(take[1])\n current = 1\n while current != n + 1:\n if x % current == 0:\n if x // current <= n:\n divisors.append(current)\n current += 1\n print(len(divisors))\nmain()\n\n", "n, x = map(int, input().split())\r\n\r\ncnt = 0\r\ni = 1\r\n\r\nwhile i ** 2 <= x and i <= n:\r\n if x % i == 0 and x // i <= n:\r\n cnt += 1\r\n if i != x // i:\r\n cnt += 1\r\n i += 1\r\n \r\nprint(cnt)", "n, x = list(map(int,input().split()))\r\nans = 0\r\nfor i in range(1,n+1):\r\n if x%i==0 and (x//i)<=n:\r\n ans += 1\r\nprint(ans)", "#Complejidad O(n)\nn, x = map(int, input().split())\ncount = 0\n\nfor i in range(1, n + 1):\n if x % i == 0:\n c = x // i \n if c <= n:\n count += 1\n\nprint(count)\n\n#Lo que hace el operador // es darme el entero\n#resultante de una división\n\n\"\"\"Primero: La i recorre los números de 1 hasta n+1.\n Después de ello revisa si ese numero es múltiplo de x,\n si es así, en la variable c, se guardara el valor de la división\n entera de x entre i.\n Si el cociente de esa división es menor o igual a n, entonces le sumara 1 \n al contador\n\"\"\"\n \t\t \t \t\t\t \t\t \t \t \t \t\t\t\t \t \t", "N, X = map(int, input().split())\r\nans = 0\r\nfor i in range(1, N + 1):\r\n\tif X % i == 0 and X // i <= N:\r\n\t\tans += 1\r\nprint(ans)", "n, x = map(int, input().split())\r\n\r\n\r\ncnt = 0 \r\nfor i in range(1, n+1):\r\n if x % i == 0 and x // i <= n : cnt += 1\r\nprint(cnt)", "n, x = map(int, input().split())\r\nprint(sum(x%i == 0 and x//i <= n for i in range(1, n+1)))", "def solve(n,a):\r\n ans=0\r\n for i in range(1,n+1):\r\n if a%i==0 and a//i<=n:\r\n ans+=1\r\n return ans\r\n\r\nn,a=map(int,input().split())\r\nprint(solve(n,a))\r\n", "n, a = map(int, input().split())\r\nprint(len(list(filter(lambda x: not a % x and a / x <= n, [i for i in range(1, n + 1)]))))", "from math import sqrt, floor\n\nn, x = (int(i) for i in input().split())\nres = sum(1 if x == i** 2 else 2 if x % i == 0 and x // i <= n else 0 for i in range(1, min(n, floor(sqrt(x))) + 1))\nprint(res)\n", "import math\r\nn,x = list(map(int,input().split()))\r\ncount = 0\r\nif x>n*n:\r\n\tpass\r\nelse:\r\n i = 1\r\n while i <= n:\r\n if (x%i==0) and (x//i<=n):\r\n count=count+1\r\n i = i+1\r\nprint(count)", "a,b = map(int,input().split())\r\nc = 0\r\nfor i in range(1,a+1):\r\n if(b%i==0 and b//i<=a):\r\n c+=1\r\nprint(c)", "siza_table, number = [int(i) for i in input().split()]\r\ni = 1\r\ncount = 0\r\nwhile i**2 <= number:\r\n if number%i==0 and i <= siza_table and number//i <= siza_table:\r\n if i != number//i:\r\n count +=2\r\n else:\r\n count +=1\r\n i += 1\r\nprint(count)", "n,x=map(int,input().split())\r\nc=0\r\nfor i in range(1,n+1):\r\n if x<=n*i:\r\n if x%i==0:\r\n c+=1\r\n\r\nprint(c)", "a,b=([int(x) for x in input().split()])\r\nc=0\r\nfor i in range(1,a+1):\r\n if i<=b:\r\n if b%i==0 and (b//i) <=a:\r\n c=c+1\r\nprint(c)", "n, x = map(int, input().split())\r\ncount = 0\r\nfor i in range(1, n + 1):\r\n temp = x / i\r\n if temp == int(temp) and temp <= n: count += 1\r\n\r\nprint (count)", "import math\r\n\r\nm, n = map(int, input().split())\r\n\r\ncount = 0\r\n\r\nfor i in range(1, int(math.sqrt(n))+1):\r\n if n % i == 0:\r\n j = n // i\r\n if i <= j and i <= m and j <= m:\r\n if i == j:\r\n count += 1\r\n else:\r\n count += 2\r\n\r\nprint(count)\r\n", "# Dev/Eng : Ziad Mohamed Gamal\r\n\r\n# =================== Libraries ======================\r\nfrom math import *\r\n# =================== solve ======================\r\nsol = 0 \r\nn,x = map(int,input().split())\r\nfor i in range(1,n+1):\r\n if (not x%i) and x/i <=n:\r\n sol += 1 \r\nprint(sol)", "n, x = map(int, input().split())\r\ncnt = 0\r\nfor i in range(1, n + 1):\r\n if(x % i == 0) and (x // i <= n):\r\n cnt = cnt + 1\r\nprint(cnt)", "n,x = map(int,input().split())\r\ncount =0\r\nfor i in range(1,n+1):\r\n if x%i==0 and x//i<=n: count+=1\r\nprint(count)\r\n", "def main():\r\n n, x = list(map(int, input().split()))\r\n\r\n counter = 0\r\n for i in range(1, n+1):\r\n j = x / i\r\n if j.is_integer() and 1 <= j <= n:\r\n counter += 1\r\n print(counter)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()", "def fact(n):\r\n i,l = 1,[]\r\n while i*i<=n:\r\n if n%i==0:\r\n if n//i==i: l.append(i)\r\n else:\r\n l.append(i)\r\n l.append(n//i)\r\n i+=1\r\n return l\r\n \r\nn,m = map(int,input().split())\r\nl,ans = fact(m),0\r\nfor i in l:\r\n for j in l:\r\n if i*j==m and i<=n and j<=n:\r\n ans+=1\r\nprint(ans)", "a,b=map(int,input().split())\r\ns=0\r\nfor i in range(1,a+1):\r\n if (b%i==0)and(b//i<=a):\r\n s+=1\r\n if(i>b):\r\n break\r\nprint(s)", "n, x = map(int, input().split())\ns = 0\nfor i in range(1, n + 1):\n if x % i == 0 and x / i <= n:\n s += 1\nprint(s)\n", "import math\r\nn, x = map(int, input().split())\r\ncnt = 0\r\n\r\nm = int(math.sqrt(x))\r\nfor i in range(1, m + 1):\r\n if x % i == 0 and i <= n and (x // i) <= n:\r\n if i * i == x:\r\n cnt += 1\r\n else:\r\n cnt += 2\r\nprint(cnt)", "from cmath import sqrt\nfrom sys import stdin, stdout\n\n\ndef input():\n return stdin.readline().strip()\n\n\ndef print(string):\n return stdout.write(str(string) + \"\\n\")\n\n\ndef main():\n n, x = map(int, input().split())\n factors = 0\n for i in range(1, int(sqrt(x).real) + 1):\n if x % i == 0 and x / i <= n:\n if x / i != i:\n factors += 2\n else:\n factors += 1\n print(factors)\n\n\nif __name__ == \"__main__\":\n main()\n", "n, x = map(int, input().split())\nres = 0\nfor i in range(1, n + 1):\n if x % i == 0:\n j = x // i\n if i == j:\n res += 1\n elif i < j <= n:\n res += 2\nprint(res)\n", "n,x=map(int,input().split())\r\ncount=0\r\nfor i in range(1,n+1):\r\n if(x//i<=n and x%i==0):\r\n count+=1\r\nprint(count)\r\n\r\n", "n, x = map(int, input().split())\na = 1\ncount = 0\nwhile a * a <= x:\n if x % a == 0 and a <= n and x // a <= n:\n if a != x // a:\n count += 2\n else:\n count += 1\n a += 1\nprint(count)\n", "n, x = map(int, input().split())\r\nans = 0\r\nfor i in range(n, 0, -1):\r\n if x / i > n:\r\n break\r\n if x % i == 0:\r\n ans += 1\r\nprint(ans)\r\n", "import sys\nif __name__ == \"__main__\":\n n, x = map(int, sys.stdin.readline().strip().split())\n count = 0\n for i in range(1, n + 1):\n if x%i == 0 and x//i <= n: count += 1\n print(count)", "a,b=map(int,input().split())\r\nc=0\r\nfor i in range(1,a+1):\r\n if b%i==0 and b//i<=a:\r\n c+=1 \r\n #print(b)\r\nprint(c)\r\n", "l = list(map(int,input().split()))\r\nn = l[0]\r\nx = l[1]\r\nk = 0\r\nfor i in range(n):\r\n if x%(i+1)==0:\r\n y = x//(i+1)\r\n if y<=n:\r\n k+=1 \r\nprint(k)", "n, m = map(int, input().split())\r\nocc = 0\r\n\r\nfor i in range(1, min(n, m) + 1):\r\n if m % i == 0 and m // i <= n:\r\n occ += 1\r\n\r\nprint(occ)\r\n", "def inp(sa):\r\n\tb=[]\r\n\tj=0\t\r\n\tfor i in range(len(sa)):\r\n\t\tif sa[i]==\" \":\r\n\t\t\tb.append(int(sa[j:i]))\r\n\t\t\tj=i+1\r\n\tb.append(int(sa[j:]))\r\n\treturn b\r\n\r\n\t\t\r\na=input()\r\na=inp(a)\r\nsum=0\r\nfor i in range(1,a[0]+1):\r\n\tif a[1]%i==0 and a[1]//i<=a[0]:\r\n\t\tsum+=1\r\n\t\t\r\nprint(sum)\t\r\n\t\t\r\n\t\t\t\t", "(n,x) = map(int,input().split())\r\nc = 0\r\n#mid = n//2\r\n#k = set()\r\nif(n==1 and x == 1):\r\n\tprint(1)\r\nelse:\r\n\tfor i in range(1,n+1):\r\n\t\tdiv = x/i\r\n\r\n\t\tif(div == int(div) and div <= n):\r\n\t\t\tif(int(div) == i):\r\n\t\t\t\tc += 1\r\n\t\t\telse:\r\n\t\t\t\tc += 1\r\n\t\t\t#k.add(i)\r\n\t\t\t#k.add(int(div))\r\n\r\n\r\n\r\n\tprint(c)", "from sys import stdin\r\n\r\ndef readint():\r\n return int(stdin.readline())\r\n\r\n\r\ndef readarray(typ):\r\n return list(map(typ, stdin.readline().split()))\r\n\r\n\r\ndef readmatrix(n):\r\n M = []\r\n for _ in range(n):\r\n row = readarray(int)\r\n assert len(row) == n\r\n M.append(row)\r\n return M\r\n \r\n \r\ndef solve():\r\n res = 0\r\n n,x = readarray(int)\r\n for i in range(1,n+1):\r\n if x%i == 0 and x//i <= n:\r\n res += 1\r\n print(res)\r\n \r\n \r\n\r\nif __name__ == \"__main__\":\r\n T = 1#readint()\r\n for _ in range(T):\r\n solve()\r\n", "n1,x1 = input().split()\r\nn = int(n1)\r\nx = int(x1)\r\ncnt = 0\r\nfor i in range(1,n+1):\r\n if x % i == 0 and x / i <= n:\r\n cnt = cnt + 1\r\nprint(cnt)\r\n ", "n, x = map(int, input().split())\r\ncount = 0\r\nfor i in range(1, n+1):\r\n left, right = 1, n\r\n while left <= right:\r\n mid = (left + right) // 2\r\n if i * mid == x:\r\n count += 1\r\n break\r\n elif i * mid < x:\r\n left = mid + 1\r\n else:\r\n right = mid - 1\r\nprint(count)\r\n", "#Complejidad O(n)\nn, x = map(int, input().split())\ncount = 0\n\nfor i in range(1, n + 1):\n if x % i == 0:\n if x//i * i ==x and x//i <=n:\n count += 1\n\nprint(count)\n\n#Lo que hace el operador // es darme el entero\n#resultante de una division\n\n\"\"\"Primero: La i recorre los numeros de 1 hasta n+1.\n Despues de ello revisa si ese numero es multiplo de x,\n si es asi, en la variable c, se guardara el valor de la division\n entera de x entre i.\n Si el cociente de esa division es menor o igual a n, entonces le sumara 1 \n al contador\n\"\"\"\n\n\n\n\t\t \t\t\t\t \t\t\t\t\t\t \t \t \t \t \t", "n, m = map(int, input().split())\r\nx = 0\r\na = n if n < m else m\r\nt = []\r\nfor i in range(1, a+1):\r\n if m % i == 0:\r\n t.append(i)\r\nfor j in range(1, n+1):\r\n for k in t:\r\n if j * k == m:\r\n x += 1\r\nprint(x)\r\n", "a,b=input().split()\r\na=int(a)\r\nb=int(b)\r\nlst=[]\r\nfor i in range(1,a+1):\r\n if (b%i==0):\r\n lst.append(i)\r\n\r\ncount=0\r\nfor i in lst:\r\n if (b//i<=a):\r\n count+=1\r\nprint(count)\r\n \r\n", "a,b=map(int,input().split())\r\ns=0\r\nfor i in range(1,a+1):\r\n if b%i==0:\r\n if b//i<=a:\r\n s+=1\r\nprint(s)\r\n", "l=list(map(int,input().strip().split()))\r\nn=l[0]\r\nx=l[1]\r\ncount=0\r\nfor i in range(1,n+1):\r\n if x%i==0:\r\n a=x//i\r\n if a<=n:\r\n count=count+1\r\nprint(count)", "d = input().split()\nn = int(d[0])\nx = int(d[1])\nc = 0\n\nfor i in range(1, n+1):\n if x == 1:\n c = 1\n break\n else:\n if x%i==0 and x/i==i :\n c = c+1\n elif x%i==0 and x/i>i and x/i<=n:\n c = c+2\n else:\n continue\nprint(c)\n\n\n\n", "def count_cells_with_x(table_size, x):\r\n count = 0\r\n i, j = 1, table_size\r\n\r\n while i <= table_size and j >= 1:\r\n current_value = i * j\r\n\r\n if current_value == x:\r\n count += 1\r\n i += 1\r\n j -= 1\r\n elif current_value > x:\r\n j -= 1\r\n else:\r\n i += 1\r\n\r\n return count\r\n\r\n\r\nn, x = map(int, input().split())\r\nprint(count_cells_with_x(n, x))", "n,x=map(int, input().split())\r\ncount=0\r\nfor i in range(1,n+1):\r\n if(((x%i)==0) and ((x/i)<=n)):\r\n count+=1\r\nprint(count)\r\n", "n, x = map(int, input().split())\r\n\r\nc = 0\r\ni = 1\r\nj = n\r\n\r\nwhile i <= n and j >= 1:\r\n if i * j == x:\r\n c += 1\r\n i += 1\r\n j -= 1\r\n elif i * j < x:\r\n i += 1\r\n else:\r\n j -= 1\r\n\r\nprint(c)\r\n", "def count_occurrences(n, x):\n count = 0\n i = 1\n j = n\n\n while i <= n and j >= 1:\n if i * j == x:\n count += 1\n i += 1\n j -= 1\n elif i * j < x:\n i += 1\n else:\n j -= 1\n\n return count\n\nn, x = list(map(int,input().split()))\noccurrence_count = count_occurrences(n, x)\nprint(occurrence_count)\n\n\t\t\t \t \t \t \t\t \t \t \t", "n,x=input().split(\" \")\r\nn=int(n)\r\nx=int(x)\r\nans=0\r\n\r\nfor a in range(1,n+1):\r\n if x%a==0:\r\n if x/a<=n:\r\n ans=ans+1\r\nprint(ans)", "count = 0\r\nn, x = [int(i) for i in input().split()]\r\nfor i in range(1, n + 1, 1):\r\n if ((x // i)*i == x and x // i <= n):\r\n count += 1\r\nprint(count)\r\n", "a,n=map(int,input().split())\r\ns=0\r\nfor i in range(1,a+1):\r\n if(n%i==0 and (n/i)<=a):\r\n s+=1\r\nprint(s)\r\n", "n,x=map(int,input().split())\r\nl=[]\r\nfor i in range(1,n+1):\r\n if x%i==0 and (x//i)<=n:\r\n l.append(i)\r\nprint(len(l))", "n,x= map(int,input().split())\r\ncnt=0\r\nfor i in range(1,n+1):\r\n if x%i==0 and x//i<=n:\r\n \r\n cnt+=1\r\nprint(cnt)", "def main():\r\n [n, k] = list(map(int, input().split()))\r\n\r\n c = 0\r\n for i in range(1, n + 1):\r\n if k % i == 0 and (k // i) <= n:\r\n c += 1\r\n\r\n print(c)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n\r\n\r\n\r\n\r\n", "x,y=map(int,input().split(\" \"))\r\ni=1\r\nans=0\r\nwhile(i<=x):\r\n if(y%i==0 and y//i<=x):\r\n ans+=1\r\n i+=1\r\nprint(ans)\r\n \r\n", "a,s = list(map(int,input().split()))\nz=1\nx=a\nq=0\nwhile((a>=z)and(x>=1)):\n if (x*z)==s:\n q+=1\n z+=1\n x-=1 \n elif(x*z<s):\n z+=1\n else:\n x-=1 \nprint(q)\n\n\n \t\t\t\t \t\t\t \t\t \t\t \t\t \t\t \t", "n,x = map(int, input().split())\r\ny=0\r\nfor i in range(1,n+1):\r\n if x%i==0 and x/i<=n:\r\n y+=1\r\nprint(y) if n>x else print(y) ", "from sys import stdin;input = lambda: stdin.readline().rstrip('\\r\\n')\r\nn,x = map(int,input().split())\r\nans = 0\r\nfor i in range(1,n + 1):\r\n if x % i == 0 and x // i <= n:\r\n ans += 1\r\nprint(ans)\r\n \r\n\r\n", "n, x = map(int, input().split())\r\n\r\ni = 1\r\npairs = 0\r\nwhile i * i <= x and i <= n:\r\n if x % i == 0:\r\n no_of_times = int(x/i)\r\n if no_of_times <= n:\r\n pairs += 2\r\n if no_of_times == i:\r\n pairs -= 1\r\n i += 1\r\n\r\nprint(pairs)", "inp = input().split()\r\n\r\nn = int(inp[0])\r\nx = int(inp[1])\r\nlist = []\r\ncounter = 0\r\n\r\nfor i in range(1,n+1):\r\n if x % i == 0:\r\n if i * n >= x:\r\n counter += 1\r\nprint(counter)\r\n", "n, x = map(int, input().split())\r\ncounter = 0\r\n\r\n\r\ndef check(x):\r\n a = set()\r\n for i in range(1, int(x ** 0.5) + 1):\r\n if x % i == 0:\r\n a.add((i, x // i))\r\n a.add((x // i, i))\r\n\r\n return a\r\n\r\n\r\nfor i in check(x):\r\n if i[0] <= n and i[1] <= n:\r\n counter += 1\r\nprint(counter)\r\n", "n, x = map(int, input().split())\nt = 0\nfor i in range(n, 0, -1):\n t += (x % i == 0 and x // i <= n)\n\nprint(t)\n", "l = input().split(' ')\r\nn = int(l[0])\r\nx = int(l[1])\r\ni = 1\r\nd = []\r\nwhile i * i <= x:\r\n if x % i == 0:\r\n d.append(i)\r\n i += 1\r\nans = 0\r\nfor j in d:\r\n if x // j <= n:\r\n if j <= n:\r\n if j == x // j:\r\n ans += 1\r\n else:\r\n ans += 2\r\nprint(ans)", "n, x = tuple (map (int, input ().split (' ')))\r\nresult = 0\r\nfor i in range (n):\r\n result += int (x % (i + 1) == 0 and x / (i + 1) <= n)\r\nprint (result)", "number,value=map(int,input().split())\ncounter=0\nfor index in range(1,number+1):\n if value%index==0 and value<=number*index:\n counter=counter+1\nprint(counter)\n \t \t\t\t\t \t\t\t\t \t \t \t \t\t\t", "c,h=map(int,input().split())\r\ny=0\r\nfor i in range(1,c+1):\r\n if h//i<=c and h%i==0:\r\n y+=1\r\nprint(y)", "a,b=map(int,input().split())\r\ncount=0\r\nfactor=[]\r\nfor i in range(1,a+1):\r\n if b%i==0:\r\n factor.append(i)\r\nfor i in factor:\r\n if b//i in factor:\r\n count+=1\r\nprint(count)", "x = list(map(int, input().split()))\r\nif x[1] == 1 : \r\n print(1)\r\nelse :\r\n factors = 0\r\n i = 1\r\n while i <=x[1] and i <= x[0]: #\r\n if (x[1]) % i == 0 and (x[1])/i <= x[0]:\r\n \r\n factors += 1\r\n i += 1\r\n print(factors)\r\n\r\n", "from sys import stdin, stdout\r\ninput, print = stdin.readline, stdout.write\r\n\r\n\r\ndef main():\r\n n, k = map(int, input().split())\r\n i = 1\r\n ans = 0\r\n while i*i <= k:\r\n if i > n:\r\n break\r\n if k % i == 0:\r\n if i*i == k:\r\n ans += 1\r\n elif k/i <= n:\r\n ans += 2\r\n i += 1\r\n print(str(ans)+\"\\n\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n,m=map(int,input().split())\r\nc=0\r\nfor x in range(1,n+1):\r\n if m%x==0 and (m//x)<=n:\r\n c+=1\r\nprint(c)\r\n", "# coding=utf-8\r\nn,x=map(int,input().split())\r\ns=0\r\nfor i in range(1,n+1):\r\n if 1<=x/i<=n and x/i==int(x/i):\r\n s+=1\r\nprint(s)\r\n\r\n \t \t\t\t \t\t\t \t\t\t\t \t \t", "import math\r\nn,x=map(int,input().split())\r\nq=int(math.sqrt(x))\r\ns=0\r\nfor a in range(1,q+1):\r\n if x%a==0:\r\n b=x//a\r\n if a<=n and b<=n:\r\n s += 2 if a != b else 1\r\nprint(s)", "n , target = map(int, input().split()) \r\ncounter = 0\r\nfor i in range(1 , n+1) :\r\n x = target // i\r\n if x <= n and target % i == 0 : \r\n counter += 1\r\nprint (counter)", "n,m = map(int,input().split())\r\ncount = 0\r\n\r\nfor i in range(1,n+1):\r\n if m%i == 0 and m // i <=n:\r\n count+=1\r\nprint(count)\r\n", "\nn,x=map(int,input().split())\nc=0\nfor i in range(1,n+1):\n if x%i==0 and x//i<=n:\n c+=1\nprint(c)\n", "import math\r\ndef get():\r\n return list(map(int, input().split()))\r\ndef intput():\r\n return int(input())\r\ndef bfs(x,n):\r\n if (x[n]!=0):\r\n bfs(x,x[n])\r\n print(n, end=' ')\r\ndef main():\r\n n=get()\r\n p=0\r\n for i in range(1,n[0]+1):\r\n if (n[1]%i==0 and n[1]/i <=n[0]):\r\n p+=1\r\n print(p)\r\nmain()", "n,x=map(int,input().split())\r\ntong=0\r\ni=1\r\nwhile i*i<=x:\r\n if x%i==0 and i<=n and x//i<=n:\r\n if i!=x//i:\r\n tong+=2\r\n else: tong+=1\r\n i+=1\r\nprint(tong)", "import math\r\nn,x=[int(x) for x in input().split()]\r\n\r\nsq=1 if int(math.sqrt(x))**2==x and x<=n*n else 0\r\n\r\n\r\n\r\ntemp=[]\r\nres=0\r\nfor k in range(1,n+1):\r\n if k*k<x<=k*n:\r\n temp.append(k) \r\n\r\nfor k in temp:\r\n if math.gcd(x,k)==k:\r\n res+=2\r\nprint(res+sq)", "l = input().split()\r\nn = int(l[0])\r\nx = int(l[1])\r\ncount = 0\r\nfor i in range(int(x**0.5), min(n,x)+1):\r\n if x%i==0:\r\n if x/i<=n:\r\n count+=1\r\n if x/i<int(x**0.5):\r\n count+=1\r\n\r\nprint(count)", "n, x = (int(x) for x in input().split())\r\nnum_count = 0\r\ni = 1\r\nwhile i*i <= x:\r\n\tif x%i == 0 and i <= n and x//i <= n:\r\n\t\tif i != x//i:\r\n\t\t\tnum_count += 2\r\n\t\telse:\r\n\t\t\tnum_count += 1\r\n\ti += 1\r\nprint(num_count)", "n,x = map(int,input().split())\r\nr = 0\r\nfor i in range(1,n+1):\r\n if x%i == 0 and x//i <= n:\r\n r += 1\r\nprint(r)", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Thu Apr 13 13:37:12 2023\r\n\r\n@author: Srusty Sahoo\r\n\"\"\"\r\n\r\nimport math\r\nw=0\r\nn,x=map(int,input().split())\r\nif x>(n*n):\r\n print(0)\r\nelse:\r\n a=int(math.sqrt(x)+1)\r\n for i in range(1,a):\r\n if (x%i)==0 and (x//i)<=n:\r\n if i!=(x//i):\r\n w=w+2\r\n else:\r\n w=w+1\r\n print(w)\r\n \r\n \r\n \r\n", "n,x=[int(x) for x in input().split()]\r\nr=0\r\nfor i in range(1,n+1):\r\n if x%i==0 and x//i<=n: r+=1\r\nprint(r)", "n,t=map(int,input().split())\r\ncount=0\r\nfor i in range(1,n+1):\r\n if t%i==0 and t//i<=n:\r\n count+=1\r\nprint(count)\r\n\r\n", "n,x=map(int,input().split())\r\na=0\r\nfor i in range(1,n+1):\r\n if x % i == 0 and x//i <= n:\r\n a+=1\r\n\r\nprint(a)", "import math\r\n\r\ntemp = input().split(\" \")[:2]\r\na = int(temp[0])\r\nb = int(temp[1])\r\n\r\ncount = 0\r\n \r\nfor i in range(1, min(int(math.sqrt(b)), a)+1):\r\n if (b%i == 0):\r\n if ((b//i) <= a) and (b//i == i):\r\n count += 1\r\n elif (b//i) <= a:\r\n count += 2\r\n \r\nprint(count) ", "a, b = map(int, input().split())\r\nc = 0\r\nfor i in range(1, a+1):\r\n if b % i == 0 and b / i <= a:\r\n c += 1\r\nprint(c)", "nx = input().split()\r\nn=int(nx[0])\r\nx=int(nx[1])\r\nans=0\r\nfor i in range(1,n+1) :\r\n if x%i == 0 :\r\n if x/i <=n :\r\n ans+=1\r\nprint(ans)", "from sys import stdin, stdout\r\nn, x = map(int, stdin.readline().strip().split())\r\ncount = 0\r\nfor i in range(1, n+1):\r\n if x%i==0:\r\n if (x//i)<=n:\r\n count+=1 \r\nstdout.write(f\"{count}\\n\")", "n, x = map(int, input().split())\r\nc = 0\r\nfor i in range(1, n+1):\r\n if (x%i == 0 and x/i <= n):\r\n c+=1\r\nprint(c)", "number,value=map(int,input().split())\r\ncounter=0\r\nfor index in range(1,number+1):\r\n if value%index==0 and value<=number*index:\r\n counter=counter+1\r\nprint(counter)", "(n, m) = map(int, input().rstrip().split())\r\n\r\n\r\ncount = 0\r\nif m <= n:\r\n count = 1\r\nfor k in range(2, n+1):\r\n if m % k == 0 and m // k <= n:\r\n count += 1\r\n\r\nprint(count)", "a,b=map(int,input().split())\r\nc=0\r\nfor i in range(1,a+1):\r\n if(b%i==0 and b<=a*i):\r\n c+=1\r\nprint(c)\r\n", "import sys, io, os\r\nimport math\r\nimport bisect\r\nimport heapq\r\nimport string\r\nfrom collections import defaultdict,Counter,deque\r\ninput = sys.stdin.readline\r\n \r\ndef I():\r\n return input()\r\n \r\ndef II():\r\n return int(input())\r\n \r\ndef MII():\r\n return map(int, input().split())\r\n \r\ndef LI():\r\n return list(input().split())\r\n \r\ndef LII():\r\n return list(map(int, input().split()))\r\n \r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n \r\ndef LGMI():\r\n return list(map(lambda x: int(x) - 1, input().split()))\r\n \r\ndef WRITE(out):\r\n return print('\\n'.join(map(str, out)))\r\n \r\ndef WS(out):\r\n return print(' '.join(map(str, out)))\r\n \r\ndef WNS(out):\r\n return print(''.join(map(str, out)))\r\n\r\n'''\r\n10000 * 10000\r\n\r\n1 2 3 4 5 6\r\n2 4 6 8 10 12\r\n\r\n2 * 6\r\n3 * 4\r\n4 * 3\r\n6 * 2\r\n\r\n1 36\r\n2 18\r\n4 9\r\n6 6\r\n\r\nso... prime factorize x and if x is not a square number\r\nreturn num(prime_factors)\r\nensure only add prime factors where the other value is <= n\r\n'''\r\n\r\ndef solve():\r\n n, x = MII()\r\n ans = 0\r\n for i in range(1, min(n,x)+1):\r\n if i*i > x:\r\n break\r\n\r\n if x%i == 0 and x//i <= n:\r\n ans += 1 if i*i == x else 2\r\n print(ans)\r\n\r\nsolve()", "n,x=(int(x) for x in input().split())\r\ncount=0\r\nfor i in range(1,n+1):\r\n if(x%i==0 and x//i<=n):\r\n count+=1\r\nprint(count)", "n,x = list(map(int,input().split()))\r\nc = 0\r\nfor i in range(1,n+1):\r\n if x % i == 0 and x // i <= n:\r\n c+=1\r\nprint(c) ", "n, m = map(int, input().split())\r\ncount = 0\r\ni = 1\r\nwhile i*i <= m:\r\n if m % i == 0 and i <= n and m //i <= n:\r\n if i != m // i:\r\n count += 2\r\n else:\r\n count += 1\r\n i += 1\r\nprint(count)", "n, x = map(int, input().split())\r\nprint(sum((x % i == 0 and x / i <= n) for i in range(1, n + 1)))\r\n", "n,x = [int(x) for x in input().split()]\r\n\r\nres = 0\r\ni = 1\r\nwhile i <= n and i <= x:\r\n if x%i == 0 and x/i <= n:\r\n res += 1\r\n i+=1\r\nprint(res)\r\n", "n, x = map(int, input().split())\r\n\r\ncount = 0\r\n\r\nfor index in range(1, n + 1):\r\n if x % index == 0 and x // index <= n:\r\n count += 1\r\n\r\nprint(count)", "n, x = map(int, input().split())\r\n\r\nif x < 1 or x > n * n:\r\n count = 0\r\nelse:\r\n count = sum(x % i == 0 and x // i <= n for i in range(1, n + 1))\r\n\r\nprint(count)", "n, x = map(int, input().split())\r\n\r\nkol = 0\r\n\r\nfor i in range(1, n + 1):\r\n if x % i == 0 and x / i <= n:\r\n kol += 1\r\n\r\nprint(kol)\r\n", "n, x = map(int, input().split())\n\nh = 0 \n\nfor i in range(1, n + 1):\n if x % i == 0 and x // i <= n:\n h += 1\nprint(h)", "def count_occurrences(n, x):\r\n count = 0\r\n i, j = 1, n # Start from the top-right corner\r\n while i <= n and j >= 1:\r\n if i * j == x:\r\n count += 1\r\n i += 1 # Move down to the next row\r\n elif i * j > x:\r\n j -= 1 # Move left within the current row\r\n else:\r\n i += 1 # Move down to the next row\r\n return count\r\n\r\nn, x = map(int, input().split())\r\nresult = count_occurrences(n, x)\r\nprint(result)\r\n", "def solve(n, x):\r\n\r\n count = 0\r\n for i in range(1, n+1):\r\n\r\n if x % i == 0 and (x/i) <= n:\r\n count += 1\r\n\r\n return count\r\n\r\n\r\nif __name__ == \"__main__\":\r\n\r\n n, x = map(int, input().split())\r\n print (solve(n, x))", "n,x = map(int,input().split())\r\nt=0\r\nfor i in range(1,(n+1)):\r\n if x%i==0 and x//i<=n:\r\n t+=1\r\nprint(t)", "x,y = (list(map(int,input().split())))\r\ncount = 0\r\nfor i in range(1,x+1):\r\n if y % i == 0 and y // i <= x:\r\n count += 1\r\nprint(count)\r\n", "n, x = map(int, input().split())\r\nc = 0\r\nfor i in range(1, n+1):\r\n if((x%i==0) and (i*n) >= x):\r\n c = c + 1\r\nprint(c)", "n, x = map(int, input().split())\r\ni = 1\r\na = []\r\nwhile i*i<= x and i<=n:\r\n \r\n if x%i == 0 and x//i <= n:\r\n a.append(i)\r\n if i != x//i:\r\n a.append(x//i)\r\n i += 1\r\na.sort()\r\nprint(len(a))", "n,x=map(int,input().split());p=0\r\nfor i in range(1,n+1):\r\n if x%i==0:\r\n if int(x/i)<=n:p+=1\r\nprint(p)", "n, x = map(int, input().split())\r\nxSqrt = int(x**0.5)\r\nub = min(x, n)\r\nres = sum(1 for k in range(1,ub+1) if x % k == 0 and x // k <= ub)\r\nprint(res)", "n,x = list(map(int, input().split()))\r\nif x == 1 or x == n * n:\r\n print(1)\r\n\r\nelse:\r\n ans = 0 \r\n \r\n for i in range(1,n+1):\r\n if x%i != 0: continue\r\n if x//i > n: continue\r\n ans += 1 \r\n print(ans) ", "s = list(map(int, input().split()))\r\nn, x = s[0], s[1]\r\nk = 0\r\nif x == 1:\r\n\tk = 1\r\nelse:\r\n\tfor i in range(1, n + 1):\r\n\t\tif x % i == 0:\r\n\t\t\tif(i <= n) and (x // i <= n):\r\n\t\t\t\tk += 1\r\nprint(k)\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\t\t\r\n\r\n\r\n\t\r\n\r\n\t\t\t\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\t \r\n \r\n\r\n\r\n\r\n\r\n\t\t\t\r\n\t\t\r\n\t\t\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "\r\nnum_inp=lambda: int(input())\r\narr_inp=lambda: list(map(int,input().split()))\r\nsp_inp=lambda: map(int,input().split())\r\nstr_inp=lambda:input()\r\nn,x=map(int,input().split())\r\nprint(sum((x%i==0and x/i<=n)for i in range(1,n+1)))", "a,b=map(int,input().split())\r\ncnt=0\r\nfor i in range(1,a+1):\r\n if b%i==0 and b//i<=a:\r\n cnt=cnt+1\r\nprint(cnt)", "import sys\r\n\r\n\r\nn,x=map(int,input().split())\r\ncount0=0\r\n\r\nfor i in range(1,n+1):\r\n if x%i==0 and n*i>=x:\r\n count0+=1\r\n\r\nsys.stdout.write(str(count0))", "n,m=map(int,input().split())\r\nd=0\r\nfor i in range(1,n+1):\r\n if m%i==0:\r\n if m//i<=n:\r\n d+=1\r\nprint(d)", "n,x=map(int,input().split())\r\ncountt=0\r\na=[]\r\nfor i in range(1,n+1):\r\n if x%i==0 and x//i<=n:\r\n a.append([x//i,i])\r\nprint(len(a))", "a,b = map(int,input().split())\r\ncount = 0\r\ni = 1\r\nwhile i < a+1:\r\n if i > b:\r\n break\r\n else:\r\n if b % i == 0:\r\n if b // i <= a:\r\n count += 1\r\n i += 1\r\nprint(count)\n# Tue Jan 03 2023 11:35:02 GMT+0300 (Moscow Standard Time)\n", "a,b=map(int,input().split())\r\nprint((b<=a)+sum(1 for i in range(2,a+1) if i*a>=b and b%i==0))", "n, x = map(int, input().split())\r\nt = 0\r\nfor i in range(1, n+1):\r\n if x%i == 0 and x<=n*i:\r\n t += 1\r\nprint(t)", "n,x=map(int,input().split())\r\nc=0\r\nfor i in range(1, n + 1):\r\n if x % i == 0 :\r\n r = x // i\r\n if r <= n:\r\n c += 1\r\nprint(c)\r\n", "#-*- coding = utf-8 -*-\r\n#@Time : 2023/6/23 17:36\r\n#@Author : xht\r\n#@File : 577A Multiplication Table.py\r\n#@Software: PyCharm\r\nn , x = map(int , input().split())\r\nprint(sum((x % i == 0 and x / i <= n) for i in range(1 , n + 1)))", "import sys\r\ninput = sys.stdin.readline\r\n\r\ndef main() -> None :\r\n TABLE_WIDTH, SEARCH_NUM = map(int, input().split())\r\n\r\n numCount:int = 0\r\n for dividNum in range(1, TABLE_WIDTH+1) :\r\n if SEARCH_NUM%dividNum==0 and SEARCH_NUM//dividNum<=TABLE_WIDTH :\r\n numCount += 1\r\n\r\n print(numCount)\r\n\r\nmain()", "n,x=map(int,input().split())\r\nc=0\r\nif x<=n:\r\n s=1\r\nelse:\r\n s=2\r\nfor i in range(s,n+1):\r\n if x<=n*i:\r\n if x%i==0:\r\n c+=1 \r\nprint(c) ", "n,x=map(int,input().split())\r\ncount=0\r\nfor i in range(n):\r\n if x%(i+1)==0 and x/(i+1)<=n:\r\n count+=1\r\nprint(count)", "def solve():\r\n n, x = list(map(int, input().split()))\r\n\r\n cnt = 0\r\n for i in range(1, n+1):\r\n if x%i==0:\r\n fac = x/i\r\n if fac <= n:\r\n cnt+=1\r\n\r\n print(cnt)\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()", "n, a=list(map(int, input().split()))\r\ns=0\r\nfor i in range(1, n+1):\r\n if a%i==0 and a//i<=n:\r\n s+=1\r\nprint(s)", " \r\n#import io, os, sys\r\n#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n#print = lambda x: sys.stdout.write(str(x) + \"\\n\")\r\n \r\nII = lambda: int(input())\r\nMII = lambda: map(int, input().split())\r\nLMII = lambda: list(MII())\r\n#SLMII = lambda: sorted(LMII())\r\n\r\nn, x = MII()\r\n\r\nk = 1\r\nans = 0\r\nwhile k*k <= x:\r\n if not x%k and k <= n and x//k <= n:\r\n ans += 1 + int(k!=x//k)\r\n k += 1\r\n \r\nprint(ans)\r\n ", "from sys import stdin\r\n\r\ndef divs(n):\r\n if n == 1: return [(1,1)]\r\n ret = []\r\n for x in range(1,n):\r\n if x*x > n: break\r\n if n%x == 0:\r\n ret.append((x,n//x))\r\n return ret\r\n\r\na, b = [int(n) for n in stdin.readlines()[0].split()]\r\ndiv_arr = divs(b)\r\nS = 0\r\nfor t in div_arr:\r\n if t[0] <= a and t[1] <= a:\r\n if t[0] == t[1]:\r\n S += 1\r\n else:\r\n S += 2\r\nprint(S)\r\n\r\n", "a = 0\r\nn, m = map(int, input().split())\r\nfor i in range(1, int(m ** 0.5) + 1):\r\n if m % i == 0 and m // i <= n:\r\n a += 2\r\n if m // i == i: a -= 1\r\nprint(a)", "from collections import Counter\r\n\r\n\r\ndef main():\r\n delit = []\r\n summ = 0\r\n pairs = set()\r\n\r\n n, x = map(int, input().split())\r\n\r\n for i in range(n, 0, -1):\r\n if x % i == 0:\r\n delit.append(i)\r\n for i in delit:\r\n for j in delit:\r\n if i*j == x:\r\n pairs.add(tuple((i, j)))\r\n delit.reverse()\r\n for i in delit:\r\n for j in delit:\r\n if i * j == x:\r\n pairs.add(tuple((i, j)))\r\n print(len(pairs))\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "n,x=[int(i) for i in input().split()]\r\nans=0\r\nfor i in range(1,n+1):\r\n\tif x%i==0 and x/i<=n:\r\n\t\tans+=1\r\nprint(ans)", "x, n = map(int,input().split())\r\ni = 1\r\nj = 0\r\nwhile i * i <= n:\r\n if i <= x and n // i <= x:\r\n if n % i == 0:\r\n if i == n // i:\r\n j += 1\r\n else:\r\n j += 2\r\n i += 1\r\nprint(j)", "x = input().split()\r\nn = int(x[0])\r\nx = int(x[1])\r\ncount = 0\r\n\r\nfor i in range(1,min(n,x)+1):\r\n if x % i == 0 and (x/i <= n):\r\n count+=1\r\n\r\nprint(count)", "n, x = list(map(int, input().split()))\r\nans = 0\r\nfor i in range(1, n + 1):\r\n if x % i != 0:\r\n continue\r\n else:\r\n if x / i <= n:\r\n ans += 1\r\n else:\r\n continue\r\nprint(ans)", "def div(x, n):\r\n count = int(0)\r\n for i in range(1, n + 1):\r\n if x % i == 0:\r\n if x / i <= n:\r\n count += 1\r\n return count\r\nif __name__ == '__main__':\r\n n, x, = map(int, input().split())\r\n print(div(x, n))", "inp = [int(i) for i in input().split()]\r\nn, x = inp[0], inp[1]\r\ncounter = 0\r\nfor i in range(1, n + 1):\r\n if x % i == 0 and i * n >= x:\r\n counter += 1\r\nprint(counter)", "class Solution:\r\n\tdef __init__(self):\r\n\t\tpass\r\n\r\n\tdef solve(self):\r\n\t\tn, x = map(int, input().split())\r\n\t\tcount = 0\r\n\r\n\t\tfor i in range(n, 0, -1):\r\n\t\t\tif x % i == 0:\r\n\t\t\t\tif x // i <= n:\r\n\t\t\t\t\tcount += 1\r\n\r\n\t\tprint(count)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n\tsol = Solution()\r\n\tsol.solve()\r\n", "c=0\r\nn,x=map(int,input().split())\r\nfor _ in range(1,n+1):\r\n if(x%_==0 and x//_<=n):\r\n c+=1\r\nprint(c)\r\n ", "n,x=input().split()\r\nn=int(n)\r\nx=int(x)\r\nc=0\r\nfor i in range(2,n+1):\r\n if(x%i==0 and x/i<=n):\r\n c=c+1\r\nif(n>=x):\r\n c=c+1\r\nprint(c)", "t,t1=map(int,input().split())\r\nk=0\r\nfor q in range(1,t+1):\r\n if q>t1:\r\n break\r\n if (t1/q)%1==0:\r\n if int(t1/q)<=t:\r\n k+=1\r\nprint(k)", "import math\r\n\r\nn, x = map(int, input().split())\r\na = []\r\nl = math.ceil(math.sqrt(x))\r\nfor i in range(1, l+1):\r\n if x % i == 0:\r\n if x // i <= n and i <= n: \r\n if i not in a:\r\n a.append(i)\r\n if x // i not in a:\r\n a.append(x // i)\r\nans = 0\r\n\r\nfor i in a:\r\n if i <= n:\r\n ans += 1\r\n\r\nprint(ans)", "y, x = map(int ,input().split())\r\nlol = 1 \r\ncnt = 0\r\nwhile lol < int(x ** .5 )+1 :\r\n if x / lol == x // lol :\r\n if x // lol <= y:\r\n cnt += 2\r\n if lol == x // lol :\r\n cnt -= 1 \r\n lol += 1\r\nprint(cnt)", "n,x=map(int,input().split())\r\ncount=0\r\ni=1\r\nwhile i*i<=x:\r\n if x%i==0 and i<=n and x//i<=n:\r\n\r\n if i!=x//i:\r\n count+=2\r\n else:\r\n count+=1\r\n i+=1\r\nprint(count)", "[size,num]=map(int,input().split())\r\ncount=0\r\nfor i in range(1,size+1):\r\n if num%i==0 and num/i<=size:\r\n count+=1\r\nprint(count)", "n,m=map(int,input().split())\r\nres=0\r\nfor i in range(1,n+1):\r\n\tif m%i==0 and i*n>=m:\r\n\t\tres+=1\r\nprint(res)", "import sys\r\nimport os\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 sys.stderr = open(\"error.txt\",\"w\")\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\ny, x = map(int ,input().split())\r\nlol = 1 \r\ncnt = 0\r\nwhile lol < int(x ** .5 )+1 :\r\n if x / lol == x // lol :\r\n if x // lol <= y:\r\n cnt += 2\r\n if lol == x // lol :\r\n cnt -= 1 \r\n lol += 1\r\nprint(cnt)\r\n", "n,x=map(int,input().split())\r\nl=[i for i in range(1,n+1) if x%i==0 and x//i<=n]\r\nprint(len(l))\r\n", "n, x = map(int, input().split())\r\n\r\ni=1\r\ncnt=0\r\nwhile i**2<=x:\r\n if x%i==0 and i<=n and x//i<=n:\r\n #print(i, x//i)\r\n if i!=x//i:\r\n cnt=cnt+2\r\n else:\r\n cnt=cnt+1\r\n #print(cnt)\r\n i=i+1\r\nprint(cnt)", "n,m = map(int,input().split())\r\ncount = 0\r\nfor i in range(1,n+1):\r\n if m % i == 0 and m / i <= n:\r\n count += 1\r\n\r\nprint(count)", "m,n=map(int, input().split())\r\ncount=0\r\nfor i in range(1,m+1):\r\n if(n/i<=m and n%i==0):\r\n count+=1\r\nprint(count)", "n,x = [int(i) for i in input().split()] \nans = 0 \nfor i in range(1,n+1): \n if x%i == 0 and x/i <= n: ans += 1\nprint(ans) ", "stuff = list(map(int, input().split()))\nn = stuff[0]\nx = stuff[1]\ncount = 0\n# for i in range length of square n\nfor i in range(n):\n\t#check if x is divisible by i \n\tif (x%(i+1) == 0):\n\t\tif int(x/(i+1)) <= n:\n\t\t\tcount += 1\n\telse:\n\t\tpass\n\nprint(count)\n\n", "from sys import stdin\nfrom math import sqrt\n\ndef line(): return stdin.readline().strip()\ndef rd(converter): return converter(line())\ndef rl(converter, delimeter = None): return list(map(converter, line().split(delimeter)))\ndef rls(num_lines, converter): return [rd(converter) for i in range(num_lines)]\ndef rg(num_lines, converter, delimeter = None): return [rl(converter,delimeter) for i in range(num_lines)]\n\nMULTIPLE_CASES = 0\n\ndef main():\n N,X = rl(int)\n print(sum((1 if num == X//num else 2) if X%num == 0 and X//num <= N else 0 for num in range(1,min(N,int(sqrt(X)))+1)))\n\nfor i in range(rd(int) if MULTIPLE_CASES else 1): main()", "n, x = [int(_) for _ in input().split()]\r\nfactors = 0\r\nfor i in range(1, n+1):\r\n if x % i == 0 and x / i <= n:\r\n factors += 1\r\n\r\nprint(factors)\r\n\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn, x = map(int, input().split())\r\n\r\nc = 0\r\nfor i in range(1, int(x**0.5)+1):\r\n if x % i == 0:\r\n if i <= n and x//i <= n:\r\n if i == x//i:\r\n c += 1\r\n else:\r\n c += 2\r\nprint(c)\r\n\r\n", "n, x = map(int, input().split())\r\ncount = 0\r\nd = 1\r\nwhile d * d <= x:\r\n if x % d == 0 and d <= n and x//d <= n:\r\n if d != x//d:\r\n count += 2\r\n else:\r\n count += 1\r\n d += 1\r\nprint(count)", "a,b=map(int,input().split())\r\nx=0\r\nfor i in range(1,a+1):\r\n\tif b%i==0 and b//i<=a:\r\n\t\tx+=1\r\nprint(x)", "def solve():\r\n n, x = map(int, input().split())\r\n cnt = 0\r\n for i in range(n+1):\r\n cnt += x <= i*n and x % i == 0\r\n print(cnt)\r\n\r\n\r\n# t = int(input())\r\nt = 1\r\nwhile t:\r\n solve()\r\n t -= 1\r\n", "x,y=input().split()\r\nx=int(x)\r\ny=int(y)\r\nc=0\r\nif y>x*x:\r\n\tprint(c)\r\nelse:\r\n\tn=1\r\n\twhile n<=x:\r\n\t\tif y%n==0:\r\n\t\t\tif y//n<=x:\r\n\t\t\t\tc+=1\r\n\t\tn+=1\r\n\tprint(c)\r\n\t \r\n\t\t\t\r\n\r\n\r\n", "n,x=[int(x) for x in input().split()]\r\nres=0\r\nfor k in range(1,n+1):\r\n if k*k<=x and x<=k*n and x%k==0:\r\n if x==k*k:\r\n res+=1\r\n else:\r\n res+=2\r\nprint(res)\r\n", "n, x = map(int, input().split())\r\nc = 0\r\nfor i in range(1, n+1):\r\n if x%i==0 and x//i<=n:\r\n c += 1\r\nprint(c)\r\n", "n,x = map(int, input().split())\r\ni = 1\r\ns = []\r\nwhile i <= n:\r\n if x % i == 0 and x // i <= n:\r\n s.append(i)\r\n if x // i <= n:\r\n s.append(x // i)\r\n i += 1\r\nprint(len(s)//2)", "n, x = map(int, input().split())\r\ni = 1\r\nk = 0\r\nwhile i <= n and i * i <= x:\r\n if x % i == 0 and x // i <= n:\r\n if i * i == x:\r\n k += 1\r\n else:\r\n k += 2\r\n i += 1\r\nprint(k)", "# Ahmed Abdelrazik\r\nT = 0\r\nn,x = map(int,input().split())\r\nfor i in range(1,n+1):\r\n if x%i==0 and x/i <= n: T+=1\r\nprint(T)", "def solve():\r\n n, x = map(int, input().split())\r\n ans = 0\r\n for i in range(1,n+1):\r\n if x % i == 0 and x/i<=n:\r\n ans += 1\r\n print(ans)\r\n\r\nfor _ in range(1):\r\n solve()\r\n", "n,x=map(int,input().split())\r\ni=1\r\ncount=0\r\nwhile i<=n:\r\n if x%i==0 and x//i<=n:\r\n count+=1\r\n## print('found i',i)\r\n i+=1\r\n## print(i)\r\nprint(count)\r\n\r\n", "from math import sqrt, floor\r\nn, x = map(int, input().split())\r\nsq = sqrt(x) \r\nlimit = floor(sq)\r\n\r\ncnt = 0\r\nfor i in range(1, limit + 1):\r\n if x % i == 0 and x // i <= n:\r\n if x // i == i:\r\n cnt += 1\r\n else:\r\n cnt += 2\r\n\r\nprint(cnt)", "n, x = map(int, input().split())\r\nres = 0\r\nfor y in range(1, n + 1):\r\n if x % y == 0 and x / y <= n:\r\n res += 1\r\nprint(res)\r\n", "n,x=map(int,input().split())\r\nq = 0\r\nfor i in range(1,n+1):\r\n if x%i == 0 and x/i <= n:\r\n q += 1\r\nprint(q)\r\n", "from functools import reduce\r\ndef factors(n): \r\n global a\r\n return len(list(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0 and i <= a and n/i <= a)))))\r\na,b,x = *map(int,input().split()),0\r\ntry:\r\n print(factors(b))\r\nexcept:\r\n print(\"0\")", "# for _ in range(int(input())):\r\nn,x=map(int,input().split())\r\narr=[]\r\nfor i in range(1,n+1):\r\n arr.append([i,n*i])\r\ncnt=0\r\nfor i in arr:\r\n if x>=i[0] and x<=i[1] and x%i[0]==0:\r\n cnt+=1\r\nprint(cnt)\r\n", "numbers = [int(x) for x in input().split()]\r\n\r\nn = numbers[0]\r\n\r\nx = numbers[1]\r\n\r\nans = 0\r\n\r\nfor i in range(1, n + 1):\r\n\r\n\tif i * n >= x:\r\n\r\n\t\tif x % i == 0:\r\n\r\n\t\t\tans += 1\r\n\r\nprint(ans)", "def count(n,x):\r\n i,count = 1,0\r\n while i*i<=x:\r\n if x%i==0:\r\n mod = x//i\r\n c = (1<=i<=n) and (1<=mod<=n)\r\n if c and mod==i:\r\n count+=1\r\n elif c and mod!=i:\r\n count+=2\r\n i+=1\r\n return count\r\n\r\nn,x = map(int,input().split())\r\nprint(count(n,x))", "a,b=map(int, input().split())\r\nc=0\r\nfor i in range(1,a+1):\r\n d=b//i\r\n if b%i==0 and d<=a:\r\n c+=1\r\nprint(c)", "a,b=map(int,input().split())\r\nres= [i for i in range(a) if b%(i+1)==0 and b/(i+1)<=a]\r\nprint(len(res))", "a,b=map(int,input().split())\r\ns=[]\r\nfor i in range(1,a+1):\r\n if b%i==0 and b<=i*a:\r\n s.append(i)\r\nprint(len(s))", "def factors(n,limit):\r\n i = 1\r\n same = 0\r\n diff = 0\r\n while i*i <= n:\r\n if n%i == 0:\r\n if n//i != i:\r\n if n//i <=limit and i <= limit:\r\n diff +=1\r\n else:\r\n if i <= limit:\r\n same +=1\r\n i+=1\r\n return (2*diff)+same\r\n\r\nlimit,n = map(int,input().split())\r\nprint(factors(n,limit))", "rows, num = [int(x) for x in input().split()]\r\ntimes = 0\r\ni = 1\r\nwhile i * i <= num:\r\n if num % i == 0 and i <= rows and num // i <= rows:\r\n if i != num // i:\r\n times += 2\r\n else:\r\n times += 1\r\n i += 1\r\n\r\nprint(times)\r\n", "l=[int(i) for i in input().split()]\r\nn=l[0]\r\nx=l[1]\r\ncount=0\r\nfor i in range(1,int(x**0.5)+1):\r\n if x%i==0 and x//i<=n:\r\n count+=2\r\nif (int(x**0.5))**2==x and x**0.5<=n:\r\n count-=1\r\nprint(count)", "n , x = map(int,input().split())\r\nans = 0\r\nfor i in range(1,n+1):\r\n if(x%i == 0):\r\n if(x//i <= n):\r\n ans = ans + 1\r\nprint(ans)", "from math import*\r\nn,m = [int(i) for i in input().split()]\r\nb = []\r\nc = []\r\nfor i in range(1, int(sqrt(m))+1):\r\n if m%i == 0:\r\n b.append(i)\r\n c.append(m//i)\r\nl = 0\r\nfor i in range(len(b)):\r\n if b[i] <= n and c[i] <= n and b[i] != c[i]:\r\n l += 2\r\n elif b[i] <= n and c[i] <= n:\r\n l+=1\r\nprint(l)" ]
{"inputs": ["10 5", "6 12", "5 13", "1 1", "2 1", "100000 1", "1 1000000000", "100000 1000000000", "100000 362880", "1 4", "9 12", "10 123", "9551 975275379", "17286 948615687", "58942 936593001", "50000 989460910", "22741 989460910", "22740 989460910", "100000 989460910", "100000 98280", "100000 997920", "100000 720720", "100000 2162160", "100000 4324320", "100000 8648640", "100000 183783600", "100000 551350800", "40000 551350800", "20000 400000000", "19999 400000000", "19999 399960001", "31621 999887641", "31622 999887641", "31620 999887641", "100000 999887641", "100000 25", "100000 1", "100000 3628800", "100000 39916800", "100000 479001600", "4 9", "2 6", "20 100", "10 3", "4 4", "2 4", "89874 1"], "outputs": ["2", "4", "0", "1", "1", "1", "0", "16", "154", "0", "4", "0", "0", "0", "0", "4", "0", "0", "4", "128", "222", "226", "282", "320", "348", "438", "392", "150", "1", "0", "1", "1", "1", "0", "3", "3", "1", "220", "328", "254", "1", "0", "3", "2", "3", "1", "1"]}
UNKNOWN
PYTHON3
CODEFORCES
257
e01325cc3bb47d387ca422ff653548a6
none
Students love to celebrate their holidays. Especially if the holiday is the day of the end of exams! Despite the fact that Igor K., unlike his groupmates, failed to pass a programming test, he decided to invite them to go to a cafe so that each of them could drink a bottle of... fresh cow milk. Having entered the cafe, the *m* friends found *n* different kinds of milk on the menu, that's why they ordered *n* bottles — one bottle of each kind. We know that the volume of milk in each bottle equals *w*. When the bottles were brought in, they decided to pour all the milk evenly among the *m* cups, so that each got a cup. As a punishment for not passing the test Igor was appointed the person to pour the milk. He protested that he was afraid to mix something up and suggested to distribute the drink so that the milk from each bottle was in no more than two different cups. His friends agreed but they suddenly faced the following problem — and what is actually the way to do it? Help them and write the program that will help to distribute the milk among the cups and drink it as quickly as possible! Note that due to Igor K.'s perfectly accurate eye and unswerving hands, he can pour any fractional amount of milk from any bottle to any cup. The only input data file contains three integers *n*, *w* and *m* (1<=≤<=*n*<=≤<=50, 100<=≤<=*w*<=≤<=1000, 2<=≤<=*m*<=≤<=50), where *n* stands for the number of ordered bottles, *w* stands for the volume of each of them and *m* stands for the number of friends in the company. Print on the first line "YES" if it is possible to pour the milk so that the milk from each bottle was in no more than two different cups. If there's no solution, print "NO". If there is a solution, then print *m* more lines, where the *i*-th of them describes the content of the *i*-th student's cup. The line should consist of one or more pairs that would look like "*b* *v*". Each such pair means that *v* (*v*<=&gt;<=0) units of milk were poured into the *i*-th cup from bottle *b* (1<=≤<=*b*<=≤<=*n*). All numbers *b* on each line should be different. If there are several variants to solve the problem, print any of them. Print the real numbers with no less than 6 digits after the decimal point. Sample Input 2 500 3 4 100 5 4 100 7 5 500 2 Sample Output YES 1 333.333333 2 333.333333 2 166.666667 1 166.666667 YES 3 20.000000 4 60.000000 1 80.000000 4 40.000000 2 40.000000 3 80.000000 2 60.000000 1 20.000000 NO YES 4 250.000000 5 500.000000 2 500.000000 3 500.000000 1 500.000000 4 250.000000
[ "import sys\r\nfrom array import array # noqa: F401\r\n\r\n\r\ndef input():\r\n return sys.stdin.buffer.readline().decode('utf-8')\r\n\r\n\r\nn, w, m = map(int, input().split())\r\nw = float(w)\r\neps = 1e-9\r\nreq = n * w / m\r\ncup = [req] * m\r\nans = [[] for _ in range(m)]\r\nj = 0\r\n\r\nfor i in range(n):\r\n milk = w\r\n cnt = 0\r\n while j < m and milk > eps:\r\n x = min(milk, cup[j])\r\n milk -= x\r\n cup[j] -= x\r\n ans[j].append(f'{i+1} {x:.8f}')\r\n cnt += 1\r\n if cup[j] < eps:\r\n j += 1\r\n if cnt > 2:\r\n print('NO')\r\n exit()\r\n\r\nprint('YES')\r\nprint('\\n'.join(' '.join(line) for line in ans))\r\n", "EPS = 1e-9\r\n\r\nclass Bottle:\r\n def __init__(self, i, c1, c2, v):\r\n self.i = i\r\n self.c1 = c1\r\n self.c2 = c2\r\n self.v = v\r\n\r\nclass Cup:\r\n def __init__(self, i, v):\r\n self.i = i\r\n self.v = v\r\n self.b = [0] * 50\r\n\r\ndef distribute_milk(n, w, m):\r\n if 2 * n < m:\r\n print('NO')\r\n return\r\n\r\n w0 = n * w / float(m)\r\n b = [Bottle(i, 0, 0, w) for i in range(1, n + 1)]\r\n c = [Cup(i, 0) for i in range(1, m + 1)]\r\n\r\n for k in range(1, 2 * n + 1):\r\n i = (k + 1) // 2\r\n if abs(b[i - 1].v) < EPS:\r\n continue\r\n for j in range(1, m + 1):\r\n if abs(c[j - 1].v - w0) < EPS:\r\n continue\r\n if b[i - 1].c1 == j or b[i - 1].c2 == j:\r\n continue\r\n if b[i - 1].c1 == 0:\r\n b[i - 1].c1 = j\r\n else:\r\n b[i - 1].c2 = j\r\n if b[i - 1].v > w0 - c[j - 1].v + EPS:\r\n b[i - 1].v -= (w0 - c[j - 1].v)\r\n c[j - 1].b[b[i - 1].i - 1] = w0 - c[j - 1].v\r\n c[j - 1].v = w0\r\n else:\r\n c[j - 1].v += b[i - 1].v\r\n c[j - 1].b[b[i - 1].i - 1] = b[i - 1].v\r\n b[i - 1].v = 0\r\n break\r\n\r\n for i in range(1, m + 1):\r\n if abs(c[i - 1].v - w0) > EPS:\r\n print('NO')\r\n return\r\n\r\n print('YES')\r\n for i in range(1, m + 1):\r\n f = True\r\n for j in range(1, n + 1):\r\n if c[i - 1].b[j - 1] > EPS:\r\n if not f:\r\n print(' ', end='')\r\n print(j, ' %.12f' % c[i - 1].b[j - 1], end='')\r\n f = False\r\n print()\r\n\r\nif __name__ == \"__main__\":\r\n n, w, m = map(int, input().split())\r\n distribute_milk(n, w, m)\r\n", "#!/usr/bin/python3\n\nn, w, m = map(int, input().split())\n\nif n > m:\n print(\"YES\")\n i = 0\n cur = w\n for j in range(m):\n milk = 0\n while milk < (w * n) / m - 1e-8:\n amount = min(cur, (w * n) / m - milk)\n print(i + 1, amount, end=' ')\n milk += amount\n cur -= amount\n if abs(cur) < 1e-8:\n i += 1\n cur = w\n print()\nelse:\n ans = [[] for i in range(m)]\n sums = [0 for i in range(m)]\n left = [w for i in range(n)]\n for i in range(m):\n while sums[i] < (w * n) / m - 1e-8:\n mx = 0\n for j in range(n):\n if left[j] > left[mx]:\n mx = j\n amount = min(left[mx], (w * n) / m - sums[i])\n if left[mx] < w and amount < left[mx] - 1e-8:\n print(\"NO\")\n exit(0)\n sums[i] += amount\n left[mx] -= amount\n ans[i].append((mx, amount))\n print(\"YES\")\n for i in range(m):\n for a, b in ans[i]:\n print(a + 1, b, end=' ')\n print()\n", "#!/usr/bin/python3\r\nfrom fractions import Fraction\r\n\r\nN,W,M = [int(x) for x in input().strip().split()]\r\nP = Fraction(N*W,M)\r\nvolume = [W]*N\r\ncounts = [0]*N\r\nans = []\r\nidx = 0\r\nfor i in range(M):\r\n\trem = P\r\n\tsel = []\r\n\twhile rem > 0:\r\n\t\tcounts[idx] += 1\r\n\t\tif volume[idx] > rem:\r\n\t\t\tsel.append((idx,rem))\r\n\t\t\tvolume[idx] -= rem\r\n\t\t\trem = 0\r\n\t\telse:\r\n\t\t\tsel.append((idx,volume[idx]))\r\n\t\t\trem -= volume[idx]\r\n\t\t\tvolume[idx] = 0\r\n\t\t\tidx += 1\r\n\tans.append(sel)\r\n\r\nif max(counts) > 2: print(\"NO\")\r\nelse:\r\n\tprint(\"YES\")\r\n\tfor sel in ans:\r\n\t\tfor f in sel: print(f[0]+1,'{0:.9f}'.format(f[1].numerator/f[1].denominator),end=\" \")\r\n\t\tprint()", "n, w, m = map(int, input().split())\r\nmid = w * n / m\r\ncnt = [0] * (n + 2)\r\nidx = 0\r\ncur = [mid] * m\r\nres = [[] for i in range(m)]\r\n\r\nfor i in range(n):\r\n\tma4rop = w\r\n\twhile ma4rop > 1e-9 and idx < m:\r\n\t\ttmp = min(ma4rop, cur[idx])\r\n\t\tma4rop -= tmp\r\n\t\tcur[idx] -= tmp\r\n\t\tcnt[i] += 1\r\n\t\tres[idx].append([i + 1, tmp])\r\n\t\tif cur[idx] < 1e-9:\r\n\t\t\tidx += 1\r\n\t\t\t\r\n\tif cnt[i] > 2:\r\n\t\tprint(\"NO\")\r\n\t\texit(0)\r\n\r\nprint(\"YES\")\r\nfor i in res:\r\n\tfor j in i:\r\n\t\tprint(j[0], j[1], end = ' ')\r\n\tprint()" ]
{"inputs": ["2 500 3", "4 100 5", "4 100 7", "5 500 2", "4 100 8", "1 1000 2", "2 500 4", "2 500 5", "9 1000 12", "20 1000 30", "50 1000 50", "50 1000 49", "49 1000 50", "40 1000 50", "48 1000 50", "45 1000 50", "30 1000 40", "20 1000 25", "21 1000 27", "21 1000 28", "21 1000 29", "22 1000 30", "3 356 14", "9 120 13", "1 301 20", "11 489 14", "6 218 16", "2 632 19", "14 157 19", "12 430 14", "16 980 19", "1 736 10", "4 650 19", "3 953 13", "10 524 8", "6 283 11", "5 825 16", "13 557 13", "13 503 9", "12 255 8", "11 827 13", "4 381 16", "18 624 32", "30 864 48", "26 637 16", "13 322 43", "12 792 38", "30 628 23", "2 190 29", "33 353 40", "21 608 35", "46 328 27", "44 371 47", "9 615 50", "4 574 9", "13 751 24", "5 556 43", "2 449 45", "21 665 45", "26 905 31", "26 856 49", "6 804 32", "15 737 26", "35 462 50", "34 948 42", "9 929 41", "11 324 24", "2 227 11", "3 606 41", "21 452 43", "19 134 48", "28 595 48", "36 371 42", "23 511 24", "24 836 25", "28 380 29", "24 704 30", "30 565 40", "35 948 42", "6 578 9", "24 619 28", "30 986 32", "26 381 28", "24 743 32", "24 459 27", "25 531 26", "40 897 42", "24 371 26", "18 169 20", "24 264 25", "27 884 28", "18 922 21", "37 772 38", "32 610 40", "22 771 23", "22 792 24", "40 100 48", "42 501 48", "36 100 39", "42 171 49", "17 100 10", "5 100 7"], "outputs": ["YES\n1 333.333333\n2 333.333333\n2 166.666667 1 166.666667", "YES\n3 20.000000 4 60.000000\n1 80.000000\n4 40.000000 2 40.000000\n3 80.000000\n2 60.000000 1 20.000000", "NO", "YES\n4 250.000000 5 500.000000 2 500.000000\n3 500.000000 1 500.000000 4 250.000000", "YES\n3 50.000000\n1 50.000000\n2 50.000000\n4 50.000000\n1 50.000000\n3 50.000000\n2 50.000000\n4 50.000000", "YES\n1 500.000000\n1 500.000000", "YES\n2 250.000000\n2 250.000000\n1 250.000000\n1 250.000000", "NO", "YES\n3 750.000000\n6 750.000000\n7 250.000000 2 500.000000\n5 750.000000\n9 250.000000 2 500.000000\n4 500.000000 8 250.000000\n6 250.000000 1 500.000000\n4 500.000000 5 250.000000\n7 750.000000\n8 750.000000\n1 500.000000 3 250.000000\n9 750.000000", "YES\n5 666.666667\n18 666.666667\n19 666.666667\n9 333.333333 18 333.333333\n14 666.666667\n1 666.666667\n20 333.333333 8 333.333333\n2 666.666667\n1 333.333333 12 333.333333\n12 666.666667\n8 666.666667\n16 666.666667\n16 333.333333 5 333.333333\n10 666.666667\n20 666.666667\n4 666.666667\n9 666.666667\n4 333.333333 7 333.333333\n13 333.333333 2 333.333333\n15 333.333333 14 333.333333\n6 666.666667\n19 333.333333 6 333.333333\n7 666.666667\n3 666.666667\n11 333.333333 17 333.333333\n15 666.666667\n10 333....", "YES\n50 1000.000000\n46 1000.000000\n15 1000.000000\n32 1000.000000\n11 1000.000000\n24 1000.000000\n12 1000.000000\n16 1000.000000\n1 1000.000000\n36 1000.000000\n40 1000.000000\n25 1000.000000\n2 1000.000000\n44 1000.000000\n33 1000.000000\n31 1000.000000\n38 1000.000000\n47 1000.000000\n30 1000.000000\n34 1000.000000\n19 1000.000000\n5 1000.000000\n4 1000.000000\n42 1000.000000\n49 1000.000000\n35 1000.000000\n27 1000.000000\n43 1000.000000\n22 1000.000000\n8 1000.000000\n28 1000.000000\n37 1000.000000\n...", "YES\n1 81.632653 50 938.775510\n46 816.326531 19 204.081633\n15 142.857143 14 877.551020\n32 857.142857 30 163.265306\n11 306.122449 40 714.285714\n24 714.285714 34 306.122449\n6 571.428571 12 448.979592\n29 938.775510 16 81.632653\n28 102.040816 1 918.367347\n36 326.530612 11 693.877551\n26 734.693878 40 285.714286\n25 102.040816 16 918.367347\n10 40.816327 2 979.591837\n44 224.489796 17 795.918367\n33 755.102041 41 265.306122\n8 510.204082 31 510.204082\n15 857.142857 38 163.265306\n33 244.897959 47 775....", "YES\n40 280.000000 11 700.000000\n19 220.000000 47 760.000000\n13 20.000000 2 960.000000\n30 180.000000 46 800.000000\n15 860.000000 14 120.000000\n35 480.000000 31 500.000000\n17 200.000000 44 780.000000\n30 820.000000 32 160.000000\n3 380.000000 5 600.000000\n3 620.000000 22 360.000000\n12 440.000000 7 540.000000\n40 720.000000 26 260.000000\n10 940.000000 2 40.000000\n1 100.000000 28 880.000000\n23 460.000000 35 520.000000\n32 840.000000 37 140.000000\n16 80.000000 25 900.000000\n20 40.000000 29 940.000...", "YES\n12 800.000000\n34 800.000000\n35 800.000000\n26 200.000000 4 600.000000\n16 600.000000 30 200.000000\n12 200.000000 7 600.000000\n20 400.000000 23 400.000000\n24 400.000000 39 400.000000\n27 200.000000 38 600.000000\n40 800.000000\n1 200.000000 28 600.000000\n18 200.000000 21 600.000000\n25 800.000000\n31 800.000000\n2 600.000000 13 200.000000\n18 800.000000\n10 400.000000 2 400.000000\n14 600.000000 17 200.000000\n9 200.000000 20 600.000000\n27 800.000000\n15 200.000000 36 600.000000\n36 400.000000 1...", "YES\n20 40.000000 29 920.000000\n24 400.000000 41 560.000000\n6 200.000000 5 760.000000\n42 720.000000 21 240.000000\n40 480.000000 26 480.000000\n44 600.000000 17 360.000000\n3 280.000000 22 680.000000\n1 800.000000 45 160.000000\n41 440.000000 33 520.000000\n25 160.000000 14 800.000000\n7 120.000000 12 840.000000\n34 360.000000 24 600.000000\n22 320.000000 43 640.000000\n23 80.000000 48 880.000000\n31 40.000000 8 920.000000\n31 960.000000\n23 920.000000 35 40.000000\n45 840.000000 10 120.000000\n30 640.0...", "YES\n15 700.000000 14 200.000000\n14 800.000000 25 100.000000\n12 900.000000\n32 200.000000 37 700.000000\n40 900.000000\n5 700.000000 6 200.000000\n8 200.000000 31 700.000000\n13 100.000000 2 800.000000\n1 500.000000 28 400.000000\n41 500.000000 24 400.000000\n42 900.000000\n2 200.000000 10 700.000000\n5 300.000000 3 600.000000\n34 300.000000 24 600.000000\n42 100.000000 27 800.000000\n44 700.000000 4 200.000000\n9 300.000000 20 600.000000\n23 500.000000 20 400.000000\n12 100.000000 6 800.000000\n16 900.0...", "YES\n7 250.000000 8 500.000000\n11 250.000000 23 500.000000\n14 500.000000 15 250.000000\n18 500.000000 9 250.000000\n27 500.000000 17 250.000000\n13 750.000000\n7 750.000000\n3 750.000000\n17 750.000000\n3 250.000000 8 500.000000\n6 500.000000 12 250.000000\n24 750.000000\n21 750.000000\n29 750.000000\n10 750.000000\n1 500.000000 25 250.000000\n28 250.000000 1 500.000000\n27 500.000000 4 250.000000\n19 500.000000 29 250.000000\n19 500.000000 16 250.000000\n4 750.000000\n20 250.000000 23 500.000000\n5 750....", "YES\n16 400.000000 19 400.000000\n13 800.000000\n15 800.000000\n9 600.000000 18 200.000000\n7 800.000000\n12 600.000000 1 200.000000\n5 800.000000\n2 400.000000 10 400.000000\n12 400.000000 8 400.000000\n8 600.000000 20 200.000000\n20 800.000000\n6 800.000000\n6 200.000000 19 600.000000\n10 600.000000 3 200.000000\n16 600.000000 5 200.000000\n3 800.000000\n4 600.000000 7 200.000000\n11 600.000000 17 200.000000\n13 200.000000 2 600.000000\n17 800.000000\n14 400.000000 11 400.000000\n15 200.000000 14 600.000...", "NO", "YES\n2 500.000000 10 250.000000\n16 250.000000 19 500.000000\n4 750.000000\n17 750.000000\n1 500.000000 3 250.000000\n15 750.000000\n7 500.000000 4 250.000000\n5 250.000000 20 500.000000\n21 750.000000\n12 750.000000\n13 750.000000\n5 750.000000\n3 750.000000\n6 750.000000\n16 750.000000\n7 500.000000 17 250.000000\n8 750.000000\n15 250.000000 14 500.000000\n19 500.000000 6 250.000000\n21 250.000000 18 500.000000\n18 500.000000 9 250.000000\n9 750.000000\n1 500.000000 12 250.000000\n10 750.000000\n8 250.00...", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "YES\n9 122.857143 7 245.714286\n1 122.857143 3 245.714286\n9 307.142857 6 61.428571\n4 307.142857 8 61.428571\n10 245.714286 2 122.857143\n1 307.142857 12 61.428571\n4 122.857143 5 245.714286\n7 184.285714 5 184.285714\n10 184.285714 3 184.285714\n8 368.571429\n12 368.571429\n11 368.571429\n2 307.142857 11 61.428571\n6 368.571429", "NO", "NO", "NO", "NO", "YES\n4 262.000000 5 393.000000\n8 131.000000 6 524.000000\n10 262.000000 3 393.000000\n7 524.000000 5 131.000000\n3 131.000000 1 524.000000\n2 131.000000 9 524.000000\n10 262.000000 2 393.000000\n8 393.000000 4 262.000000", "NO", "NO", "YES\n5 557.000000\n7 557.000000\n6 557.000000\n4 557.000000\n3 557.000000\n1 557.000000\n10 557.000000\n9 557.000000\n8 557.000000\n12 557.000000\n11 557.000000\n13 557.000000\n2 557.000000", "YES\n6 223.555556 11 503.000000\n5 335.333333 4 391.222222\n2 223.555556 13 503.000000\n9 447.111111 6 279.444444\n12 391.222222 1 335.333333\n4 111.777778 12 111.777778 8 503.000000\n3 503.000000 10 55.888889 1 167.666667\n2 279.444444 10 447.111111\n9 55.888889 7 503.000000 5 167.666667", "YES\n11 255.000000 2 127.500000\n4 127.500000 8 255.000000\n2 127.500000 10 255.000000\n12 255.000000 1 127.500000\n1 127.500000 3 255.000000\n4 127.500000 5 255.000000\n6 255.000000 9 127.500000\n9 127.500000 7 255.000000", "NO", "NO", "NO", "NO", "YES\n26 318.500000 12 637.000000 1 79.625000\n6 238.875000 16 159.250000 19 637.000000\n14 637.000000 24 398.125000\n5 79.625000 26 318.500000 22 637.000000\n4 79.625000 21 637.000000 18 318.500000\n9 637.000000 18 318.500000 20 79.625000\n8 637.000000 3 398.125000\n23 477.750000 20 557.375000\n7 159.250000 17 637.000000 24 238.875000\n2 238.875000 10 637.000000 25 159.250000\n23 159.250000 3 238.875000 11 637.000000\n1 557.375000 25 477.750000\n16 477.750000 5 557.375000\n13 637.000000 2 398.125000\n4 557...", "NO", "NO", "YES\n19 273.043478 16 546.086957\n26 327.652174 28 491.478261\n23 518.782609 11 300.347826\n10 245.739130 25 573.391304\n12 382.260870 6 436.869565\n13 628.000000 2 191.130435\n24 409.565217 17 409.565217\n14 600.695652 24 218.434783\n12 245.739130 7 573.391304\n15 628.000000 29 163.826087 14 27.304348\n23 109.217391 9 81.913043 20 628.000000\n8 628.000000 7 54.608696 3 136.521739\n27 600.695652 17 218.434783\n9 546.086957 18 273.043478\n1 628.000000 28 136.521739 25 54.608696\n22 518.782609 26 300.347826\n...", "NO", "NO", "NO", "YES\n9 182.222222 20 328.000000 23 48.592593\n4 170.074074 17 60.740741 44 328.000000\n25 97.185185 15 133.629630 14 328.000000\n30 170.074074 32 328.000000 37 60.740741\n8 182.222222 35 48.592593 31 328.000000\n28 291.555556 37 267.259259\n21 242.962963 42 315.851852\n9 145.777778 21 85.037037 18 328.000000\n6 315.851852 12 242.962963\n29 303.703704 19 255.111111\n26 328.000000 40 72.888889 4 157.925926\n3 218.666667 6 12.148148 5 328.000000\n45 194.370370 1 328.000000 28 36.444444\n34 218.666667 27 328.0...", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "YES\n5 53.000000 6 265.000000\n34 212.000000 27 106.000000\n26 53.000000 32 265.000000\n4 318.000000\n3 318.000000\n31 318.000000\n18 265.000000 21 53.000000\n30 159.000000 16 159.000000\n33 318.000000\n36 212.000000 11 106.000000\n28 318.000000\n35 318.000000\n8 265.000000 31 53.000000\n24 212.000000 14 106.000000\n5 318.000000\n2 265.000000 13 53.000000\n17 53.000000 11 265.000000\n36 159.000000 15 159.000000\n13 318.000000\n19 106.000000 16 212.000000\n17 318.000000\n18 106.000000 9 212.000000\n25 159.0...", "YES\n7 149.041667 17 340.666667\n16 212.916667 19 276.791667\n3 85.166667 1 404.541667\n21 404.541667 18 85.166667\n2 468.416667 13 21.291667\n22 170.333333 5 319.375000\n22 340.666667 8 149.041667\n4 127.750000 7 361.958333\n12 127.750000 8 361.958333\n23 489.708333\n13 489.708333\n19 234.208333 6 255.500000\n5 191.625000 16 298.083333\n6 255.500000 15 234.208333\n4 383.250000 21 106.458333\n1 106.458333 12 383.250000\n20 42.583333 9 447.125000\n11 191.625000 14 298.083333\n18 425.833333 9 63.875000\n23 2...", "YES\n13 802.560000\n17 535.040000 7 267.520000\n14 468.160000 24 334.400000\n2 769.120000 13 33.440000\n15 434.720000 14 367.840000\n3 702.240000 10 100.320000\n6 434.720000 19 367.840000\n8 234.080000 22 568.480000\n23 769.120000 11 33.440000\n20 735.680000 23 66.880000\n6 401.280000 15 401.280000\n18 668.800000 9 133.760000\n7 568.480000 4 234.080000\n21 200.640000 4 601.920000\n5 535.040000 22 267.520000\n5 300.960000 16 501.600000\n11 802.560000\n20 100.320000 9 702.240000\n10 735.680000 2 66.880000\n1...", "YES\n18 262.068966 9 104.827586\n28 78.620690 26 288.275862\n5 117.931034 16 248.965517\n4 235.862069 21 131.034483\n11 65.517241 23 301.379310\n15 209.655172 6 157.241379\n3 327.586207 8 39.310345\n6 222.758621 19 144.137931\n27 157.241379 17 209.655172\n23 78.620690 20 288.275862\n14 196.551724 15 170.344828\n20 91.724138 9 275.172414\n2 353.793103 13 13.103448\n10 340.689655 2 26.206897\n13 366.896552\n25 327.586207 10 39.310345\n24 183.448276 14 183.448276\n24 196.551724 17 170.344828\n4 144.137931 27 ...", "YES\n13 563.200000\n14 422.400000 15 140.800000\n6 563.200000\n13 140.800000 2 422.400000\n19 422.400000 6 140.800000\n10 422.400000 3 140.800000\n5 140.800000 16 422.400000\n12 281.600000 8 281.600000\n20 281.600000 23 281.600000\n21 281.600000 4 281.600000\n19 281.600000 16 281.600000\n9 140.800000 20 422.400000\n24 281.600000 14 281.600000\n17 140.800000 24 422.400000\n11 563.200000\n9 563.200000\n18 563.200000\n4 422.400000 7 140.800000\n10 281.600000 2 281.600000\n15 563.200000\n17 563.200000\n12 422....", "YES\n7 141.250000 8 282.500000\n11 141.250000 23 282.500000\n14 282.500000 15 141.250000\n18 282.500000 9 141.250000\n27 282.500000 17 141.250000\n13 423.750000\n7 423.750000\n3 423.750000\n17 423.750000\n3 141.250000 8 282.500000\n6 282.500000 12 141.250000\n24 423.750000\n21 423.750000\n29 423.750000\n10 423.750000\n1 282.500000 25 141.250000\n28 141.250000 1 282.500000\n27 282.500000 4 141.250000\n19 282.500000 29 141.250000\n19 282.500000 16 141.250000\n4 423.750000\n20 141.250000 23 282.500000\n5 423....", "YES\n7 632.000000 8 158.000000\n33 474.000000 29 316.000000\n21 632.000000 18 158.000000\n28 790.000000\n3 790.000000\n17 632.000000 11 158.000000\n16 158.000000 30 632.000000\n19 158.000000 29 632.000000\n10 474.000000 25 316.000000\n16 790.000000\n11 790.000000\n18 790.000000\n32 474.000000 26 316.000000\n8 790.000000\n1 790.000000\n15 474.000000 22 316.000000\n9 790.000000\n5 158.000000 6 632.000000\n4 474.000000 27 316.000000\n31 158.000000 35 632.000000\n31 790.000000\n20 632.000000 9 158.000000\n20 3...", "YES\n1 385.333333\n1 192.666667 6 192.666667\n3 385.333333\n5 192.666667 2 192.666667\n4 385.333333\n4 192.666667 3 192.666667\n2 385.333333\n6 385.333333\n5 385.333333", "YES\n13 530.571429\n14 176.857143 24 353.714286\n15 530.571429\n2 442.142857 13 88.428571\n6 530.571429\n3 265.285714 10 265.285714\n16 353.714286 19 176.857143\n8 530.571429\n11 530.571429\n21 88.428571 18 442.142857\n19 442.142857 6 88.428571\n23 442.142857 11 88.428571\n24 265.285714 17 265.285714\n17 353.714286 7 176.857143\n22 442.142857 8 88.428571\n23 176.857143 20 353.714286\n9 265.285714 20 265.285714\n21 530.571429\n10 353.714286 2 176.857143\n14 442.142857 15 88.428571\n4 88.428571 7 442.142857\n...", "YES\n22 493.000000 26 431.375000\n6 862.750000 5 61.625000\n27 862.750000 17 61.625000\n8 308.125000 3 616.250000\n9 616.250000 18 308.125000\n13 924.375000\n29 246.500000 19 677.875000\n7 246.500000 8 677.875000\n18 677.875000 21 246.500000\n16 369.750000 30 554.625000\n5 924.375000\n21 739.500000 4 184.875000\n11 431.375000 23 493.000000\n24 924.375000\n10 184.875000 25 739.500000\n28 616.250000 1 308.125000\n28 369.750000 26 554.625000\n20 554.625000 9 369.750000\n24 61.625000 14 862.750000\n14 123.2500...", "YES\n9 163.285714 18 190.500000\n12 163.285714 26 190.500000\n22 217.714286 5 136.071429\n23 272.142857 11 81.642857\n11 299.357143 3 54.428571\n3 326.571429 8 27.214286\n14 27.214286 24 326.571429\n23 108.857143 20 244.928571\n8 353.785714\n2 326.571429 13 27.214286\n7 108.857143 4 244.928571\n10 299.357143 2 54.428571\n18 190.500000 21 163.285714\n21 217.714286 4 136.071429\n19 81.642857 16 272.142857\n7 272.142857 17 81.642857\n15 353.785714\n22 163.285714 26 190.500000\n14 353.785714\n13 353.785714\n12...", "YES\n13 557.250000\n15 557.250000\n19 371.500000 6 185.750000\n13 185.750000 2 371.500000\n16 185.750000 19 371.500000\n10 557.250000\n5 557.250000\n12 557.250000\n9 557.250000\n7 371.500000 4 185.750000\n16 557.250000\n18 371.500000 9 185.750000\n14 371.500000 15 185.750000\n24 185.750000 14 371.500000\n20 185.750000 23 371.500000\n18 371.500000 21 185.750000\n21 557.250000\n7 371.500000 17 185.750000\n10 185.750000 2 371.500000\n11 185.750000 23 371.500000\n24 557.250000\n11 557.250000\n5 185.750000 22 3...", "YES\n13 408.000000\n17 51.000000 24 357.000000\n15 255.000000 14 153.000000\n2 357.000000 13 51.000000\n15 204.000000 6 204.000000\n10 153.000000 3 255.000000\n16 102.000000 19 306.000000\n8 357.000000 22 51.000000\n9 255.000000 20 153.000000\n18 204.000000 9 204.000000\n19 153.000000 6 255.000000\n11 408.000000\n17 408.000000\n7 408.000000\n22 408.000000\n11 51.000000 23 357.000000\n23 102.000000 20 306.000000\n21 153.000000 18 255.000000\n10 306.000000 2 102.000000\n24 102.000000 14 306.000000\n4 357.000...", "YES\n7 183.807692 17 326.769231\n5 183.807692 16 326.769231\n18 122.538462 21 388.038462\n10 469.730769 2 40.846154\n4 367.615385 21 142.961538\n15 265.500000 14 245.076923\n25 81.692308 1 428.884615\n9 428.884615 20 81.692308\n13 20.423077 2 490.153846\n18 408.461538 9 102.115385\n19 306.346154 16 204.230769\n3 20.423077 11 490.153846\n19 224.653846 6 285.923077\n13 510.576923\n25 449.307692 10 61.269231\n8 388.038462 12 122.538462\n5 347.192308 22 163.384615\n3 510.576923\n23 61.269231 20 449.307692\n12 ...", "YES\n15 555.285714 36 299.000000\n21 811.571429 18 42.714286\n6 512.571429 12 341.714286\n30 512.571429 32 341.714286\n29 384.428571 19 469.857143\n15 341.714286 22 512.571429\n7 598.000000 8 256.285714\n38 128.142857 27 726.142857\n9 854.285714\n13 854.285714\n28 256.285714 37 598.000000\n23 768.857143 20 85.428571\n1 683.428571 25 170.857143\n6 384.428571 5 469.857143\n2 811.571429 13 42.714286\n23 128.142857 35 726.142857\n2 85.428571 10 768.857143\n24 256.285714 39 598.000000\n8 640.714286 31 213.57142...", "YES\n13 342.461538\n24 85.615385 17 256.846154\n14 313.923077 15 28.538462\n13 28.538462 2 313.923077\n15 342.461538\n3 256.846154 10 85.615385\n6 28.538462 19 313.923077\n8 199.769231 22 142.692308\n20 285.384615 23 57.076923\n9 256.846154 20 85.615385\n6 342.461538\n21 199.769231 18 142.692308\n17 114.153846 7 228.307692\n7 142.692308 4 199.769231\n5 114.153846 22 228.307692\n11 342.461538\n11 28.538462 23 313.923077\n18 228.307692 9 114.153846\n10 285.384615 2 57.076923\n24 285.384615 14 57.076923\n21 1...", "YES\n17 118.300000 7 33.800000\n6 50.700000 15 101.400000\n15 67.600000 14 84.500000\n8 50.700000 12 101.400000\n18 135.200000 5 16.900000\n10 50.700000 3 101.400000\n10 118.300000 2 33.800000\n7 135.200000 4 16.900000\n16 16.900000 9 135.200000\n2 135.200000 13 16.900000\n9 33.800000 6 118.300000\n16 152.100000\n4 152.100000\n8 118.300000 18 33.800000\n14 84.500000 11 67.600000\n17 50.700000 11 101.400000\n5 152.100000\n1 84.500000 12 67.600000\n1 84.500000 3 67.600000\n13 152.100000", "YES\n13 253.440000\n17 168.960000 7 84.480000\n14 147.840000 24 105.600000\n2 242.880000 13 10.560000\n15 137.280000 14 116.160000\n3 221.760000 10 31.680000\n6 137.280000 19 116.160000\n8 73.920000 22 179.520000\n23 242.880000 11 10.560000\n20 232.320000 23 21.120000\n6 126.720000 15 126.720000\n18 211.200000 9 42.240000\n7 179.520000 4 73.920000\n21 63.360000 4 190.080000\n5 168.960000 22 84.480000\n5 95.040000 16 158.400000\n11 253.440000\n20 31.680000 9 221.760000\n10 232.320000 2 21.120000\n17 95.0400...", "YES\n6 378.857143 15 473.571429\n13 31.571429 2 820.857143\n18 631.428571 9 221.000000\n26 221.000000 22 631.428571\n13 852.428571\n23 726.142857 11 126.285714\n20 694.571429 23 157.857143\n10 789.285714 2 63.142857\n1 726.142857 25 126.285714\n4 568.285714 21 284.142857\n25 757.714286 10 94.714286\n27 347.285714 17 505.142857\n5 599.857143 22 252.571429\n18 252.571429 21 599.857143\n7 852.428571\n8 63.142857 3 789.285714\n14 442.000000 15 410.428571\n19 536.714286 16 315.714286\n3 94.714286 11 757.714286\n...", "YES\n11 395.142857 17 395.142857\n6 790.285714\n15 790.285714\n12 790.285714\n8 131.714286 18 658.571429\n4 790.285714\n10 526.857143 2 263.428571\n17 526.857143 7 263.428571\n16 526.857143 9 263.428571\n2 658.571429 13 131.714286\n9 658.571429 6 131.714286\n5 395.142857 16 395.142857\n4 131.714286 7 658.571429\n8 790.285714\n15 131.714286 14 658.571429\n14 263.428571 11 526.857143\n18 263.428571 5 526.857143\n12 131.714286 1 658.571429\n3 526.857143 1 263.428571\n13 790.285714\n3 395.142857 10 395.142857\n...", "YES\n16 203.157895 19 548.526316\n35 284.421053 23 467.263158\n27 426.631579 34 325.052632\n11 60.947368 36 690.736842\n28 121.894737 37 629.789474\n5 609.473684 3 142.210526\n26 751.684211\n9 345.368421 18 406.315789\n10 60.947368 25 690.736842\n19 223.473684 29 528.210526\n4 406.315789 27 345.368421\n7 223.473684 8 528.210526\n23 304.736842 20 446.947368\n24 467.263158 14 284.421053\n26 20.315789 17 731.368421\n6 182.842105 12 568.842105\n3 629.789474 22 121.894737\n18 365.684211 21 386.000000\n5 162.526...", "YES\n17 122.000000 24 366.000000\n13 488.000000\n9 122.000000 20 366.000000\n29 488.000000\n30 488.000000\n19 244.000000 16 244.000000\n7 366.000000 12 122.000000\n24 244.000000 14 244.000000\n22 488.000000\n31 488.000000\n6 488.000000\n27 488.000000\n3 244.000000 5 244.000000\n1 488.000000\n7 244.000000 8 244.000000\n9 488.000000\n28 244.000000 26 244.000000\n26 366.000000 32 122.000000\n2 366.000000 13 122.000000\n15 488.000000\n15 122.000000 14 366.000000\n21 366.000000 18 122.000000\n25 122.000000 10 3...", "YES\n13 33.521739 2 703.956522\n7 569.869565 4 167.608696\n14 301.695652 15 435.782609\n6 402.260870 15 335.217391\n8 234.652174 22 502.826087\n5 301.695652 16 435.782609\n6 368.739130 19 368.739130\n9 703.956522 20 33.521739\n17 234.652174 11 502.826087\n11 268.173913 14 469.304348\n3 134.086957 1 603.391304\n4 603.391304 21 134.086957\n13 737.478261\n16 335.217391 19 402.260870\n21 636.913043 18 100.565217\n22 268.173913 5 469.304348\n12 201.130435 8 536.347826\n9 67.043478 18 670.434783\n10 670.434783 2...", "YES\n13 66.000000 2 660.000000\n7 396.000000 17 330.000000\n6 66.000000 15 660.000000\n6 726.000000\n8 462.000000 22 264.000000\n5 594.000000 16 132.000000\n19 726.000000\n9 132.000000 18 594.000000\n14 198.000000 11 528.000000\n14 594.000000 15 132.000000\n1 462.000000 3 264.000000\n7 396.000000 4 330.000000\n13 726.000000\n16 660.000000 19 66.000000\n4 462.000000 21 264.000000\n22 528.000000 5 198.000000\n12 396.000000 8 330.000000\n21 528.000000 18 198.000000\n10 594.000000 2 132.000000\n20 66.000000 9 ...", "YES\n5 16.666667 6 66.666667\n27 66.666667 34 16.666667\n31 83.333333\n14 66.666667 17 16.666667\n16 83.333333\n6 33.333333 12 50.000000\n35 33.333333 23 50.000000\n24 83.333333\n38 50.000000 21 33.333333\n4 50.000000 26 33.333333\n28 83.333333\n18 83.333333\n25 66.666667 1 16.666667\n8 83.333333\n13 16.666667 2 66.666667\n9 83.333333\n10 50.000000 2 33.333333\n33 50.000000 29 33.333333\n23 50.000000 20 33.333333\n27 33.333333 38 50.000000\n11 83.333333\n40 83.333333\n9 16.666667 20 66.666667\n7 33.333333 ...", "YES\n28 375.750000 37 62.625000\n25 250.500000 10 187.875000\n24 438.375000\n34 375.750000 24 62.625000\n26 125.250000 4 313.125000\n16 313.125000 30 125.250000\n19 250.500000 29 187.875000\n37 438.375000\n31 250.500000 8 187.875000\n28 125.250000 1 313.125000\n3 313.125000 5 125.250000\n12 62.625000 7 375.750000\n33 375.750000 41 62.625000\n20 438.375000\n3 187.875000 22 250.500000\n29 313.125000 33 125.250000\n32 438.375000\n15 313.125000 36 125.250000\n17 313.125000 39 125.250000\n1 187.875000 25 250.50...", "YES\n3 53.846154 22 38.461538\n4 53.846154 27 38.461538\n30 30.769231 32 61.538462\n18 38.461538 21 53.846154\n15 69.230769 36 23.076923\n8 15.384615 7 76.923077\n20 23.076923 9 69.230769\n16 76.923077 19 15.384615\n33 7.692308 14 84.615385\n6 61.538462 12 30.769231\n26 46.153846 28 46.153846\n8 84.615385 31 7.692308\n12 69.230769 7 23.076923\n34 69.230769 24 23.076923\n15 30.769231 22 61.538462\n13 7.692308 2 84.615385\n10 76.923077 2 15.384615\n17 92.307692\n13 92.307692\n29 7.692308 19 84.615385\n30 69....", "YES\n28 146.571429\n25 73.285714 10 73.285714\n24 97.714286 41 48.857143\n24 73.285714 34 73.285714\n26 146.571429\n16 73.285714 30 73.285714\n19 122.142857 29 24.428571\n37 146.571429\n31 146.571429\n1 122.142857 28 24.428571\n5 146.571429\n7 97.714286 8 48.857143\n33 146.571429\n20 73.285714 9 73.285714\n3 146.571429\n38 146.571429\n32 122.142857 37 24.428571\n22 48.857143 15 97.714286\n14 73.285714 17 73.285714\n25 97.714286 1 48.857143\n2 48.857143 10 97.714286\n3 24.428571 22 122.142857\n4 122.142857 ...", "YES\n17 30.000000 14 40.000000 11 100.000000\n4 100.000000 8 20.000000 5 50.000000\n17 70.000000 7 100.000000\n9 20.000000 16 100.000000 5 50.000000\n3 40.000000 10 100.000000 2 30.000000\n12 90.000000 8 80.000000\n15 100.000000 6 10.000000 14 60.000000\n3 60.000000 12 10.000000 1 100.000000\n2 70.000000 13 100.000000\n9 80.000000 6 90.000000", "NO"]}
UNKNOWN
PYTHON3
CODEFORCES
5
e01e94d3d663c0ea8272b045a34e994b
Post Lamps
Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has $n$ positions to install lamps, they correspond to the integer numbers from $0$ to $n - 1$ on the OX axis. However, some positions are blocked and no post lamp can be placed there. There are post lamps of different types which differ only by their power. When placed in position $x$, post lamp of power $l$ illuminates the segment $[x; x + l]$. The power of each post lamp is always a positive integer number. The post lamp shop provides an infinite amount of lamps of each type from power $1$ to power $k$. Though each customer is only allowed to order post lamps of exactly one type. Post lamps of power $l$ cost $a_l$ each. What is the minimal total cost of the post lamps of exactly one type Adilbek can buy to illuminate the entire segment $[0; n]$ of the street? If some lamps illuminate any other segment of the street, Adilbek does not care, so, for example, he may place a lamp of power $3$ in position $n - 1$ (even though its illumination zone doesn't completely belong to segment $[0; n]$). The first line contains three integer numbers $n$, $m$ and $k$ ($1 \le k \le n \le 10^6$, $0 \le m \le n$) — the length of the segment of the street Adilbek wants to illuminate, the number of the blocked positions and the maximum power of the post lamp available. The second line contains $m$ integer numbers $s_1, s_2, \dots, s_m$ ($0 \le s_1 &lt; s_2 &lt; \dots s_m &lt; n$) — the blocked positions. The third line contains $k$ integer numbers $a_1, a_2, \dots, a_k$ ($1 \le a_i \le 10^6$) — the costs of the post lamps. Print the minimal total cost of the post lamps of exactly one type Adilbek can buy to illuminate the entire segment $[0; n]$ of the street. If illumintaing the entire segment $[0; n]$ is impossible, print -1. Sample Input 6 2 3 1 3 1 2 3 4 3 4 1 2 3 1 10 100 1000 5 1 5 0 3 3 3 3 3 7 4 3 2 4 5 6 3 14 15 Sample Output 6 1000 -1 -1
[ "n, m, k = map(int, input().split())\r\nfree = [True] * n\r\nfor i in list(map(int, input().split())):\r\n free[i] = False\r\na = list(map(int, input().split()))\r\nlast_lamp = [-1] * n\r\nfor i in range(n):\r\n if free[i]:\r\n last_lamp[i] = i\r\n if i > 0 and not free[i]:\r\n last_lamp[i] = last_lamp[i - 1]\r\nans = int(1E100)\r\nfor i in range(1, k + 1):\r\n last, prev = 0, -1\r\n cur = 0\r\n while last < n:\r\n if last_lamp[last] <= prev:\r\n cur = None\r\n break\r\n prev = last_lamp[last]\r\n last = prev + i\r\n cur += 1\r\n if cur is not None:\r\n ans = min(ans, a[i - 1] * cur)\r\nif ans == int(1E100):\r\n print(-1)\r\nelse:\r\n print(ans)", "import sys\r\nfrom array import array\r\n\r\nn, m, k = map(int, input().split())\r\nblock = list(map(int, input().split()))\r\na = [0] + list(map(int, input().split()))\r\n\r\nif block and block[0] == 0:\r\n print(-1)\r\n exit()\r\n\r\nprev = array('i', list(range(n)))\r\nfor x in block:\r\n prev[x] = -1\r\n\r\nfor i in range(1, n):\r\n if prev[i] == -1:\r\n prev[i] = prev[i-1]\r\n\r\ninf = ans = 10**18\r\n\r\nfor i in range(1, k+1):\r\n s = 0\r\n cost = 0\r\n while True:\r\n cost += a[i]\r\n t = s+i\r\n\r\n if t >= n:\r\n break\r\n if prev[t] == s:\r\n cost = inf\r\n break\r\n s = prev[t]\r\n\r\n ans = min(ans, cost)\r\n\r\nprint(ans if ans < inf else -1)\r\n", "import sys\r\nfrom array import array\r\n\r\ndef input():\r\n return sys.stdin.readline().rstrip()\r\ndef getN():\r\n return int(input())\r\ndef getNM():\r\n return map(int, input().split())\r\ndef getList():\r\n return list(map(int, input().split()))\r\ndef getListGraph():\r\n return list(map(lambda x:int(x) - 1, input().split()))\r\ndef getArray(intn):\r\n return [int(input()) for i in range(intn)]\r\n\r\nmod = 10 ** 9 + 7\r\nMOD = 998244353\r\n# sys.setrecursionlimit(10000000)\r\n# import pypyjit\r\n# pypyjit.set_param('max_unroll_recursion=-1')\r\ninf = float('inf')\r\neps = 10 ** (-12)\r\ndy = [0, 1, 0, -1]\r\ndx = [1, 0, -1, 0]\r\n\r\n#############\r\n# Main Code #\r\n#############\r\n\r\nn, m, k = getNM()\r\nblock = getList()\r\na = [0] + getList()\r\n\r\n# 先頭がブロックならもちろんアウト\r\nif block and block[0] == 0:\r\n print(-1)\r\n exit()\r\n\r\nprev = list(range(n))\r\nfor x in block:\r\n prev[x] = -1\r\n\r\nfor i in range(1, n):\r\n if prev[i] == -1:\r\n prev[i] = prev[i-1]\r\n\r\ninf = ans = 10**18\r\n\r\nfor i in range(1, k+1):\r\n s = 0\r\n cost = 0\r\n while True:\r\n cost += a[i]\r\n t = s+i\r\n\r\n if t >= n:\r\n break\r\n if prev[t] == s:\r\n cost = inf\r\n break\r\n s = prev[t]\r\n\r\n ans = min(ans, cost)\r\n\r\nprint(ans if ans < inf else -1)" ]
{"inputs": ["6 2 3\n1 3\n1 2 3", "4 3 4\n1 2 3\n1 10 100 1000", "5 1 5\n0\n3 3 3 3 3", "7 4 3\n2 4 5 6\n3 14 15", "1 0 1\n\n1000000", "1 1 1\n0\n1000", "3 2 3\n1 2\n1 1 1000000", "3 0 3\n\n333 500 1001", "3 0 3\n\n334 500 1001", "6 2 3\n2 3\n1 1 3", "9 4 3\n3 4 7 8\n1 1 1", "11 4 6\n3 4 5 6\n1000000 1000000 1000000 1000000 1000000 1", "1000000 0 1\n\n999999", "1000000 0 1\n\n1000000", "2 1 2\n1\n1 2", "2 1 1\n1\n1", "4 1 3\n3\n3 2 9", "3 1 2\n1\n8 61", "20 2 10\n9 16\n109 58 165 715 341 620 574 732 653 675", "4 0 4\n\n1 4 4 3", "20 16 16\n1 2 3 4 5 6 8 9 10 11 13 14 15 16 18 19\n2 1 1 1 1 1 3 3 2 2 1 3 3 3 3 2", "10 3 2\n2 3 8\n2 4", "4 1 3\n3\n838 185 210", "3 1 2\n2\n1 1", "3 1 1\n2\n1"], "outputs": ["6", "1000", "-1", "-1", "1000000", "-1", "1000000", "999", "1000", "9", "4", "3", "999999000000", "1000000000000", "2", "-1", "4", "122", "638", "3", "3", "-1", "370", "2", "-1"]}
UNKNOWN
PYTHON3
CODEFORCES
3
e0304ed0a9986c1e8d9720575bb720bb
Alena's Schedule
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying. One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes). The University works in such a way that every day it holds exactly *n* lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks). The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the *n* pairs she knows if there will be a class at that time or not. Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university. Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home. Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair. The first line of the input contains a positive integer *n* (1<=≤<=*n*<=≤<=100) — the number of lessons at the university. The second line contains *n* numbers *a**i* (0<=≤<=*a**i*<=≤<=1). Number *a**i* equals 0, if Alena doesn't have the *i*-th pairs, otherwise it is equal to 1. Numbers *a*1,<=*a*2,<=...,<=*a**n* are separated by spaces. Print a single number — the number of pairs during which Alena stays at the university. Sample Input 5 0 1 0 1 1 7 1 0 1 0 0 1 0 1 0 Sample Output 4 4 0
[ "n = int(input())\r\na = list(map(int,input().split()))\r\nif a.count(0)==len(a):\r\n print(0)\r\n quit()\r\nwhile a[0]==0:\r\n a.pop(0)\r\nwhile a[-1]==0:\r\n a.pop(-1)\r\nx = len(a)\r\nfor i in range(x):\r\n if a[i]==0:\r\n if a[i-1]==1 and a[i+1]==1:\r\n a[i]=1\r\nprint(sum(a))", "n = int(input())\r\na = [int(s) for s in input().split()]\r\n\r\nsum = a[0]\r\nif n > 1:\r\n sum = sum + a[n-1]\r\nfor i in range(1, n - 1):\r\n if a[i] == 1:\r\n sum = sum + 1\r\n elif a[i] == 0 and a[i-1] + a[i+1] == 2:\r\n sum = sum + 1\r\n\r\nprint(sum)\r\n \r\n", "import re\n\nn = int(input())\ns = re.sub('\\s+', '', input())\n\ngroups = re.findall('1(?:1|01)*', s)\nprint(sum(map(len, groups)))\n\n", "from re import sub;input();print(len(sub('[0]{2,}' , '' , \"\".join(input().strip('0').split())).strip('0')))\r\n", "n = int(input())\npairs = [ int(pair) for pair in input().split() ]\n\ni = 0\nwhile i < len(pairs) and pairs[i] == 0:\n i += 1\npairs = pairs[i:]\ni = len(pairs)-1\nif 0 <= i < len(pairs):\n while pairs[i] == 0:\n i -= 1\n pairs = pairs[:i+1]\n\nzero_count = 0\nans = 0\nfor i in range(len(pairs)):\n if pairs[i] == 1:\n ans += 1\n zero_count = 0\n elif pairs[i] == 0:\n zero_count += 1\n if zero_count == 1:\n ans += 1\n if zero_count == 2:\n ans -= 1\n\nprint(ans)", "n = int(input())\nschedule = [int(i) for i in input().split()]\n\npos = 0\ntime = 0\n# Go to the first 1 to start\nwhile pos < len(schedule) and schedule[pos] == 0:\n pos += 1\nif pos == len(schedule): # No 1s in the list at all\n pass\nelse:\n time = 1\n pos += 1 # Starts out after the first one\n while True:\n if pos == len(schedule): # At the end\n break\n elif schedule[pos] == 1: # A one--advance to the next spot\n time += 1\n pos += 1\n elif pos == len(schedule)-1: # A single zero at the end\n break\n elif schedule[pos+1] == 1: # Only one zero--she must stay\n time += 2\n pos += 2\n else: # The double zero case--find the next one\n while pos < len(schedule) and schedule[pos] == 0:\n pos += 1\nprint (time)\n \n \n \n", "n,count=int(input()),0\r\na=[]\r\na=input().split()\r\nfor i in range(0,n):\r\n\ta[i]=int(a[i])\r\nfor i in range(0,n):\r\n\tif(a[i]==1):\r\n\t\tcount+=1\r\n\telif(a[i]==0 and i-1>=0 and a[i-1]==1 and i+1<n and a[i+1]==1):\r\n\t\tcount+=1\r\nprint(count)", "n = int(input())\r\ns = input().split()\r\ns = [int(x) for x in s]\r\ni=0\r\nwhile len(s) and s[-1]==0:\r\n s.pop()\r\nwhile len(s) and s[0]==0:\r\n s.remove(0)\r\nans=len(s)\r\nwhile i<len(s):\r\n counter=0\r\n while s[i]==0 and i<len(s):\r\n counter+=1\r\n i+=1\r\n if counter>=2:\r\n ans-=counter\r\n i+=1\r\nprint(ans)", "__author__ = 'suvasish'\r\n\r\nclasses = int(input())\r\narr = list(map(int, input().split(' ')))\r\npos = []\r\ncount = 0\r\nfor i in range(0, len(arr)):\r\n if arr[i] == 1:\r\n pos.append(i)\r\n\r\n# print(pos)\r\nfor i in range(0, len(pos)):\r\n if i == 0:\r\n count += 1\r\n if i > 0:\r\n diff = pos[i]-pos[i-1]\r\n if diff > 2:\r\n count += 1\r\n else:\r\n count += diff\r\nprint(count)", "a = int(input())\r\ns = list(map(int, input().split()))\r\nc = s.count(1)\r\nv = 0\r\nim = 0\r\nfor i in range(a):\r\n if s[i] == 1:\r\n im = i\r\n break\r\nfor i in range(1, a):\r\n if s[i] == 0:\r\n v += 1\r\n else:\r\n if v == 1 and i > im:\r\n c += 1\r\n v = 0\r\n else:\r\n v = 0\r\nprint(c)", "import sys\r\ninput = sys.stdin.readline\r\n\r\n\r\ninput()\r\ns = input()[:-1].strip(' 0').replace(' ', '')\r\na = s.count('1')\r\nd = [i for i in map(len, s.split('1')) if i < 2]\r\n\r\n\r\n\r\nprint(sum(d)+a)", "#in the name of god\r\n#Mr_Rubik\r\n#''.join(sorted(a)) sort string\r\nn=int(input())\r\narr=list(map(int, input().split()))\r\ncnt=sum(arr)\r\nfor i in range(1,n-1):\r\n if arr[i]==0 and arr[i+1]==arr[i-1]==1:\r\n cnt+=1\r\nprint(cnt)", "import re\r\n_ = input()\r\n\r\nprint(len(\"\".join(re.split('00+', input().replace(' ', '').strip('0')))))", "lessons = int(input())\nschedule = list(map(int, input().split(' ')))\nif 1 not in schedule:\n print(0)\nelse:\n first_lesson = schedule.index(1)\n last_lesson = lessons - schedule[::-1].index(1) - 1\n pairs_at_home = len(schedule[:first_lesson]) + len(schedule[last_lesson + 1:])\n indexes_of_pairs_at_school = []\n for i in range(lessons):\n if schedule[i] == 1:\n indexes_of_pairs_at_school.append(i)\n\n j = 0\n while j < len(indexes_of_pairs_at_school) - 1:\n if indexes_of_pairs_at_school[j + 1] - indexes_of_pairs_at_school[j] > 2:\n pairs_at_home += (indexes_of_pairs_at_school[j + 1] - indexes_of_pairs_at_school[j] - 1)\n j += 1\n\n print(lessons - pairs_at_home)", "n = int(input())\nschedule = list(map(int, input().split()))\nh = 0\nfor i in range(len(schedule)):\n if schedule[i] == 1:\n h += 1\n continue\n if (\n i != 0\n and i != len(schedule) - 1\n and schedule[i - 1] == 1\n and schedule[i + 1] == 1\n ):\n h += 1\nprint(h)\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nx,y=0,0\r\nz=0\r\nfor i in range(n):\r\n if a[i]==1 :\r\n z=i\r\n break\r\na=a[i:]\r\nfor i in range(len(a)) :\r\n if a[i]==1 :\r\n if x==1 :\r\n y+=2\r\n else :\r\n y+=1\r\n x=0\r\n else :\r\n x+=1\r\nprint(y)", "n = int(input())\r\ns = input().split()\r\n\r\n\r\nfirst=-1\r\nlast=-1\r\nfor i in range(len(s)):\r\n if s[i]=='1':\r\n last=i\r\n if first==-1:\r\n first=i\r\ns=s[first:last+1]\r\n\r\n# print(s)\r\nc=0\r\nprop=False\r\nfor i in range(0, len(s)-1):\r\n if s[i]!='0':\r\n prop=False\r\n elif prop:\r\n c+=1\r\n elif s[i+1]=='0':\r\n c+=1\r\n prop=True\r\nprint(len(s)-c)", "input()\r\nA = input().replace(' ', '').strip('0')\r\n\r\nwhile '000' in A:\r\n A = A.replace('000', '00')\r\n\r\nprint(len(A.replace('00', '')))", "#!/usr/bin/env python3\n\nfrom itertools import dropwhile\nfrom operator import not_\n\nn = int(input())\na = list(map(int, input().split()))\n\nresult = 0\nprev1 = prev2 = -1\nfor x in dropwhile(not_, a):\n if x:\n result += 1\n if ~prev2 and not prev1 and prev2:\n result += 1\n prev1, prev2 = x, prev1\nprint(result)\n", "def func(s):\r\n if len(s)<3:\r\n return sum(s)\r\n k=0\r\n for i in range(1,len(s)-1):\r\n if s[i]==0:\r\n if s[i-1]==s[i+1]==1:\r\n k+=1\r\n return sum(s)+k\r\n \r\n\r\nn=int(input())\r\ns=list(map(int,input().split()))\r\nprint(func(s))\r\n\r\n \r\n \r\n \r\n \r\n", "from sys import stdin\r\ninput = stdin.readline\r\n\r\n\r\nlength = int(input())\r\narr = [int(x) for x in input().split()]\r\n\r\nans = 0\r\ni = 0 \r\nwhile i < length and arr[i] == 0:\r\n i+=1\r\n\r\nrun = 0 \r\nfor j in range(i, length):\r\n if arr[j]:\r\n if run == 1:\r\n ans +=1 \r\n run = 0 \r\n ans +=1\r\n else:\r\n run +=1 \r\n\r\nprint(ans)\r\n ", "n = int(input())\r\ns = [int(x) for x in input().split(' ')]\r\nfor i in range(1, n - 1):\r\n if s[i - 1:i + 2] == [1, 0, 1]:\r\n s[i] = 1\r\nprint(sum(s))", "#!/usr/bin/python3.5\r\n\r\nn=int(input())\r\ns=[int(x) for x in input().split()]\r\np,o,=0,0\r\nfor i in range(n):\r\n if s[i]:\r\n p+=1\r\n o=1\r\n elif not(o):\r\n continue\r\n elif i<n-1:\r\n if s[i+1] and s[i-1]:\r\n p+=1\r\nprint(p)\r\n", "n=int(input())\r\nm=list(map(int,input().split()))\r\nN=-1\r\nK=-1\r\ni=0\r\nk=0\r\no=0\r\nI=0\r\nwhile N==-1 and i<n:\r\n if m[i]==1:\r\n N=i\r\n i+=1\r\ni=n-1\r\nwhile K==-1 and i>-1:\r\n if m[i]==1:\r\n K=i\r\n i-=1\r\ni=0\r\nk=K-N+1\r\nfor i in range(N,K-1):\r\n if m[i]==0 and m[i+1]==0:\r\n if i!=N and m[i-1]==1:\r\n o+=1\r\n o+=1\r\nif N==-1:\r\n k=0\r\nelif o>1:\r\n k=k-o\r\nprint(k)", "n = int(input().strip())\narr = list(input().strip().split())\narr = list(''.join(arr).strip('0'))\nfor i in range(len(arr)):\n\tif arr[i] == '0' and arr[i-1] == '1' and arr[i+1] == '1':\n\t\tarr[i] = '1'\nprint(arr.count('1'))", "n = int(input())\r\nl = list(map(int,input().split()))\r\nl += [0,0,0,0]\r\n\r\nstart = 0\r\nend = n\r\nwhile start <n and l[start] == 0 :\r\n start += 1\r\nwhile end >= 0 and l[end] == 0 :\r\n end -= 1\r\np = 0\r\n\r\ni = start\r\nwhile i <= end :\r\n #print(i,'}')\r\n if l[i] == 1 :\r\n p += 1\r\n else:\r\n if l[i+1] == 0 :\r\n while l[i+1] == 0 :\r\n i += 1\r\n else:\r\n p += 1\r\n i += 1\r\n\r\nprint(p)\r\n\r\n", "R = lambda:map(int,input().split())\r\n\r\nn, = R()\r\ns = ''.join(input().split())\r\n\r\nwhile '101' in s:\r\n s = s.replace('101', '111')\r\n \r\n\r\nprint(sum(map(int , s )))\r\n", "n = int(input())\na = list(map(int, input().split()))\n\nans = 0\nfor i, e in enumerate(a):\n if e == 1:\n ans += 1\n else:\n if i < len(a) - 1 and i > 0 and\\\n a[i + 1] == 1 and a[i - 1] == 1:\n ans += 1\n\nprint(ans)\n", "n = int(input())\r\na = [int(i) for i in input().split()]\r\nfor i in range(1, n - 1):\r\n if a[i] == 0 and a[i - 1] == 1 and a[i + 1] == 1:\r\n a[i] = 1\r\nprint(sum(a))\r\n", "n = int(input())\r\n\r\ndaf = list(map(int, input().split()))\r\n\r\nif sum(daf) == 0:\r\n print(0)\r\nelse:\r\n first_1 = daf.index(1)\r\n daf_rev = daf[::-1]\r\n last_1 = daf_rev.index(1)\r\n daf = daf[first_1:(n - last_1)]\r\n count = 0\r\n i = 0\r\n while i < len(daf):\r\n if daf[i] == 0:\r\n daf2 = daf[i:]\r\n ind = daf2.index(1)\r\n if ind >= 2:\r\n i += ind-1\r\n else:\r\n count += 1\r\n else:\r\n count += 1\r\n i += 1\r\n print(count)\r\n", "n = int(input())\r\nlesson = list(map(int, input().split()))\r\nk = sum(lesson)\r\n\r\nwhile lesson[0] == 0 and sum(lesson) != 0:\r\n lesson.pop(0)\r\nwhile lesson[-1] == 0 and sum(lesson) != 0:\r\n lesson.pop(-1)\r\n\r\nlesson = str(lesson).split('1')\r\nprint(k + lesson.count(', 0, '))\r\n", "n = int(input())\r\narray = list(map(int, input().split()))\r\ncount = sum(array)\r\nfor i in range(1, n - 1):\r\n #if (array[i - 1] == array[i]) and array[i] == 0:\r\n # print(i, 'TUTA')\r\n # count += 1\r\n if array[i] == 0 and array[i - 1] == 1 and array[i + 1] == 1:\r\n count += 1\r\nprint(count)\r\n", "from sys import stdin\r\nn=int(stdin.readline().strip())\r\ns=list(map(int,stdin.readline().strip().split()))\r\ns1=[]\r\nans=0\r\nfor i in range(n):\r\n if(s[i]==1):\r\n s1.append(i)\r\nans=0\r\nif len(s1)>=1:\r\n ans+=1\r\nfor i in range(1,len(s1)):\r\n if s1[i]-s1[i-1]>=3:\r\n ans+=1\r\n else:\r\n ans+=s1[i]-s1[i-1]\r\nprint(ans)\r\n", "input()\r\nPairs = input().replace(\" \", \"\").strip(\"0\")\r\ni, Count = 0, 0\r\nwhile i < len(Pairs):\r\n if Pairs[i] == Pairs[i - 1] == \"0\":\r\n while Pairs[i - 1] == \"0\":\r\n Count += 1\r\n i += 1\r\n else:\r\n i += 1\r\nprint(len(Pairs) - Count)\r\n\r\n# UB_CodeForces\r\n# Advice: “Whenever you find yourself on the side of the majority, it is time to pause and reflect.”\r\n# Location: Behind my desk\r\n# Caption: On the right way\r\n# CodeNumber: 550\r\n", "input()\r\nx = list(map(int, input().split()))\r\nfor i in range(200):\r\n for j in range(1, len(x)-1):\r\n if x[j-1] == x[j+1] == 1:\r\n x[j] = 1\r\nprint(sum(x))", "n = int(input())\r\na = [int(v) for v in input().split()]\r\n\r\nfor i in range(1, len(a) - 1):\r\n\tif a[i - 1] == 1 and a[i + 1] == 1:\r\n\t\ta[i] = 1\r\n\r\nprint(sum(a))", "input()\nl = list(map(int, input().split()))\nwhile l and l[0] == 0:\n\tl = l[1:]\nwhile l and l[-1] == 0:\n\tl = l[:-1]\nfor i in range(1, len(l) - 1):\n\tif l[i-1] == 1 and l[i] == 0 and l[i+1] == 1:\n\t\tl[i] = 1\nprint(l.count(1))\n\t\t\n", "a = 0\r\nx = int(input())\r\nlista=input()\r\nl=lista.split()\r\ny=[]\r\nfor r in l:\r\n y.append(int(r))\r\nc = 0\r\nif y[c] == 1:\r\n a = a+1\r\n c = c+1\r\nelse:\r\n c = c+1\r\nfor i in range(1, x):\r\n if y[c] == 1:\r\n a = a+1\r\n c = c+1\r\n elif c == (x-1) and y[c] == 0:\r\n a = a+0\r\n elif y[c] == 0 and y[(c+1)] == 0 or y[c] == 0 and y[(c-1)] == 0:\r\n c = c+1\r\n else:\r\n a = a+1\r\n c = c+1\r\nprint(a)", "import sys\nn = int(input())\na = list(map(int, sys.stdin.readline().split()))\nans = 0\nfor i in range(1,n-1):\n if a[i] == 0:\n if a[i-1] == 1 and a[i+1] == 1:\n a[i] = 1\nprint(sum(a))\n", "n = int(input())\r\na = [int(x) for x in input().split()]\r\nk = 0\r\nwhile k < n and a[k] != 1:\r\n k += 1\r\nm = n - 1\r\nwhile m >= 0 and a[m] != 1:\r\n m -= 1\r\nans = m - k + 1\r\nfor i in range(k + 1, m):\r\n if a[i] == 0 and (a[i - 1] == 0 or a[i + 1] == 0):\r\n ans -= 1\r\nprint(max(0, ans))", "n = int(input())\r\ncnt = list(map(int, input().split()))\r\nans = 0\r\nif cnt.count(1) != 0:\r\n sost = 1\r\n for i in range(cnt.index(1), n):\r\n if cnt[i] and sost == 2:\r\n sost = 1\r\n ans += 2\r\n elif cnt[i]:\r\n ans += 1\r\n sost = 1\r\n elif not cnt[i] and sost == 1:\r\n sost = 2\r\n elif not cnt[i] and sost == 2:\r\n sost = 0\r\n if (i != n - 1) and not cnt[i + 1:].count(1):\r\n break\r\nprint(ans)", "n=int(input())\r\nlista=list(map(int,input().split()))\r\nif len(lista)>=2:\r\n ile_godzin=0+lista[0]+lista[-1]\r\nelif len(lista)==1:\r\n ile_godzin=0+lista[0]\r\nfor i in range(1,len(lista)-1):\r\n if lista[i]==1:\r\n ile_godzin+=1\r\n elif lista[i-1] and lista[i+1]:\r\n ile_godzin += 1\r\nprint(ile_godzin)", "__author__ = 'pxy'\nn=int(input())\ng=[int(j) for j in input().split()]\nb=0\nt=0\nfor z in g:\n if z==1:\n if b>=2 and t>0:\n t+=1-b\n else:\n t+=1\n b=0\n else:\n b+=1\n if t>0:\n t+=1\n\nif t==0:\n print(0)\nelse:\n print(t-b)\n", "# Description of the problem can be found at http://codeforces.com/problemset/problem/586/A\r\n\r\nn = int(input())\r\nl_p = list(map(int, input().split()))\r\n\r\nt = 0\r\nc_s = 2\r\nfor p in l_p:\r\n if p == 0:\r\n c_s += 1\r\n if p == 1:\r\n if c_s < 2:\r\n t += c_s\r\n c_s = 0\r\n t += 1\r\n\r\nprint(t)", "n = int(input(''))\r\nclasses = input('').split(' ')\r\n\r\nstay = ['1', '0', '1']\r\n\r\ncount = 0\r\nfor j in range(n-2):\r\n if(classes[j: j+3] == stay):\r\n count = count + 1\r\n\r\nprint (count + classes.count('1'))\r\n", "def days(schedule):\r\n #7print(schedule)\r\n if len(schedule)==0:\r\n return 0\r\n if len(schedule)==1:\r\n if schedule[0]==0:\r\n return 0\r\n else:\r\n return 1\r\n else:\r\n if schedule[0]==0:\r\n if schedule[1]==1:\r\n return 1+days(schedule[1:])\r\n else:\r\n if 1 in schedule:\r\n return days(schedule[schedule.index(1):])\r\n else:\r\n return days([])\r\n else:\r\n return 1+days(schedule[1:])\r\nn=int(input())\r\nschedule=[int(i) for i in input().split()]\r\nif 1 in schedule:\r\n print(days(schedule[schedule.index(1):]))\r\nelse:\r\n print(0)\r\n", "import sys, io, os\r\nimport math\r\nimport bisect\r\nimport heapq\r\nimport string\r\nfrom collections import defaultdict,Counter,deque\r\ninput = sys.stdin.readline\r\n \r\ndef I():\r\n return input()\r\n \r\ndef II():\r\n return int(input())\r\n \r\ndef MII():\r\n return map(int, input().split())\r\n \r\ndef LI():\r\n return list(input().split())\r\n \r\ndef LII():\r\n return list(map(int, input().split()))\r\n \r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n \r\ndef LGMI():\r\n return list(map(lambda x: int(x) - 1, input().split()))\r\n \r\ndef WRITE(out):\r\n return print('\\n'.join(map(str, out)))\r\n \r\ndef WS(out):\r\n return print(' '.join(map(str, out)))\r\n \r\ndef WNS(out):\r\n return print(''.join(map(str, out)))\r\n\r\n'''\r\nconsecutive groups of 0's => go home\r\n\r\n0 1 0 1 1\r\n\r\n-remove all leading and trailing zeros\r\n-ignore all groups of 0's \r\n\r\n'''\r\n\r\ndef solve():\r\n n = II()\r\n a = LII()\r\n\r\n s = 0\r\n while s < n and a[s] == 0:\r\n s += 1\r\n \r\n e = n-1\r\n while e >= 0 and a[e] == 0:\r\n e -= 1\r\n \r\n if s > e:\r\n print(0)\r\n return\r\n \r\n a = a[s:e+1]\r\n ans = []\r\n i = 0\r\n while i < len(a):\r\n group = False\r\n while i < len(a)-1 and a[i] == 0 and a[i+1] == 0:\r\n group = True\r\n i += 1\r\n \r\n if group:\r\n i += 1\r\n\r\n if i < len(a):\r\n ans.append(a[i])\r\n i += 1\r\n\r\n print(len(ans))\r\n\r\nsolve()", "n=int(input())\r\na=list(map(int,input().split()))\r\nif 1 in a:\r\n x=a.index(1)\r\n a=a[::-1]\r\n y=a.index(1)\r\n a=a[::-1]\r\n a=a[x:n-y]\r\n n=len(a)\r\nelse:\r\n n=0\r\n a=[]\r\nb=0\r\nfor i in range(n):\r\n if((a[i]==0)and(a[i+1]==0))or((a[i]==0)and(a[i-1]==0)):\r\n b=b+1\r\nif(b>0): \r\n print(len(a)-b)\r\nelif(len(a)==0):\r\n print(0)\r\nelse:\r\n print(len(a))\r\n \r\n", "\"\"\"\nCodeforces Round #325 (Div. 2)\n\nProblem 586 A\n\n@author yamaton\n@date 2015-11-09\n\"\"\"\n\nimport itertools as it\nimport functools\nimport operator\nimport collections\nimport math\nimport sys\n\n\ndef solve(xs):\n ys = it.dropwhile(lambda x: x == 0, (reversed(list(it.dropwhile(lambda x: x == 0, reversed(xs))))))\n zs = [(x, sum(1 for _ in iterable)) for x, iterable in it.groupby(ys)]\n print('zs =', zs, file=sys.stderr)\n return sum(cnt for (x, cnt) in zs if not (x == 0 and cnt > 1))\n\n\ndef main():\n n = int(input())\n xs = [int(i) for i in input().strip().split()]\n assert len(xs) == n\n\n result = solve(xs)\n print(result)\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n n = int(input())\n a = list(map(int, input().split()))\n cnt = 0\n ans = 0\n i = 0\n while i < n:\n if a[i] == 1:\n break\n i += 1\n while i < n:\n cnt = 0\n if a[i] == 0:\n while i < n and a[i] == 0:\n cnt += 1\n i += 1\n i -= 1\n else:\n ans += 1\n if cnt < 2 and i != n - 1:\n ans += cnt\n i += 1\n\n print(ans)\n\n\n\n\n\nmain()", "lessons = int(input())\nschedule = list(map(int, input().split(' ')))\nif 1 not in schedule:\n print(0)\nelse:\n first_lesson = schedule.index(1)\n last_lesson = lessons - schedule[::-1].index(1) - 1\n pairs_at_home = len(schedule[:first_lesson]) + len(schedule[last_lesson + 1:])\n indexes_of_pairs_at_school = []\n for i in range(lessons):\n if schedule[i] == 1:\n indexes_of_pairs_at_school.append(i)\n\n lst = []\n\n for j in range(len(indexes_of_pairs_at_school) - 1):\n lst.append(indexes_of_pairs_at_school[j + 1] - indexes_of_pairs_at_school[j] - 1)\n\n for a in lst:\n if a > 1:\n pairs_at_home += a\n\n print(lessons - pairs_at_home)", "n = int(input(''))\r\nclasses = input('').split(' ')\r\n\r\n#stay = '1 0 1'\r\n\r\ncount = 0\r\nfor j in range(n-2):\r\n if((classes[j] == '1') and (classes[j+1] == '0') and (classes[j+2] == '1')):\r\n count = count + 1\r\n\r\nprint (count + classes.count('1'))\r\n", "n = int(input())\r\na = input()\r\na = a.split()\r\na = [int(x) for x in a]\r\n\r\nfor i in range(1, n-1):\r\n if a[i] == 0 and a[i+1] == 1:\r\n a[i] = a[i-1]\r\n\r\n\r\n\r\n\r\nprint(a.count(1))", "n = int(input())\r\narr = list(map(int, input().split()))\r\nfor i in range(200):\r\n for j in range(1, len(arr)-1):\r\n if arr[j-1] == arr[j+1] == 1:\r\n arr[j] = 1\r\nprint(sum(arr))\r\n", "n = int(input())\na = list(map(int, input().split()))\na = a + [0]\nans = 0\nf = 0\nfor i in range(n):\n\tif(a[i] == a[i+1] and a[i] == 0):\n\t\tf = 0\n\tif(a[i] == 1):\n\t\tf = 1\n\tans += f\nprint(ans)\n", "n=int(input())\r\na='0'+''.join(input().split())+'0'\r\ns=''\r\ni=1\r\nwhile i<=n:\r\n if a[i]=='1':\r\n s+=a[i]\r\n else:\r\n if a[i+1]=='0':\r\n pass\r\n else:\r\n if a[i-1]=='0':\r\n s+=a[i+1]\r\n elif a[i-1]=='1':\r\n s+=a[i]+a[i+1]\r\n i+=1\r\n i+=1\r\n\r\nprint(len(s))", "n=int(input())\r\narr=[int(x) for x in input().split()]\r\ndef calc():\r\n count=0\r\n first,last=[-1,-1]\r\n for j in range(n):\r\n if arr[j]==1:\r\n first=j\r\n break\r\n for j in range(n-1,-1,-1):\r\n if arr[j]==1:\r\n last=j\r\n break\r\n if first==-1:\r\n print(0)\r\n return\r\n if last==-1:\r\n print(0)\r\n return\r\n i=first\r\n while(i<=last):\r\n if arr[i]==1:\r\n count+=1\r\n if arr[i]==0:\r\n j=i\r\n count2=0\r\n while(arr[j]==0):\r\n count2+=1\r\n j+=1\r\n if count2==1:\r\n count+=1\r\n else:\r\n i+=(count2-1)\r\n i+=1\r\n print(count)\r\ncalc()\r\n", "import re\r\nn = int(input())\r\nl = input().replace(' ','').strip('0')\r\nl = re.sub(r\"0{2,}\", '', l)\r\nprint(len(l))", "n=int(input())\r\nl=list(map(int,input().split()))\r\nfor i in range(2,n):\r\n if l[i]==1 and l[i-1]==0 and l[i-2]==1: l[i-1]=1\r\nprint(l.count(1))", "def dvoiki(a, b):\r\n global d\r\n d=[1]+d+[1]\r\n f=0\r\n i=a+1\r\n while i < b+1:\r\n if d[i]==0 and d[i+1]==d[i-1]==1:\r\n f+=1\r\n i+=1\r\n return f\r\nn=int(input())\r\nd=list(map(int, input().split()))\r\nif set(d)=={0}:\r\n print(0)\r\n exit()\r\na=d.index(1)\r\nd=d[::-1]\r\nb=n-1-d.index(1)\r\nd=d[::-1]\r\nprint(b-a+1+dvoiki(a, b)-d[a+1:b+2].count(0))", "n = int(input())\r\nb = input().split()\r\ni = 0\r\na = list(str(int(''.join(b))))\r\nwhile i < len(a):\r\n if a[-1] == '0':\r\n del a[-1]\r\n else:\r\n i = i+1\r\ncount = 0\r\nfor i in range(1,len(a)-1):\r\n if a[i] == '0':\r\n if a[i-1] == '0' or a[i+1] == '0':\r\n count = count +1\r\nprint (len(a) - count)\r\n\r\n", "n, a = int(input()), input().replace(\" \", \"\").strip(\"0\")\nres = a.count(\"1\") + sum(len(x) == 1 for x in a.split(\"1\"))\nprint(res)\n", "n=int(input().strip())\r\nx=input().strip().split()\r\nx=[int(y) for y in x]\r\n#print(x)\r\n\r\ncount=0\r\ni,itmp=0,0\r\nc0=0\r\nwhile( (i<n) and (x[i]==0) ):\r\n i=i+1\r\n#print(\"istart\",i)\r\nwhile(i<n):\r\n #print(i,end=\",\")\r\n while( (i<n) and (x[i]==1)):\r\n count = count+1\r\n i=i+1\r\n c0=0\r\n while( (i<n) and (x[i]==0)):\r\n c0 = c0+1\r\n i=i+1\r\n if( (c0==1) and (i !=n) ): #skip last single 0\r\n count=count+1\r\n \r\n#print()\r\nprint(count)\r\n", "n = int(input())\r\nastring = input().replace(\" \", \"\")\r\n\r\ncount = 0\r\nfor i in range(n):\r\n \r\n if astring[i] == \"1\":\r\n count += 1\r\n \r\n if i not in [0, n-1] and astring[i-1:i+2] == \"101\":\r\n count += 1\r\n \r\nprint(count)\r\n ", "n = int(input())\r\narr = list(map(int, input().split()))\r\ncnt = sum(arr)\r\nfor i in range(1, n - 1):\r\n if arr[i] == 0 and arr[i + 1] == arr[i - 1] == 1:\r\n cnt += 1\r\nprint(cnt)\r\n", "n=int(input())\r\nx=[int(q) for q in input().split()]\r\nfor i in range(2,n):\r\n if x[i]==1 and x[i-1]==0 and x[i-2]==1:\r\n x[i-1]=1\r\nprint(x.count(1))", "n = int(input())\r\ns = str(input())\r\ns = s.replace(\" \",\"\")\r\ns= s.strip(\"0\")\r\ntemp = ''\r\ni=0\r\nwhile i<len(s)-1:\r\n if s[i]==s[i+1] and s[i]==\"0\":\r\n temp = s[i:]\r\n temp= temp.lstrip(\"0\")\r\n s= s[:i] +temp\r\n i = i+1\r\nprint(len(s))", "# ---rgkbitw---\r\n# 7.10.2017\r\nn=input()\r\ns=input()\r\nans=s.count('1')+sum( s[i:i+5]=='1 0 1' for i in range(len(s)) )\r\nprint(ans)\r\n", "n = int(input())\r\nl = input().replace('1 0','1 x').replace('x 1', '1 1')\r\nprint (l.count('1'))", "n=int(input())\r\nl=list(map(int,input().split()))\r\ntot=l.count(1)\r\nfor i in range(1,n):\r\n if i==n-1:\r\n break\r\n if l[i]==0 and l[i+1]==1 and l[i-1]==1:\r\n tot+=1\r\nprint(tot)\r\n", "def solve(lst):\r\n ans=0\r\n ln=len(lst)\r\n for i in range(ln):\r\n if lst[i]==1:\r\n ans+=1\r\n if i>0 and i<ln-1 and lst[i]==0 and lst[i-1]==1 and lst[i+1]==1:\r\n ans+=1\r\n return ans\r\n\r\nn=int(input())\r\nlst=list(map(int,input().split()))\r\nprint(solve(lst))\r\n", "\n\n\nn = int(input())\ntmp = input().split()\nlessons = list()\nfor i in tmp :\n\tlessons.append(bool(int(i)))\ncounter = 0\n\nwhile lessons[0] == False and len(lessons) > 1 :\n\tlessons.remove(False)\n\nif len(lessons) > 0 :\n\tlessons.append(False)\n\tlessons.append(False)\nelse :\n\tprint(0)\n\tquit()\n\ninUniv = True\n\nsize = len(lessons) - 2\ni = 0\nwhile i < size :\n\tif lessons[i] == True :\n\t\tcounter += 1\n\telif lessons[i+1] == False :\n\t\twhile lessons[i + 1] == False and i < size :\n\t\t\ti += 1\n\telse :\n\t\tcounter += 1\n\ti += 1\n\nprint(counter)\n\n\n\n\n\n\n\n\n\n\n\n", "n = int(input())\r\nv = [int(e) for e in input().split()]\r\n\r\nfirst = last = -1\r\n\r\nfor i in range(n):\r\n if v[i] == 1:\r\n last = i + 1\r\n if first == -1:\r\n first = i\r\n\r\nans = last - first\r\ncnt = 0\r\n\r\nfor i in range(first, last):\r\n if v[i] == 1:\r\n if cnt >= 2:\r\n ans -= cnt\r\n cnt = 0\r\n else:\r\n cnt += 1\r\n\r\nprint(ans)\r\n", "n = int(input())\r\nk = 0\r\nf = 0\r\ncurr = 0\r\nnumero = input().split()\r\nfor i in numero:\r\n if int(i) == 1 :\r\n k += 1\r\n f = 1\r\n if curr < 2 :\r\n k += curr\r\n curr = 0\r\n elif int(i) == 0 :\r\n if f == 1 :\r\n curr += 1\r\nprint(k)\r\n \r\n", "days = int(input()) \r\nschedule = [0] + list(map(int , input().split())) + [0] \r\ncounter = 0 \r\nfor i in range(1 , days+1):\r\n if schedule[i] == 1 : \r\n counter += 1 \r\n else : \r\n if schedule[i-1] ==1 and schedule[i +1 ] == 1 : \r\n counter += 1 \r\nprint(counter) \r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nif 1 in l:\r\n\tx=l.index(1)\r\nelse:\r\n\tx=n\r\nc=0\r\nfor i in range(x,n-1):\r\n\tif (l[i]==l[i+1]==0 or l[i]==l[i-1]==0) and i!=0:\r\n\t\tpass\r\n\telse:\r\n\t\tc+=1\r\nif l[-1]==1:\r\n\tc+=1\r\nprint(c)", "input()\r\na=''.join(input().split())\r\nwhile '101'in a:a=a.replace('101','111')\r\nprint(sum(map(int,a)))\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\nstring = ''\r\nfor i in a:\r\n string += str(i)\r\nstring = string.strip('0')\r\ncount = 0\r\nstring = '00' + string + '00'\r\nfor i in range(len(string)):\r\n if string[i] == '1':\r\n count += 1\r\n if string[i] == '0' and (string[i-1] != '0' and string[i+1] != '0'):\r\n count += 1\r\nprint(count)", "n = int(input())\r\nlist = [int(i) for i in input().split()]\r\nlist.insert(0,0)\r\nlist.append(0)\r\ndem = 0\r\nfor i in range(0,n+1):\r\n # print(list[i], end=' ')\r\n if list[i] == 1:\r\n dem += 1\r\n elif list[i-1]==1 and list[i+1]==1:\r\n dem += 1\r\n\r\nprint (dem)", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nn = int(input())\r\na = [0] + list(map(int, input().split())) + [0]\r\nans = sum(a)\r\nfor i in range(1, n + 1):\r\n if a[i - 1] > a[i] < a[i + 1]:\r\n ans += 1\r\nprint(ans)", "import re\r\ninput()\r\nprint(len(\"\".join(re.split('00+', input().replace(' ', '').strip('0')))))", "\nn = int(input())\na = [int(x) for x in input().split()]\nans = 0\nif a:\n while a[-1] == 0 and a:\n a.pop(-1)\n if not(a):break\nif a:\n while a[0] == 0:\n a.pop(0)\n if not(a):break\nskip = 0\nfor i in range(len(a) ):\n if a[i] == 1:\n ans += 1\n if skip == 1:ans += 1 \n skip = 0\n else:\n skip += 1\nprint(ans)\n\n\n", "n = int(input())\na = list(map(int, input().split()))\nwhile len(a) > 0 and a[0] == 0:\n a.pop(0)\nwhile len(a) > 0 and a[-1] == 0:\n a.pop(-1)\n\nl = 0\nr = 0\n\nbreaktime = 0\nfor i in range(1, len(a)):\n if a[i-1] == 1 and a[i] == 0:\n l = i\n if a[i-1] == 0 and a[i] == 1:\n if i - l > 1:\n breaktime += i - l\n\nprint(len(a) - breaktime)\n \n", "import sys\r\ninput = sys.stdin.readline\r\nn = input()\r\na = [x for x in input().split()]\r\nans = 0\r\nif a:\r\n while a[-1] == '0' and a:\r\n a.pop(-1)\r\n if not(a):break\r\nif a:\r\n while a[0] == '0':\r\n a.pop(0)\r\n if not(a):break\r\nskip = 0\r\nfor i in range(len(a) ):\r\n if a[i] == '1':\r\n ans += 1\r\n if skip == 1:ans += 1 \r\n skip = 0\r\n else:\r\n skip += 1\r\nprint(ans)\r\n\r\n\r\n", "def input_ints():\r\n return list(map(int, input().split()))\r\n\r\ndef solve():\r\n n = int(input())\r\n a = input_ints()\r\n for i in range(1, n-1):\r\n if a[i-1] and a[i+1]:\r\n a[i] = 1\r\n print(a.count(1))\r\n\r\nif __name__ == '__main__':\r\n solve()\r\n", "n = int(input())\r\na = list(input().split(' '))\r\na = list(int(x) for x in a)\r\nres = 0\r\nbegin = 0\r\nwhile a[begin] == 0:\r\n begin += 1\r\n if begin == n:\r\n break\r\nfor i in range(begin, n):\r\n if a[i] == 1:\r\n res += 1\r\n elif i < n-1 and i > 0 :\r\n if a[i] == 0 and a[i+1] == 1 and a[i-1] == 1:\r\n res += 1\r\nprint(res)\r\n", "n = input()\r\ns = input().replace(' ', '')\r\nwhile s.find('101') != -1:\r\n s = s.replace('101', '111')\r\ns = s.replace('0', '')\r\nprint(len(s))\r\n", "n = int(input())\r\na = list(map(int, input().split(' ')[:n]))\r\nres = 0\r\nstate = 0\r\nfor x in a:\r\n if state == 0:\r\n if x == 0:\r\n pass\r\n else:\r\n state = 1\r\n res += 1\r\n elif state == 1:\r\n if x == 0:\r\n state = 2\r\n else:\r\n res += 1\r\n elif state == 2:\r\n if x == 0:\r\n state = 0\r\n else:\r\n state = 1\r\n res += 2\r\n\r\nprint(res)", "n=int(input())\r\nl=list(map(str,input().split()))\r\nk=\"\".join(l)\r\nk=k.lstrip(\"0\")\r\nk=k.rstrip(\"0\")\r\nfor i in range(n,1,-1):\r\n k=k.replace(\"0\"*i,\"\")\r\nprint(len(k))\r\n \r\n \r\n \r\n", "def timetable(lst):\r\n flag, count = True, 0\r\n result = 0\r\n for elem in lst:\r\n if elem == 1:\r\n if count >= 2 and not flag:\r\n result += count\r\n count = 0\r\n flag = False\r\n else:\r\n count += 1\r\n if flag is True:\r\n result += 1\r\n if not flag:\r\n result += count\r\n return len(lst) - result\r\n\r\n\r\nn = int(input())\r\na = [int(j) for j in input().split()]\r\nprint(timetable(a))\r\n\r\n\r\n\r\n", "n = int(input())\r\n\r\nif n==1 :\r\n st = input()\r\n if st=='1' :\r\n print (1)\r\n else :\r\n print (0)\r\n\r\nelse :\r\n st = input()\r\n ans = n-2\r\n n = n*2\r\n if st[0]=='1' :\r\n ans += 1\r\n if st[n-2]=='1' :\r\n ans += 1\r\n for a in range (2,n-3,2) :\r\n if st[a]=='0' and (st[a-2]=='0' or st[a+2]=='0') :\r\n ans -= 1\r\n print (ans)\r\n", "input()\na= input().split()\nn=0\ni=0\nb=False\nwhile i <len(a):\n if a[i]=='1':\n n+=1\n elif i+1 < len(a) and a[i+1]=='1' and i!=0 and a[i-1] =='1':\n n+=1\n i+=1\nprint(n) ", "n = int(input())\r\nmat = list(map(int, input().split()))\r\ntry:\r\n mat = mat[mat.index(1)::]\r\n\r\n for i in range(1,len(mat)-1):\r\n if mat[i]==0 and mat[i-1]==1 and mat[i+1]==1:\r\n mat[i]=1\r\n \r\n print(sum(mat))\r\n\r\n\r\nexcept:\r\n print(0)\r\n", "n = int(input())\r\n\r\na = [int(x) for x in input().split()]\r\n\r\nonly_zero = False\r\nzero_before = 0\r\n\r\nsuma = 0\r\nfor x in a:\r\n if x == 1:\r\n if zero_before < 2:\r\n suma += zero_before\r\n only_zero = True\r\n zero_before = 0\r\n suma += 1\r\n #elif x == 0 and zero_before > 0:\r\n #zero_before += 1\r\n elif x == 0 and only_zero == True:\r\n zero_before += 1\r\n \r\nprint(suma)", "n = int(input().strip())\r\nans = 0\r\npairs = list(map(int, input().split()))\r\ncurr_old = 10000000000\r\nfor i in range(n):\r\n if pairs[i] == 1:\r\n ans += 1\r\n if i - curr_old == 2:\r\n ans += 1\r\n curr_old = i\r\nprint(ans)", "n=int(input())\r\nl=list(map(int,input().split()))\r\nans = 0\r\nfor i in range(n):\r\n if l[i] ==1:\r\n ans +=1\r\n elif 0<i<n-1 and l[i-1]==1 and l[i+1]==1:\r\n ans+=1\r\n # print(l[i] , ans)\r\nprint(ans)", "import sys\nimport time\nimport traceback\nfrom contextlib import contextmanager\nfrom io import StringIO\n\n\nfsm = [\n [(0, 0), (1, 1)],\n [(2, 0), (1, 1)],\n [(0, 0), (1, 2)],\n]\n\n\ndef npairs(n, aa):\n s = 0\n t = 0\n for ai in aa:\n s, dt = fsm[s][ai]\n t += dt\n return t\n\n\ndef main():\n n = int(input())\n aa = [int(i) for i in input().split()]\n assert len(aa) == n\n print(npairs(n, aa))\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 = [(\"\"\"\\\n5\n0 1 0 1 1\n\"\"\", \"\"\"\\\n4\n\"\"\"), (\"\"\"\\\n7\n1 0 1 0 0 1 0\n\"\"\", \"\"\"\\\n4\n\"\"\"), (\"\"\"\\\n1\n0\n\"\"\", \"\"\"\\\n0\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", "dem, n, lst, pos = 0, int(input()), list(map(int, input().split())), []\r\nfor x in range(n):\r\n if lst[x] == 1: pos.append(x)\r\ndem = len(pos)\r\nfor x in range(len(pos) - 1):\r\n if pos[x + 1] - pos[x] == 2: dem += 1\r\nprint(dem)", "import math\r\ndef main_function():\r\n input()\r\n a = [int(i) for i in input().split(\" \")]\r\n counter_1 = 0\r\n did_first_pair_start = False\r\n now_no_0_pair_only_1 = False\r\n s_now_no_many_pair = False\r\n for i in range(len(a)):\r\n if not did_first_pair_start and a[i] == 1:\r\n did_first_pair_start = True\r\n counter_1 += 1\r\n elif did_first_pair_start and now_no_0_pair_only_1 and not s_now_no_many_pair and a[i] == 0:\r\n s_now_no_many_pair = True\r\n now_no_0_pair_only_1 = False\r\n elif did_first_pair_start and not now_no_0_pair_only_1 and not s_now_no_many_pair and a[i] == 0:\r\n now_no_0_pair_only_1 = True\r\n elif did_first_pair_start and not now_no_0_pair_only_1 and not s_now_no_many_pair and a[i] == 1:\r\n counter_1 += 1\r\n now_no_0_pair_only_1 = False\r\n s_now_no_many_pair = False\r\n elif did_first_pair_start and now_no_0_pair_only_1 and not s_now_no_many_pair and a[i] == 1:\r\n counter_1 += 2\r\n now_no_0_pair_only_1 = False\r\n s_now_no_many_pair = False\r\n elif did_first_pair_start and not now_no_0_pair_only_1 and s_now_no_many_pair and a[i] == 1:\r\n counter_1 += 1\r\n now_no_0_pair_only_1 = False\r\n s_now_no_many_pair = False\r\n return counter_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\nprint(main_function())", "n = int(input())\r\na = [int(i) for i in input().split(\" \")]\r\n\r\ns = 0\r\nfor i in range(n):\r\n if a[i] == 1:\r\n s += 1\r\n elif a[i] == 0 and (i > 0 and i + 1 < n and a[i-1] == 1 and a[i+1] == 1):\r\n s += 1\r\n\r\nprint(s)\r\n", "n = input()\nlessons = input().split()\nprev = '0'\nhome = True\ncnt = 0\nfor l in lessons:\n if l == '0' and prev == '0':\n home = True\n elif l == '1':\n cnt += 1\n if prev == '0' and not home:\n cnt += 1\n home = False\n prev = l\nprint(cnt)\n\n\n", "n=int(input())\r\na=input()\r\na=a.replace(' ','')\r\na=a+'00'\r\nc=2\r\nh=0\r\nfor i in a:\r\n if i=='0':\r\n c+=1\r\n else:\r\n if c==1:\r\n h+=2\r\n else:\r\n h+=1\r\n c=0\r\nprint(h)", "n=int(input())\r\ns=\"\".join(input().split())\r\nwhile \"101\" in s:\r\n s=s.replace(\"101\", \"111\")\r\nprint(sum(map(int, s)))\r\n\r\n", "from collections import Counter\r\ndef mp(): return map(int,input().split())\r\ndef lt(): return list(map(int,input().split()))\r\ndef pt(x): print(x)\r\ndef ip(): return input()\r\ndef it(): return int(input())\r\ndef sl(x): return [t for t in x]\r\ndef spl(x): return x.split()\r\ndef aj(liste, item): liste.append(item)\r\ndef bin(x): return \"{0:b}\".format(x)\r\n\r\nn = it()\r\ns = input()\r\nprint(s.count(\"1\") + sum([s[i:i+5] == \"1 0 1\" for i in range(len(s))]))\r\n \r\n \r\n \r\n ", "n=int(input())\r\ns=input()\r\na=s.split(' ')\r\nd=0\r\nk=0\r\nfor i in a:\r\n if i=='0':\r\n k+=1\r\n if i=='1':\r\n if k==1 and d>0:\r\n d+=2\r\n k=0\r\n else:\r\n d+=1\r\n k=0\r\nprint(d)\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\ncnt0 = 0\r\nfor i in range(1, n - 1):\r\n if a[i-1:i+2] == [1, 0, 1]:\r\n cnt0 += 1\r\nprint(a.count(1) + cnt0)", "size = input()\r\narr = (''.join(input().split())).strip('0')\r\n\r\ncount = 0\r\nstart = arr.find('00')\r\nend = arr.find('1',start+2)\r\n\r\nwhile start!=-1:\r\n count += end - start\r\n start = arr.find('00',end+1)\r\n end = arr.find('1',start+2)\r\n\r\nprint(len(arr)-count)", "#!/usr/bin/env python\r\n# -*- coding: utf-8 -*-\r\n\r\nn = int(input())\r\nA = list(map(int,input().split()))\r\n\r\nattends = 0\r\ni = 0\r\nwhile i < n:\r\n if A[i] == 1:\r\n attends += 1\r\n else:\r\n if 0 < i < n - 1 and A[i-1] == 1 and A[i+1] == 1:\r\n attends += 2\r\n i += 1\r\n i += 1\r\nprint(attends)\r\n", "a=int(input())\r\nl=list(map(int,input().split()))\r\nfor i in range(1,a-1):\r\n if(l[i-1] and l[i+1]):\r\n l[i]=1\r\nprint(sum(l))", "n = int(input())\na = [int(i) for i in input().split()]\ncount = 0\nk = 0\nif sum(a) != 1:\n if len(a) > 1 and sum(a) != 0:\n for i in range(len(a)):\n if a[i] != 0:\n a = a[i:]\n break\n while k < len(a) - 1:\n if a[k] == 1:\n count += 1\n k += 1\n elif a[k] == 0 and a[k + 1] == 0:\n k += 2\n elif a[k] == 0 and a[k + 1] == 1:\n if a[k - 1] == 0:\n k += 1\n else:\n count += 1\n k += 1\n if a[len(a) - 1] > 0:\n count += 1\n else:\n count = a[0]\nelse:\n count += 1\nprint(count)\n", "n = int(input())\nps = input().split()\n\ni = 0\nwhile i < n and ps[i] == '0':\n i += 1\nj = -1\nwhile -j <= n and ps[j] == '0':\n j -= 1\n\nfree = 0\nr = 0\nfor p in ps[i:n+j+1]:\n if p == '0':\n if free == 0:\n r += 1\n elif free == 1:\n r -= 1\n else:\n pass\n free += 1\n else:\n free = 0\n r += 1\nprint(r)\n", "n = int(input())\r\n\r\narr = [int(x) for x in input().split()]\r\narr.append(10)\r\nif arr[0] == 1:\r\n ans = 1\r\nelse:\r\n ans = 0\r\n\r\nfor i, v in enumerate(arr):\r\n if i == 0 or v == 10:\r\n continue\r\n if v == 1:\r\n ans += 1\r\n else:\r\n if arr[i - 1] == 1 and arr[i + 1] == 1:\r\n ans += 1\r\nprint(ans)\r\n", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport re\n\nN = int(input())\nS = input()\nS = S.replace(\" \", \"\")\nS = S.strip(\"0\")\n\nret = 0\nfor seg in re.split(\"00+\", S):\n ret += len(seg)\n\nprint(ret)\n\n", "n = int(input())\nx = list(map(int, input().split()))\nans = x.count(1)\nfor i in range(1, n):\n if i == n - 1:\n break\n if x[i] == 0 and x[i - 1] == 1 and x[i + 1] == 1:\n ans += 1\nprint(ans)\n", "n=int(input())\r\na=[int(x) for x in input().split()]\r\nres,pos1,pos2=2,-1,-1\r\nfor i in range(n):\r\n if a[i]==1:\r\n pos1=i\r\n break\r\nfor i in range(n-1,-1,-1):\r\n if a[i]==1:\r\n pos2=i\r\n break\r\nif pos1==-1:\r\n print(0)\r\nelse:\r\n a=a[pos1:pos2+1]\r\n if len(a)==1:\r\n print(1)\r\n elif len(a)==2:\r\n print(2)\r\n else:\r\n for i in range(1,len(a)-1):\r\n if a[i]==1:\r\n res+=1\r\n else:\r\n if a[i-1]==1 and a[i+1]==1:\r\n res+=1\r\n print(res)", "from sys import stdin, stdout\ninput = stdin.readline\n\nn = int(input())\na = list(map(int, input().split()))\nans = 0\n\nuni = False\nind = 0\n\nwhile ind < n-1:\n if a[ind] == 1:\n ans += 1\n ind += 1\n uni = True\n else:\n if a[ind+1] == 0:\n while ind < n and a[ind] == 0:\n ind += 1\n uni = False\n else:\n if uni:\n ans += 1\n ind += 1\n\nif a[n-1] == 1:\n ans += 1\n\nstdout.write(str(ans))\n\n\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nk=0\r\nfor i in range(n):\r\n if a[i]==1:\r\n k+=1\r\n elif k>0:\r\n if (i-1>=0 and a[i-1]!=0):\r\n if (i+1<n and a[i+1]==1):\r\n k+=1\r\nprint(k)\r\n", "length = int(input())\r\nnums = list(map(int,input().split()))\r\nhome = 1\r\ncount = 0\r\nfor index in range(length) :\r\n if nums[index] == 1 : \r\n count += 1\r\n home = 0\r\n elif home == 1 and nums[index] == 0 : continue\r\n else :\r\n if index == length - 1 : count += nums[index]\r\n elif nums[index] == nums[index + 1] : home = 1 \r\n elif nums[index] != nums[index + 1] : count += 1 \r\n\r\nprint(count)", "n = int(input())\r\ns = input().strip('0 ').replace(' ', '')\r\ni = 0\r\nans = 0\r\nwhile i != len(s):\r\n if s[i] == '1':\r\n i += 1\r\n ans += 1\r\n elif s[i] == '0' and s[i + 1] == '1':\r\n i += 1\r\n ans += 1\r\n else:\r\n while s[i + 1] != '1':\r\n i += 1\r\n i += 1\r\nprint(ans)", "import sys\r\n\r\nn = int(input())\r\nv = list(map(int, input().split()))\r\n\r\nfor i in range(2, n):\r\n\tif v[i] + v[i - 2] == 2: v[i - 1] = 1\r\n\r\nprint(sum(v))", "def main():\n n = int(input())\n a = [int(i) for i in input().split()]\n start = -1\n finish = -1\n for i in range(n):\n if start == -1 and a[i] == 1:\n start = i\n if a[i] == 1:\n finish = i\n if finish == -1:\n print(0)\n return\n count_windows = 0\n tmp_count = 0\n for i in range(start, finish + 1):\n if a[i] == 0:\n tmp_count += 1\n else:\n if tmp_count >= 2:\n count_windows += tmp_count\n tmp_count = 0\n print(finish + 1 - start - count_windows)\n return\n\nmain()\n", "from sys import stdin\n\nx = [int(i) for i in stdin.read().rstrip().split()]\n\nn = x[0]\nsch = x[1:]\n\ncount = 0\nfor i in range(n):\n if sch[i] == 1:\n count += 1\n if sch[i] == 0 and i > 0 and i < n-1 and (sch[i-1] == 1 and sch[i+1] == 1):\n count += 1\n\nprint(count)\n", "n=int(input())\r\nl=list(map(int,input().split()))[0:n]\r\nc=l.count(1)\r\nfor i in range(1,n-1,1):\r\n if l[i]==0 and l[i-1]+l[i+1]==2:c+=1\r\nprint(c)", "count = int(input())\r\nin_str = input()\r\ntimetable = [int(i) for i in in_str.split()]\r\nhome = False\r\nwindows = 0\r\nend_windows = 0\r\n\r\nfor i in timetable:\r\n if i == 0:\r\n count -= 1\r\n else:\r\n break\r\n\r\nif len(timetable) != count:\r\n timetable = timetable[len(timetable) - count:]\r\n\r\nfor i in range(len(timetable)-1,0, -1):\r\n if timetable[i] == 0:\r\n end_windows += 1\r\n else:\r\n break\r\n\r\ntimetable = timetable[:len(timetable) - end_windows]\r\n\r\n\r\ncount -= end_windows\r\n\r\nfor i in timetable:\r\n if i == 0:\r\n windows += 1\r\n if windows >= 2 and not home:\r\n home = True\r\n count -= 2\r\n continue\r\n else:\r\n home = False\r\n windows = 0\r\n if home:\r\n count -= 1\r\n\r\nprint(count)\r\n", "i=int(input())\r\nmas=list(input())\r\nflag=3\r\nfor j in range(len(mas)):\r\n if flag==1 and j==len(mas)-1 and mas[j]==\"0\":\r\n i-=1\r\n elif flag==1 and mas[j]==\"0\":\r\n flag=2\r\n elif flag==2 and mas[j]==\"0\":\r\n i-=2\r\n flag=3\r\n elif flag==3 and mas[j]==\"0\":\r\n i-=1\r\n elif (flag==2 or flag==3) and mas[j]==\"1\":\r\n flag=1\r\nprint(i)", "def solve():\r\n n = int(input())\r\n seq = list(map(int,input().split()))\r\n #n = 7\r\n #seq = [1,0,1,0,0,1,0]\r\n count = 0\r\n i = 0\r\n while i < n-1:\r\n if seq[i] == 1:\r\n count += 1\r\n elif seq[i] == 0 and seq[i+1] == 1 and seq[i-1] == 1 and i != 0:\r\n count += 1\r\n i +=1\r\n #i += 1\r\n if seq[i] == 1:\r\n count += 1\r\n print(count)\r\n \r\nsolve()", "n=int(input())\r\na='0'+''.join(input().split())+'0'\r\ns=''\r\ni=1\r\nwhile i<=n:\r\n if a[i]=='1':\r\n s+=a[i]\r\n else:\r\n if a[i+1]=='0':\r\n pass\r\n else:\r\n if a[i-1]=='0':\r\n s+=a[i+1]\r\n elif a[i-1]=='1':\r\n s+=a[i]+a[i+1]\r\n i+=1\r\n i+=1\r\n \r\nans=s.rfind('1')-s.find('1')\r\nprint(ans+1 if ans or s.rfind('1')!=-1 else 0)", "n = int(input())\nl = list(map(int, input().split()))\ncnt = 0\n#print(l)\nstop = -1\nfor i in range(n):\n if l[i] == 1:\n break\n else:\n stop = i\nwhile l and l[-1] == 0:\n l.pop(-1)\n#print(l)\nfor i in range(stop+1, len(l)):\n #print(i)\n if i <= len(l)-2:\n if (i<len(l)-1 and l[i] == 0 and l[i+1] == 0) or (i>0 and l[i] == 0 and l[i-1]==0):\n pass\n #print(\"bob\")\n elif l[i] == 1 or l[i+1] == 1 or l[i+2] == 1:\n cnt += 1\n #print(\"add\")\n elif i <= len(l)-2:\n if l[i+1] == 1:\n #print(\"add\")\n cnt += 1\n elif l[i] == 1:\n #print(\"add\")\n cnt += 1\n \nprint(cnt)\n", "n = int(input())\r\npairs = list(map(int, input().split()))\r\nif 1 in pairs:\r\n\tfirst = pairs.index(1)\r\n\tlast = pairs[::-1].index(1)\r\n\tpairs = pairs[first:n-last]\r\n\ttotal = 0\r\n\tfor i in range(len(pairs)-1):\r\n\t\tif pairs[i] == 0 and pairs[i+1] == 1 and pairs[i-1] == 1:\r\n\t\t\ttotal+=1\r\n\r\n\ttotal += pairs.count(1)\r\n\tprint(total)\r\nelse:\r\n\tprint(0)\r\n\r\n", "num = int(input())\r\n\r\narr = list(map(int, input().split()))\r\n\r\nans = 0\r\nstarted = False\r\n\r\nfor i in range(num):\r\n if arr[i] == 1 and not started:\r\n started = True\r\n ans +=1\r\n elif arr[i] == 1:\r\n ans += 1\r\n elif arr[i] == 0 and started:\r\n if i == num -1:\r\n continue\r\n else:\r\n if arr[i-1] == arr[i+1] == 1:\r\n ans += 1\r\n\r\nprint(ans)\r\n", "input()\r\n\r\nA = list(map(int,input().split()))\r\n\r\nif 1 not in A: print(0)\r\n\r\nelse:\r\n id = A.index(1)\r\n de = 0\r\n c0 = 0\r\n for i in A[id:]:\r\n if i == 0:\r\n c0 += 1\r\n else:\r\n if c0 > 1:\r\n de += c0\r\n c0 = 0\r\n de += c0\r\n \r\n print(len(A) - id - de)\r\n \r\n ", "def solve(s):\r\n k = 0\r\n j = 0\r\n while (s[j]=='0') and (j<len(s)-1):\r\n j += 2\r\n for i in range(j,len(s),2):\r\n if (s[i]=='1'):\r\n k += 1\r\n if (i>1) and (i<len(s)-1) and (s[i-2]=='1') and (s[i]=='0') and (s[i+2]=='1'):\r\n k += 1\r\n return k\r\n\r\ninp0 = input()\r\ninp = input() \r\nprint(solve(inp))\r\n", "n = int(input())\r\na = [int(x) for x in input().split()]\r\nans = 0\r\nfor i in range(n):\r\n if (i > 0 and i < n - 1 and a[i] == 0 and a[i - 1] == 1 and a[i + 1] == 1):\r\n ans += 1\r\n if (a[i] == 1):\r\n ans += 1\r\n\r\nprint(ans)\r\n \r\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\nt = 0\r\nfor i in range(len(l)):\r\n\tif l[i] == 0 and i > 0 and i < n-1:\r\n\t\tif l[i-1] == 1 and l[i+1] == 1:\r\n\t\t\tt = t + 1\r\n\tif l[i] == 1:\r\n\t\tt = t + 1\r\nprint(t)", "n = int(input())\r\nb=list(map(int,input().split()))\r\nb=[0]+b+[0]\r\nfor i in range(1,len(b)-3):\r\n if b[i:i+3]==[1,0,1]:\r\n b=b[:i]+[1,1,1]+b[i+3:]\r\nprint(sum(b))\r\n\r\n", "a=int(input())\r\n\r\nb=list(map(int,input().split()))\r\n\r\nfor i in range(1,a-1):\r\n if(b[i-1] and b[i+1]):\r\n b[i]=1\r\n\r\nprint(sum((b)))\r\n", "n = int(input())\r\nword = input().replace(\" \", \"\").strip(\"0\")\r\nword = word.replace(\"0\"*5, \"00\")\r\nwhile \"000\" in word:\r\n word = word.replace(\"000\", \"00\")\r\nword = word.replace(\"00\", \"\")\r\nprint(len(word))", "n = int(input())\r\na = input()\r\nans = a.count('1')\r\nz = a.find('0')\r\na = a.split('1')\r\nif z == 0:\r\n z = 1\r\nelse:\r\n z = 0\r\nfor i in range(z, len(a)):\r\n if len(a[i].strip()) == 1 and a[i] != ' 0':\r\n ans += 1\r\nprint(ans)\r\n \r\n\r\n \r\n", "import re\ninput()\nv = ''.join(input().split()).strip('0')\nprint(len(re.sub(r\"00+\", \"\", v)))\n", "import sys\nimport re\nsys.stdin.readline()\ns = sys.stdin.readline()\ns = re.sub('[^01]','',s)\ns = s.strip('0')\ns = re.sub('0{2,}','',s)\n#print(repr(s))\nprint(len(s))\n\n", "n=int(input());\r\nans=0;\r\na=[0];\r\na.extend([int(v) for v in input().split(' ')]);\r\nfor i in range(1,n+1):\r\n if a[i]==1:\r\n ans=ans+1;\r\n if i<=n-2 and a[i+1]==0 and a[i+2]==1:\r\n ans=ans+1;\r\nprint(ans);\r\n", "def arr_inp():\r\n return [int(x) for x in input().split()]\r\n\r\n\r\nn, a = int(input()), arr_inp()\r\ncount, tem, ix1, ix2 = 0, 0, -1, -1\r\n\r\nfor i in range(n):\r\n if (a[i]):\r\n ix1 = i\r\n break\r\n\r\nfor i in range(n - 1, -1, -1):\r\n if (a[i]):\r\n ix2 = i\r\n break\r\n\r\nif(ix1==-1 or ix2==-1):\r\n exit(print(0))\r\n\r\nfor i in range(ix1, ix2 + 1):\r\n if (a[i]):\r\n if (tem > 1):\r\n count -= tem\r\n tem=0\r\n else:\r\n tem += 1\r\n count += 1\r\nprint(count)\r\n", "n = int(input())\na = '0' + ''.join(input().split()) + '0'\ns = ''\ni = 1\nwhile i <= n:\n if a[i] == '1':\n s += a[i]\n else:\n if a[i + 1] == '0':\n pass\n else:\n if a[i - 1] == '0':\n s += a[i + 1]\n elif a[i - 1] == '1':\n s += a[i] + a[i + 1]\n i += 1\n i += 1\nprint(len(s))\n", "input()\r\na=''.join(input().split())\r\nfor i in range(100):a=a.replace('101','111')\r\nprint(a.count('1'))\r\n", "n = int(input())\r\nAs = list(map(int, input().split()))\r\nstay = 0\r\natuniv = False\r\nfor i in range(n):\r\n if As[i] == 1:\r\n atuniv = True\r\n stay += 1\r\n elif atuniv == False:\r\n continue\r\n elif i == n - 1:\r\n continue\r\n elif As[i + 1] == 0:\r\n atuniv = False\r\n else:\r\n stay += 1\r\nprint(stay)", "from sys import stdin\r\nlive = True\r\nif not live: stdin = open('data.in', 'r')\r\n\r\nn = int(stdin.readline())\r\nnumbers = list(map(int, stdin.readline().strip().split()))\r\nnumbers += [0]\r\n\r\nans = 0\r\nisToHome = True\r\n\r\nfor it in range(n):\r\n\tif isToHome:\r\n\t\tif numbers[it] != 0:\r\n\t\t\tisToHome = False\r\n\t\t\tans += 1\r\n\telse:\r\n\t\tif numbers[it] == 1:\r\n\t\t\tans += 1\r\n\t\telse:\r\n\t\t\tif numbers[it + 1] == 0:\r\n\t\t\t\tisToHome = True\r\n\t\t\telse:\r\n\t\t\t\tans += 1\r\n\t\t\t\t\r\nprint(ans)\r\nif not live: stdin.close()", "input()\r\na = list(map(int, input().split()))\r\nfor i in range(1, len(a) - 1):\r\n if a[i - 1] and a[i + 1]:\r\n a[i] = 1\r\nprint(sum(a))", "n=int(input())\r\nl=list(map(int,input().split()))\r\nc=0\r\nfor i in range(n-2):\r\n if(l[i]==1 and l[i+1]==0 and l[i+2]==1):\r\n c=c+1\r\nprint(c+l.count(1))", "n = int(input())\narr = list(map(int, input().split()))\n\nans = 0\n\nif arr[0] == 0:\n arr[0] = -1\n\nif arr[n - 1] == 0:\n arr[n - 1] = -1\n\nfor i in range(0, n):\n if arr[i] == 1:\n ans += 1\n if arr[i] == 0:\n if arr[i - 1] == 1 and arr[i + 1] == 1:\n ans += 1\n\nprint(ans)", "__author__ = 'yarsanich'\nn = int(input(''))\na = list(map(int, input('').split()))\nans = 0\nfor i in range(n):\n if (a[i] == 1):\n ans+=1\na.append(1)\nstart = a.index(1)\nif (start!=n):\n for i in range(start,n-1):\n if (a[i] == 0) and (a[i+1] != 0) and (a[i-1]!=0):\n ans+=1\n print(ans)\nelse:\n print(0)\n", "n = int(input())\na = [int(x) for x in input().split()]\nptr = 0\nwhile ptr < n and a[ptr] == 0:\n\tptr += 1\nif ptr == n:\n\tprint(0)\n\texit()\na = a[ptr:]\nptr = len(a) - 1\nwhile a[ptr] == 0:\n\tptr -= 1\na = a[:ptr + 1]\nn = len(a)\nptr = 0\nres = 0\nwhile ptr < n:\n\tif a[ptr]:\n\t\tres += 1\n\t\tptr += 1\n\t\tcontinue\n\tj = 0\n\twhile a[ptr + j] == 0:\n\t\tj += 1\n\tif j == 1:\n\t\tres += 1\n\tptr += j\nprint(res)\n", "n = int(input())\r\nP = list(map(int, input().split()))\r\nkol = 0\r\n\r\nif P[0] == 1:\r\n kol += 1\r\n\r\nfor i in range(1, n-1):\r\n if P[i] != 0:\r\n kol += 1\r\n elif P[i-1] != 0 and P[i] == 0 and P[i+1] != 0:\r\n kol += 1\r\n\r\nif P[n-1] != 0 and n != 1:\r\n kol += 1\r\n\r\nprint(kol)\r\n", "input()\npprev, prev = None, None\nans = 0\nfor i in input().split():\n if i == '1':\n ans += 1\n if prev == '0' and pprev == '1':\n ans += 1\n pprev, prev = prev, i\nprint(ans)\n", "from itertools import groupby\n\n\nN = int(input())\nA = list(map(int, input().split()))\nif N == 1 and A[0] == 0:\n print(0)\n exit()\ngroups = groupby(A)\nans = 0\nfor i, (key, vals) in enumerate(groups):\n vals = list(vals)\n if key == 1:\n ans += len(vals)\n else:\n if len(vals) == 1 and i != 0:\n ans += 1\n# last zero\nif A[-1] == 0:\n groups = groupby(A)\n n_groups = len(list(groups))\n groups = groupby(A)\n for i, (key, vals) in enumerate(groups):\n vals = list(vals)\n if i == n_groups - 1:\n if len(vals) == 1:\n ans -= 1\nprint(ans)\n", "def getData():\r\n line = input()\r\n line = line.split()\r\n for i in range(len(line)):\r\n line[i] = int(line[i])\r\n return line\r\n\r\nn = int(input())\r\nsc = getData()\r\n\r\ntime = 0\r\ni = 0\r\nwhile (i<len(sc)):\r\n if (i == 0):\r\n while (sc[i] == 0 and i<len(sc)-1):\r\n i += 1\r\n\r\n if (sc[i] == 1):\r\n time += 1\r\n i += 1\r\n elif(sc[i] == 0 and i < (len(sc) - 1)):\r\n if (sc[i+1] == 1):\r\n time += 1\r\n i += 1\r\n else:\r\n while (sc[i] == 0 and i<len(sc)-1):\r\n i += 1\r\n else:\r\n break\r\n\r\nprint(time)\r\n \r\n", "n = int(input())\r\narr = list(map(int, input().split()))\r\nans = 0\r\nfor i in range(len(arr)):\r\n if i + 1 <= len(arr) - 1 and i - 1 >= 0:\r\n if arr[i] == 1:\r\n ans += 1\r\n if arr[i] == 0 and arr[i+1] == 1 and arr[i-1] == 1:\r\n ans += 1\r\n else:\r\n if arr[i] == 1:\r\n ans += 1\r\nprint(ans)", "n=int(input())\r\n\r\nl=input().split()\r\ns=l.count('1')\r\ni=0\r\nwhile(i<n):\r\n if(l[i]=='0'):\r\n if(i+1<n and l[i+1]=='1'):\r\n if(i>0 and l[i-1]=='1'):\r\n s+=1\r\n i+=1\r\nprint(s)\r\n", "n=int(input())\r\na=[0]+list(map(int,input().split()))+[0]\r\nprint(sum(a[i-1]+a[i+1]+a[i]*9>1 for i in range(1,n+1)))", "from sys import stdin,stdout\n\nn = int(stdin.readline())\n\nnulls = float('inf')\nresult = 0\nfor a in map(int, stdin.readline().split()):\n if a:\n result += 2 if 0 < nulls < 2 else 1\n nulls = 0\n else:\n nulls += 1\n\nprint(result)", "import sys\r\nsize = int(input())\r\n\r\nlist = list(map(int, input().split()))\r\n\r\nif 1 not in list:\r\n print(0)\r\n sys.exit()\r\n\r\n\r\n\r\ncounter = 0\r\n\r\npos = list.index(1)\r\n\r\nflag=0\r\nfor i in range(pos, size):\r\n if list[i]==1:\r\n counter += 1\r\n elif list[i]==0:\r\n if i!=(size-1):\r\n if list[i+1] == 0 and flag == 0:\r\n flag=1\r\n continue\r\n elif list[i+1]==1 and flag == 0:\r\n counter += 1\r\n elif list[i+1]==1 and flag == 1:\r\n flag=0\r\n\r\n\r\n\r\nprint(counter)\r\n\r\n# 10\r\n#0 0 1 0 0 0 0 1 1 0", "import re\r\nn = int(input())\r\nl = input().split()\r\ns = ''.join(l).strip('0')\r\nif len(s)==0:\r\n print(0)\r\nelse:\r\n c=len(s)\r\n xl = re.findall(r'00+',s)\r\n #print(xl)\r\n for i in xl:\r\n c-=len(i)\r\n print(c)", "n=int(input())\r\nclasses=list(map(int,input().split(\" \")))\r\npair=0\r\ncont=0\r\nfor j in range(len(classes)):\r\n if classes[j]==1:\r\n break\r\n#print(j)\r\nfor i in range(j,len(classes)):\r\n if classes[i]==1 and cont==1:\r\n pair+=2\r\n cont=0\r\n elif classes[i]==1 and cont==0:\r\n pair+=1\r\n elif classes[i]==1 and cont>1:\r\n pair+=1\r\n cont=0\r\n elif classes[i]==0:\r\n cont+=1\r\nprint(pair)", "n = int(input())\na = input().split()\nzeroth = 0\nind = 0\n\nfor i in range(n):\n if(a[i] == \"1\"):\n if(i == 1 and zeroth != 0):\n ind -= zeroth\n if(zeroth > 1):\n ind -= zeroth\n ind += 1\n zeroth = 0\n else:\n zeroth += 1\n ind += 1\n\nind -= zeroth\n\nprint(ind)\n\n \t \t\t \t \t \t \t \t\t\t \t", "n=int(input())\r\nl=[int(i) for i in input().split()]\r\nans=l.count(1)\r\nseen=0 \r\nfor i in range(n):\r\n if l[i]==0 and seen:\r\n c+=1 \r\n elif l[i]==1:\r\n if seen==0:\r\n seen=1 \r\n c=0 \r\n else:\r\n if c==1:\r\n ans+=1 \r\n c=0 \r\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\ncount = 0\ni = 0\nwhile i < n and a[i] == 0:\n i += 1\nwhile i < n:\n if a[i] == 1:\n i += 1\n count += 1\n else:\n tmp = 0\n while i < n and a[i] == 0:\n tmp += 1\n i += 1\n if i != n and tmp < 2:\n count += tmp\nprint(count)", "n=int(input())\r\nl=list(input().split())\r\ns=\"\".join(l)\r\ns=s.lstrip(\"0\")\r\ns=s.rstrip(\"0\")\r\n# print(s)\r\nif s==\"\":\r\n\tprint(0)\t\r\nelse:\r\n\t# c=s.count(\"00\")\r\n\t# print(len(s)-2*c)\r\n\tc=\"0\"\r\n\tnew=\"\"\r\n\tl=[]\r\n\ta=0\r\n\t# print(len(s))\r\n\tfor i in range(len(s)-1):\r\n\t\tif s[i]==s[i+1]==\"0\" or s[i]==s[i-1]==\"0\":\r\n\t\t\tpass\r\n\t\t\t# a+=1\r\n\t\t\t# print(a,s[i],i,\"*\")\t\r\n\t\telse:\r\n\t\t\ta+=1\r\n\t# l=list(set(l))\r\n\tprint(a+1)", "n = int(input())\r\na = input().split()#[int(x) for x in input().split()]\r\ntmp_count = 0\r\nprev_sum = 0\r\nfor i in a:\r\n i = int(i)\r\n if i == 0:\r\n if tmp_count == 0:\r\n continue\r\n else:\r\n prev_sum +=1\r\n else:\r\n if prev_sum == 1:\r\n tmp_count += 2\r\n prev_sum = 0\r\n else:\r\n prev_sum = 0\r\n tmp_count += 1\r\n \r\nprint(str(tmp_count))\r\n", "n = int(input())\r\narr = list(map(int,input().split()))\r\nstart=end=-1\r\nfor i in range(n):\r\n if arr[i]==1:\r\n start=i\r\n break\r\nfor i in range(n-1,-1,-1):\r\n if arr[i]==1:\r\n end=i\r\n break\r\nif start==end==-1:\r\n print(0)\r\nelif start==end:\r\n print(1)\r\nelse:\r\n i=start+1\r\n counter = 0\r\n while i<end:\r\n count = 0\r\n if arr[i]==0:\r\n while arr[i]==0:\r\n count += 1\r\n i += 1\r\n else:\r\n i += 1\r\n if count>=2:\r\n counter += count\r\n print(end-start+1-counter)\r\n", "num = int(input())\r\n\r\narr = \"\".join(list(input().split())).replace(\"101\", \"111\")\r\nwhile \"101\" in arr:\r\n arr = arr.replace(\"101\", \"111\")\r\nans = arr.count(\"1\")\r\nprint(ans)\r\n# print(arr)\r\n\r\n\r\n", "n = int(input())\r\nstring = input()\r\nnumbers = string.split()\r\nfor x in range(n):\r\n numbers[x] = int(numbers[x])\r\nstreaks = []\r\nstreak = 0\r\nfor x in numbers:\r\n if x == 0:\r\n streak += 1\r\n else:\r\n streaks.append(streak)\r\n streak = 0\r\nif len(streaks) > 0:\r\n del streaks[0]\r\nprint(numbers.count(1) + sum(list(filter(lambda x: x < 2, streaks))))\r\n", "n = int(input())\narray = list(map(int, input().split()))\n\nif array[0] == 0:\n array[0] = -1\n\nif array[n - 1] == 0:\n array[n - 1] = -1\n\nanswer = 0\n\nfor i in range(0, n):\n if array[i] == 1:\n answer += 1\n if array[i - 1] == 1 and array[i] == 0 and array[i + 1] == 1:\n answer += 1\n\nprint(answer)" ]
{"inputs": ["5\n0 1 0 1 1", "7\n1 0 1 0 0 1 0", "1\n0", "1\n1", "2\n0 0", "2\n0 1", "2\n1 0", "2\n1 1", "10\n0 0 0 0 0 0 0 0 0 0", "9\n1 1 1 1 1 1 1 1 1", "11\n0 0 0 0 0 0 0 0 0 0 1", "12\n1 0 0 0 0 0 0 0 0 0 0 0", "20\n1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 0 0", "41\n1 1 0 1 0 1 0 0 1 0 1 1 1 0 0 0 1 1 1 0 1 0 1 1 0 1 0 1 0 0 0 0 0 0 1 0 0 1 0 1 1", "63\n1 1 0 1 1 0 0 0 1 1 0 0 1 1 1 1 0 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1 1 0 0 1 0 1 0", "80\n0 1 1 1 0 1 1 1 1 1 0 0 1 0 1 1 0 1 1 1 0 1 1 1 1 0 1 0 1 0 0 0 1 1 0 1 1 0 0 0 0 1 1 1 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1", "99\n1 1 0 0 0 1 0 0 1 1 1 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0 0 0 1 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 1 0 0 0 1 1 1 0 1 1 1 0 1 0 0 1 1 0 1 0 0 1 1 1 1 0 0 1 1 0 0 1 0 1 1 1 0 1 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 0 1", "100\n0 1 1 0 1 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 0 1 0 0 0 0 0 1 0 1 1 0 0 1 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 0 0 1 1 1 1 0 1 1 1 0", "11\n0 1 1 0 0 0 0 0 0 0 0", "11\n0 1 0 1 0 0 1 1 0 1 1", "11\n1 0 1 0 1 1 0 1 1 1 0", "11\n1 0 0 0 0 0 1 0 1 1 1", "22\n0 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 1 0", "22\n0 1 0 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 0 0 0 1", "22\n1 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 0", "22\n1 0 1 0 0 0 1 0 0 1 1 0 1 0 1 1 0 0 0 1 0 1", "33\n0 1 1 0 1 1 0 1 0 1 1 0 1 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0 1 1 0 0", "33\n0 1 0 1 0 1 1 0 0 0 1 1 1 0 1 0 1 1 0 1 0 1 0 0 1 1 1 0 1 1 1 0 1", "33\n1 0 1 0 1 0 0 0 1 0 1 1 1 0 0 0 0 1 1 0 1 0 1 1 0 1 0 1 1 1 1 1 0", "33\n1 0 1 0 1 1 1 1 1 0 1 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 1", "44\n0 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 1 1 0 0", "44\n0 1 1 1 1 0 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 0 0 0 0 1 0 1 1", "44\n1 0 1 0 0 1 0 1 0 1 0 1 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 0 1 0", "44\n1 0 1 0 1 1 1 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 0 1 1 1 1", "55\n0 1 1 0 1 0 0 0 1 0 0 0 1 0 1 0 0 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0", "55\n0 1 1 0 1 0 1 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 1", "55\n1 0 1 0 0 1 0 0 1 1 0 1 0 1 0 0 1 1 0 0 0 0 1 1 1 0 0 0 1 1 1 1 0 1 0 1 0 0 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0", "55\n1 0 1 0 1 0 1 0 1 1 0 0 1 1 1 1 0 1 0 0 0 1 1 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 0 1 1 1", "66\n0 1 1 0 0 1 0 1 0 1 0 1 1 0 1 1 0 0 1 1 0 1 0 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 0 1 1 1 0 0 0 0 0 1 0", "66\n0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 0 0 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 1 0 0 1 1 0 1", "66\n1 0 1 0 0 0 1 0 1 0 1 0 1 1 0 1 0 1 1 0 0 0 1 1 1 0 1 0 0 1 0 1 0 0 0 0 1 1 0 1 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 0 1 1 0 1 1 0 1 1 0 0", "66\n1 0 1 0 0 0 1 1 1 1 1 0 1 0 0 0 1 1 1 0 1 1 0 1 0 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 1 1 1 1 1 0 1 1 1 1 1 1 0 0 0 1 0 1 1 0 0 0 1", "77\n0 0 1 0 0 1 0 0 1 1 1 1 0 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 1 1 0 1 0 1 1 0 0 0 1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 0", "77\n0 0 1 0 0 0 1 0 1 1 1 1 0 1 1 1 0 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 0 0 1 1", "77\n1 0 0 0 1 0 1 1 0 0 1 0 0 0 1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 1 1 1 0 1 1 1 0 0 0 1 1 0 1 1 1 0 1 1 0 0 1 0 0 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 0 0 0", "77\n1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 0 1 1 0 1 0 0 0 0 1 1 1 0 1 0 0 1 1 0 1 0 1 1 1 1 1 1 1 0 0 1 1 0 0 1 0 1 1 1 1 1 1 1 1 0 0 1 0 1 1", "88\n0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 0 0 1 0 0 0 1 0 1 1 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 1 1 0", "88\n0 0 1 0 0 0 1 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 1 0 1 1 0 0 0 0 0 1 1 0 0 1 0 1 1 1 0 1 1 0 1 1 0 0 0 1 1 1 1 1 1 1 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 1", "88\n1 0 0 0 1 1 1 0 1 1 0 0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 1 1 1 1 0 0 1 0 1 1 1 0 1 0 1 1 1 1 0 1 0 1 1 1 0 0 0", "88\n1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 1 0 1 1 0 1 0 0 1 0 0 1 0 0 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 1 0 1 1 0 1", "99\n0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 1 1 0 1 1 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 0 0 0 1 0 0 1 0 1 0 1 0 0 0 0 1 0 1 1 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 0 1 0 0 0 1 1 0 0 0 0", "99\n0 0 1 0 0 1 1 0 0 0 1 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 1 0 0 0 1 0 1 1 0 0 1 1 1 0 1 1 0 0 0 0 0 1 0 0 1 0 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 1 0 1 0 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 1 1 1", "99\n1 1 0 0 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 1 1 1 0 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 1 1 1 1 0 0 1 0", "99\n1 1 1 0 1 0 1 1 0 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 0 1 1 0 1 0 1 0 0 1 1 1 1 1 0 1 1 0 1 1 0 0 0 1 0 1 0 1 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1", "90\n0 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "90\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "95\n0 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "95\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "100\n0 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"], "outputs": ["4", "4", "0", "1", "0", "1", "1", "2", "0", "9", "1", "1", "16", "28", "39", "52", "72", "65", "2", "8", "10", "6", "7", "16", "11", "14", "26", "27", "25", "24", "19", "32", "23", "32", "23", "39", "32", "36", "41", "42", "46", "46", "47", "44", "45", "51", "44", "59", "53", "63", "56", "58", "65", "77", "0", "90", "0", "95", "0", "100"]}
UNKNOWN
PYTHON3
CODEFORCES
171
e032edaee261e97dbb910310c3e107a9
Ternary Logic
Little Petya very much likes computers. Recently he has received a new "Ternatron IV" as a gift from his mother. Unlike other modern computers, "Ternatron IV" operates with ternary and not binary logic. Petya immediately wondered how the *xor* operation is performed on this computer (and whether there is anything like it). It turned out that the operation does exist (however, it is called *tor*) and it works like this. Suppose that we need to calculate the value of the expression *a* *tor* *b*. Both numbers *a* and *b* are written in the ternary notation one under the other one (*b* under *a*). If they have a different number of digits, then leading zeroes are added to the shorter number until the lengths are the same. Then the numbers are summed together digit by digit. The result of summing each two digits is calculated modulo 3. Note that there is no carry between digits (i. e. during this operation the digits aren't transferred). For example: 1410 *tor* 5010<==<=01123 *tor* 12123<==<=10213<==<=3410. Petya wrote numbers *a* and *c* on a piece of paper. Help him find such number *b*, that *a* *tor* *b*<==<=*c*. If there are several such numbers, print the smallest one. The first line contains two integers *a* and *c* (0<=≤<=*a*,<=*c*<=≤<=109). Both numbers are written in decimal notation. Print the single integer *b*, such that *a* *tor* *b*<==<=*c*. If there are several possible numbers *b*, print the smallest one. You should print the number in decimal notation. Sample Input 14 34 50 34 387420489 225159023 5 5 Sample Output 50 14 1000000001 0
[ "a, c = list(map(int, input().split()))\r\nad = [0] * 20\r\nan = 0\r\ncd = [0] * 20\r\ncn = 0\r\n\r\nwhile a != 0:\r\n ad[an] = a % 3\r\n an += 1\r\n a //= 3\r\n\r\nwhile c != 0:\r\n cd[cn] = c % 3\r\n cn += 1\r\n c //= 3\r\n\r\ntor = 0\r\nfor i in range(max(an, cn) - 1, -1, -1):\r\n tor = tor * 3 + (cd[i] + 3 - ad[i]) % 3\r\n\r\nprint(tor)\r\n", "# Input two integers a and c\r\na, c = map(int, input().split())\r\n\r\n# Lists to store the ternary digits of a and c\r\nternary_digits_a = [0] * 20\r\nternary_digits_a_count = 0\r\nternary_digits_c = [0] * 20\r\nternary_digits_c_count = 0\r\n\r\n# Convert 'a' to ternary and store its digits\r\nwhile a != 0:\r\n ternary_digits_a[ternary_digits_a_count] = a % 3\r\n ternary_digits_a_count += 1\r\n a //= 3\r\n\r\n# Convert 'c' to ternary and store its digits\r\nwhile c != 0:\r\n ternary_digits_c[ternary_digits_c_count] = c % 3\r\n ternary_digits_c_count += 1\r\n c //= 3\r\n\r\n# Initialize the result variable 'tor'\r\nresult = 0\r\n\r\n# Calculate the result in base 3\r\nfor i in range(max(ternary_digits_a_count, ternary_digits_c_count) - 1, -1, -1):\r\n result = result * 3 + (ternary_digits_c[i] + 3 - ternary_digits_a[i]) % 3\r\n\r\n# Output the result\r\nprint(result)\r\n", "a, c = map(int, input().split())\r\nb, i = 0, 1\r\nwhile a > 0 or c > 0:\r\n b += i * (((c % 3) - (a % 3)) % 3)\r\n i *= 3\r\n a //= 3\r\n c //= 3\r\nprint(b)", "a, c = map(int, input().split())\r\nli = [0] * 20\r\nli2 = [0] * 20\r\nd = 0\r\n\r\ndef ternary(num, array):\r\n global d\r\n while num != 0:\r\n j = 0\r\n while 3 ** j <= num:\r\n j += 1\r\n num -= 3 ** (j - 1)\r\n array[j - 1] += 1\r\n if num < 3 and num > 0:\r\n array[0] = num\r\n num = 0\r\n d = max(d, j - 1)\r\n\r\nternary(a, li)\r\nternary(c, li2)\r\n\r\nli = li[:d+1]\r\nli2 = li2[:d+1]\r\n\r\nans = []\r\nfor i in range(d, -1, -1):\r\n ans.append((li2[i] - li[i]) % 3)\r\n\r\nres = 0\r\nfor i in range(d+1):\r\n res += ans[i] * 3 ** (d - i)\r\nprint(res)", "a,c=map(int,input().split())\nb=0\ni=0\nwhile a+c>0:\n b+=(3+c-a)%3*3**i\n a=a//3\n c=c//3\n i+=1\nprint(b)" ]
{"inputs": ["14 34", "50 34", "387420489 225159023", "5 5", "23476 23875625", "11111 10101010", "1 23865354", "0 0", "2376234 0", "1 0", "581130733 0", "581131733 1", "0 1000000000", "1000000000 0", "1000000000 100000000", "956747697 9487", "229485033 8860", "5341 813849430", "227927516 956217829", "390 380875228", "336391083 911759145", "154618752 504073566", "6436017 645491133", "4232 755480607", "19079106 69880743", "460318555 440850074", "227651149 379776728", "621847819 8794", "827112516 566664600", "460311350 820538776", "276659168 241268656", "9925 9952", "830218526 438129941", "630005197 848951646", "123256190 174927955", "937475611 769913258", "561666539 29904379", "551731805 8515539", "6560 96330685", "337894292 55", "479225038 396637601", "111174087 482024380", "785233275 1523", "47229813 6200", "264662333 6952", "523162963 922976263", "6347 7416", "278014879 3453211", "991084922 66", "929361351 7373", "532643581 213098335", "69272798 718909239", "440760623 316634331", "9001 9662", "417584836 896784933", "640735701 335933492", "5440 6647", "3545 6259", "847932562 1405", "359103580 852", "406369748 625641695", "345157805 719310676", "9150 823789822", "8727 702561605", "931392186 677650263", "976954722 548418041", "168971531 697371009", "5849 7211", "934045591 4156", "427471963 436868749", "702754885 762686553", "897312963 177161062", "268520356 1999", "635318406 289972012", "237819544 904440360", "44788825 4485", "7376 994270908", "893244884 654169485", "960725158 342144655", "460645829 46697832", "8389 172682371", "294567098 631452590", "5573 8790", "285938679 907528096", "774578699 101087409", "153749013 598457896", "364059865 346004232", "237924125 573400957", "987310001 827978268", "922263603 387506683", "5712 384487208", "9099 3208", "948688087 38251290", "260153932 138945442", "497129325 766959165", "783390583 7679", "657244587 28654748", "455705795 757666961", "815932189 211656771", "511307975 307916669", "274842194 1000000000"], "outputs": ["50", "14", "1000000001", "0", "23860906", "10116146", "23865356", "0", "4732515", "2", "1162261466", "1162260467", "1000000000", "693711461", "650219958", "736688812", "308580772", "813850920", "872370713", "380874919", "1135529718", "753527130", "639142839", "755485882", "56293527", "25179124", "168088492", "1114556841", "908742057", "404875070", "358409486", "27", "784719357", "754665575", "243699845", "994719535", "1152454076", "1049769112", "96330968", "243175169", "47143216", "430083082", "393767834", "89081162", "141903557", "414184806", "10549", "171855414", "690049933", "679915097", "842718489", "668771236", "1052493562", "1390", "481392203", "992169746", "10711", "3536", "488901051", "201115550", "221459919", "504894191", "823781437", "702556127", "923604336", "862925051", "588009082", "10146", "661009836", "67345761", "81198815", "620860447", "135088146", "950864476", "857959352", "89397617", "994283218", "1095395095", "548529624", "792961330", "172696203", "745235571", "13021", "1068058915", "940495066", "444892699", "40934348", "507664538", "275919178", "1064907553", "384482225", "14035", "768385433", "271056231", "276817557", "399664540", "921153434", "303798597", "562850021", "1137612240", "1162261466"]}
UNKNOWN
PYTHON3
CODEFORCES
5
e0332eac78721837186baef3409b2d7d
Vile Grasshoppers
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. The only line contains two integers *p* and *y* (2<=≤<=*p*<=≤<=*y*<=≤<=109). Output the number of the highest suitable branch. If there are none, print -1 instead. Sample Input 3 6 3 4 Sample Output 5 -1
[ "\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)", "import math \r\ndef printDivisors(n):\r\n i = 1\r\n minp = 1000000001\r\n while i <= math.sqrt(n): \r\n if (n % i == 0):\r\n if (n / i == i) : \r\n if i > 1:\r\n minp = min(minp, i)\r\n else:\r\n if i > 1 and n/i > 1:\r\n minp = min(minp, i, n/i)\r\n i = i + 1\r\n return minp\r\n\r\np, y = map(int, input().strip().split())\r\nn = y + 0\r\nsolved = False\r\nwhile n > p:\r\n i = 1\r\n minp = 1000000001\r\n while i <= math.sqrt(n):\r\n if (n % i == 0):\r\n if (n / i == i):\r\n if i > 1:\r\n minp = min(minp, i)\r\n else:\r\n if i > 1 and n/i > 1:\r\n minp = min(minp, i, n/i)\r\n i = i + 1\r\n if minp > p:\r\n print(n)\r\n solved = True\r\n break\r\n n -= 1\r\n\r\nif not solved:\r\n print(-1)", "l, r = map(int, input().split())\r\n\r\nx = r\r\n\r\nwhile x > l:\r\n d = 2\r\n while d <= l and d * d <= x:\r\n if x % d == 0:\r\n break\r\n d += 1\r\n else:\r\n print(x)\r\n break\r\n x -= 1\r\nelse:\r\n print(-1)\r\n", "n,h = map(int,input().split())\r\nfor i in range(h,n,-1):\r\n if all(i%j for j in range(2,min(int(i**.5),n)+1)):print(i);exit()\r\nprint(-1)", "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 ", "p, n = (int(x) for x in input().split())\r\nflag = False\r\nfor i in range(n, p, -1):\r\n flag = True\r\n # print(i)\r\n for j in range(2, min(int(n ** 0.5), p) + 1):\r\n if i % j == 0:\r\n flag = False\r\n break\r\n if flag:\r\n print(i)\r\n break\r\nif not flag:\r\n print(-1)\r\n\r\n", "def mindiv(i,p):\r\n cnt=p+1\r\n j=2\r\n while(j*j<=i):\r\n if(i%j!=0):\r\n j=j+1\r\n continue\r\n else:\r\n cnt=min(cnt,j)\r\n cnt=min(cnt,i//j)\r\n j=j+1\r\n return cnt \r\np,y=[int(p) for p in input().split()]\r\nfor i in range(y,p,-1):\r\n if(mindiv(i,p)<=p):\r\n continue\r\n else:\r\n print(i)\r\n exit()\r\nprint(-1) ", "p,y=map(int,(input().split(' ')))\r\n\r\ndef vileGrasshoppers(y,p):\r\n for i in range(y,p,-1):\r\n c=1\r\n for j in range(2,int(i**0.5)+1):\r\n if i%j==0 and j<=p:\r\n c=0\r\n break\r\n if c:\r\n return i\r\n return -1\r\n\r\nprint(vileGrasshoppers(y,p))\r\n\r\n#http://codeforces.com/contest/937/problem/B", "from sys import stdin\r\n\r\ndef firstDiv(n) : \r\n # Corner cases \r\n if (n <= 1) : \r\n return False\r\n if (n <= 3) : \r\n return 2\r\n # This is checked so that we can skip \r\n # middle five numbers in below loop \r\n if n % 2 == 0:\r\n return 2\r\n elif n % 3 == 0: \r\n return 3\r\n \r\n i = 5\r\n while(i * i <= n) : \r\n if n % i == 0:\r\n return i\r\n elif n % (i + 2) == 0: \r\n return i + 2\r\n i = i + 6\r\n \r\n return 10e9 + 1\r\n \r\n# print all prime numbers \r\n# less than equal to N \r\ndef sol(n, p): \r\n for i in range(n, p, -1): \r\n f = firstDiv(i)\r\n #print(i, f)\r\n if f > p:\r\n print(i)\r\n return\r\n print(-1)\r\n \r\n\r\np, y = list(map(int, stdin.readline().rstrip().split(\" \")))\r\nsol(y, p)\r\n\r\n\r\n", "lack,ok=map(int,input().split())\nkj=ok\nwhile kj>lack:\n d=2\n while d<=lack and d*d<=kj:\n if 0==kj%d:\n break\n d+=1\n else:\n print(kj)\n break\n kj-=1\nelse:\n print (-1)\n \t\t\t\t\t\t \t\t \t \t\t \t \t \t\t \t", "import 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\np, y = map(int, input().split())\r\nans = -1\r\nfor x in range(y, p, -1):\r\n d = divisor(x)\r\n f = 0\r\n for i in d:\r\n if 2 <= i <= p:\r\n f = 1\r\n break\r\n if not f:\r\n ans = x\r\n break\r\nprint(ans)", "def is_prime(n):\n i = 2\n if n == 1:\n return True\n while i**2 <= n:\n if n%i == 0:\n return False\n i += 1\n return True\n\np,y = map(int, input().split())\nfor i in range(1, y+1)[::-1]:\n if is_prime(i):\n break\n\nfor z in range(max(i, p+1), y+1)[::-1]:\n flag = True\n for j in range(2,p+1):\n if z % j == 0:\n flag = False\n break\n if j**2 >= z+1:\n break\n if flag:\n print(z)\n quit()\nprint(-1)", "p,y = map(int, input().split())\nfor b in range(y - int(y % 2 == 0), p, -2):\n for i in range(3, min(int(b ** 0.5) + 1, p + 1), 2):\n if b % i == 0:\n break\n else:\n print(b)\n break\nelse:\n print(-1)", "import math\r\np,y = list(map(int,input().split()))\r\n\r\nfor i in range(y,p,-1):\r\n test = True\r\n for j in range(2, min(p,int(math.sqrt(i)))+1):\r\n if i%j == 0:\r\n test = False\r\n break\r\n if test:\r\n print(i)\r\n exit(0)\r\nprint(-1)", "import sys\r\ndef fun(n,p,y):\r\n i=2\r\n while i<=p and i**2<=y:\r\n if n%i==0:\r\n return False\r\n i+=1\r\n \r\n return True\r\n \r\n \r\np,y=map(int,input().split())\r\nans=-1\r\nfor i in range(y,p,-1):\r\n if fun(i,p,y):\r\n print(i)\r\n sys.exit()\r\nprint(-1)\r\n", "from sys import exit\r\np,y=[int(e) for e in input().split()]\r\ndef d(x):\r\n i=2\r\n while i*i<=x:\r\n if x%i==0:\r\n return i\r\n i+=1\r\n return x\r\nwhile d(y)<=p:\r\n y-=1\r\n if y<=p:\r\n print(-1)\r\n exit()\r\nprint(y)", "lock,ok=map(int,input().split())\nkj=ok\nwhile kj>lock:\n d=2\n while d<=lock and d*d<=kj:\n if 0==kj%d:\n break\n d+=1\n else:\n print(kj)\n break\n kj-=1\nelse:\n print (-1)\n \t\t \t \t \t\t\t \t \t\t\t \t\t \t\t\t \t", "p, y = map(int, input().split())\r\nfor x in range(y, p, -1):\r\n if all(x % i for i in range(2, min(int(x ** .5), p) + 1)):\r\n print(x)\r\n exit()\r\nprint(-1)", "p, y = map(int, input().split())\r\nfor number in range(y, p, -1):\r\n for i in range(2, min(int(number ** 0.5) + 2, p + 1)):\r\n if number % i == 0:\r\n break\r\n else:\r\n print(number)\r\n break\r\nelse:\r\n print(-1)", "def pr(l,n):\r\n for i in range(2,int(l)+1):\r\n if n%i==0:\r\n return False\r\n return True\r\np,y=map(int,input().split())\r\nx=0\r\nfor i in range(y,p,-1):\r\n if pr(min(p,i**0.5),i):\r\n x=i\r\n break\r\nif x:\r\n print(x)\r\nelse:\r\n print(-1)", "def minf(n):\r\n i = 2\r\n while i ** 2 <= n:\r\n if n % i == 0:\r\n return i\r\n i += 1\r\n return n\r\np, y = map(int, input().split())\r\nfor i in range(y, p, -1):\r\n if minf(i) > p:\r\n print(i)\r\n exit()\r\nprint(-1)", "from math import sqrt, ceil\n\ndef isPrime(x):\n if x < 2:\n return False\n if x < 4:\n return True\n if x % 2 == 0:\n return False\n for i in range(3, ceil(sqrt(x)) + 1, 2):\n if x % i == 0:\n return False\n return True\n\ndef doesntDivide(x):\n if p > sqrt(y):\n return False\n if x % 2 == 0:\n return False\n for i in range(3, p + 1, 2):\n if x % i == 0:\n return False\n return True\n\np, y = map(int, input().split())\n\nfor i in range(y, max(p, y - 1000), -1):\n if isPrime(i) or doesntDivide(i):\n print(i)\n break\nelse:\n print(-1)", "p, y = list(map(int,input().split()))\r\nx = -1\r\nfor i in range(y, p, -1):\r\n er = 0\r\n for j in range(2, int(i ** 0.5) + 1):\r\n if i % j == 0 and j <= p:\r\n er = 1\r\n break\r\n if er == 0:\r\n x = i\r\n break\r\nprint(x)", "import sys, math\r\ninput = lambda: sys.stdin.readline()[:-1]\r\nmass = lambda: list(map(int, input().split()))\r\n\r\n\r\ndef solve():\r\n p, y = mass()\r\n while p < y:\r\n for i in range(2, min(p, int(y ** 0.5)) + 1):\r\n if y % i == 0 and i <= p:\r\n break\r\n else:\r\n print(y)\r\n return\r\n y -= 1\r\n print(-1)\r\n\r\n\r\n#for _ in range(int(input())):\r\nsolve()", "p,y=map(int,input().split())\r\nh=y\r\nwhile h>p:\r\n d=2\r\n while d<=p and d*d<=h:\r\n if 0==h%d:\r\n break\r\n d+=1\r\n else:\r\n print(h)\r\n break\r\n h-=1\r\nelse:\r\n print (-1)", "p,y=map(int,input().split())\r\nf=-1\r\nwhile(y>p):\r\n\tvalid=1\r\n\ti=2\r\n\twhile(i*i<=y and i<=p):\r\n\t\tif(y%i==0):\r\n\t\t\tvalid=0\r\n\t\t\tbreak\r\n\t\ti+=1\r\n\t\r\n\tif(valid):\r\n\t\tf=y\r\n\t\tbreak\r\n\ty-=1\r\nprint(f)", "q, y = map (int, input ().split ())\r\nfor i in range (y, q, -1) :\r\n p = 2; flag = False\r\n while p * p <= i :\r\n if i % p == 0 :\r\n if p > q : print (i); exit (0)\r\n else : flag = True; break\r\n p += 1\r\n if flag == False : print (i); exit (0)\r\nprint (-1)\r\n", "import math\r\ndef printDivisors(n):\r\n i = 2\r\n s = set()\r\n while i <= math.sqrt(n):\r\n if (n % i == 0):\r\n if (n // i == i):\r\n s.add(i)\r\n\r\n else:\r\n s.add(i)\r\n s.add(n//i)\r\n\r\n i = i + 1\r\n\r\n return s\r\n\r\np,y = map(int,input().split())\r\nm = -1\r\nj = y\r\nwhile(j > p):\r\n e = printDivisors(j)\r\n f = 0\r\n for i in e:\r\n if i <= p:\r\n f = 1\r\n break\r\n\r\n if f == 0:\r\n m = j\r\n break\r\n\r\n j = j-1\r\n\r\nprint(m)\r\n", "p, y = map(int, input().split())\r\n\r\ndef ch(n):\r\n i = 2\r\n while i <= p and i*i <= y:\r\n if not(n%i):\r\n return False\r\n i += 1\r\n return True\r\n\r\nfor i in range(y, p, -1):\r\n if ch(i):\r\n print(i)\r\n break\r\nelse:\r\n print(\"-1\")\r\n", "\n\np,y = map(int, input().split())\n\n\n\nfor x in range(y, p, -1):\n\n if all(x%i for i in range(2,min(p, int(x**0.5))+1)):\n\n print(x)\n\n exit()\n\n\n\nprint (-1)\n\n\n\n# Made By Mostafa_Khaled", "def mlt(): return map(int, input().split())\r\n\r\n\r\nx, y = mlt()\r\n\r\n\r\ndef mn(x):\r\n n = 2\r\n if x % 2 == 0:\r\n return 2\r\n\r\n n = 3\r\n while n*n <= x:\r\n if x % n == 0:\r\n return n\r\n n += 2\r\n\r\n return x\r\n\r\n\r\nwhile y > x:\r\n if mn(y) > x:\r\n print(y)\r\n exit(0)\r\n y -= 1\r\n\r\nprint(-1)\r\n", "import math\r\nfrom sys import stdin\r\nstring=stdin.readline().strip().split()\r\np=int(string[0])\r\ny=int(string[1])\r\ndef findmf(number):\r\n factor=number\r\n for i in range(2,math.floor(math.sqrt(number))+1):\r\n \r\n if number%i==0:\r\n factor=i\r\n \r\n break\r\n return factor\r\nwhile True:\r\n if p<findmf(y):\r\n \r\n break\r\n elif y>p:\r\n \r\n y-=1\r\n else:\r\n y=-1\r\n \r\n break\r\nprint(y)\r\n", "p, y = map(int, input().split())\n\ndef div(n):\n\tfor i in range(2, int(n ** (1 / 2)) + 1):\n\t\tif n % i == 0:\n\t\t\treturn i\n\treturn n\n\nwhile y > p:\n\tif div(y) > p:\n\t\tprint(y)\n\t\tbreak\n\ty -= 1\n\nif y <= p:\n\tprint(-1)", "p,y = map(int,input().split())\r\nfor x in range(y,p,-1):\r\n if all(x%i for i in range(2,min(p,int(x**.5))+1)):\r\n print(x)\r\n exit()\r\nprint(-1)", "import math,sys\r\nfrom collections import Counter, defaultdict\r\nfrom sys import stdin, stdout\r\n#input = stdin.readline\r\nlili=lambda:list(map(int,sys.stdin.readlines()))\r\nli = lambda:list(map(int,input().split()))\r\n\r\ndef checkprime(a):\r\n for i in range(2, int(a**0.5)+1):\r\n if a%i == 0 and i <= z[0]:\r\n return False\r\n return True\r\nz = li()\r\nfor i in range(z[1], z[0], -1):\r\n if checkprime(i):\r\n print(i)\r\n exit()\r\nprint(-1)", "from math import ceil, sqrt\r\n\r\ndef main():\r\n\r\n def is_simple(x):\r\n for i in range(2,ceil(sqrt(x))+1):\r\n if x % i == 0:\r\n return False\r\n else:\r\n return True\r\n\r\n \r\n p, y = map(int, input().split())\r\n f = False\r\n \r\n for i in range(y, p, -1):\r\n if is_simple(i):\r\n print(i)\r\n f = True\r\n break\r\n for j in range(2, p+1):\r\n if i % j == 0:\r\n break\r\n else:\r\n print(i)\r\n f = True\r\n break\r\n \r\n if not f:\r\n print(-1)\r\n \r\nif __name__ == '__main__':\r\n main()", "p, y = map(int, input().split())\r\n\r\nans = -1\r\n\r\nfor j in range(y, p, -1):\r\n i = 2\r\n d = j\r\n while i * i <= j:\r\n if j % i == 0:\r\n d = i\r\n break\r\n i += 1\r\n\r\n if d > p:\r\n ans = j\r\n break\r\n\r\nprint(ans) \r\n \r\n \r\n\r\n\r\n", "\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)", "p,y = map(int,input().split())\r\nans = -1\r\nwhile y>p:\r\n\tflag,i=1,2\r\n\twhile i<=p and i**2<=y:\r\n\t\tif y%i==0:\r\n\t\t\tflag=0\r\n\t\t\tbreak\r\n\t\ti+=1\r\n\tif flag:\r\n\t\tans=y\r\n\t\tbreak\r\n\ty-=1\r\nprint(ans)", "import math \r\ndef div(n) : \r\n a=[]\r\n i = 1\r\n while i <= math.sqrt(n): \r\n if (n % i == 0) : \r\n if (n / i == i) : \r\n a.append(i)\r\n else : \r\n a.append(i)\r\n a.append(n//i)\r\n i = i + 1\r\n a.sort()\r\n a.pop(0)\r\n return a\r\nimport sys,math \r\np,y=map(int,sys.stdin.readline().split())\r\nif p==y:\r\n print(-1)\r\nelse:\r\n i=y\r\n flag=True\r\n while(True):\r\n a=div(i)\r\n if a[0]>p:\r\n print(i)\r\n flag=False\r\n break \r\n else:\r\n i-=1\r\n if i==p:\r\n break\r\n if flag:\r\n print(-1)\r\n \r\n \r\n \r\n \r\n", "def fuc(a,p):\r\n for i in range(2,int(a**0.5)+1):\r\n if(a%i==0):\r\n if(i>p):\r\n return True\r\n else:\r\n return False\r\n return True\r\n\r\np,y = map(int,input().split())\r\nans = -1\r\nwhile(y>p):\r\n if(fuc(y,p)):\r\n ans = y\r\n break\r\n y-=1\r\nprint(ans)\r\n\r\n" ]
{"inputs": ["3 6", "3 4", "2 2", "5 50", "944192806 944193066", "1000000000 1000000000", "2 1000000000", "28788 944193066", "49 52", "698964997 734575900", "287894773 723316271", "171837140 733094070", "37839169 350746807", "125764821 234689174", "413598841 430509920", "145320418 592508508", "155098216 476450875", "459843315 950327842", "469621113 834270209", "13179877 557546766", "541748242 723508350", "607450717 924641194", "786360384 934418993", "649229491 965270051", "144179719 953974590", "28122086 963752388", "268497487 501999053", "356423140 385941420", "71233638 269883787", "2601 698964997", "4096 287894773", "5675 171837140", "13067 350746807", "8699 234689174", "12190 413598841", "20555 592508508", "19137 476450875", "8793 950327842", "1541 834270209", "1082 13179877", "3888 723508350", "14078 607450717", "20869 786360384", "13689 965270051", "782 144179719", "404 28122086", "21992 501999053", "13745 385941420", "8711 269883787", "31333 981756889", "944192808 944193061", "3 9", "4 5", "2 13", "7 53", "10 1000000000", "2 7", "4 9"], "outputs": ["5", "-1", "-1", "49", "944192807", "-1", "999999999", "944192833", "-1", "734575871", "723316207", "733094069", "350746727", "234689137", "430509917", "592508479", "476450861", "950327831", "834270209", "557546753", "723508301", "924641189", "934418981", "965270051", "953974583", "963752347", "501999053", "385941419", "269883787", "698964983", "287894771", "171837131", "350746727", "234689137", "413598817", "592508479", "476450861", "950327831", "834270209", "13179871", "723508301", "607450703", "786360373", "965270051", "144179719", "28122079", "501999053", "385941419", "269883787", "981756871", "-1", "7", "5", "13", "53", "999999997", "7", "7"]}
UNKNOWN
PYTHON3
CODEFORCES
41
e047d6f8c864250517f98173e0289925
Prairie Partition
It can be shown that any positive integer *x* can be uniquely represented as *x*<==<=1<=+<=2<=+<=4<=+<=...<=+<=2*k*<=-<=1<=+<=*r*, where *k* and *r* are integers, *k*<=≥<=0, 0<=&lt;<=*r*<=≤<=2*k*. Let's call that representation prairie partition of *x*. For example, the prairie partitions of 12, 17, 7 and 1 are: 17<==<=1<=+<=2<=+<=4<=+<=8<=+<=2, 7<==<=1<=+<=2<=+<=4, 1<==<=1. Alice took a sequence of positive integers (possibly with repeating elements), replaced every element with the sequence of summands in its prairie partition, arranged the resulting numbers in non-decreasing order and gave them to Borys. Now Borys wonders how many elements Alice's original sequence could contain. Find all possible options! The first line contains a single integer *n* (1<=≤<=*n*<=≤<=105) — the number of numbers given from Alice to Borys. The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1012; *a*1<=≤<=*a*2<=≤<=...<=≤<=*a**n*) — the numbers given from Alice to Borys. Output, in increasing order, all possible values of *m* such that there exists a sequence of positive integers of length *m* such that if you replace every element with the summands in its prairie partition and arrange the resulting numbers in non-decreasing order, you will get the sequence given in the input. If there are no such values of *m*, output a single integer -1. Sample Input 8 1 1 2 2 3 4 5 8 6 1 1 1 2 2 2 5 1 2 4 4 4 Sample Output 2 2 3 -1
[ "from collections import Counter\r\nn = int(input())\r\na = list(map(int, input().split()))\r\n\r\ndef get(cnt):\r\n c = Counter(a)\r\n last = []\r\n while c[1] and (cnt is None or len(last) < cnt):\r\n x = 1\r\n while c[x]:\r\n c[x] -= 1\r\n x *= 2\r\n last.append(x >> 1)\r\n rem = sorted(c.elements())\r\n i = 0\r\n for x in last[::-1]:\r\n if i < len(rem) and rem[i] < 2 * x:\r\n i += 1\r\n return len(last) if i == len(rem) else 0\r\n\r\nmx = get(None)\r\nlo, hi = 0, mx\r\nwhile lo < hi:\r\n mid = (lo + hi) >> 1\r\n if get(mid):\r\n hi = mid\r\n else:\r\n lo = mid + 1\r\nif mx:\r\n print(*range(lo, mx + 1))\r\nelse:\r\n print(-1)\r\n", "n = int(input())\na = sorted(list(map(int, input().split())))\n\nmaxe = max(a)\ncnt = []\ncur = 1\nk = 0\ni = 0\nwhile i < n:\n cnt.append(0)\n while i < n and a[i] < cur:\n cnt[2 * k] += 1\n i += 1\n cnt.append(0)\n while i < n and a[i] == cur:\n cnt[2 * k + 1] += 1\n i += 1\n k += 1\n cur *= 2\ncnt.append(0)\ncnt.append(0)\nmaxe = len(cnt) - 1\n\nmaxk = cnt[1]\nwas = False\nfor l in range(maxk):\n cur = 1\n while cnt[cur] > 0:\n cnt[cur] -= 1\n cur += 2\n cnt[cur] -= 1\n cursum = 0\n ok = True\n for t in range(maxe, 0, -1):\n cursum += cnt[t]\n if cursum > 0:\n ok = False\n break\n if ok:\n print(l + 1, end=\" \")\n was = True\n\nif not was:\n print(-1)\n \t \t \t \t \t\t\t\t\t\t \t\t\t \t \t\t", "n = int(input())\r\na = sorted(list(map(int, input().split())))\r\n\r\nmaxe = max(a)\r\ncnt = []\r\ncur = 1\r\nk = 0\r\ni = 0\r\nwhile i < n:\r\n cnt.append(0)\r\n while i < n and a[i] < cur:\r\n cnt[2 * k] += 1\r\n i += 1\r\n cnt.append(0)\r\n while i < n and a[i] == cur:\r\n cnt[2 * k + 1] += 1\r\n i += 1\r\n k += 1\r\n cur *= 2\r\ncnt.append(0)\r\ncnt.append(0)\r\nmaxe = len(cnt) - 1\r\n\r\nmaxk = cnt[1]\r\nwas = False\r\nfor l in range(maxk):\r\n cur = 1\r\n while cnt[cur] > 0:\r\n cnt[cur] -= 1\r\n cur += 2\r\n cnt[cur - 1] -= 1\r\n cursum = 0\r\n ok = True\r\n for t in range(maxe, 0, -1):\r\n cursum += cnt[t]\r\n if cursum > 0:\r\n ok = False\r\n break\r\n if ok:\r\n print(l + 1, end=\" \")\r\n was = True\r\n\r\nif not was:\r\n print(-1)", "def ctz(x):\n\treturn 0 if x&1 else ctz(x>>1)+1\n\ndef clz(x):\n\treturn len(bin(x))-3\n\ndef ok(a, b):\n\tp=0\n\tfor i in range(40, -1, -1):\n\t\tp+=a[i]-a[i+1]-b[i]\n\t\tif p<0:\n\t\t\treturn False\n\treturn True\n\na=[0]*50\nb=a[:]\nc=[]\ninput()\n\nfor x in map(int, input().split()):\n\tif x==(x&-x):\n\t\ta[ctz(x)]+=1\n\telse:\n\t\tb[clz(x)]+=1\n\nwhile a[0]>0:\n\tfor i in range(40):\n\t\tif a[i]<a[i+1]:\n\t\t\tb[i+1]+=a[i+1]-a[i]\n\t\t\ta[i+1]=a[i]\n\tif not ok(a, b):\n\t\tbreak\n\tc+=[a[0]]\n\ta[0]-=1\n\tb[0]+=1\n\nif c==[]:\n\tprint(-1)\nelse:\n\tprint(*reversed(c))\n" ]
{"inputs": ["8\n1 1 2 2 3 4 5 8", "6\n1 1 1 2 2 2", "5\n1 2 4 4 4", "20\n1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 8 8 10 10 11", "20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2", "25\n1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 8 13 15 16 16 31 32 36 41 55", "25\n1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 9 16 16 32 40 43 53 61 64 128", "45\n1 1 1 1 1 2 2 2 2 2 2 2 4 4 4 4 4 4 8 8 8 8 8 8 16 16 16 16 16 32 32 32 32 32 41 64 64 64 64 128 128 128 256 256 512", "100\n1 1 1 1 1 1 1 2 2 2 2 2 2 2 4 4 4 4 4 4 4 6 8 8 8 8 8 8 8 10 16 16 16 16 16 16 16 17 22 24 24 30 32 32 32 32 32 32 48 62 64 64 65 65 67 70 74 88 89 98 99 101 101 109 121 127 128 128 137 143 152 153 155 156 160 161 170 183 186 196 196 214 220 226 228 230 238 240 241 245 249 249 250 253 254 256 256 512 1024 1703", "101\n1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 7 8 8 8 8 8 8 8 8 8 8 8 16 16 16 16 16 16 16 16 16 16 16 32 32 32 32 32 32 32 32 32 32 64 64 64 64 64 64 64 64 64 128 128 128 128 128 128 128 128 239 256 256 256 256 256 373 512 512 512 512 695 1024 1024 1024", "101\n1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 5 8 8 8 8 8 8 8 8 8 8 8 8 16 16 16 16 16 16 16 16 16 16 16 16 26 32 32 32 32 32 32 32 32 49 58 64 64 64 64 64 64 122 128 128 128 128 128 128 256 256 256 256 256 491 512 512 512 512 718 1024 1024 1024 2935 3123", "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 6 6 6 8 8 8 8 8 8 8 8 11 13 14", "1\n1", "2\n1 2", "2\n1 1", "1\n2", "1\n1000000000000", "2\n1 1000000000000", "40\n1 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", "41\n1 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 1000000000000", "41\n1 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", "96\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 8 8 8 8 8 8 8 8 8 8 8 9 12 12 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 18 21"], "outputs": ["2 ", "2 3 ", "-1", "4 ", "9 10 11 12 13 14 15 16 17 ", "-1", "-1", "5 ", "-1", "11 12 ", "-1", "27 28 29 30 31 32 33 34 35 36 37 38 ", "1 ", "1 ", "1 2 ", "-1", "-1", "-1", "1 ", "1 ", "1 2 ", "-1"]}
UNKNOWN
PYTHON3
CODEFORCES
4
e06260a867da74744d2211c1c54a8ad6
Barcode
You've got an *n*<=×<=*m* pixel picture. Each pixel can be white or black. Your task is to change the colors of as few pixels as possible to obtain a barcode picture. A picture is a barcode if the following conditions are fulfilled: - All pixels in each column are of the same color. - The width of each monochrome vertical line is at least *x* and at most *y* pixels. In other words, if we group all neighbouring columns of the pixels with equal color, the size of each group can not be less than *x* or greater than *y*. The first line contains four space-separated integers *n*, *m*, *x* and *y* (1<=≤<=*n*,<=*m*,<=*x*,<=*y*<=≤<=1000; *x*<=≤<=*y*). Then follow *n* lines, describing the original image. Each of these lines contains exactly *m* characters. Character "." represents a white pixel and "#" represents a black pixel. The picture description doesn't have any other characters besides "." and "#". In the first line print the minimum number of pixels to repaint. It is guaranteed that the answer exists. Sample Input 6 5 1 2 ##.#. .###. ###.. #...# .##.# ###.. 2 5 1 1 ##### ..... Sample Output 11 5
[ "inf = 9999999999\r\n\r\ndef f(ll,n,m,x,y):\r\n W = [0]*m #White\r\n for i in range(n):\r\n for j in range(m):\r\n if ll[i][j]=='.':\r\n W[j] += 1\r\n B = [n-c for c in W] #Black\r\n Bw = [inf]*(y+1)\r\n Ww = [inf]*(y+1)\r\n Bw[1] = B[0]\r\n Ww[1] = W[0]\r\n Bv = B[0] if x==1 else inf\r\n Wv = W[0] if x==1 else inf\r\n for i in range(1,m):\r\n for j in range(y,0,-1):\r\n Bw[j] = Bw[j-1]+B[i]\r\n Ww[j] = Ww[j-1]+W[i]\r\n if Bv < inf: #if valid!\r\n Ww[1] = Bv + W[i]\r\n Bw[1] = Wv + B[i]\r\n Bv = min(Bw[x:y+1])\r\n Wv = min(Ww[x:y+1])\r\n return min(Bv,Wv)\r\n\r\nn,m,x,y = list(map(int,input().split()))\r\nll = [input() for _ in range(n)]\r\nprint(f(ll,n,m,x,y))\r\n\r\n", "import sys\r\nn,m,x,y=list(map(int,input().split()))\r\nlis1=[0]*m\r\nlis2=[0]*m\r\nfor i in range(n):\r\n s=str(input())\r\n for j in range(m):\r\n if s[j]==\"#\":\r\n lis1[j]+=1\r\n else:\r\n lis2[j]+=1\r\nnum1=[0]\r\nnum2=[0]\r\nfor i in range(m):\r\n num1.append(num1[-1]+lis1[i])\r\n num2.append(num2[-1]+lis2[i])\r\ndp=[[0]*(m+1) for i in range(2)]\r\nfor i in range(1,m+1):\r\n ans1=sys.maxsize\r\n ans2=sys.maxsize\r\n for j in range(x,y+1):\r\n if i-j>=0:\r\n temp1=dp[1][i-j]+num1[i]-num1[i-j]\r\n temp2=dp[0][i-j]+num2[i]-num2[i-j]\r\n ans1=min(ans1,temp1)\r\n ans2=min(ans2,temp2)\r\n dp[0][i]=ans1\r\n dp[1][i]=ans2\r\nprint(min(dp[0][m],dp[1][m]))\r\n\r\n\r\n \r\n\r\n", "from math import inf\nn,m,x,y = map(int, input().split())\nA = []\nfor _ in range(n):\n A.append(input().strip())\n\nwhite_cost = []\nblack_cost = []\nfor i in range(m):\n white_cost.append(sum(1 if A[j][i] == \"#\" else 0 for j in range(n)))\n black_cost.append(n-white_cost[-1])\npre_white = [0]\npre_black = [0]\nfor i in range(m):\n pre_white.append(pre_white[-1] + white_cost[i])\n pre_black.append(pre_black[-1] + black_cost[i])\n\ncost = [white_cost, black_cost]\n\ndp = [[inf] * (m+1), [inf] * (m+1)]\ndp[0][0] = 0\ndp[1][0] = 0\n\nfor i in range(1,m+1):\n for j in range(x,y+1):\n if j > i:\n break\n dp[0][i] = min(dp[0][i], dp[1][i-j] + pre_black[i] - pre_black[i-j])\n for j in range(x,y+1):\n if j > i:\n break\n dp[1][i] = min(dp[1][i], dp[0][i-j] + pre_white[i] - pre_white[i-j])\n\n\nprint(min(dp[0][m],dp[1][m]))\n\n", "n,m,x,y=map(int,input().split())\r\na=[]\r\nfor i in range(n):\r\n a.append(list(input()))\r\n\r\ndp=[[-10000000,-10000000] for i in range(m+1)]\r\ndp[0]=[0,0]\r\ncost=[0 for i in range(m+1)]\r\nfor i in range(m):\r\n cost[i+1]=cost[i]\r\n for j in range(n):\r\n if a[j][i]==\".\":\r\n cost[i+1]+=1\r\n\r\nfor i in range(1,m+1):\r\n if i<x:\r\n dp[i][0]=-1\r\n dp[i][1]=-1\r\n continue\r\n for nxt in range(i-x,max(-1,i-y-1),-1):\r\n dp[i][0]=max(dp[i][0],dp[nxt][1]+cost[i]-cost[nxt])\r\n dp[i][1]=max(dp[i][1],dp[nxt][0]+(n*(i-nxt)-(cost[i]-cost[nxt])))\r\nprint(n*m-max(dp[m][0],dp[m][1]))", "from sys import stdin, stdout\r\n\r\n\r\n\r\n\r\ndef main():\r\n n, m, x, y = map(int, stdin.readline().split())\r\n \r\n b_pixels = [0]*(m+1)\r\n w_pixels = [0]*(m+1)\r\n \r\n for _ in range(n):\r\n l = stdin.readline().strip()\r\n for i in range(len(l)):\r\n if l[i] == \"#\":\r\n b_pixels[i+1] += 1\r\n else:\r\n w_pixels[i+1] += 1\r\n \r\n for i in range(1, m+1):\r\n b_pixels[i] += b_pixels[i-1]\r\n w_pixels[i] += w_pixels[i-1]\r\n \r\n dpw = [1e9] * (m+1)\r\n dpb = [1e9] * (m+1)\r\n # min pixels to paint given that ith one is white\r\n def w(k):\r\n if k < 0 :\r\n return 1e9\r\n if k == 0:\r\n return 0\r\n if dpw[k] != 1e9:\r\n return dpw[k]\r\n \r\n cost = 1e9\r\n for j in range(x, y+1):\r\n if k-j < 0:\r\n break\r\n paint_white_pixels = w_pixels[k] - w_pixels[k-j]\r\n paint_rest = b(k-j)\r\n cost = min(cost, paint_white_pixels + paint_rest)\r\n \r\n dpw[k] = cost\r\n return cost\r\n def b(k):\r\n if k < 0 :\r\n return 1e9\r\n if k == 0:\r\n return 0\r\n if dpb[k] != 1e9:\r\n return dpb[k]\r\n \r\n cost = 1e9\r\n for j in range(x, y+1):\r\n if k-j < 0:\r\n break\r\n paint_black_pixels = b_pixels[k] - b_pixels[k-j]\r\n paint_rest = w(k-j)\r\n cost = min(cost, paint_black_pixels + paint_rest)\r\n \r\n dpb[k] = cost\r\n return cost\r\n \r\n print(min(w(m), b(m)))\r\n \r\n \r\n \r\n \r\n \r\nmain()\r\n", "import sys\n\n\ndef DP(curPos, color, placing, x, y, grid):\n # since readGrid is represented by (white, black), color is rep.\n # by 0 and 1. if color is 0 (white), we need to turn the BLACK squares\n # white (grid[1], so we should lookup color^1.\n if curPos == 0:\n if x <= placing <= y:\n return grid[curPos][color ^ 1]\n else:\n return 10000000\n\n if (curPos, color, placing) in cache:\n return cache[curPos, color, placing]\n\n if placing < x:\n total = DP(curPos - 1, color, placing + 1, x, y, grid)\n elif placing == y:\n total = DP(curPos - 1, (color + 1) % 2, 1, x, y, grid)\n else:\n total = min(\n DP(curPos - 1, color, placing + 1, x, y, grid),\n DP(curPos - 1, (color + 1) % 2, 1, x, y, grid),\n )\n\n total += grid[curPos][color ^ 1]\n cache[curPos, color, placing] = total\n return total\n\n\ndef iterativeDP(m, x, y, grid):\n\n cache = [[[0 for _ in range(y + 1)] for _ in range(2)] for _ in range(m)]\n\n for j in range(2):\n for i in range(len(cache[0][0])):\n cache[0][j][i] = 1000000\n\n cache[0][0][1] = grid[0][\n 1\n ] # 0 for white, meaning \"1\" is all black squares that need to be turned white\n cache[0][1][1] = grid[0][0] # 1 for black\n\n for i in range(1, m):\n for k in range(1, y):\n cache[i][0][k + 1] = cache[i - 1][0][k] + grid[i][1]\n cache[i][1][k + 1] = cache[i - 1][1][k] + grid[i][0]\n cache[i][0][1] = min(cache[i - 1][1][x : y + 1]) + grid[i][1]\n cache[i][1][1] = min(cache[i - 1][0][x : y + 1]) + grid[i][0]\n\n return min(min(cache[m - 1][0][x : y + 1]), min(cache[m - 1][1][x : y + 1]))\n\n\ndef readGrid(grid):\n simpleGrid = []\n for i in range(len(grid[0])):\n colHash = 0\n colDot = 0\n for j in range(len(grid)):\n if grid[j][i] == \"#\":\n colHash += 1\n else:\n colDot += 1\n simpleGrid.append((colDot, colHash)) # representing (white, black)\n\n return simpleGrid\n\n\ndef solve(n, m, x, y, grid):\n intGrid = readGrid(grid)\n #ans = min(DP(m - 1, 0, 1, x, y, intGrid), DP(m - 1, 1, 1, x, y, intGrid))\n ans2 = iterativeDP(m, x, y, intGrid)\n return ans2\n\n\ndef readinput():\n n, m, x, y = map(int, sys.stdin.readline().rstrip().split(\" \"))\n grid = []\n for _ in range(n):\n line = [i for i in sys.stdin.readline().rstrip()]\n grid.append(line)\n print(solve(n, m, x, y, grid))\n\n\nreadinput()\n", "n,m,x,y=map(int,input().split())\r\nd={'#':0,'.':1}\r\nl=[[0,0] for i in range(m)]\r\nfor i in range(n):\r\n\ts=input()\r\n\tfor j in range(m):\r\n\t\tl[j][d[s[j]]]+=1\r\npb,pw=[0],[0]\r\nfor i in range(m):\r\n\tpb.append(pb[-1]+l[i][0])\r\n\tpw.append(pw[-1]+l[i][1])\r\ndp=[[float('inf')]*(m+1) for i in range(2)]\r\ndp[0][0]=dp[1][0]=0\r\nfor i in range(1,m+1):\r\n\tfor j in range(x,y+1):\r\n\t\tif i-j>=0:\r\n\t\t\tdp[0][i]=min(dp[0][i],dp[1][i-j]+pb[i]-pb[i-j])\r\n\t\t\tdp[1][i]=min(dp[1][i],dp[0][i-j]+pw[i]-pw[i-j])\r\nprint(min(dp[0][-1],dp[1][-1]))\r\n ", "import sys\r\nimport math as mt\r\nimport bisect\r\n#input=sys.stdin.buffer.readline \r\n#t=int(input())\r\nt=1\r\nfor __ in range(t):\r\n #n=int(input())\r\n n,m,x,y=map(int,input().split())\r\n #l=list(map(int,input().split()))\r\n l=[]\r\n\r\n for i in range(n):\r\n l.append(input())\r\n yhash=[0]*(m+1)\r\n ydot=[0]*(m+1)\r\n j1=1\r\n for j in range(m):\r\n cnt=0\r\n for i in range(n):\r\n if l[i][j]=='#':\r\n cnt+=1\r\n yhash[j1]=(cnt+yhash[j1-1])\r\n ydot[j1]=(n-cnt+ydot[j1-1])\r\n j1+=1\r\n dp=[[0 for i in range(m+1)]for j in range(2)]\r\n #dp[1][1]=1\r\n #print(dp)\r\n #print(yhash,ydot)\r\n for i in range(1,m+1):\r\n mini=10**6\r\n \r\n for j in range(x,y+1):\r\n if i-j>=0:\r\n # print(i,i-j)\r\n mini=min(dp[0][i-j]+yhash[i]-yhash[i-j],mini)\r\n dp[1][i]=mini\r\n \r\n mini=10**6\r\n for j in range(x,y+1):\r\n if i-j>=0:\r\n mini=min(dp[1][i-j]+ydot[i]-ydot[i-j],mini)\r\n dp[0][i]=mini\r\n #print(dp) \r\n print(min(dp[0][m],dp[1][m])) \r\n ", "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\nfrom collections import defaultdict\r\n\r\nN,M,X,Y = map(int, input().split())\r\nS = []\r\nfor _ in range(N):\r\n S.append(input())\r\n\r\nA = []\r\nfor i in range(M):\r\n cnt = defaultdict(int)\r\n for j in range(N):\r\n cnt[S[j][i]]+=1\r\n A.append((cnt['.'],cnt['#']))\r\n\r\nINF = float('inf')\r\ndp = [[INF,INF] for _ in range(Y+1)]\r\ndp[0][0] = dp[0][1] = 0\r\nfor i in range(M):\r\n ndp = [[INF,INF] for _ in range(Y+1)]\r\n for j in range(Y+1):\r\n if j<Y:\r\n ndp[j+1][0] = min(ndp[j+1][0], dp[j][0]+A[i][1])\r\n ndp[j+1][1] = min(ndp[j+1][1], dp[j][1]+A[i][0])\r\n \r\n if j>=X:\r\n ndp[1][1] = min(ndp[1][1], dp[j][0]+A[i][0])\r\n ndp[1][0] = min(ndp[1][0], dp[j][1]+A[i][1])\r\n dp = ndp\r\n\r\nans = INF\r\nfor i in range(X,Y+1):\r\n ans = min(ans, min(dp[i]))\r\nprint(ans)", "n , m , x , y=map(int,input().split())\r\nl=[]\r\ncnt =[]\r\nfor i in range(n):\r\n l1=input()\r\n l.append(l1)\r\nfor i in range(m):\r\n c=0\r\n for j in range(n):\r\n if l[j][i]=='.':\r\n c+=1 \r\n cnt.append(c)\r\npre =[0]\r\nfor i in range(m):\r\n pre.append(pre[-1]+cnt[i])\r\ndp=[[0]*(m+1) for j in range(m+1)]\r\nfor i in range(1,m+1):\r\n dp[0][i]=10**18\r\n dp[1][i]=10**18\r\n \r\n \r\n for j in range(x,y+1):\r\n if i>=j: \r\n dot=pre[i]-pre[i-j]\r\n has=n*j-dot \r\n dp[0][i]=min(dp[0][i],dp[1][i-j]+dot)\r\n dp[1][i]=min(dp[1][i],dp[0][i-j]+has)\r\nprint(min(dp[0][m],dp[1][m]))\r\n \r\n ", "# cook your dish here\r\nimport sys\r\nimport math\r\nimport random\r\nimport heapq\r\n#sys.setrecursionlimit(10**6)\r\ninput=sys.stdin.readline\r\ndef pow(a,n,m):\r\n if n==0:\r\n return 1 \r\n x=pow(a,n//2,m)\r\n if n%2==0 :\r\n return (x*x)%m \r\n else:\r\n return (x*x*a)%m\r\n \r\ndef gcd(a,b):\r\n while b!=0:\r\n a,b=b,a%b\r\n return a \r\n \r\ndef bs(arr,le,ri):\r\n l=0\r\n arr.sort()\r\n r=len(arr)-1\r\n ans=10000000\r\n while l<=r:\r\n m=(l+r)//2\r\n if arr[m]>=le and arr[m]<=ri:\r\n ans=arr[m]\r\n r=m-1\r\n elif arr[m]<le:\r\n l=m+1 \r\n else:\r\n r=m-1\r\n return ans\r\ndef fun(s,x,y,dp,co,c,n,m):\r\n if s==m:\r\n return 0\r\n if m-s<x:\r\n return n*m+1 \r\n if dp[s][c]<n*m+1:\r\n return dp[s][c]\r\n te=sum(co[c][s:s+x-1])\r\n for i in range(s+x,min(s+y+1,m+1)):\r\n te+=co[c][i-1]\r\n dp[s][c]=min(dp[s][c],fun(i,x,y,dp,co,1-c,n,m)+te)\r\n return dp[s][c] \r\n\r\n \r\nt=1 \r\n# t=int(input())\r\nwhile t>0:\r\n n,m,x,y=map(int,input().split())\r\n c=[[0]*m for i in range(2)] \r\n for i in range(n):\r\n s=input().strip()\r\n for j in range(m):\r\n if s[j]=='#':\r\n c[0][j]+=1\r\n else:\r\n c[1][j]+=1\r\n # print(c)\r\n dp=[[n*m+1]*2 for j in range(m)]\r\n fun(0,x,y,dp,c,0,n,m)\r\n # print(dp)\r\n fun(0,x,y,dp,c,1,n,m)\r\n # print(dp)\r\n print(min(dp[0][0],dp[0][1]))\r\n t-=1\r\n ", "n, m, x, y = [int(x) for x in input().split()]\r\ncol_blacks = [0]*m\r\nfor i in range(n):\r\n\tcur_str = input()\r\n\tfor j, cur_ch in enumerate(cur_str):\r\n\t\tif cur_ch == '#':\r\n\t\t\tcol_blacks[j] += 1\r\n# print(col_blacks)\r\n\r\ndef get_min_pixels(pos, color, memory={}):\r\n\t# print(f'pos {pos}, color {color}')\r\n\t# assume a column starts from pos and its size may be from x to y\r\n\t# returns min pixels to repain of matrix suffix starting from this col\r\n\t# memory holds (pos, color) -> required_min\r\n\r\n\tif (pos, color) in memory:\r\n\t\treturn memory[(pos, color)]\r\n\r\n\tif color == 'white':\r\n\t\tcosts = col_blacks\r\n\telse:\r\n\t\tcosts = [n-col_black for col_black in col_blacks]\r\n\r\n\t# if pos == m-1:\r\n\t\t# return 0\r\n\tif pos < m and pos+x > m:\r\n\t\tval = 2*n*m\r\n\t\tmemory[(pos, color)] = val\r\n\t\treturn val\r\n\tcur_max_size = min(y, m-pos) # correct\r\n\t# print(f'cur_max_size {cur_max_size}')\r\n\tcumsums = []\r\n\t# print(f'costs {costs}')\r\n\tfor cost in costs[pos : pos+cur_max_size]:\r\n\t\tif len(cumsums) == 0:\r\n\t\t\tcumsums.append(cost)\r\n\t\telse:\r\n\t\t\tcumsums.append(cost+cumsums[-1])\r\n\t# print(f'cumsums {cumsums}') # test\r\n\tif len(cumsums) == 0:\r\n\t\tval = 0\r\n\t\tmemory[(pos, color)] = val\r\n\t\treturn val\r\n\r\n\t# print(f'pos, color {pos} {color}')\r\n\t# print(f'cumsums {cumsums}')\r\n\r\n\toverall_min = n*m\r\n\tnext_color = 'white' if color=='black' else 'black'\r\n\tfor size in range(x, cur_max_size+1):\r\n\t\t# print(f'size {size}')\r\n\t\t# print(f'cumsums[size-x] {cumsums[size-x]}')\r\n\t\tcur_min = cumsums[size-1] + get_min_pixels(pos+size, next_color, memory)\r\n\t\t# print(f'cur_min {cur_min}')\r\n\t\toverall_min = min(overall_min, cur_min)\r\n\t\t# process end of matrix\r\n\tmemory[(pos, color)] = overall_min\r\n\treturn overall_min\r\n\r\nmemory = {}\r\nblack_min = get_min_pixels(0, 'black', memory)\r\n# print(memory)\r\n# memory = {} # just for test. REMOVE!!!!!!!!!!\r\nwhite_min = get_min_pixels(0, 'white', memory)\r\n# print(memory)\r\n# print(f'black_min {black_min}')\r\n# print(f'white_min {white_min}')\r\nprint(min(black_min, white_min))\r\n", "from math import inf\r\nn, m, x, y = map(int, input().split())\r\nw, a, b = [0] * 1100, [inf] * 1100, [inf] * 1100 \r\nfor i in range(n):\r\n s = input()\r\n for j in range(m):\r\n if(s[j] == '.'):\r\n w[j + 1] += 1 \r\nfor i in range(1, m + 1):\r\n w[i] += w[i - 1]\r\na[0], b[0] = 0, 0\r\nfor i in range(1, m + 1):\r\n for j in range(x, y + 1):\r\n if(i >= j):\r\n a[i] = min(a[i], w[i] - w[i - j] + b[i - j])\r\n b[i] = min(b[i], n * j - w[i] + w[i - j] + a[i - j]) \r\nprint(min(a[m], b[m]))", "from math import inf\nn,m,x,y = map(int, input().split())\nA = []\nfor _ in range(n):\n A.append(input())\n\npref = [(0,0)]\nfor j in range(m):\n hashtags = sum(1 if A[i][j] == \"#\" else 0 for i in range(n))\n pref.append(\n (pref[-1][0] + hashtags, # white\n pref[-1][1] + n - hashtags) # black\n ) \n\ndp = [[inf] * 2 for _ in range(m+1)]\ndp[0] = [0,0]\n\nfor j in range(1,m+1):\n for c in range(2):\n for w in range(x,y+1):\n if j-w < 0:\n break\n dp[j][c] = min(dp[j][c], dp[j-w][1-c] + pref[j][c] - pref[j-w][c])\n\nprint(min(dp[-1]))\n", "n, m, x, y = map(int, input().split())\r\n\r\nM = []\r\nfor i in range(n):\r\n M.append(list(input()))\r\n\r\nwhites = [0] * m\r\nblacks = [0] * m\r\n\r\nfor j in range(m):\r\n for i in range(n):\r\n whites[j] += 1 if M[i][j] == '.' else 0\r\n blacks[j] += 1 if M[i][j] == '#' else 0\r\n\r\nwhite_stripes = [[0 for w in range(y + 1)] for j in range(m)]\r\nblack_stripes = [[0 for w in range(y + 1)] for j in range(m)]\r\n\r\nfor j in range(m):\r\n for w in range(1, y + 1):\r\n if j + w - 1 >= m:\r\n break\r\n white_stripes[j][w] = white_stripes[j][w - 1] + blacks[j + w - 1]\r\n black_stripes[j][w] = black_stripes[j][w - 1] + whites[j + w - 1]\r\n\r\ndp = [[-1, -1] for i in range(m + 1)]\r\n\r\n\r\ndef find_min(column, color):\r\n if column == m:\r\n return 0\r\n if dp[column][color] != -1:\r\n return dp[column][color]\r\n res = 10 ** 6 + 1\r\n stripes = white_stripes if color == 1 else black_stripes\r\n for w in range(x, y + 1):\r\n if column + w > m:\r\n break\r\n # print('column', column, 'color', color, 'width', w)\r\n r = stripes[column][w] + find_min(column + w, (0 if color == 1 else 1))\r\n res = min(res, r)\r\n # print('column', column, 'color', color, 'width', w, 'res', r)\r\n\r\n dp[column][color] = res\r\n return res\r\n\r\n\r\nans = min(find_min(0, 0), find_min(0, 1))\r\nprint(ans)\r\n", "INF = 2147483647\r\n \r\nn, m, x, y = list(map(int, input().split()))\r\nbarcode = []\r\nfor _ in range(n):\r\n barcode.append(list(input()))\r\ncolumn_black = [-1] * m\r\ncolumn_white = [-1] * m\r\n \r\ndef column(x, colour):\r\n re = 0\r\n for i in range(n):\r\n if barcode[i][x] != colour:\r\n re += 1\r\n return re\r\n \r\nfor i in range(m):\r\n column_black[i] = column(i, '#')\r\n column_white[i] = column(i, '.')\r\n\r\nblack = [[INF] * (y + 1) for _ in range(m + 1)]\r\nwhite = [[INF] * (y + 1) for _ in range(m + 1)]\r\nfor i in range(x, y + 1):\r\n black[0][i] = 0\r\n white[0][i] = 0\r\n\r\n# black\r\nfor index in range(1, m + 1):\r\n for consec in range(y + 1):\r\n change_black = INF\r\n change_white = INF\r\n if consec < x:\r\n change_black = black[index - 1][consec + 1]\r\n elif consec >= y:\r\n change_white = white[index - 1][1]\r\n else:\r\n change_black = black[index - 1][consec + 1]\r\n change_white = white[index - 1][1]\r\n change_white += column_white[index - 1]\r\n change_black += column_black[index - 1]\r\n black[index][consec] = min(change_black, change_white)\r\n # white\r\n change_black = INF\r\n change_white = INF\r\n if consec < x:\r\n change_white = white[index - 1][consec + 1]\r\n elif consec >= y:\r\n change_black = black[index - 1][1]\r\n else:\r\n change_black = black[index - 1][1]\r\n change_white = white[index - 1][consec + 1]\r\n change_white += column_white[index - 1]\r\n change_black += column_black[index - 1]\r\n white[index][consec] = min(change_black, change_white)\r\n\r\n\r\n# for row in black: print(row)\r\n# print('')\r\n# for row in white: print(row)\r\n\r\nprint(min(black[m][0], white[m][0]))", "# eric_kirch\n# Tarea 3 Ejercicio 5\n# E - Supermercado Lidor\n\n# column -> (hashes (black), dots (white))\n# because column(# . # # .) == column(# # # . .)\n# (as far as operations it can handle goes)\n\nimport sys\n\n# Input\nline = sys.stdin.readline()\nheight, width, x, y = [int(x) for x in line.split()]\n# n is height, m is width\n\nblack_columns = [0] * (width + 1)\nwhite_columns = [0] * (width + 1)\n\n# Storing input into columns\nfor row in range(1, height + 1):\n line = sys.stdin.readline().rstrip()\n index = 1\n for char in line:\n if char == \"#\":\n black_columns[index] += 1\n else:\n white_columns[index] += 1\n index += 1\n\n\n# CUMSUM JAJAJAJAJ\ncumsum_black = [0]\ncumsum_white = [0]\n\nfor i in range(width):\n cumsum_black.append(cumsum_black[i] + black_columns[i + 1])\n cumsum_white.append(cumsum_white[i] + white_columns[i + 1])\n\n\n# Processing\ndp_black = [0]\ndp_white = [0]\n\nfor i in range(1, width + 1):\n current_min_black_value = 2147483647\n current_min_white_value = 2147483647\n\n for j in range(x, y + 1):\n this_index = (i - j)\n\n if this_index < 0:\n break\n\n this_value_black = dp_white[this_index] + (cumsum_black[i] - cumsum_black[this_index])\n this_value_white = dp_black[this_index] + (cumsum_white[i] - cumsum_white[this_index])\n\n if this_value_black < current_min_black_value:\n current_min_black_value = this_value_black\n\n if this_value_white < current_min_white_value:\n current_min_white_value = this_value_white\n\n dp_black.append(current_min_black_value)\n dp_white.append(current_min_white_value)\n\nanswer = min(dp_black[width], dp_white[width])\nsys.stdout.write(str(answer) + \"\\n\")\n \t\t \t \t \t\t \t \t \t\t \t \t\t\t\t", "row, col, x, y = map(int, input().strip().split())\r\nmat = []\r\nfor i in range(row):\r\n mat.append(list(input()))\r\n\r\nblack_pre, white_pre = [0 for i in range(col+1)], [0 for i in range(col+1)]\r\n\r\nfor j in range(1,col+1):\r\n w = 0; b = 0\r\n for i in range(row):\r\n if mat[i][j-1] == '.':\r\n w += 1\r\n else:\r\n b += 1\r\n black_pre[j] += black_pre[j-1]+b\r\n white_pre[j] += white_pre[j-1]+w\r\n\r\ndp = [[float('inf') for i in range(col+1)] for i in range(2)]\r\ndp[0][0] = 0; dp[1][0] = 0\r\n# print(\"#######\")\r\n# print(white_pre, black_pre)\r\n# print(\"#######\")\r\nfor i in range(1, col+1):\r\n for j in range(x, y+1):\r\n if i-j >= 0:\r\n dp[0][i] = min(dp[0][i], dp[1][i-j] + white_pre[i]-white_pre[i-j])\r\n dp[1][i] = min(dp[1][i], dp[0][i-j] + black_pre[i]-black_pre[i-j])\r\n # print(\"---\")\r\n # for i in dp:\r\n # print(i)\r\n # print(\"---\")\r\nprint(min(dp[0][-1], dp[1][-1]))\r\n\r\n\r\n\r\n\r\n", "n,m,x,y=map(int,input().split())\r\ncnt=[0]*m\r\nfor i in range(n):\r\n s=input()\r\n for j in range(m):\r\n if s[j]=='#':\r\n cnt[j]+=1\r\n\r\npre=[[0,0]]\r\nfor i in cnt:\r\n pre.append([pre[-1][0]+i,pre[-1][1]+n-i])\r\ndp=[None]*(m+1)\r\ndp[0]=[0,0]\r\nfor i in range(m):\r\n dp[i+1]=[int(1e6),int(1e6)]\r\nfor i in range(m):\r\n for j in range(x,y+1):\r\n try:\r\n if i+j<=m:\r\n dp[i+j][0]=min(dp[i][1]+pre[i+j][0]-pre[i][0],dp[i+j][0])\r\n dp[i+j][1]=min(dp[i+j][1],dp[i][0]+pre[i+j][1]-pre[i][1])\r\n except:\r\n print(i,j)\r\nprint(min(dp[m][0],dp[m][1]))", "n,m,x,y = map(int, input().split())\nA = []\nfor _ in range(n):\n A.append(input().strip())\n\npre_white = [0]\npre_black = [0]\nfor i in range(m):\n hashtags = sum(1 if A[j][i] == \"#\" else 0 for j in range(n))\n pre_white.append(pre_white[-1] + hashtags)\n pre_black.append(pre_black[-1] + n - hashtags)\n\ndp = [[float(\"inf\")] * 2 for _ in range(m+1)]\ndp[0][0] = 0\ndp[0][1] = 0\n\nfor i in range(1,m+1):\n for j in range(x,y+1):\n if j > i:\n break\n dp[i][0] = min(dp[i][0], dp[i-j][1] + pre_black[i] - pre_black[i-j])\n for j in range(x,y+1):\n if j > i:\n break\n dp[i][1] = min(dp[i][1], dp[i-j][0] + pre_white[i] - pre_white[i-j])\n\n\nprint(min(dp[-1]))\n\n", "import abc\r\nimport itertools\r\nimport math\r\nfrom math import gcd as gcd\r\nimport sys\r\nimport queue\r\nimport itertools\r\nfrom heapq import heappop, heappush\r\nimport random\r\nfrom array import array\r\nfrom bisect import *\r\n\r\n# input = lambda: sys.stdin.buffer.readline().decode().strip()\r\n# inp = lambda dtype: [dtype(x) for x in input().split()]\r\ndebug = lambda *x: print(*x, file=sys.stderr)\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nMint, Mlong, out = 2 ** 31 - 1, 2 ** 63 - 1, []\r\n\r\n\r\n# Solution starts here\r\ndef solve():\r\n n, m, x, y = map(int, sys.stdin.readline().split())\r\n # f_i - number of # in column i\r\n f = [0 for i in range(m)]\r\n\r\n for i in range(n):\r\n e = str(sys.stdin.readline()[:-1])\r\n for j in range(m):\r\n f[j] += int(e[j] == \"#\")\r\n\r\n pref_sum = [0 for i in range(m + 1)]\r\n for i in range(m):\r\n pref_sum[i + 1] = pref_sum[i] + f[i]\r\n\r\n last_black = [1<<60 for i in range(m)]\r\n last_white = [1<<60 for i in range(m)]\r\n\r\n for i in range(x - 1, m):\r\n for size in range(x, min(y, i + 1) + 1):\r\n # try to make black strip\r\n s = pref_sum[i + 1] - pref_sum[i + 1 - size]\r\n last_black[i] = min(last_black[i], last_white[i - size] + size * n - s if i - size >= 0 else size * n - s)\r\n\r\n # try to make white strip\r\n s = pref_sum[i + 1] - pref_sum[i + 1 - size]\r\n last_white[i] = min(last_white[i], last_black[i - size] + s if i - size >= 0 else s)\r\n\r\n #print(last_black)\r\n #print(last_white)\r\n print(min(last_black[-1], last_white[-1]))\r\n return\r\n\r\n\r\nif __name__ == '__main__':\r\n multi_test = 0\r\n\r\n if multi_test == 1:\r\n t = int(sys.stdin.readline())\r\n for _ in range(t):\r\n solve()\r\n else:\r\n solve()\r\n", "def main():\r\n n, m, x, y = map(int, input().split())\r\n \r\n col = [0] * m\r\n for i in range(n):\r\n row = input()\r\n for j in range(m):\r\n if row[j] == '.':\r\n col[j] += 1\r\n \r\n acc = [0]\r\n for j in range(m):\r\n acc.append(acc[-1] + col[j])\r\n \r\n dp = [[0]*(m+1), [0]*(m+1)]\r\n \r\n for j in range(1, m+1):\r\n dp[0][j] = float('infinity')\r\n dp[1][j] = float('infinity')\r\n for k in range(x, y+1):\r\n if j-k >= 0:\r\n wp = acc[j] - acc[j-k]\r\n bp = k * n - wp\r\n dp[0][j] = min(dp[0][j], dp[1][j-k] + wp)\r\n dp[1][j] = min(dp[1][j], dp[0][j-k] + bp)\r\n \r\n print(min(dp[0][m], dp[1][m]))\r\n \r\n \r\nif __name__ == \"__main__\":\r\n main()", "n, m, x, y = map(int, input().split())\r\na = [input() for i in range(n)]\r\n\r\nc = [0] * m \r\nfor j in range(m):\r\n for i in range(n):\r\n c[j]+=int(a[i][j] == '.')\r\npr = [0] * (m + 1)\r\nfor i in range(1, m + 1):\r\n pr[i] = pr[i - 1] + c[i - 1]\r\n\r\nd = [[10 ** 10] * 2 for i in range(m + 1)]\r\nd[0][0] = 0\r\nd[0][1] = 0\r\n\r\nfor j in range(1, m + 1):\r\n for i in range(x, y + 1):\r\n if(j - i < 0):\r\n break # epic fail\r\n d[j][1] = min(d[j][1], d[j - i][0] + pr[j] - pr[j - i])\r\n d[j][0] = min(d[j][0], d[j - i][1] + (n * i - (pr[j] - pr[j - i])))\r\nprint(min(d[ m ][0], d[ m ][1]))\r\n\r\n", "import sys\r\nfrom typing import Callable\r\n\r\ndef prefix_sum(i, j, arr):\r\n if j - 1 < 0:\r\n return arr[i]\r\n return arr[i] - arr[j - 1]\r\n\r\ndef main() -> None:\r\n read: Callable[[], str] = sys.stdin.readline\r\n m, n, x, y = (int(i) for i in read().split())\r\n count_w = [0] * n\r\n # Find the number of white cells per column. If a given row has x white, it will have n - x black\r\n for _ in range(m):\r\n for i, c in enumerate(read().strip()):\r\n if c != '#':\r\n count_w[i] += 1\r\n\r\n # Compute prefix sum array based on count w\r\n num_of_whites = [0] * (n + 1)\r\n num_of_whites[1] = count_w[0] # 1 based arr\r\n for i in range(1, n):\r\n num_of_whites[i + 1] = count_w[i] + num_of_whites[i]\r\n\r\n matrix = [[float('inf') for _ in range(n + 1)] for _ in range(2)]\r\n matrix[0][0] = 0\r\n matrix[1][0] = 0\r\n # We make a decision column by column\r\n # We let row = 0 mean that the last column is white\r\n # If the row is 1, it means that the last column is black\r\n # And let matrix[i][j] = min number of repainted cells where the last column is color i\r\n for i in range(1, n + 1):\r\n # We only consider valid widths (note that it needs to be inclusive on y), let j be the current width we are\r\n # considering.\r\n for width in range(x, y + 1):\r\n # Find the start point based on the width\r\n start = i - (width - 1)\r\n if start < 0:\r\n break\r\n # Find how much it cost to convert the cols from [start..i] to black, and do the same for white\r\n cost_paint_black = prefix_sum(i, start, num_of_whites)\r\n cost_paint_white = (i - start + 1) * m - cost_paint_black\r\n # We are repainting col i to be white, so the total cost for the current width will be the cost of the \r\n # columns [start..i] to be painted white + the cost of the col before start to be black\r\n matrix[0][i] = min(matrix[0][i], cost_paint_white + matrix[1][start - 1])\r\n # We are repainting col i to be black\r\n matrix[1][i] = min(matrix[1][i], cost_paint_black + matrix[0][start - 1])\r\n print(min(matrix[0][-1], matrix[1][-1]))\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n main()", "#!/usr/bin/env python3\n# created : 2020. 12. 31. 23:59\n\nimport os\nfrom sys import stdin, stdout\n\n\ndef solve(tc):\n n, m, x, y = map(int, stdin.readline().split())\n\n grid = []\n for i in range(n):\n grid.append(list(stdin.readline().strip()))\n\n dp = [[[n*m, n*m] for j in range(y+1)] for i in range(m+1)]\n dp[0][0][0] = dp[0][0][1] = 0\n\n for i in range(m):\n blacks = 0\n for j in range(n):\n if grid[j][i] == '#':\n blacks += 1\n\n for k in range(x):\n dp[i+1][k+1][0] = min(dp[i+1][k+1][0], dp[i][k][0] + n - blacks)\n dp[i+1][k+1][1] = min(dp[i+1][k+1][1], dp[i][k][1] + blacks)\n\n for k in range(x, y):\n dp[i+1][k+1][0] = min(dp[i+1][k+1][0], dp[i][k][0] + n - blacks)\n dp[i+1][k+1][1] = min(dp[i+1][k+1][1], dp[i][k][1] + blacks)\n dp[i+1][1][0] = min(dp[i+1][1][0], dp[i][k][1] + n - blacks)\n dp[i+1][1][1] = min(dp[i+1][1][1], dp[i][k][0] + blacks)\n\n dp[i+1][1][0] = min(dp[i+1][1][0], dp[i][y][1] + n - blacks)\n dp[i+1][1][1] = min(dp[i+1][1][1], dp[i][y][0] + blacks)\n\n ans = n*m\n for k in range(x, y+1):\n ans = min(ans, dp[m][k][0])\n ans = min(ans, dp[m][k][1])\n print(ans)\n\n\ntcs = 1\n# tcs = int(stdin.readline().strip())\ntc = 1\nwhile tc <= tcs:\n solve(tc)\n tc += 1\n", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Aug 1 22:57:03 2020\n\n@author: divyarth\n\"\"\"\n\nimport sys\nimport heapq\nimport math\nsys.setrecursionlimit(100000)\n\nfrom collections import deque\nfrom collections import defaultdict\nfrom collections import Counter\n\n#input=sys.stdin.readline\n#print=sys.stdout.write\n\ndef PRINT(lst,sep=' '): print(sep.join(map(str,lst)))\nI=lambda : list(map(int,input().split(' ')))\n\ndef solve():\n return\n\nn,m,x,y=I()\nbar=[list(input()) for _ in range(n)]\n\ndef COL(k): return [bar[i][k] for i in range(n)]\nrow=[]\nfor i in range(m):\n c=dict(Counter(COL(i)))\n row.append(( c['#'] if '#' in c else 0))\n \ns_arr=[0]\nfor r in row: \n s_arr.append(s_arr[-1]+r)\n \ndef SUM(l,r):\n return s_arr[r+1]-s_arr[l]\n\nmem={}\nimport time\nglobal arr\ndef rec(start,color):\n \n if (start,color) in mem:\n return mem[(start,color)]\n elif start==m:\n return 0\n \n mm=float('inf')\n for end in range(start+x-1,start+y):\n if end>=m: continue\n ss=SUM(start,end) if color=='b' else (end-start+1)*n-SUM(start,end)\n #print(start,end,ss,(end-start+1)*n-ss)\n mm=min(mm,ss+rec(end+1,'w' if color=='b' else 'b'))\n \n \n mem[(start,color)]=mm \n \n return mm\n\nprint(min(rec(0,'w'),rec(0,'b')))", "n, m, x, y = map(int, input().split())\r\nu = [i.count('.') for i in list(zip(*[input() for i in range(n)]))]\r\nv = [n - i for i in u]\r\na, b, s = [u[0]], [v[0]], x - 1\r\nfor i in range(1, x):\r\n a, b = [1000001] + [j + u[i] for j in a], [1000001] + [j + v[i] for j in b]\r\nfor i in range(x, min(y, m)):\r\n a, b = [min(b[s: ]) + u[i]] + [j + u[i] for j in a], [min(a[s: ]) + v[i]] + [j + v[i] for j in b]\r\nfor i in range(min(y, m), m):\r\n a, b = [min(b[s: ]) + u[i]] + [j + u[i] for j in a[: -1]], [min(a[s: ]) + v[i]] + [j + v[i] for j in b[: -1]]\r\nprint(min(min(a[s: ]), min(b[s: ])))", "n, m, x, y = map(int, input().split())\r\ns = [input() for _ in range(n)]\r\ndp = [[[1e18, 1e18] for i in range(y+1)] for j in range(m)]\r\nct = [0 for i in range(m)]\r\n\r\nfor i in range(n):\r\n\tfor j in range(m):\r\n\t\tif(s[i][j] == '.'): \r\n\t\t\tct[j] += 1\r\n\r\ndp[0][1][1] = ct[0]\r\ndp[0][1][0] = n - ct[0]\r\nfor i in range(1, m):\r\n\tfor j in range(1, y+1):\r\n\t\tdp[i][j][1] = dp[i-1][j-1][1] + ct[i]\r\n\t\tdp[i][j][0] = dp[i-1][j-1][0] + n - ct[i]\r\n\t\tif j >= x:\r\n\t\t\tdp[i][1][0] = min(dp[i][1][0], dp[i-1][j][1] + n - ct[i])\r\n\t\t\tdp[i][1][1] = min(dp[i][1][1], dp[i-1][j][0] + ct[i])\r\n\r\nres = 1e18\r\nfor i in range(x, y+1):\r\n\tres = min(res, min(dp[-1][i]))\r\nprint(res)\r\n", "# Author : nitish420 --------------------------------------------------------------------\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\ndef main():\r\n\tn,m,x,y=map(int,input().split())\r\n\twhite=[0]*(m+1)\r\n\tblack=[0]*(m+1)\r\n\tfor _ in range(n):\r\n\t\tarr=list(input())\r\n\t\tfor i,item in enumerate(arr):\r\n\t\t\tif item=='.':\r\n\t\t\t\twhite[i+1]+=1\r\n\t\t\telse:\r\n\t\t\t\tblack[i+1]+=1\r\n\r\n\tfor i in range(1,m+1):\r\n\t\twhite[i]+=white[i-1]\r\n\t\tblack[i]+=black[i-1]\r\n\r\n\tdp=[[ 10**7 for _ in range(m+1)] for _ in range(2)]\r\n\r\n\t# 0 for white 1 for black\r\n\tdp[0][0]=0\r\n\tdp[1][0]=0\r\n\r\n\tfor i in range(x,m+1):\r\n\t\tfor j in range(x,y+1):\r\n\t\t\tif i-j>=0:\r\n\t\t\t\tdp[0][i]=min(dp[0][i],dp[1][i-j]+white[i]-white[i-j])\r\n\t\t\t\tdp[1][i]=min(dp[1][i],dp[0][i-j]+black[i]-black[i-j])\r\n\t\t\telse:\r\n\t\t\t\tbreak\r\n\t\r\n\tprint(min(dp[0][m],dp[1][m]))\r\n\r\n\r\n# region fastio\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\r\n# endregion\r\n\r\nif __name__ == '__main__':\r\n\tmain()", "import gc\r\nimport heapq\r\nimport itertools\r\nimport math\r\nimport sqlite3\r\nfrom collections import Counter, deque, defaultdict\r\nfrom sys import stdout\r\nimport time\r\nfrom math import factorial, log, gcd\r\nimport sys\r\nfrom decimal import Decimal\r\nimport threading\r\nfrom heapq import *\r\nfrom fractions import Fraction\r\n\r\n\r\ndef S():\r\n return sys.stdin.readline().split()\r\n\r\n\r\ndef I():\r\n return [int(i) for i in sys.stdin.readline().split()]\r\n\r\n\r\ndef II():\r\n return int(sys.stdin.readline())\r\n\r\n\r\ndef IS():\r\n return sys.stdin.readline().replace('\\n', '')\r\n\r\n\r\ndef main():\r\n n, m, x, y = I()\r\n matrix = [IS() for _ in range(n)]\r\n white = [0] * m\r\n for i in range(n):\r\n for j in range(m):\r\n white[j] += 1 if matrix[i][j] == '.' else 0\r\n white_pref = [0] * (m + 1)\r\n for i in range(m):\r\n white_pref[i + 1] = white_pref[i] + white[i]\r\n\r\n dp = [[float('inf')] * 2 for _ in range(m + 1)]\r\n dp[0][1] = dp[0][0] = 0\r\n for i in range(m):\r\n for d in range(x, y + 1):\r\n if i + 1 - d < 0:\r\n break\r\n dp[i + 1][0] = min(dp[i - d + 1][1] + n * d - white_pref[i + 1] + white_pref[i - d + 1], dp[i + 1][0])\r\n dp[i + 1][1] = min(dp[i - d + 1][0] + white_pref[i + 1] - white_pref[i - d + 1], dp[i + 1][1])\r\n print(min(dp[m]))\r\n\r\n\r\nif __name__ == '__main__':\r\n # for _ in range(II()):\r\n # main()\r\n main()", "from functools import lru_cache\n@lru_cache(maxsize=None)\ndef solve() : \n bc=[0 for i in range(m)]\n wc=[0 for i in range(m)]\n\n for i in range(n) :\n for j in range(m) :\n if arr[i][j]=='#' :\n bc[j]+=1\n else:\n wc[j]+=1\n for i in range(1,m):\n bc[i]+=bc[i-1]\n wc[i]+=wc[i-1]\n bc=[0]+bc\n wc=[0]+wc\n\n\n dp=[[float('inf')]*(m+1) for i in range(2)]\n dp[0][0]=0\n dp[1][0]=0\n for i in range(1,m+1):\n for a in range(x,y+1):\n if i-a>=0:\n dp[0][i]=min(dp[0][i],dp[1][i-a]+bc[i]-bc[i-a])\n dp[1][i]=min(dp[1][i],dp[0][i-a]+wc[i]-wc[i-a])\n \n return min(dp[0][m],dp[1][m])\n \n\n\n\n \n \n\n\n\n#from bisect import bisect_left as bisect\nfrom math import ceil,floor\nfrom collections import defaultdict,Counter\nfrom sys import stdin ,stdout #, setrecursionlimit\ninput = stdin.buffer.readline \nimport threading\nout=stdout.write \n#setrecursionlimit(100002) \n\nn,m,x,y= list(map(int, input().split()))\narr=[list(input().strip().decode(\"utf-8\")) for _ in range(n)]\nout(str(solve())+'\\n')\nquit()\n\nfor _ in range(int(input())) :\n n,k= list(map(int, input().split()))\n arr=list(map(int, input().split()))\n out(str(solve())+'\\n')\n\n'''\n\nthreading.stack_size(2**24)\nt = threading.Thread(target=main)\nt.start()\nt.join()\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" ]
{"inputs": ["6 5 1 2\n##.#.\n.###.\n###..\n#...#\n.##.#\n###..", "10 5 3 7\n.####\n###..\n##.##\n#..#.\n.#...\n#.##.\n.##..\n.#.##\n#.#..\n.#..#", "6 3 1 4\n##.\n#..\n#..\n..#\n.#.\n#.#", "5 10 4 16\n.#####....\n##..#..##.\n.#..##.#..\n##..#####.\n...#.##..#", "5 4 1 4\n####\n..##\n##..\n..#.\n#..#", "1 1 1 2\n.", "3 44 2 18\n####..###.#.##........##...###.####.#.....##\n...#....##.###.###.##.#####.#######.#..#..#.\n#...#.####.#.##.#.#.#.....##.##..###.#....##", "69 1 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.\n.\n#\n.\n.\n.\n#\n.\n.\n#\n#\n.\n.\n#\n.\n.\n.\n#\n#\n#\n#\n#\n.\n#\n.\n#\n#\n#\n#", "56 2 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##"], "outputs": ["11", "24", "6", "21", "8", "0", "39", "31", "55"]}
UNKNOWN
PYTHON3
CODEFORCES
31
e066aeeb5f5b265ec4c40aa35e1d99b3
Easy Tape Programming
There is a programming language in which every program is a non-empty sequence of "&lt;" and "&gt;" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using movement of instruction pointer (IP) which consists of two parts. - Current character pointer (CP); - Direction pointer (DP) which can point left or right; Initially CP points to the leftmost character of the sequence and DP points to the right. We repeat the following steps until the first moment that CP points to somewhere outside the sequence. - If CP is pointing to a digit the interpreter prints that digit then CP moves one step according to the direction of DP. After that the value of the printed digit in the sequence decreases by one. If the printed digit was 0 then it cannot be decreased therefore it's erased from the sequence and the length of the sequence decreases by one. - If CP is pointing to "&lt;" or "&gt;" then the direction of DP changes to "left" or "right" correspondingly. Then CP moves one step according to DP. If the new character that CP is pointing to is "&lt;" or "&gt;" then the previous character will be erased from the sequence. If at any moment the CP goes outside of the sequence the execution is terminated. It's obvious the every program in this language terminates after some steps. We have a sequence *s*1,<=*s*2,<=...,<=*s**n* of "&lt;", "&gt;" and digits. You should answer *q* queries. Each query gives you *l* and *r* and asks how many of each digit will be printed if we run the sequence *s**l*,<=*s**l*<=+<=1,<=...,<=*s**r* as an independent program in this language. The first line of input contains two integers *n* and *q* (1<=≤<=*n*,<=*q*<=≤<=100) — represents the length of the sequence *s* and the number of queries. The second line contains *s*, a sequence of "&lt;", "&gt;" and digits (0..9) written from left to right. Note, that the characters of *s* are not separated with spaces. The next *q* lines each contains two integers *l**i* and *r**i* (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*) — the *i*-th query. For each query print 10 space separated integers: *x*0,<=*x*1,<=...,<=*x*9 where *x**i* equals the number of times the interpreter prints *i* while running the corresponding program. Print answers to the queries in the order they are given in input. Sample Input 7 4 1&gt;3&gt;22&lt; 1 3 4 7 7 7 1 7 Sample Output 0 1 0 1 0 0 0 0 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 3 2 1 0 0 0 0 0 0
[ "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\nfrom collections import defaultdict\r\n\r\nN,Q = map(int, input().split())\r\nS = input()\r\nfor _ in range(Q):\r\n l,r = map(int, input().split())\r\n l-=1;r-=1\r\n \r\n ans = [0]*10\r\n\r\n s = [c for c in S[l:r+1]]\r\n idx=0\r\n d=1\r\n m = len(s)\r\n for i in range(m):\r\n if s[i] not in ('>','<'):\r\n s[i]=int(s[i])\r\n pre,pre_idx='',0\r\n while idx>=0 and idx<m:\r\n #print(idx,s)\r\n if s[idx] in ('>','<'):\r\n if pre in ('>','<'):\r\n s[pre_idx]=-1\r\n if s[idx]=='>':\r\n d=1\r\n else:\r\n d=-1\r\n pre=s[idx]\r\n pre_idx=idx\r\n elif s[idx]>-1:\r\n ans[s[idx]]+=1\r\n s[idx]-=1\r\n pre=s[idx]\r\n pre_idx=idx\r\n \r\n \r\n idx+=d\r\n\r\n print(*ans)\r\n \r\n ", "n, q = map(int, input().split())\nS = list('x'+input()+'x')\nfor _ in range(q):\n\tl, r = map(int, input().split())\n\ts = S[l-1:r+2]\n\ts[0] = s[-1] = 'x'\n\tc = [0]*10\n\tdp, p = 1, 1\n\twhile s[p]!='x':\n\t\tif s[p]=='>':\n\t\t\tdp = 1\n\t\t\tif s[p+1] in \"><\":\n\t\t\t\ts.pop(p)\n\t\t\telse:\n\t\t\t\tp += 1\n\t\telif s[p]=='<':\n\t\t\tdp = -1\n\t\t\tp -= 1\n\t\t\tif s[p] in \"><\": s.pop(p+1)\n\t\telse:\n\t\t\td = ord(s[p])-ord('0')\n\t\t\tc[d] += 1\n\t\t\tif d==0: s.pop(p)\n\t\t\telse: s[p] = chr(d-1+ord('0'))\n\t\t\tp += dp\n\t\t\tif d==0 and dp==1: p -= 1\n\tprint(' '.join(map(str, c)))\n", "n, q = map(int, input().split())\r\ns = input()\r\nfor _ in range(q):\r\n l, r = map(int, input().split())\r\n t = list(s[l-1:r])\r\n p, d = 0, 1\r\n res = [0] * 10\r\n while 0 <= p < len(t):\r\n if '0' <= t[p] <= '9':\r\n k = int(t[p])\r\n res[k] += 1\r\n if k > 0:\r\n t[p] = str(k-1)\r\n p += d\r\n else:\r\n t.pop(p)\r\n if d == -1:\r\n p += d\r\n else:\r\n d = -1 if t[p] == '<' else 1\r\n if 0 <= p+d < len(t) and not ('0' <= t[p+d] <= '9'):\r\n t.pop(p)\r\n if d == -1:\r\n p += d\r\n else:\r\n p += d\r\n print(*res)\r\n", "n, q = map(int, input().split())\nS = [-1]+list(map(lambda x: ord(x)-ord('0'), input()))+[-1]\nD = [12, 14]\nfor _ in range(q):\n\tl, r = map(int, input().split())\n\ts = S[l-1:r+2]\n\ts[0] = s[-1] = -1\n\tc = [0]*10\n\tdp, p = 1, 1\n\ti = s[p]\n\twhile i!= -1:\n\t\tif i==14:\n\t\t\tdp = 1\n\t\t\tif s[p+1] in D:\n\t\t\t\ts.pop(p)\n\t\t\telse:\n\t\t\t\tp += 1\n\t\telif i==12:\n\t\t\tdp = -1\n\t\t\tp -= 1\n\t\t\tif s[p] in D: s.pop(p+1)\n\t\telse:\n\t\t\tc[i] += 1\n\t\t\tif i==0: s.pop(p)\n\t\t\telse: s[p] -= 1\n\t\t\tp += dp\n\t\t\tif i==0 and dp==1: p -= 1\n\t\ti = s[p]\n\tprint(' '.join(map(str, c)))\n", "R = lambda: map(int, input().split())\r\nn, q = R()\r\ns = input()\r\nfor _ in range(q):\r\n l, r = R()\r\n l -= 1\r\n r -= 1\r\n cs = [c for c in s[l:r + 1]]\r\n res = [0] * 10\r\n p = 0\r\n dir = 1\r\n while 0 <= p < len(cs):\r\n if cs[p].isnumeric():\r\n num = int(cs[p])\r\n res[num] += 1\r\n if not num:\r\n cs[p] = ''\r\n else:\r\n cs[p] = str(num - 1)\r\n elif cs[p] == '<':\r\n dir = -1\r\n np = p + dir\r\n while np >= 0 and not cs[np]:\r\n np += dir\r\n if np >= 0 and cs[np] in '<>':\r\n cs[p] = ''\r\n elif cs[p] == '>':\r\n dir = 1\r\n np = p + dir\r\n while np < len(cs) and not cs[np]:\r\n np += dir\r\n if np < len(cs) and cs[np] in '<>':\r\n cs[p] = ''\r\n p += dir\r\n print(' '.join(map(str, res)))" ]
{"inputs": ["7 4\n1>3>22<\n1 3\n4 7\n7 7\n1 7", "5 2\n>>>>>\n1 5\n1 2", "1 3\n9\n1 1\n1 1\n1 1", "7 1\n0101010\n1 7", "10 30\n306<<>4>04\n2 2\n6 6\n1 10\n1 8\n2 4\n9 10\n2 8\n3 5\n7 7\n2 6\n1 3\n3 7\n4 9\n3 10\n5 9\n7 10\n1 3\n5 7\n4 10\n6 10\n6 7\n4 5\n3 4\n4 6\n4 7\n7 9\n4 6\n2 8\n1 5\n2 6", "17 21\n187<9>82<818<4229\n8 14\n4 10\n11 17\n8 8\n4 12\n6 6\n5 12\n10 12\n15 16\n7 7\n3 8\n4 8\n8 9\n8 10\n5 7\n1 7\n11 12\n3 6\n6 11\n8 16\n6 9", "21 33\n007317842806111438>67\n2 11\n3 21\n3 12\n5 8\n14 14\n10 14\n9 17\n7 17\n1 12\n12 18\n3 10\n2 20\n5 5\n10 13\n14 20\n2 19\n1 13\n6 11\n6 9\n8 13\n16 16\n1 15\n18 20\n12 12\n7 20\n3 11\n13 21\n3 11\n12 13\n8 15\n13 17\n5 5\n2 16", "1 5\n<\n1 1\n1 1\n1 1\n1 1\n1 1", "1 2\n>\n1 1\n1 1", "1 1\n0\n1 1", "3 10\n<<<\n2 3\n3 3\n2 3\n3 3\n1 3\n1 1\n1 2\n3 3\n1 1\n2 2", "1 100\n3\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1", "2 100\n44\n1 2\n2 2\n2 2\n1 2\n1 1\n2 2\n2 2\n1 2\n1 1\n1 1\n1 2\n1 1\n1 2\n1 1\n2 2\n1 1\n1 2\n2 2\n1 2\n1 2\n2 2\n2 2\n1 2\n1 1\n1 1\n1 2\n1 1\n2 2\n1 2\n1 2\n2 2\n1 2\n1 2\n2 2\n1 2\n2 2\n1 1\n1 1\n1 2\n1 2\n2 2\n1 2\n1 1\n1 2\n1 2\n2 2\n1 1\n2 2\n1 2\n1 1\n2 2\n1 1\n1 2\n2 2\n1 2\n1 1\n1 1\n1 2\n2 2\n1 2\n1 2\n1 1\n1 2\n1 2\n1 1\n2 2\n1 2\n2 2\n1 1\n1 2\n2 2\n1 2\n1 2\n1 2\n1 1\n1 2\n1 1\n1 1\n1 1\n1 2\n1 1\n1 1\n1 1\n2 2\n1 1\n2 2\n2 2\n1 2\n1 1\n2 2\n1 1\n1 1\n1 2\n1 2\n2 2\n1 2\n2 2\n1 2\n1 2\n1 2", "5 1\n1>3><\n4 5", "4 1\n217<\n1 4", "4 1\n34><\n1 4"], "outputs": ["0 1 0 1 0 0 0 0 0 0 \n2 2 2 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n2 3 2 1 0 0 0 0 0 0 ", "0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 ", "0 0 0 0 0 0 0 0 0 1 \n0 0 0 0 0 0 0 0 0 1 \n0 0 0 0 0 0 0 0 0 1 ", "4 3 0 0 0 0 0 0 0 0 ", "1 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n1 0 1 1 0 1 1 0 0 0 \n1 0 1 1 0 1 1 0 0 0 \n1 0 0 0 0 1 1 0 0 0 \n1 0 0 0 1 0 0 0 0 0 \n1 0 0 0 0 1 1 0 0 0 \n0 0 0 0 0 1 1 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n1 0 0 0 0 1 1 0 0 0 \n1 0 0 1 0 0 1 0 0 0 \n0 0 0 0 0 1 1 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 1 1 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n1 0 0 0 2 0 0 0 0 0 \n1 0 0 1 0 0 1 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n1 0 0 0 2 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 1 1 0 0 0 \n0 0 0...", "0 1 1 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n1 1 0 0 0 0 0 1 1 0 \n0 0 1 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n2 3 2 1 1 1 1 1 3 1 \n0 1 0 0 0 0 0 0 2 0 \n0 0 2 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 1 0 \n0 0 0 0 0 0 1 1 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 1 1 0 0 0 0 0 0 0 \n0 1 1 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 1 1 \n1 1 0 0 0 0 1 2 1 0 \n0 1 0 0 0 0 0 0 1 0 \n0 0 0 0 0 0 1 1 0 0 \n2 3 2 1 1 1 1 1 2 0 \n0 1 1 0 0 0 0 0 0 0 \n2 2 2 1 1 1 1 1 1 0 ", "2 1 1 1 1 0 0 2 2 0 \n1 4 1 2 2 0 2 3 3 0 \n1 1 1 1 1 0 1 2 2 0 \n0 1 0 0 1 0 0 1 1 0 \n0 1 0 0 0 0 0 0 0 0 \n1 2 0 0 0 0 1 0 1 0 \n1 3 1 1 1 0 1 0 1 0 \n1 3 1 1 2 0 1 0 2 0 \n3 1 1 1 1 0 1 2 2 0 \n0 3 0 1 1 0 1 0 1 0 \n0 1 1 1 1 0 0 2 2 0 \n2 4 1 2 2 0 2 2 3 0 \n0 1 0 0 0 0 0 0 0 0 \n1 1 0 0 0 0 1 0 1 0 \n0 2 0 1 1 0 1 0 1 0 \n2 4 1 2 2 0 1 2 3 0 \n3 2 1 1 1 0 1 2 2 0 \n1 0 1 0 1 0 0 1 2 0 \n0 0 1 0 1 0 0 1 1 0 \n1 1 1 0 1 0 1 0 1 0 \n0 0 0 0 1 0 0 0 0 0 \n3 4 1 1 1 0 1 2 2 0 \n0 0 0 0 0 0 1 0 1 0 \n0 0 0...", "0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 ", "0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 ", "1 0 0 0 0 0 0 0 0 0 ", "0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 \n0 0 0 0 0 0 0 0 0 0 ", "0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0 1 0 0 0 0 0 0 \n0 0 0...", "0 0 0 0 2 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 2 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 2 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 2 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 2 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 2 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 2 0 0 0 0 0 \n0 0 0 0 2 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 1 0 0 0 0 0 \n0 0 0 0 2 0 0 0 0 0 \n0 0 0...", "0 0 0 0 0 0 0 0 0 0 ", "1 2 1 0 0 0 1 1 0 0 ", "0 0 1 2 1 0 0 0 0 0 "]}
UNKNOWN
PYTHON3
CODEFORCES
5
e070fa09a730ded5af470dfb1b5ddf32
Almost Identity Permutations
A permutation *p* of size *n* is an array such that every integer from 1 to *n* occurs exactly once in this array. Let's call a permutation an almost identity permutation iff there exist at least *n*<=-<=*k* indices *i* (1<=≤<=*i*<=≤<=*n*) such that *p**i*<==<=*i*. Your task is to count the number of almost identity permutations for given numbers *n* and *k*. The first line contains two integers *n* and *k* (4<=≤<=*n*<=≤<=1000, 1<=≤<=*k*<=≤<=4). Print the number of almost identity permutations for given *n* and *k*. Sample Input 4 1 4 2 5 3 5 4 Sample Output 1 7 31 76
[ "n,k=map(int,input().split())\r\ndp=[[[0]*(k+1) for i in range(n+1)] for j in range(k+1)]\r\ndp_c=[[[0]*(k+1) for i in range(n+1)] for j in range(k+1)]\r\nfor i in range(1,n):\r\n dp[1][i][1]=1\r\nstore=[0,1,1,2,9]\r\nans=0\r\nfor i in range(2,k+1):\r\n add=0\r\n for j in range(1,n+1):\r\n add += dp[i - 1][j - 1][i - 1]\r\n if j>=i:\r\n dp[i][j][i]=add\r\n dp_c[i][j][i]=add*store[i]\r\n ans+=dp_c[i][j][i]\r\nprint(ans+1)", "from math import factorial as fact\r\n\r\nerrors = [1, 0, 1, 2, 9]\r\n\r\n\r\ndef cnk(n, k):\r\n return fact(n) // (fact(k) * fact(n - k))\r\n\r\n\r\ns = 0\r\nn, k = map(int, input().split())\r\nfor i in range(k + 1):\r\n s += cnk(n, i) * errors[i]\r\n\r\nprint(s)\r\n", "import math\r\nn , k =map(int ,input().split())\r\ns=n-k\r\nres=0\r\nfor i in range(k+1):\r\n x=i+s\r\n z=math.factorial(n)//(math.factorial(x)*math.factorial(n-x))\r\n if x==n-1:\r\n continue\r\n if x==n:\r\n res=res+1\r\n if x==n-2:\r\n res=res+z\r\n if x==n-3:\r\n res=res+z*2\r\n if x==n-4:\r\n res=res+z*9\r\nprint(res)", "## Fast I/O\nimport io,os,sys\n\n# Fast input. Use s = input().decode() for strings\n# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\n# Fast output\ndef print(*args, sep = ' ', end = '\\n'):\n string = sep.join(map(str, args))+end\n sys.stdout.write(string)\n\ndef debug(*args, sep = ' ', end = '\\n'):\n string = \"Debug: \" + sep.join(map(str, args)) + end\n sys.stderr.write(string)\n\n# from collections import Counter, defaultdict\n# from functools import lru_cache\n# from math import floor, ceil, sqrt, gcd\n# from sys import stderr\n\ndef facto(n):\n if n <= 1:\n return 1\n return n * facto(n-1)\n\ndef D(n):\n if n == 0:\n return 1\n elif n&1:\n return n * D(n - 1) - 1\n return n * D(n - 1) + 1\n\ndef A(k, n):\n # Number of arrangments for a small k\n r = 1\n for i in range(n, n-k, -1):\n r *= i\n return r\n\ndef binom(k, n):\n # n choose k for a small k\n return A(k, n) // facto(k)\n\ndef exact(k, n):\n return D(k) * binom(k, n)\n\nN, K = map(int, input().split())\nans = 0\nfor k in range(K+1):\n ans += exact(k, N)\nprint(ans)\n\n\n#\n# @PoustouFlan\n# Code:Choke?!\n# [ 极客 ]\n#\n", "\ndef C(n, k):\n result = 1\n for i in range(n - k + 1, n + 1):\n result *= i\n for i in range(2, k + 1):\n result //= i\n return result\n\n\nn, k = map(int, input().split())\n\nderangements = {\n 2: 1,\n 3: 2,\n 4: 9\n}\n\nresult = 1\n\nfor a, n_derang in derangements.items():\n if a <= k:\n result += C(n, a) * n_derang\n\nprint(result)\n", "import sys\r\ninput = sys.stdin.readline\r\nfrom math import comb\r\n\r\nn, k = map(int, input().split())\r\nc = 0\r\nwhile k:\r\n if k == 4:\r\n c += comb(n, n-4) * 9\r\n elif k == 3:\r\n c += comb(n, n-3) * 2\r\n elif k == 2:\r\n c += comb(n, n-2)\r\n else:\r\n c += 1\r\n k -= 1\r\n\r\nprint(c)\r\n", "n,k=map(int,input().split())\r\nc=lambda i:c(i-1)*(n-i+1)//i if i else 1\r\nprint(sum([1,c(2),2*c(3),9*c(4)][:k]))", "from math import factorial\r\n\r\ndef fac(n,m):\r\n return factorial(n) // factorial(m) // factorial(n-m)\r\n\r\nn, k = map(int, input().split())\r\nif k == 1:\r\n print(1)\r\nelif k == 2:\r\n print(fac(n, 2) + 1)\r\nelif k == 3:\r\n print(fac(n, 3) * 2 + fac(n, 2) + 1)\r\nelif k == 4:\r\n print(fac(n, 4) * 9 + fac(n, 3) * 2 + fac(n, 2) + 1)\r\n", "n,k=map(int,input().split())\r\nif k==1:\r\n print(1)\r\nif k==2:\r\n print(1 + n*(n-1)//2) \r\nif k==3:\r\n print(1 + n*(n-1)//2 + 2*(n*(n-1)*(n-2))//6)\r\nif k==4:\r\n print(1 + n*(n-1)//2 + 2*(n*(n-1)*(n-2))//6 +(9*n*(n-1)*(n-2)*(n-3))//24)\r\n", "from math import factorial as fact\r\ndef ncr(n,k):\r\n #awesome ncr than traditional\r\n ans=1\r\n den=1\r\n for i in range(1,k+1):\r\n ans*=(n-i+1)\r\n den*=i\r\n return ans//den\r\nn,k=map(int,input().split())\r\nans=1\r\nder=[1,0,1,2,9]\r\nfor i in range(1,k+1):\r\n ans+=ncr(n,i)*der[i]\r\nprint(ans)\r\n \r\n \r\n", "from math import factorial as f\r\n\r\nd = [0] * 1001\r\nd[2] = 1\r\nfor i in range(3, len(d)):\r\n d[i] = (i - 1) * (d[i - 1] + d[i - 2])\r\n\r\n\r\ndef C(n, k):\r\n return f(n) // (f(n - k) * f(k))\r\n\r\n\r\ndef ints(): return list(map(int, input().split()))\r\n\r\n\r\nn, k = ints()\r\nres = 1\r\nfor i in range(1 + k):\r\n res += C(n, i) * d[i]\r\nprint(res)\r\n", "N = 1001\r\nD = [0]*N # dearrangements\r\nD[0] = 1\r\nfor i in range(2, N):\r\n D[i] = (D[i-1] + D[i-2]) * (i-1)\r\n\r\n\r\ndef nCr(n, r):\r\n c = 1\r\n for i in range(r): \r\n c = c*(n-i)//(i+1)\r\n return c\r\n\r\n\r\nn, k = map(int, input().split())\r\nans = 0\r\nfor r in range(k+1):\r\n ans += nCr(n, r) * D[r]\r\n\r\nprint(ans)", "import sys\ninput = sys.stdin.readline\n\n'''\n\n'''\n\ndef fast_factorial(mod=None):\n \"\"\"\n Faster than naive factorial, uses memoization.\n \"\"\"\n res = [1,1]\n size = 2\n\n def ff(k):\n nonlocal size\n\n while k >= size:\n res.append(res[-1] * size)\n size += 1 \n return res[k]\n \n def ff_mod(k):\n nonlocal size\n\n while k >= size:\n res.append((res[-1] * (size % mod)) % mod)\n size += 1\n \n return res[k]\n\n if mod == None:\n return ff\n else:\n return ff_mod\n\nff = fast_factorial()\n\ndef nCk(n, k):\n return ff(n) // (ff(k) * ff(n-k))\n\nn, k = map(int, input().split())\n\ndef remain(n):\n nums = [-1] * n\n res = 0\n\n def solve(i):\n nonlocal nums, res\n\n if i == n:\n #print(nums)\n res += 1\n return \n\n for j in range(n):\n if i != j and not(j in nums):\n nums[i] = j\n solve(i+1)\n nums[i] = -1 \n\n solve(0)\n return res \n\n#remain(4)\n\nres = 1\nfor c in range(n-k, n-1):\n num = nCk(n, c) * remain(n-c)\n res += num\nprint(res)\n", "n, k = map(int, input().split())\ndg = [0, 0, 1, 2, 9]\ndef getCombinationValue(r):\n if r == 0:\n return 1\n elif r == 1:\n return n\n elif r == 2:\n return ((n - 1) * n)// 2\n elif r == 3:\n return ((n - 1) * n * (n - 2)) // 6\n elif r == 4:\n return ((n - 1) * n * (n - 2) * (n - 3)) // 24\nans = 1\nfor m in range(k + 1):\n ans += getCombinationValue(m) * dg[m]\nprint(ans)", "from math import factorial as fact\n# mod = 10**9 + 7\n\ndef C(n, k):\n\treturn fact(n) // (fact(k) * fact(n - k))\n\nn, k= map(int, input().split())\nsum=0\nfor i in range(k+1):\n if i==0:\n sum+=C(n , i)\n if i==2:\n sum+=C(n , i)*1\n if i==3:\n sum+=C(n , i)*2\n if i==4:\n sum+=C(n , i)*9\n\nprint(sum)", "N = 10**3+50\r\nC = [[0]*(N+1) for i in range(N+1)] #C[n][k] > nCk\r\n\r\nfor i in range(N+1):\r\n for j in range(i+1):\r\n if j == 0 or j == i:\r\n C[i][j] = 1\r\n else:\r\n C[i][j] = C[i-1][j-1]+C[i-1][j]\r\n\r\ndef cmb3(n, k):\r\n return C[n][k]\r\n\r\nn,k = map(int, input().split())\r\nans = 1\r\nimport math\r\n\r\ndp = [0]*5\r\ndp[0] = 1\r\ndp[1] = 0\r\nfor i in range(2, 5):\r\n dp[i] = math.factorial(i)\r\n for j in range(i):\r\n dp[i] -= cmb3(i, i-j)*dp[j]\r\nfor i in range(1, k+1):\r\n ans += cmb3(n, i)*dp[i]\r\nprint(ans)\r\n", "from math import factorial as fac\r\npc = {3: 2, 2: 1, 4:9}\r\nn, k = [int(x) for x in input().split()]\r\ngood = 0\r\nif k >= 2:\r\n cp = int(fac(n) / (fac(2) * fac(n - 2)))\r\n good += cp * pc[2]\r\nif k >= 3:\r\n cp = int(fac(n) / (fac(3) * fac(n - 3)))\r\n good += cp * pc[3]\r\nif k == 4:\r\n cp = int(fac(n) / (fac(4) * fac(n - 4)))\r\n good += cp * pc[4]\r\nprint(good + 1)", "import math\r\nimport sys\r\n\r\nsys.setrecursionlimit(2*10**5)\r\n\r\ndef fact(n):\r\n if n == 0:\r\n return 1\r\n return n * fact(n-1)\r\n\r\nn, moveis = [int(x) for x in input().split()]\r\nfixos = n - moveis\r\n\r\ndiffs = [0 for _ in range(5)]\r\ndiffs[0] = 1\r\ndiffs[1] = 0\r\ndiffs[2] = n * (n-1) // 2\r\ndiffs[3] = n * (n-1) * (n-2) // 6 * 2\r\ndiffs[4] = n * (n-1) * (n-2) * (n-3) // 24 * 9\r\n\r\nprint(sum(diffs[:moveis+1]))\r\n \r\n\r\n", "n,k = map(int,input().split())\r\nif k == 1:\r\n print(1)\r\nif k == 2:\r\n print(1+n*(n-1)//2)\r\nif k == 3:\r\n print(1+n*(n-1)//2+n*(n-1)*(n-2)//3)\r\nif k == 4:\r\n ans = 1+(n*(n-1)//2+n*(n-1)*(n-2)//3)\r\n ans += n*(n-1)*(n-2)*(n-3)//24*(9)\r\n print(ans)", "a = [0, 0, 1, 2, 9]\r\ndef C(n, k):\r\n\tif n == 0 or k > n: return 0\r\n\tk = max(k, n - k)\r\n\tlim = min(k, n - k)\r\n\tret = 1\r\n\tj = 2\r\n\tfor i in range(k + 1, n + 1):\r\n\t\tret = ret * i\r\n\t\tif j <= lim and ret % j == 0:\r\n\t\t\tret /= j\r\n\t\t\tj += 1\r\n\treturn ret\r\n\r\nn, k = map(int, input().split())\r\nans = 0\r\nfor i in range(1, k + 1):\r\n\tans += a[i] * C(n, i)\r\nprint(int(ans + 1))\r\n", "p = [\n [1, 4, 6, 4, 1]\n]\nd = [1, 0, 1, 2, 9]\nfor i in range(1, 997):\n pr = [1, i+4]\n for j in range(2, 5):\n pr.append(p[i-1][j] + p[i-1][j-1])\n p.append(pr)\nb = []\nfor i in range(0 ,997):\n pr = [1, 1]\n for j in range(2, 5):\n pr.append(p[i][j] * d[j] + pr[j-1])\n b.append(pr)\n\nx, y = map(int, input().split())\nprint(b[x-4][y])\n\t \t \t\t\t \t\t \t\t\t\t\t \t \t \t\t \t\t\t", "from math import comb\r\nn,k=[int(x) for x in input().split()]\r\nfrom math import comb\r\na=[1]\r\na.append(a[-1]+0)\r\na.append(a[-1]+comb(n,2))\r\na.append(a[-1]+2*comb(n,3))\r\na.append(a[-1]+9*comb(n,4))\r\nprint(a[k])", "A = input().split()\r\nn = int(A[0])\r\nk = int(A[1])\r\nfact = [1]*(n+1)\r\nfor i in range (1,n+1):\r\n fact[i] = fact[i-1]*(i)\r\nder = [1]*(n+1)\r\nder[0] = 1\r\nder[1] = 0\r\nfor i in range (2,n+1):\r\n der[i] = (i-1)*(der[i-1]+der[i-2])\r\ndef comb(n,k):\r\n return(fact[n]//(fact[k]*fact[n-k]))\r\ntot = 0\r\nfor i in range (0,k+1):\r\n tot = tot + comb(n,i)*der[i]\r\nprint(tot)", "n, k = [int(x) for x in input().split(' ')]\r\n\r\nans = 1\r\nif k >= 2:\r\n ans += (n * (n - 1)) // 2\r\nif k >= 3:\r\n ans += (n * (n - 1) * (n - 2)) // 3\r\nif k >= 4:\r\n ans += 9 * (n * (n - 1) * (n - 2) * (n - 3)) // 24\r\nprint(ans)", "N,K=map(int,input().split())\r\nprint(sum([1,0,N*(N-1)//2,N*(N-1)*(N-2)//3,N*(N-1)*(N-2)*(N-3)*3//8][:K+1]))", "n,k=map(int,input().split())\r\n\r\nar=[]\r\nar.append(1)\r\nfor i in range(1,n+1):\r\n ar.append(ar[i-1]*i)\r\n \r\nk=n-k\r\nans=0\r\nbr=[]\r\nbr.append(1)\r\nbr.append(0)\r\nfor i in range(2,n+1):\r\n br.append((i-1)*(br[i-1]+br[i-2]))\r\n\r\nfor i in range (k,n+1):\r\n ans=ans+(ar[n]//(ar[i]*ar[n-i]))*br[n-i]\r\nprint(ans)", "mod = 1e9+7\n\ndef power(a):\n\tre = 1\n\tfor i in range(1,a+1):\n\t\tre*=i;\n\treturn re\n\ndef func(n):\n\tif n==0:\n\t\treturn 1\n\tsum = 0\n\tfor i in range(2,n+1):\n\t\tsum+=pow(-1,i)/power(i)\n\treturn power(n)*sum\n\ndef C(a,b):\n\treturn power(b)/(power(b-a)*power(a));\n\n\n_in = input()\nn = int(_in[:-1])\nk = int(_in[-1:])\nsum=0;\nfor i in range(n-k,n+1):\n\tsum+=C(i,n)*func(n-i)\nprint(\"%d\"%sum)\n\n \t \t\t\t\t \t \t \t\t \t \t \t\t\t \t", "# |\r\n# _` | __ \\ _` | __| _ \\ __ \\ _` | _` |\r\n# ( | | | ( | ( ( | | | ( | ( |\r\n# \\__,_| _| _| \\__,_| \\___| \\___/ _| _| \\__,_| \\__,_|\r\n\r\nimport sys\r\nimport math\r\nimport operator as op\r\nfrom functools import reduce\r\nfrom sys import maxsize \r\n\r\ndef read_line():\r\n\treturn sys.stdin.readline()[:-1]\r\n \r\ndef read_int():\r\n\treturn int(sys.stdin.readline())\r\n\t\r\ndef read_int_line():\r\n\treturn [int(v) for v in sys.stdin.readline().split()]\r\n\r\ndef read_float_line():\r\n\treturn [float(v) for v in sys.stdin.readline().split()]\r\n\r\ndef ncr(n, r):\r\n\tr = min(r, n-r)\r\n\tnumer = reduce(op.mul, range(n, n-r, -1), 1)\r\n\tdenom = reduce(op.mul, range(1, r+1), 1)\r\n\treturn numer / denom\r\n\r\ndef nc2(n):\r\n\treturn n*(n-1)//2\r\n\r\n# t = read_int()\r\nt = 1\r\nfor i in range(t):\r\n\tn,k = read_int_line()\r\n\tdp = [0]*(n+1)\r\n\tdp[0] = 1\r\n\tdp[1] = 0\r\n\tdp[2] = 1\r\n\r\n\tfor i in range(3,n+1):\r\n\t\tdp[i] = (i-1)*(dp[i-1]+dp[i-2])\r\n\r\n\tans = 0\r\n\tfor i in range(k+1):\r\n\t\tans += ncr(n,i)*dp[i]\r\n\tprint(int(ans))", "from math import factorial as f\r\nfrom itertools import permutations\r\n\r\nn, k = map(int, input().split())\r\n\r\ndef nCk(k):\r\n return f(n) // (f(k) * f(n - k))\r\n\r\ndef isBad(a):\r\n for i, val in enumerate(a):\r\n if i == val:\r\n return False\r\n return True\r\n\r\nret = 0\r\nfor cnt in range(k + 1):\r\n ways = nCk(cnt)\r\n badCnt = 0\r\n for p in permutations(range(cnt)):\r\n badCnt += isBad(p)\r\n ret += ways * badCnt\r\nprint(ret)", "import math\r\nn,k=map(int,input().split())\r\nb=[1,0]\r\nfor i in range(2,n+1):\r\n b.append(((i-1)*(b[-1]+b[-2])))\r\nt=math.factorial(n)\r\nfor i in range(0,n-k):\r\n t-=math.comb(n,i)*b[-(i+1)]\r\nprint(t)", "import math\r\nn,k = [int(_) for _ in input().split()]\r\nc = [0,0,1,2,9]\r\n\r\nresult = 0\r\n\r\nfor i in range(1, k+1):\r\n result += math.comb(n, i)*c[i]\r\n\r\nprint(result+1)", "def c(n, k):\r\n\tt=1; b=1\r\n\tfor i in range(k):\r\n\t\tb*=(i+1)\r\n\t\tt*=(n-i)\r\n\treturn t//b\r\n\r\ndef howmany(n, k):\r\n\ta=0; b=1; s=0\r\n\tfor i in range(k+1):\r\n\t\ts+=b*c(n, i)\r\n\t\tbuf=b\r\n\t\tb=i*(a+b)\r\n\t\ta=buf\r\n\treturn s\r\n\r\ndef main():\r\n\tinp=input('').split(' ')\r\n\tn=int(inp[0]); k=int(inp[1])\r\n\tprint(howmany(n,k))\r\n\r\nif __name__=='__main__':\r\n\tmain()", "import itertools\nclass Solution:\n def __init__(self):\n self.n, self.k = [int(x) for x in input().split()]\n self.mod = 975319753197531975319\n\n\n def binpow(self, a: int, b: int = 975319753197531975319 - 2) -> int:\n ans = 1\n i = 1\n while i <= b:\n if b&i:\n ans = (ans * a) % self.mod\n a = (a * a) % self.mod\n i *= 2\n return ans\n\n def precompute(self, T: int) -> None:\n self.fac = [0 for i in range(T + 1)]\n self.fac[0] = 1\n self.ifac = [0 for i in range(T + 1)]\n for i in range(1, T + 1):\n self.fac[i] = (i * self.fac[i - 1]) % self.mod\n self.ifac[T] = self.binpow(self.fac[T])\n for i in range(T, 0, -1):\n self.ifac[i - 1] = i * self.ifac[i] % self.mod\n assert self.ifac[0] == self.fac[0]\n\n def choose(self, a: int, b: int):\n if b < 0 or a - b < 0: return 0\n return self.fac[a] * self.ifac[b] % self.mod * self.ifac[a - b] % self.mod\n\n def slow_solution(self) -> int:\n L = [0 for i in range(self.n)]; ans = 0\n for p in itertools.permutations(L):\n fps = 0\n for ind, val in list(p):\n if ind == val: fps += 1\n if fps >= self.n - self.k: ans += 1\n return ans\n \n def fast_solution(self) -> int:\n ans = 0\n for i in range(self.n - self.k, self.n):\n if i == self.n - 1:\n ans += 1\n break\n ans += self.choose(self.n, i) * round(self.fac[self.n - i]/2.718281828459045)\n return ans\n\nsolution_obj = Solution()\nsolution_obj.precompute(1000)\nprint(solution_obj.fast_solution())\n\n", "n,k=[int(e) for e in input().split()]\r\ndef C(n,k):\r\n y=1\r\n for i in range(n-k+1,n+1):\r\n y*=i\r\n for i in range(2,k+1):\r\n y//=i\r\n return y\r\ndef A(n,k):\r\n y=1\r\n for i in range(n-k+1,n+1):\r\n y*=i\r\n return y\r\ndef SF(n):\r\n return sum(A(n,n-i)*(-1)**i for i in range(n+1))\r\nc=1\r\nfor i in range(1,k+1):\r\n c+=C(n,i)*SF(i)\r\nprint(c)", "from math import factorial, comb, e\n\ndef derangement(m):\n if m == 0:\n return 1\n return int(0.5 + factorial(m) / e)\n\ninp = input().split(\" \")\n\nn, k = int(inp[0]), int(inp[1])\n\nprint(sum(comb(n, i) * derangement(i) for i in range(k + 1)))\n", "\r\n\r\nk,kk=map(int,input().split())\r\nc=0\r\nif(kk>=1):c=1\r\nif(kk>1):c+=(k*(k-1)/2)\r\nif(kk>2):c+=(k*(k-1)*(k-2)/6)*(2)\r\nif(kk>3):c+=(k*(k-1)*(k-2)*(k-3)/24)*(9)\r\nprint(int(c))\r\n", "import io, os\r\n\r\n# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n\r\nt = 1\r\nfor _ in range(t):\r\n n, k = map(int, input().split())\r\n ans = 1\r\n if k >= 2:\r\n ans += n*(n - 1)//2\r\n if k >= 3:\r\n ans += n*(n - 1)*(n - 2)//3\r\n if k == 4:\r\n ans += (n*(n - 1)*(n - 2)*(n - 3)//24) * 9\r\n print(ans)\r\n", "#!/usr/bin/env python3\r\n\r\nimport math\r\nimport sys\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n\r\ndef test_case():\r\n n, k = map(int, input().split())\r\n d = [0 for _ in range(n+1)]\r\n d[0] = 1\r\n d[1] = 0\r\n for i in range(2, 5):\r\n d[i] = (i-1)*(d[i-1] + d[i-2])\r\n f = [0 for _ in range(n+1)]\r\n f[0] = 1\r\n for i in range(1, n+1):\r\n f[i] = i*f[i-1]\r\n\r\n# print(f)\r\n# print(d)\r\n\r\n ans = 0\r\n for i in range(0, k+1):\r\n c = f[n]//(f[n-i]*f[i])\r\n# print(c)\r\n# print(d[i]*c)\r\n ans += (d[i] * c)\r\n print(ans)\r\n\r\n\r\ndef main():\r\n t = 1\r\n# t = int(input())\r\n for _ in range(t):\r\n test_case()\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "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\ndef fact(n):\r\n if n==0:\r\n return(1)\r\n p=1\r\n for i in range(1,n+1):\r\n p=p*i\r\n return(p)\r\ndef de(n):\r\n o=0\r\n a=fact(n)\r\n for i in range(n+1):\r\n o=o + (a*((-1)**i))/fact(i)\r\n return(o)\r\nn,k=invr()\r\nout=0\r\nfor i in range(n-k,n+1):\r\n out=out+(fact(n)/(fact(i)*fact(n-i)))*de(n-i)\r\nprint(int(out))\r\n", "#!/usr/bin/env python3\r\n# -*- coding: utf-8 -*-\r\nfrom functools import reduce\r\n\r\n_ = '''\r\n (1) Let's define function f(n, k) - exactly k permutation elements\r\n on non identical indices.\r\n Our result function is then: F(n, k) = sum(f(n, ki) ki = 0 .. k)\r\n \r\n (2) f(n, 0) = 1\r\n f(n, 1) = 0\r\n \r\n (3) We choose k indices - C(n, k).\r\n All other indices are fixed and identical.\r\n We need to permutate k! elements\r\n so we do not set them to their own identical positions.\r\n Let's define the latter function as ni(k)\r\n \r\n (4) ni(0) = 1\r\n ni(1) = 0\r\n ni(2) = 1\r\n ni(3) = 2\r\n 0 1 2 - doesn't count\r\n 0 2 1 - doesn't count\r\n 1 0 2 - doesn't count\r\n 1 2 0\r\n 2 0 1\r\n 2 1 0 - doesn't count\r\n \r\n (5) We choose (k-1) elements for first position.\r\n Let's define chosen element c1\r\n Then we go to c1 position. There we can choose from (k-1) elements (c2).\r\n Then we go to c2 position. There we can choose from (k-2) elements (c3).\r\n Then we go to c3 position. There we can choose from (k-3) elements (c4).\r\n ni'(k) := (k-1)*(k-1)!\r\n \r\n ni'(2) := (2-1)*(2-1)! = 1\r\n ni'(3) := (3-1)*(3-1)! = 4 - WRONG\r\n \r\n Let's just brutforce h(n, k) or manually check the last k=4 answer.\r\n'''\r\nni = [1, 0, 1, 2, 9]\r\n\r\nn, k = map(int, input().split())\r\n\r\ndef f_exactly_k(n, k):\r\n return (\r\n reduce(lambda x, y: x*y, range(n-k+1, n+1), 1) \\\r\n // reduce(lambda x, y: x*y, range(1, k+1), 1)\r\n ) * ni[k]\r\n\r\ns = 0\r\nfor ki in range(k+1):\r\n s += f_exactly_k(n, ki)\r\nprint(s)", "n, k = map(int, input().split()); ans = 1; ct = n\r\nspoils = [0, 1, 1, 2, 9]\r\n\r\nfor i in range(2, k + 1):\r\n ct = ct*(n - i + 1) // i\r\n ans += ct*spoils[i]\r\nprint(ans)\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn,k = list(map(int,input().split()))\r\nc = [[0]*1007 for _ in range(0,1007)]\r\nd = [0]*7\r\nans = 0\r\n\r\nfor i in range(1,n+1):\r\n c[i][0] = c[i][i] = 1\r\n for j in range(1,i):\r\n c[i][j] = c[i-1][j] + c[i-1][j-1]\r\n \r\nd[1] = 0\r\nd[2] = 1\r\nfor i in range(3,5):\r\n d[i] = (i-1)*(d[i-1]+d[i-2])\r\n\r\nfor i in range(0,k+1):\r\n ans += c[n][i]*d[i]\r\n \r\nprint(ans+1)", "import operator as op\r\nfrom functools import reduce\r\nfrom itertools import permutations\r\ndef C(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\nn,k = map(int,input().split())\r\nd = [1]\r\nfor i in range(1,k+1):\r\n p = [j for j in range(i)]\r\n x = 0\r\n for q in permutations(p):\r\n valid = True\r\n for j in range(len(q)):\r\n if j == q[j]:\r\n valid = False\r\n if valid:\r\n x += 1\r\n d.append(x)\r\nanswer = 0\r\nfor i in range(k+1):\r\n answer += C(n,i)*d[i]\r\nprint(answer)", "import math\r\nfrom sys import stdin\r\nstring = stdin.readline().strip().split()\r\nn=int(string[0])\r\nk=int(string[1])\r\ndef factorial(N):\r\n result=1\r\n for i in range(1,N+1):\r\n result*=i\r\n return result\r\noutput=1\r\nfor i in range(2,k+1):\r\n if i==2:\r\n output=output+factorial(n)/factorial(n-2)/2\r\n if i==3:\r\n output=output+2*(factorial(n)/factorial(n-3)/6)\r\n if i==4:\r\n output=output+9*(factorial(n)/factorial(n-4)/24)\r\nprint(int(output))\r\n", "n,k = list(map(int,input().split()))\r\np,q,r = ((n*(n-1))//2),((n*(n-1)*(n-2))//6),((n*(n-1)*(n-2)*(n-3))//24)\r\nif k<2:\r\n print(1)\r\nelif k==2:\r\n print(1+p)\r\nelif k==3:\r\n print(1+p+2*q)\r\nelif k==4:\r\n print(1+p+2*q+9*r)\r\n", "def C(n, m):\r\n ans=1\r\n for i in range(m):\r\n ans*=n-i\r\n for i in range(m):\r\n ans//=i+1\r\n return ans\r\n\r\nn, m=map(int, input().split())\r\nans=1\r\n\r\nif m>=2:\r\n ans+=C(n, 2)\r\n\r\nif m>=3:\r\n ans+=C(n, 3)*2\r\n\r\nif m>=4:\r\n ans+=C(n, 2)*C(n-2, 2)//2\r\n ans+=C(n, 4)*6\r\n\r\nprint(ans)\r\n", "n, k = map(int, input().strip().split())\r\nd = [0, 0]\r\nfor i in range(k-1):\r\n d.append(d[-1]*(i+2) + (-1)**(i+2))\r\nans = 0\r\nsel = 1\r\nfor i in range(k+1):\r\n ans += sel*d[i]\r\n sel = int(sel*(n-i)/(i+1))\r\nprint(ans+1)\r\n", "n,k=list(map(int,input().split()))\r\ndef ncr(n, r):\r\n # initialize numerator\r\n # and denominator\r\n num = den = 1\r\n for i in range(r):\r\n num = (num * (n - i))\r\n den = (den * (i + 1))\r\n return (num //den)\r\n\r\ndeara=[0,0,1,2,9]\r\ntotal=0\r\nfor i in range(2,k+1):\r\n total+=ncr(n,n-i)*deara[i]\r\n\r\nprint(total+1)\r\n", "n,k=list(map(int, input().split()))\r\nif k==1:\r\n print(1)\r\nelif k==2:\r\n print(1+(n*(n-1))//2)\r\nelif k==3:\r\n print(1+(n*(n-1))//2+(n*(n-1)*(n-2)//3))\r\nelse:\r\n print(1+(n*(n-1))//2+(n*(n-1)*(n-2)//3)+9*(n*(n-1)*(n-2)*(n-3)//24))", "n,k=map(int,input().split())\r\nimport math\r\ns=[1,0]\r\nfor i in range(2,n+1):\r\n s.append(((i-1)*(s[-1]+s[-2])))\r\nkq=0\r\nt=n-k\r\nfor i in range(t,n+1):\r\n kq+=math.comb(n,i)*s[n-i]\r\nprint(kq) \r\n \r\n", "# (4 ≤ n ≤ 1000, 1 ≤ k ≤ 4)\r\nD4 = 9\r\nD3 = 2\r\nD2 = 1\r\nD1 = 0\r\nx = input().split()\r\nn = int(x[0])\r\nk = int(x[1])\r\n# answer in this cases is 1 + sigma Di * nCi i from 2 to k \r\nsumma = 0\r\nif k == 1:\r\n print(1)\r\nelse:\r\n if k == 2:\r\n print(((n*(n-1))//2)*D2 + 1)\r\n elif k == 3:\r\n print(((n*(n-1)*(n-2))//6)*D3 + ((n*(n-1))//2)*D2 + 1)\r\n elif k == 4:\r\n print(((n*(n-1)*(n-2)*(n-3))//24)*D4 + ((n*(n-1)*(n-2))//6)*D3 + ((n*(n-1))//2)*D2 + 1)\r\n\r\n\r\n", "import io, os\r\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\nn,k=list(map(int,input().split()))\r\narr=[1,0,(n*(n-1))//2]\r\narr.append((n*(n-1)*(n-2))//3)\r\narr.append((n*(n-1)*(n-2)*(n-3)*3)//8)\r\nprint(sum(arr[:k+1]))\r\n", "def C(n, m):\r\n if m == 1:\r\n return n\r\n if m == 2:\r\n return n * (n - 1) // 2\r\n if m == 3:\r\n return n * (n - 1) * (n - 2) // 6\r\n if m == 4:\r\n return n * (n - 1) * (n - 2) * (n - 3) // 24\r\n return -1\r\n\r\nn, k = map(int, input().split())\r\nif k == 1:\r\n print(1)\r\nelif k == 2:\r\n print(C(n, 2) + 1)\r\nelif k == 3:\r\n print(2 * C(n, 3) + C(n, 2) + 1)\r\nelse:\r\n print(9 * C(n, 4) + 2 * C(n, 3) + C(n, 2) + 1)", "import array as arr\r\nimport math\r\n\r\nn,k = map(int, input().split())\r\n\r\n\r\na = arr.array('i',[1,0,1,2,9])\r\n\r\ns = 0\r\n\r\nwhile(k>-1):\r\n s = s + (math.factorial(n)/(math.factorial(k)*math.factorial(n-k)))*a[k]\r\n k = k - 1\r\n\r\nprint(int(s))", "import sys\ninput = lambda: sys.stdin.readline().rstrip()\nfrom collections import deque,defaultdict,Counter\nfrom itertools import permutations,combinations\nfrom bisect import *\nfrom heapq import *\nfrom math import ceil,gcd,lcm,floor,comb\nN,M = map(int,input().split())\nl = [0,0,1,2,9]\nans = 1\nfor i in range(1,M+1):\n ans+=(comb(N,i)*l[i])\nprint(ans)", "import operator as op\nfrom functools import reduce\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\ndef countDer(n): \n der = [0 for i in range(n + 10)] \n der[0] = 1\n der[1] = 0\n der[2] = 1\n for i in range(3, n + 1): \n der[i] = (i - 1) * (der[i - 1] + der[i - 2]) \n return der[n] \nn, k = map(int, input().split())\nans = 0\nfor i in range(n - k, n + 1):\n ans += ncr(n, i) * countDer(n - i)\nprint(int(ans))\n\t\t \t \t\t \t\t\t \t \t\t\t \t \t", "import math\r\nn, k = map(int, input().split())\r\nx = [1,0,1,2,9]\r\nans = 0\r\nfor i in range(0, k + 1):\r\n ans += math.comb(n, i) * x[i]\r\nprint(ans)", "import math\r\nn, k = input ().split ()\r\nn = int (n)\r\nk = int (k)\r\nf = [0] * 5\r\nf[1] = 0\r\nf[2] = 1\r\nf[3] = 2\r\nf[4] = 9\r\nans = 1\r\nfor i in range (1, k + 1):\r\n ans += math.comb (n, i) * f[i]\r\nprint (ans)\r\n", "n,k=map(int,input().split())\r\nif k==1:\r\n print(1)\r\nelif k==2:\r\n print(n*(n-1)//2+1)\r\nelif k==3:\r\n print(n*(n-1)*(n-2)//3+n*(n-1)//2+1)\r\nelif k==4:\r\n print(9*n*(n-1)*(n-2)*(n-3)//24+n*(n-1)*(n-2)//3+n*(n-1)//2+1)", "fact = [0] * 1001\r\nfact[0] = 1\r\nfor i in range(1, 1001):\r\n fact[i] = fact[i - 1] * i\r\nn, k = map(int, input().split())\r\nmess = [0] * 1001\r\n\r\ndef get_mess(x, fact):\r\n ans = 0\r\n for i in range(0, x + 1):\r\n sign = 1 - 2 * (i % 2)\r\n ans = ans + sign * (fact[x] // fact[i])\r\n return ans\r\nm = n - k\r\nans = 0\r\nfor i in range(m, n + 1):\r\n ans += get_mess(n - i, fact) * (fact[n] // fact[i] // fact[n - i])\r\nprint(ans)\r\n\r\n \r\n \r\n\n# Tue Nov 09 2021 16:29:46 GMT+0000 (Coordinated Universal Time)\n", "import sys\r\ninput = sys.stdin.readline \r\n\r\nn, k = map(int, input().split()) \r\nd = {0 : 1, 1 : 0, 2 : n * (n - 1) // 2, 3 : n * (n - 1) * (n - 2) // 3 , 4 : n * (n - 1) * (n - 2) * (n - 3) // 8 * 3} \r\nans = 0\r\nfor i in range(k + 1):\r\n ans += d[i] \r\nprint(ans)", "import sys\ninput = sys.stdin.readline\nimport math\n\n\ndef solve(n, k):\n # combinatorics\n res = {}\n res[(n, 0)] = 1\n res[(n, 1)] = 0\n res[(n, 2)] = n*(n-1)//2\n res[(n, 3)] = 2*n*(n-1)*(n-2)//6\n res[(n, 4)] = 9*n*(n-1)*(n-2)*(n-3)//24\n ans = 0\n for i in range(k+1):\n ans += res[(n, i)]\n print(ans)\n\n\nn, k = map(int, input().split())\nsolve(n, k)", "#almost identity permutations\r\nimport math\r\nn, k = map(int, input().split(\" \"))\r\n# nck and number of derangements\r\n''' since k is btw 0 to 4 we may have 1,0,1,2,9'''\r\n\r\ndef combination(n,r):\r\n\tnpr = math.factorial(n)//math.factorial(r)\r\n\tncr = npr/(math.factorial(n-r))\r\n\treturn int(ncr)\r\ndp = [1,0,1,2,9]\r\ntem = 0\r\nfor _ in range(k+1):\r\n\r\n\ttem += dp[_]*combination(n, _)\r\n\r\nprint(tem)\r\n", "\r\nn,k=[int(i) for i in input().split()]\r\n\r\nans=1\r\nif k>=2:\r\n ans+=n*(n-1)/2\r\nif k>=3:\r\n ans+=n*(n-1)*(n-2)/3\r\nif k>=4:\r\n ans+=(n*(n-1)*(n-2)*(n-3)/24)*9\r\nprint(int(ans)) \r\n", "n, k = map(int, input().split())\r\ndef derangement (n):\r\n if n == 0 or n == 2:\r\n return 1\r\n if n == 1:\r\n return 0\r\n return (n - 1) * (derangement(n-1) + derangement(n-2))\r\nf = [derangement (i) for i in range(k+1)]\r\n\r\ndef C(n, m):\r\n z = 1\r\n for i in range(m):\r\n z = z * (n - i) // (i + 1)\r\n return z\r\n\r\n\r\nans = 0\r\nfor i in range(k + 1):\r\n ans += C(n, i) * f[i]\r\n\r\nprint(ans)", "import math\r\n\r\ndef ncr(n, r):\r\n n = int(n)\r\n r = int(r)\r\n return math.factorial (n) // (math.factorial (r) * math.factorial(n-r))\r\n\r\n\r\nM = 1000000007\r\nn, k = input().split()\r\nn = int(n)\r\nk = int(k)\r\nd = [0]*5\r\nd[0] = 1\r\nd[1] = 0\r\nfor i in range(2, 5):\r\n d[i] = (i-1)*(d[i-1] + d[i-2])\r\nans = 0\r\nfor i in range(0, k+1):\r\n ans += ncr(n, i)*d[i]\r\nprint(ans)\r\n \r\n", " ###### ### ####### ####### ## # ##### ### ##### \r\n # # # # # # # # # # # # # ### \r\n # # # # # # # # # # # # # ### \r\n ###### ######### # # # # # # ######### # \r\n ###### ######### # # # # # # ######### # \r\n # # # # # # # # # # #### # # # \r\n # # # # # # # ## # # # # # \r\n ###### # # ####### ####### # # ##### # # # # \r\n \r\nfrom __future__ import print_function # for PyPy2\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\n# from collections import *\r\nfrom sys import stdin\r\n# from bisect import *\r\n# from heapq import *\r\nfrom math import log2, ceil, sqrt, gcd, log\r\n \r\ng = lambda : stdin.readline().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, k = gil()\r\nf = [0, 0, n*(n-1)]\r\nf.append(f[-1]*(n-2))\r\nf.append(f[-1]*(n-3))\r\nfc = [1, 1, 2, 6, 24]\r\n\r\nans = [1, 0]\r\nminus = [0, 0, 1, 4, 15]\r\n\r\nfor i in range(2, k+1):\r\n ans.append((f[i]*(fc[i]-minus[i]))//fc[i])\r\n\r\nprint(sum(ans))\r\n\r\n", "n,k=map(int,input().split())\r\nprint(sum([1,0,n*(n-1)//2,n*(n-1)*(n-2)//3,n*(n-1)*(n-2)*(n-3)*3//8][:k+1]))", "n, k = map(int, input().split())\r\nans = 1\r\nif k >= 1:\r\n ans += 0\r\nif k >= 2:\r\n ans += n * (n - 1) // 2\r\nif k >= 3:\r\n ans += 2 * n * (n - 1) * (n - 2) // 6\r\nif k >= 4:\r\n ans += 9 * n * (n - 1) * (n - 2) * (n - 3) // 24\r\nprint(ans)", "a,b=map(int,input().split())\r\ns=1\r\nif b>=2:\r\n s+=a*(a-1)>>1 \r\nif b>=3:\r\n s+=a*(a-1)*(a-2)/3 \r\nif b==4:\r\n s+=3*a*(a-1)*(a-2)*(a-3)>>3\r\n\r\nprint(int(s))\r\n", "# Сложность по времени O(1)\r\n# Сложность по памяти O(1)\r\n\r\nn, k = map(int, input().split())\r\nk = min(n, k)\r\na = [0] * 4\r\na[0] = 1\r\na[1] = n * (n - 1) // 2\r\na[2] = a[1] * (n - 2) // 3\r\na[3] = a[2] * (n - 3) // 4\r\n\r\na[2] *= 2\r\na[3] *= 9\r\ns = 0\r\nfor i in range(k):\r\n s += a[i]\r\nprint(s)", "n = [int(i) for i in input().split()]\nr = [0 for i in range(4)]\nr[0] = 1\nr[1] = n[0]*(n[0]-1)//2\nr[2] = n[0]*(n[0]-1)*(n[0]-2)//3\nr[3] = (9*n[0]*(n[0]-1)*(n[0]-2)*(n[0]-3))//(4*3*2)\nsum1 = 0\nfor i in range(n[1]):\n\tsum1+=r[i]\nprint(sum1)", "import sys\r\nfrom math import factorial\r\nfrom functools import reduce\r\nfrom operator import mul\r\n\r\nn, k = map(int, input().split())\r\nmontmort = [0, 0, 1, 2, 9]\r\n\r\nans = 1\r\nfor x in range(2, k+1):\r\n ans += reduce(mul, range(n, n-x, -1), 1) // factorial(x) * montmort[x]\r\n\r\nprint(ans)\r\n", "import math\r\nn,k = map(int,input().split())\r\nder = [0 for i in range(1000 + 1)]\r\n \r\nder[1] = 0\r\nder[0] = 1\r\n\r\n \r\nfor i in range(2, n + 1):\r\n der[i] = (i - 1) * (der[i - 1] + der[i - 2])\r\nans = 0\r\nfor t in range(n-k,n+1):\r\n bin = math.factorial(n)//(math.factorial(t)*math.factorial(n-t))\r\n \r\n ans += bin*der[n-t]\r\nprint(ans)\r\n\r\n", "dp = []\r\nder = [0,0,1,2,9]\r\ndef comb(n,r):\r\n global dp\r\n #print(\"{} {}\".format(n,r))\r\n if n==r or r==0: return 1\r\n if dp[n][r] != 0: return dp[n][r]\r\n dp[n][r] = comb(n-1,r) + comb(n-1,r-1)\r\n dp[n][n-r] = dp[n][r]\r\n return dp[n][r]\r\nn,k = map(int,input().split())\r\nif k==1:\r\n print(1)\r\n exit(0)\r\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\r\nans = 0\r\nfor i in range(n-k,n-1):\r\n ans = ans + comb(n,i)*der[n-i]\r\nprint(ans+1)", "n, k = map(int, input().split())\r\nc = lambda i: c(i - 1) * (n - i + 1) // i if i else 1\r\nprint(sum([1, c(2), 2 * c(3), 9 * c(4)][:k]))", "import math\r\n\r\nn,k = map(int, input().split())\r\n\r\ns = 0\r\n\r\nif(k==4):\r\n s = s + (math.factorial(n)/(math.factorial(k)*math.factorial(n-k)))*9\r\n k = k - 1\r\n\r\nif(k==3):\r\n s = s + (math.factorial(n)/(math.factorial(k)*math.factorial(n-k)))*2\r\n k = k - 1\r\n\r\nif(k==2):\r\n s = s + (math.factorial(n)/(math.factorial(k)*math.factorial(n-k)))\r\n k = k - 1\r\n\r\nif(k==1):\r\n k = k - 1\r\n\r\nif(k==0):\r\n s = s + 1\r\n\r\nprint(int(s))", "import math;\r\n\r\nn , k = map(int , input().split())\r\n\r\n\r\ndp = [ 1, (n*(n-1)) // 2, (n*(n-1)*(n-2)*2)//6 , (n*(n-1)*(n-2)*(n-3)*9)//24];\r\n\r\n\r\nans = 0;\r\nfor i in range(0,k):\r\n ans+=dp[i];\r\nprint(ans)\r\n", "n,k=map(int, input().split())\r\n\r\n\r\nres=1\r\n\r\nif k>=2:\r\n res += n*(n-1)/2\r\nif k>=3:\r\n res += n*(n-1)*(n-2)/3\r\nif k>=4:\r\n res += n*(n-1)*(n-2)*(n-3)/24*9\r\n\r\nprint(int(res))", "n, k = map(int, input().split())\nif k == 1:\n print(1)\nelif k == 2:\n print(1 + n * (n - 1) // 2)\nelif k == 3:\n print(1 + n * (n - 1) * (n - 2) // 3 + n * (n - 1) // 2)\nelse:\n print(1 + n * (n - 1) // 2 + n * (n - 1) * (n - 2) // 3 + 3 * n * (n - 1) * (n - 2) * (n - 3) // 8)", "n,k=map(int,input().split())\r\na=[0,0,1,2,9]\r\ns=0\r\nfor i in range(1,k+1):\r\n x=1\r\n y=1\r\n p=n\r\n for j in range(1,i+1):\r\n x=x*j\r\n y=y*p\r\n p-=1\r\n s+=(y//x)*a[i]\r\nprint(s+1)", "import math\r\nfrom itertools import *\r\n\r\ndef f(n, k):\r\n return math.factorial(n) // math.factorial(n - k) // math.factorial(k)\r\n\r\nn, k = map(int, input().split())\r\nans = 1\r\nfor i in range(2, k + 1):\r\n s = ''\r\n for j in range(i):\r\n s += str(j + 1)\r\n p = 0\r\n for it in permutations(s):\r\n h = True\r\n for j in range(len(s)):\r\n if int(it[j]) - 1 == j:\r\n h = False\r\n break\r\n if h:\r\n p += 1\r\n ans += f(n, n - i) * p\r\nprint(ans)", "def nCr(n,r):\n p = 1\n for i in range(n,n-r,-1):\n p*=i\n for i in range(1,r+1):\n p//=i\n return p\n\nn,k = list(map(int,input().split()))\nout = 1\nif k>=2:\n out += nCr(n,2)\nif k>=3:\n out += 2*nCr(n,3)\nif k==4:\n out += 9*nCr(n,4)\nprint(out)", "from math import factorial\r\ndef comb(n, r):\r\n if(r ==1 ):\r\n return n\r\n elif(r == 2):\r\n return (n * (n - 1)) // 2\r\n elif(r == 3):\r\n return (n * (n -1) * (n - 2))//6\r\n else:\r\n return (n * (n- 1) * (n-2) * (n-3))//24\r\ndef derange(n):\r\n if(n == 1):\r\n return 0\r\n elif(n == 2):\r\n return 1\r\n elif(n == 3):\r\n return 2\r\n elif(n == 4):\r\n return 9\r\nn,k = map(int,input().split())\r\n\r\nans = 0\r\nfor i in range(1, k+1):\r\n ans += comb(n, i) * int(derange(i))\r\nprint(ans+1)", "from math import factorial as fact\r\nn, k = map(int, input().split())\r\nans = 1\r\nwhile k != 1:\r\n if k == 4:\r\n ans += 9 *(fact(n)//(fact(k) * fact(n-k)))\r\n elif k == 3:\r\n ans += 2 *(fact(n)//(fact(k) * fact(n-k)))\r\n else:\r\n ans += (fact(n)//(fact(k) * fact(n-k)))\r\n k -= 1\r\nprint(ans)", "from math import comb\r\n\r\nn,k = map(int, input().split())\r\nd = [0,0,1,2,9]\r\nc = 1\r\n\r\nfor i in range(2, k+1):\r\n c += d[i] * comb(n,i)\r\n\r\nprint(c)", "d = [0, 0, 1, 2, 9]\r\n\r\ndef C(n, k):\r\n res = 1\r\n for i in range(1, k + 1):\r\n res = (res * (n + 1 - i)) // (i)\r\n return res\r\n\r\nn, k = map(int, input().split())\r\nres = 1\r\nfor i in range(k + 1):\r\n res += C(n, i) * d[i]\r\n\r\nprint(res)\r\n", "from math import comb\r\n\r\n# can't think of better names\r\nn, k = [int(i) for i in input().split()]\r\n\r\n# only need to get 4, so might as well hardcode it\r\ndisjoint_num = [1, 0, 1, 2, 9]\r\n\r\ntotal = 0\r\nfor i in range(k + 1):\r\n keep_same = n - i\r\n curr_disjoint = disjoint_num[i]\r\n config_num = comb(n, keep_same)\r\n total += config_num * curr_disjoint\r\n\r\nprint(total)\r\n\r\n\"\"\"\r\n0, 1\r\n1, 0\r\n\"\"\"\r\n", "n,k=map(int,input().split())\r\na=1\r\nb=0\r\nc=n*(n-1)//2\r\nd=n*(n-1)*(n-2)//3\r\ne=n*(n-1)*(n-2)*(n-3)*3//8\r\narr=[a,b,c,d,e]\r\nans=0\r\nfor i in range(k+1):\r\n ans+=arr[i]\r\nprint(ans)", "import sys\r\ninput=sys.stdin.readline\r\nfrom math import *\r\nn,k=map(int,input().split())\r\ndef cof(n, k): \r\n C = [[0 for x in range(k+1)] for x in range(n+1)] \r\n\r\n for i in range(n+1): \r\n for j in range(min(i, k)+1): \r\n\r\n if j == 0 or j == i: \r\n C[i][j] = 1\r\n\r\n else: \r\n C[i][j] = C[i-1][j-1] + C[i-1][j] \r\n \r\n return C[n][k] \r\ndef deran(n,der): \r\n\r\n der[0] = 1\r\n der[1] = 0\r\n der[2] = 1\r\n\r\n for i in range(3, n + 1): \r\n der[i] = (i - 1) * (der[i - 1] + der[i - 2]) \r\n \r\n return der[n]\r\n \r\nc=0\r\nder=[0 for i in range(n+10)]\r\nderan(n,der)\r\nfor i in range(k+1): \r\n p=cof(n,n-i)\r\n c+=p*der[i]\r\nprint(c) \r\n ", "n,k=list(map(int,input().split()))\r\nprint(1 if k==1 else n*(n-1)//2+1 if k==2 else n*(n-1)*(n-2)//3+n*(n-1)//2+1 if k==3 else n*(n-1)*(n-2)*(n-3)*9//24+n*(n-1)*(n-2)//3+n*(n-1)//2+1)\r\n", "n, k = map(int, input().split())\r\ntot = 1\r\nif k > 1: tot += n*(n-1)//2\r\nif k > 2: tot += n*(n-1)*(n-2)//3\r\nif k > 3: tot += n*(n-1)*(n-2)*(n-3)//24*9\r\nprint(tot)", "n, k = map(int, input().split()) \r\nans = 1 \r\nget = n\r\ns = [0, 1, 1, 2, 9]\r\nfor i in range(2, k + 1):\r\n get = get*(n - i + 1)//i\r\n ans += get*s[i]\r\nprint(ans)", "#https://en.wikipedia.org/wiki/Derangement\r\nfrom math import comb\r\nn,k=map(int,input().strip().split())\r\nans=0\r\nfor i in range(k+1):\r\n if i==0:\r\n ans+=1\r\n if i==2:\r\n ans+=comb(n,2)*1\r\n if i==3:\r\n ans+=comb(n,3)*2\r\n if i==4:\r\n ans+=comb(n,4)*9\r\nprint(ans)\r\n", "a=input().split()\r\nn=int(a[0])\r\nk=int(a[1])\r\nc=1\r\nif k>1:\r\n c+=n*(n-1)//2\r\nif k>2:\r\n c+=n*(n-1)*(n-2)//3\r\nif k>3:\r\n c+=n*(n-1)*(n-2)*(n-3)//24*9\r\n \r\n \r\nprint(c)", "#!/usr/bin/python\n\nn,k = map(int, input().split())\nanswer=1\n\nif k>1:\n answer += n*(n-1)/2\nif k>2:\n answer += n*(n-1)*(n-2)/3\nif k>3:\n answer += n*(n-1)*(n-2)*(n-3)/24*9\n\nprint(int(answer))\n", "from math import *\r\n\r\ndef derangements(n):\r\n return floor(0.50 + factorial(n) / exp(1))\r\n \r\nn, k = map(int, input().split())\r\ntot = 1 + sum(comb(n, i) * derangements(i) for i in range(1, k+1))\r\n\r\nprint(tot)", "import sys\r\ninput = sys.stdin.readline\r\n\r\ndef comb(n, r):\r\n x, y = 1, 1\r\n for i in range(n, n - r, -1):\r\n x *= i\r\n y *= i + r - n\r\n return x // y\r\n\r\nx = [0, 0, 1, 2, 9]\r\nn, k = map(int, input().split())\r\nans = 1\r\nfor i in range(2, k + 1):\r\n ans += comb(n, i) * x[i]\r\nprint(ans)", "import queue\r\nfrom math import inf, gcd, floor, sqrt, ceil, log, log2, log10, factorial\r\nimport sys\r\nfrom collections import *\r\nfrom random import *\r\nimport itertools\r\n\r\nsys.setrecursionlimit(99999)\r\n#sys.stdin = open(\"input.txt\", 'r') # for debug purpose\r\neps = sys.float_info.epsilon\r\nP = 2\r\nINF = 1e9 + 1\r\nMOD = 998244353\r\n\r\n\r\ndef is_prime(n):\r\n if n == 0 or n == 1:\r\n return False\r\n d = 2\r\n while d * d <= n:\r\n if n % d == 0:\r\n return False\r\n d += 1\r\n return True\r\n\r\n\r\ndef div_up(n, k):\r\n if n % k == 0:\r\n return n // k\r\n else:\r\n return n // k + 1\r\n\r\n\r\ndef num_len(n, base=10):\r\n if n == 0:\r\n return 1\r\n res = 0\r\n while n > 0:\r\n res += 1\r\n n //= 10\r\n return res\r\n\r\n\r\ndef down(a):\r\n for i in range(1, len(a)):\r\n if a[i] > a[i - 1]:\r\n return False\r\n return True\r\n\r\n\r\ndef up(a):\r\n for i in range(1, len(a)):\r\n if a[i] < a[i - 1]:\r\n return False\r\n return True\r\n\r\n\r\ndef code(c):\r\n return ord(c) - 32\r\n\r\n\r\ndef _hash_(s):\r\n res, p = 0, 1\r\n for i in range(len(s)):\r\n res += (code(s[i]) * p)\r\n res %= MOD\r\n p *= P\r\n p %= MOD\r\n return res % MOD\r\n\r\n\r\ndef remove_edge(v, u, graph):\r\n graph[v].remove(u)\r\n graph[u].remove(v)\r\n\r\n\r\ndef all_eq(a):\r\n for i in range(len(a) - 1):\r\n if a[i] != a[i + 1]:\r\n return False\r\n return True\r\n\r\n\r\ndef kmp(s, pr):\r\n n = len(s)\r\n pr[0] = 0\r\n for i in range(1, n):\r\n j = pr[i - 1]\r\n while j > 0 and s[i] != s[j]:\r\n j = pr[j - 1]\r\n if s[i] == s[j]:\r\n j += 1\r\n pr[i] = j\r\n\r\n\r\ndef lcm(a, b):\r\n return a * b // gcd(a, b)\r\n\r\n\r\ndef gcd_advanced(a, b):\r\n if a == 0:\r\n return 0, 1, b\r\n x1, y1, g = gcd_advanced(b % a, a)\r\n return y1 - x1 * (b // a), x1, g\r\n\r\n\r\ndef lowest(s):\r\n res = 0\r\n ret = ''\r\n while res + 9 <= s:\r\n res += 9\r\n ret += '9'\r\n if res == s:\r\n return ret\r\n return str(s - res) + ret\r\n\r\n\r\ndef C(k, n):\r\n res = 1\r\n for i in range(n - k + 1, n + 1):\r\n res *= i\r\n for i in range(1, k + 1):\r\n res //= i\r\n return res\r\n\r\n\r\ndef d(n):\r\n if n == 1:\r\n return 0\r\n if n == 2:\r\n return 1\r\n return (n - 1) * (d(n - 2) + d(n - 1))\r\n\r\n\r\ndef solve():\r\n n, k = map(int, input().split())\r\n k = n - k\r\n res = 1\r\n for i in range(k, n - 1):\r\n res += C(i, n) * d(n - i)\r\n print(res)\r\n# 1 2 4 3\r\n# 1 _ 3 _ _\r\n\r\n#for _ in range(int(input())):\r\nsolve()\r\n\r\n\r\ndef debug():\r\n pass\r\n\r\n\r\n#debug()", "def fac(k):\r\n res = 1\r\n for i in range(2, k + 1):\r\n res *= i\r\n return res\r\n\r\n\r\na = [1, 2, 9]\r\nn, k = list(map(int, input().split()))\r\nans = 1\r\nfor i in range(2, k + 1):\r\n cnt = 1\r\n for j in range(i):\r\n cnt *= (n - j)\r\n cnt //= fac(i)\r\n ans += cnt * a[i - 2]\r\nprint(ans)", "import math\nimport sys\n\nn, k_limit = [int(x) for x in sys.stdin.readline().strip().split(\" \")]\n\nn_fact = math.factorial(n)\n\ntotal = 1\nfor k in range(2, k_limit + 1):\n m = math.factorial(k)\n n_minus_m = math.factorial(n - k)\n combos = n_fact / (m * n_minus_m)\n derangement = math.floor(m / math.e + 0.5)\n #print(combos, derangement)\n total += combos * derangement\n\nprint(int(total))\n\t\t \t\t \t \t \t\t\t\t \t \t\t \t \t\t\t", "import itertools\n\ndef C(n, m):\n ret = 1\n for i in range(m):\n ret *= (n - i)\n for i in range(m):\n ret //= (i + 1)\n return ret\n\nn, k = map(int, input().split())\nd = [0] * (k + 1)\n\nfor m in range(k + 1):\n p = list()\n for i in range(m):\n p.append(i)\n pp = itertools.permutations(p)\n for permutation in pp:\n ok = True\n for i in range(m):\n if permutation[i] == i:\n ok = False\n break\n if ok: d[m] += 1\n\nans = 0\nfor m in range(k + 1):\n ans += C(n, m) * d[m]\nprint(ans)", "\r\nimport math\r\nfrom itertools import permutations\r\ndef ncr(n,r):\r\n return (math.factorial(n)//(math.factorial(r)*math.factorial(n-r)))\r\n\r\ndef left_one(left):\r\n temp=[x for x in range(left)]\r\n cnt=0\r\n allperm=list(permutations(temp))\r\n for x in allperm:\r\n chk=0\r\n for z in range(len(x)):\r\n if x[z]==z:\r\n chk=1\r\n break\r\n if chk==0:\r\n #print(x)\r\n cnt+=1\r\n return cnt\r\nn,k=map(int,input().split(\" \"))\r\nk=n-k\r\nans=1\r\nfor x in range(k,n):\r\n #print(left_one(n-x),ncr(n,x))\r\n # print(n-x)\r\n ans+=ncr(n,x)*left_one(n-x)\r\nprint(ans)\r\n", "import math\r\nn, k = map(int, input().split())\r\n# d[i] - количество перестановок из i элементов без неподвижных точек.\r\nd = [1, 0, 1, 2, 9]\r\nans = 0\r\nfor i in range(k + 1):\r\n ans += math.comb(n, n - i) * d[i]\r\nprint(ans)\r\n", "import sys\r\nimport math\r\ndef derange(k):\r\n\tans=math.factorial(k)\r\n\tz=-1\r\n\tmult=1\r\n\tfor i in range(1,k+1):\r\n\t\tmult += z * (1/(math.factorial(i)))\r\n\t\tz *= -1\r\n\tans=ans*mult\r\n\t#print(ans,'ans')\r\n\treturn int(ans)\r\ndef com(n,k):\r\n\tif k==0:\r\n\t\treturn 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\tif k==3:\r\n\t\treturn n*(n-1)*(n-2)//6\r\n\treturn n*(n-1)*(n-2)*(n-3)//24\r\nn,k=map(int,sys.stdin.readline().split())\r\nans=0\r\nfor i in range(k+1):\r\n\tx = com(n,i)*derange(i)\r\n\tans += x\r\nprint(ans)", "n, k = map(int, input().split())\nans = 0\nfor i in range(k+1):\n\tif (i==1):\n\t\tans += 1\n\telif (i==2):\n\t\tans += (n*(n-1))/2\n\telif (i==3):\n\t\tans += 2*(n*(n-1)*(n-2))/6\n\telif (i==4):\n\t\tans += 9*(n*(n-1)*(n-2)*(n-3))/24\nprint(int(ans))", "import math\r\ndef calculate_derangement(fac, n):\r\n\tans = fac[n]\r\n\tfor i in range(1, n+1):\r\n\t\tif i % 2 == 1:\r\n\t\t\tans -= fac[n]//fac[i]\r\n\t\telse:\r\n\t\t\tans += fac[n]//fac[i]\r\n\treturn ans\r\n\r\nn, k = map(int, input().split())\r\nfac = [1]\r\nfor i in range(1, n+1):\r\n\tfac.append(fac[i-1]*i)\r\nans = 0\r\nfor i in range(0, k+1):\r\n\tchoose = fac[n]\r\n\tchoose //= fac[i]\r\n\tchoose //= fac[n-i]\r\n\tans += choose*calculate_derangement(fac, i)\r\n\r\nprint(ans) ", "#-*-coding:utf8;-*-\r\n#qpy:3\r\n#qpy:console\r\n\r\nd=input()\r\nn=int(d.split(' ')[0])\r\nk=int(d.split(' ')[1])\r\ndef c(a,b):\r\n s=1\r\n for i in range(b):\r\n s*=a-i\r\n s/=i+1\r\n return int(s)\r\ndizi=[-1,0,1,2,9]\r\nson=0\r\nfor i in range(k,1,-1):\r\n son+=c(n,i)*dizi[i]\r\nprint(son+1)\r\n", "#Bhargey Mehta (Sophomore)\r\n#DA-IICT, Gandhinagar\r\nimport sys, math, queue, bisect\r\n#sys.stdin = open(\"input.txt\", \"r\")\r\nMOD = 10**9+7\r\nsys.setrecursionlimit(1000000)\r\n\r\nn, k = map(int, input().split())\r\nif k == 1:\r\n print(1)\r\nelif k == 2:\r\n ans = 1 + (n*(n-1))//2\r\n print(ans)\r\nelif k == 3:\r\n ans = 1 + (n*(n-1))//2 + (n*(n-1)*(n-2))//3\r\n print(ans)\r\nelse:\r\n ans = 1 + (n*(n-1))//2 + (n*(n-1)*(n-2))//3 + 9*((n*(n-1)*(n-2)*(n-3))//24)\r\n print(ans)", "import sys\r\ninput = sys.stdin.readline\r\ninf = float('inf')\r\ndef arr_in():\r\n return list(map(int, input().split()))\r\n\r\ndef tup_in():\r\n return map(int, input().split())\r\n\r\n\"\"\"\r\n--- Notes ---\r\n- k >= 1:\r\n+1\r\n- k >= 2:\r\ntranspositions:\r\nn choose 2\r\n- k >= 3:\r\n1 2 3\r\n\r\n3 1 2\r\n2 3 1\r\nn choose 3 * 2?\r\n- k >= 4:\r\n1 2 3 4\r\n\r\n2 3 4 1\r\n3 4 1 2\r\n4 1 2 3\r\n2 1 4 3\r\n4 3 2 1\r\n\"\"\"\r\n\r\ndef solution():\r\n n, k = tup_in()\r\n ans = 0\r\n if k >= 1:\r\n ans += 1\r\n if k >= 2:\r\n ans += (n * (n - 1)) // 2\r\n if k >= 3:\r\n ans += (2 * n * (n - 1) * (n - 2)) // 6\r\n if k >= 4:\r\n ans += (9 * n * (n - 1) * (n - 2) * (n - 3)) // 24\r\n print(ans)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n solution()", "# region declaration\nfrom collections import *\nfrom functools import *\nfrom math import *\nfrom heapq import *\nfrom itertools import *\nfrom bisect import *\n\n# autopep8: off\ndef floatl(): return (list(map(float, input().split())))\ndef inlt(): return (list(map(int, input().split())))\ndef inp(): return int(input())\ndef ins(): return str(input())\ndef insr(): return list(input())\ndef invr(): return (map(int, input().split()))\ndef yesno(predicate): print(\"Yes\" if predicate else \"No\")\nMOD = 998244353\nINF = inf\n# autopep8: on\n# endregion\n\n\ndef derangement(n, m):\n if m == 1:\n return 0\n der = 0\n for i in range(m+1):\n der += factorial(m) * (-1 if i % 2 else 1) // factorial(i)\n return comb(n, m) * der\n\n\ndef solve():\n n, k = inlt()\n return 1+sum(derangement(n, i) for i in range(2, k+1))\n\n\nt = 1\n# t = inp()\nfor _ in range(t):\n print(solve())\n", "def f(n,k):\r\n c = [1,0,0,0,0,0]\r\n c[2] = n*(n-1)//2\r\n c[3] = n*(n-1)*(n-2)//3\r\n c[4] = n*(n-1)*(n-2)*(n-3)*3//8\r\n return sum(c[:k+1])\r\n\r\nn,k = map(int,input().split())\r\nprint(f(n,k))\r\n", "def fall_fac(n,k):\r\n\tans = 1\r\n\tfor i in range(k):\r\n\t\tans *= n-i\r\n\treturn ans\r\ndef C(n,k):\r\n\tif not(0 <= k <= n):\r\n\t\treturn 0\r\n\telse:\r\n\t\treturn fall_fac(n,k)//fall_fac(k,k)\r\ndef derangement(n):\r\n\tif n==0:\r\n\t\treturn 1\r\n\telif n==1:\r\n\t\treturn 0\r\n\telse:\r\n\t\treturn (n-1)*(derangement(n-1)+derangement(n-2))\r\nn, k = [int(x) for x in input().split()]\r\nprint(sum([C(n,i)*derangement(i) for i in range(k+1)]))", "import math\r\nn,k = map(int ,input().split())\r\nx = [1,0,1,2,9]\r\nans = 0\r\nfor i in range(0,k+1):\r\n ans += math.comb(n,i)*x[i]\r\nprint(ans)\r\n", "import math\r\n\r\nn, k = map(int, input().split())\r\nif k == 1:\r\n print(1)\r\n exit()\r\n\r\n\r\ndef ways_to_choose(cnt) -> int:\r\n product = 1\r\n for i in range(cnt):\r\n product *= (n - i)\r\n return product // math.factorial(cnt)\r\n\r\n\r\nmontmort = [0] * (k + 1)\r\nmontmort[2] = 1\r\nfor i in range(3, k + 1):\r\n montmort[i] = (i - 1) * (montmort[i - 1] + montmort[i - 2])\r\n\r\nres = 1 + sum(ways_to_choose(i) * montmort[i] for i in range(2, k + 1))\r\nprint(res)\r\n", "from math import comb\r\nn,m = map(int,input().split())\r\nl = [1,0,1,2,9]\r\nans = 1\r\nfor i in range(2,m+1):\r\n ans+=comb(n,i)*l[i]\r\nprint(ans)", "def C(n, k):\n\tres = 1\n\t\n\tfor i in range(1, k + 1):\n\t\tres *= (n - i + 1)\n\tfor i in range(2, k + 1):\n\t\tres //= i\n\n\treturn res\n\n\nif __name__ == \"__main__\":\n\tn, k = map(int, input().split())\n\tans = 1\n\tval = {\n\t\t1: 1,\n\t\t2: 2,\n\t\t3: 9,\n\t}\n\n\tfor i in range(k, 1, -1):\n\t\tans += val[(i - 1)] * C(n, i)\n\n\tprint(ans)\n", "def countDer(n):\r\n\r\n der = [0 for i in range(max(3,(n + 1)))]\r\n\r\n # Base cases\r\n der[0] = 1\r\n der[1] = 0\r\n der[2] = 1\r\n\r\n\r\n for i in range(3, n + 1):\r\n der[i] = (i - 1) * (der[i - 1] +\r\n der[i - 2])\r\n\r\n return der[n]\r\n\r\n\r\ndef nCr(n, r):\r\n return (fact(n) / (fact(r)\r\n * fact(n - r)))\r\n\r\n\r\n# Returns factorial of n\r\ndef fact(n):\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\nn,k=map(int,input().split())\r\nj=(n-k)\r\ns=0\r\nwhile(j<=n):\r\n s+=(nCr(n,j)*(countDer(n-j)))\r\n j+=1\r\nprint(int(s))\r\n" ]
{"inputs": ["4 1", "4 2", "5 3", "5 4", "200 1", "200 2", "200 3", "200 4", "400 1", "400 2", "400 3", "400 4", "600 1", "600 2", "600 3", "600 4", "800 1", "800 2", "800 3", "800 4", "1000 1", "1000 2", "1000 3", "1000 4", "4 4"], "outputs": ["1", "7", "31", "76", "1", "19901", "2646701", "584811251", "1", "79801", "21253401", "9477912501", "1", "179701", "71820101", "48187303751", "1", "319601", "170346801", "152620985001", "1", "499501", "332833501", "373086956251", "24"]}
UNKNOWN
PYTHON3
CODEFORCES
118
e081729c9849ecde07bd53798955d477
Lorry
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres). Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body. The first line contains a pair of integer numbers *n* and *v* (1<=≤<=*n*<=≤<=105; 1<=≤<=*v*<=≤<=109), where *n* is the number of waterborne vehicles in the boat depot, and *v* is the truck body volume of the lorry in cubic metres. The following *n* lines contain the information about the waterborne vehicles, that is a pair of numbers *t**i*,<=*p**i* (1<=≤<=*t**i*<=≤<=2; 1<=≤<=*p**i*<=≤<=104), where *t**i* is the vehicle type (1 – a kayak, 2 – a catamaran), and *p**i* is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file. In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them. Sample Input 3 2 1 2 2 7 1 3 Sample Output 7 2
[ "r=lambda:map(int,input().split())\r\n[n,v]=r()\r\nt=[]\r\no=[]\r\nfor i in range(n):\r\n\t[tp,p]=r()\r\n\tif tp==1: o+=[[p,i]]\r\n\telse: t+=[[p,i]]\r\nt.sort(reverse=True)\r\no.sort(reverse=True)\r\nnt=len(t)\r\nno=len(o)\r\nfor i in range(1,nt): t[i][0]+=t[i-1][0]\r\nfor i in range(1,no): o[i][0]+=o[i-1][0]\r\na=[0,0,0]\r\nfor i in range(v+1):\r\n\tif i>no: break\r\n\tj=min(nt, (v-i)//2)\r\n\tr=0\r\n\tif i: r+=o[i-1][0]\r\n\tif j: r+=t[j-1][0]\r\n\ta=max(a,[r,i,j])\r\nprint (a[0])\r\nfor i in range(a[1]): print (o[i][1]+1)\r\nfor i in range(a[2]): print (t[i][1]+1)", "n, v = list(map(int, input().split()))\r\n\r\nkay = []\r\ncat = []\r\nkayo = []\r\ncato = []\r\n\r\nfor i in range(n):\r\n t, c = list(map(int, input().split()))\r\n if t == 1:\r\n kay.append(c)\r\n kayo.append(str(i+1))\r\n else:\r\n cat.append(c)\r\n cato.append(str(i+1))\r\n\r\ndef sorting(arr, order):\r\n if len(arr) > 1:\r\n mid = len(arr) // 2\r\n\r\n L = arr[:mid]\r\n R = arr[mid:]\r\n\r\n Lo = order[:mid]\r\n Ro = order[mid:]\r\n\r\n sorting(L, Lo)\r\n sorting(R, Ro)\r\n\r\n i = j = k = 0\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 order[k] = Lo[i]\r\n i += 1\r\n else:\r\n arr[k] = R[j]\r\n order[k] = Ro[j]\r\n j += 1\r\n k += 1\r\n \r\n while i < len(L):\r\n arr[k] = L[i]\r\n order[k] = Lo[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 order[k] = Ro[j]\r\n j += 1\r\n k += 1\r\n\r\nsorting(kay, kayo)\r\nsorting(cat, cato)\r\n\r\nfor i in range(1, len(kay)):\r\n kay[i] += kay[i-1]\r\nfor i in range(1, len(cat)):\r\n cat[i] += cat[i-1]\r\nlenkay = len(kay)\r\nlencat = len(cat)\r\nkay.insert(0, 0)\r\ncat.insert(0, 0)\r\n\r\nans = 0\r\ntotkay = 0\r\ntotcat = 0\r\nfor i in range(lencat+1):\r\n c = 2 * i\r\n\r\n if c > v:\r\n break\r\n rem = v - c\r\n if rem < 0:\r\n break\r\n if rem > lenkay:\r\n rem = lenkay\r\n tot = cat[i] + kay[rem]\r\n if tot >= ans:\r\n ans = tot\r\n totkay = rem\r\n totcat = i\r\n\r\nprint(ans)\r\nif totkay > 0 and totcat > 0:\r\n dummy = kayo[:totkay]\r\n dummy.extend(cato[:totcat])\r\n print(' '.join(dummy))\r\nelif totkay == 0 and totcat > 0:\r\n print(' '.join(cato[:totcat]))\r\nelif totkay > 0 and totcat == 0:\r\n print(' '.join(kayo[:totkay]))\r\nelse:\r\n print('')", "def f(x):\n\treturn x[1]\n\ns = input().split(' ')\nk = []\nc = []\n\nloops = int(s[0])\nvol = int(s[1])\n\nfor i in range(loops):\n\ts = input().split(' ')\n\tt = int(s[0])\n\tif(t == 1): k.append([i+1,int(s[1])])\n\telse: c.append([i+1,int(s[1])])\n\nk.sort(reverse=True,key=f)\nc.sort(reverse=True,key=f)\n\nnum = 0\nlst = []\naccvol = vol\nci = 0\nki = 0\n\nwhile accvol > 0:\n\tif accvol > 1:\n\t\tif ki > len(k)-1 and ci > len(c)-1:\n\t\t\tbreak\n\t\telif ki+1 > len(k)-1 and ci > len(c)-1:\n\t\t\tnum += k[ki][1]\n\t\t\taccvol -= 1\n\t\t\tlst.append(str(k[ki][0]))\n\t\t\tki += 1\n\t\telif ki+1 > len(k)-1:\n\t\t\tnum += c[ci][1]\n\t\t\taccvol -= 2\n\t\t\tlst.append(str(c[ci][0]))\n\t\t\tci += 1\n\t\telif ci > len(c)-1:\n\t\t\tnum += k[ki][1]\n\t\t\taccvol -= 1\n\t\t\tlst.append(str(k[ki][0]))\n\t\t\tki += 1\n\t\telse:\n\t\t\tif c[ci][1] > k[ki][1]+k[ki+1][1]:\n\t\t\t\tnum += c[ci][1]\n\t\t\t\taccvol -= 2\n\t\t\t\tlst.append(str(c[ci][0]))\n\t\t\t\tci += 1\n\t\t\telse:\n\t\t\t\tnum += k[ki][1]\n\t\t\t\taccvol -= 1\n\t\t\t\tlst.append(str(k[ki][0]))\n\t\t\t\tki += 1\n\telif not (ki > len(k)-1):\n\t\tnum += k[ki][1]\n\t\taccvol -= 1\n\t\tlst.append(str(k[ki][0]))\n\t\tki += 1\n\telse:\n\t\tbreak\n\nprint(int(num))\nprint(' '.join(lst))", "n, v = map(int, input().split())\r\np, t = [], []\r\nfor i in range(1, n + 1):\r\n a, b = map(int, input().split())\r\n t.append((b * (3 - a), a, b, i))\r\nt.sort(reverse = True)\r\na = b = i = 0\r\nwhile i < n and a < v:\r\n a += t[i][1]\r\n b += t[i][2]\r\n p.append(t[i][3])\r\n i += 1\r\nif a > v:\r\n i, j, k = i - 1, i - 2, i\r\n while j >= 0 and t[j][1] > 1: j -= 1\r\n while k < n and t[k][1] > 1: k += 1\r\n if j >= 0: \r\n if k < n:\r\n if t[j][2] + t[k][2] > t[i][2]: \r\n p[i] = t[k][3]\r\n b += t[k][2] - t[i][2]\r\n else:\r\n p.pop(j)\r\n b -= t[j][2]\r\n else:\r\n if t[j][2] > t[i][2]:\r\n p.pop()\r\n b -= t[i][2]\r\n else:\r\n p.pop(j)\r\n b -= t[j][2]\r\n elif k < n:\r\n p[i] = t[k][3]\r\n b += t[k][2] - t[i][2]\r\n else:\r\n p.pop()\r\n b -= t[i][2]\r\nprint(b)\r\nprint(' '.join(map(str, p)))", "n, v = [int(i) for i in input().split()]\r\na = []\r\nbai = []\r\nkat = []\r\nfor i in range(n):\r\n t = [int(j) for j in input().split()]\r\n if t[0] == 1:\r\n bai.append((-t[1], str(i + 1)))\r\n else:\r\n kat.append((-t[1], str(i + 1)))\r\nbai.sort(key=lambda i: i[0])\r\nkat.sort(key=lambda i: i[0])\r\ng = 0\r\nbi = 0\r\nki = 0\r\nif v % 2 == 1:\r\n if bi < len(bai) > 0:\r\n a.append(bai[bi][1])\r\n g = g + bai[bi][0]\r\n bi = bi + 1\r\n v = v - 1\r\nif (len(bai) - bi) % 2 == 1:\r\n bai.append((0, 0))\r\nwhile (v > 0) and (bi < len(bai)) and (ki < len(kat)):\r\n if bai[bi][0] + bai[bi + 1][0] < kat[ki][0]:\r\n g = g + bai[bi][0] + bai[bi + 1][0]\r\n a.append(bai[bi][1])\r\n a.append(bai[bi + 1][1])\r\n bi = bi + 2\r\n v = v - 2\r\n else:\r\n g = g + kat[ki][0]\r\n a.append(kat[ki][1])\r\n ki = ki + 1\r\n v = v - 2\r\nif len(bai) > bi:\r\n while (v > 0) and (len(bai) > bi):\r\n g = g + bai[bi][0] + bai[bi + 1][0]\r\n a.append(bai[bi][1])\r\n a.append(bai[bi + 1][1])\r\n bi = bi + 2\r\n v = v - 2\r\nelse:\r\n while (v > 0) and (len(kat) > ki):\r\n g = g + kat[ki][0]\r\n a.append(kat[ki][1])\r\n ki = ki + 1\r\n v = v - 2\r\nprint(-g)\r\nfor t in a:\r\n if t != 0:\r\n print(t)\r\n", "from heapq import nlargest\nfrom itertools import accumulate, chain\nimport sys\n\nn, v = map(int, sys.stdin.readline().split())\na1, a2 = [], []\ni1, i2 = [], []\nfor i in range(n):\n t, p = map(int, sys.stdin.readline().split())\n if t == 1:\n a1.append(p)\n i1.append(i)\n else:\n a2.append(p)\n i2.append(i)\nacc1 = list(accumulate(sorted(a1, reverse=True), initial=0))\nacc2 = list(accumulate(sorted(a2, reverse=True), initial=0))\nbest = (0, 0, 0)\nfor n2 in range(min(v // 2, len(a2)) + 1):\n n1 = min(v - 2 * n2, len(a1))\n best = max(best, (acc1[n1] + acc2[n2], n1, n2))\nans, n1, n2 = best\nsys.stdout.write(str(ans) + \"\\n\")\nii1 = sorted(range(len(a1)), key=a1.__getitem__)[len(a1) - n1 :]\nii2 = sorted(range(len(a2)), key=a2.__getitem__)[len(a2) - n2 :]\nsys.stdout.write(\" \".join(str(i1[i] + 1) for i in ii1))\nsys.stdout.write(\" \")\nsys.stdout.write(\" \".join(str(i2[i] + 1) for i in ii2))\nsys.stdout.write(\"\\n\")\n", "'''\r\nJana Goodman\r\n\r\nLorry\r\n\r\n use distribution of types of boats\r\n x + 2y <= volume where x, y = #kayaks, #catamarans\r\n\r\n'''\r\n\r\nimport time\r\nimport itertools\r\n\r\nKAYAK = 1\r\nCATAMARAN = 2\r\n\r\ndef get_boats(num_boats):\r\n kayaks, catamarans = list(), list()\r\n for boat_num in range(1, num_boats + 1):\r\n type_boat, cap = map(int, input().strip().split(' '))\r\n if type_boat == KAYAK:\r\n kayaks.append((cap, boat_num))\r\n else:\r\n catamarans.append((cap, boat_num))\r\n kayaks.sort(reverse=True)\r\n catamarans.sort(reverse=True)\r\n return kayaks, catamarans\r\n\r\ndef get_maxes(kayaks, catamarans, dists):\r\n# running totals of capacity for each type of boat\r\n cap_kayaks = [0] + list(itertools.accumulate([cap for cap, i in kayaks]))\r\n cap_catamarans = [0] + list(itertools.accumulate([cap for cap, i in catamarans]))\r\n\r\n max_capacity, max_x_y = -1, None\r\n for x, y in dists:\r\n capacity = cap_kayaks[x] + cap_catamarans[y]\r\n if capacity > max_capacity:\r\n max_capacity = capacity\r\n max_x_y = (x, y)\r\n print(max_capacity)\r\n\r\n x, y = max_x_y\r\n max_boats = [i for cap, i in kayaks[0:x]] \\\r\n + [i for cap, i in catamarans[0:y]]\r\n print(''.join(str(cap) + ' ' for cap in max_boats))\r\n\r\n\r\nif __name__ == '__main__':\r\n# start = time.time()\r\n num_boats, mx_vol = map(int, input().strip().split(' '))\r\n kayaks, catamarans = get_boats(num_boats)\r\n get_maxes(kayaks, catamarans,\r\n [(x, min(len(catamarans), (mx_vol - x) >> 1))\r\n for x in range(0, min(len(kayaks), mx_vol) + 1)])\r\n# print(f'Time elapsed: {time.time() - start}')", "def solve():\r\n n, v = map(int, input().split(' '))\r\n l = [[], []]\r\n for i in range(n):\r\n x, y = map(int, input().split(' '))\r\n l[x - 1].append([y, i])\r\n for i in range(2):\r\n l[i].sort(reverse = True)\r\n # print(i, l[i])\r\n p = len(l[1]) - 1\r\n s1 = 0\r\n s2 = sum([i[0] for i in l[1]])\r\n ans = 0\r\n z = [-1, -1]\r\n for i in range(-1, len(l[0])):\r\n if i != -1:\r\n s1 += l[0][i][0]\r\n while p >= 0 and i + 1 + (p + 1) * 2 > v:\r\n s2 -= l[1][p][0]\r\n p -= 1\r\n if i + 1 + (p + 1) * 2 <= v:\r\n # print(\"[s1, s2, ans]\", s1, s2, ans)\r\n if s1 + s2 > ans:\r\n z = [i, p]\r\n ans = s1 + s2\r\n # print(\"[s1, s2, ans, i, p, z]\", s1, s2, ans, i, p, z)\r\n # print('ans', ans)\r\n print(ans)\r\n u = []\r\n for w in range(0, 2):\r\n for i in range(0, min(z[w] + 1, len(l[w]))):\r\n u.append(l[w][i][1] + 1)\r\n # print('here')\r\n print(' '.join(map(str, u)))\r\ndef main():\r\n tt = 1\r\n for case in range(tt):\r\n solve()\r\nmain()\r\n# l = [0, 1, 2, 3, 4, 5]\r\n# u = l.copy()\r\n# u[3] = 123123\r\n# print(l)\r\n", "n, v = map(int, input().split())\r\ntruck1 = []\r\ntruck2 = []\r\nsum1 = [0]\r\nsum2 = [0]\r\nfor i in range(n):\r\n t, p = map(int, input().split())\r\n if t == 1:\r\n truck1.append({'v': p, 'o': str(i + 1)})\r\n else:\r\n truck2.append({'v': p, 'o': str(i + 1)})\r\ntruck1.sort(key=lambda x: x['v'], reverse=True)\r\ntruck2.sort(key=lambda x: x['v'], reverse=True)\r\nlen1 = len(truck1)\r\nlen2 = len(truck2)\r\nfor i in range(1, len1 + 1):\r\n sum1.append(truck1[i - 1]['v'] + sum1[i - 1])\r\nfor i in range(1, len2 + 1):\r\n sum2.append(truck2[i - 1]['v'] + sum2[i - 1])\r\nres = 0\r\nans = []\r\nidx1 = 0\r\nidx2 = 0\r\ni = 0\r\nwhile i <= len2 and i * 2 <= v:\r\n j = min(v - i * 2, len1)\r\n if res < sum1[j] + sum2[i]:\r\n idx1 = j\r\n idx2 = i\r\n res = sum1[j] + sum2[i]\r\n i += 1\r\nprint(sum1[idx1] + sum2[idx2])\r\nfor i in range(idx1):\r\n ans.append(truck1[i]['o'])\r\nfor i in range(idx2):\r\n ans.append(truck2[i]['o']) \r\nprint(' '.join(ans))\r\n", "n, v = map(int, input().split(\" \"))\na, b = [], []\nfor i in range(n):\n t, p = map(int, input().split(\" \"))\n if t == 1:\n a.append([p, i+1])\n else:\n b.append([p, i+1])\na.sort(reverse = True)\nb.sort(reverse = True)\ni, j = 0, 0\nwhile v > 0 and i+j < n:\n if v == 1:\n if i < len(a):\n v -= 1\n i += 1\n if v == 0 and i > 1 and j < len(b) and a[i-1][0] + a[i-2][0] < b[j][0]:\n i -= 2\n j += 1\n if v == 1 and i > 0 and j < len(b) and a[i-1][0] < b[j][0]:\n v -= 1\n i -= 1\n j += 1\n break\n else:\n if i < len(a) and j < len(b):\n if a[i][0] * 2 > b[j][0]:\n v -= 1\n i += 1\n else:\n v -= 2\n j += 1\n elif i < len(a):\n v -= 1\n i += 1\n else:\n v -= 2\n j += 1\na, b = a[:i], b[:j]\ncapacity = sum([t[0] for t in a]) + sum([t[0] for t in b])\ns = [t[1] for t in a] + [t[1] for t in b]\nprint(capacity)\nprint(\" \".join(map(str, s)))\n", "class Solution(object):\r\n def __init__(self):\r\n n, v = map(int, input().split())\r\n l1 = []\r\n l2 = []\r\n for i in range(n):\r\n x, y = map(int, input().split())\r\n if x == 1:\r\n l1.append((y, i + 1))\r\n else:\r\n l2.append((y, i + 1))\r\n l1.sort(reverse=True)\r\n l2.sort(reverse=True)\r\n # print(f'l1: {l1} l2: {l2}')\r\n\r\n s1 = [0]\r\n s2 = [0]\r\n for i in range(min(v, len(l1))):\r\n s1.append(s1[-1] + l1[i][0])\r\n # print(s1)\r\n for i in range(min(v // 2, len(l2))):\r\n s2.append(s2[-1] + l2[i][0])\r\n # print(s2)\r\n\r\n ans = idx1 = idx2 = 0\r\n for i in range(len(s1)):\r\n j = min(len(s2) - 1, (v - i) // 2)\r\n x = s1[i] + s2[j]\r\n if ans < x:\r\n ans = x\r\n idx1 = i\r\n idx2 = j\r\n\r\n # print(f'ans: {ans} idx1: {idx1} idx2: {idx2}')\r\n\r\n print(f'{ans}')\r\n a = [l1[i][1] for i in range(idx1)] + [l2[i][1] for i in range(idx2)]\r\n for x in a:\r\n print(f'{x}', end=' ')\r\n\r\n pass\r\n\r\n\r\ndef main():\r\n Solution()\r\n pass\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "import sys\r\n\r\nn, v = map(int, input().split())\r\nkayak = []\r\ncatam = []\r\n\r\nfor i in range(0,n):\r\n nums = list(map(int, sys.stdin.readline().split()))\r\n if nums[0] == 1:\r\n kayak.append((nums[1], i + 1))\r\n else:\r\n catam.append((nums[1], i + 1))\r\n# sorts by [0] elementwise\r\nkayak.sort(key=lambda pair: pair[0])\r\ncatam.sort(key=lambda pair: pair[0])\r\n\r\n# Greedily take kayaks and catamarans\r\ntruck = []\r\nwhile v > 0:\r\n if v == 1:\r\n if kayak:\r\n truck.append(kayak.pop())\r\n v -= 1\r\n else:\r\n if not kayak and not catam:\r\n v = 0\r\n elif not kayak:\r\n truck.append(catam.pop())\r\n v -= 2\r\n elif not catam:\r\n truck.append(kayak.pop())\r\n v -= 1\r\n else:\r\n if len(kayak) == 1:\r\n if kayak[0][0] > catam[-1][0]:\r\n truck.append(kayak.pop())\r\n v -= 1\r\n else:\r\n truck.append(catam.pop())\r\n v -= 2\r\n else:\r\n if kayak[-1][0]+kayak[-2][0] > catam[-1][0]:\r\n truck.append(kayak.pop())\r\n v -= 1\r\n else:\r\n truck.append(catam.pop())\r\n v -= 2\r\n\r\nans = 0\r\nfor i in truck:\r\n ans += i[0]\r\nprint(ans)\r\nfor i in truck:\r\n sys.stdout.write(str(i[1]) + \" \")\r\n ", "__author__ = 'Darren'\r\n\r\n\r\ndef solve():\r\n import sys\r\n stdin = sys.stdin if True else open('data')\r\n\r\n n, v = map(int, next(stdin).split())\r\n kayaks, catamarans = [], []\r\n for i in range(n):\r\n t, p = map(int, next(stdin).split())\r\n if t == 1:\r\n kayaks.append((str(i+1), p))\r\n else:\r\n catamarans.append((str(i+1), p))\r\n\r\n get_capacity = lambda x: x[1]\r\n kayaks.sort(key=get_capacity, reverse=True)\r\n catamarans.sort(key=get_capacity, reverse=True)\r\n\r\n num_kayaks, num_catamarans = len(kayaks), len(catamarans)\r\n last_kayak = min(v, num_kayaks)\r\n capacity_sum_1 = 0\r\n for i in range(last_kayak):\r\n capacity_sum_1 += kayaks[i][1]\r\n capacity_sum_2 = 0\r\n max_capacity = capacity_sum_1\r\n selected_catamarans = 0\r\n for i in range(1, min(v//2, num_catamarans)+1):\r\n j = min(v - 2 * i, num_kayaks)\r\n for k in range(j,last_kayak):\r\n capacity_sum_1 -= kayaks[k][1]\r\n last_kayak = j\r\n capacity_sum_2 += catamarans[i-1][1]\r\n if capacity_sum_1 + capacity_sum_2 > max_capacity:\r\n max_capacity = capacity_sum_1 + capacity_sum_2\r\n selected_catamarans = i\r\n\r\n print(max_capacity)\r\n result = []\r\n for i in range(selected_catamarans):\r\n result.append(catamarans[i][0])\r\n for i in range(min(v-selected_catamarans*2, num_kayaks)):\r\n result.append(kayaks[i][0])\r\n print(' '.join(result))\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()", "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())\n\nn,v=M()\nk=[]\nc=[]\nfor i in range(n):\n t,cap=M()\n if(t==1):\n k.append((cap,i+1))\n else:\n c.append((cap,i+1))\nk.sort(reverse=True,key=lambda x:x[0])\nc.sort(reverse=True,key=lambda x:x[0])\n#print(len(k),len(c))\nlorry=v\nans=0\na=[]\ni=0\nj=0\nwhile((lorry>1 and i<len(c)) and j<len(k)-1):\n if(lorry>=2):\n if(c[i][0]>=k[j][0]+k[j+1][0]):\n lorry-=2\n ans+=c[i][0]\n a.append(c[i][1])\n i+=1\n else:\n lorry-=2\n ans+=k[j][0]+k[j+1][0]\n a.append(k[j][1])\n a.append(k[j+1][1])\n j+=2\n\nwhile(i<len(c) and lorry>=2):\n ans+=c[i][0]\n a.append(c[i][1])\n lorry-=2\n i+=1\nwhile(j< len(k) and lorry>0):\n ans+=k[j][0]\n a.append(k[j][1])\n lorry-=1\n j+=1\n\nif(i<len(c)):\n if(j-1>=0 and k[j-1][0]<c[i][0] and lorry+1>=2):\n lorry+=1\n ans-=k[j-1][0]\n a.remove(k[j-1][1])\n a.append(c[i][1])\n ans+=c[i][0]\n lorry-=2\n j-=1\n i+=1\n elif(j>=2 and k[j-1][0]+k[j-2][0]<c[i][0] and lorry+2>=2):\n lorry+=2\n ans-=k[j-1][0]\n ans-=k[j-2][0]\n a.remove(k[j-1][1])\n a.remove(k[j-2][1])\n j-=2\n a.append(c[i][1])\n ans+=c[i][0]\n lorry-=2\n i+=1\n#print(lorry)\nprint(ans)\nprint(*a)\n\n \n \n \n \n \n\n \n \n \n \n \n \n", "#3B - Lorry\r\n# n - the number of waterborne vehicles in the boat depot\r\n# v - the truck body volume of the lorry in cubic metres\r\nn,v = map(int,input().split())\r\n# l1 - list of kayaks\r\n# l2 - list of catamarans\r\nl1 = []\r\nl2 = []\r\nfor i in range(n):\r\n # t - vehicle type\r\n # x - carrying capacity\r\n t,x = map(int,input().split())\r\n # if type of waterborne vehicle = 1 (kayak):\r\n if t == 1:\r\n l1.append([x,i+1])\r\n # if type of waterborne vehicle = 2 (catamaran):\r\n else:\r\n l2.append([x,i+1])\r\n#Now, we sort the waterborne vehicles from in decreasing order of their capacity\r\nl1.sort(reverse=True)\r\nl2.sort(reverse=True)\r\n#The sum o capacities of kayaks (s1) and catamarans(s2):\r\ns1 = [0]\r\ns2 = [0]\r\n# print(\"Here: {}\".format(min(v, len(l1))))\r\n#We iterate up to the last kayak: \r\nfor i in range(min(v,len(l1))):\r\n s1.append(s1[-1]+l1[i][0])\r\n#We repeat the procedure and calculate the space occupied by catamarans:\r\nfor i in range(min(int(v/2),len(l2))):\r\n s2.append(s2[-1]+l2[i][0])\r\n# ans - the maximum possible carrying capacity of the set.\r\nans = 0\r\nnum = 0\r\n# print(s1)\r\n# print(s2)\r\nfor i in range(min(v,len(l1))+1):\r\n # print(t)\r\n t = s1[i]+s2[min(len(l2),int((v-i)/2))]\r\n if ans < t:\r\n num = i\r\n ans = t\r\nprint(ans)\r\n#Also, we print a string consisting of the numbers of the vehicles that make the optimal set. \r\nprint(\" \".join(map(lambda x:str(x[1]),l1[0:num]+l2[0:min(len(l2),int((v-num)/2))])))", "import sys\r\ndef input():\r\n return sys.stdin.readline().rstrip()\r\nn,v=map(int,input().split())\r\none=[]\r\ntwo=[]\r\nfor i in range(n):\r\n t,p=map(int,input().split())\r\n if t==1:\r\n one.append((p,i+1))\r\n else:\r\n two.append((p,i+1))\r\none.sort(reverse=True)\r\ntwo.sort(reverse=True)\r\nmax_capacity=0\r\nselected_vehicles=[]\r\ni=0\r\nj=0\r\nwhile v>0 and (i<len(one) or j<len(two)):\r\n if v%2==1 and i<len(one):\r\n selected_vehicles.append(str(one[i][1]))\r\n max_capacity+=one[i][0]\r\n v-=1\r\n i+=1\r\n elif v>=2 and j<len(two):\r\n if i<len(one)-1 and one[i][0]+one[i+1][0]>=two[j][0]:\r\n selected_vehicles.append(str(one[i][1]))\r\n selected_vehicles.append(str(one[i+1][1]))\r\n max_capacity+=one[i][0]+one[i+1][0]\r\n v-=2\r\n i+=2\r\n else:\r\n selected_vehicles.append(str(two[j][1]))\r\n max_capacity+=two[j][0]\r\n v-=2\r\n j+=1\r\n elif i<len(one):\r\n selected_vehicles.append(str(one[i][1]))\r\n max_capacity+=one[i][0]\r\n v-=1\r\n i+=1\r\n else:\r\n break\r\nprint(max_capacity)\r\nprint(\" \".join(selected_vehicles))", "R = lambda: map(int, input().split())\r\nn, v= R()\r\nk,c=[],[]\r\nfor i in range(n):\r\n t, a= R()\r\n if(t==1): k+=[[a,i+1]]\r\n else: c+=[[a,i+1]]\r\nk.sort(reverse=True)\r\nc.sort(reverse=True)\r\nsum=0\r\nklen = len(k)\r\nclen= len(c)\r\ny= min(klen,v)\r\nfor i in range(1,y):\r\n k[i][0]+=k[i-1][0]\r\nfor i in range(1,clen):\r\n c[i][0]+=c[i-1][0]\r\n#print(k,c)\r\nif y>0: ans= k[y-1][0]\r\nelse: ans=0\r\n#print(ans)\r\nj= int((v-y)/2)\r\nif clen>0:\r\n if j>0 and j<clen:\r\n ans+=c[j-1][0]\r\n elif j>0:\r\n ans+=c[clen-1][0]\r\n j=clen\r\n #print(ans,j)\r\n if 2*j+y == v-1 and j<clen:\r\n if y>1 and ans<=c[j][0]+k[y-2][0]:\r\n ans= c[j][0]+k[y-2][0]\r\n j,y =j+1, y-1\r\n elif y==1 and ans<=c[j][0]:\r\n ans=c[j][0]\r\n y,j=0,j+1\r\n #print(ans,y,j)\r\n while y>2 and j<clen and ans<=c[j][0]+k[y-3][0]:\r\n ans= c[j][0]+k[y-3][0]\r\n j,y =j+1, y-2\r\n #print(ans,j)\r\n if y==2 and j<clen and ans<=c[j][0]:\r\n ans=c[j][0]\r\n y,j=0,j+1\r\nprint(ans)\r\ns=\"\"\r\nfor i in range(y): s+=str(k[i][1])+\" \"\r\nfor i in range(j): s+=str(c[i][1])+\" \"\r\nprint(s)\r\n " ]
{"inputs": ["3 2\n1 2\n2 7\n1 3", "5 3\n1 9\n2 9\n1 9\n2 10\n1 6", "10 10\n1 14\n2 15\n2 11\n2 12\n2 9\n1 14\n2 15\n1 9\n2 11\n2 6", "20 19\n2 47\n1 37\n1 48\n2 42\n2 48\n1 38\n2 47\n1 48\n2 47\n1 41\n2 46\n1 28\n1 49\n1 45\n2 34\n1 43\n2 29\n1 46\n2 45\n2 18", "50 27\n2 93\n1 98\n2 62\n1 56\n1 86\n1 42\n2 67\n2 97\n2 59\n1 73\n1 83\n2 96\n1 20\n1 66\n1 84\n1 83\n1 91\n2 97\n1 81\n2 88\n2 63\n1 99\n2 57\n1 39\n1 74\n2 88\n1 30\n2 68\n1 100\n2 57\n1 87\n1 93\n1 83\n1 100\n1 91\n1 14\n1 38\n2 98\n2 85\n2 61\n1 44\n2 93\n2 66\n2 55\n2 74\n1 67\n2 67\n1 85\n2 59\n1 83", "1 1\n1 600", "10 14\n2 230\n2 516\n2 527\n2 172\n2 854\n2 61\n1 52\n2 154\n2 832\n2 774", "8 8\n1 1\n1 1\n1 1\n1 1\n2 100\n2 100\n2 100\n2 100", "8 4\n1 100\n1 100\n1 100\n1 100\n2 1\n2 1\n2 1\n2 1"], "outputs": ["7\n2", "24\n3 1 5", "81\n6 1 7 2 4 9", "630\n13 8 3 18 14 16 10 6 2 5 9 7 1 11", "2055\n34 29 22 2 32 35 17 31 5 48 15 50 33 16 11 19 25 10 46 14 4 38 18 8", "600\n1", "3905\n5 9 10 3 2 1 4", "400\n8 7 6 5", "400\n4 3 2 1"]}
UNKNOWN
PYTHON3
CODEFORCES
17
e095fc0f2706652ae0c7e6370b7eedb8
Timetable
Ivan is a student at Berland State University (BSU). There are *n* days in Berland week, and each of these days Ivan might have some classes at the university. There are *m* working hours during each Berland day, and each lesson at the university lasts exactly one hour. If at some day Ivan's first lesson is during *i*-th hour, and last lesson is during *j*-th hour, then he spends *j*<=-<=*i*<=+<=1 hours in the university during this day. If there are no lessons during some day, then Ivan stays at home and therefore spends 0 hours in the university. Ivan doesn't like to spend a lot of time in the university, so he has decided to skip some lessons. He cannot skip more than *k* lessons during the week. After deciding which lessons he should skip and which he should attend, every day Ivan will enter the university right before the start of the first lesson he does not skip, and leave it after the end of the last lesson he decides to attend. If Ivan skips all lessons during some day, he doesn't go to the university that day at all. Given *n*, *m*, *k* and Ivan's timetable, can you determine the minimum number of hours he has to spend in the university during one week, if he cannot skip more than *k* lessons? The first line contains three integers *n*, *m* and *k* (1<=≤<=*n*,<=*m*<=≤<=500, 0<=≤<=*k*<=≤<=500) — the number of days in the Berland week, the number of working hours during each day, and the number of lessons Ivan can skip, respectively. Then *n* lines follow, *i*-th line containing a binary string of *m* characters. If *j*-th character in *i*-th line is 1, then Ivan has a lesson on *i*-th day during *j*-th hour (if it is 0, there is no such lesson). Print the minimum number of hours Ivan has to spend in the university during the week if he skips not more than *k* lessons. Sample Input 2 5 1 01001 10110 2 5 0 01001 10110 Sample Output 5 8
[ "\r\n \r\nfrom heapq import heapify, heappop, heappush\r\nfrom itertools import cycle\r\nfrom math import sqrt,ceil\r\nimport os\r\n\r\nimport sys\r\nfrom collections import defaultdict,deque\r\nfrom io import BytesIO, IOBase\r\n \r\nfrom collections import Counter\r\nfrom functools import lru_cache\r\nfrom collections import deque\r\n\r\ndef main():\r\n n,m,k=map(int,input().split())\r\n mn=[[float(\"inf\")]*(m+1) for _ in range(n+1)]\r\n arr=[]\r\n for _ in range(n):\r\n temp=[i for i,el in enumerate(input()) if el==\"1\"]\r\n arr.append(temp[:])\r\n\r\n for i in range(n):\r\n t=arr[i]\r\n mn[i][0]=0\r\n \r\n for j in range(1,len(t)+1):\r\n start=0\r\n end=j-1\r\n p=float(\"inf\")\r\n while end<len(t):\r\n p=min(p,t[end]-t[start]+1)\r\n end+=1\r\n start+=1\r\n mn[i][j]=p\r\n dp=[[float(\"inf\")]*(k+1) for _ in range(n+1)]\r\n dp[0][0]=0\r\n for i in range(1,n+1):\r\n le=len(arr[i-1])\r\n for j in range(k+1):\r\n for lec in range(le+1):\r\n bunk=le-lec\r\n if bunk<=j:\r\n dp[i][j]=min(dp[i][j],mn[i-1][lec]+dp[i-1][j-bunk])\r\n print(min(dp[-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 \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\nif __name__ == '__main__':\r\n main()\r\n \r\n \r\n ", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn, m, k = map(int, input().split())\r\ndp = [0] * (k + 1)\r\ns0 = 0\r\nfor _ in range(n):\r\n s = list(input().rstrip())\r\n x = []\r\n for i in range(m):\r\n if s[i] == \"1\":\r\n x.append(i)\r\n l = len(x)\r\n if not l:\r\n continue\r\n y = [0] * (l + 1)\r\n c = x[-1] - x[0] + 1\r\n s0 += c\r\n for i in range(l):\r\n for j in range(i, l):\r\n u = l - (j - i) - 1\r\n y[u] = max(y[u], c - (x[j] - x[i] + 1))\r\n y[l] = c\r\n for i in range(k, -1, -1):\r\n dpi = dp[i]\r\n for j in range(min(l, i) + 1):\r\n dpi = max(dpi, dp[i - j] + y[j])\r\n dp[i] = dpi\r\nans = s0 - max(dp)\r\nprint(ans)", "n, m, k = map(int, input().split())\r\nDATA = [input() for i in range(n)]\r\n\r\n#dp[n_day][used_cost]\r\n#ans = min(dp[n_day][used_cost] for used_cost in range(k + 1))\r\n#dp[n_day][used_cost] := min(dp[n_day - 1][prev_cost] + cost(pay used_cost - prev_cost in n_day) for prev_cost in range(used_cost + 1))\r\nINF = 1 << 60\r\ndp = [[INF]*(k + 10) for i in range(n + 10)]\r\ndp[0][0] = 0\r\n\r\nCOST = [[INF]*(k + 10) for i in range(n + 10)]\r\nfor i, string in enumerate(DATA):\r\n #COST[i + 1]\r\n stack = []\r\n for j in range(m):\r\n if string[j] == \"1\":\r\n stack.append(j)\r\n L = len(stack)\r\n for j in range(k + 10):\r\n if j >= L:\r\n COST[i + 1][j] = 0\r\n continue\r\n else:\r\n for pos in range(j + 1):\r\n l = pos\r\n r = pos + L - 1 - j\r\n COST[i+1][j] = min(COST[i+1][j], stack[r] - stack[l] + 1)\r\nfor day in range(1, n + 1):\r\n for used_cost in range(k + 1):\r\n dp[day][used_cost] = min(dp[day - 1][prev_cost] + COST[day]\r\n [used_cost - prev_cost] for prev_cost in range(used_cost + 1))\r\n\r\nans = min(dp[n][used_cost] for used_cost in range(k + 1))\r\nprint(ans)\r\n", "\r\nimport sys, collections, math, bisect, heapq, random, functools,io,os\r\ninput = sys.stdin.readline\r\nout = sys.stdout.flush\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\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 solve():\r\n n,m,k = map(int,input().split())\r\n v = [input().rstrip('\\n') for i in range(n)]\r\n dp = [0] * (k + 1)\r\n for s in v:\r\n temp = []\r\n for i in range(m):\r\n if s[i] == '1':\r\n temp.append(i)\r\n if not temp:\r\n continue\r\n t = len(temp)\r\n dp2 = [float('inf')] * (t + 1)\r\n dp2[-1] = 0\r\n for i in range(t):\r\n for j in range(i,t):\r\n dp2[t - (j - i + 1)] = min(dp2[t - (j - i + 1)],temp[j] - temp[i] + 1)\r\n\r\n next_dp = [float('inf')] * (k + 1)\r\n for i in range(k,-1,-1):\r\n for j in range(t + 1):\r\n if i + j > k:\r\n break\r\n next_dp[i + j] = min(next_dp[i + j],dp[i] + dp2[j])\r\n dp = next_dp\r\n\r\n\r\n print(min(dp))\r\n\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()", "I,G=input,range;n,m,k=map(int,I().split());f=[[0]*(k+1)for _ in G(n+1)]\r\nfor i in G(1,n+1):\r\n r=[j for j,c in enumerate(I())if c=='1'];n1=len(r);on=[0]+[m]*m\r\n for l in G(1,n1+1):\r\n for start in G(n1-l+1):\r\n on[l]=min(on[l], r[start+l-1]-r[start]+1)\r\n for j in G(k+1):\r\n f[i][j]=i*m\r\n for l in G(min(j,m)+1):#skip l lessons\r\n f[i][j]=min(f[i][j], f[i-1][j-l]+on[n1-l])\r\nprint(f[n][k])", "from collections import defaultdict\r\nimport threading\r\n# import sys\r\ndef ri(): return int(input())\r\ndef rs(): return input()\r\ndef rl(): return list(map(int, input().split()))\r\ndef rls(): return list(input().split())\r\n\r\n\r\n# threading.stack_size(10**8)\r\n# sys.setrecursionlimit(10**6)\r\n\r\n\r\ndef main():\r\n n, m, k = rl()\r\n a = [rs() for _ in range(n)]\r\n\r\n inf = float('inf')\r\n dp = [[inf for _ in range(k+1)] for _ in range(n+1)]\r\n for i in range(k+1):\r\n dp[0][i] = 0\r\n for i in range(n):\r\n ones = []\r\n s = a[i]\r\n for idx, e in enumerate(s):\r\n if e == '1':\r\n ones.append(idx)\r\n\r\n for j in range(k+1):\r\n temp = 0\r\n if j < len(ones):\r\n temp = inf\r\n c = 0\r\n for x in range(len(ones)-j-1, len(ones)):\r\n temp = min(temp, ones[x]-ones[c]+1)\r\n c += 1\r\n for x in range(k+1-j):\r\n dp[i+1][x+j] = min(dp[i+1][x+j], dp[i][x]+temp)\r\n print(dp[n][k])\r\n pass\r\n\r\n\r\nmain()\r\n# threading.Thread(target=main).start()\r\n", "I,G=input,range;n,m,k=map(int,I().split());f=[0]*(k+1)\r\nfor i in G(1,n+1):\r\n r=[j for j,c in enumerate(I())if c=='1'];n1=len(r);on=[0]+[m]*m;cur=[i*m]*(k+1)\r\n for l in G(1,n1+1):\r\n for start in G(n1-l+1):\r\n on[l]=min(on[l], r[start+l-1]-r[start]+1)\r\n for j in G(k+1):\r\n for l in G(min(j,m)+1):#skip l lessons\r\n cur[j]=min(cur[j], f[j-l]+on[n1-l])\r\n cur,f=f,cur\r\nprint(f[k])", "def min_sub_array(day, k):\r\n if not day:\r\n return [0] * (k + 1)\r\n n = len(day)\r\n best = [float('inf')] * (n + 1)\r\n best[0] = 0\r\n best[1] = 1\r\n for size in range(2, n + 1):\r\n for i in range(n + 1 - size):\r\n best[size] = min(best[size], day[i + size - 1] - day[i] + 1)\r\n output = [0] * (k + 1)\r\n for i in range(k + 1):\r\n if n - i > 0:\r\n output[i] = best[n - i]\r\n return output\r\n\r\n\r\nN, M, K = map(int, input().split())\r\n\r\nday = [i for i, val in enumerate(input()) if val == '1']\r\nbest = min_sub_array(day, K)\r\n\r\nfor _ in range(N - 1):\r\n day = [i for i, val in enumerate(input()) if val == '1']\r\n new_day_best = min_sub_array(day, K)\r\n\r\n new_best = [float('inf')] * (K + 1)\r\n for i in range(K + 1):\r\n for j in range(i + 1):\r\n new_best[i] = min(new_best[i], new_day_best[j] + best[i - j])\r\n best = new_best\r\nprint(best[K])", "I, G = input, range\r\nn, m, k = map(int, I().split())\r\nf = [0] * (k+1)\r\nfor i in G(1, n+1):\r\n r = [j for j, c in enumerate(I()) if c=='1']\r\n n1 = len(r)\r\n on = [0] + [m]*m\r\n cur = [i*m] * (k+1)\r\n for l in G(1, n1+1):\r\n for start in G(n1-l+1):\r\n on[l] = min(on[l], r[start+l-1]-r[start]+1)\r\n for j in G(k+1):\r\n for l in G(min(j,m)+1):#skip l lessons\r\n cur[j] = min(cur[j], f[j-l]+on[n1-l])\r\n cur, f = f, cur\r\nprint(f[k])" ]
{"inputs": ["2 5 1\n01001\n10110", "2 5 0\n01001\n10110", "3 4 0\n0000\n0000\n0000", "3 4 12\n1111\n1111\n1111", "3 4 6\n1111\n1111\n1111", "10 10 0\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001", "10 10 5\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001", "10 10 10\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001", "10 10 20\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001", "10 10 19\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001", "4 16 11\n1111011101111111\n0111110111111111\n0011101111011000\n0000010000001000", "1 1 5\n1", "4 113 370\n01110100100010110100110000000011001111110000100111111001011001110111110111001011010110000110110010101010110001000\n01101001111110001010001100101100111100111001001001001101110101100110110110001110100010111011101011101110011110100\n01100110001001111010000010101100111100011111010000101010011011111111000111111001001010110110011011111110110010111\n11100111000100010000100111010101110110100101100100001111000001001010001000101110011100101011101100011010111010000", "3 3 4\n000\n000\n000", "1 5 1\n10001", "1 1 1\n0", "10 10 100\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001", "5 1 6\n1\n1\n1\n0\n1", "1 1 1\n1", "8 4 8\n0001\n0010\n0100\n0000\n1001\n1101\n0010\n0001", "1 1 2\n1", "1 1 0\n1", "1 1 2\n0"], "outputs": ["5", "8", "0", "0", "6", "100", "55", "10", "0", "1", "30", "0", "0", "0", "1", "0", "0", "0", "0", "2", "0", "1", "0"]}
UNKNOWN
PYTHON3
CODEFORCES
9
e0978618e361da10f11b0837442672c5
Game on Tree
Momiji has got a rooted tree, consisting of *n* nodes. The tree nodes are numbered by integers from 1 to *n*. The root has number 1. Momiji decided to play a game on this tree. The game consists of several steps. On each step, Momiji chooses one of the remaining tree nodes (let's denote it by *v*) and removes all the subtree nodes with the root in node *v* from the tree. Node *v* gets deleted as well. The game finishes when the tree has no nodes left. In other words, the game finishes after the step that chooses the node number 1. Each time Momiji chooses a new node uniformly among all the remaining nodes. Your task is to find the expectation of the number of steps in the described game. The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the number of nodes in the tree. The next *n*<=-<=1 lines contain the tree edges. The *i*-th line contains integers *a**i*, *b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*; *a**i*<=≠<=*b**i*) — the numbers of the nodes that are connected by the *i*-th edge. It is guaranteed that the given graph is a tree. Print a single real number — the expectation of the number of steps in the described game. The answer will be considered correct if the absolute or relative error doesn't exceed 10<=-<=6. Sample Input 2 1 2 3 1 2 1 3 Sample Output 1.50000000000000000000 2.00000000000000000000
[ "# https://codeforces.com/problemset/problem/280/C\nfrom collections import defaultdict, deque\nimport sys\n\nnodes = int(sys.stdin.readline())\nedges = defaultdict(list)\nfor line in sys.stdin:\n a, b = line.split()\n a = int(a)\n b = int(b)\n edges[a].append(b)\n edges[b].append(a)\nbfs = deque([(1, 1)])\ndepths = {}\nwhile bfs:\n nid, depth = bfs.popleft()\n if nid in depths:\n continue\n depths[nid] = depth\n for n2 in edges[nid]:\n bfs.append((n2, depth + 1))\nprint(sum(1.0 / d for d in sorted(depths.values(), reverse=True)))", "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 adj = [[] for _ in range(n)]\n for _ in range(n-1):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n adj[a].append(b)\n adj[b].append(a)\n\n d = [0] * n\n d[0] = 1\n q = [0]\n while q:\n v = q.pop()\n for nei in adj[v]:\n if d[nei] == 0:\n d[nei] = d[v] + 1\n q.append(nei)\n ans = sum(1 / x for x in d)\n print(ans)\n\n\nt = 1\n\nfor _ in range(t):\n solve()\n", "from collections import deque\r\nfrom sys import stdin\r\ninput = stdin.readline\r\nn = int(input())\r\n\r\na = [list(map(int, line.split())) for line in stdin.read().splitlines()]\r\nadj = [[] for _ in range(n + 1)]\r\nfor (u, v) in a:\r\n adj[u].append(v)\r\n adj[v].append(u)\r\n\r\nres = 0\r\n\r\nif n == 1:\r\n print(1)\r\n\r\nelse:\r\n Q = deque()\r\n Q.append((0, 1))\r\n depth = 1\r\n visited = set()\r\n visited.add(1)\r\n while Q:\r\n res += 1.0/depth*len(Q)\r\n for _ in range(len(Q)):\r\n p, cur = Q.popleft()\r\n for i in adj[cur]:\r\n if i != p:\r\n Q.append((cur, i))\r\n depth += 1\r\n print(res)\r\n" ]
{"inputs": ["2\n1 2", "3\n1 2\n1 3", "10\n1 2\n2 3\n3 4\n1 5\n2 6\n6 7\n4 8\n6 9\n9 10", "6\n1 3\n2 4\n5 6\n3 6\n5 4"], "outputs": ["1.50000000000000000000", "2.00000000000000000000", "3.81666666666666690000", "2.45000000000000020000"]}
UNKNOWN
PYTHON3
CODEFORCES
3
e0a25aa6735cc7bbb4f5284e0f982675
Watching Fireworks is Fun
A festival will be held in a town's main street. There are *n* sections in the main street. The sections are numbered 1 through *n* from left to right. The distance between each adjacent sections is 1. In the festival *m* fireworks will be launched. The *i*-th (1<=≤<=*i*<=≤<=*m*) launching is on time *t**i* at section *a**i*. If you are at section *x* (1<=≤<=*x*<=≤<=*n*) at the time of *i*-th launching, you'll gain happiness value *b**i*<=-<=|*a**i*<=-<=*x*| (note that the happiness value might be a negative value). You can move up to *d* length units in a unit time interval, but it's prohibited to go out of the main street. Also you can be in an arbitrary section at initial time moment (time equals to 1), and want to maximize the sum of happiness that can be gained from watching fireworks. Find the maximum total happiness. Note that two or more fireworks can be launched at the same time. The first line contains three integers *n*, *m*, *d* (1<=≤<=*n*<=≤<=150000; 1<=≤<=*m*<=≤<=300; 1<=≤<=*d*<=≤<=*n*). Each of the next *m* lines contains integers *a**i*, *b**i*, *t**i* (1<=≤<=*a**i*<=≤<=*n*; 1<=≤<=*b**i*<=≤<=109; 1<=≤<=*t**i*<=≤<=109). The *i*-th line contains description of the *i*-th launching. It is guaranteed that the condition *t**i*<=≤<=*t**i*<=+<=1 (1<=≤<=*i*<=&lt;<=*m*) will be satisfied. Print a single integer — the maximum sum of happiness that you can gain from watching all the fireworks. Please, do not write the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier. Sample Input 50 3 1 49 1 1 26 1 4 6 1 10 10 2 1 1 1000 4 9 1000 4 Sample Output -31 1992
[ "class SortedList(list):\n\n def add(self, other):\n left = -1\n right = len(self)\n while right - left > 1:\n mid = (right + left) >> 1\n if other < self[mid]:\n right = mid\n else:\n left = mid\n super().insert(right, other)\n\n\nINF = int(3e18)\n\n\ndef solve_good(n, m, d, a, b, t):\n left = SortedList()\n left.append(-INF)\n right = SortedList()\n right.append(INF)\n lborder = -INF\n rborder = INF\n tprev = 0\n ans = 0\n for ai, bi, ti in zip(a, b, t):\n ans += bi\n dt = ti - tprev\n interval = dt * d\n tprev = ti\n\n lborder += interval\n rborder -= interval\n\n lefta = lborder + ai\n righta = rborder - (n - ai)\n\n if lefta < left[-1]:\n top = left.pop()\n ans -= abs(top - lefta)\n left.add(lefta)\n left.add(lefta)\n right.add(rborder - (n - abs(top - lborder)))\n elif righta > right[0]:\n top = right.pop(0)\n ans -= abs(top - righta)\n right.add(righta)\n right.add(righta)\n left.add(lborder + n - abs(top - rborder))\n else:\n left.add(lefta)\n right.add(righta)\n return ans\n\n\nn, m, d = [int(elem) for elem in input().split()]\na, b, t = [], [], []\nfor i in range(m):\n ai, bi, ti = [int(elem) for elem in input().split()]\n a.append(ai)\n b.append(bi)\n t.append(ti)\n\nprint(solve_good(n, m, d, a, b, t))\n", "from collections import deque\r\n\r\n\r\ndef rollingmax(x, y, r, a):\r\n k = 2 * r + 1\r\n d = deque()\r\n lx = len(x)\r\n for i in range(lx + r):\r\n if i < lx:\r\n while d and d[-1][1] <= x[i]:\r\n d.pop()\r\n d.append((i, x[i]))\r\n while d and d[0][0] <= i - k:\r\n d.popleft()\r\n if i >= r:\r\n y[i - r] = d[0][1] - abs(i - r - a)\r\n\r\n\r\nn, m, d = [int(x) for x in input().split()]\r\na, ball, t0 = [int(x) for x in input().split()]\r\nf = [-abs(i - a) for i in range(1, n + 1)]\r\ng = [0] * n\r\nfor _ in range(m - 1):\r\n a, b, t = [int(x) for x in input().split()]\r\n ball += b\r\n r = min(n - 1, (t - t0) * d)\r\n t0 = t\r\n rollingmax(f, g, r, a - 1)\r\n f, g = g, f\r\n\r\nprint(max(f) + ball) ", "import os, sys\r\nfrom io import BytesIO, IOBase\r\nfrom array import array\r\nfrom itertools import accumulate\r\nimport bisect\r\nimport math\r\nfrom collections import deque\r\n\r\n# from functools import cache\r\n# cache cf需要自己提交 pypy3.9!\r\nfrom copy import deepcopy\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\nn,m,d = ints()\r\na,b,t = [],[],[]\r\nfor _ in range(m):\r\n aa,bb,tt = ints()\r\n a.append(aa)\r\n b.append(bb)\r\n t.append(tt)\r\n\r\nans = 0\r\ndp = [[0]*(n+1) for _ in range(2)]\r\nfor j in range(1,n+1):\r\n dp[0][j] = b[0] - abs(a[0] - j)\r\n\r\nfor i in range(1,m):\r\n \r\n \r\n q = deque()\r\n k = 1\r\n for j in range(1,n+1):\r\n while k <= j + (t[i] -t[i-1])*d and k <= n:\r\n while q and dp[(i-1)&1][q[-1]] <= dp[(i-1)&1][k]:\r\n q.pop()\r\n q.append(k)\r\n k += 1\r\n while q and q[0] < j - (t[i] -t[i-1])*d:\r\n q.popleft()\r\n dp[i&1][j] = b[i] - abs(a[i] - j) + dp[(i-1)&1][q[0]]\r\n#print(dp[0])\r\n#print(dp[1])\r\nans = -inf\r\nfor j in range(1,n+1):\r\n ans = max(ans,dp[(m-1)&1][j])\r\nprint(ans)\r\n \r\n \r\n \r\n \r\n \r\n" ]
{"inputs": ["50 3 1\n49 1 1\n26 1 4\n6 1 10", "10 2 1\n1 1000 4\n9 1000 4", "30 8 2\n15 97 3\n18 64 10\n20 14 20\n16 18 36\n10 23 45\n12 60 53\n17 93 71\n11 49 85", "100 20 5\n47 93 3\n61 49 10\n14 69 10\n88 2 14\n35 86 18\n63 16 20\n39 49 22\n32 45 23\n66 54 25\n77 2 36\n96 85 38\n33 28 45\n29 78 53\n78 13 60\n58 96 64\n74 39 71\n18 80 80\n18 7 85\n97 82 96\n74 99 97"], "outputs": ["-31", "1992", "418", "877"]}
UNKNOWN
PYTHON3
CODEFORCES
3
e0a8066c3ffaf53d1423dd8bb7537fb4
The Brand New Function
Polycarpus has a sequence, consisting of *n* non-negative integers: *a*1,<=*a*2,<=...,<=*a**n*. Let's define function *f*(*l*,<=*r*) (*l*,<=*r* are integer, 1<=≤<=*l*<=≤<=*r*<=≤<=*n*) for sequence *a* as an operation of bitwise OR of all the sequence elements with indexes from *l* to *r*. Formally: *f*(*l*,<=*r*)<==<=*a**l* | *a**l*<=+<=1 | ...  | *a**r*. Polycarpus took a piece of paper and wrote out the values of function *f*(*l*,<=*r*) for all *l*,<=*r* (*l*,<=*r* are integer, 1<=≤<=*l*<=≤<=*r*<=≤<=*n*). Now he wants to know, how many distinct values he's got in the end. Help Polycarpus, count the number of distinct values of function *f*(*l*,<=*r*) for the given sequence *a*. Expression *x* | *y* means applying the operation of bitwise OR to numbers *x* and *y*. This operation exists in all modern programming languages, for example, in language C++ and Java it is marked as "|", in Pascal — as "or". The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the number of elements of sequence *a*. The second line contains *n* space-separated integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=106) — the elements of sequence *a*. Print a single integer — the number of distinct values of function *f*(*l*,<=*r*) for the given sequence *a*. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier. Sample Input 3 1 2 0 10 1 2 3 4 5 6 1 2 9 10 Sample Output 411
[ "def subarrayBitwiseOR(A):\r\n\tres = set()\r\n\tpre = {0}\r\n\tfor x in A:\r\n\t\tpre = {x | y for y in pre} | {x}\r\n\t\tres |= pre\r\n\treturn len(res)\r\nn, A = int(input()), list(map(int, input().split()))\r\nprint(subarrayBitwiseOR(A))", "n, p, q = input(), set(), set()\nfor i in map(int, input().split()):\n q = set(i | j for j in q)\n q.add(i)\n p.update(q)\nprint(len(p))", "#n=int(input())\r\nfrom bisect import bisect_right\r\n#d=sorted(d,key=lambda x:(len(d[x]),-x)) d=dictionary d={x:set() for x in arr}\r\n#n=int(input())\r\n#n,m,k= map(int, input().split())\r\nimport heapq\r\n#for _ in range(int(input())):\r\n#n,k=map(int, input().split())\r\n#input=sys.stdin.buffer.readline\r\n#for _ in range(int(input())):\r\nn=int(input())\r\narr = list(map(int, input().split()))\r\nans=set()\r\ns=set()\r\nfor i in range(n):\r\n s={arr[i]|j for j in s}\r\n s.add(arr[i])\r\n ans.update(s)\r\n #print(s)\r\nprint(len(ans))", "input()\r\na, b = set(), set()\r\narr = map(int, input().split())\r\nfor i in arr:\r\n a = {i | j for j in a}\r\n a.add(i)\r\n b.update(a)\r\nprint(len(b))\r\n\r\n", "import sys, math,os\r\nfrom io import BytesIO, IOBase\r\n#from bisect import bisect_left as bl, bisect_right as br, insort\r\n#from heapq import heapify, heappush, heappop\r\nfrom collections import defaultdict as dd, deque, Counter\r\n#from itertools import permutations,combinations\r\ndef data(): return sys.stdin.readline().strip()\r\ndef mdata(): return list(map(int, data().split()))\r\ndef outl(var) : sys.stdout.write(' '.join(map(str, var))+'\\n')\r\ndef out(var) : sys.stdout.write(str(var)+'\\n')\r\nsys.setrecursionlimit(100000)\r\nINF = float('inf')\r\nmod = int(1e9)+7\r\n\r\ndef main():\r\n\r\n n=int(data())\r\n A=mdata()\r\n s=set()\r\n ans=set()\r\n for i in A:\r\n s=set(i|j for j in s)\r\n s.add(i)\r\n ans.update(s)\r\n print(len(ans))\r\n\r\n\r\nif __name__ == '__main__':\r\n main()", "def R(): return map(int, input().split())\r\ndef I(): return int(input())\r\ndef S(): return str(input())\r\n\r\ndef L(): return list(R())\r\n\r\nfrom collections import Counter \r\n\r\nimport math\r\nimport sys\r\n\r\nfrom itertools import permutations\r\n\r\n\r\nimport bisect\r\n\r\n\r\nn=I()\r\na=L()\r\n\r\ns1=set()\r\ns2=set()\r\n\r\nfor i in range(n):\r\n s1={a[i]|j for j in s1}\r\n s1.add(a[i])\r\n s2.update(s1)\r\n\r\nprint(len(s2))\r\n\r\n\r\n\r\n", "def brand(arr):\r\n ans=set()\r\n temp=set()\r\n for i in arr:\r\n temp={i|j for j in temp}\r\n temp.add(i)\r\n ans.update(temp)\r\n return len(ans)\r\n\r\n\r\na=input()\r\nlst=list(map(int,input().strip().split()))\r\nprint(brand(lst))", "def subarrayBitwiseOR(A):\r\n\r\n # res contains distinct values\r\n res = set()\r\n\r\n pre = {0}\r\n\r\n for x in A:\r\n pre = {x | y for y in pre} | {x}\r\n res |= pre\r\n\r\n return len(res)\r\n\r\n\r\n# Driver program\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\n\r\n# print required answer\r\nprint(subarrayBitwiseOR(arr))\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\ns1, s2 = set(), set()\r\n\r\nfor each in a:\r\n st = set()\r\n st.add(each)\r\n for i in s1:\r\n st.add(each | i)\r\n s1 = st\r\n s2.update(s1)\r\n \r\nprint(len(s2))", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=set();c=set()\r\nfor i in a:\r\n b=set(i|j for j in b)\r\n b.add(i)\r\n c.update(b)\r\nprint(len(c))\r\n", "# @Chukamin ICPC_TRAIN\n\ndef main():\n n = int(input())\n data = list(map(int, input().split()))\n vis = set()\n for i in range(n):\n now = data[i]\n jud = 0\n vis.add(now)\n for j in range(i - 1, -1, -1):\n now |= data[j]\n jud |= data[j]\n vis.add(now)\n if now == jud:\n break\n print(len(vis))\n \nif __name__ == '__main__':\n main()\n\n\t \t\t \t\t \t \t \t\t\t \t \t\t\t\t\t \t\t", "n, a, b = input(), set(), set()\r\nfor i in map(int, input().split()):\r\n b = set(i | j for j in b)\r\n b.add(i)\r\n a.update(b)\r\nprint(len(a))\r\n", "n = int(input())\r\na,b=set(),set()\r\nlst = list(map(int,input().split()))\r\nfor i in lst:\r\n a={i|j for j in a}\r\n a.add(i)\r\n b.update(a)\r\nprint(len(b))", "input();a,b=set(),set()\r\nfor i in map(int,input().split()):a={i|j for j in a}; a.add(i,);b.update(a)\r\nprint(len(b))", "import sys\r\ninput=sys.stdin.readline\r\nn=int(input())\r\na=list(map(int,input().split()))\r\ns=set()\r\nt=set()\r\nfor aa in a:\r\n s={aa|j for j in s}\r\n s.add(aa)\r\n t.update(s)\r\nprint(len(t))", "import sys,os\r\nfrom io import BytesIO,IOBase\r\n# from functools import lru_cache\r\nmod = 10**9+7; Mod = 998244353; INF = float('inf')\r\n# input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n# inp = lambda: list(map(int,sys.stdin.readline().rstrip(\"\\r\\n\").split()))\r\n#______________________________________________________________________________________________________\r\n# region fastio\r\n# ''' \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\n# endregion'''\r\n#______________________________________________________________________________________________________\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\ninp = lambda: list(map(int,sys.stdin.readline().rstrip(\"\\r\\n\").split()))\r\n# ______________________________________________________________________________________________________\r\n# import math\r\n# from bisect import *\r\n# from heapq import *\r\nfrom collections import defaultdict as dd\r\n# from collections import OrderedDict as odict\r\n# from collections import Counter as cc\r\n# from collections import deque\r\n# from itertools import groupby\r\n# from itertools import combinations\r\n# sys.setrecursionlimit(100_100) #this is must for dfs\r\n# ______________________________________________________________________________________________________\r\n# segment tree for range minimum query and update 0 indexing\r\n# init = float('inf')\r\n# st = [init for i in range(4*len(a))]\r\n# def build(a,ind,start,end):\r\n# if start == end:\r\n# st[ind] = a[start]\r\n# else:\r\n# mid = (start+end)//2\r\n# build(a,2*ind+1,start,mid)\r\n# build(a,2*ind+2,mid+1,end)\r\n# st[ind] = min(st[2*ind+1],st[2*ind+2])\r\n# build(a,0,0,n-1)\r\n# def query(ind,l,r,start,end):\r\n# if start>r or end<l:\r\n# return init\r\n# if l<=start<=end<=r:\r\n# return st[ind]\r\n# mid = (start+end)//2\r\n# return min(query(2*ind+1,l,r,start,mid),query(2*ind+2,l,r,mid+1,end))\r\n# def update(ind,val,stind,start,end):\r\n# if start<=ind<=end:\r\n# if start==end:\r\n# st[stind] = a[start] = val\r\n# else:\r\n# mid = (start+end)//2\r\n# update(ind,val,2*stind+1,start,mid)\r\n# update(ind,val,2*stind+2,mid+1,end)\r\n# st[stind] = min(st[left],st[right])\r\n# ______________________________________________________________________________________________________\r\n# Checking prime in O(root(N))\r\n# def isprime(n):\r\n# if (n % 2 == 0 and n > 2) or n == 1: return 0\r\n# else:\r\n# s = int(n**(0.5)) + 1\r\n# for i in range(3, s, 2):\r\n# if n % i == 0:\r\n# return 0\r\n# return 1\r\n# def lcm(a,b):\r\n# return (a*b)//gcd(a,b)\r\n# returning factors in O(root(N))\r\n# def factors(n):\r\n# fact = []\r\n# N = int(n**0.5)+1\r\n# for i in range(1,N):\r\n# if (n%i==0):\r\n# fact.append(i)\r\n# if (i!=n//i):\r\n# fact.append(n//i)\r\n# return fact\r\n# ______________________________________________________________________________________________________\r\n# Merge sort for inversion count\r\n# def mergeSort(left,right,arr,temp):\r\n# inv_cnt = 0\r\n# if left<right:\r\n# mid = (left+right)//2\r\n# inv1 = mergeSort(left,mid,arr,temp)\r\n# inv2 = mergeSort(mid+1,right,arr,temp)\r\n# inv3 = merge(left,right,mid,arr,temp)\r\n# inv_cnt = inv1+inv3+inv2\r\n# return inv_cnt\r\n# def merge(left,right,mid,arr,temp):\r\n# i = left\r\n# j = mid+1\r\n# k = left\r\n# inv = 0\r\n# while(i<=mid and j<=right):\r\n# if(arr[i]<=arr[j]):\r\n# temp[k] = arr[i]\r\n# i+=1\r\n# else:\r\n# temp[k] = arr[j]\r\n# inv+=(mid+1-i)\r\n# j+=1\r\n# k+=1\r\n# while(i<=mid):\r\n# temp[k]=arr[i]\r\n# i+=1\r\n# k+=1\r\n# while(j<=right):\r\n# temp[k]=arr[j]\r\n# j+=1\r\n# k+=1\r\n# for k in range(left,right+1):\r\n# arr[k] = temp[k]\r\n# return inv\r\n# ______________________________________________________________________________________________________\r\n# nCr under mod\r\n# def C(n,r,mod = 10**9+7):\r\n# if r>n: return 0\r\n# if r>n-r: r = n-r\r\n# num = den = 1\r\n# for i in range(r):\r\n# num = (num*(n-i))%mod\r\n# den = (den*(i+1))%mod\r\n# return (num*pow(den,mod-2,mod))%mod\r\n# def C(n,r):\r\n# if r>n:\r\n# return 0\r\n# if r>n-r:\r\n# r = n-r\r\n# ans = 1\r\n# for i in range(r):\r\n# ans = (ans*(n-i))//(i+1)\r\n# return ans\r\n# ______________________________________________________________________________________________________\r\n# For smallest prime factor of a number\r\n# M = 5*10**5+100\r\n# spf = [i for i in range(M)]\r\n# def spfs(M):\r\n# for i in range(2,M):\r\n# if spf[i]==i:\r\n# for j in range(i*i,M,i):\r\n# if spf[j]==j:\r\n# spf[j] = i\r\n\r\n# return\r\n# spfs(M)\r\n# p = [0]*M\r\n# for i in range(2,M):\r\n# p[i]+=(p[i-1]+(spf[i]==i))\r\n# ______________________________________________________________________________________________________\r\n# def gtc(p):\r\n# print('Case #'+str(p)+': ',end='')\r\n# ______________________________________________________________________________________________________\r\ntc = 1\r\n# tc = int(input())\r\nfor test in range(1,tc+1):\r\n n = int(input())\r\n a = inp()\r\n s = [[n]*20 for i in range(n+1)]\r\n for i in range(n-1,-1,-1):\r\n for j in range(20):\r\n s[i][j] = s[i+1][j]\r\n if (a[i]&(1<<j)):\r\n s[i][j] = i\r\n ans = set()\r\n for i in range(n):\r\n num = a[i]\r\n ans.add(num)\r\n d = dd(list)\r\n for j in range(20):\r\n if s[i][j]<n and s[i][j]!=i:\r\n d[s[i][j]].append(j)\r\n for key in sorted(d.keys()):\r\n for j in d[key]:\r\n num+=(1<<j)\r\n ans.add(num)\r\n print(len(ans))\r\n\r\n\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nrj=set()\r\n\r\npr=set()\r\nfor i in range(n):\r\n tr=set()\r\n for j in pr:\r\n rj.add(j|a[i])\r\n tr.add(j|a[i])\r\n tr.add(a[i])\r\n rj.add(a[i])\r\n pr=tr.copy()\r\n\r\nprint(len(rj))\r\n", "from math import inf\r\nfrom collections import *\r\nimport math, os, sys, heapq, bisect, random\r\nfrom functools import lru_cache\r\nfrom itertools import *\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\nM,M1=1000000007,998244353\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 n = inpu()\r\n arr = lis()\r\n s=set()\r\n p=set()\r\n for i in range(n):\r\n q=set()\r\n for j in p:\r\n q.add(j | arr[i])\r\n q.add(arr[i])\r\n p =q\r\n for k in p:\r\n s.add(k)\r\n print(len(s))\r\nif __name__ == '__main__':\r\n main()\r\n", "n=input()\nr=set()\ns=set()\nl=list(map(int,input().split(' ')))\nfor i in l:\n s={i|a for a in s}\n s.add(i)\n r|=s\nprint(len(r))\n\n", "n = int(input())\r\na = [int(x) for x in input().split()]\r\n\r\nans = set()\r\ncur_ans = set()\r\nfor i in a:\r\n cur_ans = {i | j for j in cur_ans}\r\n cur_ans.add(i)\r\n ans.update(cur_ans)\r\n # print(cur_ans, ans, \"----------\", sep=\"\\n\") # DEBUG\r\nprint(len(ans))\r\n\r\n", "#CF Round 150. Div II Prob. C - The Brand New Function\r\nimport sys\r\n\r\nIn = sys.stdin\r\nn = int(In.readline().strip())\r\narr = [int(x) for x in In.readline().split()]\r\n \r\nres, m = set(), set()\r\n \r\nfor i in range(n):\r\n s = set()\r\n s.add(arr[i])\r\n s.update([x | arr[i] for x in m])\r\n m = s\r\n res.update(s)\r\n\t\r\nprint(len(res))" ]
{"inputs": ["3\n1 2 0", "10\n1 2 3 4 5 6 1 2 9 10", "1\n123", "10\n6 8 4 5 1 9 10 2 3 7", "7\n1 2 4 8 16 32 64", "10\n375813 659427 484038 348181 432640 368050 271089 721588 345312 630771", "5\n0 1 2 0 4", "1\n0", "1\n1000000"], "outputs": ["4", "11", "1", "15", "28", "29", "7", "1", "1"]}
UNKNOWN
PYTHON3
CODEFORCES
21
e0d0422a544145c98c802c1517bec7f7
Industrial Nim
There are *n* stone quarries in Petrograd. Each quarry owns *m**i* dumpers (1<=≤<=*i*<=≤<=*n*). It is known that the first dumper of the *i*-th quarry has *x**i* stones in it, the second dumper has *x**i*<=+<=1 stones in it, the third has *x**i*<=+<=2, and the *m**i*-th dumper (the last for the *i*-th quarry) has *x**i*<=+<=*m**i*<=-<=1 stones in it. Two oligarchs play a well-known game Nim. Players take turns removing stones from dumpers. On each turn, a player can select any dumper and remove any non-zero amount of stones from it. The player who cannot take a stone loses. Your task is to find out which oligarch will win, provided that both of them play optimally. The oligarchs asked you not to reveal their names. So, let's call the one who takes the first stone «tolik» and the other one «bolik». The first line of the input contains one integer number *n* (1<=≤<=*n*<=≤<=105) — the amount of quarries. Then there follow *n* lines, each of them contains two space-separated integers *x**i* and *m**i* (1<=≤<=*x**i*,<=*m**i*<=≤<=1016) — the amount of stones in the first dumper of the *i*-th quarry and the number of dumpers at the *i*-th quarry. Output «tolik» if the oligarch who takes a stone first wins, and «bolik» otherwise. Sample Input 2 2 1 3 2 4 1 1 1 1 1 1 1 1 Sample Output tolik bolik
[ "import math\r\nimport time\r\nfrom collections import defaultdict,deque,Counter\r\nfrom sys import stdin,stdout\r\nfrom bisect import bisect_left,bisect_right\r\nfrom queue import PriorityQueue \r\nimport sys\r\ndef xor(x):\r\n ch=x&3\r\n if(ch==1):\r\n return 1\r\n if(ch==2):\r\n return x+1\r\n if(ch==3):\r\n return 0\r\n return x\r\nn=int(input())\r\nans=0\r\nfor _ in range(n):\r\n x,m=map(int,stdin.readline().split())\r\n ans^=xor(x+m-1)^xor(x-1)\r\nif(ans==0):\r\n print(\"bolik\")\r\nelse:\r\n print(\"tolik\")", "import sys\n\n\nN = int(sys.stdin.readline().split()[0])\n\n\ndef ff(a: int) -> int:\n return [0, a - 1, 1, a][a & 3]\n\n\nresult = 0\nfor _ in range(N):\n x, m = tuple(map(int, sys.stdin.readline().split()))\n result ^= ff(x) ^ ff(x + m)\n\nif result == 0:\n print('bolik')\nelse:\n print('tolik')\n", "def f(a):\n res = [a, 1, a + 1, 0]\n return res[a % 4]\n\n\ndef xorRange(a, b):\n return f(b) ^ f(a - 1)\n\n\ni = int(input())\n\ncurrentResult = 0\n\nfor _ in range(i):\n line = input().split(\" \")\n a = int(line[0])\n b = int(line[1])\n currentResult ^= xorRange(a, a + b - 1)\n\nif currentResult == 0:\n print(\"bolik\")\nelse:\n print(\"tolik\")\n", "n = int(input())\r\nf = lambda x: [x,1,x+1,0][x%4]\r\nr = lambda a,b: f(a+b-1)^f(a-1)\r\nimport operator, itertools, functools\r\nnim = functools.reduce(operator.xor, itertools.starmap(r, \r\n\t(map(int,input().split()) for _ in range(n))))\r\nprint((\"bolik\",\"tolik\")[nim > 0])", "def f(x):\r\n if x%4==1:return x-1\r\n if x%4==2:return 1\r\n if x%4==3:return x\r\n return 0\r\nn=int(input())\r\nk=0\r\nfor i in range(n):\r\n a,b=input().split()\r\n k^=f(int(a))^f(int(a)+int(b))\r\nif k==0:\r\n print(\"bolik\")\r\nelse:\r\n print(\"tolik\")", "def f(x):\n if x%4==0:\n return x\n elif x%4==1:\n return 1\n elif x%4==2:\n return x+1\n return 0\n\nn = int(input())\nres = 0\nfor i in range(n):\n x,m = input().split()\n x,m = int(x),int(m)\n res ^= f(x-1)^f(x+m-1)\n\nif res == 0:\n print(\"bolik\")\nelse:\n print(\"tolik\")\n \t\t\t \t\t\t \t \t\t\t \t \t", "def nim():\r\n res = 0\r\n for _ in range(int(input())):\r\n x, m = map(int,input().split())\r\n res ^= xor(x-1) ^ xor(x-1+m)\r\n return 'tolik' if res else 'bolik'\r\n\r\n\r\ndef xor(r):\r\n return {3: 0, 2: r+1, 1: 1, 0: r}[r%4]\r\n\r\n\r\n# res = 0\r\n# for i in range(20):\r\n# res ^= i\r\n# print(i, res == xor(i))\r\n\r\nprint(nim())", "def f(x):\r\n if x % 4 == 1:\r\n return x - 1\r\n if x % 4 == 2:\r\n return 1\r\n if x % 4 == 3:\r\n return x\r\n return 0\r\n\r\n\r\nn = int(input())\r\nk = 0\r\nfor i in range(n):\r\n a, b = input().split()\r\n k ^= f(int(a)) ^ f(int(a)+int(b))\r\nprint(\"bolik\" if k == 0 else \"tolik\")\r\n", "__author__ = 'Darren'\r\n\r\n\r\ndef solve():\r\n n = int(input())\r\n xor = 0\r\n for _i in range(n):\r\n x, m = map(int, input().split())\r\n xor ^= xor_range(x - 1) ^ xor_range(x + m - 1)\r\n print([\"tolik\", \"bolik\"][xor == 0])\r\n\r\n\r\ndef xor_range(n):\r\n return [n, 1, n+1, 0][n % 4]\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()\r\n", "import sys; R = sys.stdin.readline\r\nr = 0\r\nfor _ in range(int(R())):\r\n x,m = map(int,R().split())\r\n a,b = x,x+m-1\r\n if a&1: r ^= a; a += 1\r\n if not b&1: r ^= b; b -= 1\r\n if (b-a+1)&2: r ^= 1\r\nprint(\"tolik\" if r else \"bolik\")" ]
{"inputs": ["2\n2 1\n3 2", "4\n1 1\n1 1\n1 1\n1 1", "10\n2 3\n1 4\n5 8\n4 10\n10 8\n7 2\n1 2\n1 7\n4 10\n5 3", "20\n8 6\n6 3\n2 9\n7 8\n9 1\n2 4\n3 6\n6 3\n5 6\n5 3\n6 5\n2 10\n2 9\n6 3\n10 6\n10 10\n10 7\n3 9\n16 1\n1 3", "30\n53 12\n13 98\n21 60\n76 58\n39 5\n62 58\n73 80\n13 75\n37 45\n44 86\n1 85\n13 33\n17 50\n12 26\n97 48\n52 40\n2 71\n95 79\n38 76\n24 54\n91 39\n97 92\n94 80\n50 61\n33 56\n22 91\n39 94\n31 56\n28 16\n20 44", "1\n3737203222172202 1", "1\n3737203222172202 1"], "outputs": ["tolik", "bolik", "tolik", "bolik", "tolik", "tolik", "tolik"]}
UNKNOWN
PYTHON3
CODEFORCES
10
e0d62a2e04817aababe97ea9ff251c84
Dividing the numbers
Petya has *n* integers: 1,<=2,<=3,<=...,<=*n*. He wants to split these integers in two non-empty groups in such a way that the absolute difference of sums of integers in each group is as small as possible. Help Petya to split the integers. Each of *n* integers should be exactly in one group. The first line contains a single integer *n* (2<=≤<=*n*<=≤<=60<=000) — the number of integers Petya has. Print the smallest possible absolute difference in the first line. In the second line print the size of the first group, followed by the integers in that group. You can print these integers in arbitrary order. If there are multiple answers, print any of them. Sample Input 4 2 Sample Output 0 2 1 4 1 1 1
[ "def generate_list_124(s, n):\r\n lst = []\r\n for i in range(s, int(n/2) + 1, 2):\r\n lst.append(i)\r\n lst.append(n-i+s)\r\n return lst\r\n\r\ndef generate_list_3(s, n):\r\n lst = []\r\n for i in range(s, int(n/2) - 1, 2):\r\n lst.append(i)\r\n lst.append(n-i+s)\r\n lst.append(int(n/2))\r\n return lst \r\n\r\nn = int(input())\r\n \r\nmod = n % 4\r\n\r\nif(mod == 0):\r\n print(0)\r\n print(int(n / 2), end=' ')\r\n print(*generate_list_124(1, n), sep=' ')\r\nelif(mod == 1):\r\n print(1)\r\n print(int(n / 2), end=' ')\r\n print(*generate_list_124(2, n), sep=' ')\r\nelif(mod == 2):\r\n print(1)\r\n print(int(n / 2), end=' ')\r\n print(*generate_list_3(1, n), sep=' ')\r\nelse:\r\n print(0)\r\n print(int(n / 2) + 1, end=' ')\r\n print(*generate_list_124(1, n-1), sep=' ')", "n=int(input())\nl=list(range(1,n+1))\nr=[]\n\nif n%4==0:\n r=list(range(1,n//2,2)) + list(range(n,n//2,-2))\n print(0)\n print(len(r), *r)\n\nif n%4==2 and n!=2:\n r=list(range(1,n//2,2)) + list(range(n,n//2,-2))\n print(1)\n print(len(r), *r)\n\nif n%4==1:\n r=list(range(1,n//2,2)) + list(range(n,n//2,-2))\n # print(r)\n m=(n+1)//2\n if (m//2)%2!=0:\n m=m//2\n else:\n m=(m+1)//2\n r.remove(m)\n print(1)\n print(len(r), *r)\n\nif n%4==3:\n n+=1\n r=list(range(1,n//2,2)) + list(range(n,n//2,-2))\n r.remove(n)\n r.append(n//2)\n print(0)\n print(len(r), *r)\n\nif n==2:\n print(1)\n print(1, 1)\n", "\n\ndef solve():\n\tn = int(input())\n\tif n==1:\n\t\tprint(1)\n\t\tprint(1,1)\n\t\treturn\n\tgsum = n*(n+1)//2\n\ttt = gsum\n\tgsum/=2\n\tt = gsum\n\tg1 = []\n\tfor i in range(n,0,-1):\n\t\tif gsum-i>=0:\n\t\t\tgsum-=i\n\t\t\tg1.append(i)\n\tgsum = t-gsum\n\tts = tt-gsum\n\tprint(abs(int(ts-gsum)))\n\tprint(len(g1),*g1)\n\n\n\n\n\n\n\n\n\t\n\n\n\n\n# number of test cases\n#t = int(input())\nt = 1\nfor i in range(t):\n\tsolve()\n\n\n\n\n\n\n\n\n\n", "n=int(input())\r\n\r\nif n==2:\r\n\tprint(1)\r\n\tprint('1 1')\r\n\texit()\r\ndif=from_pos=to_pos=0\r\nmod=n%4\r\nif mod==0 or mod==3:\r\n\tfrom_pos=n//4+1\r\n\tif mod==0:\r\n\t\tto_pos=from_pos+n//2\r\n\telse:\r\n\t\tto_pos=from_pos+n//2+1\r\nelse:\r\n\tdif=1\r\n\tif mod==1:\r\n\t\tfrom_pos=n//4+2\r\n\t\tto_pos=from_pos+n//2\r\n\telse:\r\n\t\tfrom_pos=n//4\r\n\t\tto_pos=from_pos+n//2+1\r\nprint(dif)\r\nprint(to_pos-from_pos,' '.join(map(str,range(from_pos,to_pos))))", "n = int(input())\r\nsum = (n * (n+1))//2\r\nprint (sum & 1)\r\nsum = sum // 2\r\nans =[]\r\nlen =0\r\nwhile n > 0 :\r\n if sum >= n :\r\n sum-=n\r\n ans.append(n)\r\n len+=1\r\n n-=1\r\nprint (len , end = ' ')\r\nfor i in range(len):\r\n print (ans[i] , end = ' ')\r\n", "\r\nN = int(input())\r\nList = list()\r\nK, curr = (N * (N+1)) / 2, 0\r\nwant = K // 2\r\nif K % 2 == 0:\r\n print(0)\r\nelse:\r\n print(1)\r\nwhile N != 0:\r\n if curr + N <= want:\r\n curr += N\r\n List.append(N)\r\n N -= 1\r\nprint(len(List), end=\" \")\r\nfor num in List:\r\n print(num, end=\" \")\r\n\r\n", "for t in range(1):\r\n n=int(input())\r\n sum1=0\r\n sum2=0\r\n arr1=[]\r\n arr2=[]\r\n for i in range(n,0,-1):\r\n if sum1>=sum2:\r\n sum2+=i\r\n arr2.append(i)\r\n else:\r\n sum1+=i\r\n arr1.append(i)\r\n print(abs(sum1-sum2))\r\n print(len(arr1),*arr1)\r\n", "n = int(input())\r\n\r\nls = list(range(1, n + 1))\r\n\r\ndef ans(ls, n):\r\n\tls2 = []\r\n\tif n == 2:\r\n\t\tprint(1)\r\n\t\tprint(1, 1)\r\n\t\treturn\r\n\tif n % 2 == 0:\r\n\t\tif n%4 == 0:\r\n\t\t\tprint(0)\r\n\t\t\tprint(n//2, end = ' ')\r\n\t\t\tfor i in range(0, n//2, 2):\r\n\t\t\t\tls2.append(ls[i])\r\n\t\t\t\tls2.append(ls[n - i - 1])\r\n\t\t\tfor i in ls2:\r\n\t\t\t\tprint(i, end = ' ')\r\n\t\t\tprint()\r\n\t\t\treturn\r\n\t\telse:\r\n\t\t\tprint(1)\r\n\t\t\tfor i in range(0, n//2 - 1, 2):\r\n\t\t\t\tls2.append(ls[i])\r\n\t\t\t\tls2.append(ls[n - i - 1])\r\n\t\t\tls2.append(ls[n//2])\r\n\t\t\tprint(len(ls2), end = ' ')\r\n\t\t\tfor i in ls2:\r\n\t\t\t\tprint(i, end = ' ')\r\n\t\t\tprint()\r\n\t\t\treturn\r\n\tls2 = ['1']\r\n\tj = 1\r\n\tk = 0\r\n\twhile j < n:\r\n\t\tls2.append(ls[j])\r\n\t\tif k % 2 == 0:\r\n\t\t\tj += 3\r\n\t\telse:\r\n\t\t\tj+= 1\r\n\t\tk += 1\r\n\tif n == 3:\r\n\t\tprint(0)\r\n\t\tprint(2, 1, 2)\r\n\t\treturn\r\n\telif (n - 1)%4 == 0:\r\n\t\tprint(1)\r\n\telse:\r\n\t\tprint(0)\r\n\tprint(n//2 + 1, end = ' ')\r\n\tfor i in ls2:\r\n\t\tprint(i, end = ' ')\r\n\tprint()\r\n\treturn\r\n\t\r\nans(ls, n)", "import math\r\nimport sys\r\nfrom collections import defaultdict\r\nfrom collections import Counter\r\nfrom collections import deque\r\nimport bisect\r\nsys.setrecursionlimit(1000000)\r\ninput = iter(sys.stdin.buffer.read().decode().splitlines()).__next__\r\nilele = lambda: map(int,input().split())\r\nalele = lambda: list(map(int, input().split()))\r\n\r\nN = int(input())\r\nt = (N*(N+1))//2\r\ntt = t//2\r\nf= 0;A =[]\r\nfor i in range(N,0,-1):\r\n if f + i <= tt:\r\n A.append(i)\r\n f += i\r\nprint(abs(t - 2*f))\r\nprint(len(A),end = \" \")\r\nprint(*A)", "n = int(input())\n\ntotal = n*(n+1)/2\n\nif total%2 == 0:\n diff = 0\nelse:\n diff = 1\n \n\nres = []\nnums = [i for i in range(1,n+1)][::-1]\n#print(nums)\nsum_num = 0\nfor num in nums:\n if sum_num+num <= total/2:\n sum_num += num\n res.append(num)\nprint(diff)\nprint(str(len(res)) + \" \" + ' '.join(str(item) for item in res))\n#print(res)", "n=int(input())\r\na=[x for x in range(1,n+1)]\r\nsuma=sum(a)\r\nans=[]\r\nif suma%2!=0 or n==2:\r\n print(1)\r\nelse:\r\n print(0)\r\nreq=suma//2\r\nfor i in range(n,0,-1):\r\n if i>req:\r\n if req==0:\r\n break\r\n ans.append(req)\r\n break\r\n ans.append(i)\r\n req-=i\r\nprint(len(ans),*ans)\r\n", "n = int(input())\n\na = list(reversed([1 if i%2!=0 else 0 for i in range(int((n+1)/2)) for j in range(2)]))[1:]+[1]\nb = [1 if i%2==0 else 0 for i in range(int((n+1)/2)) for j in range(2)]\n\nif n%2!=0:\n a=a[1:]\n b=b[:-1]\n \ndif = b[n-1] \nlist_ = []\nfor index, i in enumerate(a):\n if ((index+1)*i)!=0:\n list_.append((index+1)*i)\n \ndigits = \"{} \".format(len(list_))\nfor d in list_:\n digits = digits+\"{} \".format(d)\n \nprint(dif)\nprint(digits[:-1])", "n = int(input())\na,b = 0,0 \nx = []\nfor i in range(n,0,-1):\n\tif a>b:\n\t\tb+=i\n\telse:\n\t\tx.append(i)\n\t\ta+=i\nprint(abs(a-b))\nprint(len(x),*x)\n", "from math import ceil\n\n\nn = int(input())\nif ceil(n / 2) % 2 == 0:\n min_dif = 0\nelse:\n min_dif = 1\n\ndata = [x for x in range(1, n + 1)]\nans = []\ncur_sum = n * (n + 1) // 4\nif n == 2:\n print(min_dif)\n print(1, 2)\n exit()\nfor _ in range(n - 1, -1, -1):\n cur_sum -= data[_]\n ans.append(data[_])\n if cur_sum == 0:\n break\n if cur_sum < data[_]:\n ans.append(data[cur_sum - 1])\n cur_sum = 0\n if cur_sum == 0:\n break\nprint(min_dif)\nprint(len(ans), *ans)\n", "n = int(input())\r\ns1, s2 = n * (n+1) // 2, 0\r\nres = []\r\nfor i in range(n, 0, -1):\r\n if s2 + i <= s1 - i:\r\n s1 -= i\r\n s2 += i\r\n res.append(i)\r\nprint(s1 - s2)\r\nprint(len(res), *res)\r\n", "n = int(input())\r\na,b = 0,0 \r\nx = []\r\nfor i in range(n,0,-1):\r\n\tif a>b:\r\n\t\tb+=i\r\n\telse:\r\n\t\tx.append(i)\r\n\t\ta+=i\r\nprint(abs(a-b))\r\nprint(len(x),*x)\r\n", "n = int(input())\r\nmin_diff = n * (n + 1) // 2\r\nnumbers = []\r\ntotal = 0\r\n\r\nfor num in reversed(range(1, n + 1)):\r\n if total + num <= min_diff // 2:\r\n numbers.append(num)\r\n total += num\r\n\r\nprint(min_diff % 2)\r\nprint(len(numbers), *numbers)\r\n", "n = int(input())\nf = []\nl = r = 0\nfor p in range(n, 0, -1) :\n if l > r :\n r += p\n else :\n l += p\n f.append(p)\nprint(abs(l-r))\nprint(len(f), *f)\n", "n=int(input())\r\nsum=n*(n+1)/2\r\nif sum%2==0:\r\n print(0)\r\nelse:\r\n print(1)\r\ns=''\r\ncount=0\r\narr=[]\r\nfor i in range(1,n+1):\r\n arr.append(n-i+1)\r\nx=[]\r\nm=int(sum/2)\r\nwhile(m>0):\r\n count+=1\r\n if (m>arr[0]):\r\n m-=arr[0]\r\n x.append(arr[0])\r\n arr.pop(0)\r\n else:\r\n x.append(m)\r\n break\r\nfor i in range(len(x)): s=str(x[i])+' '+s\r\ns=' '+s\r\ns=str(count)+s\r\nprint(s)", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Aug 28 03:20:26 2020\r\n\r\n@author: Dark Soul\r\n\"\"\"\r\n\r\nn=int(input(''))\r\nsol=[]\r\nans=0\r\nfor i in range(n,0,-1):\r\n if ans<=0:\r\n ans+=i\r\n sol.append(i)\r\n else:\r\n ans-=i\r\nprint(ans)\r\nprint(len(sol),*sol)", "# aadiupadhyay\r\nimport os.path\r\nfrom math import gcd, floor, ceil\r\nfrom collections import *\r\nimport sys\r\nmod = 1000000007\r\nINF = float('inf')\r\ndef st(): return list(sys.stdin.readline().strip())\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 pr(n): return sys.stdout.write(str(n)+\"\\n\")\r\ndef prl(n): return sys.stdout.write(str(n)+\" \")\r\n\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\nn = inp()\r\ns = n*(n+1)//2\r\nif s % 2 == 0:\r\n pr(0)\r\nelse:\r\n pr(1)\r\nsize = n//2\r\nans = []\r\nprl(size)\r\ns = s//2\r\nfor i in range(n, 0, -1):\r\n if i > s:\r\n continue\r\n if size*(size-1) // 2 <= (s-i):\r\n ans.append(i)\r\n s -= i\r\n size -= 1\r\nprint(*ans)\r\n", "n = int(input())\r\nd1 = 0\r\nd2 = 0\r\nans= []\r\n\r\nfor i in range(n,0,-1):\r\n if d1>=d2:\r\n d2 +=i \r\n ans.append(i)\r\n else:\r\n d1+=i \r\n\r\nprint(abs(d1-d2))\r\nprint(len(ans),*ans)\r\n\r\n", "n = int(input())\r\nsumma = (n + 1) * n // 2 \r\nL = []\r\nif summa % 2 == 0:\r\n print(0)\r\n summa1 = 0\r\n k = n\r\n while summa1 + k <= summa // 2:\r\n summa1 += k\r\n L.append(k)\r\n k -= 1\r\n if summa // 2 != summa1 and summa // 2 - summa1 != 0:\r\n L.append(summa // 2 - summa1)\r\nelse:\r\n print(1)\r\n summa1 = 0\r\n k = n\r\n while summa1 + k <= summa // 2:\r\n summa1 += k\r\n L.append(k)\r\n k -= 1\r\n if summa // 2 - summa1 != 0:\r\n L.append(summa // 2 - summa1)\r\nprint(len(L), end = ' ')\r\nfor i in L:\r\n print(i, end = ' ')", "\n\n# 6 3 2 5 4 1\nif __name__ == '__main__':\n n = int(input())\n numbers = [i for i in range(1, n + 1)]\n first = 0\n second = 0\n result = []\n for i in range(len(numbers), 0, -1):\n if first > second:\n second += i\n else:\n first += i\n result.append(i)\n\n print(abs(first - second))\n result.insert(0, len(result))\n print(*result)\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\nk = n * (n + 1) // 2 // 2;\r\nres = []\r\nfor i in range(n, 0, -1):\r\n if k >= i:\r\n res.append(i)\r\n k -= i\r\n\r\nprint((n * (n + 1) // 2) % 2)\r\nprint(len(res), end = ' ')\r\nfor x in res:\r\n print(x, end = ' ')\r\n", "import math\n\nn = int(input())\nsum = n * (n + 1) / 2\nsum1 = math.ceil(sum / 2)\nsum2 = math.floor(sum / 2)\n\ndiff = abs(sum1 - sum2)\n\ngroup1 = []\n\nfor i in range(n, 0, -1):\n if sum1 - i == 0:\n group1.append(i)\n break\n elif sum1 - i > 0:\n sum1 -= i\n group1.append(i)\n \nprint(diff)\nprint(len(group1), end=' ')\nfor num in group1:\n print(num, end=' ')\nprint(\"\")\n", "n = int(input())\r\nx = n * (n+1)//2\r\na = x//2\r\nb = x - a\r\nc = []\r\nprint(abs(b-a))\r\nfor i in range(n, 0, -1):\r\n if i <= a:\r\n a-=i\r\n c.append(i)\r\nprint(len(c), end = ' ')\r\nfor i in c:\r\n print(i, end = ' ')", "n = int(input())\r\na1 = set()\r\na2 = set()\r\nsum_a1 = 0\r\nsum_a2 = 0\r\nfor i in range(n, 0, -1):\r\n if sum_a1 < sum_a2:\r\n sum_a1 += i\r\n a1.add(i)\r\n else:\r\n sum_a2 += i\r\n a2.add(i)\r\nprint(abs(sum_a1 - sum_a2))\r\na1 = list(map(str, list(a1)))\r\na = \" \".join(a1)\r\nprint(len(a1), a)\r\n", "import bisect\r\n\r\ndef list_output(s): \r\n print(' '.join(map(str, s)))\r\n \r\ndef list_input(s='int'):\r\n if s == 'int':\r\n return list(map(int, input().split())) \r\n elif s == 'float':\r\n return list(map(float, input().split()))\r\n return list(map(str, input().split()))\r\n\r\nn = int(input())\r\n\r\na = list()\r\nfor i in range(n//4):\r\n a.append(i+1+n%4)\r\n a.append(n-i)\r\ndiff = 0\r\nif n%4 == 1:\r\n diff = 1\r\nelif n%4 == 2:\r\n diff = 1\r\n a.append(1)\r\nelif n%4 == 3:\r\n diff = 0\r\n a.append(1)\r\n a.append(2)\r\nprint(diff)\r\nprint(len(a), ' '.join(map(str, a)))\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n = int(input())\ns1 = set()\ns2 = set()\n\nsum1 = 0\nsum2 = 0\nfor i in range(n, 0, -1):\n if i == n:\n s1.add(i)\n sum1 += i\n else:\n if sum1 > sum2:\n s2.add(i)\n sum2 += i\n else:\n s1.add(i)\n sum1 += i\n\nprint(abs(sum1 - sum2))\nprint(len(s1), ' '.join(map(str, s1)))\n\n\n", "n= int(input())\r\nout = []\r\nif n%4==0:\r\n print(0)\r\n out = []\r\n for i in range(n//2):\r\n if i&1==0:\r\n out.append(i+1)\r\n out.append(n-i)\r\n print(len(out),*out)\r\nelif n%2==0:\r\n print(1)\r\n mid = n//2\r\n out.append(n//2)\r\n for i in range(n//2-1):\r\n if i&1==0:\r\n out.append(i+1)\r\n out.append(n-i)\r\n print(len(out),*out)\r\nelif n%2!=0 and n%4==1:\r\n print(1)\r\n out.append(1)\r\n l = 2\r\n r= n\r\n flag= True\r\n while(l<r):\r\n if flag:\r\n out.append(l)\r\n out.append(r)\r\n l+=1\r\n r-=1\r\n flag = not flag\r\n print(len(out),*out)\r\nelse:\r\n print(0)\r\n out.append(1)\r\n out.append(n//2+1)\r\n mid= n//2\r\n l = 2\r\n r= n\r\n flag= True\r\n while(l<=mid):\r\n if flag:\r\n out.append(l)\r\n out.append(r)\r\n l+=1\r\n r-=1\r\n flag = not flag\r\n print(len(out),*out)", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\nx = n*(n+1)//2\r\n\r\nif x % 2 == 0:\r\n print(0)\r\nelse:\r\n print(1)\r\nd = []\r\nc = x//2\r\nk = n\r\nwhile c != 0:\r\n if c - k >= 0:\r\n c -= k\r\n d.append(k)\r\n k -= 1\r\nprint(len(d), ' '.join(map(str, d)))\r\n", "n = int(input())\ns = n * (n + 1) // 2\nprint(s & 1)\nx = s // 2\nres = set()\nfor i in range(n, 0, -1):\n\tif i <= x:\n\t\tx -= i\n\t\tres.add(i)\n\t\tif not x:\n\t\t\tbreak\nprint(len(res), *res)\n\n \t\t\t \t \t\t\t \t \t\t \t\t \t\t \t\t\t\t", "n = int(input())\r\na = []\r\nif n % 2 == 0:\r\n if (n/2) % 2 == 0:\r\n print(0)\r\n for i in range(1, n//2 + 1, 2):\r\n a.append(i)\r\n a.append(n-i+1)\r\n else:\r\n print(1)\r\n for i in range(1, n//2 + 1, 2):\r\n a.append(i)\r\n a.append(n-i+1)\r\n a.pop()\r\nelse:\r\n if ((n+1)//2) % 2 == 0:\r\n print(0)\r\n for i in range(n, 3, -4):\r\n a.append(i)\r\n a.append(i - 3)\r\n a.append(3)\r\n else:\r\n print(1)\r\n for i in range(n, 1, -4):\r\n a.append(i)\r\n a.append(i - 3)\r\nprint(len(a), end=' ')\r\nfor i in a:\r\n print(i, end=' ')\r\nprint()\r\n", "import sys\r\nfrom math import gcd,ceil,sqrt\r\nINF = float('inf')\r\nMOD = 998244353\r\nmod = 10**9+7\r\nfrom collections import Counter,defaultdict as df\r\nfrom functools import reduce\r\ndef counter(l): return dict(Counter(l))\r\ndef printm(l):\r\n for i in range(len(l[0])):\r\n print(*l[i])\r\ndef P(n) : \r\n if (n <= 1) :return False\r\n if (n <= 3) :return True\r\n if (n % 2 == 0 or n % 3 == 0) :return False\r\n for i in range(5,ceil(sqrt(n))+1,6):\r\n if (n % i == 0 or n % (i + 2) == 0) :return False\r\n return True\r\n\r\ndef so(x): return {k: v for k, v in sorted(x.items(), key=lambda item: item[1])}\r\ndef rev(l): return list(reversed(l))\r\ndef ini(): return int(sys.stdin.readline())\r\ndef inp(): return map(int, sys.stdin.readline().strip().split())\r\ndef li(): return list(map(int, sys.stdin.readline().strip().split()))\r\ndef input(): return sys.stdin.readline().strip()\r\ndef inputm(n,m):return [li() for i in range(m)]\r\na=\"Ashishgup\"\r\nb= \"FastestFinger\"\r\nn=ini()\r\nl=[]\r\nc1=0\r\nc2=0\r\nx=n*(n+1)//4\r\nfor i in range(1,n+1):\r\n if c1+i<=x:\r\n l+=[i]\r\n c1+=i\r\n else:\r\n break\r\nm=i\r\nfor i in range(i,n+1):\r\n c2+=i\r\n \r\nif abs(c1-c2)==0:\r\n print(0)\r\n print(len(l),*l)\r\nelse:\r\n x=m-((c2-c1)//2)\r\n #print(x,l,c1,c2)\r\n if x in l:\r\n c1-=x\r\n c1+=m\r\n c2+=x\r\n c2-=m\r\n l.remove(x)\r\n l+=[m]\r\n print(abs(c1-c2))\r\n print(len(l),*l)\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n", "n = int(input())\n# n = 6\n\ns = sum(range(1, n + 1))\ns2 = 0\nresult = []\nfor i in range(n, 0, -1):\n\tif s - i >= s2 + i:\n\t\ts -= i\n\t\ts2 += i\n\t\tresult.append(i)\n\nprint(s - s2)\nst = str(len(result)) + ' '\nfor i in result:\n\tst += str(i) + ' '\nprint(st)", "n = int(input())\nf = []\ns = []\nf1 = s1 = 0\nfor i in range(n, 0, -1):\n if f1 <= s1:\n f1 += i\n f.append(i)\n else:\n s1 += i\n s.append(i)\nprint(abs(f1 - s1))\nprint(len(f), *f)", "n=int(input())\r\na=[i for i in range(1,n+1)]\r\nif n%4==0:\r\n print('0\\n%d '%(n//2),end='')\r\n for i in range(1,n+1,4):\r\n print('%d %d '%(i+1,i+2),end='')\r\nelif n%4==1:\r\n print('1\\n%d '%(n//2),end='')\r\n for i in range(2,n+1,4):\r\n print('%d %d '%(i+1,i+2),end='')\r\nelif n%4==2:\r\n print('1\\n%d 1 '%(n//2),end='')\r\n for i in range(3,n+1,4):\r\n print('%d %d '%(i+1,i+2))\r\nelse:\r\n print('0\\n%d 3 '%(n//2),end='')\r\n for i in range(4,n+1,4):\r\n print('%d %d '%(i+1,i+2))", "n = int(input())\r\nif n == 2:\r\n\tprint(1)\r\n\tprint(1, 1)\r\n\texit()\r\ns = n * (n + 1) // 2\r\nif s & 1:\r\n\tprint(1)\r\n\tx = (s - 1) // 2\r\n\tres = set()\r\n\tfor i in range(n, 0, -1):\r\n\t\tif i <= x:\r\n\t\t\tx -= i\r\n\t\t\tres.add(i)\r\n\t\t\tif not x:\r\n\t\t\t\tbreak\r\n\tprint(len(res), *res)\r\nelse:\r\n\tprint(0)\r\n\tx = s // 2\r\n\tres = set()\r\n\tfor i in range(n, 0, -1):\r\n\t\tif i <= x:\r\n\t\t\tx -= i\r\n\t\t\tres.add(i)\r\n\t\t\tif not x:\r\n\t\t\t\tbreak\r\n\tprint(len(res), *res)", "n = int(input())\r\na = []\r\nb = []\r\na.append(n)\r\nb.append(n-1)\r\nc1 = n\r\nc2 = n-1\r\nk = n-2\r\nwhile(k>0):\r\n if abs(k+c1-c2)<abs(k+c2-c1):\r\n a.append(k)\r\n c1+=k\r\n else:\r\n b.append(k)\r\n c2+=k\r\n k-=1\r\ns = ''\r\nfor i in a:\r\n s+=str(i) + ' '\r\nprint(abs(c1-c2))\r\nprint(str(len(a)) + ' ' + s)", "n = int(input())\ns = n * (n + 1) // 2\n\nprint(s & 1)\ns //= 2\nans = []\nfor i in range(n, 0, -1):\n\tif s - i >= 0:\n\t\tans.append(i)\n\t\ts -= i\n\nprint(len(ans), *ans)", "mod = 1000000007\r\nii = lambda : int(input())\r\nsi = lambda : input()\r\ndgl = lambda : list(map(int, input()))\r\nf = lambda : map(int, input().split())\r\nil = lambda : list(map(int, input().split()))\r\nls = lambda : list(input())\r\nn=ii()\r\nsa,sb,l=0,0,[]\r\nfor i in range(n,0,-1):\r\n if sa>sb:\r\n sb+=i\r\n else:\r\n sa+=i\r\n l.append(i)\r\nprint(abs(sb-sa))\r\nprint(len(l),*l)", "n=int(input())\r\ns1=n\r\ns2=n-1\r\nans1=[n]\r\n\r\nfor i in range(n-2,0,-1):\r\n if s1<=s2:\r\n s1+=i\r\n ans1.append(i)\r\n else:\r\n s2+=i\r\nprint(abs(s1-s2))\r\nprint(len(ans1),*ans1)\r\n \r\n \r\n ", "\r\nn=int(input())\r\nx=(n)*(n+1)//4\r\ni=n\r\nwhile(x>i):\r\n \r\n x-=i\r\n i-=1\r\na=list(range(i+1,n+1))\r\nif(x!=0):\r\n print((n*(n+1)//2)%2)\r\n print(n-i+1,x,end=' ')\r\n\r\n print(*a)\r\nelse:\r\n print((n*(n+1)//2)%2)\r\n print(n-i,end=' ')\r\n print(*a)\r\n \r\n", "n = int(input())\n\nfib_sum = 0\n\nfor value in range(1, n+1):\n fib_sum += value\n\nis_diff = False\nif fib_sum % 2 == 1:\n fib_sum -= 1\n is_diff = True\n\nfib_sum //= 2\n\ngroup1 = []\n\nwhile fib_sum != 0:\n if fib_sum - n < 0:\n n -= 1\n continue\n fib_sum -= n\n group1.append(n)\n n -= 1\n\nif is_diff:\n print(1)\nelse:\n print(0)\ngroup1 = [str(x) for x in group1]\nprint(len(group1), ' '.join(group1))\n\n\t\t\t \t\t\t\t\t\t\t\t\t\t \t \t \t \t \t\t \t", "n=int(input())\r\nsum=n*(n+1)//2 \r\nreq=sum//2 \r\nl=[n]\r\ns=n\r\ncurr=n-1\r\nwhile s+curr<req:\r\n s+=curr \r\n l.append(curr)\r\n curr-=1 \r\nif s<req:\r\n l.append(req-s)\r\nif sum%2==0:\r\n print(0)\r\nelse:\r\n print(1)\r\nprint(len(l),end=' ')\r\nprint(*l)\r\n", "if __name__ == '__main__':\r\n n = int(input().strip())\r\n l1, l2 = [], []\r\n s1, s2 = 0, 0\r\n for i in range(n, 0, -1):\r\n if s1 < s2:\r\n s1 += i\r\n l1.append(i)\r\n else:\r\n s2 += i\r\n l2.append(i)\r\n print(abs(s1 - s2))\r\n print(len(l1), end=\" \")\r\n for i in l1:\r\n print(i, end=\" \")\r\n", "n = int(input())\r\nl = []\r\nr = []\r\nls = rs = 0\r\nfor i in range(n, 0, -1):\r\n if ls <= rs:\r\n ls += i\r\n l.append(i)\r\n else:\r\n rs += i\r\n r.append(i)\r\n\r\nprint (abs(ls-rs))\r\nprint(len(l), *l)\r\n", "n = int(input())\r\ns1,s2 = 0,0\r\nans = []\r\nfor i in range(n,0,-1):\r\n if s1 >= s2:\r\n s2 += i\r\n ans.append(i)\r\n else:\r\n s1 += i\r\nprint(abs(s1-s2))\r\nprint(len(ans),end = \" \")\r\nfor i in ans:\r\n print(i,end = \" \")\r\n", "\r\nn = int(input())\r\n\r\ns = n * (n + 1) / 2\r\n\r\nif s % 2 == 0:\r\n\tprint(0)\r\n\tres = []\r\n\tb = [0 for x in range(n + 1)]\r\n\ts /= 2\r\n\ts = int(s)\r\n\twhile 1 :\r\n\t\tif (s <= n and b[s] == 0):\r\n\t\t\tres.append(s)\r\n\t\t\tbreak\r\n\t\ts -= n\r\n\t\tres.append(n)\r\n\t\tn -= 1\r\n\tprint(len(res))\r\n\tfor x in res: \r\n\t\tprint(x)\r\nelse:\r\n\tprint(1)\r\n\tres = []\r\n\tb = [0 for x in range(n + 1)]\r\n\ts /= 2\r\n\ts = int(s)\r\n\twhile 1 :\r\n\t\tif (s <= n and b[s] == 0):\r\n\t\t\tres.append(s)\r\n\t\t\tbreak\r\n\t\ts -= n\r\n\t\tres.append(n)\r\n\t\tn -= 1\r\n\tprint(len(res))\r\n\tfor x in res: \r\n\t\tprint(x)\r\n\r\n\r\n", "# for _ in range(int(input())):\r\nn = int(input())\r\nrem = n%4\r\nif (rem==0 or rem==3):\r\n print(0)\r\nelse:\r\n print(1)\r\nprint(n//2, end= ' ')\r\n\r\nif rem==2:\r\n print(1, end= ' ')\r\nelif rem==3:\r\n print(3, end= ' ')\r\n\r\nfor i in range(rem+1,n+1,4):\r\n print(i,end=' ')\r\n print(i+3,end=' ')\r\nprint()", "n=int(input())\r\nif n%4==0:\r\n print(0)\r\n print(n//4*2,end=' ')\r\n j=1\r\n for i in range(n//4):\r\n print(j,j+3,end=' ')\r\n j+=4\r\nelif n%4==1:\r\n print(1)\r\n print(n//4*2,end=' ')\r\n j=2\r\n for i in range(n//4):\r\n print(j,j+3,end=' ')\r\n j+=4\r\nelif n%4==2:\r\n print(1)\r\n print(n//4*2+1,1,end=' ')\r\n j=3\r\n for i in range(n//4):\r\n print(j,j+3,end=' ')\r\n j+=4\r\nelse:\r\n print(0)\r\n print(n//4*2+1,3,end=' ')\r\n j=4\r\n for i in range(n//4):\r\n print(j,j+3,end=' ')\r\n j+=4\r\n", "def read_int():\n\treturn int(input())\n\ndef read_str():\n\treturn input()\n\ndef read_list(type):\n\treturn list(map(type, input().split()))\n\ndef print_list(x):\n\tprint(len(x), ' '.join(map(str, x)))\n\n# ------------------------------------------------------\n\ndef f(arr):\n\tr = []\n\tfor x, y in zip(arr, arr[::-1]):\n\t\tr.extend([x, y])\n\treturn r[:len(arr)//2]\n\nif __name__ == '__main__':\n\tn = read_int()\n\tmod = n%4\n\tprint(((mod+1)%4)//2)\n\tarr = list(range(1, n+1))\n\tres = f(arr[mod:])\n\tif mod:\n\t\tres += arr[:mod-1]\n\tprint_list(res)", "n=int(input())\r\nans=[]\r\nif((n*(n+1))%4==0):\r\n a=[i+1 for i in range(n)]\r\n \r\n if(n%2==0):\r\n a=[i+1 for i in range(n)]\r\n for i in range(0,n//2,2):\r\n ans.append(a[i])\r\n ans.append(a[n-i-1])\r\n print(0)\r\n print(len(ans),end=' ')\r\n for i in ans:\r\n print(i,end=' ')\r\n \r\n else:\r\n a=[i+1 for i in range(n-1)]\r\n for i in range(0,(n-1)//2,2):\r\n ans.append(a[i])\r\n ans.append(a[n-i-2])\r\n print(0)\r\n print(len(ans),end=' ')\r\n for i in ans:\r\n print(i,end=' ')\r\n\r\n\r\nelse:\r\n a=[i+1 for i in range(n)]\r\n \r\n if((n)%2==0):\r\n for i in range(0,(n)//2-1,2):\r\n ans.append(a[i])\r\n ans.append(a[n-i-1])\r\n print(1)\r\n ans.append(a[n//2])\r\n print(len(ans),end=' ')\r\n for i in ans:\r\n print(i,end=' ')\r\n else:\r\n a=[i+1 for i in range(1,n)]\r\n for i in range(0,(n-1)//2,2):\r\n ans.append(a[i])\r\n ans.append(a[n-i-1-1])\r\n print(1)\r\n ans.append(1)\r\n print(len(ans),end=' ')\r\n for i in ans:\r\n print(i,end=' ')", "from math import ceil, sqrt \r\ndef solve_quadratic_equation(a, b, c): \r\n x1 = (-b+sqrt(b**2-4*a*c))/2*a\r\n x2 = (-b-sqrt(b**2-4*a*c))/2*a\r\n return max(x1, x2)\r\nn = int(input()) \r\nq = (n*(n+1))//2\r\nprint(q%2)\r\na = [n] \r\nS, E = -1, -1\r\np = ceil(q/2) - n \r\nfor i in range(1, n) : \r\n c = -i*(i-1)-2*p \r\n Solve = solve_quadratic_equation(1, 1, c)\r\n if Solve == int(Solve) : S = i; E = int(Solve) ; break\r\nprint(E-S+2, end = ' ') \r\nprint(n, end = ' ')\r\nfor i in range(S, E+1) : print(i, end = ' ') \r\nprint()", "n=int(input())\r\na,b=0,0\r\nl=[]\r\nfor i in range(n,0,-1):\r\n if a>b:\r\n b+=i\r\n else:\r\n a+=i\r\n l.append(i)\r\nprint(abs(a-b))\r\nprint(len(l),*l)", "n=int(input())\r\nres=[]\r\napp=res.append\r\nif n%2==1:\r\n for i in range(2,n//2+1,2):\r\n app(i)\r\n app(n-i+2)\r\n if (n//2)%2==1:app(n//2+2)\r\nelse:\r\n for i in range(1,n//2,2):\r\n app(i)\r\n app(n-i+1)\r\n if (n//2)%2==1:app(n//2)\r\nres.sort()\r\nprint((n*(n+1)//2)%2)\r\nprint(len(res),*res)", "n = int(input())\r\ngroup1 = []\r\n\r\nsum1 = 0\r\nsum2 = 0\r\n\r\nfor no in range(n, 0, -1):\r\n if sum1 <= sum2:\r\n group1.append(no)\r\n sum1 += no\r\n else:\r\n sum2 += no\r\n\r\nprint (abs(sum1 - sum2))\r\nprint (len(group1), end = ' ')\r\n\r\nfor no in group1:\r\n print (no, end = ' ')", "\nn = int(input())\n\nsum = n * (1 + n) / 4\nv = []\np = []\nsum_v = 0\nsum_p = 0\n\nfor i in range(n, 0, -1):\n if sum_v + i <= sum:\n sum_v += i\n v.append(i)\n else:\n sum_p += i\n\nif sum_v >= sum_p:\n print(sum_v - sum_p)\nelse:\n print(sum_p - sum_v)\n\nprint(len(v), end=' ')\nfor x in v:\n print(x, end=' ')\nprint()\n\n", "n = int(input())\r\ns = n * (n + 1) // 2\r\nprint(s & 1)\r\nx = s // 2\r\nres = set()\r\nfor i in range(n, 0, -1):\r\n\tif i <= x:\r\n\t\tx -= i\r\n\t\tres.add(i)\r\n\t\tif not x:\r\n\t\t\tbreak\r\nprint(len(res), *res)", "n=int(input())\r\n\r\ntemp1,temp2=[],[]\r\n\r\nnums=[ num for num in range(1,n+1)]\r\ni,j=0,n-1\r\nwhile i+2<j:\r\n \r\n i+=2\r\n j-=2\r\n \r\ni-=2\r\nj+=2\r\nremainder=nums[i+2:j-1]\r\nval=len(remainder)\r\nif val==0:\r\n print(0)\r\n i,j=0,n-1\r\n while i+2<j:\r\n temp1.append(nums[i])\r\n temp1.append(nums[j])\r\n temp2.append(nums[i+1])\r\n temp2.append(nums[j-1])\r\n i+=2\r\n j-=2\r\n print(len(temp1),end=\" \")\r\n for ele in temp1: print(ele,end=\" \")\r\n print()\r\n \r\nelif val==1:\r\n print(1)\r\n i,j=1,n-1\r\n while i+2<j:\r\n temp1.append(nums[i])\r\n temp1.append(nums[j])\r\n temp2.append(nums[i+1])\r\n temp2.append(nums[j-1])\r\n i+=2\r\n j-=2\r\n print(len(temp1),end=\" \")\r\n for ele in temp1: print(ele,end=\" \")\r\n print()\r\nelif val==2:\r\n print(1)\r\n i,j=2,n-1\r\n while i+2<j:\r\n temp1.append(nums[i])\r\n temp1.append(nums[j])\r\n temp2.append(nums[i+1])\r\n temp2.append(nums[j-1])\r\n i+=2\r\n j-=2\r\n print(len(temp1)+1,end=\" \")\r\n for ele in temp1: print(ele,end=\" \")\r\n print(1)\r\nelse:\r\n \r\n print(0)\r\n i,j=3,n-1\r\n while i+2<j:\r\n temp1.append(nums[i])\r\n temp1.append(nums[j])\r\n temp2.append(nums[i+1])\r\n temp2.append(nums[j-1])\r\n i+=2\r\n j-=2\r\n print(len(temp1)+1,end=\" \")\r\n for ele in temp1: print(ele,end=\" \")\r\n print(3)\r\n \r\n \r\n \r\n ", "n=int(input())\r\ntot=(n*(n+1))/2\r\nm=int(tot/2)\r\narr=[]\r\ns=0\r\nfor i in range(n,0,-1):\r\n s+=i\r\n if(s>m):\r\n s-=i\r\n else:\r\n arr.append(i)\r\ntot=int(tot-sum(arr))\r\nprint(abs(tot-sum(arr)))\r\nprint(len(arr),*arr)\r\n \r\n \r\n \r\n", "import sys\r\n#sys.stdin = open('in.txt')\r\n\r\nn = int(input())\r\n\r\na = []\r\ns1 = 0\r\ns2 = 0\r\nfor i in range(n, 0, -1):\r\n if s1 <= s2:\r\n s1 += i\r\n a.append(str(i))\r\n else:\r\n s2 += i\r\n\r\nprint(abs(s1-s2))\r\nprint(len(a), str.join(' ', a))\r\n", "import math\nn = int(input())\n\nsuma = n * (n + 1) / 2\narreglopeq_suma = suma / 2\nsumagra = 0\n\narreglopeq=[]\narreglogra=[]\nfor i in range(n, 0, -1):\n\n if (arreglopeq_suma - i >= 0) :\n arreglopeq.append(i)\n\n arreglopeq_suma -= i\n else:\n arreglogra.append(i)\n sumagra += i\n\nprint(sumagra - math.floor((suma/2)))\nprint(len(arreglopeq), end = \" \")\nfor i in range(0, len(arreglopeq)):\n print(arreglopeq[i], end = \" \")\n\n\t \t\t \t\t\t \t\t\t\t \t\t\t \t \t\t \t", "n = int(input())\n\nsoma = n * (n + 1)//2\nideal = soma // 2\n\nif n == 1:\n print(1)\n print(1, 1)\nelif n % 4 == 0:\n arr = list(range(1,n+1))\n res = []\n while arr:\n res.append(str(arr.pop(0)))\n res.append(str(arr.pop(-1)))\n arr.pop(0)\n arr.pop(-1)\n\n print(0)\n print(len(res), ' '.join(res))\nelse:\n total = 0\n second = 0\n arr = []\n for i in range(n, 0, -1):\n if total + i <= ideal:\n total += i\n arr.append(str(i))\n else:\n second += i\n\n print(abs(total-second))\n print(len(arr), ' '.join(arr))\n\n\t\t \t\t \t \t \t\t \t\t \t \t \t", "#I = lambda: [int(i) for i in input().split()]\r\n#import io, os, sys\r\n#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n\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\nmod = 1000000007\r\n# print(\"Case #\"+str(_+1)+\":\",)\r\n\r\nfrom collections import Counter,defaultdict\r\n#import sys\r\n#import bisect\r\n\r\nn = int(input())\r\nans=[]\r\ns = (n*(n+1))//2\r\nc = n//4\r\nif n&1:\r\n for i in range(2,n//2+2,2):\r\n ans.append(i)\r\n if c:\r\n ans.append(n+2-i)\r\n c-=1\r\n ans.append(1)\r\n \r\nelse:\r\n for i in range(1,n//2+1,2):\r\n ans.append(i)\r\n if c:\r\n ans.append(n+1-i)\r\n c-=1\r\n \r\n\r\nif s&1:\r\n print(1)\r\nelse:\r\n print(0)\r\nprint(len(ans),end=' ')\r\nprint(*ans)\r\n\r\n\r\n \r\n \r\n \r\n\r\n", "n = int(input())\r\n\r\ndef flatten(l):\r\n return [item for sublist in l for item in sublist]\r\n\r\ndef join(l):\r\n return ' '.join(map(str, l))\r\n\r\nif n%4==0:\r\n print(0)\r\n print(join([n//2] + flatten([[i+1, n-i] for i in range(n//4)])))\r\nelif n%4==1:\r\n print(1)\r\n print(join([n//2] + flatten([[i+2, n-i] for i in range(n//4)])))\r\nelif n%4==2:\r\n print(1)\r\n print(join([n//2, 1] + flatten([[i+3, n-i] for i in range(n//4)])))\r\nelif n%4==3:\r\n print(0)\r\n print(join([n//2+1, 1, 2] + flatten([[i+4, n-i] for i in range(n//4)])))", "n = int(input())\n\ns = int(n * (n + 1) / 2)\n\nmed = int(s / 2)\ni = n\ngroup = []\n\nwhile med != 0:\n\tif med >= i:\n\t\tmed -= i\n\t\tgroup.append(str(i))\n\ti -= 1\n\nprint(s % 2)\n\nl = len(group)\nprint(l, \" \".join(group))", "n = int(input())\nk = n%4\ngrp1 = []\nif k == 0:\n for i in range(1,n+1):\n if i%4 == 0 or i%4 ==1:\n grp1.append(i)\n print(0)\n grp1.insert(0, len(grp1))\n print(*grp1)\nif k == 1:\n for i in range(1,n+1):\n if i<= (n//4 +1) or i >= (n - n//4 +1):\n grp1.append(i)\n print(1)\n grp1.insert(0, len(grp1))\n print(*grp1) \nif k == 2:\n for i in range(1,n+1):\n if i%4 == 0 or i%4 ==1:\n grp1.append(i)\n print(1)\n grp1.insert(0, len(grp1))\n print(*grp1)\nif k ==3:\n for i in range(1,n+1):\n if i <= n//4 or i >= (n- n//4):\n grp1.append(i)\n print(0)\n grp1.insert(0, len(grp1))\n print(*grp1)\n\n\n", "n = int(input())\r\na = []\r\nif n % 4 == 0:\r\n print(0)\r\n for i in range(1, n + 1):\r\n if i % 4 == 0 or i % 4 == 1:\r\n a.append(i)\r\nelif n % 4 == 2:\r\n print(1)\r\n for i in range(1, n + 1):\r\n if i % 4 == 0 or i % 4 == 1:\r\n a.append(i)\r\nelif n % 4 == 1:\r\n print(1)\r\n for i in range(1, n + 1):\r\n if i % 4 == 1 or i % 4 == 2:\r\n a.append(i)\r\nelse:\r\n print(0)\r\n for i in range(1, n + 1):\r\n if i % 4 == 0 or i % 4 == 3:\r\n a.append(i)\r\nprint(len(a), *a)\r\n", "n = int(input())\nl = [x for x in range(1, n + 1)]\na = []\nb = []\na.append(l.pop())\nwhile l:\n b.append(l.pop())\n if l:\n b.append(l.pop())\n if l:\n a.append(l.pop())\n if l:\n a.append(l.pop())\nx = n % 4\nif x == 0 or x == 3:\n print(0)\nelse:\n print(1)\nprint(len(a), end=\" \")\nfor i in a:\n print(i, end=\" \")\n# 1540421010344\n", "x=int(input())\r\ns=[*range(1,x+1)]\r\ns=s[::-1]\r\nk=(x*(x+1))//2\r\nif k%2==0:\r\n print(0)\r\nelse:\r\n print(1)\r\n \r\np=k//2\r\nc=0\r\ni=0\r\nlol=[]\r\nwhile c<p:\r\n if c+s[i]<=p:\r\n c+=s[i]\r\n lol.append(s[i])\r\n i+=1\r\nprint(len(lol),*lol)\r\n \r\n", "from os import path\r\nfrom sys import stdin, stdout\r\n\r\n\r\nfilename = \"../templates/input.txt\"\r\nif path.exists(filename):\r\n stdin = open(filename, 'r')\r\n\r\n\r\ndef input():\r\n return stdin.readline().rstrip()\r\n\r\n\r\ndef print(*args, sep=' ', end='\\n'):\r\n stdout.write(sep.join(map(str, args)))\r\n stdout.write(end)\r\n\r\n\r\ndef sn(a1: int, an: int, n: int) -> int:\r\n return (a1 + an) * n // 2\r\n\r\n\r\ndef solution():\r\n n = int(input())\r\n total = sn(1, n, n)\r\n s = set(range(1, n + 1))\r\n ans = []\r\n cur = total // 2\r\n k = n\r\n while cur > 0:\r\n if cur in s:\r\n ans.append(cur)\r\n s.remove(cur)\r\n cur = 0\r\n else:\r\n ans.append(k)\r\n s.remove(k)\r\n cur -= k\r\n k -= 1\r\n print(total - total // 2 * 2)\r\n print(len(ans), *ans)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\ndef main():\r\n t = 1\r\n while t:\r\n solution()\r\n t -= 1\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "n = int(input())\nres = []\nk = 1\nif n % 4 == 0:\n print(0)\nelif n % 4 == 1:\n print(1)\n k = 2\nelif n % 4 == 2:\n print(1)\n res.append(n // 2)\nelse:\n print(0)\n k = 2\n res.append(n // 2 + 2)\nfor x in range(n // 4):\n res.append(x + k)\n res.append(n - x)\nprint(len(res), ' '.join([str(x) for x in res]))\n\t\t\t\t\t \t \t\t\t \t\t \t \t\t\t\t\t\t\t\t\t", "#constructive algorithm, graphs, math\r\n#Try 1\r\nn = int(input())\r\nAnsList = []\r\nX = int((n*(n+1)/2))\r\nif(X%2==0):\r\n print(0)\r\nelse:\r\n print(1)\r\nSum = 0\r\nTill = int(X//2)\r\nfor i in range(n,0,-1):\r\n Sum+=i\r\n if(Sum<Till):\r\n AnsList.append(i)\r\n else:\r\n Sum-=i\r\n break\r\nAnsList.append(Till-Sum)\r\nAnsList.insert(0,len(AnsList))\r\nprint(*AnsList)", "# Q3\nn = int(input())\nres = n%4\nif res == 0:\n d = 0\n nl = list(range(1,n+1,4))+list(range(4,n+1,4))\nelif res == 3:\n d = 0\n nl =[1,2] + list(range(4,n+1,4))+list(range(7,n+1,4))\nelif res == 1:\n d = 1\n nl = list(range(2,n+1,4))+list(range(5,n+1,4))\nelse:\n d = 1\n nl = [1]+list(range(3,n+1,4))+list(range(6,n+1,4))\n \nprint(d)\nprint(len(nl),end=\" \")\nprint(\" \".join(map(str,nl)))", "n=int(input())\r\narr=[]\r\nif n%4==0:\r\n ans=0\r\n for x in range(1,n+1):\r\n if x%4==1 or x%4==0:\r\n arr.append(x)\r\nif n%4==1:\r\n ans=1\r\n for x in range(1,n+1):\r\n if x%4==2 or x%4==1:\r\n arr.append(x)\r\nif n%4==2:\r\n ans=1\r\n for x in range(1,n+1):\r\n if x%4==3 or x%4==2:\r\n arr.append(x)\r\nif n%4==3:\r\n ans=0\r\n for x in range(1,n+1):\r\n if x%4==0 or x%4==3:\r\n arr.append(x)\r\nprint(ans)\r\nprint(len(arr),end=\" \")\r\nprint(*arr)", "n = int(input())\r\nadd, v = 0, []\r\nif n % 2:\r\n n, add, v = n - 3, add + 1, [3]\r\nif n % 4 == 0:\r\n print(0, n // 2 + add, sep='\\n', end=' ')\r\n for i in range(1, n // 4 + 1):\r\n print(i + add * 3, n - i + 1 + add * 3, end=' ')\r\n print(*v)\r\nelif n % 2 == 0:\r\n print(1, n // 2 + add, sep='\\n', end=' ')\r\n for i in range(1, n // 4 + 1):\r\n print(i + add * 3, n - i + 1 + add * 3, end=' ')\r\n print(n // 2 + add * 3, *v)\r\n\r\n", "n=int(input())\ntot=n*(n+1)//2\nl=[]\nif n==2:\n\tprint(1)\n\tprint('1 1')\n\texit(0)\nif n==3:\n\tprint(0)\n\tprint('2 1 2')\n\texit(0)\ni=1\nif tot%2==0:\n\ttot//=2\n\twhile 1:\n\t\ttot-=n+1\n\t\tl.append(i)\n\t\tl.append(n+1-i)\n\t\tif tot==0:\n\t\t\tbreak\n\t\telif tot<=n and tot>i:\n\t\t\tl.append(tot)\n\t\t\tbreak\n\t\ti+=1\n\tprint('0')\nelse:\n\ttot//=2\n\twhile 1:\n\t\ttot-=n+1\n\t\tl.append(i)\n\t\tl.append(n+1-i)\n\t\tif tot<=n and tot>i:\n\t\t\tl.append(tot)\n\t\t\tbreak\n\t\telif tot<=n and tot+1>i:\n\t\t\tl.append(tot+1)\n\t\t\tbreak\n\t\ti+=1\n\tprint('1')\nprint(len(l),end=\" \")\nfor i in l:\n\tprint(i,end=\" \")", "n=int(input())\r\n\r\ns=n\r\n\r\ni=n-1\r\ng=[n]\r\nwhile i>0:\r\n\tif s>0:\r\n\t\ts-=i\r\n\telse:\r\n\t\ts+=i\r\n\t\tg.append(i)\r\n\ti-=1\r\n\r\nprint(s)\r\nprint(len(g),end=' ')\r\nprint(*g)", "n = int(input())\r\ni = 1\r\nl = []\r\n\r\nif n%2 == 1:\r\n l= [1]\r\n i = 2\r\n print((n//2+1)%2)\r\nelse:\r\n print((n//2)%2)\r\n\r\nj = 0\r\nwhile i<= n:\r\n l.append(i)\r\n i = i + 3 if j % 2 == 0 else i+1\r\n j = (j+1)%2\r\n\r\nprint(len(l), *l, sep = \" \")\r\n\r\n", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nn = int(input())\r\nans = [0]\r\nx = [i for i in range(1, n + 1)]\r\nwhile len(x) >= 4:\r\n x.pop()\r\n ans.append(x.pop())\r\n ans.append(x.pop())\r\n x.pop()\r\nif len(x) == 3:\r\n ans.append(x.pop())\r\n x.pop()\r\n x.pop()\r\nm = 0\r\nif x:\r\n m = 1\r\n ans.append(1)\r\nans[0] = len(ans) - 1\r\nprint(m)\r\nsys.stdout.write(\" \".join(map(str, ans)))", "N = int(input())\r\n\r\nif (N%4 in [0, 3]):\r\n print(0)\r\nelse:\r\n print(1)\r\n\r\nif (N%4 in [0, 1]):\r\n print( N//4*2, end = \" \" )\r\nelse:\r\n print( N//4*2+1, end = \" \" )\r\n\r\nwhile N>=4:\r\n print(N, N-3, end = \" \")\r\n N -= 4\r\nif N==3:\r\n print(3, end = \" \")\r\nif N==2:\r\n print(2, end = \" \")", "import sys\ninput = sys.stdin.readline\n\n############ ---- Input Functions ---- ############\n\n# integer inputs\ndef inp():\n return(int(input()))\n\n# list inputs \ndef inlt():\n return(list(map(int,input().split())))\n\n# string inputs (list of chars)\ndef insr():\n s = input()\n return(list(s[:len(s) - 1]))\n\n# space separated integer variable inputs\ndef invr():\n return(map(int,input().split()))\n\n###################################################\n\ndef main():\n n = inp()\n nums = [x for x in range(1, n+1)]\n total_sum = sum(nums)\n\n group_one = []\n if n % 4 == 1:\n group_one = [1]\n nums = nums[1:]\n n -= 1\n elif n % 4 == 2:\n group_one = [1]\n nums = nums[2:]\n n -= 2\n elif n % 4 == 3:\n group_one = [1, 2]\n nums = nums[3:]\n n -= 3\n one = True\n for i in range(n//2):\n if one:\n group_one.append(nums[i])\n group_one.append(nums[n-1-i])\n one = False \n else:\n one = True \n\n one_sum = sum(group_one)\n diff = abs((total_sum - one_sum) - one_sum)\n print(diff)\n\n print(len(group_one), end=\" \")\n for num in group_one:\n print(num, end=\" \")\n\nmain()", "n=int(input())\r\nf=0\r\ns=(n*(n+1))//2\r\nm=s\r\ns=s//2\r\nj=s\r\nk=m-s\r\nl=[]\r\nwhile n>0:\r\n if s==0:\r\n break\r\n if n>s:\r\n pass\r\n else:\r\n l.append(n)\r\n s-=n\r\n n-=1\r\nprint(abs(k-j))\r\nprint(len(l),*l)\r\n", "n=int(input())\r\nn2,a,b=(n*n+n)//2,[],0\r\nprint(n2%2)\r\nn2//=2\r\nwhile n2>=n:\r\n a,n2,n,b=a+[n],n2-n,n-1,b+1\r\nif n2!=0:\r\n a,b=a+[n2],b+1\r\nprint(b,' '.join(map(str,a)))", "n = int(input())\nf = 0\nl = 0\narr = []\nfor i in range(n, 0, -1):\n if f <= l:\n f += i\n arr.append(i)\n else:\n l += i\nprint(abs(f - l))\nprint(len(arr), *arr)", "n = int(input())\r\nsum_val = n * (n + 1) // 2\r\nprint(sum_val % 2)\r\nsum_val //= 2\r\nds = []\r\nfor i in range(n, 0, -1):\r\n if sum_val >= i:\r\n sum_val -= i\r\n ds.append(i)\r\nprint(len(ds), end=\" \")\r\nprint(*ds)# 1691238002.2104461", "from sys import stdin,stdout\r\nfrom collections import Counter\r\ndef ai(): return list(map(int,input().split()))\r\ndef ei(): return map(int,input().split())\r\ndef ip(): return int(stdin.readline())\r\ndef op(ans): return stdout.write(str(ans) + '\\n')\r\n\r\nn = ip()\r\nr = l = 0\r\nli = []\r\nfor i in range(n,0,-1):\r\n\tif r < l:\r\n\t\tr += i\r\n\telse:\r\n\t\tl += i\r\n\t\tli.append(i)\r\nprint(abs(r-l))\r\nprint(len(li),*li)", "n = int(input())\r\n\r\nl = [x for x in range(1, n + 1)]\r\n\r\ng1 = []\r\ng2 = []\r\n\r\nif n % 2 == 1:\r\n l = l[1:]\r\n a = l[:len(l) // 2]\r\n b = l[len(l) // 2:]\r\n b.reverse()\r\n\r\n\r\n if len(a) % 2 == 1:\r\n for x in range(len(a) - 1):\r\n if x % 2 == 0:\r\n g1.append(a[x])\r\n g1.append(b[x])\r\n\r\n else:\r\n g2.append(a[x])\r\n g2.append(b[x])\r\n\r\n g1.append(a[len(a) - 1])\r\n g2.append(b[len(a) - 1])\r\n\r\n else:\r\n for x in range(len(a)):\r\n if x % 2 == 0:\r\n g1.append(a[x])\r\n g1.append(b[x])\r\n\r\n else:\r\n g2.append(a[x])\r\n g2.append(b[x])\r\n\r\n sumg1 = sum(g1)\r\n sumg2 = sum(g2)\r\n\r\n if(sumg1 < sumg2):\r\n g1.append(1)\r\n sumg1+=1\r\n else:\r\n g2.append(1)\r\n sumg2+=1\r\n\r\n print(abs(sumg1 - sumg2))\r\n print(len(g1), end=' ')\r\n for z in g1:\r\n print(z, end=' ')\r\n\r\n\r\nelse:\r\n a = l[:len(l) // 2]\r\n b = l[len(l) // 2:]\r\n b.reverse()\r\n\r\n\r\n\r\n if len(a) % 2 == 1:\r\n for x in range(len(a) - 1):\r\n if x % 2 == 0:\r\n g1.append(a[x])\r\n g1.append(b[x])\r\n\r\n else:\r\n g2.append(a[x])\r\n g2.append(b[x])\r\n\r\n g1.append(a[len(a) - 1])\r\n g2.append(b[len(a) - 1])\r\n\r\n else:\r\n for x in range(len(a)):\r\n if x % 2 == 0:\r\n g1.append(a[x])\r\n g1.append(b[x])\r\n\r\n else:\r\n g2.append(a[x])\r\n g2.append(b[x])\r\n\r\n sumg1 = sum(g1)\r\n sumg2 = sum(g2)\r\n print(abs(sumg1 - sumg2))\r\n print(len(g1), end=' ')\r\n for z in g1:\r\n print(z, end=' ')", "n = int(input())\r\nif n == 2:\r\n print(1)\r\n print(1, 1)\r\nelif n % 4 == 0:\r\n print(0)\r\n r = n//4\r\n print(2*r, end = \" \")\r\n for i in range(r+1, 3*r + 1):\r\n print(i, end = \" \")\r\nelif n%4 == 1:\r\n print(1)\r\n r = n//4\r\n print(2*r, end = \" \")\r\n for i in range(r+2, 3*r + 2):\r\n print(i, end = \" \")\r\n # print(3*r + 2)\r\nelif n%4 == 2:\r\n print(1)\r\n r = n//4\r\n print(2*r, end = \" \")\r\n for i in range(r+3, 3*r + 2):\r\n print(i, end = \" \")\r\n print(3*r + 3)\r\nelse:\r\n print(0)\r\n r = n//4\r\n print(2*r + 2, end = \" \")\r\n for i in range(r+1, 3*r + 3):\r\n print(i, end = \" \")\r\n # print(3*r + 2)\r\n", "n=int(input())\r\nt = n*(n+1) // 2 ;\r\n\r\nif t%2==0:\r\n print(0)\r\n t=t//2\r\nelse:\r\n print(1)\r\n t=t//2\r\ni=n\r\nans = []\r\nwhile t-i>0:\r\n t-=i\r\n ans.append(i)\r\n i-=1\r\nprint(len(ans)+1 , end=\" \")\r\nans.append(t)\r\nfor i in ans:print(i , end= \" \")\r\n\r\n \r\n", "n = int(input())\r\nprint((((n + 1) * n) // 2) % 2)\r\nk = 0\r\nL = []\r\nfor i in range(n, 0, -2):\r\n k += 1\r\n if k % 2:\r\n ans = i\r\n else:\r\n ans = i - 1\r\n if ans:\r\n L.append(ans)\r\nprint(len(L), end = ' ')\r\nfor i in range(len(L)):\r\n print(L[i], end = ' ')\r\n \r\n \r\n", "a=int(input())\r\nif a%4==0:\r\n print(0)\r\n print(2*(a//4),end=\" \")\r\n for i in range(a//4):print(1+2*i,a-2*i,end=\" \")\r\nelif a%2==0:\r\n print(1)\r\n print(2*(a//4)+1,end=\" \")\r\n for i in range(a // 4): print(1 + 2 * i, a - 2 * i,end=\" \")\r\n print(a//2)\r\nelif a%4==3:\r\n print(0)\r\n print(2*(a//4)+1,end=\" \")\r\n for i in range(a//4):print(2+2*i,a-2*i,end=\" \")\r\n print(1+(a+1)//2)\r\nelse:\r\n print(1)\r\n print(2*(a//4),end=\" \")\r\n for i in range(a // 4): print(2 + 2 * i, a - 2 * i,end=\" \")", "x = int(input())\r\ni = 1\r\nif x%4 == 0:\r\n print(0)\r\n print(int(x/2), end=' ')\r\n while i < int(x/2):\r\n print(i,end=' ')\r\n print(x-i+1,end=' ')\r\n i+=2\r\nif x%4 == 1:\r\n print(1)\r\n print(int(x/2), end=' ')\r\n while i < int(x/2):\r\n if i == 1:\r\n t = int(int(x/2+1)/2)\r\n if t%2 == 0:\r\n t+=1\r\n print(i + t,end=' ')\r\n else:\r\n print(i,end=' ')\r\n print(x-i+1,end=' ')\r\n i+=2\r\nif x%4 == 2:\r\n print(1)\r\n print(int(x/2), end=' ')\r\n while i < int(x/2):\r\n print(i,end=' ')\r\n print(x-i+1,end=' ')\r\n i+=2\r\n print(i)\r\nif x%4 == 3:\r\n print(0)\r\n print(int(x/2),end=' ')\r\n i = 1\r\n while i <= int(x/4):\r\n print(i,end=' ')\r\n print(x-i,end=' ')\r\n i += 1\r\n print(x)", "n = int(input())\n\ng1 = []\ng2 = []\ns1 = s2 = n1 = 0\n\nfor i in range(n, 0, -1):\n if s1 <= s2:\n g1.append(i)\n s1 += i\n n1 += 1\n else:\n g2.append(i)\n s2 += i\n\nprint(abs(s1 - s2))\nprint(n1, end=' ')\nprint(' '.join(f'{a}' for a in g1))\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Aug 28 03:20:26 2020\r\n\r\n@author: Dark Soul\r\n\"\"\"\r\ndef flip(n):\r\n if n:\r\n return 0\r\n else:\r\n return 1\r\nn=int(input(''))\r\nans=[0,1,1]\r\nfor i in range(3,60002):\r\n if ans[i-1]==ans[i-2]:\r\n ans.append(flip(ans[i-1]))\r\n else:\r\n ans.append(ans[i-1])\r\n \r\nsol=[]\r\na=0\r\nfor i in range(n,0,-1):\r\n if a<=0:\r\n a+=i\r\n sol.append(i)\r\n else:\r\n a-=i\r\nprint(ans[n])\r\nprint(len(sol),*sol)", "while True:\n try:\n n = int(input())\n except:\n break\n \n k = n % 4\n t = n // 4\n \n if k == 0:\n print(0)\n print(t * 2, end=' ')\n for i in range(1, t+1):\n print(i, n-i+1, end=' ')\n print()\n \n elif k == 1:\n print(1)\n print(t * 2 + 1, 1, end=' ')\n for i in range(1, t+1):\n print(i+1, n-i+1, end=' ')\n print()\n \n elif k == 2:\n print(1)\n print(t * 2 + 1, 1, end=' ')\n for i in range(1, t+1):\n print(i+2, n-i+1, end=' ')\n print()\n \n else:\n print(0)\n print(t * 2 + 1, 3, end=' ')\n for i in range(1, t+1):\n print(i+3, n-i+1, end=' ')\n print()\n\t\t \t \t \t\t \t \t\t\t \t \t\t", "n = int(input())\ngoal = (n * (n + 1)) >> 1\nans = 1 if goal & 1 == 1 else 0\n\nlis = ''\ncnt = 0\ngoal >>= 1\nwhile goal > 0:\n if goal > n:\n goal -= n\n lis += ' ' + str(n)\n n -= 1\n else:\n lis += ' ' + str(goal)\n goal = 0\n cnt += 1\n\nprint(ans)\nprint(str(cnt) + lis)\n", "import sys\r\nmod = 1000000007\r\ndef get_array(): return list(map(int, sys.stdin.readline().split()))\r\ndef get_ints(): return map(int, sys.stdin.readline().split())\r\ndef input(): return sys.stdin.readline()\r\ndef print_array(a): print(\" \".join(map(str, a)))\r\ndef main():\r\n n = int(input())\r\n l = list(range(1, n+1))\r\n a = []\r\n target = (n * (n+1))//4\r\n accum = 0\r\n for i in reversed(l):\r\n if accum + i <= target:\r\n a.append(i)\r\n accum += i \r\n print(abs(accum - (n*(n+1))//2 + accum))\r\n print(len(a), ' '.join(str(x) for x in a))\r\nif __name__ == \"__main__\":\r\n main()", "n=int(input())\r\nprint(0if n%4==0 or n%4==3else 1)\r\nl=[]\r\nif n%4==0 or n%4==2:\r\n if n%4==2:l.append(n//2)\r\n for i in range(1,n//4+1):l.append(i);l.append(n+1-i)\r\nelse:\r\n if n%4==3:l.append(1);l.append(n//2+1)\r\n for i in range(2,n//4+2):l.append(i);l.append(n+2-i)\r\nprint(len(l),*l)", "n=int(input())\r\nx,y=0,0\r\nl=[]\r\nfor i in range(n,0,-1):\r\n if(x>y):\r\n y+=i\r\n else:\r\n x+=i\r\n l.append(i)\r\nprint(abs(x-y))\r\nprint(len(l),*l)", "n=int(input())\r\na=n*(n+1)//2\r\nif(a%2==0):\r\n print(0)\r\nelse:\r\n print(1)\r\nl1=set()\r\nl2=set()\r\nsum1=0\r\nsum2=0\r\nfor i in range(n,0,-1):\r\n if(sum1>=sum2):\r\n sum2+=i\r\n else:\r\n sum1+=i\r\n l1.add(i)\r\nprint(len(l1),*l1)", "n = int(input())\ngroup_1 = []\nsum_group_1 = 0\nsum_group_2 = 0\nfor number in range(n, 0, -1):\n\tif sum_group_1 <= sum_group_2:\n\t\tgroup_1.append(str(number))\n\t\tsum_group_1 += number\n\telse:\n\t\tsum_group_2 += number\n\nprint(abs(sum_group_1 - sum_group_2))\nprint(len(group_1), end=\" \")\nprint(\" \".join(group_1))\n \t \t \t\t \t \t \t\t \t\t\t", "n=int(input())\r\ns=n*(n+1)//2\r\nf=s//2+s%2\r\nl=[]\r\nwhile n>0:\r\n if f-n>=0:\r\n l+=[n]\r\n f-=n\r\n n-=1\r\nprint(s%2)\r\nprint(len(l),' '.join(map(str,l)))\r\n", "def main(): \n\tn = int(input())\n\ta_s = 0\n\tb_s = 0\n\tass = []\n\tbss = []\n\tfor i in range(n,0,-1):\n\t\tif a_s>b_s:\n\t\t\tb_s+=i\n\t\t\tbss.append(i)\n\t\telse:\n\t\t\ta_s+=i\n\t\t\tass.append(i)\n\tprint(abs(a_s-b_s))\n\tprint(len(ass),end=' ')\n\tfor a in ass:\n\t\tprint(a,end=' ')\n\tprint()\n\n\n\n\nif __name__ ==\"__main__\":\n\tmain()\n\t \t \t \t \t\t \t\t \t\t \t\t\t\t", "n, first, second, ar = int(input()), 0, 0, []\nfor i in range(n, 0, -1):\n if first >= second:\n second += i\n else:\n first += i\n ar.append(i)\nprint(abs(first-second), len(ar), ' '.join(map(str, ar)), sep='\\n')", "n=int(input())\r\nif n%2==0 :\r\n l=[]\r\n i=0\r\n for j in range(n//2):\r\n if j%2==0:\r\n i+=1\r\n else:\r\n i+=3\r\n l.append(i)\r\n if (n//2)%2==0:\r\n print(0)\r\n print(n//2,*l)\r\n else:\r\n print(1)\r\n print(n//2,*l)\r\nelse:\r\n l=[] \r\n i=0\r\n for j in range(n//2):\r\n if j%2==0:\r\n i+=3\r\n else:\r\n i+=1\r\n l.append(i)\r\n if ((n-1)//2)%2==0:\r\n print(1)\r\n print(n//2,*l)\r\n else:\r\n print(0)\r\n print(n//2,*l)\r\n \r\n", "n = int(input())\r\ns1,s2 = 0,0\r\nl1,l2 = [],[]\r\nfor i in range(n,0,-1):\r\n if s1 > s2:\r\n s2 += i\r\n l2.append(i)\r\n else:\r\n s1 += i\r\n l1.append(i)\r\nprint(abs(s1-s2))\r\nprint(len(l1),end=\" \")\r\nfor i in l1:\r\n print(i,end=\" \")\r\n", "#for i in range(int(input())):\r\nn=int(input())\r\ns1=0\r\ns2=0\r\narr=[]\r\nfor i in range(n,0,-1):\r\n if s1>s2:\r\n s2+=i\r\n else:\r\n s1+=i\r\n arr.append(i)\r\nprint(abs(s2-s1),)\r\nprint(len(arr),end=\" \")\r\nprint(*arr)", "n = int(input())\r\nif ((n + 1) * n // 2) % 2 == 0:\r\n print(0)\r\nelse:\r\n print(1)\r\nleft = 0\r\nright = 0\r\nans = []\r\nfor i in range(n, 0, -1):\r\n if left < right:\r\n left += i\r\n ans.append(i)\r\n else:\r\n right += i\r\nprint(len(ans), *ans)", "n = int(input())\r\nl,t,s1,s2 = [n],[n-1],n,n-1\r\nfor i in range(n-2,0,-1):\r\n if s1<s2:\r\n l.append(i)\r\n s1 += i\r\n else:\r\n t.append(i)\r\n s2 += i\r\nprint(abs(s2-s1))\r\nprint(len(l),*l)", "from sys import stdin\r\ninput=stdin.readline\r\nread=lambda :map(lambda s:int(s),input().strip().split())\r\nfrom collections import defaultdict\r\nfrom math import gcd\r\nn=int(input())\r\nsa,sb=0,0\r\na,b=[],[]\r\ni=n\r\nwhile i:\r\n if sa<sb:\r\n a.append(i)\r\n sa+=i\r\n else:\r\n b.append(i)\r\n sb+=i\r\n i-=1\r\n\r\nprint(abs(sa-sb))\r\nprint(len(a),*a)\r\n", "n = int(input())\r\nl = [n]\r\nt = [n-1]\r\ns1 = n\r\ns2 = n-1\r\nfor i in range(n-2,0,-1):\r\n if s1<s2:\r\n l.append(i)\r\n s1 += i\r\n else:\r\n t.append(i)\r\n s2 += i\r\nprint(abs(s2-s1))\r\nprint(len(l),*l)", "n = int(input())\r\ns = n*(n+1) // 2\r\nA = []\r\nx = 0\r\n\r\nfor a in reversed(range(1, n+1)):\r\n if x+a <= s//2:\r\n A.append(a)\r\n x += a\r\n\r\nprint(s%2)\r\nprint(len(A), *A)", "n = int(input())\r\nl = [n]\r\nr = []\r\nfor i in range(n-1, 0, -4):\r\n r.append(i)\r\n if i > 1:\r\n r.append(i-1)\r\nfor i in range(n-3, 0, -4):\r\n l.append(i)\r\n if i > 1:\r\n l.append(i-1)\r\nprint(abs(sum(l)-sum(r)))\r\nprint('' + str(len(l))+ ' ' +' '.join(map(str, l)))", "n = int(input())\r\nres = []\r\nleft = right = 0\r\nfor i in range(n,0,-1):\r\n if left > right:\r\n right += i\r\n else:\r\n left += i\r\n res.append(i)\r\nprint(abs(left-right))\r\nprint(len(res), *res)\r\n", "import math\r\nn = int(input())\r\nans = []\r\nb = False\r\nif n%4==0:\r\n print(0)\r\n print(n//2,end = ' ')\r\n for i in range(n//4):\r\n print(i+1,n-i,end = ' ')\r\nif n%4==1:\r\n print(1)\r\n if (n//4%2)==0:\r\n print(n//2+1,end = ' ')\r\n for i in range(n//4):\r\n print(2*i+1,n-2*i,end = ' ')\r\n print((n//2+1)//2,end = ' ')\r\n if (n//4%2)==1:\r\n print(n//2+1,end = ' ')\r\n for i in range(n//4):\r\n print(2*i+1,n-2*i,end = ' ')\r\n print((n//2+1)//2+1,end = ' ')\r\nif n%4==2:\r\n print(1)\r\n print(n//2,end = ' ')\r\n for i in range(n//4):\r\n print(2*i+1,n-2*i,end = ' ')\r\n print(n//2)\r\nif n%4==3:\r\n if n ==3:\r\n print(0)\r\n print(1,' ',3)\r\n if n>3:\r\n print(0)\r\n for i in range(n//4):\r\n ans.append(1+2*i)\r\n ans.append(n - 2*i)\r\n for i in range(len(ans)):\r\n if ans[i]==int(n/4-0.75):\r\n ans[i] = n//2\r\n ans.append(n//2+1)\r\n b = True\r\n if b == False:\r\n ans.append(n//2+2)\r\n ans.append(int(n/4-0.75))\r\n print(len(ans),end = ' ')\r\n for i in range(len(ans)):\r\n print(ans[i],end = ' ')\r\n \r\n \r\n \r\n \r\n\r\n \r\n", "n = int(input())\nsum_of_n = n * (n + 1) / 2\nmodulo = int(sum_of_n % 2)\nsum_of_n = int(sum_of_n / 2) if modulo == 0 else int(sum_of_n // 2)\nprint(str(modulo))\ndigits = []\nwhile sum_of_n != 0:\n if sum_of_n >= n:\n digits.append(str(n))\n sum_of_n -= n\n n -= 1\n else:\n digits.append(str(sum_of_n))\n sum_of_n -= sum_of_n\nprint(str(len(digits)), \" \".join(digits))\n \t \t\t\t\t \t\t\t \t\t\t \t\t \t\t \t", "n = int(input())\r\nm = n % 4\r\nrec = []\r\nif m == 0:\r\n for i in range(1, n + 1, 4):\r\n rec.append(i)\r\n for i in range(4, n + 1, 4):\r\n rec.append(i)\r\n rec = sorted(rec)\r\n print(0)\r\n print(\"{} \".format(len(rec)) + \" \".join(map(str, rec)))\r\nelif m == 3:\r\n for i in range(4, n + 1, 4):\r\n rec.append(i)\r\n for i in range(7, n + 1, 4):\r\n rec.append(i)\r\n rec = sorted(rec)\r\n print(0)\r\n print(\"{} {} \".format(len(rec) + 1, 3) + \" \".join(map(str, rec)))\r\nelif m == 2:\r\n for i in range(3, n + 1, 4):\r\n rec.append(i)\r\n for i in range(6, n + 1, 4):\r\n rec.append(i)\r\n rec = sorted(rec)\r\n print(1)\r\n print(\"{} {} \".format(len(rec) + 1, 2) + \" \".join(map(str, rec)))\r\nelse:\r\n for i in range(2, n + 1, 4):\r\n rec.append(i)\r\n for i in range(5, n + 1, 4):\r\n rec.append(i)\r\n rec = sorted(rec)\r\n print(1)\r\n print(\"{} {} \".format(len(rec) + 1, 1) + \" \".join(map(str, rec)))", "n = int(input())\r\n\r\nv = int(n * (n + 1) / 2)\r\nprint(v % 2)\r\ntarg = int(v / 2)\r\n\r\nseq = []\r\nfor i in range(n, 0, -1):\r\n if (targ >= i):\r\n targ -= i\r\n seq.append(i)\r\n\r\nprint(len(seq), end = \" \")\r\n[print(seq[i], end = \" \") for i in range(len(seq))]", "n = int(input())\r\nif n%2==0:\r\n x = n//2\r\n if x%2==0:\r\n print(0)\r\n else:\r\n print(1)\r\n arr1 = []\r\n arr2 = []\r\n cnt = 0\r\n for i in range(1,n+1,2):\r\n if cnt==0:\r\n arr1.append(i)\r\n arr2.append(i+1)\r\n cnt = cnt^1\r\n else:\r\n arr1.append(i+1)\r\n arr2.append(i)\r\n cnt = cnt^1\r\n print(len(arr1),*arr1)\r\nelse:\r\n x = n-1\r\n x = x//2\r\n if x%2==0:\r\n print(1)\r\n else:\r\n print(0)\r\n arr1 = []\r\n arr2 = []\r\n cnt = 0\r\n for i in range(2,n+1,2):\r\n if cnt==0:\r\n arr1.append(i)\r\n arr2.append(i+1)\r\n cnt = cnt^1\r\n else:\r\n arr1.append(i+1)\r\n arr2.append(i)\r\n cnt = cnt^1\r\n if sum(arr1)<=sum(arr2):\r\n arr1.append(1)\r\n print(len(arr1),*arr1)\r\n else:\r\n arr2.append(1)\r\n print(len(arr2),*arr2)", "\"\"\"\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n ..,,,,,,,,************,,,,,,,,,,,,,.\r\n ..,*. .,,,,,,,,,,,,,,,,,,,,,,,,...\r\n #&@@@@@@@@@@@@@@@@@( .....,,,,,,,.....\r\n (*@@@@@@@@@@@@@@@@@@@@@@@@&* ...,,,,,\r\n &*&@@@@@@%@%,.*%@@@@@@@@@@@@@@@@& (&@@@@&%/ ..,,,,,,,,,,,,,*******\r\n ##@@@@@@&#, *@@@@@@@@@@@@ (@@@@@@@@@@@@@@@@@@@@@( . /@@@@(,,,,,,,*********//\r\n (@@@@@@@. #@@@@@@@@@@* %@@@@@@@@@@@@&&@@@@@@@@@@@@@@@% ,@@@@@@% /@@@@@@(...,,,,,,,,,,,,,,**\r\n ,,@@@@@@, #@@@@@@@&, %@@@@@@@/ #@@@@@@@& @@@@@@@@@& .... ,@@@@@@@/ ..,,,,,,,,\r\n ,@@@@@@, .&@@@@&. &@@@@@@. ,&@@@@@@, @@@@@@@@@@, @@@@@@@@% ..,,,\r\n /&@@@@@/ &@ %@@@@@@ #@@@@@@/ /@@@@@@@@@@& @@@@@@@@@@ .\r\n @@@@@@/ &@@@@@, *@@@@@@. @@@@@@@@@@@@ *@@@@@@@@@@&\r\n &&@@@@% @@@@@@ .&@@@@@@@@@@@@& (@@@@@@ #@@@@@@@@@@@# @@@@@@@@@@@&\r\n *%&&@@@*# @@@@@@ /@@@@@@@@@@@@@@@@@@@% @@@@@@ .@@@@@@@@@@@@ @@@@@@@@@@@&\r\n .&@@@@@*( /@@@@@, @@@@@@@@@@@# &@@@@@@@@@( &@@@@@ .@@@@@@@@@@@& @@@@@@@@@@@,\r\n .&@@@@@@% &@@@@@ @@@@@@@@@@@. @@@@@@@@& &@@@@@ &@@@@@@@@@@@@@@@@@@@@\r\n (/@@@@@@@#. @@@@@& ,@@@@@@@@@ .@@@@@@% @@@@@% @@@@@@@@@@@@@@@@@#\r\n &%@@@@@@@@@# @@@@@& *@@@@@@@@ /@@@@@& ,@@@@@ @@@@@@@@@@@@@@,\r\n (,@@@/%@@@@@@@@@@@&, &@@@@@ @@@@@@@& @@@@@@* @@@@@. @@@@@@@@@@@\r\n . &@@@@@@@@@@@@@@@@@@@, @@@@@( *@@@@@@@, ,@@@@@@@ @@@@@, ,@@@@@@@@@@@@\r\n .&@@@@@@@@@@@@@@@@@@, &@@@@@ (@@@@@@@& ,@@@@@@@& @@@@@ @@@@@@@@@@@@@@@@\r\n (@@@@@@@@@@@@, &@@@@@ @@@@@@@@@@@@@&@@@@@@@@@@@ @@@@@@ /@@@@@@@@.@@@@@@@@@&\r\n %@@@@@@@@@% @@@@@@ &@@@@@@@@@@@@@@@@@@@@( #@@@@& (@@@@@@@& .@@@@@@@@@/\r\n *@@@@@@@@# @@@@@@. &@@@@@@@@@@@@@@, &@@@@@. .@@@@@@@# @@@@@@@@@\r\n &@@@@@@@ &@@@@@& %@@@@@@ *@@@@@@@ @@@@@@@@&\r\n &@@@@@@, %@@@@@@& &@@@@@@( .....,,.&@@@@@@& #&@@@@@@.\r\n %@@@@@@ ........@@@@@@@@ . %@@@@@@@( .,,,,,,,,*@@@@@@@ /@@@@@@@\r\n &@@@@@@ .....,,,,,,,,@@@@@@@@# *@@@@@@@@@. ..,,,,,,,,,,%@@@@@@@ .@@@@@@#\r\n @@@@@@. ....,,,,,,,,,,,@@@@@@@@@@@@@@# *&@@@@@@@@@@@@@@@@ .,,,,,,,,,,,,,,@@@@@@@* @@@@@@,\r\n * @@@@@@, ...,,,,,,,,,,,,(@@@@@@/@@@@@@@@@@@@@@@@@@@@@@@@@@& @@@@@@@# .,,,,,,,,,,,,,,,,#@@@@@@& @@@@@&\r\n @@@@/ @@@@@@,...,,,,,,,,,,,,,@@@@@@@ *&@@@@@@@@@@@@@@@@% @@@@@@@@,,,,,,&&#*,,,,,,,,,%@@@@@@ @@@@@#\r\n &@@@@@ &@@@@@@,,,,,,&@@@@*,,,/@@@@@@& *@@@@@@@*,,,*@@@&,,... #@@@@@ .@@@@&\r\n &@@@@@# @@@@@@@,,,,,,%@@@@@@@/@@@@@@@. ..@@@@@@@(,,*@@@@( (@@@@/ ,@@@@.\r\n ,@@@@@@/ &@@@@@@@,,,,,,,,,@@@@@@@@@@@@, ....,,%@@@@@@% @@@@@ @@@@ (@@@*\r\n &@@@@@@@ ,@@@@@@@@@,,,,,,,,,,,,/@@@@@@@@# ..........@@@@@@% &@@@@ #@% @@@&\r\n #@@@@@@@@. (@@@@@@@@@@,,,,,,,,,,,.../@@@@@@@@@@@. .... %@@@@@%.@@@@ *@@#/\r\n .@@@@@@@@@@&, *@@@@@@@@@@@@&,,,,,,,,,... .@@@@@@&*@@@@@@@% @@@@@@@@@@& &@@(\r\n @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%..,,,,,,.... .@@@@@@@. #@@@@@@@ &&& %@@@@@@@@@ %&%\r\n &@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@%............ @@@@@@@/ /@&% &@@@@@@@@&. @@@@@@@@ (&/\r\n (@@@@@@, *&@@@@@@@@@&/ .... (@@@@@@# &&@@@@@@@@@@@@@@@@@@@@@* *\r\n *** %@@@@@& .(@@@@@@@@@@@@@@@@%......\r\n ,&, ....,,,,,,,,,,,,,,,,,,/&@@@@@@*.\r\n ...,,,,,,,,,,,,,,,,,,,,,,,,,,,,,... .,,,\r\n ...,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.. ..,,,,****\r\n ..,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.. .,,,,,,****////\r\n\"\"\"\r\nn = int(input())\r\na = []\r\nsm0, sm1 = 0, 0\r\nfor i in range(1, n + 1):\r\n if sm0 <= sm1:\r\n sm0 += n + 1 - i\r\n a.append(n + 1 - i)\r\n else:\r\n sm1 += n + 1 - i\r\nprint(abs(sm1 - sm0))\r\nprint(len(a), ' '.join(str(i) for i in a))", "n = int(input())\n\nif n == 2:\n print(1)\n print(\"1 1\")\n quit()\n\nif n == 3:\n print(0)\n print(\"2 1 2\")\n quit()\n\nk = n*(n+1)/2\n\nif k%2 == 0:\n print(0)\n l = [n//2, n]\n for i in range(n-3, 0, -4):\n l.append(i)\n if i-1 > 0:\n l.append(i-1)\n print(*l) \nelse:\n print(1)\n l = []\n if (n-1)%4 == 0:\n l = [n//2 + 1, n]\n else:\n l = [n//2, n]\n for i in range(n-3, 0, -4):\n l.append(i)\n if i-1 > 0:\n l.append(i-1)\n print(*l)\n\n\n\n \t \t \t\t \t\t\t \t \t\t\t \t \t", "n = int(input())\r\narr = []\r\nsm1 = 0\r\nsm2 = 0\r\nj = 0\r\nfor i in range(n, 0, -1):\r\n if sm1 > sm2:\r\n sm2 += i\r\n else:\r\n sm1 += i\r\n arr.append(i)\r\n j += 1\r\nprint(abs(sm2 - sm1))\r\nprint(j, end=\" \")\r\nprint(*arr)", "n = int(input())\r\na = []\r\nb = []\r\nans1 = ans2 = 0\r\nfor i in range(n,0,-1):\r\n if ans1 > ans2 :\r\n ans2 += i\r\n b.append(i)\r\n else :\r\n ans1 += i\r\n a.append(i)\r\nprint(abs(ans1-ans2))\r\na.sort()\r\nprint(len(a),*a)", "n=int(input());total_sum=(n*(n+1))//2\r\n#anslysis for the answer\r\nif total_sum%2==0:\r\n ans=0;n1=total_sum//2\r\nelse:\r\n n1=total_sum//2;ans=1\r\n\r\narr=[i+1 for i in range(n)]\r\nans1=[];\r\n#make the sum for n1\r\nfor i in range(n,0,-1):\r\n if n1!=0 and n1>=i:n1-=i;ans1.append(i)\r\n if n1==0:break\r\n \r\nprint(ans)\r\nprint(len(ans1),*ans1)\r\n", "n = int(input())\r\n\r\nif n%4 == 0 or n%4 ==3:\r\n print(0)\r\nelse:\r\n print(1)\r\n\r\nres = []\r\n\r\ni = n%4\r\nif i != 0:\r\n res.append(i)\r\n\r\ni += 4\r\nwhile i <= n:\r\n res.append(i)\r\n res.append(i-3)\r\n i += 4\r\n\r\nprint(len(res), end=\" \")\r\nprint(' '.join([str(rr) for rr in res]))\r\n", "n = int(input())\n\nout = []\nwhile n >= 4:\n out += [n, n-3]\n n -= 4\n\ndiff = 0\nif n == 3:\n out += [3]\nelif n == 2:\n out += [1]\n diff = 1\nelif n == 1:\n diff = 1\n\nprint(diff)\nprint(' '.join(map(str,[len(out)]+out)))", "n = int(input())\r\nh = n * (n + 1) // 4\r\nused = []\r\nhigh = n\r\nwhile h > 0 and high <= h:\r\n h -= high\r\n used.append(high)\r\n high -= 1\r\nif h:\r\n used.append(h)\r\nprint(n * (n + 1) // 2 % 2)\r\nprint(len(used), *used)\r\n", "a = []\r\nfor i in range(5,60001,4): a.append(i)\r\nfor i in range(2,60001,4): a.append(i)\r\n\r\nx = int(input())\r\njumlah = x*(x+1) // 2\r\nh = 0\r\nhsl = []\r\nif x not in a:\r\n print(0)\r\n jml = jumlah // 2\r\n for i in range(x,0,-1):\r\n if(jml >= i):\r\n hsl.append(i)\r\n h+=1\r\n jml -= i\r\n if(jml <= 0): break\r\n print(h,end=' ')\r\n for i in hsl:\r\n print(i,end=' ')\r\nelse:\r\n print(1)\r\n jml = jumlah // 2 + 1\r\n for i in range(x,0,-1):\r\n if(jml >= i):\r\n hsl.append(i)\r\n h+=1\r\n jml -= i\r\n if(jml <= 0): break\r\n print(h,end=' ')\r\n for i in hsl:\r\n print(i,end=' ')\r\n\r\nprint()\r\n", "n = int(input())\r\nnum_list = []\r\npart_sum = (n * (n + 1)) // 4\r\n# find out the \"difference\"\r\nif n % 4 == 1 or n % 4 == 2:\r\n\tdif = 1\r\nelif n % 4 == 3 or n % 4 == 0:\r\n\tdif = 0\r\n# find out the num_list\r\nnow = 0\r\nfor i in range(n // 2):\r\n\tnum_list.append(i + 1)\r\n\tnow += i + 1\r\n\r\ni += 1\r\nwhile now != part_sum:\r\n\tif now < part_sum:\r\n\t\ti += 1\r\n\t\tnum_list.append(i)\r\n\t\tnow += i\r\n\telse :\r\n\t\tnow -= num_list.pop(0)\r\n\r\n# print the result\r\nprint(dif)\r\nprint(len(num_list), end=\" \")\r\nfor i in range(len(num_list)):\r\n\tprint(num_list[i], end=\" \")\r\nprint()\r\n", "import itertools\r\nimport math\r\nimport sys\r\nimport queue\r\nimport itertools\r\nfrom heapq import heappop, heappush\r\nimport random\r\n\r\n\r\ndef solve():\r\n n = int(input())\r\n\r\n s = (1 + n) * n // 2\r\n si = s * 1\r\n s = s // 2\r\n\r\n res = []\r\n while s >= n:\r\n res.append(n)\r\n s = s - n\r\n n -= 1\r\n if s != 0:\r\n res.append(s)\r\n\r\n print(abs((si) - 2 * sum(res)))\r\n print(len(res), end=\" \")\r\n for i in range(len(res)):\r\n print(res[i], end=\" \")\r\n\r\n\r\nif __name__ == '__main__':\r\n multi_test = 0\r\n\r\n if multi_test:\r\n t = int(sys.stdin.readline())\r\n for _ in range(t):\r\n solve()\r\n else:\r\n solve()\r\n", "n = int(input())\r\n\r\nfirst = list()\r\nsecond = list()\r\n\r\nsm1 = sm2 = 0\r\n\r\nfor i in range(n, 0, -1):\r\n if sm1 <= sm2:\r\n sm1 += i\r\n first.append(i)\r\n else:\r\n sm2 += i\r\n second.append(i)\r\n\r\nprint(abs(sm1 - sm2))\r\nprint(len(first), *first)\r\n", "\r\na = []\r\nn = int(input().strip())\r\n\r\nif n%4==0:\r\n\tprint(0)\r\n\tfor i in range(1,n+1,4):\r\n\t\ta.append(i)\r\n\t\ta.append(i+3)\r\n\r\nelif n%4==3:\r\n\tprint(0)\r\n\ta.append(3)\r\n\tfor i in range(4,n+1,4):\r\n\t\ta.append(i)\r\n\t\ta.append(i+3)\t\t\r\n\r\nelif n%4==2:\r\n\tprint(1)\r\n\ta.append(1)\r\n\tfor i in range(3,n+1,4):\r\n\t\ta.append(i)\r\n\t\ta.append(i+3)\t\t\t\t\r\n\r\nelse:\r\n\tprint(1)\r\n\tfor i in range(2,n+1,4):\r\n\t\ta.append(i)\r\n\t\ta.append(i+3)\r\n\r\nprint(len(a),end=\" \")\r\nfor i in range(len(a)):\r\n\tprint(a[i],end=\" \")", "n = int(input())\r\nx, y, lst = 0, 0, list()\r\nfor i in range(n, 0, -1):\r\n if x > y:\r\n y += i\r\n else:\r\n x += i\r\n lst.append(i)\r\nprint(abs(x - y))\r\nprint(len(lst), *lst)\r\n ", "n=int(input())\r\nprint(n*(n+1)//2%2)\r\nans=list()\r\nt=True\r\nwhile n>0:\r\n ans.append(n)\r\n if(t):\r\n n-=3\r\n t=False\r\n else:\r\n n-=1\r\n t=True\r\nprint(len(ans),end=' ')\r\nfor i in ans :\r\n print(i,end=' ')", "n=int(input())\r\nf=[]\r\nf1=s1=0\r\nfor i in range(n,0,-1):\r\n if f1<=s1:\r\n f1+=i\r\n f.append(i)\r\n else:\r\n s1+=i\r\nprint(abs(f1-s1))\r\nprint(str(len(f)),*f)\r\n", "n = int(input())\r\ns = []\r\n\r\nfor i in range(0, n):\r\n s.append(i+1)\r\n\r\nu = []\r\nv = []\r\nk = int(n/4)\r\nj = 4 * k\r\na = n\r\n\r\nif n%4 == 2:\r\n for i in range(n-1-k, n):\r\n v.append(s[i])\r\n for i in range(0, k-1):\r\n v.append(s[i])\r\n for i in range(k-1, n-1-k):\r\n u.append(s[i])\r\nelif n%4 == 0:\r\n for i in range(0, k):\r\n v.append(s[i])\r\n for i in range(k, n-k):\r\n u.append(s[i])\r\n for i in range(n-k, n):\r\n v.append(s[i])\r\nelif n%4 == 1:\r\n v.append(s[0])\r\n for i in range(1, k+1):\r\n v.append(s[i])\r\n for i in range(k+1, n-k):\r\n u.append(s[i])\r\n for i in range(n-k, n):\r\n v.append(s[i])\r\nelif n%4 == 3:\r\n for i in range(0, k):\r\n v.append(s[i])\r\n for i in range(n-1-k, n):\r\n v.append(s[i])\r\n for i in range(k, n-1-k):\r\n u.append(s[i])\r\n\r\nw = sum(u)\r\ny = sum(v)\r\nz = abs(w-y)\r\nprint(z)\r\n\r\nprint(len(v))\r\nfor x in v:\r\n print(x)\r\n", "n=int(input())\r\nx=[]\r\nfor i in range(1,n+1):\r\n x.append(i)\r\n\r\nif n%4==0:\r\n s= (n*(n+1))//4\r\n val=0\r\n i=len(x)-1\r\n ans=[]\r\n while val<s:\r\n val+=x[i]\r\n ans.append(x[i])\r\n i-=1\r\n ans.pop()\r\n val-=x[i+1]\r\n if s-val>0:\r\n ans.append(s-val)\r\n print(0)\r\n print(len(ans),end=\" \")\r\n print(*ans)\r\nelif n%2==0:\r\n s1=(n*(n+1))//2\r\n s=(s1-1)//2\r\n val=0\r\n i=len(x)-1\r\n ans=[]\r\n while val<s:\r\n val+=x[i]\r\n ans.append(x[i])\r\n i-=1\r\n ans.pop()\r\n val-=x[i+1]\r\n if s-val>0:\r\n ans.append(s-val)\r\n print(1)\r\n print(len(ans),end=\" \")\r\n print(*ans)\r\nelse:\r\n n+=1\r\n if n % 4 == 0:\r\n s = (n * (n - 1)) // 4\r\n val = 0\r\n i = len(x) - 1\r\n ans = []\r\n while val < s:\r\n val += x[i]\r\n ans.append(x[i])\r\n i -= 1\r\n ans.pop()\r\n val -= x[i + 1]\r\n if s - val > 0:\r\n ans.append(s - val)\r\n print(0)\r\n print(len(ans), end=\" \")\r\n print(*ans)\r\n elif n % 2 == 0:\r\n s1 = (n * (n - 1)) // 2\r\n s = (s1 - 1) // 2\r\n val = 0\r\n i = len(x) - 1\r\n ans = []\r\n while val < s:\r\n val += x[i]\r\n ans.append(x[i])\r\n i -= 1\r\n ans.pop()\r\n val -= x[i + 1]\r\n if s - val > 0:\r\n ans.append(s - val)\r\n print(1)\r\n print(len(ans), end=\" \")\r\n print(*ans)\r\n", "n = int(input())\r\nall_sum = (1+n)*n // 2\r\ntarget = (all_sum - 1)//2 + 1\r\n\r\nif all_sum%2 == 0:\r\n print(0)\r\nelse:\r\n print(1)\r\n\r\nansw1 = []\r\ncurr_sum = 0\r\nfor i in range(n,0,-1):\r\n if curr_sum+i <= target:\r\n curr_sum += i\r\n answ1.append(i)\r\n else:\r\n continue\r\n\r\n if curr_sum == target:\r\n break\r\n\r\nprint(len(answ1), end = ' ')\r\nfor i in answ1:\r\n print(i, end=' ')", "n = int(input())\ncalc = n*(n+1)/2\nif n == 2:\n print (\"1\")\n print (1,1)\nelse:\n if calc%2 == 0:\n print(0)\n listaArmazenadora = []\n calc = int(calc/2)\n while calc > n:\n listaArmazenadora.append(str(n))\n calc -= n\n n -= 1\n listaArmazenadora.append(str(calc))\n print(len(listaArmazenadora),end=' ')\n listaArmazenadora=sorted(listaArmazenadora)\n print(*listaArmazenadora)\n else:\n print(1)\n calc = int(calc/2)\n listaArmazenadora = []\n while calc > n:\n listaArmazenadora.append(str(n))\n calc -= n\n n -= 1\n listaArmazenadora.append(str(calc))\n print(len(listaArmazenadora), end=' ')\n listaArmazenadora=sorted(listaArmazenadora)\n print(*listaArmazenadora)\n\n\t\t \t \t \t\t \t \t\t\t\t \t\t \t \t", "n = int(input())\r\nS = n * (n + 1) // 2\r\na = []\r\ns = S // 2;\r\nfor i in range(n, 0, -1):\r\n if (s >= i):\r\n s -= i;\r\n a.append(i);\r\nprint(S - sum(a) - sum(a))\r\nprint (len(a),\"\".join((str(x) + ' ' for x in a)))\r\n", "\nn = int(input().strip())\nfirst = []\n\ns = (n*(n+1))//2\nT = s//2\nfor i in range(n,0,-1):\n if(T-i>=0):\n first.append(i)\n T= T-i\n\n# print(T)\nif(s%2==0):\n print(0)\nelse:\n print(1)\n\nprint(len(first),end=' ')\nprint(*sorted(first))\n" ]
{"inputs": ["4", "2", "3", "5", "59998", "60000", "59991", "59989", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "59999", "59997", "59996", "59995", "59994", "59993", "59992", "59990", "100", "1000", "10001", "103", "1002", "31724", "2032", "42620", "18076", "53520", "37193", "12645", "53237", "28693", "4145", "36042", "16646", "57238", "27542", "8146", "46659", "27259", "2715", "38159", "18759"], "outputs": ["0\n2 1 4 ", "1\n1 1 ", "0\n1\n3 ", "1\n3\n1 2 5 ", "1\n29999 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "0\n30000 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "0\n29995\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "1\n29995\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "1\n3 1 4 5 ", "0\n3\n1 6 7 ", "0\n4 1 4 5 8 ", "1\n5\n1 2 3 8 9 ", "1\n5 1 4 5 8 9 ", "0\n5\n1 2 9 10 11 ", "0\n6 1 4 5 8 9 12 ", "1\n7\n1 2 3 4 11 12 13 ", "1\n7 1 4 5 8 9 12 13 ", "0\n7\n1 2 3 12 13 14 15 ", "0\n8 1 4 5 8 9 12 13 16 ", "1\n9\n1 2 3 4 5 14 15 16 17 ", "1\n9 1 4 5 8 9 12 13 16 17 ", "0\n9\n1 2 3 4 15 16 17 18 19 ", "0\n10 1 4 5 8 9 12 13 16 17 20 ", "1\n11\n1 2 3 4 5 6 17 18 19 20 21 ", "1\n11 1 4 5 8 9 12 13 16 17 20 21 ", "0\n11\n1 2 3 4 5 18 19 20 21 22 23 ", "0\n12 1 4 5 8 9 12 13 16 17 20 21 24 ", "0\n29999\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "1\n29999\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "0\n29998 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "0\n29997\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "1\n29997 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "1\n29997\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "0\n29996 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "1\n29995 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "0\n50 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 ", "0\n500 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 28...", "1\n5001\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 15...", "0\n51\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 ", "1\n501 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 28...", "0\n15862 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "0\n1016 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 2...", "0\n21310 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "0\n9038 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 2...", "0\n26760 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "1\n18597\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "1\n6323\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 15...", "1\n26619\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "1\n14347\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "1\n2073\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 15...", "1\n18021 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "1\n8323 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 2...", "1\n28619 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "1\n13771 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 ...", "1\n4073 1 4 5 8 9 12 13 16 17 20 21 24 25 28 29 32 33 36 37 40 41 44 45 48 49 52 53 56 57 60 61 64 65 68 69 72 73 76 77 80 81 84 85 88 89 92 93 96 97 100 101 104 105 108 109 112 113 116 117 120 121 124 125 128 129 132 133 136 137 140 141 144 145 148 149 152 153 156 157 160 161 164 165 168 169 172 173 176 177 180 181 184 185 188 189 192 193 196 197 200 201 204 205 208 209 212 213 216 217 220 221 224 225 228 229 232 233 236 237 240 241 244 245 248 249 252 253 256 257 260 261 264 265 268 269 272 273 276 277 2...", "0\n23329\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "0\n13629\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "0\n1357\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 15...", "0\n19079\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 1...", "0\n9379\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 15..."]}
UNKNOWN
PYTHON3
CODEFORCES
144
e0d9b47413ecdfc4e7b25dd15d254c2c
Two Strings Swaps
You are given two strings $a$ and $b$ consisting of lowercase English letters, both of length $n$. The characters of both strings have indices from $1$ to $n$, inclusive. You are allowed to do the following changes: - Choose any index $i$ ($1 \le i \le n$) and swap characters $a_i$ and $b_i$; - Choose any index $i$ ($1 \le i \le n$) and swap characters $a_i$ and $a_{n - i + 1}$; - Choose any index $i$ ($1 \le i \le n$) and swap characters $b_i$ and $b_{n - i + 1}$. Note that if $n$ is odd, you are formally allowed to swap $a_{\lceil\frac{n}{2}\rceil}$ with $a_{\lceil\frac{n}{2}\rceil}$ (and the same with the string $b$) but this move is useless. Also you can swap two equal characters but this operation is useless as well. You have to make these strings equal by applying any number of changes described above, in any order. But it is obvious that it may be impossible to make two strings equal by these swaps. In one preprocess move you can replace a character in $a$ with another character. In other words, in a single preprocess move you can choose any index $i$ ($1 \le i \le n$), any character $c$ and set $a_i := c$. Your task is to find the minimum number of preprocess moves to apply in such a way that after them you can make strings $a$ and $b$ equal by applying some number of changes described in the list above. Note that the number of changes you make after the preprocess moves does not matter. Also note that you cannot apply preprocess moves to the string $b$ or make any preprocess moves after the first change is made. The first line of the input contains one integer $n$ ($1 \le n \le 10^5$) — the length of strings $a$ and $b$. The second line contains the string $a$ consisting of exactly $n$ lowercase English letters. The third line contains the string $b$ consisting of exactly $n$ lowercase English letters. Print a single integer — the minimum number of preprocess moves to apply before changes, so that it is possible to make the string $a$ equal to string $b$ with a sequence of changes from the list above. Sample Input 7 abacaba bacabaa 5 zcabd dbacz Sample Output 4 0
[ "n=int(input())\r\na=input()\r\nb=input()\r\nans=0\r\nfor i in range(n//2):\r\n seen=set()\r\n if b[i]==b[n-i-1]:\r\n if a[i]==a[n-i-1]:\r\n ans+=0\r\n else:\r\n ans+=1\r\n else :\r\n seen.add(b[i])\r\n if b[n-i-1] in seen:\r\n seen.remove(b[n-i-1])\r\n else :\r\n seen.add(b[n-i-1])\r\n if a[i] in seen:\r\n seen.remove(a[i])\r\n else :\r\n ans+=1\r\n if a[n-1-i] in seen:\r\n seen.remove(a[n-i-1])\r\n else :\r\n ans+=1\r\nif n%2:\r\n if a[n//2]!=b[n//2]:\r\n ans+=1\r\nprint(ans)", "# LUOGU_RID: 116435796\nn=int(input())\r\na=input()\r\nb=input()\r\nans=0\r\nif n%2!=0:\r\n if a[n//2]!=b[n//2]:\r\n ans+=1\r\nfor i in range(n//2):\r\n if b[i]==b[n-1-i]:\r\n if a[i]!=a[n-1-i]:\r\n ans+=1\r\n continue\r\n if b[i]!=a[i] and b[i]!=a[n-1-i]:\r\n ans+=1\r\n if b[n-1-i]!=a[i] and b[n-1-i]!=a[n-1-i]:\r\n ans+=1\r\nprint(ans)\r\n", "from collections import *\r\nfrom heapq import *\r\nfrom bisect import *\r\nfrom itertools import *\r\nfrom functools import *\r\nfrom math import *\r\nfrom string import *\r\nimport operator\r\nimport sys\r\n\r\ninput = sys.stdin.readline\r\n\r\n\r\ndef solve():\r\n n = int(input())\r\n A = input().strip()\r\n B = input().strip()\r\n\r\n ans = 0\r\n for i in range(n // 2):\r\n w, x, y, z = A[i], A[~i], B[i], B[~i]\r\n ans += w != x if y == z else len({y, z} - {w, x})\r\n\r\n if n % 2 and A[n//2] != B[n//2]:\r\n ans += 1\r\n\r\n print(ans)\r\n\r\ndef main():\r\n tests = 1\r\n for _ in range(tests):\r\n solve()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "# https://codeforces.com/contest/1006\n\nimport sys\n\ninput = lambda: sys.stdin.readline().rstrip() # faster!\n\n\ndef solve_case():\n n = int(input())\n a = input()\n b = input()\n\n ans = 0\n for i in range(n // 2):\n l = len({a[i], a[n - 1 - i], b[i], b[n - 1 - i]})\n if l == 1:\n ans += 0\n elif l == 2:\n if a[i] == a[n - 1 - i] and b[i] != b[n - 1 - i]:\n ans += 1\n elif a[i] != a[n - 1 - i] and b[i] == b[n - 1 - i]:\n ans += 1\n else:\n ans += 0\n elif l == 3:\n if a[i] == a[n - 1 - i]:\n ans += 2\n else:\n ans += 1\n elif l == 4:\n ans += 2\n if n & 1 and a[n // 2] != b[n // 2]:\n ans += 1\n\n print(ans)\n\n\nsolve_case()\n", "n=int(input())\r\ns=input()\r\nt=input()\r\nans=0\r\nfor i in range((n+1)//2):\r\n if 2*i==n-1:\r\n if s[i]!=t[i]:\r\n ans+=1\r\n continue\r\n S=[s[i],s[n-1-i],t[i],t[n-i-1]]\r\n S.sort()\r\n if S[0]==S[1] and S[2]==S[3]:\r\n continue\r\n if len(set(S))==4:\r\n ans+=2\r\n continue\r\n if len(set(S))==2:\r\n ans+=1\r\n continue\r\n if s[i]==s[n-1-i]:\r\n ans+=2\r\n else:\r\n ans+=1\r\n \r\nprint(ans)", "#OMM NAMH SHIVAY\r\n#JAI SHREE RAM\r\nimport sys,math,heapq,queue\r\nfast_input=sys.stdin.readline \r\nn=int(input()) \r\na=\"0\"+input()\r\nb=\"0\"+input() \r\nans=0 \r\nfor i in range(1,n+1):\r\n if i>n-i+1:\r\n break \r\n if i==n-i+1:\r\n if a[i]!=b[i]:\r\n ans+=1 \r\n else:\r\n s=a[i]+a[n-i+1]+b[i]+b[n-i+1]\r\n if (s[0]==s[2] and s[1]==s[3]):\r\n ans+=0 \r\n elif (s[0]==s[3] and s[1]==s[2]):\r\n ans+=0 \r\n elif (s[0]==s[1] and s[2]==s[3]):\r\n ans+=0 \r\n elif (s[0]!=s[2] and s[1]==s[3]):\r\n ans+=1 \r\n elif (s[0]!=s[3] and s[1]==s[2]):\r\n ans+=1 \r\n elif (s[0]==s[2] and s[1]!=s[3]):\r\n ans+=1 \r\n elif (s[0]==s[3] and s[1]!=s[2]):\r\n ans+=1 \r\n elif (s[2]==s[3]):\r\n ans+=1 \r\n else:\r\n ans+=2 \r\nprint(ans)\r\n", "n=int(input())\r\n\r\na=str(input())\r\n\r\nb=str(input())\r\n\r\nif n==1:\r\n\tans=0\r\n\tif a[0]!=b[0]:\r\n\t\tans+=1\r\n\tprint(ans)\r\n\texit()\r\nans=0\r\nif n%2==1:\r\n\tif a[n//2]!=b[n//2]:\r\n\t\tans+=1\r\ndef aze(l):\r\n\tif l[2]==l[3]:\r\n\t\tif l[0]!=l[1]:\r\n\t\t\treturn(1)\r\n\t\treturn(0)\r\n\tif l[0]==l[1]:\r\n\t\tif l[0] in l[2:]:\r\n\t\t\treturn(1)\r\n\t\treturn(2)\r\n\tans=0\r\n\tif l[0] not in l[2:]:\r\n\t\tans+=1\r\n\tif l[1] not in l[2:]:\r\n\t\tans+=1\r\n\treturn(ans)\r\n\r\nfor i in range(n//2):\r\n\tans+=aze(a[i]+a[n-1-i]+b[i]+b[n-1-i])\r\n\t\r\nprint(ans )", "n = int(input())\r\na = input()\r\nb = input()\r\nc = 0\r\nfor i in range(n // 2):\r\n m = [a[i], a[n - i - 1], b[i], b[n - i - 1]]\r\n d = dict()\r\n for let in m:\r\n if d.get(let, False):\r\n d[let] += 1\r\n else:\r\n d[let] = 1\r\n if len(set(m)) == 1:\r\n continue\r\n elif len(set(m)) == 2:\r\n num = sorted([d[let] for let in m])\r\n if num[0] == 1:\r\n c += 1\r\n elif len(set(m)) == 3:\r\n if a[i] == a[n - i - 1]:\r\n c += 2\r\n else:\r\n c += 1\r\n elif len(set(m)) == 4:\r\n c += 2\r\nif n % 2 == 1 and a[n // 2] != b[n // 2]:\r\n c += 1\r\nprint(c)", "from collections import Counter\r\nn=int(input())\r\na=input()\r\nb=input()\r\nres=0\r\nc=len(a)\r\nif c%2:\r\n if a[c//2]!=b[c//2]:\r\n res+=1\r\nfor j in range(c//2):\r\n x=[a[j], a[n-j-1], b[j], b[n-j-1]]\r\n x=Counter(x)\r\n x=list(x.values())\r\n x.sort()\r\n if x[-1]==3:\r\n res+=1\r\n elif x[-1]==2:\r\n if x[-2]==1:\r\n if a[j]==a[n-j-1]:\r\n res+=2\r\n else:\r\n res+=1\r\n elif x[-1]==1:\r\n res+=2\r\nprint(res)", "n = int(input())\r\na = input()\r\nb = input()\r\nl = 0; r = n-1; ans = 0\r\nwhile l < r:\r\n x1 = a[l]; x2 = a[r]\r\n y1 = b[l]; y2 = b[r]\r\n \r\n if (x1 == y1 and x2 == y2) or (x1 == y2 and x2 == y1) or (x1 == x2 and y1 == y2):\r\n ans += 0\r\n elif (x1 == y1 or x2 == y2) or (x1 == y2 or x2 == y1) or (y1 == y2):\r\n ans += 1\r\n else:\r\n ans += 2\r\n l+=1; r-=1\r\n #print(ans)\r\nif l == r:\r\n ans += 1 if a[l] != b[l] else 0 \r\nprint(ans)\r\n \r\n ", "n=int(input())\r\na,b=input(),input()\r\nk=n//2\r\nc=a[k]!=b[k]and n%2\r\nfor u,v,x,y in zip(a[:k],a[::-1],b,b[::-1]):c+=(len({x,y}-{u,v}),u!=v)[x==y]\r\nprint(c)", "n=int(input())\r\na=input()\r\nb=input()\r\nans=0\r\nif n%2==0:\r\n for i in range(n//2):\r\n temp=len(set([a[i],b[i],a[n-1-i],b[n-1-i]]))\r\n if temp==4 or (temp==3 and a[i]==a[n-1-i]):\r\n ans+=2\r\n elif temp==3:\r\n ans+=1\r\n elif temp==2 and [a[i],b[i],a[n-1-i],b[n-1-i]].count(a[i])!=2:\r\n ans+=1\r\n print(ans)\r\nelse:\r\n if a[(n-1)//2]!=b[(n-1)//2]:\r\n ans+=1\r\n for i in range(n//2):\r\n temp=len(set([a[i],b[i],a[n-1-i],b[n-1-i]]))\r\n if temp==4 or (temp==3 and a[i]==a[n-1-i]):\r\n ans+=2\r\n elif temp==3:\r\n ans+=1\r\n elif temp==2 and [a[i],b[i],a[n-1-i],b[n-1-i]].count(a[i])!=2:\r\n ans+=1\r\n print(ans)", "n=int(input())\r\na=input()\r\nb=input()\r\nmoves=0\r\nfor i in range(n//2):\r\n cond1=(a[i]==a[n-i-1]) and (b[i]==b[n-i-1])\r\n cond2=(a[i]==b[i]) and (a[n-i-1]==b[n-i-1])\r\n cond3=(a[i]==b[n-i-1]) and (a[n-i-1]==b[i])\r\n if cond1 or cond2 or cond3:\r\n continue\r\n else:\r\n s=set()\r\n s.add(a[i])\r\n s.add(a[n-i-1])\r\n s.add(b[i])\r\n s.add(b[n-i-1])\r\n if len(s)==4 or (len(s)==3 and a[i]==a[n-i-1]):\r\n moves+=2\r\n else:\r\n moves+=1\r\nif n%2!=0 and a[n//2]!=b[n//2]:\r\n moves+=1\r\nprint(moves)\r\n", "n = int(input())\r\n\r\na = input()\r\nb = input()\r\n\r\nans = 0\r\nfor i in range(n//2):\r\n sa = [a[i], a[n-i-1]]\r\n sb = [b[i], b[n-i-1]]\r\n sa.sort()\r\n sb.sort()\r\n #print(sa, sb)\r\n\r\n if sb[0] == sb[1]:\r\n if not sa[0] == sa[1]:\r\n ans += 1\r\n else:\r\n if sa[0] == sa[1]:\r\n if sa[0] == sb[0] or sa[0] == sb[1]:\r\n ans += 1\r\n else:\r\n ans += 2\r\n else:\r\n ans += len(set([a[i], a[n-i-1], b[i], b[n-i-1]]))-2\r\n \r\n #print(ans)\r\nif n%2 == 1:\r\n if a[n//2] != b[n//2]:\r\n ans += 1\r\nprint(ans)", "n = int(input())\na = input()\nb = input()\n\noutput = 0\nfor i in range((n + 1) // 2):\n if i == n - i - 1:\n output += a[i] != b[i]\n continue\n\n pairs = (a[i], a[n - i - 1], b[i], b[n - i - 1])\n\n if pairs[2] == pairs[3]:\n output += pairs[0] != pairs[1]\n else:\n output += min(\n sum((pairs[0] != pairs[2], pairs[1] != pairs[3])),\n sum((pairs[0] != pairs[3], pairs[1] != pairs[2]))\n )\n\nprint(output)\n", "n=int(input())\na,b=input(),input()\nk=n//2\nc=a[k]!=b[k]and n%2\nfor z,w,x,y in zip(a[:k],a[::-1],b,b[::-1]):c+=z!=w if x==y else len({x,y}-{z,w})\nprint(c)\n\t \t \t \t\t \t \t \t \t\t \t \t \t", "n = int(input())\na = input()\nb = input()\nc = 0\nfor i in range(n // 2):\n e = sorted([a[i], b[i], a[-i - 1], b[-i - 1]])\n if not (e[0] == e[1] and e[2] == e[3]):\n if e[0] == e[1] == e[2] or e[1] == e[2] == e[3]:\n c += 1\n elif len(set(e)) == 4:\n c += 2\n elif a[i] == a[-i - 1]:\n c += 2\n else:\n c += 1\n \nif n % 2 == 1 and a[n // 2] != b[n // 2]:\n c += 1\nprint(c)\n \t\t\t \t\t \t \t \t \t \t \t \t \t", "n=int(input())\na=input()\nb=input()\nans=0\nif n%2!=0:\n if a[n//2]!=b[n//2]:\n ans+=1\nfor i in range(n//2):\n if b[i]==b[n-1-i]:\n if a[i]!=a[n-1-i]:\n ans+=1\n continue\n if b[i]!=a[i] and b[i]!=a[n-1-i]:\n ans+=1\n if b[n-1-i]!=a[i] and b[n-1-i]!=a[n-1-i]:\n ans+=1\nprint(ans)\n\n\t\t\t \t\t \t\t \t\t \t \t\t\t\t\t\t\t \t \t" ]
{"inputs": ["7\nabacaba\nbacabaa", "5\nzcabd\ndbacz", "1\na\nb", "5\nahmad\nyogaa"], "outputs": ["4", "0", "1", "3"]}
UNKNOWN
PYTHON3
CODEFORCES
18
e1034fbea68dca22768a04b14ad82878
Booking System
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity! A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system. There are *n* booking requests received by now. Each request is characterized by two numbers: *c**i* and *p**i* — the size of the group of visitors who will come via this request and the total sum of money they will spend in the restaurant, correspondingly. We know that for each request, all *c**i* people want to sit at the same table and are going to spend the whole evening in the restaurant, from the opening moment at 18:00 to the closing moment. Unfortunately, there only are *k* tables in the restaurant. For each table, we know *r**i* — the maximum number of people who can sit at it. A table can have only people from the same group sitting at it. If you cannot find a large enough table for the whole group, then all visitors leave and naturally, pay nothing. Your task is: given the tables and the requests, decide which requests to accept and which requests to decline so that the money paid by the happy and full visitors was maximum. The first line of the input contains integer *n* (1<=≤<=*n*<=≤<=1000) — the number of requests from visitors. Then *n* lines follow. Each line contains two integers: *c**i*,<=*p**i* (1<=≤<=*c**i*,<=*p**i*<=≤<=1000) — the size of the group of visitors who will come by the *i*-th request and the total sum of money they will pay when they visit the restaurant, correspondingly. The next line contains integer *k* (1<=≤<=*k*<=≤<=1000) — the number of tables in the restaurant. The last line contains *k* space-separated integers: *r*1,<=*r*2,<=...,<=*r**k* (1<=≤<=*r**i*<=≤<=1000) — the maximum number of people that can sit at each table. In the first line print two integers: *m*,<=*s* — the number of accepted requests and the total money you get from these requests, correspondingly. Then print *m* lines — each line must contain two space-separated integers: the number of the accepted request and the number of the table to seat people who come via this request. The requests and the tables are consecutively numbered starting from 1 in the order in which they are given in the input. If there are multiple optimal answers, print any of them. Sample Input 3 10 50 2 100 5 30 3 4 6 9 Sample Output 2 130 2 1 3 2
[ "import sys\n\n\ndef readline():\n return sys.stdin.readline().strip()\n\n\ndef read(t=int):\n s = sys.stdin.readline()\n return list(map(t, s.strip().split(' ')))\n\n\ndef readint():\n return read()[0]\n\n\ndef go():\n n = readint()\n cplist = []\n for i in range(n):\n c, p = read()\n cplist += [(c, p)]\n k = readint()\n rlist = sorted([(r, i) for i, r in enumerate(read(), 1)])\n cplist = sorted([(i, v) for i, v in enumerate(cplist, 1)],\n key=lambda x: -x[1][1])\n res = 0\n cnt = 0\n www = []\n for ii, v in cplist:\n c, p = v\n for i, (r, index) in enumerate(rlist):\n if r >= c and r > 0:\n res += p\n cnt += 1\n rlist[i] = (-1, index)\n www += [[ii, index]]\n break\n print(cnt, res)\n for i in www:\n ind, v = i\n print(ind, v)\n\n\ngo()\n", "import heapq\r\n\r\ndef solve():\r\n n = int(input())\r\n booked = 0\r\n mx_money = 0\r\n v = []\r\n\r\n for i in range(n):\r\n x, y = map(int, input().split())\r\n v.append((x, (y, i + 1)))\r\n\r\n v.sort()\r\n k = int(input())\r\n a = []\r\n l = [int(x) for x in input().split()]\r\n\r\n for i in range(k):\r\n a.append((l[i], i + 1))\r\n\r\n a.sort()\r\n res = []\r\n pq = []\r\n j = 0\r\n\r\n for it in a:\r\n while j < n and v[j][0] <= it[0]:\r\n heapq.heappush(pq, (-v[j][1][0], v[j][1][1]))\r\n j += 1\r\n\r\n if pq:\r\n booked += 1\r\n mx_money += -pq[0][0]\r\n res.append((pq[0][1], it[1]))\r\n heapq.heappop(pq)\r\n\r\n print(booked)\r\n print(mx_money)\r\n for pair in res:\r\n print(pair[0], pair[1])\r\nsolve()", "from bisect import bisect_left as lower\r\ndef put(): return map(int, input().split())\r\n\r\nn = int(input())\r\nc,p = [],[]\r\nfor i in range(n):\r\n ci,pi = put()\r\n c.append(ci)\r\n p.append(pi)\r\n\r\nk = int(input())\r\nrr = list(put())\r\n\r\nl = []\r\nfor i in range(n):\r\n l.append((p[i], c[i], i+1))\r\nl.sort()\r\nr = []\r\nfor i,v in enumerate(rr):\r\n r.append((v,i+1))\r\nr.sort()\r\n\r\nt = k\r\nx,y = 0,0\r\nvis =[0]*k\r\nans = []\r\nwhile t>0 and l:\r\n p,c,a = l.pop()\r\n j = lower(r, (c,0))\r\n while j<k and vis[j]:\r\n j+=1\r\n if j<k:\r\n x+= 1\r\n y+= p\r\n vis[j]=1\r\n t-=1\r\n ans.append((a, r[j][1]))\r\n\r\nprint(x,y)\r\nfor a,b in ans:\r\n print(a,b)\r\n\r\n\r\n", "peeps=[]\r\nfor i in range(int(input())):\r\n a=[int (x) for x in input().split()]\r\n peeps.append((a[1],a[0],i+1))\r\nn=int(input())\r\nr=[int (x) for x in input().split()]\r\nfor i in range(n):\r\n r[i]=(r[i],i+1)\r\npeeps.sort()\r\nr.sort()\r\nslot=[0]*n\r\nresult=[]\r\nmoney=0\r\nwhile len(peeps)!=0:\r\n c=peeps.pop()\r\n for i in range(n):\r\n if r[i][0]>=c[1] and slot[i]==0:\r\n slot[i]=1\r\n result.append((c[2],r[i][1]))\r\n money+=c[0]\r\n break\r\nprint(len(result),money)\r\nfor i in range(len(result)):\r\n print(result[i][0],result[i][1])", "import random\r\n \r\n\r\n \r\n#z=int(input()) \r\nfor contorr in range(1):\r\n\r\n #n,q=list(map(int, input().split()))\r\n \r\n \r\n n=int(input())\r\n \r\n \r\n tupla=[]\r\n for i in range(n):\r\n \r\n c,p=list(map(int,input().split()))\r\n \r\n \r\n tupla.append((i+1,c,p))\r\n \r\n tupla = sorted(tupla, key=lambda x: x[2])[::-1]\r\n #print(tupla)\r\n \r\n cate=0\r\n \r\n \r\n m=int(input())\r\n\r\n mat=[]\r\n mese=list(map(int,input().split()))\r\n \r\n \r\n for i in range(m):\r\n a=[]\r\n a.append(i+1)\r\n a.append(mese[i])\r\n a.append(random.randint(1,1000))\r\n mat.append(a)\r\n \r\n mat = sorted(mat, key=lambda x: x[1])\r\n #print(mat)\r\n answ=[]\r\n cate=0\r\n pret=0\r\n for i in range(n):\r\n for j in range(m):\r\n if mat[j][1]>=tupla[i][1]:\r\n pret+=tupla[i][2]\r\n cate+=1\r\n mat[j][1]=-1\r\n a=[]\r\n a.append(tupla[i][0])\r\n a.append(mat[j][0])\r\n answ.append(a)\r\n break\r\n print(cate,pret) \r\n for z in answ:\r\n print(*z)\r\n \r\n \r\n\r\n \r\n ", "#import sys\n#sys.stdin = open(\"123.data\")\nn = int(input())\nx = []\nfor i in range(n):\n\tc, p = map(int, input().split())\n\tx += [(p, c, i)]\n#print(x)\nk = int(input())\nr = list(map(int, input().split()))\nsm = 0\nans = []\nx.sort(reverse = True)\n#print(x)\nfor i in range(n):\n\tcount = x[i][0]\n\tcost = x[i][1]\n\tuk = x[i][2]\n\ttm1 = -1\n\ttm2 = 100000\n\t#print(count, cost, uk, tm1, tm2)\n\tfor j in range(k):\n\t\tif cost <= r[j] < tm2:\n\t\t\ttm1 = j\n\t\t\ttm2 = r[j]\n\tif tm1 > -1:\n\t\tr[tm1] = 0\n\t\tans += [(uk, tm1)]\n\t\tsm += count\nprint(len(ans), sm)\n#print(ans)\nfor (i, j) in ans:\n\tprint(i + 1, j + 1)\n", "n=int(input())\r\narr=[]\r\nfor i in range(n):\r\n c,p=map(int,input().split())\r\n arr.append([c,p,i])\r\nr=int(input())\r\ntables=list(map(int,input().split()))\r\narr.sort(key=lambda x:(-x[1],x[0]))\r\nt=0\r\nam=0\r\nseen=set()\r\nans=[]\r\nfor c,p,ind in arr:\r\n o=float(\"inf\")\r\n for j in range(r):\r\n if tables[j]>=c and j not in seen:\r\n if o>tables[j]:\r\n o=tables[j]\r\n q=j\r\n if o!=float(\"inf\"):\r\n seen.add(q)\r\n ans.append([ind+1,q+1])\r\n am+=p\r\n t+=1\r\nprint(t,am)\r\nfor a,b in ans:\r\n print(a,b)", "# DO NOT EDIT THIS\r\nimport math\r\nimport sys\r\ninput = sys.stdin.readline\r\nfrom collections import deque, defaultdict\r\nimport heapq\r\ndef counter(a):\r\n c = defaultdict(lambda : 0) # way faster than Counter\r\n for el in a:\r\n c[el] += 1\r\n return c\r\n\r\ndef inp(): return [int(k) for k in input().split()]\r\ndef si(): return int(input())\r\ndef st(): return input()\r\n\r\n# DO NOT EDIT ABOVE THIS\r\nn = si()\r\nrequests = [inp() + [i + 1] for i in range(n)]\r\nk = si()\r\ntables = inp()\r\ntables = [[k, i + 1] for i, k in enumerate(tables)]\r\n\r\ntables.sort()\r\nrequests.sort()\r\ndp = [[0] * (k + 1) for _ in range(n + 1)]\r\n\r\nfor i in range(len(dp) - 1, -1, -1):\r\n for j in range(len(dp[i]) - 1, -1, -1):\r\n if i == n or j == k:\r\n dp[i][j] = 0\r\n else:\r\n skip_request = dp[i + 1][j]\r\n seat = requests[i][1] + dp[i + 1][j + 1] if requests[i][0] <= tables[j][0] else 0\r\n move_table = dp[i][j + 1]\r\n dp[i][j] = max(skip_request, seat, move_table)\r\n\r\ntotal_profit = dp[0][0]\r\nnum_tables = 0\r\ni, j = 0, 0\r\nres = []\r\n\r\nwhile i < (len(dp) - 1) and j < (len(dp[i]) - 1):\r\n skip_request = dp[i + 1][j]\r\n seat = requests[i][1] + dp[i + 1][j + 1] if requests[i][0] <= tables[j][0] else 0\r\n move_table = dp[i][j + 1]\r\n\r\n m = max(skip_request, seat, move_table)\r\n if m == skip_request:\r\n i += 1\r\n elif m == seat:\r\n res.append([requests[i][2], tables[j][1]])\r\n i += 1\r\n j += 1\r\n num_tables += 1\r\n else:\r\n j += 1\r\n\r\nprint(*[num_tables, total_profit])\r\nfor el in res:\r\n print(*el)\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\ndef multi_input():\r\n return map(int, input().split())\r\n\r\ndef array_print(arr):\r\n print(' '.join(map(str, arr)))\r\n\r\nrequests = []\r\nr = int(input())\r\nfor n in range(1,r+1):\r\n p,c = multi_input()\r\n requests.append([n,p,c])\r\n\r\nt = int(input())\r\ntables = list(multi_input())\r\ntables_index = [0]*t\r\n\r\nrequests.sort(key=lambda item: item[2], reverse=True)\r\n\r\nans = []\r\nprofit = 0\r\nfor i in range(r):\r\n req_index = requests[i][0]\r\n person = requests[i][1]\r\n cost = requests[i][2]\r\n idx = -1\r\n jgte = 1000000\r\n for j in range(t):\r\n # print(requests[i], tables[j])\r\n\r\n if tables_index[j]==0 and tables[j]>= person and jgte>=tables[j]:\r\n jgte=tables[j]\r\n idx = j\r\n\r\n if idx!=-1:\r\n # print(requests[i], tables[idx])\r\n profit += cost\r\n tables_index[idx] = 1\r\n ans.append([req_index, idx+1])\r\n\r\nprint(len(ans), profit)\r\nfor i in range(len(ans)):\r\n print(ans[i][0], ans[i][1])\r\n", "from sys import stdin\r\nfrom random import randint\r\n\r\n#quickSort en segunda posición. El ascending dice si es decreciente o creciente\r\n\r\ndef quickSort(L, ascending=False):\r\n if len(L) <= 1:\r\n return L\r\n smaller, equal, larger = [], [], []\r\n pivot = L[randint(0, len(L) - 1)][0]\r\n\r\n for x in L:\r\n if x[0] < pivot:\r\n smaller.append(x)\r\n elif x[0] == pivot:\r\n equal.append(x)\r\n else:\r\n larger.append(x)\r\n\r\n larger = quickSort(larger, ascending=ascending)\r\n smaller = quickSort(smaller, ascending=ascending)\r\n\r\n if ascending:\r\n final = smaller + equal + larger\r\n else:\r\n final = larger + equal + smaller\r\n return final\r\n\r\ndef solve(n,m,gr_f,t_f):\r\n cant_tables = len(t_f)\r\n ans_money = 0\r\n ans_groups = []\r\n occu = 0\r\n for i in range(n):\r\n for j in range(m-1,-1,-1):\r\n if t_f[j][0] >= gr_f[i][1] and not t_f[j][2]:\r\n t_f [j][2] = True\r\n ans_groups.append([gr_f[i][2],t_f[j][1]])\r\n occu += 1\r\n ans_money += gr_f[i][0]\r\n break\r\n if occu == m:\r\n break\r\n print(len(ans_groups),ans_money)\r\n for a in ans_groups:\r\n print(a[0],a[1])\r\n \r\n\r\n\r\ndef main():\r\n n = int(stdin.readline())\r\n groups = []\r\n for i in range(n):\r\n [size,money] = [int(x) for x in stdin.readline().split()]\r\n groups.append([money,size,i+1])\r\n gr_f = quickSort(groups,ascending=False)\r\n m = int(stdin.readline())\r\n tables = [int(x) for x in stdin.readline().split()]\r\n tables_to_sort = []\r\n for i in range(m):\r\n tables_to_sort.append([tables[i],i+1,False])\r\n t_f = quickSort(tables_to_sort,ascending=False)\r\n solve(n,m,gr_f,t_f)\r\n\r\nmain()\r\n\r\n", "n=int(input())\r\nls=[]\r\nfor i in range(n):\r\n c,p=map(int,input().split())\r\n ls.append([p,c,i+1])\r\nls.sort(reverse=True) \r\nk=int(input()) \r\ntable=[[0] for i in range(1001)]\r\nr=list(map(int,input().split()))\r\nfor i in range(k):\r\n table[r[i]].append(i+1)\r\ntotal=0\r\nans=[]\r\nfor i in range(n):\r\n for j in range(ls[i][1],1001):\r\n if(table[j][0]<len(table[j])-1):\r\n total+=ls[i][0]\r\n ans.append([ls[i][2],table[j][table[j][0]+1]])\r\n table[j][0]+=1\r\n break\r\nprint(len(ans),total)\r\nfor i in range(len(ans)):print(*ans[i])", "n=int(input())\r\nrequest, ans = [], []\r\nfor idx in range(n):\r\n request.append(list(map(int, input().split()))+[idx+1])\r\nk=int(input())\r\naccept=0\r\nsize=list((map(int, input().split())))\r\nfor idx in range(k):\r\n size[idx]=[size[idx], idx+1]\r\nsize.sort()\r\nrequest.sort(reverse=True, key=lambda x: x[1])\r\ntotal_cost=0\r\nfor idx in range(n):\r\n if(size and size[-1][0]>=request[idx][0]):\r\n l, r = 0, k-1-accept\r\n while(l<r-1):\r\n mid=(l+r)//2\r\n if(size[mid][0]<request[idx][0]):\r\n l=mid+1\r\n else:\r\n r=mid\r\n if(size[l][0]<request[idx][0]):\r\n l=r\r\n total_cost+=request[idx][1]\r\n ans.append([request[idx][2], size[l][1]])\r\n del size[l]\r\n accept+=1\r\nprint(accept, total_cost)\r\nfor val in ans:\r\n print(val[0], val[1]) ", "\r\n#? -----------------------------------------------------------------------------------------------------\r\n#?            ∧_∧\r\n#?      ∧_∧   (´<_` )  \r\n#?     ( ´_ゝ`) /  ⌒i \r\n#?    /   \    | | \r\n#?    /   / ̄ ̄ ̄ ̄/ |  |\r\n#?  __(__ニつ/  _/ .| .|____\r\n#?     \/____/ (u ⊃\r\n#?\r\n#?\t\t /\\_/\\\r\n#?\t\t(= ._.)\r\n#?\t\t/ >WA \\>AC\r\n#?\r\n# WELCOME TO MY CODING SPACE\r\n#! Filename: L_Booking_System.py\r\n#* Folder: D:\\Code\\Python\\Codeforces\\ProblemSet\\Topic Stream Mashup Dynamic Programming\r\n#? Author: TranDucTri2003\r\n#TODO CreatedAt: 08/09/2022 23:32:56\r\n#? -----------------------------------------------------------------------------------------------------\r\n\r\n#! Dòng đầu tiên chứa số request\r\n#! n dòng tiếp theo chứa số người đặt bàn và số tiền nhận được\r\n#! dòng tiếp theo ghi số bàn mà nhà hàng có\r\n#! dòng cuối ghi số chỗ mỗi bàn\r\n\r\n#? dòng đầu tiên output ghi số bàn accepted để số tiền nhận được là tối đa\r\n#? các dòng tiếp theo ghi số thứ tự của yêu cầu được chấp nhận và số bàn phân công tương ứng\r\n\r\nimport sys\r\nimport os\r\nfrom io import BytesIO, IOBase\r\n\r\n\r\nMOD=10**9+7\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\n\r\nn=int(input())\r\n\r\ngroups=[]\r\nfor i in range(n):\r\n size,price=list(map(int,input().split()))\r\n groups.append([size,price,i+1])\r\n\r\nm=int(input())\r\nk=list(map(int,input().split()))\r\n\r\n\r\ntables=[]\r\nfor i in range (m):\r\n tables.append([k[i],i+1])\r\n\r\ngroups.sort(key=lambda x:(-x[1],x[0]))\r\ntables.sort(key=lambda x:x[0])\r\n\r\n# print(groups)\r\n# print(tables)\r\n\r\nans=0\r\ntime=0\r\nres=[]\r\n\r\nfor i in range(n):\r\n for j in range(m):\r\n if tables[j][0]>=groups[i][0]:\r\n time+=1\r\n ans+=groups[i][1]\r\n res.append([groups[i][2],tables[j][1]])\r\n tables[j][0]=-1\r\n groups[i][0]=10**9\r\n\r\n# for group in groups:\r\n# for i in range(m):\r\n# if tables[i][0]>group[0]:\r\n# ans+=group[1]\r\n# res.append([group[2],tables[i][1]])\r\n# tables[i][0]=-1\r\n# print(\"res\",group,i)\r\nprint(time,ans)\r\nfor num in res:\r\n print(num[0],num[1])\r\n \r\n\r\n\r\n \r\n", "\n\n\nn = int(input())\na = []\nfor i in range(n):\n c,p = map(int,input().split())\n a.append([p,c,i+1])\n\na.sort(reverse=True)\n\nk = int(input())\nr = list(map(int,input().split()))\n\nhast = {}\nfor j in range(len(r)):\n i = r[j]\n if i in hast:\n hast[i].append(j+1)\n else:\n hast[i] = [j+1]\nace = 0\nmoney = 0\naceeped = []\nmaxi = max(hast.keys())\nfor j in range(len(a)):\n i = a[j]\n for z in range(i[1], maxi+1):\n if z in hast:\n ace+=1 \n money += i[0]\n aceeped.append([i[2],hast[z].pop()])\n if len(hast[z]) == 0:\n del hast[z]\n break\n \nprint(ace,money)\nfor i in aceeped:\n print(*i)\n\n \t\t\t \t \t \t \t\t\t \t \t \t\t\t", "n = int(input())\r\nv = []\r\nfor i in range(1, n+1):\r\n v.append([int(x) for x in input().split()]+[i])\r\nk = int(input())\r\nw = []; r = [int(x) for x in input().split()]\r\nfor i in range(1, k+1):\r\n w.append([r[i-1], i])\r\n\r\nw.sort()\r\nans = []\r\nfor cap, tid in w:\r\n v.sort(key=lambda x:-x[1])\r\n for i in range(len(v)):\r\n if v[i][0] <= cap:\r\n ans.append([v[i][1], v[i][2], tid])\r\n v.pop(i)\r\n break\r\n\r\ntol = 0\r\nfor x in ans: tol += x[0]\r\nprint(f'{len(ans)} {tol}')\r\nfor x in ans:\r\n print(f'{x[1]} {x[2]}')", "from heapq import *\r\npq=[]\r\nans=[]\r\na=int(input())\r\nfor i in range(a):\r\n x,y=map(int,input().split())\r\n ans.append([x,y,i+1])\r\ntemp=ans.copy()\r\nans.sort()\r\ns=int(input())\r\n\r\nz=list(map(int,input().split()))\r\nt1=[]\r\nfor i in range(len(z)):\r\n t1.append([z[i],i+1])\r\nt1.sort()\r\nfin=[]\r\ncnt=0\r\ntotal=0\r\nfor i in range(len(t1)):\r\n while(cnt<len(ans) and ans[cnt][0]<=t1[i][0]):\r\n heappush(pq,(-ans[cnt][1],ans[cnt][2]))\r\n cnt+=1\r\n \r\n if(len(pq)):\r\n r=heappop(pq)\r\n \r\n fin.append([r[1],t1[i][1]])\r\n total+=temp[r[1]-1][1]\r\nprint(len(fin),total)\r\nfor i in range(len(fin)):\r\n print(fin[i][0],fin[i][1])\r\n \r\n", "n = int(input())\r\npos = []\r\nfor i in range(n):\r\n\tvvod1, vvod2 = map(int, input().split())\r\n\tpos.append([vvod2, vvod1])\r\ndop1 = pos.copy()\r\npos.sort()\r\npos.reverse()\r\nk = int(input())\r\nsto = list(map(int, input().split()))\r\ndop2 = sto.copy()\r\nsto.sort()\r\nkol = 0\r\nsuma = 0\r\nvivod = []\r\nfor y in range(n):\r\n\tfor x in range(k):\r\n\t\tif pos[y] != '' and sto[x] != '' and pos[y][1] <= sto[x]:\r\n\t\t\tvivod.append([pos[y], sto[x]])\r\n\t\t\tsuma += pos[y][0]\r\n\t\t\tkol += 1\r\n\t\t\tpos[y] = ''\r\n\t\t\tsto[x] = ''\r\n\t\t\tbreak\r\nprint(kol, suma)\r\nfor i in range(kol):\r\n\tx = dop1.index(vivod[i][0])\r\n\ty = dop2.index(vivod[i][1])\r\n\tprint (x + 1, y + 1)\r\n\tdop1[x] = ''\r\n\tdop2[y] = ''\r\n", "def smaller(a,val,vis):\r\n\tind=None\r\n\tfor i in range(len(a)):\r\n\t\tif a[i]>=val and vis[i]==0 :\r\n\t\t\tif ind!=None:\r\n\t\t\t\tif a[i]<a[ind]:\r\n\t\t\t\t\tind=i\r\n\t\t\telse:\r\n\t\t\t\tind=i\r\n\treturn ind\r\ndef f(p,a):\r\n\tfor i in range(len(p)):\r\n\t\tp[i].append(i)\r\n\tp=sorted(p,key=lambda s:s[1],reverse=True)\r\n\tans=[]\r\n\ts=0\r\n\tvis=[0]*(len(a))\r\n\tfor i in p:\r\n\t\tind=smaller(a,i[0],vis)\r\n\t\t# print(ind,i)\r\n\t\tif ind!=None:\r\n\t\t\tans.append([i[2]+1,ind+1])\r\n\t\t\tvis[ind]=1\r\n\t\t\ts+=i[1]\r\n\tprint(len(ans),s)\r\n\tfor i in ans:\r\n\t\tprint(*i)\r\n\treturn \"\"\r\np=[]\r\nfor i in range(int(input())):\r\n\ta,b=map(int,input().strip().split())\r\n\tp.append([a,b])\r\nk=input()\r\nar=list(map(int,input().strip().split()))\r\nprint(f(p,ar))", "class x:\r\n def __init__(self, c, m, index):\r\n self.c = c\r\n self.m = m\r\n self.index = index\r\n def __str__(self):\r\n s = f'{self.c}-{self.m}-{self.index}'\r\n return s\r\n def __repr__(self):\r\n s = f'{self.c}-{self.m}-{self.index}'\r\n return s\r\nclass t:\r\n def __init__(self, no, index):\r\n self.no = no\r\n self.index = index\r\n def __str__(self):\r\n s = f'{self.no}-{self.index}'\r\n return s\r\n def __repr__(self):\r\n s = f'{self.no}-{self.index}'\r\n return s\r\n\r\n\r\ndef main():\r\n n = int(input())\r\n C = []\r\n for i in range(n):\r\n c, p = list(map(int, input().split()))\r\n cu = x(c, p, i + 1)\r\n C.append(cu)\r\n \r\n C.sort(key=lambda x: x.m, reverse=True)\r\n k = int(input())\r\n R = list(map(int, input().split()))\r\n Tables = []\r\n for i in range(k):\r\n Tab = t(R[i], i + 1)\r\n Tables.append(Tab)\r\n Tables.sort(key= lambda x: x.no)\r\n result = []\r\n O = [False for _ in range(k)]\r\n m, s = 0, 0,\r\n for i in range(n):\r\n for j in range(k):\r\n if (C[i].c <= Tables[j].no and O[Tables[j].index - 1] is False):\r\n m += 1\r\n s += C[i].m\r\n O[Tables[j].index - 1] = True\r\n result.append([C[i].index, Tables[j].index])\r\n break\r\n print(m, s)\r\n for cur_res in result:\r\n print(*cur_res)\r\nif __name__ == '__main__':\r\n main()", "n=int(input())\r\na=[list(map(int,input().split())) for i in range(n)]\r\nk=int(input())\r\nb=list(map(int,input().split()))\r\nr=max(b)\r\nfor i in range(n):\r\n if a[i][0]>r:\r\n a[i].append(1)\r\n a[i]=a[i][::-1];a[i].append(i+1)\r\n else:\r\n a[i].append(0)\r\n a[i]=a[i][::-1];a[i].append(i+1)\r\na.sort(reverse=True)\r\nc=[[] for i in range(1001)]\r\nfor i in range(k):\r\n c[b[i]].append(i+1)\r\nmo=0;ans=[]\r\nfor i in range(n):\r\n if not(a[i][0]):\r\n for j in range(a[i][2],r+1):\r\n if len(c[j])>0:\r\n mo+=a[i][1];ans.append([a[i][-1],c[j][0]])\r\n del c[j][0];break\r\nprint(len(ans),mo)\r\nfor i in ans:\r\n print(*i)\r\n", "from sys import stdin,stdout\r\nnmbr = lambda: int(stdin.readline())\r\nlst = lambda: list(map(int, stdin.readline().split()))\r\nfor _ in range(1):#nmbr()):\r\n n=nmbr()\r\n l=[lst() for _ in range(n)]\r\n m=nmbr();sm=0\r\n a=sorted(zip(lst(),range(m)))\r\n vis={}# table -> request\r\n for i in range(m):\r\n mx=0;p=-1\r\n for j in range(n):\r\n if j not in vis and l[j][0]<=a[i][0] and mx<=l[j][1]:\r\n # print(i,j)\r\n mx=l[j][1]\r\n p=j\r\n if p!=-1:\r\n vis[p]=a[i][1]\r\n sm+=mx\r\n print(len(vis),sm)\r\n for k,v in vis.items():\r\n print(k+1,v+1)\r\n\r\n", "\r\nn = int(input())\r\nvs = list()\r\nfor i in range(n):\r\n a,b = map(int,input().strip().split())\r\n vs.append([b,a,i+1])\r\nvs.sort(reverse = True)\r\nk = int(input())\r\ntb = list()\r\nj = 1\r\nfor i in map(int,input().strip().split()):\r\n tb.append([i,j])\r\n j+=1\r\ntb.sort()\r\n#print(vs)\r\n#print(tb)\r\ni = 0\r\nans = 0\r\nans_ar = list()\r\nwhile len(tb)>0 and i<len(vs):\r\n# print(vs[i][1])\r\n l = 0\r\n r = len(tb)-1\r\n mid = int(r/2)\r\n while l<r:\r\n if vs[i][1] > tb[mid][0]:\r\n l = mid+1\r\n else:\r\n r = mid\r\n mid = int((l+r)/2)\r\n if vs[i][1]<=tb[r][0]:\r\n ans += vs[i][0]\r\n ans_ar.append([vs[i][2],tb[r][1]])\r\n tb.pop(r) \r\n i+=1\r\n\r\nprint(\"{} {}\".format(len(ans_ar),ans))\r\nfor i in range(len(ans_ar)):\r\n print(\"{} {}\".format(ans_ar[i][0],ans_ar[i][1]))\r\n \r\n", "import bisect\r\ndef ans(n,k):\r\n if dp[n][k] != -1:\r\n return dp[n][k]\r\n if k == 0 and n!=0:\r\n return ans(n-1,k)\r\n if n == 0:\r\n return 0\r\n if l[n-1][0]<=lll[k-1]:\r\n dp[n][k] = max(l[n-1][1] + ans(n-1,k-1),ans(n-1,k),ans(n,k-1))\r\n return max(l[n-1][1] + ans(n-1,k-1),ans(n-1,k),ans(n,k-1))\r\n else:\r\n dp[n][k] = max(ans(n-1,k),ans(n,k-1))\r\n return max(ans(n-1,k),ans(n,k-1))\r\nn = int(input())\r\nl = []\r\nll = []\r\nfor i in range(n):\r\n l1 = list(map(int,input().split()))\r\n l1.append(i)\r\n l.append(l1)\r\nk = int(input())\r\nlll = list(map(int,input().split()))\r\ndp = []\r\n'''for i in range(tt+1):\r\n q = []\r\n for j in range(ttt+1):\r\n q.append(-1)\r\n dp.append(q)'''\r\nl1 = []\r\nl2 = []\r\nans = []\r\ncount = 0\r\nl2 = sorted(lll)\r\nl.sort(key = lambda x: x[1])\r\nanss = 0\r\nfor i in l[-1::-1]:\r\n index = bisect.bisect_left(l2,i[0])\r\n if index < len(l2):\r\n anss+=i[1]\r\n count+=1\r\n qq = lll.index(l2[index])\r\n lll[qq] = 0\r\n l2.pop(index)\r\n ans.append([i[2]+1,qq+1])\r\nprint(count,anss)\r\nfor i in ans:\r\n print(*i)\r\n \r\n \r\n \r\n\r\n", "n=int(input())\r\nx=[]\r\nfor i in range(n):\r\n c,p=map(int,input().split(\" \"))\r\n x+=[(p,c,i)]\r\nk=int(input())\r\nr=list(map(int,input().split(\" \",k)[:k]))\r\ns=0\r\nq=[]\r\nfor (v,c,a) in reversed(sorted(x)):\r\n p=-1\r\n u=100000\r\n for (j,z) in enumerate(r):\r\n if c<=z<u:\r\n p=j\r\n u=z\r\n if p>-1:\r\n r[p]=0\r\n q+=[(a,p)]\r\n s+=v\r\nprint(len(q),s)\r\nfor (i,j) in q:\r\n print(i+1,j+1)\r\n", "from sys import stdin,stdout\r\nimport bisect\r\nn=int(input())\r\n\r\nsize=[]\r\nmoney=[]\r\nfor _ in range(n):\r\n\tci,pi=map(int,stdin.readline().split(' '))\r\n\tsize.append(ci);money.append(pi)\r\ngroupno=[i+1 for i in range(n)]\r\nk=int(input())\r\ntable=list(map(int,stdin.readline().split(' ')))\r\ntid=[i+1 for i in range(k+1)]\r\ntd={}\r\nt1=sorted(zip(table,tid))\r\ntable=[x for x,y in t1]\r\ntid=[y for x,y in t1]\r\nfor i in range(k):\r\n\ttd[i+1]=-1\r\nt1=sorted(zip(money,size,groupno))\r\nsize=[y for x,y,z in t1]\r\ngroupno=[z for x,y,z in t1]\r\nmoney=[x for x,y,z in t1]\r\nmoney.reverse();groupno.reverse();size.reverse()\r\nans=0;ans1=0\r\nfor i in range(len(money)):\r\n\tt1=bisect.bisect_left(table,size[i])\r\n\t#print(i,t1)\r\n\tif t1!=len(table):\r\n\t\ttd[tid[t1]]=groupno[i]\r\n\t\tans+=money[i];ans1+=1\r\n\t\ttid.pop(t1);table.pop(t1)\r\nprint(ans1,ans)\r\nfor i in td:\r\n\tif td[i]!=-1:\r\n\t\tstdout.write(str(td[i])+\" \"+str(i)+\"\\n\")\r\n\r\n\r\n\r\n", "from bisect import bisect_left as bl\r\nfrom collections import defaultdict\r\nn=int(input())\r\nl=[]\r\nfor i in range(n):\r\n l.append(list(map(int,input().split())))\r\nd=defaultdict(list)\r\nfor i in range(n-1,-1,-1):\r\n d[l[i][0],l[i][1]].append(i+1)\r\nk=int(input())\r\nl1=list(map(int,input().split()))\r\nl2=[]\r\nfor i in range(k):\r\n l2.append([l1[i],i])\r\nl2.sort()\r\nl.sort()\r\nans1=0\r\nans2=0\r\nans=[]\r\n\r\nfor i in range(k):\r\n if len(l)==0:\r\n break\r\n a=bl(l,[l2[i][0],1001])\r\n x=0\r\n y=0\r\n for j in range(a):\r\n if x<=l[j][1]:\r\n x=l[j][1]\r\n y=j\r\n if x:\r\n ans1+=1\r\n ans2+=x\r\n ans.append([d[l[y][0],l[y][1]][-1],l2[i][1]+1])\r\n d[l[y][0],l[y][1]].pop()\r\n l.pop(y)\r\nprint(ans1,ans2)\r\nans.sort()\r\nfor i in ans:\r\n print(*i)\r\n\r\n \r\n \r\n \r\n \r\n \r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sat Oct 15 00:37:04 2016\r\n\r\n@author: Arpan\r\n\"\"\"\r\n\r\nn=int(input())\r\n\r\nclass req:\r\n def __init__(self,no,size,cash):\r\n self.no=no\r\n self.size=size\r\n self.cash=cash\r\nclass table:\r\n def __init__(self,no,size):\r\n self.no=no\r\n self.size=size\r\n \r\nrl=[] \r\n \r\nfor i in range(n):\r\n s,c=[int(x) for x in input().split()] \r\n a=req(i+1,s,c)\r\n rl.append(a)\r\nk=int(input())\r\nt=[int(x) for x in input().split()]\r\n\r\ntl=[]\r\n\r\nfor i in range(len(t)):\r\n a=table(i+1,t[i])\r\n tl.append(a)\r\n\r\n\r\nrl.sort(key=lambda x: x.cash,reverse=True)\r\ntl.sort(key=lambda x: x.size)\r\n\r\ntot=0\r\nseated=0\r\na=[]\r\n\r\nfor i in tl:\r\n s=i.size\r\n for j in rl:\r\n if j.size<=i.size:\r\n tot+=j.cash\r\n seated+=1\r\n a.append([j.no,i.no])\r\n rl.remove(j)\r\n break\r\na.sort(key=lambda x: x[0])\r\nprint(seated,tot)\r\nfor i in a:\r\n print(i[0],i[1])\r\n \r\n\r\n", "n = int(input())\r\nq = []\r\nfor i in range(n):\r\n x, y = map(int, input().split())\r\n q.append((y, x, i+1))\r\nm = int(input())\r\nt = list(map(int, input().split()))\r\nt = list(enumerate(t, 1))\r\nt = list(map(lambda x: [x[1], x[0]], t))\r\nq.sort()\r\nt.sort()\r\nres, sum = [], 0\r\nfor i in range(n-1, -1, -1):\r\n for j in range(m):\r\n if q[i][1] <= t[j][0]:\r\n t[j][0] = 0\r\n sum += q[i][0]\r\n res.append((q[i][2], t[j][1]))\r\n break\r\nprint(len(res), sum)\r\nfor i in res:\r\n print(*i)\r\n", "n = int(input())\r\nrequests = []\r\nfor i in range(n):\r\n c, p = map(int, input().split())\r\n requests.append((c, p, i)) # store the request index as well\r\nrequests.sort(key=lambda x: x[1], reverse=True) # sort by decreasing order of money\r\n\r\nk = int(input())\r\ntables = list(map(int, input().split()))\r\n\r\nassignments = [-1] * n # initially, no request is assigned to any table\r\naccepted = []\r\ntotal_money = 0\r\nfor c, p, i in requests:\r\n j = -1\r\n for l in range(k):\r\n if tables[l] >= c:\r\n if j == -1 or tables[l] < tables[j]:\r\n j = l\r\n if j != -1:\r\n tables[j] = 0 # mark this table as occupied\r\n assignments[i] = j+1 # assign this request to this table\r\n accepted.append((i+1, j+1)) # store the accepted request and table\r\n total_money += p\r\n\r\nm = len(accepted)\r\nprint(m, total_money)\r\nfor i, j in accepted:\r\n print(i, j)", "def get_key(item):\r\n return item[1]\r\n\r\n\r\nn = int(input())\r\n\r\nrequests = []\r\n\r\nfor i in range(n):\r\n c, p = map(int, input().split())\r\n requests.append([c, p, i+1])\r\n\r\nk = int(input())\r\n\r\nl = list(map(int, input().split()))\r\ncapacity = []\r\n\r\nfor i in range(k):\r\n capacity.append([l[i], i+1, 0])\r\n\r\ncapacity = sorted(capacity)\r\nrequests = sorted(requests, key=get_key,reverse=True)\r\n\r\n\r\nresults = []\r\nsum = 0\r\nfor i in range(n):\r\n for j in range(k):\r\n if capacity[j][2] == 0 and requests[i][0] <= capacity[j][0]:\r\n capacity[j][2] = 1\r\n results.append([requests[i][2], capacity[j][1]])\r\n sum+= requests[i][1]\r\n break\r\n\r\n\r\nprint(len(results), sum)\r\n\r\nfor i in results:\r\n print(i[0], i[1])\r\n\r\n\r\n\r\n\r\n\r\n", "n=int(input())\r\nl=[]\r\nfor i in range(n):\r\n l.append(list(map(int,input().split())))\r\n l[i]+=[i+1]\r\nk=int(input())\r\ns=list(map(int,input().split()))\r\nfor i in range(k):\r\n s[i]=[i+1,s[i]]\r\ndef fun(itm):\r\n return itm[1]\r\nl.sort(reverse=True,key=fun)\r\ns.sort(key=fun)\r\nans=0\r\nansl=[]\r\nfor i in l:\r\n for j in s:\r\n if i[0]<=j[1]:\r\n ans+=i[1]\r\n s.remove(j)\r\n ansl.append([i[2],j[0]])\r\n break\r\n# print(i)\r\n# print(l)\r\n# print(s)\r\n# print(ans)\r\nprint(len(ansl),ans)\r\nfor i in ansl:\r\n print(i[0],i[1])\r\n ", "def findTable(tables,c,visited):\r\n min_diff = float('inf')\r\n index = -1\r\n k = len(tables)\r\n for i in range(k):\r\n diff = tables[i]-c\r\n if diff >= 0:\r\n if diff < min_diff and ((i+1) not in visited):\r\n min_diff = diff\r\n index = i+1\r\n\r\n if index != -1:\r\n visited.add(index)\r\n\r\n return index\r\n\r\ndef main():\r\n n = int(input())\r\n visitors = []\r\n for i in range(n):\r\n c,p = map(int,input().split())\r\n visitors.append((p,c,i+1))\r\n\r\n visitors.sort(reverse = True)\r\n\r\n ans = []\r\n money = 0\r\n\r\n k = int(input())\r\n tables = list(map(int,input().split()))\r\n visited = set()\r\n\r\n for visitor in visitors:\r\n p,c = visitor[0],visitor[1]\r\n index = findTable(tables,c,visited)\r\n if index != -1:\r\n visited.add(index)\r\n ans.append((visitor[2],index))\r\n money += p\r\n\r\n print(len(ans),money)\r\n for i in ans:\r\n print(i[0],i[1])\r\n\r\nmain()\r\n", "n = int(input())\nvis = []\nfor i in range(n):\n vis.append(list(map(int,input().split()))+[i+1])\nvis.sort(key = lambda x:(x[1],x[0]))\nm = int(input())\ntables = []\nfor i,el in enumerate(list(map(int,input().split()))):\n tables.append([el,i+1])\ntables.sort()\nresr = []\nac_vis = 0\ntotal = 0\nfor i in range(n):\n tmp = vis.pop()\n for j in range(len(tables)):\n if tmp[0] <= tables[j][0]:\n total += tmp[1]\n ac_vis += 1\n resr.append([tmp[2],tables[j][1]])\n tables[j]=[-1,-1]\n break\n\nprint(ac_vis,total)\nfor i in resr:\n print(*i)\n\n \t\t \t\t \t\t \t \t \t \t \t", "from collections import namedtuple\n\nn = int(input())\n\nTable = namedtuple('Table', 'id, size')\nGroup = namedtuple('Group', 'id, size, income')\n\ndef first_fit(size):\n\tfor t in tables:\n\t\tif t.size >= size and t.id not in used_tables:\n\t\t\tused_tables.add(t.id)\n\t\t\treturn t\n\ntables, groups = [], []\nused_tables = set()\n\nfor i in range(n):\n\tc, p = map(int, input().split())\n\tgroups.append(Group(i+1, c, p))\n\nk = int(input())\nr = list(map(int, input().split()))\nfor i in range(k):\n\ttables.append(Table(i+1, r[i]))\n\ngroups.sort(key=lambda group: group.income, reverse=True)\ntables.sort(key=lambda table: table.size)\n\nsum_ = 0\nans = []\n\nfor i in range(n):\n\tg = groups[i]\n\tneeded_table = first_fit(g.size)\n\tif not needed_table:\n\t\tcontinue\n\tsum_ += g.income\n\tans.append((g.id, needed_table.id))\n\nprint(len(ans), sum_)\nfor a in ans:\n\tprint(*a)\n", "n = int(input())\r\ng = [list(map(int, input().split())) + [i] for i in range(n)]\r\nk = int(input())\r\nr = [(v, i) for i, v in enumerate(list(map(int, input().split())))]\r\nb = [None] * n\r\n \r\nsg = sorted(g, key=lambda x: x[1], reverse=True)\r\nsr = sorted(r)\r\ncount = 0\r\nmoney = 0\r\n \r\nfor v in sg:\r\n for w in sr:\r\n if w[0] < v[0]:\r\n continue\r\n b[v[2]] = w[1]\r\n count += 1\r\n money += v[1]\r\n sr.remove(w)\r\n break\r\n \r\nprint(count, money)\r\nfor i in range(n):\r\n if b[i] == None:\r\n continue\r\n print(i + 1, b[i] + 1)", "n = int(input())\r\nclients = []\r\nfor i in range(1, n + 1):\r\n clients.append(list(map(int, input().split())))\r\n clients[-1].reverse()\r\n clients[-1] += [i]\r\nk = int(input())\r\nr = list(map(int, input().split()))\r\n\r\ns = 0\r\nanswer = []\r\nclients.sort(reverse = True)\r\nr = [1001] + r\r\nfor i in clients:\r\n pos = 0\r\n for j in range(k + 1):\r\n if r[j] >= i[1] and r[j] < r[pos]:\r\n pos = j\r\n if r[pos] >= i[1] and pos:\r\n answer.append(str(i[2]) + ' ' + str(pos))\r\n r[pos] = 0\r\n s += i[0]\r\n\r\nprint(len(answer), s)\r\nprint('\\n'.join(answer))\r\n", "import sys\ninput = lambda: sys.stdin.readline().rstrip()\nfrom collections import deque,defaultdict,Counter\nfrom itertools import permutations,combinations\nfrom bisect import *\nfrom heapq import *\nfrom math import ceil,gcd,lcm,floor,comb\nalph = 'abcdefghijklmnopqrstuvwxyz'\n#pow(x,mod-2,mod)\n\nN = int(input())\nA = []\nfor i in range(N):\n A.append(list(map(int,input().split()))+[i+1])\n\nA.sort(reverse=True)\n\nK = int(input())\nB = list(map(int,input().split()))\nP = sorted([[B[i],i+1] for i in range(K)])\n\nh = [];heapify(h)\nrt = []\nans,cnt = 0,0\n\nfor k,i in P:\n while A and A[-1][0]<=k:\n a,b,c = A.pop()\n heappush(h,[-b,a,c])\n\n if h:\n b,a,c = heappop(h)\n ans+=abs(b)\n cnt+=1\n rt.append([c,i])\nprint(cnt,ans)\nfor i in rt:print(*i)\n\n", "#!/usr/bin/env python3\n# created : 2020. 12. 31. 23:59\n\nimport os\nfrom sys import stdin, stdout\nfrom heapq import heappush, heappop\n\n\ndef solve(tc):\n n = int(stdin.readline().strip())\n\n people = []\n for i in range(n):\n ci, pi = map(int, stdin.readline().split())\n people.append([ci, pi])\n pidx = list(range(n))\n\n pidx = sorted(pidx, key=lambda x: people[x])\n\n k = int(stdin.readline().strip())\n tables = list(map(int, stdin.readline().split()))\n tidx = list(range(k))\n tidx = sorted(tidx, key=lambda x: tables[x])\n\n ans = []\n tot = 0\n p = 0\n heap = []\n for i in range(k):\n while p < n and people[pidx[p]][0] <= tables[tidx[i]]:\n heappush(heap, [-people[pidx[p]][1], pidx[p]])\n p += 1\n\n if len(heap) > 0:\n top = heappop(heap)\n tot -= top[0]\n ans.append([top[1]+1, tidx[i]+1])\n\n print(len(ans), tot)\n for i in range(len(ans)):\n print(' '.join(map(lambda x : str(x), ans[i])))\n\n\ntcs = 1\n# tcs = int(stdin.readline().strip())\ntc = 1\nwhile tc <= tcs:\n solve(tc)\n tc += 1\n", "def smaller(a, val, vis):\n\tind=None\n\tfor i in range(len(a)):\n\t\tif a[i]>=val and vis[i]==0 :\n\t\t\tif ind!=None:\n\t\t\t\tif a[i]<a[ind]:\n\t\t\t\t\tind=i\n\t\t\telse:\n\t\t\t\tind=i\n\treturn ind\n\ndef f(p,a):\n\tfor i in range(len(p)):\n\t\tp[i].append(i)\n\tp=sorted(p,key=lambda s:s[1],reverse=True)\n\tans=[]\n\ts=0\n\tvis=[0]*(len(a))\n\tfor i in p:\n\t\tind=smaller(a,i[0],vis)\n\t\tif ind!=None:\n\t\t\tans.append([i[2]+1,ind+1])\n\t\t\tvis[ind]=1\n\t\t\ts+=i[1]\n\tprint(len(ans),s)\n\tfor i in ans:\n\t\tprint(*i)\n\treturn \"\"\n\np=[]\nfor i in range(int(input())):\n\ta,b=map(int,input().strip().split())\n\tp.append([a,b])\nk=input()\nar=list(map(int,input().strip().split()))\nprint(f(p,ar))\n \t \t\t \t\t \t\t \t\t\t \t \t \t", "import sys\r\n#sys.setrecursionlimit(10**7)\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############ ---- Input Functions ---- ############\r\n\r\ndef Booking_System():\r\n n = inp()\r\n request_index = []\r\n num_people = []\r\n money = []\r\n\r\n for i in range(n):\r\n c, p = invr()\r\n request_index.append(i+1)\r\n num_people.append(c)\r\n money.append(p)\r\n \r\n sorted_data = sorted(zip(money,num_people,request_index), reverse= True)\r\n money_sorted, num_people_acc, request_index_acc = zip(*sorted_data)\r\n\r\n k = inp()\r\n sequence = inlt()\r\n booked = [False]*len(sequence)\r\n\r\n outputStr = ''\r\n total_revenue = 0\r\n total_seated = 0 \r\n\r\n for index in range(len(num_people_acc)):\r\n revenue = money_sorted[index]\r\n size = num_people_acc[index]\r\n request_num = request_index_acc[index]\r\n \r\n current_table_size = max(sequence)\r\n current_table_index = -1\r\n\r\n for i,table in enumerate(sequence):\r\n if booked[i] == False:\r\n if table >= size and table <= current_table_size:\r\n current_table_size = table \r\n current_table_index = i\r\n \r\n if current_table_index != -1:\r\n booked[current_table_index] = True \r\n total_revenue += revenue\r\n total_seated += 1\r\n outputStr += str(request_num) + ' ' + str(current_table_index+1) + '\\n'\r\n\r\n print(str(total_seated) + ' ' + str(total_revenue))\r\n outputStr = outputStr.strip()\r\n print(outputStr)\r\n return\r\n\r\nBooking_System()", "import math\r\nimport random \r\n\r\ndef main(arr,tables):\r\n idx_arr={} \r\n for i in range(len(arr)):\r\n val=arr[i]\r\n if val not in idx_arr:\r\n idx_arr[val]=[] \r\n idx_arr[val].append(i+1) \r\n table_arr={}\r\n for i in range(len(tables)):\r\n val=tables[i]\r\n if val not in table_arr:\r\n table_arr[val]=[] \r\n table_arr[val].append(i+1) \r\n \r\n arr.sort(key=lambda x: x[1],reverse=True)\r\n tot=0 \r\n ans=[]\r\n \r\n \r\n for i in range(len(arr)):\r\n p,c=arr[i] \r\n val=float('inf')\r\n idx_for_table=None\r\n for j in range(len(tables)):\r\n if tables[j]>=p:\r\n if val>tables[j]:\r\n val=tables[j]\r\n \r\n if val!=float('inf'):\r\n ans.append([idx_arr[(p,c)][-1],table_arr[val][-1]])\r\n idx_arr[(p,c)].pop()\r\n \r\n tables.remove(val)\r\n table_arr[val].pop()\r\n tot+=c \r\n print(len(ans),tot)\r\n for e in ans:\r\n print(*e)\r\n \r\n \r\nn=int(input()) \r\narr=[]\r\nfor i in range(n):\r\n arr.append(tuple(map(int,input().split())))\r\n\r\nm=int(input()) \r\ntables=list(map(int,input().split()))\r\n(main(arr,tables))\r\n\r\n\r\n \r\n\r\n", "n, = map(int, input().split())\nA = []\nfor i in range(n):\n c,p = map(int, input().split())\n A.append((p,c,i))\nA.sort(reverse=True)\n\nk, = map(int, input().split())\nR = list(map(int, input().split()))\nR = [(r,i) for i,r in enumerate(R)]\nR.sort()\n\nmoney = 0\naccepts = 0\ntablings = []\n\ntaken = set()\nfor p,c,ai in A:\n for r,ri in R:\n if ri in taken: continue\n if c <= r:\n money += p\n accepts += 1\n tablings.append((ai,ri))\n taken.add(ri)\n break\n\nprint(accepts, money)\nfor ai,ri in tablings:\n print(ai+1,ri+1)\n", "from sys import stdin\n\ninput = stdin.readline\n\n\nclass Booking:\n def __init__(self, number, people, cost):\n self.number = number\n self.people = people\n self.cost = cost\n self.table = None\n\n def __str__(self):\n return str(self.__dict__)\n\n\nclass Table:\n def __init__(self, number, capacity):\n self.number = number\n self.capacity = capacity\n self.occupied = False\n\n def __str__(self):\n return str(self.__dict__)\n\n\nb = int(input())\nrequests = [[int(item) for item in input().split(' ')] for i in range(b)]\nbookings = []\nfor i in range(b):\n bookings.append(Booking(i + 1, requests[i][0], requests[i][1]))\n\nn = int(input())\ncapacity = [int(item) for item in input().split(' ')]\n\ntables = []\n\nfor i in range(n):\n tables.append(Table(i + 1, capacity[i]))\n\nst = [table for table in sorted(tables, key=lambda x: x.capacity)]\ngranted = 0\ntotal = 0\nfor booking in sorted(bookings, key=lambda bo: -1 * bo.cost):\n if granted == len(st):\n break\n for table in st:\n if table.occupied:\n continue\n if table.capacity >= booking.people:\n booking.table = table.number\n total += booking.cost\n table.occupied = True\n granted += 1\n break\n\nprint(granted, total)\n\nfor booking in bookings:\n if booking.table:\n print(booking.number, booking.table)\n", "n = int(input())\r\nc = []\r\nfor i in range(n):\r\n c.append(list(map(int, input().split())))\r\n c[i].append(i + 1)\r\n\r\nr = int(input())\r\nk = list(map(int, input().split()))\r\n\r\ndef sortfn(inp):\r\n return inp[1]\r\n\r\nc.sort(key = sortfn, reverse = True)\r\nfor i in range(len(k)):\r\n val = k[i]\r\n k[i] = [i + 1, val]\r\nk.sort(key = sortfn)\r\n\r\ndef gettable(size):\r\n for i in range(len(k)):\r\n if k[i][1] >= size:\r\n k[i][1] = -1\r\n table = k[i][0]\r\n return table\r\n return -1\r\n \r\ngroups = []\r\nval = 0\r\nfor group in c:\r\n table = gettable(group[0])\r\n if table > 0:\r\n groups.append([str(group[2]), str(table)])\r\n val += group[1]\r\n\r\nprint(str(len(groups)) + \" \" + str(val))\r\nfor g in groups:\r\n print(\" \".join(g))\r\n", "n=int(input(''))\r\ngroup=[]\r\ntable=[]\r\nfor i in range(n):\r\n size,money=map(int,input('').split())\r\n group+=[(money,size,i)]\r\nk=int(input(''))\r\nout=[]\r\nall_money=0\r\ntable=list(map(int,input('').split()))\r\nfor (money,size,j) in reversed(sorted(group)):\r\n max=1000\r\n uu=-1\r\n for (i,table1) in enumerate(table):\r\n if size<=table1<max+1:\r\n max=table1\r\n uu=i\r\n if uu>-1:\r\n table[uu]=0\r\n out+=[(j,uu)]\r\n all_money+=money \r\nprint(len(out),all_money)\r\nfor (i,j) in out: print (i+1,j+1)\r\n", "\r\n\r\ndef solve(n, k, bookings, tables_capacities):\r\n total_accept_bookings, total_profit = 0, 0\r\n bookings_accepted = []\r\n bookings.sort(key=lambda x: x[1]) # ordeno las solicitudes de reserva por ganancia\r\n tables_capacities.sort(key=lambda x: x[0]) # ordeno las capacidades de menor a mayor\r\n mark_tables_capacities = [False for _ in range(k)] # creo un array booleano para saber que mesas estan ocupadas o no\r\n\r\n for i in range(n - 1, -1, -1): # comienzo en la reserva de mayor ganancia\r\n ci, pi, num_booking = bookings[i] # tomo la cantidad de personas, la ganancia y el numero de la reserva i\r\n rj, num_table = exits_table(ci, tables_capacities, mark_tables_capacities) # busco una mesa donde sentar a las personas de la reserva num_booking\r\n \r\n if rj != -1: # si existe una mesa con capacidad para todas las personas de la reserva num_booking\r\n total_accept_bookings += 1 # aumento el numero de reservas aceptadas\r\n total_profit += pi # aumento el dinero total recaudado\r\n mark_tables_capacities[num_table - 1] = True # reservo la mesa para la reserva num_booking\r\n bookings_accepted.append((num_booking, num_table)) # añado la reserva num_booking y la mesa que se le asigno a la lista de reservas aceptadas\r\n\r\n return total_accept_bookings, total_profit, bookings_accepted\r\n\r\n\r\ndef exits_table(ci, tables_capacities, mark_tables_capacities):\r\n for j in range(len(tables_capacities)): # busco en cada una de las capacidades de las mesas\r\n rj, num_table = tables_capacities[j] # tomo la capacidad de la mesa\r\n if ci <= rj and not mark_tables_capacities[num_table - 1]: # si encuentro una mesa donde quepan todas las personas de la reserva, retorno su capacidad y el numero de mesa\r\n return rj, num_table # retorno la capacidad y el numero de mesa\r\n return -1, -1 # si no encuentro mesa con capacidad para ci personas, retorna -1\r\n\r\n\r\ndef print_solve(total_accept_bookings, total_profit, accepted_bookings):\r\n print(f\"{total_accept_bookings} {total_profit}\") # imprimo el numero de reservas aceptadas y el dinero total recaudado\r\n\r\n for booking in accepted_bookings:\r\n i, r = booking\r\n print(f\"{i} {r}\")\r\n\r\n\r\n\r\n# if __name__ == '__main__':\r\nn = int(input()) # cantidad de reservas de los clientes\r\nbookings = [] # reservas de los clientes de la forma (ci=cant de personas, pi=cant que pagaran)\r\n\r\nfor i in range(n): # leer las reservas realizadas\r\n ci, pi = map(int, input().split()) # cantidad de personas de la reserva i, cantidad de dinero de la reserva i\r\n bookings.append((ci, pi, i + 1)) # guardo la cantidad de personas, el dinero y el numero de la reserva\r\n\r\nk = int(input()) # cantidad de mesas del restaurante\r\nrj = input().split() # leer capacidades de cada una de las mesas\r\ntable_capacities = [(int(rj[j]), j + 1) for j in range(len(rj))]\r\n\r\nm, s, accepted_bookings = solve(n, k, bookings, table_capacities)\r\nprint_solve(m, s, accepted_bookings)" ]
{"inputs": ["3\n10 50\n2 100\n5 30\n3\n4 6 9", "1\n1 1\n1\n1", "1\n2 1\n1\n1", "2\n10 10\n5 5\n1\n5", "2\n10 10\n5 5\n1\n10", "2\n2 100\n10 10\n1\n10", "2\n10 100\n5 90\n2\n15 20", "3\n10 10\n3 5\n5 8\n3\n3 4 10", "10\n739 307\n523 658\n700 143\n373 577\n120 433\n353 833\n665 516\n988 101\n817 604\n800 551\n10\n431 425 227 147 153 170 954 757 222 759", "9\n216 860\n299 720\n688 831\n555 733\n863 873\n594 923\n583 839\n738 824\n57 327\n10\n492 578 452 808 492 163 670 31 267 627", "3\n694 606\n76 973\n676 110\n5\n592 737 313 903 13", "7\n172 864\n853 523\n368 989\n920 452\n351 456\n269 104\n313 677\n9\n165 47 259 51 693 941 471 871 206", "1\n545 609\n4\n584 822 973 652", "9\n23 163\n895 838\n344 444\n284 763\n942 39\n431 92\n147 515\n59 505\n940 999\n8\n382 497 297 125 624 212 851 859", "3\n500 613\n671 899\n628 131\n10\n622 467 479 982 886 968 326 64 228 321", "7\n682 870\n640 857\n616 306\n649 777\n725 215\n402 977\n981 353\n1\n846", "1\n160 616\n5\n406 713 290 308 741", "6\n397 946\n871 126\n800 290\n505 429\n239 43\n320 292\n9\n387 925 9 440 395 320 58 707 994", "1\n3 20\n4\n3 2 1 4", "2\n2 100\n1 1000\n1\n2"], "outputs": ["2 130\n2 1\n3 2", "1 1\n1 1", "0 0", "1 5\n2 1", "1 10\n1 1", "1 100\n1 1", "2 190\n1 1\n2 2", "2 15\n1 3\n2 1", "6 3621\n6 2\n2 8\n9 7\n4 1\n7 10\n5 4", "7 5233\n6 10\n1 9\n7 7\n3 4\n4 2\n2 3\n9 6", "3 1689\n2 3\n1 2\n3 4", "5 3509\n3 7\n1 9\n7 5\n2 8\n5 6", "1 609\n1 1", "6 2482\n4 3\n7 6\n8 4\n3 1\n1 2\n6 5", "3 1643\n2 5\n1 1\n3 6", "1 977\n6 1", "1 616\n1 3", "6 2126\n1 4\n4 8\n6 6\n3 2\n2 9\n5 1", "1 20\n1 1", "1 1000\n2 1"]}
UNKNOWN
PYTHON3
CODEFORCES
46
e12509b906dd993ec3ead38d458dc7f9
Maximize Sum of Digits
Anton has the integer *x*. He is interested what positive integer, which doesn't exceed *x*, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. The first line contains the positive integer *x* (1<=≤<=*x*<=≤<=1018) — the integer which Anton has. Print the positive integer which doesn't exceed *x* and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros. Sample Input 100 48 521 Sample Output 99 48 499
[ "print((lambda s:max([(sum(map(int,s)),int(s))]+[(lambda t:(float(\"-inf\"),)if s[t]==\"0\" else(lambda x:(sum(map(int,str(x))),x))(int(s[:t]+str(int(s[t])-1)+\"9\"*(len(s)-1-i))))(i)for i in range(len(s))])[1])(input()))\r\n", "a=input()\r\nans=[sum(map(int,a)),a]\r\nfor i in range(len(a)-1,-1,-1):\r\n b=a[:i]+str(int(a[i])-1)+'9'*len(a[i+1:])\r\n if a[i]!='0'and sum(map(int,b))>ans[0]:ans=[sum(map(int,b)),b]\r\nprint(ans[1].strip('0'))", "def gh(z,i):\r\n k=str(z[:i])+str(int(z[i])-1)+'9'*len(z[i+1::])\r\n return (sum(map(int,k)),k)\r\na=input();p=[]\r\nfor i in range(len(a)-1):\r\n if a[i]!='0':p.append(gh(a,i))\r\np.append((sum(map(int,a)),a))\r\nprint(int(sorted(p,reverse=True)[0][1]))", "t = input()\r\np = [t] + [int(t) - int(t[-k:]) - 1 for k in range(1, len(t))]\r\nprint(\r\n max(p, key=lambda variant: sum(map(int, str(variant)))\r\n))", "from math import log10, ceil\r\n\r\ndef s(n: int) -> int:\r\n su = 0 \r\n for i in range(int(log10(n) + 1)):\r\n su += n % 10 \r\n n //= 10\r\n return su \r\n\r\ndef l(n: int) -> int:\r\n if n == 1:\r\n return 1\r\n else:\r\n return 10 ** (n - 1) + l(n - 1)\r\n\r\ndef g(n: int) -> int:\r\n a = l(n)\r\n return a * 9\r\n\r\nn = int(input())\r\nif n < 10:\r\n print(n)\r\nelif n == 10:\r\n print(9)\r\nelse: \r\n d = ceil(log10(n))\r\n ans = set()\r\n for i in range(1, d): \r\n mb = n - 10 ** i\r\n mb -= mb % (10 ** i)\r\n mb += g(i)\r\n\r\n if s(mb) > s(n):\r\n ans.add(mb)\r\n if n in ans:\r\n ans.remove(n)\r\n else:\r\n ans.add(n)\r\n ans = list(ans)\r\n ans.sort(reverse=True)\r\n print(max(ans, key=s))\r\n", "n = str(int(input()))\r\n\r\ndef sumOfDigits(x):\r\n total = 0\r\n for digit in str(x):\r\n total += int(digit)\r\n return total\r\n \r\nlength = len(str(n))\r\nans = n\r\nhighestSum = sumOfDigits(ans)\r\n\r\n\r\n\r\nfor i in range(length-1, -1, -1):\r\n if n[i] != \"0\":\r\n toCheck = n[:i] + str(int(n[i]) -1) + (\"9\" * (length-i-1))\r\n\r\n toCheck = int(toCheck)\r\n toCheckSum = sumOfDigits(toCheck)\r\n if toCheckSum > highestSum:\r\n highestSum = toCheckSum\r\n ans = toCheck\r\n\r\nprint(ans)", "x = input()\r\nn = len(x)\r\nif n == 1:\r\n print(x)\r\n exit(0)\r\nans = \"\"\r\ns = 0\r\nps = 0\r\npn = \"\"\r\nfor i in range(n):\r\n ts = ps + int(x[i]) - 1 + 9 * (n - i - 1)\r\n if ts >= s:\r\n ans = pn + str(int(x[i]) - 1) + \"9\" * (n - i - 1)\r\n s = ts\r\n ps += int(x[i])\r\n pn += x[i]\r\nif ps >= s:\r\n ans = pn\r\nprint(int(ans))", "n=int(input())\r\nli=[0,1,2,3,4,5,6,7,8,9]\r\nres=[n]\r\np=n//10\r\ni=1\r\nwhile p>0:\r\n rem=p%10\r\n p//=10\r\n j=li.index(rem)\r\n if j==0:\r\n i+=1\r\n continue\r\n else:\r\n j=li[j-1]\r\n res.append(p*10**(i+1)+j*10**i+int('9'*i))\r\n i+=1\r\nmaxsum=0\r\nmaxi=0\r\ndef getsum(n):\r\n res=0\r\n while n>0:\r\n res+=n%10\r\n n//=10\r\n return res\r\nfor i in res:\r\n if getsum(i)>maxsum:\r\n maxsum=getsum(i)\r\n maxi=i\r\nprint(maxi)", "a = [int(x) for x in input()]\nn = len(a)\nmaxm = 0\nfor i in range(n):\n if a[i] != 0:\n new_a = a[:i] + [a[i] - 1] + [9] * (n - i - 1)\n s = sum(new_a)\n if s >= maxm:\n maxm, maxm_num = s, new_a\ns = sum(a)\nif s >= maxm:\n maxm, maxm_num = s, a\nprint(int(''.join([str(x) for x in maxm_num])))", "n = int(input())\ns = str(n)\n\nk_n = 0\nfor x in s:\n k_n += int(x)\n\nl0 = s\nk = 0\nfor x in range(len(s)):\n l = s[:x] + str(max(int(s[x])-1,0))+'9'*(len(s)-x-1)\n k_l = 0\n for y in l:\n k_l += int(y)\n if k_l >= k:\n l0 = l\n k = k_l\nif k <= k_n:\n print(n)\nelse:\n print(int(l0))\n", "import math\r\n\r\nn = int(input())\r\nlen_n = int(math.log10(n)) + 1\r\nans = n\r\n\r\niniSum = 0\r\ntemp_n = n\r\nwhile temp_n > 0:\r\n iniSum += temp_n % 10\r\n temp_n //= 10\r\n\r\nfor i in range(len_n + 1):\r\n k = 10 ** i\r\n deduct = (n % k) + 1\r\n N = n - deduct\r\n temp_sum = 0\r\n temp_N = N\r\n while temp_N > 0:\r\n temp_sum += temp_N % 10\r\n temp_N //= 10\r\n if temp_sum > iniSum:\r\n ans = N\r\n iniSum = temp_sum\r\n\r\nprint(ans)", "n = int(input())\r\nif len(str(n)) == 1:\r\n print(n)\r\nelse:\r\n cnt = 0\r\n while cnt + 1 < len(str(n)) and str(n)[cnt + 1] == \"9\":\r\n cnt += 1\r\n if cnt == 0:\r\n if str(n)[1] == \"8\" and str(n)[2:] == \"9\" * len(str(n)[2:]):\r\n print(n)\r\n else:\r\n a = str(int(str(n)[0]) - 1)\r\n if a == \"0\":\r\n print(\"9\" * (len(str(n)) - 1))\r\n else:\r\n print(a + \"9\" * (len(str(n)) - 1))\r\n elif cnt == len(str(n)) - 1:\r\n print(n)\r\n else:\r\n ans = [str(n)]\r\n for i in range(1, len(str(n))):\r\n if str(n)[i] != \"0\":\r\n ans.append(str(n)[:i] + str(int(str(n)[i]) - 1) + \"9\" * (len(str(n)) - i - 1))\r\n anz = 0\r\n ans.sort(reverse=True)\r\n for i in range(len(ans)):\r\n num = ans[i]\r\n cnt = 0\r\n for j in range(len(num)):\r\n cnt += int(num[j])\r\n anz = max(anz, cnt)\r\n ans[i] = (num, cnt)\r\n for i in range(len(ans)):\r\n if ans[i][1] == anz:\r\n print(ans[i][0])\r\n break", "x = input()\r\nnum = int(x)\r\ns = sum(int(d) for d in x)\r\nfor i in range(len(x)):\r\n if x[i] == '0': continue\r\n y = x[:i] + (str(int(x[i]) - 1)) + '9' * len(x[i+1:])\r\n sumy = sum(int(d) for d in y)\r\n numy = int(y)\r\n if sumy > s or (sumy == s and numy > num):\r\n s = sumy\r\n num = numy\r\nprint(num)", "def f(s):\r\n\tif(len(s) == 1):\r\n\t\treturn [ord(s[0])-ord('0'),s]\r\n\tif(s[0] == \"0\"):\r\n\t\treturn [f(s[1:])[0], \"0\"+f(s[1:])[1]]\r\n\ta = [f(s[1:])[0]+ord(s[0])-ord(\"0\"),s[0]+f(s[1:])[1]]\r\n\tb = [ord(s[0])-ord(\"0\")-1+9*(len(s)-1),str(int(s[0])-1)+(len(s)-1)*\"9\"]\r\n\treturn max(a,b)\r\n\r\nn = input()\r\nprint(int(f(n)[1]))", "import sys\r\ninput = sys.stdin.readline\r\n\r\nx = input()[:-1]\r\nn = len(x)\r\nd = [int(x)]\r\nfor i in range(1, n+1):\r\n d.append(int(str(int(x[:i])-1) + '9'*(n-i)))\r\nd.sort(reverse=True)\r\n\r\nfor i in range(len(d)):\r\n if d[i] <= int(x):\r\n c = sum([int(a) for a in str(d[i])])\r\n d[i] = [c, d[i]]\r\n\r\nc = max(i for i, j in d)\r\nfor i, j in d:\r\n if i == c:\r\n print(j)\r\n break" ]
{"inputs": ["100", "48", "521", "1", "2", "3", "39188", "5", "6", "7", "8", "9", "10", "59999154", "1000", "10000", "100000", "1000000", "10000000", "100000000", "1000000000", "10000000000", "100000000000", "1000000000000", "10000000000000", "100000000000000", "1000000000000000", "10000000000000000", "100000000000000000", "1000000000000000000", "999999990", "666666899789879", "65499992294999000", "9879100000000099", "9991919190909919", "978916546899999999", "5684945999999999", "999999999999999999", "999999999999990999", "999999999999999990", "909999999999999999", "199999999999999999", "299999999999999999", "999999990009999999", "999000000001999999", "999999999991", "999999999992", "79320", "99004", "99088", "99737", "29652", "59195", "19930", "49533", "69291", "59452", "11", "110", "111", "119", "118", "1100", "1199", "1109", "1190", "12", "120", "121", "129", "128", "1200", "1299", "1209", "1290", "13", "130", "131", "139", "138", "1300", "1399", "1309", "1390", "14", "140", "141", "149", "148", "1400", "1499", "1409", "1490", "15", "150", "151", "159", "158", "1500", "1599", "1509", "1590", "16", "160", "161", "169", "168", "1600", "1699", "1609", "1690", "17", "170", "171", "179", "178", "1700", "1799", "1709", "1790", "18", "180", "181", "189", "188", "1800", "1899", "1809", "1890", "19", "190", "191", "199", "198", "1900", "1999", "1909", "1990", "20", "200", "201", "209", "208", "2000", "2099", "2009", "2090", "21", "210", "211", "219", "218", "2100", "2199", "2109", "2190", "22", "220", "221", "229", "228", "2200", "2299", "2209", "2290", "23", "230", "231", "239", "238", "2300", "2399", "2309", "2390", "24", "240", "241", "249", "248", "2400", "2499", "2409", "2490", "25", "250", "251", "259", "258", "2500", "2599", "2509", "2590", "26", "260", "261", "269", "268", "2600", "2699", "2609", "2690", "27", "270", "271", "279", "278", "2700", "2799", "2709", "2790", "28", "280", "281", "289", "288", "2800", "2899", "2809", "2890", "29", "290", "291", "299", "298", "2900", "2999", "2909", "2990", "999", "999", "890", "995", "999", "989", "999", "999", "991", "999", "9929", "4999", "9690", "8990", "9982", "9999", "1993", "9367", "8939", "9899", "99999", "93929", "99999", "38579", "79096", "72694", "99999", "99999", "99992", "27998", "460999", "999999", "999999", "998999", "999999", "999929", "999999", "999999", "979199", "999999", "9899999", "9699959", "9999999", "9997099", "8992091", "9599295", "2999902", "9999953", "9999999", "9590999"], "outputs": ["99", "48", "499", "1", "2", "3", "38999", "5", "6", "7", "8", "9", "9", "59998999", "999", "9999", "99999", "999999", "9999999", "99999999", "999999999", "9999999999", "99999999999", "999999999999", "9999999999999", "99999999999999", "999999999999999", "9999999999999999", "99999999999999999", "999999999999999999", "999999989", "599999999999999", "59999999999999999", "8999999999999999", "9989999999999999", "899999999999999999", "4999999999999999", "999999999999999999", "999999999999989999", "999999999999999989", "899999999999999999", "199999999999999999", "299999999999999999", "999999989999999999", "998999999999999999", "999999999989", "999999999989", "78999", "98999", "98999", "98999", "28999", "58999", "19899", "48999", "68999", "58999", "9", "99", "99", "99", "99", "999", "999", "999", "999", "9", "99", "99", "99", "99", "999", "999", "999", "999", "9", "99", "99", "99", "99", "999", "999", "999", "999", "9", "99", "99", "99", "99", "999", "999", "999", "999", "9", "99", "99", "99", "99", "999", "999", "999", "999", "9", "99", "99", "99", "99", "999", "999", "999", "999", "9", "99", "99", "99", "99", "999", "999", "999", "999", "18", "99", "99", "189", "99", "999", "1899", "999", "999", "19", "189", "189", "199", "198", "1899", "1999", "1899", "1989", "19", "199", "199", "199", "199", "1999", "1999", "1999", "1999", "19", "199", "199", "199", "199", "1999", "1999", "1999", "1999", "19", "199", "199", "199", "199", "1999", "1999", "1999", "1999", "19", "199", "199", "199", "199", "1999", "1999", "1999", "1999", "19", "199", "199", "199", "199", "1999", "1999", "1999", "1999", "19", "199", "199", "199", "199", "1999", "1999", "1999", "1999", "19", "199", "199", "199", "199", "1999", "1999", "1999", "1999", "19", "199", "199", "199", "199", "1999", "1999", "1999", "1999", "28", "199", "199", "289", "199", "1999", "2899", "1999", "1999", "29", "289", "289", "299", "298", "2899", "2999", "2899", "2989", "999", "999", "889", "989", "999", "989", "999", "999", "989", "999", "9899", "4999", "8999", "8989", "9899", "9999", "1989", "8999", "8899", "9899", "99999", "89999", "99999", "29999", "78999", "69999", "99999", "99999", "99989", "19999", "399999", "999999", "999999", "998999", "999999", "999899", "999999", "999999", "899999", "999999", "9899999", "8999999", "9999999", "9989999", "8989999", "8999999", "2999899", "9999899", "9999999", "8999999"]}
UNKNOWN
PYTHON3
CODEFORCES
15
e130bca7c9717c52c141f6eb021a0626
Delete from the Left
You are given two strings $s$ and $t$. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by $1$. You can't choose a string if it is empty. For example: - by applying a move to the string "where", the result is the string "here", - by applying a move to the string "a", the result is an empty string "". You are required to make two given strings equal using the fewest number of moves. It is possible that, in the end, both strings will be equal to the empty string, and so, are equal to each other. In this case, the answer is obviously the sum of the lengths of the initial strings. Write a program that finds the minimum number of moves to make two given strings $s$ and $t$ equal. The first line of the input contains $s$. In the second line of the input contains $t$. Both strings consist only of lowercase Latin letters. The number of letters in each string is between 1 and $2\cdot10^5$, inclusive. Output the fewest number of moves required. It is possible that, in the end, both strings will be equal to the empty string, and so, are equal to each other. In this case, the answer is obviously the sum of the lengths of the given strings. Sample Input test west codeforces yes test yes b ab Sample Output 2 9 7 1
[ "string1 = input()\r\nstring2 = input()\r\nsame = 0\r\nminn = min(len(string1),len(string2))\r\nfor i in range(minn):\r\n if string1[-1-i]==string2[-1-i]:\r\n same += 2\r\n else:\r\n break\r\nprint((len(string1)+len(string2))-same)", "s=input();s1=input()\r\nsl,s1l=len(s),len(s1)\r\nwhile sl and s1l and s[sl-1]==s1[s1l-1]:\r\n sl-=1;s1l-=1\r\nprint(sl+s1l)", "a = input()\nb = input()\nw = 0\nwhile True:\n i = len(a) - w - 1\n j = len(b) - w - 1\n if i >= 0 and j >= 0 and a[i] == b[j]:\n w += 1\n else:\n break\n\nprint(len(a) + len(b) - 2 * w) ", "a=input()\r\nb=input()\r\nl=len(a)-1\r\nm=len(b)-1\r\nwhile l>=0 and m>=0 and a[l]==b[m]:\r\n l-=1\r\n m-=1\r\nprint(l+m+2)", "s = input()\r\nt = input()\r\nw = 0\r\n\r\nwhile True:\r\n i = len(s) - w - 1\r\n j = len(t) - w - 1\r\n if i >= 0 and j >= 0 and s[i] == t[j]:\r\n w += 1\r\n else:\r\n break\r\n\r\nprint(len(s) + len(t) - 2 * w)\r\n", "a = input()\r\nb = input()\r\nx = len(a) - 1\r\ny = len(b) - 1\r\nn = 0\r\nflg = 0\r\nwhile x >= 0 and y >= 0:\r\n if a[x] == b[y]:\r\n x -= 1\r\n y -= 1\r\n n += 1\r\n else:\r\n break\r\nprint(len(a)+len(b)-(2*n))", "def main():\r\n s = input()\r\n t = input()\r\n \r\n moves = 0\r\n s_len = len(s)\r\n t_len = len(t)\r\n i = s_len - 1 # zero-based\r\n j = t_len - 1 # zero-based\r\n min_len = min(s_len, t_len)\r\n \r\n for it in range(min_len):\r\n if s[i] == t[j]:\r\n i -= 1\r\n j -= 1\r\n \r\n i = i+1\r\n j = j+1\r\n moves = i + j\r\n \r\n print(moves)\r\n \r\n \r\nif __name__=='__main__':\r\n main()", "a = input()\r\nb = input()\r\na = a[::-1]\r\nb = b[::-1]\r\nc = 0\r\nfor i in range(min(len(a),len(b))):\r\n if a[i] == b[i]:\r\n c += 1\r\n elif c == 0:\r\n print(len(a) + len(b))\r\n break\r\n else:\r\n break\r\nif c != 0:\r\n print(len(a) + len(b) - 2*c)\n# Sun Oct 03 2021 00:40:53 GMT+0300 (Москва, стандартное время)\n", "s = input()\nt = input()\n\nshort_str = min(len(s), len(t))\nj = len(s)-1\nk = len(t)-1\ncount = 0\n\nfor i in range(short_str):\n if s[j]==t[k]:\n count+=1\n j-=1\n k-=1\n else:\n break\nprint((len(s)-count)+(len(t)-count))\n\t \t \t \t\t \t\t\t \t\t \t \t \t\t\t", "s = input()\nt = input()\ns_size, t_size = len(s) - 1 , len(t) - 1\ncnt = 0\nwhile s_size >= 0 and t_size >= 0:\n if s[s_size] == t [t_size]: cnt += 2\n else: break\n s_size -= 1\n t_size -= 1\nprint(len(s) + len(t) - cnt)\n \t\t\t \t\t \t \t \t\t\t \t\t \t", "a = input()\nb = input()\na = a[::-1]\nb = b[::-1]\nc = min(len(a), len(b))\nd = 0\nfor i in range(c):\n if a[i] == b[i]:\n d += 2\n else:\n break\nprint(len(a) + len(b) - d)\n# Tue Sep 05 2023 22:02:08 GMT+0300 (Moscow Standard Time)\n", "s1=input()\r\ns2=input()\r\nnum=len(s1)+len(s2)\r\ni=len(s1)-1\r\nj=len(s2)-1\r\ndl=0\r\nwhile(s1[i]==s2[j]) and i>=0 and j>=0:\r\n dl+=2\r\n i-=1\r\n j-=1\r\nprint(num-dl)", "s = list(input())\nt = list(input())\n\ns.reverse()\nt.reverse()\n\nl1, l2 = len(s), len(t)\ni, j = 0, 0\n\nwhile i < l1 and j < l2 and s[i] == t[j]:\n i += 1\n j += 1\n\nans = (l1-i) + (l2-j)\nprint(ans)\n", "s=input()[::-1]\r\nt=input()[::-1]\r\nmax=max(len(s), len(t))\r\nmin=min(len(s), len(t))\r\ncount=0\r\nfor i in range(max):\r\n if s[i]==t[i] and i == min-1:\r\n count+=1\r\n break\r\n elif s[i]==t[i]:\r\n count+=1\r\n else:\r\n break\r\nprint(len(s)+len(t)-(2*count))", "s1=input()\ns2=input()\na=len(s1)\nb=len(s2)\nsum=a+b\nc=0\nif a>b:\n for i in range(b-1,-1,-1):\n a=a-1\n if s2[i]==s1[a]:\n c=c+1\n else:\n break\n print(sum-2*c)\nelse:\n for i in range(a-1,-1,-1):\n b=b-1\n if s1[i]==s2[b]:\n c=c+1\n else:\n break\n print(sum-2*c)\n\t \t \t \t\t \t \t \t \t\t \t \t\t", "s = input()\r\nt = input()\r\n\r\ncount = 0\r\n\r\nwhile (True):\r\n a = len(s) - count - 1\r\n b = len(t) - count - 1\r\n \r\n if (a >= 0 and b >= 0 and s[a] == t[b]):\r\n count += 1\r\n else:\r\n break\r\n \r\nprint(len(s) + len(t) - 2 * count)\r\n \r\n", "s = input()\r\nt = input()\r\ncounter = 0\r\nwhile True:\r\n a = len(s) - counter - 1\r\n b = len(t) - counter - 1\r\n if a >= 0 and b >= 0 and s[a] == t[b]:\r\n counter += 1\r\n else:\r\n break\r\nprint(len(s) + len(t) - 2 * counter)", "s1=input()\r\ns2=input()\r\nlen1=len(s1)-1\r\nlen2=len(s2)-1\r\ncount=0\r\nwhile(len1>=0 and len2>=0):\r\n if(s1[len1]!=s2[len2]):\r\n break\r\n count+=1\r\n len1-=1\r\n len2-=1\r\nprint(len(s1)+len(s2)-2*count)\r\n\r\n", "s1 = list(input())\r\ns2 = list(input())\r\nx = 0\r\nfor i in range(1, min(len(s1),len(s2))+1):\r\n if s1[-i] != s2[-i]:\r\n break\r\n else:\r\n x += 1\r\nprint(len(s1)+len(s2)-2*x)\r\n\r\n", "s1=input()\ns2=input()\ns1=s1[::-1]\ns2=s2[::-1]\nn=0\nL=min(len(s1),len(s2))\nfor i in range(L):\n if s1[i]==s2[i]:\n n+=1\n else:\n break\nprint(len(s1)+len(s2)-2*n)\n\n\n \t\t \t\t \t\t \t\t \t \t", "s=input()\r\nt=input()\r\ns=s[::-1]\r\nt=t[::-1]\r\nn=min(len(t),len(s))\r\nr=max(len(t),len(s))-min(len(t),len(s))\r\nk=0\r\nfor i in range(n):\r\n if s[i]==t[i]:\r\n k+=2\r\n else:\r\n break\r\nprint(n*2-k+r)\r\n ", "n=input()\r\ns=input()\r\na=len(n)\r\nb=len(s)\r\nwhile a>0 and b>0 and n[a-1]==s[b-1]:\r\n a=a-1\r\n b=b-1\r\nprint(a+b)\r\n", "#B. Delete from the Left\r\n\r\ns = input()\r\nt = input()\r\nn = len(s)\r\nm = len(t)\r\ni = 0\r\nwhile i < min(n, m) and s[n-i-1] == t[m-i-1]:\r\n i += 1\r\nprint(n+m-2*i)\r\n", "def solve(s, t):\r\n same_suffix_length = 0\r\n while same_suffix_length + 1 <= min(len(s), len(t)) and s[-1 - same_suffix_length] == t[-1 - same_suffix_length]:\r\n same_suffix_length += 1\r\n return len(s) + len(t) - 2 * same_suffix_length\r\n\r\nif __name__ == \"__main__\":\r\n s = input()\r\n t = input()\r\n print(solve(s, t))", "s = input()\nt = input()\ni = 0\nls = len(s)\nlt = len(t)\nm = min(ls, lt)\nwhile i < m and s[~i] == t[~i]:\n i += 1\nprint(ls + lt - (2 * i))\n", "if __name__ == '__main__':\r\n s = str(input())\r\n t = str(input())\r\n left, right = len(s) - 1, len(t) - 1\r\n while left >= 0 and right >= 0:\r\n if s[left] == t[right]:\r\n left -= 1; right -= 1\r\n else:\r\n break\r\n print(left + right + 2)", "first_string = input()\nsecond_string = input()\n\nlongest_length = max(len(first_string), len(second_string))\nshortest_length = min(len(first_string), len(second_string))\n\nto_remove = longest_length-shortest_length\n\na = 0\nfor index in range(-1, -shortest_length-1, -1):\n if first_string[index] != second_string[index]:\n a = index\n break\n\nif a != 0:\n to_remove += 2*(shortest_length+a+1)\nprint(to_remove)\n\n# Thu Sep 30 2021 23:40:19 GMT+0300 (Москва, стандартное время)\n", "ui1 = input()\r\nui2 = input()\r\nres = len(ui1) + len(ui2)\r\nfor i in range(1, min(len(ui1), len(ui2)) + 1):\r\n if ui1[len(ui1) - i] == ui2[len(ui2) - i]:\r\n res -= 2\r\n else:\r\n break\r\nprint(res)", "import sys\r\nimport math\r\nfrom itertools import combinations\r\niput = sys.stdin.readline\r\n\r\ns = input()\r\ns2 = input()\r\nif len(s2) == len(s):\r\n ans = 0\r\n tmp = 0\r\n for i in range(len(s)):\r\n if s[i] == s2[i]:\r\n tmp += 2\r\n else:\r\n ans += 2+tmp\r\n tmp = 0\r\n print(ans)\r\nelif len(s2) < len(s):\r\n ans = len(s) - len(s2)\r\n j = len(s) - len(s2)\r\n tmp = 0\r\n for i in range(len(s2)):\r\n if s[j] == s2[i]:\r\n tmp += 2\r\n else:\r\n ans += 2+tmp\r\n tmp = 0\r\n j += 1\r\n print(ans)\r\nelse:\r\n ans = len(s2) - len(s)\r\n j = len(s2) - len(s)\r\n tmp = 0\r\n for i in range(len(s)):\r\n if s2[j] == s[i]:\r\n tmp += 2\r\n else:\r\n ans += 2+tmp\r\n tmp = 0\r\n j += 1\r\n print(ans)\r\n", "s1=input()\r\ns2=input()\r\n\r\nn1=0\r\nn2=0\r\nif len(s2)<=len(s1):\r\n s1,s2=s2,s1\r\n\r\nfor i in range(1,len(s1)+1):\r\n if s1[-i]==s2[-i]:\r\n n1+=1\r\n else:\r\n break\r\nif len(s1)==n1:\r\n print(len(s2)-i)\r\nelse:\r\n print(len(s1)-n1+len(s2)-n1)\r\n", "s = input()\r\nt = input()\r\ni = -1\r\nj = -1\r\nwhile s[i] == t[j]:\r\n if i+len(s)>0 and j+len(t)>0:\r\n i -= 1\r\n j -= 1\r\n elif i+len(s) == 0:\r\n j = -len(s)-2\r\n break\r\n elif j+len(t) == 0:\r\n i = -len(t)-2\r\n break\r\nprint(len(s)+len(t)+i+j+2)", "s = input()\r\nt = input()\r\nreverse_s = s[::-1]\r\nreverse_t = t[::-1]\r\ntotal = len(s)+len(t)\r\ncount = 0\r\ni = 0\r\nwhile ( i < min([len(s),len(t)]) ) and (reverse_s[i] == reverse_t[i]):\r\n count += 2\r\n i += 1\r\nprint(total-count)", "s = input()\r\nt = input() \r\nfl = 0\r\nif len(s) >= len(t):\r\n for i in range(min(len(t),len(s))):\r\n if t[i] == s[i+abs(len(s) - len(t))]:\r\n fl += 1\r\n else:\r\n fl = 0\r\n print(abs(len(s) - len(t)) + 2*(len(t) - fl))\r\nelse:\r\n for i in range(min(len(t),len(s))):\r\n if t[i+abs(len(s) - len(t))] == s[i]:\r\n fl += 1\r\n else:\r\n fl = 0\r\n print(abs(len(s) - len(t)) + 2*(len(s) - fl))", "s = input()\r\nt = input()\r\nm = len(s)\r\nn = len(t)\r\nwhile m > 0 and n > 0 and s[m - 1] == t[n - 1]:\r\n m -= 1\r\n n -= 1\r\nprint(m + n)\r\n", "s = input()\r\nt = input()\r\nlength_s=len(s)\r\nlength_t=len(t)\r\nwhile length_s and length_t and s[length_s-1]==t[length_t-1]:\r\n length_s-=1\r\n length_t-=1\r\nprint(length_s+length_t)", "from collections import *\nx=deque(input())\ny=deque(input())\nwhile x[-1]==y[-1]:\n x.pop()\n y.pop()\n if len(x)==0 or len(y)==0:\n break\nc=len(x)+len(y)\nprint(c)\n \t\t \t \t\t\t \t\t\t \t\t \t \t", "s = input()\r\nt = input()\r\n\r\na = len(s)-1\r\nb = len(t)-1\r\n\r\nwhile a >= 0 and b >= 0 and s[a] == t[b]:\r\n\ta -= 1\r\n\tb -= 1\r\n\r\nprint(a+b+2)\r\n", "a=input()\r\nb=input()\r\nn1=len(a)\r\nn2=len(b)\r\nwhile n1 and n2 and a[n1-1]==b[n2-1]:\r\n n1-=1;n2-=1\r\nprint(n1+n2)", "a = input()\r\nb = input()\r\ni = 1\r\ntry:\r\n while a[-i] == b[-i]:\r\n i += 1\r\nexcept:\r\n pass\r\nprint((len(a)+(len(b)) - 2 * (i - 1)))\r\n", "s=str(input())\nt=str(input())\na=len(s)\nb=len(t)\np=0\nfor i in range(1,min(a,b)+1):\n if(s[-i]==t[-i]):\n p+=1\n else:\n break\nprint(a+b-2*p)\n\n\t \t\t \t \t\t \t \t \t\t \t\t\t\t", "first = input()\r\nsecond = input()\r\nukaz = len(first)-1\r\nukaz1 = len(second) -1\r\nans = 0\r\nwhile first[ukaz] == second[ukaz1] and ukaz != -1 and ukaz1 != -1:\r\n ans += 1\r\n ukaz -= 1\r\n ukaz1 -= 1\r\n\r\n\r\nprint(len(first) - ans + len(second) - ans)\n# Wed Sep 29 2021 18:12:46 GMT+0300 (Москва, стандартное время)\n", "s = input()\nt = input()\na, b = s[::-1], t[::-1]\ncnt = 0\nfor i in range(0, min(len(s), len(t))):\n if a[i] == b[i]:\n cnt += 2\n else: break\nprint(len(s) + len(t) - cnt)\n \t \t\t \t \t \t \t\t\t\t\t\t \t\t\t\t\t \t", "s,t=input(),input()\r\ni,j=len(s),len(t)\r\nwhile i*j*(s[i-1] == t[j-1]):\r\n i-=1\r\n j-=1\r\nprint(i+j)\r\n\r\n", "s1 = str(input())\r\ns2 = str(input())\r\ns1 = s1[::-1]\r\ns2 = s2[::-1]\r\ni = 0\r\nwhile i < len(s1) and i < len(s2):\r\n if s1[i] == s2[i]:\r\n i += 1\r\n else:\r\n break\r\nprint(len(s1) - i + len(s2) - i)", "p=input()\r\nq=input()\r\nr=len(p)\r\ns=len(q)\r\nwhile p[r-1]==q[s-1] and r>0 and s>0:\r\n r=r-1\r\n s=s-1\r\nprint(r+s)", "a=input()\r\nb=input()\r\nn=len(a)\r\nm=len(b)\r\nwhile n and m and a[n-1]==b[m-1]:\r\n n-=1;m-=1\r\nprint(n+m)", "s = input()\nt = input()\nString = []\nif s==t:\n Moves = 0\nif len(s)==len(t) and s!=t:\n for i in range(1,len(s)):\n if s[-i] == t[-i]:\n String.append(t[-i])\n else:\n break\n Moves = len(s)+len(t)-2*len(String)\nelif s!=t and len(s)!=len(t):\n Min = min(s,t,key=len)\n Max = max(s,t,key=len)\n for i in range(1,len(Min)+1):\n if Min[-i] == Max[-i]:\n String.append(Max[-i])\n else:\n break\n Moves = len(s)+len(t)-2*len(String)\nprint(Moves)\n", "a=input()\r\nb=input()\r\nla,lb=len(a),len(b)\r\nminl=min(la,lb)\r\na=a[::-1]\r\nb=b[::-1]\r\ncount=0\r\nfor i in range(minl):\r\n if a[i]==b[i]:\r\n count+=1\r\n elif i==0:\r\n count=la+lb\r\n break\r\n else:\r\n break\r\nif count!=la+lb:\r\n final=la-count+lb-count\r\n print(final)\r\nelse:\r\n print(count)\r\n", "s = input()\r\nt = input()\r\nx = len(s)\r\ny = len(t)\r\nm = max(x,y)\r\nn = min(x,y)\r\nif x == m:\r\n big = s\r\n small = t\r\nelse:\r\n big = t\r\n small = s\r\nif big[-1] != small[-1]:\r\n print(m+n)\r\nelse:\r\n count = 0\r\n for i in range(n):\r\n if big[-count-1] == small[-count-1]:\r\n count = count+1\r\n else:\r\n break\r\n print(m+n-count-count)", "S=input()\r\nA=input()\r\nN=len(S)\r\nJ=len(A)\r\nwhile N*J*(S[N-1]==A[J-1]):\r\n\tN-=1\r\n\tJ-=1\r\nprint(N+J)", "s = input()\r\nt = input()\r\n\r\ncnt = 0\r\nfor i in range(min(len(s),len(t))):\r\n if s[-(i+1)] == t[-(i+1)]:\r\n cnt += 1\r\n else:\r\n break\r\nprint(len(s) + len(t) - 2 * cnt)", "s1 = list(input())\r\ns2 = list(input())\r\ns1.reverse()\r\ns2.reverse()\r\ncount = 0\r\n\r\nfor i, i1 in zip(s1, s2):\r\n if i == i1:\r\n count += 2\r\n else:\r\n break\r\nprint(len(s1) + len(s2) - count)\r\n", "s1 = input()\r\ns2 = input()\r\nc = 0\r\nfor i in range(-1, -min(len(s1),len(s2))-1, -1):\r\n if s1[i] == s2[i]:\r\n c += 1\r\n else:\r\n break\r\nprint(len(s1)+len(s2)-c*2)", "s = input().strip()\r\nt = input().strip()\r\n\r\ncommon_suffix_len = 0\r\nfor i in range(1, min(len(s), len(t))+1):\r\n if s[-i] == t[-i]:\r\n common_suffix_len += 1\r\n else:\r\n break\r\n\r\ntotal_moves = len(s)+len(t)-2*common_suffix_len\r\nprint(total_moves)", "a = input()\r\nb = input()\r\n\r\nrevA = a[::-1]\r\nrevB = b[::-1]\r\n\r\ncnt = 0\r\nfor x,y in zip(revA,revB):\r\n if x==y:\r\n cnt+=1\r\n# print(cnt)\r\nif len(b)==0 or len(a)==0:\r\n print(len(a+b))\r\nelse:\r\n i = len(a)\r\n j = len(b)\r\n while a[i-1]==b[j-1] and j>0 and i>0:\r\n j-=1\r\n i-=1\r\n print(j+i)\r\n # else:\r\n # lnA = len(a)\r\n # lnB = len(b)\r\n # print(lnA+lnB)\r\n\r\n", "s=list(input())\r\nt=list(input())\r\nmoves=0\r\nif len(s)==len(t):\r\n for i in range (len(s)):\r\n if s[i]!=t[i]:\r\n moves=(i+1)*2\r\n print(moves)\r\nelse:\r\n if len(s)>len(t):\r\n diff=len(s)-len(t)\r\n s=s[len(s)-len(t):]\r\n for i in range (len(s)):\r\n if s[i]!=t[i]:\r\n moves=(i+1)*2\r\n print(moves+diff)\r\n elif len(t)>len(s):\r\n diff=len(t)-len(s)\r\n t=t[len(t)-len(s):]\r\n for i in range (len(s)):\r\n if s[i]!=t[i]:\r\n moves=(i+1)*2\r\n print(moves+diff)\r\n", "s1= input()\r\ns2= input()\r\ni = len(s1) - 1\r\nj = len(s2) - 1\r\nwhile i >= 0 and j >= 0:\r\n if s1[i] == s2[j]:\r\n i -=1\r\n j -=1\r\n continue \r\n else:\r\n break\r\nprint(i+j+2) ", "a,b=input()[::-1],input()[::-1];t=0\r\nk=min(len(a),len(b))\r\nfor i in range(k):\r\n if a[i]==b[i]:t+=2\r\n else:break\r\nprint(len(a)+len(b)-t)", "s = input()\r\nt= input()\r\ntl = len(s) + len(t)\r\nsml = [len(s),len(t)]\r\ns_l = min(sml)\r\nfor i in range(s_l):\r\n if s[len(s) - i -1] == t[len(t) - i - 1]:\r\n tl -= 2\r\n else:\r\n break\r\nprint(tl)", "import sys\r\n# sys.stdin = open(\"input.txt\", \"r\")\r\n\r\ns1 = input()[::-1]\r\ns2 = input()[::-1]\r\n\r\nc = 0\r\n\r\nfor i, j in zip(s1, s2):\r\n if i != j:\r\n break\r\n c += 1\r\n\r\nprint(len(s1) + len(s2) - 2 * c)\r\n\r\n\r\n", "a=input()\nb=input()\nc=min(len(a),len(b))\ni=0\nwhile i<c and a[len(a)-1-i]==b[len(b)-1-i]:\n\ti+=1\ne=len(a)+len(b)-2*i\nprint(e)\n \t\t \t \t\t\t \t\t \t\t\t\t \t\t\t", "s1=input()\r\ns2=input()\r\nn=len(s1)\r\nm=len(s2)\r\ns1=s1[::-1]\r\ns2=s2[::-1]\r\nc=0\r\nfor i in range(min(n,m)):\r\n \r\n if s1[i]!=s2[i]:\r\n break\r\n else:\r\n c=c+1\r\n \r\nif c==0:\r\n print(n+m)\r\n\r\nelse:\r\n print(n-c+m-c)\r\n \r\n", "import os,sys,io,math\r\nfrom re import *\r\nfrom math import *\r\nfrom array import *\r\nfrom heapq import *\r\nfrom bisect import *\r\nfrom functools import *\r\nfrom itertools import *\r\nfrom statistics import *\r\nfrom collections import *\r\nI=lambda:[*map(int,sys.stdin.readline().split())]\r\nIP=lambda:map(int,input().split())\r\nIS=lambda:input()\r\nIN=lambda:int(input())\r\nIF=lambda:float(input())\r\n\r\na,b,c=IS(),IS(),0\r\nwhile True:\r\n r=len(a)-c-1\r\n s=len(b)-c-1\r\n if r>=0 and s>=0 and a[r]==b[s]:c+=1\r\n else:break\r\nprint(len(a)+len(b)-2*c)", "\ns,n = input() ,input()\n\nfirst = len(s)\nsecond = len(n)\n\nwhile first and second and s[first-1]==n[second-1]:\n first-=1\n second-=1\nprint(first+second)\n\n\t\t\t \t \t\t\t \t \t \t \t\t\t\t \t", "def solve(a,b):\n suff = 0\n i,j=len(a)-1,len(b)-1\n while i >= 0 and j >= 0:\n if a[i] != b[j]:\n break\n else:\n suff += 1\n i -= 1\n j -= 1\n return len(a)-suff+len(b)-suff\n\na=input()\nb=input()\nprint (solve(a,b))\n", "def main():\n s = input() \n t = input()\n smaller = t if len(t) < len(s) else s\n com = 0\n for i in range(1,len(smaller) +1):\n if t[-i] == s[-i]:\n com += 1 \n else:\n break \n\n print((len(s) - com) + (len(t) - com))\n\n return\n\n\nmain()\n \t \t \t \t\t \t \t\t \t\t \t \t \t\t", "first=input()\r\nsecond=input()\r\nlength_a,length_b=len(first),len(second)\r\ncounter=0\r\nif length_a>length_b or length_a==length_b:\r\n item=-1\r\n for i in range(len(second)):\r\n if first[item]==second[item]:\r\n counter+=1\r\n item-=1\r\n if (item-1)*(-1)-2==len(second):\r\n break\r\n print(length_a-counter+length_b-counter)\r\nelse:\r\n item2=-1\r\n for i in range(len(first)):\r\n if first[item2]==second[item2]:\r\n counter+=1\r\n item2-=1\r\n if (item2-1)*(-1)-2==len(first):\r\n break\r\n print(length_a-counter+length_b-counter)", "s1 = input()\r\ns2 = input()\r\ns1 = s1[::-1]\r\ns2 = s2[::-1]\r\nk = 0\r\nfor i in range(0, min(len(s1), len(s2))):\r\n if s1[i] != s2[i]:\r\n break\r\n k += 1\r\nprint(len(s1) - k + len(s2) - k)", "import math\ns = input()\nt = input()\nx = min(len(s),len(t))\nans = 0\ni = -1\nwhile i+x >= 0 and s[i] == t[i]:\n ans += 1\n i -= 1\nans = len(s) + len(t) - ans - ans\nprint(ans)\n\n#1562 B\n#1579 E1\n#1566 C\n\n", "a = input()\nb = input()\nn = 0\nfor i, j in zip(a[::-1], b[::-1]):\n if i == j:\n n += 1\n else:\n break\nresult = len(a) + len(b) - 2 * n\nprint(result)\n# Mon Sep 27 2021 18:41:48 GMT+0300 (Москва, стандартное время)\n", "a=str(input())\nb=str(input())\na1=len(a)\nb1=len(b)\nc=0\ni=len(a)-1\nj=len(b)-1\nwhile i>=0 and j>=0:\n if(a[i]==b[j]):\n c=c+1\n else:\n break \n i=i-1\n j=j-1\nprint(a1+b1-2*c)\n \t \t\t \t \t\t\t\t\t \t \t\t \t\t", "s = input()\r\nt = input()\r\n\r\nmove = 0 \r\n\r\nwhile (1) :\r\n i = len(s) - move -1 # -1 for indexing\r\n j = len(t) - move -1 \r\n \r\n if( i >= 0 and j >= 0 and s[i] == t[j]):\r\n move += 1\r\n else :\r\n break ;\r\n\r\nprint(len(s) + len(t) - move*2 )\r\n \r\n", "s1 = input()\r\ns2 = input()\r\nans = 0\r\nlen1 = 0\r\nif s1[-1] == s2[-1]:\r\n for i in range(min(len(s1),len(s2))):\r\n if s1[-1-i] == s2[-1-i]:\r\n len1 += 1\r\n continue\r\n if s1[-1-i] != s2[-1-i]:\r\n break\r\nelse:\r\n ans = len(s1) + len(s2)\r\n print(ans)\r\n exit()\r\nans = len(s1) - len1 + len(s2) - len1\r\nprint(ans)", "s=input()\r\nt=input()\r\ni=len(s)\r\nj=len(t)\r\nwhile s[i-1]==t[j-1] and i>0 and j>0:\r\n i-=1\r\n j-=1\r\nprint(i+j)\r\n\r\n\r\n \r\n \r\n", "from collections import deque\r\n\r\ns1 = input()\r\ns2 = input()\r\n\r\nst1 = deque(s1)\r\nst2 = deque(s2)\r\n\r\nwhile st1 and st2 and st1[-1] == st2[-1]:\r\n st1.pop()\r\n st2.pop()\r\n\r\nprint(len(st1) + len(st2))\r\n", "s1, s2 = input(), input() \r\nminimum = min(len(s1), len(s2)) \r\ni = 1 \r\nwhile i <= minimum and s1[-i] == s2[-i]:\r\n i += 1\r\ni -= 1\r\nprint(len(s1) + len(s2) - 2 * i)", "s1=input()\r\ns2=input()\r\nl1,l2=len(s1),len(s2)\r\nif l1<l2:\r\n s1='0'*(l2-l1)+s1\r\nelse:\r\n s2='0'*(l1-l2)+s2\r\nres=0\r\nfor i in range(max(l1,l2)-1,-1,-1):\r\n if s1[i]==s2[i]:\r\n res+=1\r\n else:\r\n break\r\nprint(l1+l2-2*res)", "s,t=input(),input()\r\nc=0\r\nif len(s)>=len(t):\r\n\r\n for i in range(len(t)):\r\n if s[-1-i]==t[-1-i]:\r\n c+=1\r\n else:\r\n break\r\n print(len(s)+len(t)-c-c)\r\n\r\nif len(t)>len(s):\r\n\r\n for i in range(len(s)):\r\n if s[-1-i]==t[-1-i]:\r\n c+=1\r\n else:\r\n break\r\n print(len(s)+len(t)-c-c)", "s = input()\r\nt = input()\r\na = len(s)\r\nb = len(t)\r\nc = (a+b)\r\ncount = 0\r\nif(s[-1] != t[-1]):\r\n print(c)\r\nelif(s == t):\r\n print(0)\r\nelse:\r\n while((s != 0)and(t != 0)):\r\n d = (a-1) - count\r\n e = (b-1) - count\r\n if(d >= 0 and e >= 0 and (s[d] == t[e])):\r\n count += 1\r\n else:\r\n break\r\n result = c - (count)*2\r\n print(result)\r\n\r\n\r\n\r\n \r\n", "n = list(input())\r\nt = list(input())\r\nwhile n and t and n[-1]==t[-1]:\r\n n.pop();t.pop()\r\nprint(len(n+t))", "# https://codeforces.com/contest/1005\n\nimport sys\n\ninput = lambda: sys.stdin.readline().rstrip() # faster!\n\ns = input()\nt = input()\n\ni = 0\nwhile i < len(s) and i < len(t) and s[-1 - i] == t[-1 - i]:\n i += 1\nans = len(s) + len(t) - 2 * i\nprint(ans)\n", "import sys\r\n\r\na, b = sys.stdin.read().split()\r\n\r\nsame = 0\r\nfor c, d in zip(reversed(a), reversed(b)):\r\n if c == d:\r\n same += 1\r\n else:\r\n break\r\n\r\nprint(len(a) + len(b) - same * 2)", "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\nimport math, random\r\nfrom bisect import bisect_right, bisect_left\r\nfrom itertools import product, permutations, combinations, combinations_with_replacement \r\nfrom collections import deque\r\nfrom heapq import heapify, heappush, heappop\r\nfrom functools import lru_cache, reduce\r\ninf = float('inf')\r\ndef error(*args, sep=' ', end='\\n'):\r\n print(*args, sep=sep, end=end, file=sys.stderr)\r\n# mod = 1000000007\r\n# mod = 998244353\r\n# sys.setrecursionlimit(10**5)\r\n\r\ns = input()\r\nt = input()\r\n\r\nl = len(s)\r\nr = len(t)\r\n\r\nm = min(l, r)\r\nans = 0\r\nwhile m > 0:\r\n m -= 1\r\n if s[l-1] == t[r-1]:\r\n ans += 1\r\n l -= 1\r\n r -= 1\r\n else:\r\n break\r\n\r\nans = len(s) + len(t) - 2*ans\r\nprint(ans)\r\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\ns1 = input().rstrip()\r\ns2 = input().rstrip()\r\nn1, n2 = len(s1), len(s2)\r\nn = min(n1, n2)\r\nc = 0\r\nfor i in range(n):\r\n if s1[-1 - i] == s2[-1 - i]:\r\n c += 1\r\n else:\r\n break\r\nprint(n1 - c + n2 - c)", "s = input()\nt = input()\ns_len = len(s)\nt_len = len(t)\na = min(s_len,t_len)\nfor i in range(1,a+1):\n if t[-i]==s[-i]:\n s_len-=1\n t_len-=1\n else:\n break\nprint(s_len+t_len) ", "a=input()\r\nb=input()\r\nla=len(a)\r\nlb=len(b)\r\nwhile la and lb and a[la-1]==b[lb-1]:\r\n la-=1\r\n lb-=1\r\nprint(la+lb)", "f =input()\r\nl=input()\r\n\r\n\r\n\r\nc =1 \r\nwhile c<=(min(len(f),len(l))) and l[-c]==f[-c]:\r\n c+=1\r\n\r\nans = abs(len(f)-(c-1)) + abs(len(l)-(c-1))\r\n\r\nprint(ans)\r\n\r\n", "s = input()\nt = input()\n\ncount = len(s) + len(t) \n\nlength = min(len(s), len(t))\n\nfor i in range(length): \n if s[len(s)-1-i] == t[len(t)-1-i]: \n count -=2\n else: \n break\n\n\nprint(count)\n", "s = input()\r\nt = input()\r\n\r\ni = len(s) - 1\r\nj = len(t) - 1\r\ncommon_length = 0\r\n\r\nwhile i >= 0 and j >= 0 and s[i] == t[j]:\r\n common_length += 1\r\n i -= 1\r\n j -= 1\r\n\r\n\r\nmoves_required = len(s) + len(t) - 2 * common_length\r\nprint(moves_required)\r\n", "S1 = input()\r\nS2 = input()\r\n\r\nresult = 0\r\n\r\nfor s1,s2 in zip(S1[::-1],S2[::-1]):\r\n if s1 == s2:\r\n result += 2\r\n else:\r\n break\r\nprint(len(S1) + len(S2) - result)", "s = input()\r\nt = input()\r\nm = 0\r\n\r\nwhile True:\r\n i = len(s) - m - 1\r\n j = len(t) - m - 1\r\n \r\n if i >= 0 and j >= 0 and s[i] == t[j]:\r\n m += 1\r\n else:\r\n break\r\n\r\nprint(len(s) + len(t) - 2 * m)\r\n\r\n\r\n\r\n\r\n", "s = input()\nt = input()\nc = 0\nif len(s) > len(t):\n c += len(s)\n s = s[-len(t):]\n c -= len(s)\nelse:\n c += len(t)\n t = t[-len(s):]\n c -= len(t)\n\nif t == s:\n print(c)\nelse:\n if t[-1] != s[-1]:\n print(c + 2*len(s))\n else:\n n = 0\n for a, b in zip(t[::-1], s[::-1]):\n if a == b: n += 1\n else: break\n print(c + 2*(len(t) - n))\n\n# Mon Sep 27 2021 15:49:36 GMT+0300 (Москва, стандартное время)\n", "s = input().strip()\r\nt = input().strip()\r\n\r\nn = len(s)\r\nm = len(t)\r\n\r\ni = n - 1\r\nj = m - 1\r\n\r\nwhile i >= 0 and j >= 0 and s[i] == t[j]:\r\n i -= 1\r\n j -= 1\r\n\r\nprint(i + j + 2)\r\n", "def solve():\r\n s1 = input()\r\n s2 = input() \r\n kol = 0\r\n while True:\r\n i = len(s1) - kol -1\r\n j = len(s2) - kol -1\r\n if (i >= 0 and j >= 0 and s1[i] == s2[j]):\r\n kol += 1\r\n else:\r\n break\r\n print(len(s1) + len(s2) - 2*kol)\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()\r\n \r\n", "s = input().strip()\r\nt = input().strip()\r\n\r\n# Find the length of the common suffix of the two strings\r\ncommon_suffix_length = 0\r\nn = min(len(s), len(t))\r\nfor i in range(1, n+1):\r\n if s[-i] == t[-i]:\r\n common_suffix_length += 1\r\n else:\r\n break\r\n\r\n# Compute the number of moves required to make the strings equal\r\nnum_moves = len(s) + len(t) - 2*common_suffix_length\r\nprint(num_moves)\r\n", "# Contest: Codeforces - Codeforces Round #496 (Div. 3)\n# URL: https://codeforces.com/contest/1005/problem/B\n# Memory Limit: 256 MB\n# Time Limit: 1000 ms\n\nimport bisect\nfrom sys import stdin\n\ninput = stdin.readline\n\nmod = 10 ** 9 + 7\neps = 10 ** -9\n\n\ndef linp(type=int):\n return list(map(type, input().split()))\n\n\ndef minp(type=int):\n return map(type, input().split())\n\n\ndef tinp(type=int):\n return type(input())\n\n\ndef __gcd(a, b):\n return a if b == 0 else __gcd(b, a % b)\n\n\ndef __lcm(a, b):\n return a * b / __gcd(a, b)\n\n\ndef __fact(n):\n return 1 if n == 1 else n * __fact(n - 1)\n\n\ndef __mex(a):\n mex = 0\n a.sort()\n for x in a:\n if x <= mex:\n mex += 1\n else:\n break\n return mex\n\n\ndef __dist(x1, y1, x2, y2):\n return (x1 - x2) ** 2 + (y1 - y2) ** 2\n\n\ndef __getprimes(n):\n isprime = [True for i in range(n + 1)]\n primes = []\n\n for i in range(2, n + 1):\n if isprime[i]:\n for j in range(i * i, n + 1, i):\n isprime[j] = False\n for i in range(2, n + 1):\n if isprime[i]:\n primes.append(i)\n return primes\n\n\ndef __getdividers(n):\n i = 1\n ret = []\n while i * i <= n:\n if n % i == 0:\n ret.append(i)\n\n if i * i != n:\n ret.append(n // i)\n i += 1\n ret.sort()\n return ret\n\n\ndef __modInverse(a, m):\n\tm0 = m\n\ty = 0\n\tx = 1\n\tif (m == 1):\n\t\treturn 0\n\t\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\ndef __isprime(n):\n if n < 2:\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\n\ndef __cntprimediv(n):\n ret = 0\n x = n\n i = 2\n while i * i <= x:\n while n % i == 0:\n n //= i\n ret += 1\n i += 1\n if n > 1:\n ret += 1\n return ret\n\n\ndef __primefactors(n):\n ret = []\n x = n\n i = 2\n while i * i <= x:\n while n % i == 0:\n ret.append(i)\n n //= i\n i += 1\n if n > 1:\n ret.append(n)\n return ret\n\n\ndef __sumdigit(n):\n ret = 0\n while n > 0:\n ret += n % 10\n n //= 10\n return ret\n\n\ndef __zfunc(s):\n n = len(s)\n z = [0 for i in range(n)]\n l = 0\n r = 0\n for i in range(1, n):\n if r >= i:\n z[i] = min(z[i - l], r - i + 1)\n while z[i] + i < n and s[z[i]] == s[z[i] + i]:\n z[i] += 1\n if i + z[i] - 1 > r:\n l = i\n r = i + z[i] - 1\n return z\n\n\ndef __to(n, x):\n ret = ''\n while n > 0:\n q = n % x\n if q < 10:\n ret += str(q)\n else:\n ret += chr(q - 10 + ord('a'))\n n //= x\n return ret[::-1]\n\n\ndef solve(t):\n\ts = input().strip()[::-1]\n\tq = input().strip()[::-1]\n\t\n\tans = len(s) + len(q)\n\tcnt = 0\n\t\n\tfor i in range(min(len(s), len(q))):\n\t\tif s[i] == q[i]:\n\t\t\tcnt += 2\n\t\telse:\n\t\t\tbreak\n\tprint(ans - cnt)\n\nt = 1\n#t = int(input())\n\nfor i in range(t):\n solve(i + 1)", "\r\ndef backwards(s, p):\r\n\r\n i = len(s) - 1\r\n j = len(p) - 1\r\n\r\n while i >= 0 and j >= 0 and s[i] == p[j]:\r\n i -= 1\r\n j -= 1\r\n\r\n return i + j + 2\r\n\r\n\r\np = input()\r\ns = input()\r\nprint(backwards(s, p))", "s = list(input())\nt = list(input())\n\nwhile s and t and s[-1]==t[-1]:\n s.pop() and t.pop()\nprint(len(s+t))\n\t \t \t \t \t \t \t\t\t\t\t \t", "#delete_from_left\r\ns = input()\r\nt = input()\r\ns_l = len(s)\r\nt_l = len(t)\r\nwhile s_l * t_l * (s[s_l - 1] == t[t_l - 1]):\r\n s_l = s_l - 1\r\n t_l = t_l - 1\r\nprint(s_l + t_l)\r\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\ns = input().rstrip()\r\nt = input().rstrip()\r\n\r\nchk = -1\r\nfor i in range(min(len(s), len(t))):\r\n if s[len(s) - i - 1] != t[len(t) - i - 1]:\r\n chk = i\r\n break\r\n\r\nprint(max(len(s), len(t)) - min(len(s), len(t)) if chk == -1 else len(s) - chk + len(t) - chk)\r\n", "string1 = input()\nstring2 = input()\n\nlen1 = len(string1)\nlen2 = len(string2)\nwhile len1 > 0 and len2 > 0 and string1[len1-1] == string2[len2-1]:\n len1 -= 1\n len2 -= 1\nsum = len1 + len2\nprint(sum)\n \t\t\t \t\t \t \t\t \t \t\t\t\t\t", "a=input()\r\nb=input()\r\nl=min(len(a),len(b))\r\nans=abs(len(a)-len(b))\r\na=a[-l:]\r\nb=b[-l:]\r\n#print(ans,a,b)\r\nfor i in range(len(a)-1,-1,-1):\r\n if(a[i]!=b[i]):\r\n ans+=2*(i+1)\r\n break\r\nprint(ans)\r\n", "x = input()\r\ny = input()\r\na=len(x)\r\nb=len(y)\r\nwhile a and b and x[a-1]==y[b-1]:\r\n a=a-1\r\n b=b-1\r\nprint(a+b)", "s=input()\r\nt=input()\r\nt1=len(t)\r\ns1=len(s)\r\nl=min(t1,s1)\r\nk=t1+s1\r\ni=0\r\nwhile i<l:\r\n if s[s1-i-1]==t[t1-i-1]:\r\n k-=2\r\n else:\r\n break\r\n i+=1\r\nprint(k)", "s = input()\nt = input()\n\nj = len(s)-1\nk = len(t)-1\ncount = 0\n\nwhile(j>=0 and k>=0):\n if s[j]==t[k]:\n count+=1\n j-=1\n k-=1\n else:\n break\n\nprint((len(s)-count)+(len(t)-count))\n", "s = input()[::-1]\nt = input()[::-1]\ni = next((i for i, (si, ti) in enumerate(zip(s, t)) if si != ti), min(len(s), len(t)))\nprint(len(s) + len(t) - 2 * i)\n", "s = input()\nt = input()\n\n# find the longest common suffix\nsuffix_length = 0\nfor i in range(1, min(len(s), len(t))+1):\n if s[-i] == t[-i]:\n suffix_length += 1\n else:\n break\n\n# calculate the minimum number of moves required\nmoves = len(s) + len(t) - 2*suffix_length\nprint(moves)\n\t\t\t\t \t\t\t \t\t\t \t\t \t\t \t \t", "a = input()\r\nb = input()\r\nal = len(a)\r\nbl = len(b)\r\ncount = abs(al-bl)\r\nif al >= bl:\r\n a = a[count::]\r\nelse:\r\n b = b[count::]\r\nfor i in range(len(b)-1, -1, -1):\r\n if b[i] != a[i]:\r\n count += (i + 1) * 2\r\n break\r\nprint(count)", "\n\nstring1 = input()\nstring2 = input()\ncounter = 0\n\nfor i,j in zip(string1[::-1],string2[::-1]):\n if i==j: counter+=2\n else: break\nlength = len(string1)+len(string2)-counter\nprint(length, end='')\n \t \t \t \t \t \t\t \t\t \t\t\t \t \t", "s=input()\r\nt=input()\r\nx=len(s)\r\ny=len(t)\r\nm=max(x,y)\r\nn=min(x,y)\r\nif x==m:\r\n big=s\r\n small=t\r\nelse:\r\n big=t\r\n small=s\r\nif big[-1]!=small[-1]:\r\n print(m+n)\r\nelse:\r\n count=0\r\n for i in range(n):\r\n if big[-count-1]==small[-count-1]:\r\n count=count+1\r\n else:\r\n break\r\n print(m+n-count-count) ", "# -*- coding: utf-8 -*-\n\"\"\"1005B_ DeletefromtheLeftBinu.ipynb\n\nAutomatically generated by Colaboratory.\n\nOriginal file is located at\n https://colab.research.google.com/drive/1_BZYsvz32LWZy_tl48x9Rg96ZdkMorGZ\n\"\"\"\n\n#https://codeforces.com/problemset/problem/1005/B\n\ns=input()\nt=input()\nx=len(s)\ny=len(t)\nwhile x and y and s[x-1]==t[y-1]:\n x=x-1\n y=y-1\nprint(x+y)", "s = input()\nt = input()\n\ns = s[::-1]\nt = t[::-1]\nanswer = []\n\nif len(s) > len(t):\n for i in range(len(t)):\n if t[i] == s[i]:\n answer.append(t[i])\n answer.append(s[i])\n else:\n break\nelse:\n for i in range(len(s)):\n if t[i] == s[i]:\n answer.append(t[i])\n answer.append(s[i])\n else:\n break\n\nstep = len(s) + len(t)\nanswer = len(answer)\n\nprint(step - answer)\n\n# Sun Sep 03 2023 22:53:34 GMT+0300 (Moscow Standard Time)\n", "s = input()[::-1]\r\nt = input()[::-1]\r\n\r\nans = min(len(s), len(t))\r\n\r\nfor i in range(min(len(s), len(t))):\r\n if s[i] == t[i]:\r\n continue\r\n else:\r\n ans = i\r\n break\r\n\r\nprint(len(s) + len(t) - 2 * ans)\r\n", "a=input()\r\nx=len(a)\r\nb=input()\r\ny=len(b)\r\nwhile y!=0 and x!=0 and a[x-1]==b[y-1]:\r\n x=x-1\r\n y=y-1\r\nprint(x+y)", "s = input()\r\nt = input()\r\nols,olt = len(s),len(t)\r\nrang = min(ols,olt)\r\ns=s[::-1]\r\nt=t[::-1]\r\ncount=0\r\nfor i in range(rang):\r\n if s[i]!=t[i]:\r\n break\r\n count+=1\r\nprint(ols+olt-(2*count))", "n=input()\r\nm=input()\r\nc=0\r\nd=min(len(n),len(m))\r\nfor i in range(1,d+1):\r\n if(n[-i]==m[-i]):\r\n c+=1\r\n else:\r\n break\r\nif(c>0):\r\n print(len(n[0:-c])+len(m[0:-c]))\r\nelse:\r\n print(len(m)+len(n))\r\n", "s = input()\r\nt = input()\r\n\r\nidx = -1\r\nwhile -1*idx <= min(len(s), len(t)):\r\n if s[idx] != t[idx]:\r\n break\r\n \r\n idx -= 1\r\n \r\nprint(len(s)+len(t) + 2*(idx+1))\r\n ", "def main():\r\n s = input();s=s[::-1]\r\n y =input();y=y[::-1]\r\n length = len(s) + len(y)\r\n mini_len= min(len(s),len(y))\r\n if s[0]!=y[0]: return length;\r\n count=1\r\n for i in range(1,mini_len):\r\n if s[i]!=y[i]:\r\n return (length -(count*2))\r\n else:\r\n count+=1\r\n \r\n return (length -(count*2))\r\nprint(main())\r\n", "s = input()\r\nt = input()\r\nans = len(s) + len(t)\r\nind = -1\r\nwhile s[ind] == t[ind]:\r\n ans -= 2\r\n ind -= 1\r\n if ind == -(min(len(s), len(t)) + 1):\r\n break\r\nprint(ans)\r\n", "p=input();q=input();r=len(p);s=len(q)\r\nwhile p[r-1]==q[s-1] and r>0 and s>0: r=r-1;s=s-1\r\nprint(r+s)", "a = input()\r\na = a[::-1]\r\nb = input()\r\nb = b[::-1]\r\ncount = 0\r\nfor i in range(min(len(a), len(b))):\r\n if a[i] == b[i]:\r\n count += 1\r\n else:\r\n break\r\nprint(len(a) + len(b) - 2 * count)\r\n", "s= input()\r\nt= input()\r\nl1=len(s)\r\nl2=len(t)\r\ni=-1\r\nfor j in range( min(l1, l2)):\r\n if s[i]== t[i]:\r\n i-=1\r\n continue\r\n else:\r\n break\r\n \r\nprint(l1+l2+i+i+2)", "a=str(input())\r\nb=str(input())\r\na1=len(a)\r\nb1=len(b)\r\nc=0\r\ni=len(a)-1\r\nj=len(b)-1\r\nwhile i>=0 and j>=0:\r\n if(a[i]==b[j]):\r\n c=c+1\r\n else:\r\n break \r\n i=i-1\r\n j=j-1\r\nprint(a1+b1-2*c)", "a = input()\r\nb = input()\r\nc = len(a)+ len(b)\r\nk = min(len(a), len(b))\r\nfor i in range(k):\r\n if a[-(i+1)] == b[-(i+1)]:\r\n \r\n c -= 2\r\n else:\r\n break\r\nprint(c)\r\n\n# Mon Sep 27 2021 22:30:01 GMT+0300 (Москва, стандартное время)\n", "a = input()\r\nb = input()\r\nif len(b) < len(a):\r\n a, b = b, a\r\n\r\na = a[::-1]\r\nb = b[::-1]\r\n\r\nans = 0\r\nfor i in range(len(a)):\r\n if a[i] == b[i]:\r\n ans += 1\r\n else:\r\n break\r\nprint(len(a) - ans + len(b) - ans)", "s = input()\r\nt = input()\r\na = list(s)\r\nb = list(t)\r\na = a[::-1]\r\nb = b[::-1]\r\ni=0\r\nc=[]\r\nwhile (i<len(a) and i<len(b)):\r\n if a[i] == b[i]:\r\n c.append(a[i])\r\n i+=1\r\n elif a[i] != b[i]:\r\n break\r\nprint(len(s)+len(t)-(2*len(c)))", "s1 = input()[::-1]\r\ns2 = input()[::-1]\r\nans = 0\r\nfor i in range(min(len(s1),len(s2))):\r\n if s1[i] != s2[i]:\r\n ans = i\r\n break\r\n ans = i+1\r\nprint(sum([len(s1)-ans,len(s2)-ans]))\r\n\n# Mon Sep 27 2021 14:01:53 GMT+0300 (Москва, стандартное время)\n", "s = input()\r\nt = input()\r\n \r\nn = len(s)\r\nm = len(t)\r\n \r\ni = n - 1\r\nj = m - 1\r\n \r\nwhile i >= 0 and j >= 0 and s[i] == t[j]:\r\n i -= 1\r\n j -= 1\r\n#print(i,j)\r\n#print(\"n and m =\",n,m)\r\nprint(i + j + 2)", "a=list(input())\r\nb=list(input())\r\nwhile a!=[] and b!=[] and a[-1]==b[-1]:\r\n a.pop()\r\n b.pop()\r\nprint(len(a+b))\r\n", "s = input()\r\nt = input()\r\n\r\ns = s[::-1]\r\nt = t[::-1]\r\nsum1 = 0\r\nfor i in range(min(len(s), len(t))):\r\n if t[i] == s[i]:\r\n sum1 += 2\r\n else:\r\n break\r\n\r\nprint(len(s) + len(t) - sum1)", "s = list(input())[::-1]\r\nt = list(input())[::-1]\r\ntmp = 0\r\nfor i in range(min(len(s), len(t))):\r\n if s[i] == t[i]:\r\n tmp += 1\r\n else:\r\n break\r\nprint(len(s) + len(t) - 2 * tmp)\r\n", "one, two = input(), input()\r\ntotal = len(one) + len(two)\r\nsame = 0\r\nr1, r2 = one[::-1], two[::-1]\r\nfor a, b in zip(r1, r2):\r\n if a == b:\r\n same +=1\r\n else:\r\n break \r\nprint(total - 2 * same)", "def f(s, t):\r\n if len(s) > len(t):\r\n s, t = t, s\r\n s = s[::-1]\r\n t = t[::-1]\r\n index = 0\r\n for i in range(len(s)):\r\n if s[i] == t[i]:\r\n index += 1\r\n else:\r\n break\r\n return (len(t) - index) + (len(s) - index)\r\n\r\n\r\n_s = input()\r\n_t = input()\r\nprint(f(_s, _t))\n# Fri Oct 01 2021 01:37:33 GMT+0300 (Москва, стандартное время)\n", "s= input()\r\nt=input()\r\nw=0\r\nwhile True:\r\n i = len(s) - w - 1\r\n j = len(t)-w-1\r\n if i>=0 and j>=0 and t[j]==s[i]:\r\n w += 1\r\n else:\r\n break\r\n\r\nprint(len(s)+len(t)-2*w)", "s1 = input()\r\ns2 = input()\r\nz1 = s1[::-1]\r\nz2 = s2[::-1]\r\nsumm = len(s1)+len(s2)\r\na = max(len(s1),len(s2))\r\ncount = 0\r\nif a == len(s1):\r\n for i in range(len(z2)):\r\n if z1[i]== z2[i]:\r\n count += 1\r\n else:\r\n break\r\n if count >0:\r\n d = abs((count +count)-summ)\r\n print(d)\r\n else:\r\n print(summ)\r\nelse:\r\n for i in range(len(z1)):\r\n if z1[i]== z2[i]:\r\n count += 1\r\n else:\r\n break\r\n if count >0:\r\n d = abs((count +count)-summ)\r\n print(d)\r\n else:\r\n print(summ)\r\n \r\n \r\n", "s=input()\r\nt=input()\r\ni=len(s)-1\r\nj=len(t)-1\r\nwhile i>=0 and j>=0 and s[i]==t[j]:\r\n i-=1\r\n j-=1\r\nprint(i+j+2)", "s = input().strip()\r\nt = input().strip()\r\n\r\n# Find the length of the longest common suffix\r\nn = min(len(s), len(t))\r\ni = 0\r\nwhile i < n and s[-i-1] == t[-i-1]:\r\n i += 1\r\n\r\n# Calculate the fewest number of moves required\r\nmoves = len(s) + len(t) - 2*i\r\nprint(moves)\r\n", "from os import path\r\nimport sys\r\nfrom collections import Counter\r\nfrom math import gcd \r\n#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\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\n\r\ninput = lambda: sys.stdin.readline().rstrip()\r\n\r\ndef tc():\r\n return int(input())\r\n\r\ndef ni():\r\n return int(input())\r\n\r\ndef si():\r\n return str(input())\r\n\r\ndef mii():\r\n return map(int,input().split())\r\n\r\ndef msi():\r\n return map(str,input().split())\r\n\r\ndef lsti():\r\n return list(map(int,input().split()))\r\n\r\ndef lssi():\r\n return list(map(str,input().split()))\r\n\r\ni2c = lambda n: chr(ord('a') + n)\r\nc2i = lambda c: ord(c) - ord('a')\r\n\r\n#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\r\n\r\ns = si()\r\nt = si()\r\n\r\nw = 0\r\n\r\nwhile True:\r\n i = len(s) - w - 1\r\n j = len(t) - w - 1\r\n \r\n if i >= 0 and j >= 0 and s[i] == t[j]:\r\n w += 1\r\n else:\r\n break\r\n\r\nprint(len(s) + len(t) - 2 * w)", "a=input()[::-1]\nb=input()[::-1]\n\nnombre=0\n\nfor x,y in zip(a,b):\n if x==y:\n nombre+=1\n else:\n break\n\nprint(len(a)+len(b)-2*nombre)\n", "s=input()\nt=input()\nn=len(s)\nm=len(t)\ni=-1\nw=0\nwhile s[i]==t[i]:\n\tw+=1\n\tif abs(i)<min(m,n):\n\t\ti-=1\n\telse:\n\t\tbreak\nprint(n+m-2*w)\n\n\n\n\n\t\t\t\n\n\n\n\t\n\t\n\n\n\n\n\n", "s1 = input()\r\ns2 = input()\r\ncount = 0\r\nans = 0\r\n\r\nwhile (True):\r\n x = len(s1)-count-1\r\n y = len(s2) - count - 1\r\n if (x>=0 and y>=0 and s1[x] == s2[y]):\r\n count+=1\r\n else:\r\n ans = len(s1)+len(s2) - 2*count\r\n break\r\n\r\nprint(ans)\r\n\r\n\n# Tue Sep 28 2021 03:12:50 GMT+0300 (Москва, стандартное время)\n", "s = input()[::-1]\r\nt = input()[::-1]\r\nmoves= len(s) + len(t)\r\n\r\nfor n in range(min(len(s), len(t))):\r\n \r\n if s[n] != t[n]:\r\n break\r\n else:\r\n moves -= 2\r\n\r\nprint(moves)", "s1 = input()\r\ns2 = input()\r\nk = 0\r\ns1, s2 = s1[::-1],s2[::-1]\r\nfor i in range(min(len(s1),len(s2))):\r\n if s1[i]==s2[i]:\r\n k+=1\r\n else:\r\n break\r\nprint(len(s1)+len(s2)-2*k)", "a = input()\r\nb = input()\r\nc = len(a)\r\nd = len(b)\r\nwhile a[c - 1] == b[d - 1] and c > 0 and d > 0:\r\n c -= 1\r\n d -= 1\r\nprint(c + d)", "def solve():\r\n a = input()\r\n b = input()\r\n count = 0\r\n i = len(a) - 1\r\n j = len(b) - 1\r\n while i>=0 and j>=0:\r\n if a[i]!=b[j]:\r\n break\r\n count+=1\r\n i-=1\r\n j-=1\r\n\r\n if count == 0:\r\n print(len(a) + len(b))\r\n else:\r\n print(len(a)-count + len(b) - count)\r\n# t = int(input())\r\n# for _ in range(t):\r\n# solve()\r\nsolve()\r\n", "def lef(a,b):\r\n i =1\r\n c = min(a,b)\r\n d = a+b\r\n while i<= c:\r\n if sa[a-i]==sb[b-i]:\r\n d -= 2\r\n else:\r\n break\r\n i += 1\r\n print(d)\r\n \r\nsa = input()\r\nsb = input()\r\nlef(len(sa),len(sb))", "s=input()\r\nt=input()\r\nm=min(len(s),len(t))\r\nx=''\r\nfor i in range(-1,(m*(-1))-1,-1):\r\n if s[i]==t[i]:\r\n x+=s[i]\r\n else:\r\n break\r\nans=(len(s)+len(t)) - (len(x)*2)\r\nprint(ans)", "s = input()\r\nt = input()\r\nls = len(s)\r\nlt = len(t)\r\ni = ls - 1\r\nj = lt - 1\r\nwhile(i >= 0 and j >= 0 and s[i] == t[j]):\r\n i -= 1\r\n j -= 1 \r\nprint(i + j + 2)\r\n \r\n \r\n \r\n", "import math, heapq\r\nfrom sys import stdin\t\r\nfrom collections import Counter, defaultdict, deque, namedtuple\r\nfrom bisect import bisect_right, bisect_left\r\nfrom typing import List, DefaultDict\r\nfrom itertools import permutations\r\nfrom copy import deepcopy\r\n\r\n \r\ndef sieve_of_eratosthenes(n):\r\n is_prime = [True] * (n+1)\r\n is_prime[0] = is_prime[1] = False\r\n for p in range(2, int(n**0.5)+1):\r\n if is_prime[p]:\r\n for i in range(p*p, n+1, p):\r\n is_prime[i] = False\r\n \r\n for i in range(2, n+1):\r\n if is_prime[i]:\r\n print(i, end=' ')\r\n\r\n\r\ndef isPowerOf2(n):\r\n\r\n def log2(x):\r\n\r\n if x == 0:\r\n return False\r\n\r\n return (math.log10(x)/math.log10(2))\r\n\r\n\r\n return math.ceil(log2(n)) == math.floor(log2(n))\r\n\r\n \r\ndef readarray(typ):\r\n return list(map(typ, stdin.readline().split()))\r\n\r\n\r\ndef readint():\r\n return int(input())\r\n\r\n\r\ns = list(input())\r\nt = list(input())\r\n\r\n\r\n\r\nwhile s and t:\r\n\r\n if s[-1] == t[-1]:\r\n s.pop()\r\n t.pop()\r\n else:\r\n break\r\n\r\n\r\nprint(len(s) + len(t))\r\n", "s=input()\nt=input()\nif len(s)<len(t):\n w=s\nelse:\n w=t\nn=0\ni=-1\nwhile i>=-len(w):\n if s[i]==t[i]:\n n+=1\n i-=1\n else:\n break\nres=len(s)+len(t)-2*n\nprint(res)\n\n \t\t \t\t\t \t \t \t\t\t\t \t\t\t \t\t \t\t\t", "string1 = input()\nstring2 = input()\ns1 = len(string1)-1\ns2 = len(string2)-1\nans = 0\nwhile s1 >= 0 and s2 >= 0:\n if string1[s1] == string2[s2]:\n ans+=2\n else:\n break\n s1-=1\n s2-=1\n\nprint((len(string1)+len(string2)-ans))", "s1 = input(); s2 = input()\r\ni, j = len(s1)-1, len(s2)-1\r\nwhile((i != -1) and (j != -1) and (s1[i] == s2[j])): i-=1;j-=1\r\nprint(i+j+2)\r\n", "s1 = input()\ns2 = input()\ns1 = s1[::-1]\ns2 = s2[::-1]\ncnt = 0\nfor i in range(0, min(len(s1), len(s2))):\n if s1[i] == s2[i]:\n cnt += 1\n else:\n break\nprint(len(s1) + len(s2) - cnt * 2)\n", "a = input()\r\nb = input()\r\ndele = 0\r\nwhile len(a) != len(b):\r\n if len(a) > len(b):\r\n a = a[1:]\r\n else:\r\n b = b[1:]\r\n dele += 1\r\nx = len(a) - 1\r\nsame = 0\r\nwhile x >= 0 and a[x] == b[x]:\r\n same += 1\r\n x -= 1\r\ndele += (len(a) - same) * 2\r\nprint(dele)", "s=input()\r\nt=input()\r\nx=len(s)\r\ny=len(t)\r\nwhile x and y and s[x-1]==t[y-1]:\r\n x=x-1\r\n y=y-1\r\nprint(x+y)", "s1=input()\r\ns2=input()\r\nl1=len(s1)\r\nl2=len(s2)\r\n\r\n\r\nc1=s1[l1-1]\r\nc2=s2[l2-1]\r\nwhile l1>0 and l2>0:\r\n if s1[l1-1]==s2[l2-1]:\r\n l1-=1\r\n l2-=1\r\n else:\r\n break\r\nprint(l1+l2)", "\r\ns1 = input()\r\ns2 = input()\r\n\r\nm = len(s1)\r\nn = len(s2)\r\nm -= 1\r\nn -= 1\r\n\r\nc = 0\r\nwhile m >= 0 and n >= 0:\r\n if s1[m] == s2[n]:\r\n c += 1\r\n m -= 1\r\n n -= 1\r\n else:\r\n break \r\n\r\nif c == 0:\r\n print(len(s1) + len(s2))\r\nelse:\r\n print((len(s1) - c) + (len(s2) - c)) ", "s,t=input(),input()\r\nm = len(s)\r\nn = len(t)\r\nwhile m != 0 and n != 0 and s[m-1]==t[n-1]:\r\n m-=1\r\n n-=1\r\nprint(m+n)", "from sys import stdin ,stdout \r\ninput=stdin.readline \r\ninp = lambda : map(int,input().split())\r\ndef print(*args, end='\\n', sep=' ') -> None: \r\n stdout.write(sep.join(map(str, args)) + end) \r\n\r\n\r\ns1 = input().strip() \r\ns2 = input().strip() \r\ni = len(s1) -1 ; j = len(s2) -1 \r\nwhile(i >-1 and j >-1) :\r\n if (s1[i] != s2[j]) : break\r\n i-=1 ; j-= 1 \r\n\r\nprint(i+1 + j+1 )\r\n \r\n", "string1, string2 = input(), input()\r\n\r\n# Find the lengths of both strings\r\nlen1 = len(string1)\r\nlen2 = len(string2)\r\n\r\n# Initialize variables\r\nans = 0\r\ni = 1\r\n\r\n# Iterate from the end of the strings and find the common suffix\r\nwhile i <= min(len1, len2) and string1[-i] == string2[-i]:\r\n ans = i\r\n i += 1\r\n\r\n# Calculate the result\r\nresult = len1 + len2 - 2 * ans\r\nprint(result)\r\n", "x= input()\r\ny= input()\r\ni= len(x)\r\nj= len(y)\r\n\r\nwhile i > 0 and j > 0:\r\n\tif x[i-1] != y[j-1]:\r\n\t\tbreak\r\n\ti -= 1\r\n\tj -= 1\r\n \r\nprint(i + j)", "word1 = input()\nword2 = input()\n\nlen_word1 = len(word1)\nlen_word2 = len(word2)\n\ncnt = 0\n\nfor i in range(1, min(len_word1, len_word2) + 1):\n if word1[len_word1 - i] == word2[len_word2 - i]:\n cnt += 2\n else:\n break\n\nprint(len_word1 + len_word2 - cnt)\n\n# Tue Sep 05 2023 23:49:12 GMT+0300 (Moscow Standard Time)\n", "s = input()\r\nt = input()\r\nsl=len(s)\r\ntl=len(t)\r\nwhile sl and tl and s[sl-1]==t[tl-1]:\r\n sl-=1\r\n tl-=1\r\nprint(sl+tl)", "s,t=input(),input()\r\ni,j=len(s),len(t)\r\nwhile i*j*(s[i-1]==t[j-1]):\r\n i-=1;j-=1\r\nprint(i+j)", "import math\r\nfrom sys import stdin, stdout\r\ninput, print = stdin.readline, stdout.write\r\n\r\n\r\ndef str_input():\r\n s = input()\r\n return s[:len(s)-1]\r\n\r\n\r\ndef char_list_input():\r\n s = input()\r\n return list(s[:len(s)-1])\r\n\r\n\r\ndef list_input(type):\r\n return list(map(type, input().split()))\r\n\r\n\r\ndef multi_input():\r\n return map(int, input().split())\r\n\r\n\r\ndef main():\r\n a = str_input()\r\n b = str_input()\r\n n = len(a)\r\n m = len(b)\r\n ans = max(n, m)-min(n, m)\r\n for i in range(1, min(n, m)+1):\r\n if a[-i] != b[-i]:\r\n ans = n+m-2*(i-1)\r\n break\r\n print(f\"{ans}\\n\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "s = input()\r\nt = input()\r\ns, t = s[::-1], t[::-1]\r\nans = len(s) + len(t)\r\nfor i in range(min(len(s), len(t))):\r\n if s[i] == t[i]:\r\n ans -= 2\r\n else:\r\n break\r\nprint(ans)\r\n", "s=list(input())\r\nt=list(input())\r\nw=0\r\nf=-1\r\nx=s[f]\r\ny=t[f]\r\nwhile x==y:\r\n\tw+=1\r\n\tf-=1\r\n\tif -f>len(s) or -f>len(t): break\r\n\tx=s[f]\r\n\ty=t[f]\r\nprint((len(s)+len(t))-2*w)", "s = input()\r\nt = input()\r\ncount = 0\r\nm = min(len(s), len(t))\r\nj = len(s) - 1\r\nk = len(t) - 1\r\nwhile(m != 0):\r\n if s[j] == t[k]:\r\n count += 1\r\n k -= 1\r\n j -= 1\r\n else:\r\n break\r\n m = m-1\r\nprint((len(s)-count) + (len(t)-count))", "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\nimport math \r\nfrom math import gcd,floor,sqrt,log,ceil,inf\r\nfrom collections import *\r\nfrom collections import deque as deq\r\nfrom collections import Counter as cnt\r\nfrom bisect import bisect_left as bl\r\nfrom bisect import bisect_right as br\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 str(input())\r\ndef strip(): return list(sys.stdin.readline().strip())\r\ndef pr(n): return sys.stdout.write(str(n)+\"\\n\")\r\ndef prl(n): return sys.stdout.write(str(n)+\" \")\r\ndef prlist(a): print(\"\".join(a))\r\nmod = 1000000007\r\nmaximum, minimum = float('inf'), float('-inf')\r\nbi=lambda n: bin(n).replace(\"0b\", \"\") \r\nyes=lambda : print(\"YES\") ; no=lambda : print(\"NO\")\r\n\r\nimport operator as op\r\nfrom functools import reduce\r\n\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\n \r\ndef fact(n):\r\n\treturn math.factorial(n)\r\n\t\r\ndef perfect(n):\r\n\treturn floor(sqrt(n))==ceil(sqrt(n))\r\ndef lcm(a, b):\r\n return a * b // gcd(a, b)\r\n \r\ndef binarySearch(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\n \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\t\r\ndef expo(a, n, M):\r\n ans = 1\r\n while(n > 0):\r\n last_bit = n&1\r\n if(last_bit):\r\n ans = (ans*a)%M\r\n a = (a*a)%M\r\n n = n >> 1\r\n return ans\r\n \r\ndef solve():\r\n s,f=input(),input()\r\n s,f,x=s[::-1],f[::-1],0\r\n for i in range(len(s)):\r\n if i<len(f) and s[i]==f[i]:\r\n x+=2\r\n else:\r\n break\r\n ans=len(s)+len(f)-x\r\n pr(ans)\r\n \r\nfor pratyush in range(1):\r\n\tsolve()", "string1 = list(input())\r\nstring2 = list(input())\r\n\r\nlen1 = len(string1)\r\nlen2 = len(string2)\r\n\r\nindex1 = len1 - 1\r\nindex2 = len2 - 1\r\n\r\ncount = 0\r\nwhile index1 >= 0 and index2 >= 0 and string1[index1] == string2[index2]:\r\n count += 1\r\n index1 -= 1\r\n index2 -= 1\r\n\r\nprint(len1 + len2 - count*2)", "s = input()\r\nt = input()\r\nm = min(len(s), len(t))\r\ni = 1\r\nwhile i <= m:\r\n if s[-i] != t[-i]:\r\n break\r\n i += 1\r\nprint(len(s) - i + len(t) - i + 2)", "def get():\r\n return list(map(int, input().split()))\r\ndef intput():\r\n return int(input())\r\ndef digit(s):\r\n return sum(list(map(int, list(str(s))))) %2 ==0 and s % 2 !=0\r\ndef main():\r\n\r\n #for _ in range(intput()):\r\n s=input()\r\n t=input()\r\n r=len(s)-1\r\n l=len(t)-1\r\n ans=0\r\n while r>-1 and l>-1 and s[r]==t[l]:\r\n ans+=1\r\n r-=1\r\n l-=1\r\n print(len(s)+len(t)-ans*2)\r\n\r\n\r\n\r\nmain()", "n1 = input()\r\nn2 = input()\r\npostfix = \"\"\r\ndiff = max(len(n1), len(n2)) - min(len(n1), len(n2))\r\nif len(n1) > len(n2):\r\n flag = True\r\nelse:\r\n flag = False\r\ncount = 0\r\nfor i in range(min(len(n1), len(n2)) - 1, -1, -1):\r\n if flag == True:\r\n if n1[i + diff] != n2[i]:\r\n break\r\n else:\r\n if n2[i + diff] != n1[i]:\r\n break\r\n count += 1\r\nprint(len(n1) + len(n2) - 2 * count)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "s = input()\r\nn = len(s)\r\nt = input()\r\nm = len(t)\r\nx = min(n,m)\r\ncount = 0\r\nfor i in range(x):\r\n if s[n-i-1] == t[m-i-1]:\r\n count += 1\r\n else :\r\n break\r\nprint( (n-count) + (m - count) )", "s = input()\r\nt = input()\r\ns_ = s[:: - 1]\r\nt_ = t[:: - 1]\r\nc = 0\r\nfor i in range(min(len(s_), len(t_))):\r\n if s_[i] != t_[i]:\r\n print(len(s_) + len(t_) - i - i)\r\n break\r\nelse:\r\n if len(s) > len(t):\r\n c = len(s) - len(t)\r\n s = s[len(s) - len(t):]\r\n elif len(s) < len(t):\r\n c = len(t) - len(s)\r\n t = t[len(t) - len(s):]\r\n def f(s, t):\r\n global c\r\n if s == t:\r\n return c\r\n else:\r\n c += 2\r\n return f(s[1:], t[1:])\r\n print(f(s, t))", "s=list(input())\r\nt=list(input())\r\n\r\ns.reverse()\r\nt.reverse()\r\n\r\na=min(len(s),len(t))\r\nb=-1\r\n\r\nfor j in range(a):\r\n if(s[j]!=t[j]):\r\n break \r\n b=j \r\nb+=1 \r\nprint(len(s)+len(t)-2*b)", "first = input()\r\nsec = input()\r\n\r\nif first == sec:\r\n print(0)\r\n quit()\r\n\r\nif len(first) == 1 and len(sec) == 1:\r\n print(2)\r\n quit()\r\n\r\nif len(first) == 1 or len(sec) == 1:\r\n if first[-1] == sec[-1]:\r\n print(abs(len(first) - len(sec)))\r\n else:\r\n print(len(first) + len(sec))\r\n quit()\r\n\r\nlst = []\r\nfor a in range(1, min(len(first), len(sec)) + 1):\r\n if first[-a] == sec[-a]:\r\n lst.append(sec[-a])\r\n else:\r\n break\r\n\r\nprint(len(first) - len(lst) + len(sec) - len(lst))\r\n", "a = input()\r\nb = input()\r\ncnt_a = len(a)\r\ncnt_b = len(b)\r\nwhile cnt_a * cnt_b * (a[cnt_a - 1] == b[cnt_b - 1]):\r\n cnt_a -= 1\r\n cnt_b -= 1\r\nprint(cnt_a + cnt_b)", "import sys, io, os\r\nimport math\r\nimport bisect\r\nimport heapq\r\nimport string\r\nfrom collections import defaultdict,Counter,deque\r\ninput = sys.stdin.readline\r\n\r\ndef I():\r\n return input()\r\n \r\ndef II():\r\n return int(input())\r\n \r\ndef MII():\r\n return map(int, input().split())\r\n \r\ndef LI():\r\n return list(input().split())\r\n \r\ndef LII():\r\n return list(map(int, input().split()))\r\n \r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n \r\ndef LGMI():\r\n return list(map(lambda x: int(x) - 1, input().split()))\r\n \r\ndef WRITE(out):\r\n return print('\\n'.join(map(str, out)))\r\n \r\ndef WS(out):\r\n return print(' '.join(map(str, out)))\r\n \r\ndef WNS(out):\r\n return print(''.join(map(str, out)))\r\n\r\n'''\r\nIgnore duplicate groups 'a...a'/'b...b'\r\nIf num groups is odd, AB already equals BA\r\nelse if even we need to minimize the steps\r\n -Minimize by choosing the smallest group of a..a/b..b\r\n and inverting the values\r\n\r\nn%4 = 1\r\nn%4 = 3\r\n\r\n11\r\n13\r\n\r\n11 = 3,7,1\r\n13 = 5,7,1\r\n\r\n7/11 14/22'\r\nMissing size requirement\r\n'''\r\ndef solve():\r\n a = I().strip()[::-1]\r\n b = I().strip()[::-1]\r\n\r\n l = 0\r\n for i in range(min(len(a), len(b))):\r\n if a[i] != b[i]:\r\n break\r\n l = i+1\r\n print(len(a) + len(b) - 2*l)\r\n\r\nsolve()", "s,t=input(),input()\ni,j=len(s),len(t)\nwhile i*j*(s[i-1]==t[j-1]):\n i-=1;j-=1\nprint(i+j)\n\n \t \t\t \t \t \t\t \t \t\t\t \t\t \t \t", "import sys;sc = sys.stdin.readline;out=sys.stdout.write\r\ns=str(sc());ss=str(sc());o=len(s);oo=len(ss)\r\na=o-1;aa=oo-1;m=0\r\nfor e in range(min(o,oo)):\r\n if s[a]!=ss[aa]:break\r\n m+=2;a-=1;aa-=1\r\nout(str((o+oo)-m))", "a,b=input(),input()\r\ni,j=len(a),len(b)\r\nwhile i*j*(a[i-1]==b[j-1]):\r\n i-=1;j-=1\r\nprint(i+j)", "s = input()\r\nt = input()\r\ni, j = len(s) - 1, len(t) - 1\r\nwhile i >= 0 and j >= 0:\r\n if s[i] != t[j]:\r\n break\r\n i -= 1\r\n j -= 1\r\nprint(i + j + 2)", "s=list(input())\r\nt=list(input())\r\ns=s[::-1]\r\nt=t[::-1]\r\nn=0\r\nfor i in range(min(len(s),len(t))):\r\n if s[i]==t[i]:\r\n n+=2\r\n else:\r\n break\r\nprint(len(s)+len(t)-n) ", "s, t = input()[::-1], input()[::-1]\nn, m, i = len(s), len(t), 0\nwhile i < min(n, m):\n if s[i] != t[i]:\n break\n i += 1\nres = m - i + n - i\nprint(res)\n", "a=input()\r\nb=input()\r\nn=len(a)\r\nm=len(b)\r\nsum=n+m\r\nfor i in range (0,min(n,m)):\r\n if(a[n-i-1]== b[m-i-1]):\r\n sum=sum-2\r\n else:\r\n break\r\n\r\nprint (sum)", "\n# Version 20.0\nimport os, sys, math, itertools\nfrom collections import deque, defaultdict, OrderedDict, Counter\nfrom bisect import bisect, bisect_left, bisect_right, insort\nfrom heapq import heapify, heappush, heappop, nsmallest, nlargest, heapreplace, heappushpop\n\nii = lambda : int(input())\nsi = lambda : input() \nmi = lambda : map(int,input().strip().split(\" \"))\nmsi = lambda : map(str,input().strip().split(\" \")) \nli = lambda : list(mi())\nlsi = lambda : list(msi())\nout = []\nexport = lambda : print('\\n'.join(map(str, out)), end='')\np = lambda x : out.append(x)\npp = lambda array : p(' '.join(map(str,array)))\n\noffline = True\n\nL = lambda string : hq.L(string) if offline == True else False\nLT = lambda tc, custom, string : hq.LT(tc, custom, string) if offline == True else False\n\ndef main() -> None:\n # 2023-10-06 19:39:14\n\n s1 = si()[::-1]\n s2 = si()[::-1]\n\n idx = 0\n for i,j in itertools.zip_longest(s1,s2):\n if i==j:\n idx+=1\n else:\n break\n p(len(s1)-idx+len(s2)-idx)\n\n\ntry: exec('from hq import *\\nexec(cc)')\nexcept (FileNotFoundError, ModuleNotFoundError): offline >> 1; main(); export()\n\t \t\t\t \t\t\t\t \t\t \t\t\t\t \t\t \t \t", "a, b = input(), input()\r\n\r\n\r\nrez = 0\r\nk = 1\r\nwhile k <= len(a) and k <= len(b):\r\n # if a == b:\r\n # print(0)\r\n # break\r\n if a[-k] == b[-k]:\r\n rez += 1\r\n else:\r\n\r\n break\r\n k += 1\r\nprint(len(a) + len(b) - 2 * rez)\r\n", "# LUOGU_RID: 133290732\nfrom collections import *\r\nx=deque(input())\r\ny=deque(input())\r\nwhile x[-1]==y[-1]:\r\n x.pop()\r\n y.pop()\r\n if len(x)==0 or len(y)==0:\r\n break\r\nc=len(x)+len(y)\r\nprint(c)", "s=input()\r\nt=input()\r\nc=0\r\ns1=len(s)-1\r\nt1=len(t)-1\r\nwhile(s1>=0 and t1>=0):\r\n if(s[s1]!=t[t1]):\r\n break\r\n c+=1\r\n s1-=1\r\n t1-=1 \r\nprint(len(s)+len(t)-2*c)", "s = input()\nt = input()\nsl, tl = len(s) - 1, len(t) - 1\nmatch = 0\nwhile sl >= 0 and tl >= 0:\n\tif s[sl] == t[tl]: match += 2\n\telse: break\n\tsl -= 1\n\ttl -= 1 \nprint(len(s) + len(t) - match)\n \t\t \t \t \t\t\t\t\t \t\t\t\t\t\t \t\t \t", "s = input()\r\nt = input()\r\nif s[-1] != t[-1]:\r\n print(len(s) + len(t))\r\nelse:\r\n a = 0\r\n s = s[::-1]\r\n t = t[::-1]\r\n for i in range(min(len(s),len(t))):\r\n if s[i] == t[i]:\r\n a += 1\r\n else:\r\n break\r\n print(len(s) + len(t) - 2 * a)\r\n\r\n\n# Mon Sep 27 2021 21:32:27 GMT+0300 (Москва, стандартное время)\n", "s=str(input())\r\nt=str(input())\r\na=len(s)\r\nb=len(t)\r\np=0\r\nfor i in range(1,min(a,b)+1):\r\n if(s[-i]==t[-i]):\r\n p+=1\r\n else:\r\n break\r\nprint(a+b-2*p)\r\n", "s1 = input()\ns2 = input()\n\ntamS1 = len(s1)-1\ntamS2 = len(s2)-1\n\nc = 0\nwhile tamS1 >= 0 and tamS2 >= 0:\n if s1[tamS1] == s2[tamS2]:\n c += 2\n else:\n break\n tamS1 -= 1\n tamS2 -= 1\n\nprint( (len(s1) + len(s2) - c) )\n\n \t\t \t \t \t\t \t\t \t \t \t \t\t \t", "# Wadea #\r\n\r\na = list(input())\r\nb = list(input())\r\nl = -1\r\nc = 0\r\nq = 0\r\nwhile True:\r\n if a[l] == b[l]:\r\n c += 1\r\n l -= 1\r\n q += 1\r\n if q < len(a) and q < len(b):\r\n pass\r\n else:\r\n break\r\n else:\r\n break\r\nprint(len(a)-c+len(b)-c)\r\n \r\n", "s = input()\r\nt = input()\r\nl1 = list(s)\r\nl2 = list(t)\r\nl1 = l1[::-1]\r\nl2 = l2[::-1]\r\ni=0\r\nl3=[]\r\nwhile (i<len(l1) and i<len(l2)):\r\n if l1[i] == l2[i]:\r\n l3.append(l1[i])\r\n i+=1\r\n elif l1[i] != l2[i]:\r\n break\r\nprint(len(s)+len(t)-(2*len(l3)))", "if __name__ == \"__main__\":\r\n\r\n\tstring1 = input()\r\n\tstring2 = input()\r\n\tc,ans = 0,0\r\n\r\n\tfor i,j in zip(string2[::-1],string1[::-1]):\r\n\t\tif i!=j:\r\n\t\t\tbreak\r\n\t\telse:\r\n\t\t\tc+=1\r\n\tans = (len(string1)-c)+(len(string2)-c)\r\n\r\n\tprint(ans)", "a = list(input())\nb = list(input())\na = a[::-1]\nb = b[::-1]\nif ' ' in a:\n a.remove(' ')\nif ' ' in b:\n b.remove(' ')\nx = len(a)\ny = len(b)\n\nif x >= y:\n n = y\nelse:\n n = x\ncount = 0\nfor i in range(n):\n if a[i] == b[i]:\n count += 1\n else:\n break\n\nnum = (x + y) - (2 * count)\n\nprint(num)\n\n \t \t \t \t\t \t \t\t\t\t \t\t \t \t \t", "sList =list(input())\r\ntList = list(input())\r\ni=0\r\nwhile i<len(sList) and i<len(tList):\r\n if sList[len(sList)-i-1]==tList[len(tList)-i-1]:\r\n i+=1\r\n else:\r\n break\r\nprint(len(sList)+len(tList)-(2*i))", "# In this way we writting the program\n# after planning the code :)\n\n'''\nstring1 = input()\nstring2 = input()\n\ncounter = 0\ni = -1\n\nwhile True:\n try:\n if string1[i] == string2[i]:\n counter += 1\n except IndexError:\n break\n i -= 1\n\nprint( len(string1) + len(string2)- (2*counter) )\n'''\ns = input()\nt = input()\nsl=len(s)\ntl=len(t)\nwhile sl and tl and s[sl-1]==t[tl-1]:\n sl-=1\n tl-=1\nprint(sl+tl)\n\n\n\n\n\n", "import sys\r\nfin = sys.stdin\r\ns = fin.readline().rstrip()[::-1]\r\nt = fin.readline().rstrip()[::-1]\r\ni = 0\r\nm = min(len(s), len(t))\r\nfor i in range(m):\r\n if s[i] != t[i]:\r\n break\r\nelse:\r\n i = m\r\nprint(len(s)+len(t)-2*i)", "a, b = input(), input()\r\npa, pb = len(a) - 1, len(b) - 1\r\nwhile pa > -1 and pb > -1 and a[pa] == b[pb]: pa, pb = pa - 1, pb - 1\r\nprint(pa + pb + 2)", "import sys\r\ninput = sys.stdin.readline\r\n\r\ndef main():\r\n S = input()\r\n T = input()\r\n ls = len(S)\r\n lt = len(T)\r\n S = S[::-1]\r\n T = T[::-1]\r\n for i in range(min(ls, lt)):\r\n if S[i] != T[i]:\r\n break\r\n else:\r\n i += 1\r\n print(ls + lt - i * 2)\r\n \r\nfor _ in range(1):\r\n main()", "a = input()\r\nb = input()\r\nc = len(a)\r\nd = len(b)\r\nwhile c * d * (a[c - 1] == b[d - 1]):\r\n c = c - 1\r\n d = d - 1\r\nprint(c + d)\r\n", "a = input()\r\nb = input()\r\nn = 0\r\na1 = len(a)\r\nb1 = len(b)\r\nwhile a1 != 0 and b1 != 0 and a[a1-1] == b[b1-1]:\r\n a1 -= 1\r\n b1 -= 1\r\nprint(a1 + b1)\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\n# Sat Oct 02 2021 13:15:45 GMT+0300 (Москва, стандартное время)\n", "from collections import *\r\nfrom heapq import *\r\nfrom bisect import *\r\nfrom itertools import *\r\nfrom functools import *\r\nfrom math import *\r\nfrom string import *\r\nimport operator\r\nimport sys\r\n\r\ninput = sys.stdin.readline\r\n\r\ndef solve():\r\n a = input().strip()\r\n b = input().strip()\r\n\r\n def lcs(a, b):\r\n ans = 0\r\n i = len(a) - 1\r\n j = len(b) - 1\r\n while i >= 0 and j >= 0 and a[i] == b[j]:\r\n ans += 1\r\n i, j = i - 1, j - 1\r\n return ans\r\n\r\n print(len(a) + len(b) - 2 * lcs(a, b))\r\n\r\n\r\ndef main():\r\n tests = 1\r\n for _ in range(tests):\r\n solve()\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()", "x = input()\r\ny = input()\r\nz = len(x)+len(y)\r\ns = min(len(x),len(y))\r\ncount = 0\r\nfor i in range(s):\r\n if x[len(x)-i-1] == y[len(y)-i-1]:\r\n count += 2\r\n else:\r\n break\r\nprint(z-count)", "s1 = input()\r\ns2 = input()\r\n\r\ni = len(s1)-1\r\nj = len(s2)-1\r\n\r\nwhile s1[i]==s2[j] and i>=0 and j>=0:\r\n i-=1\r\n j-=1\r\n\r\nprint(i+j+2)", "s,t=input(),input()\r\ni,j=len(s),len(t)\r\nwhile i and j and s[i-1]==t[j-1]:i-=1;j-=1\r\nprint(i+j)", "s = input()\r\nt = input()\r\n\r\nn = len(s)\r\nm = len(t)\r\n\r\n# start from the end of the strings and count the number of characters\r\n# that are equal\r\ni = n-1\r\nj = m-1\r\ncount = 0\r\nwhile i >= 0 and j >= 0 and s[i] == t[j]:\r\n i -= 1\r\n j -= 1\r\n count += 1\r\n\r\n# the minimum number of moves is the sum of the lengths of the strings\r\n# minus twice the number of common characters\r\nmoves = n + m - 2 * count\r\nprint(moves)\r\n", "s1,s2=input(),input()\r\nl1,l2=len(s1),len(s2)\r\nwhile(l1>0 and l2>0):\r\n l1-=1;l2-=1\r\n if s1[l1]!=s2[l2]:\r\n l1+=1;l2+=1\r\n break\r\nprint(l1+l2)", "a = input()\nb = input()\nlista = [i for i in a]\nlistb = [i for i in b]\nfor i in range(min(len(a),len(b))):\n if lista[-1]==listb[-1]:\n lista.pop()\n listb.pop()\n else:\n break\nprint(len(lista)+len(listb))\n\t\t \t\t \t\t \t\t\t\t \t\t\t \t \t", "s1 = input()\ns2 = input()\n\ns1 = s1[::-1]\ns2 = s2[::-1]\n\ncount = 0\n\nif len(s1) >= len(s2):\n for i in range(0, len(s2)):\n if s1[i] == s2[i]:\n count += 1\n else:\n break\nelse:\n for i in range(0, len(s1)):\n if s1[i] == s2[i]:\n count += 1\n else:\n break\n\n\nprint(len(s1) + len(s2) - count * 2)\n\n# Tue Sep 05 2023 19:38:39 GMT+0300 (Moscow Standard Time)\n", "s = input()\r\nt = input()\r\nsl, tl = len(s) - 1, len(t) - 1\r\nmatch = 0\r\nwhile sl >= 0 and tl >= 0:\r\n\tif s[sl] == t[tl]: match += 2\r\n\telse: break\r\n\tsl -= 1\r\n\ttl -= 1 \r\nprint(len(s) + len(t) - match)\r\n \t\t \t \t \t", "word_1 = input()[::-1]\nword_2 = input()[::-1]\n\nlen_word_1 = len(word_1)\nlen_word_2 = len(word_2)\nmin_len = min(len_word_1, len_word_2)\nc_true = 0\n\n\nfor i in range(min_len):\n a, b = word_1[i], word_2[i]\n if a != b:\n break\n else:\n c_true += 2\n\nif word_1 == word_2:\n print(0)\nelse:\n res = (len_word_1 + len_word_2) - c_true\n print(res)\n \n# Wed Sep 06 2023 21:58:57 GMT+0300 (Moscow Standard Time)\n", "s = input()\nt = input()\nmoves = 0\nwhile(True):\n u = len(s) -1 - moves\n v = len(t) -1 - moves\n if(u >= 0 and v >= 0 and s[u] == t[v]):\n moves += 1\n else:\n break\nprint(len(s)+len(t) -2 * moves)\n\t \t \t \t \t \t", "s=input()\r\nt=input()\r\nq=0\r\n \r\n \r\ni1=len(t)-1\r\ni2=len(s)-1\r\n \r\nwhile i1>=0 and i2>=0:\r\n if s[i2]==t[i1]:\r\n q+=1\r\n i1-=1\r\n i2-=1\r\n \r\n else:\r\n break\r\n \r\n \r\nsu1=len(s)-q\r\nsu2=len(t)-q\r\nprint(su1+su2)", "s = input()\nt=input()\ncnt=0\n\ns_l = len(s)-1\nt_l = len(t)-1\n\nif s_l>t_l :\n lenc=len(t)\nelse:\n lenc=len(s)\n\n\nfor x in range(lenc):\n if s[s_l]==t[t_l]:\n \n cnt+=1\n if s[s_l]!=t[t_l]:\n \n break\n s_l-=1\n t_l-=1\n\nprint(len(s)+len(t)-2*cnt)\n", "from sys import stdin\r\n\r\nm1 = stdin.readline().strip()[::-1]\r\nm2 = stdin.readline().strip()[::-1]\r\n\r\nl1 = len(m1)\r\nl2 = len(m2)\r\nmini = min(l1, l2)\r\n\r\nif m1 == m2:\r\n print(0)\r\nelse:\r\n # recherche du nbre de caractères identiques qui se suivent\r\n idem = 0\r\n for loop in range(mini):\r\n if m1[loop] == m2[loop]:\r\n idem += 1\r\n else:\r\n break\r\n reponse = l1 + l2 - (2 * idem)\r\n print(reponse)\r\n\r\n", "s_1 = str(input())\r\ns_2 = str(input())\r\nk = 0\r\nwhile True:\r\n a = len(s_1) - k - 1\r\n b = len(s_2) - k - 1\r\n if a >= 0 and b >= 0 and s_1[a] == s_2[b]:\r\n k += 1\r\n else:\r\n break\r\n\r\nprint(len(s_1) + len(s_2) - 2 * k)\n# Mon Sep 27 2021 19:54:28 GMT+0300 (Москва, стандартное время)\n", "s = list(input())\r\nt = list(input())\r\nt.reverse()\r\ns.reverse()\r\nminimum = len(min(s, t))\r\ncount = 0\r\nfor i in range(minimum):\r\n if t[i] == s[i]:\r\n count += 1\r\n else:\r\n break\r\nprint((len(t)-count)+(len(s)-count))", "q = input()\r\nw = input()\r\nql=len(q)\r\nwl=len(w)\r\nwhile ql and wl and q[ql-1]==w[wl-1]:\r\n ql-=1\r\n wl-=1\r\nprint(ql+wl)", "word1=input()\r\nword2=input()\r\nlen1=len(word1)\r\nlen2=len(word2)\r\nwhile word1[len1-1]==word2[len2-1] and len1>0 and len2>0: \r\n len1 -= 1\r\n len2 -= 1\r\nprint(len1+len2)", "s = input()\nt = input()\n\nequalCharacters = 0\ni = len(s) - 1\nj = len(t) - 1\n\nwhile(i >= 0 and j >= 0):\n if s[i] == t[j]:\n equalCharacters+=1\n else:\n break\n i-=1\n j-=1\n\nprint(len(s)-equalCharacters + len(t)-equalCharacters)", "s = str(input())\r\nt = str(input())\r\n\r\nans = len(s) + len(t)\r\n\r\ns = s[::-1]\r\nt = t[::-1]\r\n\r\nl = 0\r\nfor i in range(min(len(s), len(t))):\r\n\tif s[i] == t[i]:\r\n\t\tl += 1\r\n\telse:\r\n\t\tbreak\r\n\r\nans -= 2 * l\r\n\r\nprint(ans)", "line1 = input()[::-1]\r\nline2 = input()[::-1]\r\nx = 0\r\nfor i in range(min(len(line1), len(line2))):\r\n if line1[i] == line2[i]:\r\n x += 1\r\n else:\r\n break\r\nprint(len(line1) + len(line2) - 2 * x)\r\n", "s = input()\r\nt = input()\r\n\r\ni = 0\r\n\r\nwhile i < min(len(s), len(t)):\r\n if s[len(s)-i-1] != t[len(t)-i-1]:\r\n break\r\n\r\n i += 1\r\n\r\nprint(len(s)+len(t)-2*i)\r\n", "s = input()\r\nt = input()\r\n\r\nsuffix_len = 0\r\nfor i in range(min(len(s), len(t))):\r\n if s[-i-1] == t[-i-1]:\r\n suffix_len += 1\r\n else:\r\n break\r\n\r\nmoves = len(s) + len(t) - 2 * suffix_len\r\n\r\nprint(moves)\r\n", "s= input()\r\nt= input()\r\ni = len(s)\r\nj = len(t)\r\nwhile s[i-1]==t[j-1] and i>0 and j >0:\r\n i-=1\r\n j-=1\r\nprint(i+j)", "a = input()\r\nb = input()\r\nla, lb = map(len, [a, b])\r\nml = min((la, lb))\r\nres = ml\r\nfor i in range(ml):\r\n if a[-i-1] != b[-i-1]:\r\n res = i\r\n break\r\nprint(la - res + lb - res)", "s=input()\r\nt=input()\r\na=len(s)\r\nb=len(t)\r\nc=0\r\nl=min(a,b)\r\nfor i in range(l):\r\n if s[a-i-1]==t[b-i-1]:\r\n c+=1\r\n else:\r\n break\r\nprint(a+b-(2*c))", "s = input()\r\nt = input()\r\ns1 = list(s)\r\nt1 = list(t)\r\ns1 = s1[::-1]\r\nt1 = t1[::-1]\r\nz = len(s)+len(t)\r\ni = 0\r\nc = 0\r\nwhile ( i < min([len(s),len(t)]) ) and (s1[i] == t1[i]):\r\n c = c+2\r\n i = i+1\r\nprint(z-c)", "x=input()\r\ny=input()\r\nres=len(x)+len(y)\r\nre=0\r\nl=len(x)\r\nr=len(y)\r\nwhile l>0 and r>0:\r\n if x[l-1]!=y[r-1]:\r\n break\r\n re+=2\r\n l-=1\r\n r-=1\r\nprint(res-re)" ]
{"inputs": ["test\nwest", "codeforces\nyes", "test\nyes", "b\nab", "z\nz", "abacabadabacaba\nabacabadacaba", "z\na", "ama\nsama", "aaabc\nbc", "lxuyspmieeuyxluv\ndfwxqvavzxctblaa", "ahmedaly\naly", "aa\na", "aa\nba", "cccba\nba", "a\nab", "dadc\ndddc", "aacaaab\nb", "dddc\ncdcde", "bbdab\ndab", "a\naa", "aa\nab", "codeforces\nces"], "outputs": ["2", "9", "7", "1", "0", "18", "2", "1", "3", "32", "5", "1", "2", "3", "3", "4", "6", "9", "2", "1", "4", "7"]}
UNKNOWN
PYTHON3
CODEFORCES
233
e13a6e6f6d8c190168588e4e23f98439
DZY Loves Strings
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter *c* DZY knows its value *w**c*. For each special string *s*<==<=*s*1*s*2... *s*|*s*| (|*s*| is the length of the string) he represents its value with a function *f*(*s*), where Now DZY has a string *s*. He wants to insert *k* lowercase letters into this string in order to get the largest possible value of the resulting string. Can you help him calculate the largest possible value he could get? The first line contains a single string *s* (1<=≤<=|*s*|<=≤<=103). The second line contains a single integer *k* (0<=≤<=*k*<=≤<=103). The third line contains twenty-six integers from *w**a* to *w**z*. Each such number is non-negative and doesn't exceed 1000. Print a single integer — the largest possible value of the resulting string DZY could get. Sample Input abc 3 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Sample Output 41
[ "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\n\r\nn = len(s)\r\ndlt = ord('a')\r\nans = 0\r\nfor i in range(n):\r\n #print((i + 1) * w[ord(s[i]) - dlt])\r\n ans += (i + 1) * w[ord(s[i]) - dlt]\r\nm = max(w)\r\nfor i in range(n + 1, n + k + 1):\r\n #print(m * i)\r\n ans += m * i\r\n\r\nprint(ans)\r\n", "s=input()\r\nk=int(input())\r\nx,Sum = list(map(int, input().split(\" \"))),0\r\nfor i in range(len(s)): \r\n Sum+=x[ord(s[i])-97]*(i+1)\r\nprint(Sum+sum(max(x)*(i+1) for i in range(len(s),len(s)+k)))", "s=list(input())\r\nk=int(input())\r\na=list(map(int,input().split()))\r\nm=max(a)\r\nc=0\r\nfor i in range(len(s)):\r\n c+=a[ord(s[i])-97]*(i+1)\r\n#print(c)\r\nfor i in range(len(s)+1,len(s)+k+1,1):\r\n c+=m*i\r\nprint(c)", "def DZY_loves_strings():\n s = input()\n k = int(input())\n w = []\n h = 0\n for i in input().split():\n w.append(int(i))\n h = max(h, int(i))\n lex = \"abcdefghijklmnopqrstuvwxyz\"\n v = 0\n for i, c in enumerate(s):\n v += w[lex.index(c)] * (i + 1)\n a = h * (len(s) + 1)\n v += a * k + (h * (k ** 2 - k)) / 2\n print(int(v))\n\n\nif __name__ == \"__main__\":\n DZY_loves_strings()\n pass\n", "s = input()\r\nk = int(input())\r\nl = list(map(int, input().split()))\r\nmx=max(l)\r\nsum=0\r\nr=1\r\nfor i in range(len(s)):\r\n sum+=l[ord(s[i])-ord('a')]*(i+1)\r\n r=r+1\r\nfor i in range(k):\r\n sum+=mx*r;\r\n r=r+1\r\nprint(int(sum))", "s = input()\nk = int(input())\nw = list(map(int, input().split()))\nidx = w.index(max(w))\ns += chr(ord('a')+idx)*k\nres = 0\nfor i in range(len(s)):\n idx = ord(s[i])-ord('a')\n res += (i+1)*w[idx]\nprint(res)\n\n", "from string import ascii_lowercase as a\r\n\r\ns = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\n\r\nwmax = max(w)\r\ns += \"0\" * k\r\n\r\nsumm = 0\r\nfor b, i in zip(s, range(len(s))):\r\n if b == \"0\":\r\n summ += (i + 1) * wmax\r\n else:\r\n summ += w[a.index(b)] * (i + 1)\r\n \r\n\r\nprint(summ)\r\n", "s=input()\r\nk=int(input())\r\nlst=list(map(int,input().split()))\r\nlst2=[chr(i) for i in range(97,123)]\r\ndct={}\r\nfor i in range(len(lst2)):\r\n dct[lst2[i]]=lst[i]\r\nvalue=0\r\nalpha=max(dct.values())\r\n\r\nfor i in range(len(s)):\r\n value+=(i+1)*dct[s[i]]\r\n #print(value)\r\nalpha=max(dct.values())\r\n#print(alpha)\r\nvalue+=alpha*(k*(k+2*len(s)+1)/2)\r\nprint(int(value))", "import sys\r\nimport math\r\nimport collections\r\nfrom pprint import pprint\r\n\r\ns = input()\r\nn = len(s)\r\nk = int(input())\r\nval = list(map(int, input().split()))\r\nans = 0\r\nfor i in range(n):\r\n ans += (i + 1) * val[ord(s[i]) - ord('a')]\r\nmx = max(val)\r\nfor i in range(n, n + k):\r\n ans += (i + 1) * mx\r\nprint(ans)\r\n", "def s_till(n):\n return n*(n+1)//2\n\nz = str(input())\nk = int(input())\nva = list(map(int,input().split()))\nc_va = {chr(97+h):i for h,i in enumerate(va) }\nans = 0\nfor ind, i in enumerate(z):\n ans+=(ind+1)*c_va[i]\n\nto_mult = s_till(k+len(z)) - s_till(len(z))\nans+=to_mult*max(c_va.values())\nprint(ans)\n", "string=input()\nk=int(input())\nl=list(map(int,input().split()))\nsum=0\ni=0\nwhile(i<len(string)):\n\ttemp=ord(string[i])-ord('a')\n\tsum+=l[temp]*(i+1)\n\ti=i+1\ni=i+1\nwhile(i<=len(string)+k):\n\tsum+=max(l)*i\n\ti=i+1\nprint(sum)\n", "import sys\r\nimport string\r\nfrom decimal import *\r\nfrom itertools import *\r\nfrom math import *\r\n\r\ndef solve():\r\n s = input()\r\n k = int(input())\r\n w = list(map(int,input().split()))\r\n mm = max(w)\r\n ans = 0\r\n for i in range(len(s)+k):\r\n if (i < len(s)):\r\n ans = ans + w[ord(s[i])-ord('a')]*(i+1)\r\n else:\r\n ans = ans + mm*(i+1)\r\n print(ans)\r\n \r\nsolve();\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nans = 0\r\nfor i in range(len(s)):\r\n ans += (i+1) * w[ord(s[i]) - 97]\r\nfor i in range(len(s), len(s)+k):\r\n ans += (i+1) * max(w)\r\nprint(ans)", "s = input()\nk = int(input())\nw = list(map(int, input().split()))\n\nmax_w = max(w)\nresult = 0\nfor i in range(len(s)):\n result += w[ord(s[i]) - ord('a')] * (i + 1)\n #print(result)\n\nfor i in range(k):\n result += max_w * (len(s) + i + 1)\n #print(result)\n\nprint(result)\n\t \t\t\t\t\t \t\t\t \t \t\t\t \t \t \t\t\t\t\t", "s = input();ss = len(s)\r\nk = int(input())\r\nL = list(map(int,input().split()))\r\nc,a = 0,\"abcdefghijklmnopqrstuvwxyz\"\r\nfor i in range(len(s)):\r\n c+=L[a.index(s[i])]*(i+1)\r\nprint(c+(((ss+k)*(ss+k+1))//2 - (ss*(ss+1))//2)*max(L))\r\n", "def f(s, weight):\r\n return sum([weight[s[i]]*(i+1) for i in range(len(s))])\r\n \r\ns = input()\r\nk = int(input())\r\ng = input().split()\r\nweight = {}\r\nfor i in range(26):\r\n weight[chr(97+i)] = int(g[i]) # chr(97) = 'a'\r\n\r\n#for k,v in weight.items():\r\n# print('%s - %s' % (k,v))\r\n \r\nmax_weight = max(weight.values())\r\nx = 0\r\nfor i in range(len(s)+1,len(s)+k+1):\r\n x += i*max_weight\r\nprint(f(s, weight) + x)", "s=input()\r\nx=int(input())\r\na=list(map(int,input().split()))\r\ns=s+chr(97+a.index(max(a)))*x\r\np=0\r\nfor i in range(1,len(s)+1):\r\n\tp=p+i*a[ord(s[i-1])-97]\r\nprint(p)", "s = input()\nk = int(input())\nli = list(map(int,input().split()))\nma = max(li)\nl = len(list(s))\nres1=int((((l+k)*(l+k+1))/2 - ((l)*(l+1))/2 )*ma)\nres2 = 0\nfor i in range(l):\n\tres2 += (i+1)*li[ord(s[i])-97]\nprint(res1+res2)", "x=input()\r\ny=int(input())\r\np=list(map(int,input().split()))\r\nk=0\r\nm=max(p)\r\nfor i in range(len(x)+y):\r\n if i<len(x):k+=(i+1)*p[ord(x[i])-97]\r\n else:\r\n k+=(i+1)*m\r\nprint(k)\r\n", "import math\r\nalph=\"abcdefghijklmnopqrstuvwxyz\"\r\n#-----------------------------------\r\n\r\ns=str(input())\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\nE=0\r\nfor i in range(len(s)):\r\n E+=(i+1)*w[alph.index(s[i])]\r\nfor i in range(k):\r\n E+=(len(s)+i+1)*max(w)\r\nprint(E)", "a = list(input())\n\nk = int(input())\n\nalphaList = list(map(int, input().split(\" \")))\nalpha = {chr(i+97) : alphaList[i] for i in range(len(alphaList))}\n\nmaxKey = max(alpha.keys(), key = lambda x:alpha[x])\n\nf = 0\nfor i in range(1, len(a) + k + 1):\n if i <= len(a):\n f = f + (alpha[a[i - 1]] * i)\n else:\n f = f + (alpha[maxKey] * i)\n\nprint(f)", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nl = len(s)\r\nmv = max(w)\r\n\r\nans = sum([w[ord(s[i]) - 97] * (i + 1) for i in range(l)])\r\nfor i in range(k):\r\n ans += (i + l + 1) * mv\r\n\r\nprint(ans)", "def solve(s, k):\n d = [int(i) for i in input().split()]\n res = 0 \n for i in range(len(s)):\n res += d[ord(s[i])-97]*(i+1) \n res += max(d)*(len(s)*k + k*(k+1)//2) \n return res \n \nif __name__ == '__main__':\n s = input()\n k = int(input())\n print(solve(s, k))\n \n \n", "b=input()\r\nc=int(input())\r\nd=[int(i) for i in input().split()]\r\nh=max(d)\r\nt=0\r\nfor i in range(len(b)):\r\n z=ord(b[i])-ord('a')\r\n t+=(i+1)*d[z]\r\nfor i in range(len(b),len(b)+c):\r\n t+=h*(i+1)\r\nprint(t)\r\n", "s=input()\r\nk=int(input())\r\na=[int(i) for i in input().split()]\r\nt=0\r\nz=max(a)\r\nn=len(s)\r\nfor i in range(n):\r\n t+=a[ord(s[i])-ord('a')]*(i+1)\r\nfor i in range(n+1,n+k+1):\r\n t+=z*i\r\nprint(t)", "''' ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█ \n █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█ '''\n\n\n# [temp1.py] => [29-07-2020 @ 10:25:10] \n# Author & Template by : Udit \"luctivud\" Gupta\n# https://www.linkedin.com/in/udit-gupta-1b7863135/\n\n\nimport math; from collections import *\nimport sys; from functools import reduce\nimport time; from itertools import groupby\n\n# sys.setrecursionlimit(10**6)\n\ndef input() : return sys.stdin.readline()\ndef get_ints() : return map(int, input().strip().split())\ndef get_list() : return list(get_ints())\ndef get_string() : return list(input().strip().split())\ndef printxsp(*args) : return print(*args, end=\"\")\ndef printsp(*args) : return print(*args, end=\" \")\n\n\nDIRECTIONS = [(+0, +1), (+0, -1), (+1, +0), (+1, -1)] \nNEIGHBOURS = [(-1, -1), (-1, +0), (-1, +1), (+0, -1),\\\n (+1, +1), (+1, +0), (+1, -1), (+0, +1)]\n\n\nCAPS_ALPHABETS = {chr(i+ord('A')) : i for i in range(26)}\nSMOL_ALPHABETS = {chr(i+ord('a')) : i for i in range(26)}\nINF = float('inf')\n\n\n# Custom input output is now piped through terminal commands.\n# for _test_ in range(int(input())): \ns = input().strip('\\n')\nk = int(input())\nli = get_list()\nn = len(s)\nprint((max(li) * sum(range(n+1, n+k+1))) + sum([li[ord(s[i]) - ord('a')]*(i+1) for i in range(n)]))\n\n\n\n# print(\"Time Elapsed: {}\".format(float(S34p-S34t))) power of python just don't get tle\n", "s = input()\nk = int(input())\nl = tuple(map(int, input().split()))\n\nr = 0\n\np = 1\nfor i in s:\n r+=l[ord(i)-97]*p\n p += 1\n\nz = max(l)\n\nfor i in range(k):\n r += z*p\n p += 1\nprint(r)\n", "a=input()\r\nk=int(input())\r\ns=sorted('qwertyuioplkjhgfdsazxcvbnm')\r\nb=list(map(int,input().split()))\r\nd={}\r\nfor i in range(26):d[s[i]]=b[i]\r\nb.sort()\r\nres=0\r\nii=1\r\nfor i in a:\r\n res+=d[i]*ii\r\n \r\n ii+=1\r\n\r\nfor i in range(len(a)+1,len(a)+k+1):res+=b[-1]*i\r\nprint(res)", "s=input()\r\nn=int(input())\r\nk=input().split()\r\n# print(k)\r\nmax1=0\r\nfor i in k:\r\n if (int(i)> max1):\r\n max1=int(i)\r\nsum=0\r\n# print(max1)\r\nl=1\r\nfor i in s:\r\n sum=sum+l*int(k[ord(i)-97])\r\n l+=1\r\n\r\n# print(sum,l)\r\nfor i in range(0,n):\r\n sum=sum+l*max1\r\n l+=1\r\n# print(sum,l)\r\nprint(sum)\r\n# s1 = input()\r\n# p=s1\r\n# k = int(input())\r\n# s = list(map(int,input().split()))\r\n# ad = []\r\n# for i in range(1,len(s1)+1):\r\n# ad.append(s[ord(s1[i-1])-97])\r\n#\r\n# print(ad)\r\n# print(k)\r\n# while(k!=0):\r\n# if ad[k-1]>1 and ad[k-1]>=k:\r\n# p=p+(p[k-1]*ad[k-1])\r\n# k-=ad[k-1]\r\n# print(k)\r\n#\r\n# print(p)", "from string import ascii_lowercase as a\r\ns = input()\r\nk = int(input())\r\nd = list(map(int, input().split()))\r\nans = 0\r\n\r\nl = len(s)\r\nfor i in range(l):\r\n ans += d[a.find(s[i])]*(i + 1)\r\n\r\nf = max(d)\r\nfor i in range(k):\r\n ans += f*(i + l + 1)\r\nprint(ans)\r\n", "s=list(input())\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nn=len(s)\r\ns1=n*(n+1)/2\r\nn+=k\r\ns2=n*(n+1)/2\r\nans=0\r\ni=1\r\nfor j in s:\r\n ans+=i*l[ord(j)-97]\r\n i+=1\r\n #print(ord(j))\r\n#print(ans)\r\nans+=max(l)*(s2-s1)\r\nprint(int(ans))", "def _input(): return map(int ,input().split())\r\n\r\ns = input()\r\nn = int(input())\r\nlst = list(_input())\r\nres = 0\r\nfor i in range(1, len(s)+1):\r\n res+=(lst[ord(s[i-1])-97] * i )\r\nm = max(lst)\r\nprint(res + sum([i*m for i in range(len(s)+1, len(s)+n+1)]))\r\n", "def sumn(n):\r\n return (int)((n*(n+1))/2)\r\n \r\ns = input()\r\nk = (int)(input())\r\nval = []\r\nstr1 = input().split()\r\nfor x in range(len(str1)):\r\n val.append((int)(str1[x]))\r\nv1 = ord('a')\r\nmaxi = max(val)\r\ns1 = 0\r\nfor i in range(len(s)):\r\n s1 += (i+1) * val[ord(s[i]) - v1]\r\nadd = sumn(len(s)+k) - sumn(len(s))\r\nprint (s1 + add*maxi)", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nans=0\r\nfor i in range(len(s)):\r\n ans+=l[ord(s[i])-97]*(i+1)\r\nma=max(l)\r\nfor i in range(len(s)+1,len(s)+k+1):\r\n ans+=ma*i\r\nprint(ans)", "import sys\r\ndef input():\r\n return sys.stdin.readline().strip()\r\n \r\n \r\ndef iinput():\r\n return int(input())\r\n \r\n \r\ndef tinput():\r\n return input().split()\r\n \r\n \r\ndef rinput():\r\n return map(int, tinput())\r\n \r\n \r\ndef rlinput():\r\n return list(rinput())\r\n\r\nA = input()\r\nk = iinput()\r\nw = rlinput()\r\nmax_value = max(w)\r\nans = 0\r\ncur = ord('a')\r\nfor i in range(len(A)):\r\n ans += (w[ord(A[i])-cur] * (i+1))\r\ni += 1\r\nfor _ in range(k):\r\n ans += (max_value * (i+1))\r\n i += 1\r\nprint(ans)\r\n", "str = list(input())\r\nN = int(input())\r\nA = list(map(int, input().split()))\r\n\r\ntotal = 0\r\n\r\nmaxu = max(A)\r\n\r\nfor i in range(len(str)):\r\n total += (i+1) * (A[ord(str[i]) - 97])\r\n\r\nfor j in range(N):\r\n total += (j+len(str)+1)*maxu\r\n\r\nprint(total)\r\n", "s = input()\nk = int(input())\nw = [int(i) for i in input().split()]\nv = 0\ni = 0\nfor i,c in enumerate(s):\n v+= (i+1)*w[ord(c)-ord('a')]\nw = sorted(w)\nfor i in range(k):\n v+= (len(s)+1+i)*w[-1]\nprint(int(v))\n", "#\r\n# # # Author:Aditya Joshi\r\n# #\r\ns = input()\r\nk = int(input())\r\nl = list(map(int, input().split()))\r\nd = {}\r\nfor i in range(26):\r\n d[chr(ord('a') + i)] = l[i]\r\nans = 0\r\nfor i in range(len(s)):\r\n ans += ((i + 1) * d[s[i]])\r\nm = max(l)\r\nfor i in range(len(s), len(s) + k):\r\n ans += (m * (i+1))\r\nprint(ans)\r\n", "alph = 'abcdefghijklmnopqrstuvwxyz'\r\nst = input()\r\nk = int(input())\r\nwaz= list(map(int, input().split()))\r\nd = {}\r\nmaxv = 0\r\nfor i in range(0,26):\r\n d[alph[i]] = waz[i]\r\n if waz[i] > maxv:\r\n maxv = waz[i]\r\nanswer = 0\r\nfor i in range(0, len(st) + k):\r\n if i < len(st):\r\n answer += (i+1)*d[st[i]]\r\n else:\r\n answer += (i+1)*maxv\r\nprint(answer)\r\n", "#imgur.com/Pkt7iIf.png\r\n\r\n#n, m = map(int, input().split())\r\n#n = int(input())\r\n#d = list(map(int, input().split()))\r\n\r\ns = input()\r\nk = int(input())\r\nd = list(map(int, input().split()))\r\n\r\np = d.index(max(d))\r\ns = s + chr(ord('a') + p)*k\r\n\r\nr = 0\r\nfor i in range(1, len(s)+1):\r\n r += d[ord(s[i-1]) - ord('a')] * i\r\nprint(r)\r\n", "k=input()\r\na=int(input())\r\nl=list(map(int,input().split()))\r\nc=0\r\nt='abcdefghijklmnopqrstuvwxyz'\r\nf=zip(t,l)\r\nf=list(f)\r\nfor i in range(len(k)):\r\n for j in f:\r\n if k[i]==j[0]:\r\n c+=(i+1)*j[1]\r\nt=(((len(k)+a)*(len(k)+a+1)))//2-((len(k))*(len(k)+1))//2\r\nt*=max(l)\r\nprint(c+t)\r\n\r\n\r\n", "s = input()\nk = int(input())\nw = list(map(int, input().split()))\nans = 0\nfor i in range(len(s)):\n ans += (i + 1) * (w[ord(s[i]) - ord('a')])\nn = len(s)\nans += (n + 1 + n + k) * k // 2 * max(w)\nprint(ans)\n\n", "s = input()\nk = int(input())\na = list(map(int, input().split(\" \")))\nv, l, m = 0, len(s), max(a)\nfor i in range(l):\n v += a[(ord(s[i])-97)]*(i+1)\nfor i in range(k):\n v += m*(l+1+i)\nprint(v)\n", "s=input()\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nsum1=0\r\ni=1\r\nfor c in s:\r\n sum1+=a[ord(c)-ord('a')]*i\r\n i+=1\r\nprint(int(sum1+max(a)*(i+i+n-1)*(n)/2))\r\n", "\r\ns=list(input())\r\nL='abcdefghijklmnopqrstuvwxyz'\r\nk=m=int(input())\r\nnum=list(map(int,input().split()))\r\nsumm=0\r\nc=1\r\nfor i in s:\r\n summ+=c*(num[L.index(i)])\r\n c+=1\r\nwhile k!=0:\r\n summ+=c*(max(num))\r\n k-=1\r\n c+=1\r\nprint(summ)", "def main():\r\n r = lambda: tuple(map(int, input().split()))\r\n s = input()\r\n k = r()[0]\r\n l = r()\r\n o = k * (k + 1) // 2 + k * len(s)\r\n print(sum(l[ord(c) - ord('a')] * (i + 1) for i, c in enumerate(s)) + o * max(l))\r\nmain()", "import sys\r\nfrom collections import Counter\r\nmod = pow(10, 9) + 7\r\nmod2 = 998244353\r\ndef data(): return sys.stdin.readline().strip()\r\ndef out(var): sys.stdout.write(str(var)+\"\\n\")\r\ndef outa(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var)) + end)\r\ndef l(): return list(sp())\r\ndef sl(): return list(ssp())\r\ndef sp(): return map(int, data().split())\r\ndef ssp(): return map(str, data().split())\r\n\r\n\r\ndef calculate_diff(first, second):\r\n return first * (first + 1) // 2 - second * (second + 1) // 2\r\n\r\n\r\ns = data()\r\nk = int(data())\r\narr = l()\r\nanswer = 0\r\nfor i in range(len(s)):\r\n answer += (i + 1) * arr[(ord(s[i]) - 97)]\r\ndiff = calculate_diff(len(s) + k, len(s))\r\nout(answer + diff * max(arr))\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\n\r\ns += chr(97 + w.index(max(w))) * k\r\n\r\nr = 0\r\nfor i, c in enumerate(s):\r\n r += (i + 1) * w[ord(c) - 97]\r\n\r\nprint(r)\r\n", "s=input()\nk=int(input())\nl=[int(x) for x in input().split()]\nmax1=max(l)\nln=len(s)\nvalue=0\nfor i in range(1,k+1):\n value+=(ln+i)*max1\nfor i in range(len(s)):\n value+=(i+1)*l[ord(s[i])-ord('a')]\nprint(value)\n", "s, k = input(), int(input())\r\nw = [int(x) for x in input().split()]\r\n\r\nalph = list('abcdefghijklmnopqrstuvwxyz')\r\ns += alph[w.index(max(w))] * k\r\n\r\nout = 0\r\ni = 1\r\nfor ch in s:\r\n out += i * w[alph.index(ch)]\r\n i += 1\r\n\r\nprint(out)\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nc = chr(w.index(max(w)) + ord('a'))\r\ndef f(s):\r\n result = 0\r\n for i in range(len(s)):\r\n result += w[ord(s[i]) - ord('a')] * (i + 1)\r\n return result\r\nprint(f(s + c * k))", "n = input()\r\n\r\nk = int(input())\r\nsum = 0\r\nlist_ = list(map(int,input().split()))\r\nfor i in range(len(n)):\r\n sum += list_[ord(n[i]) - 97]*(i+1)\r\n\r\n\r\nsum+=max(list_)*(len(n) + 1 + len(n) + k)*k/2\r\n\r\nprint(int(sum))", "s = input()\r\nk = int(input())\r\nw = input().split(\" \")\r\nfor i in range(len(w)):\r\n w[i] = int(w[i])\r\nsomme = 0\r\nlens = len(s) +1\r\nfor i in range(1,lens):\r\n somme += w[ord(s[i-1])-97]*i\r\nmaxs = max(w)\r\n\r\nfor i in range(lens,k+lens):\r\n somme += i*maxs\r\n\r\nprint(somme)\r\n\r\n", "import sys\r\ninf = float(\"inf\")\r\n# sys.setrecursionlimit(1000000)\r\n\r\n\r\n# abc='abcdefghijklmnopqrstuvwxyz'\r\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}\r\nmod,MOD=1000000007,998244353\r\n# vow=['a','e','i','o','u']\r\n# dx,dy=[-1,1,0,0],[0,0,1,-1]\r\n\r\n# from collections import deque, Counter, OrderedDict,defaultdict\r\n# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace\r\nfrom math import ceil,floor,log,sqrt,factorial,pow,pi,gcd,log10,atan,tan\r\n# from bisect import bisect_left,bisect_right\r\n\r\n\r\ndef get_array(): return list(map(int , sys.stdin.readline().strip().split()))\r\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\r\ndef get_strs(): return map(str, sys.stdin.readline().strip().split())\r\ndef input(): return sys.stdin.readline().strip()\r\n\r\ndef function(n):\r\n return (n*(n+1))//2\r\n\r\nstring = input()\r\nk = int(input())\r\nArr = get_array()\r\nlength = len(string)\r\nans = 0\r\nz = 1\r\nfor i in string:\r\n ans+=Arr[ord(i)-97]*z\r\n z+=1\r\nans+=(function(length+k) - function(length))*max(Arr)\r\nprint(ans)", "s = input()\r\nk = int(input())\r\nvals = list(map(lambda x: int(x), input().split()))\r\nval = 0\r\n\r\nn = len(s)\r\nfor i in range(n):\r\n val += vals[ord(s[i])-97]*(i+1)\r\n\r\nfor j in range(n+1,n+k+1):\r\n val += max(vals)*j\r\n\r\n\r\nprint(val)", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\n#print(l)\r\nz=0\r\nfor i in range(0,len(s)):\r\n #print(l[ord(s[i])-97)])\r\n z=z+(l[(ord(s[i]))-97])*(i+1)\r\nl.sort()\r\nl=l[::-1]\r\np=len(s)\r\nfor i in range(p+1,p+k+1):\r\n z=z+(i*l[0])\r\nprint(z)", "s, k, w = input(), int(input()), list(map(int, input().split()))\r\n\r\nsum, m, l = 0, max(w), len(s)\r\nfor i in range(l + k):\r\n sum += (w[ord(s[i]) - ord('a')] if i < l else m) * (i + 1)\r\n\r\nprint(sum)", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nr=0\r\nfor i in range(len(s)):\r\n if(s[i]=='a'):\r\n r=r+(i+1)*l[0] \r\n elif(s[i]=='b'):\r\n r=r+(i+1)*l[1]\r\n elif(s[i]=='c'):\r\n r=r+(i+1)*l[2]\r\n elif(s[i]=='d'):\r\n r=r+(i+1)*l[3]\r\n elif(s[i]=='e'):\r\n r=r+(i+1)*l[4]\r\n elif(s[i]=='f'):\r\n r=r+(i+1)*l[5]\r\n elif(s[i]=='g'):\r\n r=r+(i+1)*l[6]\r\n elif(s[i]=='h'):\r\n r=r+(i+1)*l[7]\r\n elif(s[i]=='i'):\r\n r=r+(i+1)*l[8]\r\n elif(s[i]=='j'):\r\n r=r+(i+1)*l[9]\r\n elif(s[i]=='k'):\r\n r=r+(i+1)*l[10]\r\n elif(s[i]=='l'):\r\n r=r+(i+1)*l[11]\r\n elif(s[i]=='m'):\r\n r=r+(i+1)*l[12]\r\n elif(s[i]=='n'):\r\n r=r+(i+1)*l[13]\r\n elif(s[i]=='o'):\r\n r=r+(i+1)*l[14]\r\n elif(s[i]=='p'):\r\n r=r+(i+1)*l[15]\r\n elif(s[i]=='q'):\r\n r=r+(i+1)*l[16]\r\n elif(s[i]=='r'):\r\n r=r+(i+1)*l[17]\r\n elif(s[i]=='s'):\r\n r=r+(i+1)*l[18]\r\n elif(s[i]=='t'):\r\n r=r+(i+1)*l[19]\r\n elif(s[i]=='u'):\r\n r=r+(i+1)*l[20]\r\n elif(s[i]=='v'):\r\n r=r+(i+1)*l[21]\r\n elif(s[i]=='w'):\r\n r=r+(i+1)*l[22]\r\n elif(s[i]=='x'):\r\n r=r+(i+1)*l[23]\r\n elif(s[i]=='y'):\r\n r=r+(i+1)*l[24]\r\n elif(s[i]=='z'):\r\n r=r+(i+1)*l[25]\r\nif(k==0):\r\n print(r)\r\nelse:\r\n le1=len(s)\r\n le=le1+k\r\n sum1=(le/2)*(2+(le-1))\r\n sum2=(le1/2)*(2+(le1-1))\r\n sum3=sum1-sum2\r\n r1=sum3*max(l)\r\n print(int(r+r1))", "s = input()\r\nk = int(input())\r\narr = list(map(int,input().split()))\r\n\r\nchar = \"abcdefghijklmnopqrstuvwxyz\"\r\n\r\nmaxi = max(arr)\r\n\r\nres = 0\r\n\r\ni = 1\r\n\r\nwhile i <= len(s):\r\n\tidx = char.index(s[i-1])\r\n\tres += arr[idx] * i\r\n\ti += 1\r\n\r\nfor _ in range(k):\r\n\tres += maxi * i\r\n\ti += 1\r\n\r\nprint(res)\r\n", "a=input()\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nletters='abcdefghijklmnopqrstuvwxyz'\r\nb=l.index(max(l))\r\na+=n*letters[b]\r\n\r\nt=[]\r\nfor i in a:\r\n t.append(l[letters.index(i)])\r\ns=0\r\nfor i in range(1,len(a)+1):\r\n s+=i*t[i-1]\r\n\r\nprint(s)", "a = input()\nk = int(input())\nw = list(map(int, input().split()))\ndef maxind(a):\n\tres = a[0]\n\tres_ind = 0\n\tfor i, el in enumerate(a):\n\t\tif el > res:\n\t\t\tres = el\n\t\t\tres_ind = i\n\treturn res_ind\n\na += chr(maxind(w)+97)*k\nprint(sum(w[ord(el)-97]*(i+1) for i, el in enumerate(a)))\n", "from collections import Counter\r\n\r\nfunc=len\r\n\r\ndef remzero(n):\r\n res=\"\"\r\n for i in n:\r\n if i!=\"0\":\r\n res+=i\r\n\r\n return res\r\n\r\ndef solve():\r\n string=input()\r\n k=int(input())\r\n\r\n arr=[int(i) for i in input().split()]\r\n\r\n Dict={}\r\n Max,sum=0,0\r\n\r\n for count,i in enumerate(arr):\r\n Dict.setdefault(97+count,i)\r\n Max=max(Max,i)\r\n\r\n for i in range(func(string)):\r\n sum+=(i+1)*Dict[ord(string[i])]\r\n\r\n\r\n for i in range(func(string),k+func(string)):\r\n sum+=(i+1)*Max\r\n\r\n return sum\r\n\r\n\r\n\r\n\r\n\r\n\r\nprint(solve())\r\n\r\n\r\n\r\n\r\n\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\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\"]\r\n\r\nf = 0\r\nfor i in range(len(s)):\r\n f += ((i + 1) * w[alpha.index(s[i])])\r\n\r\nfor j in range(len(s) + 1, len(s) + k + 1):\r\n f += (j * max(w))\r\nprint(f)", "n=input()\r\nk=int(input())\r\nar=list(map(int,input().split()))\r\ns1=0\r\nfor x in range(len(n)):\r\n s1+=ar[ord(n[x])-ord('a')]*(x+1)\r\nar.sort()\r\nfor x in range(len(n)+1,len(n)+k+1):\r\n s1+=ar[-1]*x\r\nprint(s1)\r\n", "s=input()\r\nk=int(input())\r\nlst=[int(i) for i in input().split()]\r\nma=max(lst)\r\nsum=0\r\nfor i in range(len(s)):\r\n asci=ord(s[i])-97\r\n sum+=(i+1)*lst[asci]\r\n \r\nfor i in range(len(s),len(s)+k):\r\n sum+=(i+1)*ma\r\nprint(sum)", "import time,math\r\nfrom sys import stdin,stdout\r\nI = lambda: int(stdin.readline()) #For integer input\r\nIs = lambda: str(stdin.readline()) #For string input\r\nIn = lambda: map(int,stdin.readline().split()) #For multiple input\r\nL = lambda: list(map(int,stdin.readline().split())) #For array input\r\nSi = lambda: sorted(list(map(int,stdin.readline().split())))#For sorted array\r\nSr = lambda: sorted(list(map(int,stdin.readline().split())),reverse=True) #For sorted array(in reverse order)\r\nPi = lambda x,y : stdout.write(str(x)+\" \"+str(y)) #for double output\r\ndef P(x):\r\n return stdout.write(str(x)) #faster output without newline character\r\n\r\ndef solve():\r\n s=Is()\r\n k=I()\r\n l=L()\r\n ans=0\r\n for i in range(len(s)-1):\r\n ans+=( l[ord(s[i])-ord(\"a\")]*(i+1) )\r\n x=int(len(s)*(len(s)-1)/2)\r\n y=int( (len(s)+k) * (len(s)+k-1)/2)\r\n P((ans+(max(l)*(y-x))))\r\n\r\n\r\nif __name__ == \"__main__\" :\r\n #start = time.time()\r\n solve()\r\n #end = time.time()\r\n #print(\"Time taken : \", end-start)\r\n", "s=input()\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nsum=0\r\nm=max(l)\r\nfor i in range(len(s)):\r\n\tsum+=(i+1)*(l[ord(s[i])-97])\r\nfor i in range(len(s)+1,len(s)+n+1):\r\n\t\tsum+=i*m\r\nprint(sum)\t\t", "s=list(input())\r\nk=int(input())\r\nvalues = list(map(int,input().split()))\r\nsum=0\r\nfor i in range(len(s)):\r\n sum+=(values[ord(s[i])-97])*(i+1)\r\nmaxx = max(values)\r\nfor i in range(len(s),len(s)+k):\r\n # print(\"i = \",i)\r\n sum+=(maxx*(i+1))\r\nprint(sum)", "stri=input()\r\n\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nnum=len(stri)\r\n\r\nt=0\r\nfor i in range(num):\r\n\tt+=l[ord(stri[i])-97]*(i+1)\r\nt+=max(l)*(2*num*k+k**2+k)//2\r\nprint(t)", "s=list(input())\r\nk=int(input())\r\nval=list(map(int, input().split()))\r\na=0\r\nflag=0\r\nfor i in range(1,len(s)+1):\r\n a=int(ord(s[i-1])-96)\r\n flag= flag+ (i)*val[a-1]\r\n# print(flag)\r\nfor i in range(1,k+1):\r\n flag=flag+(len(s)+i)*max(val)\r\nprint(flag)\r\n \r\n\r\n\r\n", "s = input()\r\nk = int(input())\r\nval = list(map(int,input().split()))\r\nd = {chr(97+i): int(val[i]) for i in range(26)}\r\n# print(d)\r\nx = max(val)\r\nl = len(s)\r\nsum = 0\r\nfor i in range(l):\r\n sum = sum+(i+1)*d[s[i]]\r\n# for i in range(len(s)+1,len(s)+1+k):\r\n# sum=sum+i*x\r\n# print(sum)\r\nsum = sum+((l+k)*((l+k+1)/2)-l*((l+1)/2))*x\r\nprint(int(sum))\r\n", "a = input()\r\nk = int(input())\r\narr = list(map(int,input().split()))\r\nt = max(arr)\r\ncount = 0\r\nfor i in range(1,len(a)+1):\r\n count+= arr[(ord(a[i-1])-97)]*(i)\r\nfor i in range(1,k+1):\r\n count+=(i+len(a))*t\r\nprint(count)", "s=input()\r\nk=int(input())\r\nl=[int(i) for i in input().split()]\r\nsm=0\r\nn=len(s)\r\nfor i in range(n):\r\n sm+=l[ord(s[i])-97]*(i+1)\r\nl=sorted(l,reverse=True)\r\nz=l[0:k]\r\nz=z[::-1]\r\nfor i in range(n,n+k):\r\n sm+=(i+1)*max(l) \r\nprint(sm)\r\n", "import operator\nst = input()\nk = int(input())\nw = list(map(int, input().split()))\nmi_w, mv_w = max(enumerate(w), key=operator.itemgetter(1))\nst = st+k*(chr(mi_w+97))\nf = sum([w[ord(c)-97]*(i+1) for i, c in enumerate(st)])\nprint(f)\n", "S=input()\r\np=int(input())\r\nl=list(map(int,input().split()))\r\nS1='abcdefghijklmnopqrstuvwxyz'\r\nk=0\r\nfor i in range(len(S)) :\r\n r=S1.index(S[i])\r\n k=k+((i+1)*l[r])\r\nv=i+p+1\r\ng=i\r\nfor j in range(i+1,v) :\r\n k=k+max(l)*(j+1)\r\nprint(k)\r\n \r\n \r\n \r\n\r\n \r\n \r\n", "s = input()\r\nk = int(input())\r\n\r\na = list(map(int, input().split()))\r\n\r\nplus = max(a)\r\nitog = 0\r\n\r\nfor i in range(1, len(s) + 1):\r\n itog += a[ord(s[i - 1]) - ord('a')] * i\r\n\r\nfor i in range(len(s) + 1, len(s) + 1 + k):\r\n itog += plus * i\r\n \r\nprint(itog)\r\n \r\n", "# Aditya Morankar\r\n# lsta = list(map(int,input().split()))\r\ndef main():\r\n string = input()\r\n k = int(input())\r\n wgt = list(map(int, input().split()))\r\n \r\n ans= 0\r\n for i,char in enumerate(string):\r\n ans += (i+1)*wgt[ord(char)-97]\r\n \r\n maxw = max(wgt)\r\n n = len(string)+1\r\n for i in range(k):\r\n ans += n*maxw\r\n n+=1\r\n \r\n \r\n print(ans)\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\nif __name__ == '__main__':\r\n t = 1\r\n while t!=0:\r\n main()\r\n t-=1", "s=input()\r\nn=int(input())\r\nm=0\r\na=len(s)\r\nl=list(map(int,input().split()))\r\nfor i in range(1,a+1):\r\n j=ord(s[i-1])-97\r\n m=m+(i*l[j])\r\nf=a+n\r\nf=(f*(f+1))//2\r\na=(a*(a+1))//2\r\nm=m+((f-a)*max(l))\r\nprint(m)", "s = input()\nk = int(input())\n\nalfabet = list(map(int, input().split()))\n\nmaxi = max(alfabet)\n\ncount = maxi * (2 * len(s) + k + 1) * k // 2\n\nfor i in range(len(s)):\n count += (i + 1) * alfabet[ord(s[i]) - 97]\nprint(count)", "#!/usr/bin/env python\r\n# -*- coding: utf-8 -*-\r\n\r\nS = input()\r\nk = int(input())\r\nW = list(map(int,input().split()))\r\nm = max(W)\r\nans = 0\r\ncount = 1\r\n\r\nfor s in S:\r\n x = ord(s) - ord('a')\r\n ans += W[x] * count\r\n count += 1\r\nfor i in range(k):\r\n ans += m * (i + count)\r\nprint(ans)\r\n\r\n", "#accepting input data\r\ns = input('')\r\nk = int(input(''))\r\nweights = []\r\nweights = input().split()\r\nweights = [int(i) for i in weights] \r\n\r\nmax_wt=0\r\n\r\ns_list = []\r\nfor i in range(0,len(s)):\r\n s_list.append(ord(s[i])-96)\r\n max_wt += int(weights[s_list[i]-1])*(i+1)\r\n\r\nfor i in range(0,k):\r\n s_list.append(weights.index(max(weights))+1)\r\n max_wt += int(max(weights))*(i+1+len(s))\r\n\r\nprint(max_wt)\r\n", "def main():\r\n s=input()\r\n n=int(input())\r\n k=input().split()\r\n max1=0\r\n for i in k:\r\n if (int(i)>max1):\r\n max1=int(i)\r\n sum=0\r\n l=1\r\n for i in s:\r\n sum=sum+l*int(k[ord(i)-97])\r\n l+=1\r\n for i in range(0,n):\r\n sum=sum+l*max1\r\n l+=1\r\n print (sum)\r\nmain()", "s = input()\r\nk = int(input())\r\nl = list(map(int,input().split()))\r\nd = {}\r\na = 97\r\nfor i in l:\r\n\td[chr(a)] = i\r\n\ta+=1\r\nsum = 0\r\nno = 1\r\nfor i in s:\r\n\tsum+=d[i]*no\r\n\tno+=1\r\nfor i in range(k):\r\n\tsum+=no*max(l)\r\n\tno+=1\r\nprint(sum)", "s=input()\r\nk=input()\r\nk=int(k)\r\nw=list(map(int,input().rstrip().split()))\r\nb=sorted(w)\r\nSum=0\r\ns1=0\r\nfor i in range(len(s)):\r\n Sum=Sum+((w[abs(ord(\"a\")-ord(s[i]))])*(i+1))\r\n \r\nfor j in range(len(s)+1,len(s)+k+1):\r\n s1=s1+(j)*b[25]\r\n \r\nprint(Sum+s1) \r\n ", "from collections import defaultdict\ninput_string = input()\nk = int(input())\nkey_val = defaultdict(int)\nvalues = list(map(int, input().split()))\nj = 0\nfor i in range(97, 123):\n key_val[chr(i)] = values[j]\n j += 1\nans = 0\nfor i in range(len(input_string)):\n ans += (i+1)*key_val[input_string[i]]\nmax_val = max(values)\nfor i in range(len(input_string), len(input_string)+k):\n ans += (i+1)*max_val\nprint(ans)\n", "s = input()\nk = int(input())\nw = list(map(int, input().split()))\nvalue = 0\nn = len(s)\nfor i in range(n):\n\tvalue += (i + 1) * w[ord(s[i]) - ord('a')]\nprint(value + max(w) * ((k + n) * (k + n + 1) // 2 - (n * (n + 1) // 2)))\n", "s=str(input())\r\nk=int(input())\r\nwlist=[int(w) for w in input().split()]\r\nletter=max(wlist)\r\nalphabet='abcdefghijklmnopqrstuvwxyz'\r\nsumm=0\r\nfor i in range(len(s)):\r\n\tsumm+=wlist[alphabet.index(s[i])]*(i+1)\r\n\r\nprint(summ+letter*(k*len(s)+(k+k**2)//2))", "def main():\n s = list(input())\n k = int(input())\n w = list(map(int, input().split(' ')))\n max_index = 0\n for i in range(1, len(w)):\n if w[i] > w[max_index]:\n max_index = i\n for i in range(k):\n s.append(chr(max_index + ord('a')))\n ret = 0\n for i, c in enumerate(s):\n ret += (i + 1) * (w[ord(c) - ord('a')])\n return ret\n\n\nprint(main())\n", "str1=input('')\r\nk=int(input(''))\r\nw=list(map(int,input().split()))\r\np=max(w)\r\npidx=w.index(p)+97\r\nq=chr(pidx)\r\nstr2=k*q\r\nstr3=str1+str2\r\nf=0\r\nfor i in range(0,len(str3)):\r\n a=ord(str3[i])-97\r\n f=f+(i+1)*w[a]\r\nprint(f)", "s=input()\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\nscore=0\r\nfor i in range(len(s)):\r\n score+=(w[ord(s[i])-97]*(i+1))\r\n\r\nscore=score+(max(w)*(k*len(s)+(k*(k+1)//2)))\r\nprint(int(score))\r\n\r\n\r\n\r\n", "i1=97\r\ns=input()\r\nk=int(input())\r\nv=[int(i) for i in input().split()]\r\nm=max(v)\r\nx=0\r\ni=1\r\nfor j in s:\r\n f=ord(j)-i1\r\n x+=(i*v[f])\r\n i+=1\r\nfor l in range(k):\r\n x+=i*m\r\n i+=1\r\nprint(x)\r\n\r\n\r\n", "#in the name of god\r\n#Mr_Rubick\r\ns=input().strip()\r\nk=int(input())\r\na=list(map(int,input().split()))\r\nans=0\r\nfor i in range(len(s)):\r\n ans+=(i+1)*a[(ord(s[i])-97)]\r\nm=max(a)\r\nfor i in range(len(s),len(s)+k):\r\n ans+=m*(i+1)\r\nprint(ans)", "s = input()\r\nk = int(input())\r\narr = [int(x) for x in input().split()]\r\n\r\nans = 0\r\nfor i in range(len(s)):\r\n ans += arr[ord(s[i])-97]*(i+1)\r\n\r\nhaha = max(arr)\r\n\r\nfor i in range(k):\r\n ans += haha*(len(s)+i+1)\r\n\r\nprint(ans)\r\n\r\n\r\n", "s = input()\r\nn = int(input())\r\nvalue = list(map(int, input().split()))\r\nans = 0\r\n\r\nfor i in range(len(s)):\r\n ans += (value[ord(s[i]) - ord('a')] * (i + 1))\r\n\r\nvalue.sort()\r\nmx = value[-1]\r\n\r\nfor i in range(n):\r\n ans += (mx * (len(s) + i + 1))\r\n\r\nprint(ans)\r\n", "s = list(input())\r\nk = int(input())\r\nw = list(map(int, input().split(\" \")))\r\nlength = len(w) + k\r\nans= []\r\nfor i in s:\r\n ans.append(w[ord(i)-97])\r\nwhile k > 0:\r\n ans.append(max(w))\r\n k -= 1\r\nres = 0\r\nfor j in range(len(ans)):\r\n res += (j+1)*ans[j]\r\nprint(res)\r\n", "from sys import stdin,stdout\r\nfrom collections import Counter\r\ndef ai(): return list(map(int, stdin.readline().split()))\r\ndef ei(): return map(int, stdin.readline().split())\r\ndef ip(): return int(stdin.readline().strip())\r\ndef op(ans): return stdout.write(str(ans) + '\\n')\r\nfrom math import ceil\r\n\r\ns= input()\r\nn = ip()\r\nli = ai()\r\nans = 0\r\nfor i in range(len(s)):\r\n\tans += (i+1)*li[(ord(s[i])-97)]\r\nx = max(li)\r\nfor i in range(len(s)+1,len(s)+n+1):\r\n\tans += i*x\r\nop(ans)\r\n", "s=input()\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nz=len(s)+n\r\nx=[0]*z\r\nfor i in range(1,n+1):\r\n x[-i]=(z-i+1)*max(l)\r\nfor i in range(len(s)):\r\n x[i]=(i+1)*l[ord(s[i])-97]\r\nprint(sum(x))", "s = input()\r\nk = int(input())\r\nw = list(map(int,input().split()))\r\n\r\nmaxW = w[0]\r\nmaxS = \"a\"\r\nfor j in range(1,26):\r\n if maxW<w[j]:\r\n maxW = w[j]\r\n maxS = chr(97+j)\r\n\r\ns+=maxS*k\r\nres = 0\r\nfor i in range(len(s)):\r\n res += (i+1)*w[ord(s[i])-ord(\"a\")]\r\n\r\nprint(res)\r\n\r\n", "s=list(input())\r\nk=int(input())\r\na=list(map(int,input().split()))\r\nb=[a[i] for i in range(len(a))]\r\nb.sort()\r\nc=0\r\nfor j in range(len(s)):\r\n\tc=c+(j+1)*a[ord(s[j])-97]\r\n# print(c)\r\ni=len(s)+1\r\nfor j in range(k):\r\n\tc=c+i*b[-1]\r\n\ti=i+1\r\nprint(c)", "from collections import defaultdict\r\ns=\"abcdefghijklmnopqrstuvwxyz\"\r\ns1=input()\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nd=defaultdict(int)\r\nfor i in range(len(s)):\r\n d[s[i]]=l[i]\r\ncount=1\r\nts=0\r\nfor i in range(len(s1)):\r\n ts+=d[s1[i]]*count\r\n count+=1\r\ncount-=1\r\n#print(ts)\r\nk1=max(d.values())\r\nfs=(count*(count+1))//2\r\n#print(fs)\r\nk2=count+n\r\nk2=(k2*(k2+1))//2\r\n#print(k2)\r\nk2=k2-fs\r\nts+=k2*k1\r\nprint(ts)\r\n", "s=input()\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\n\r\nc=0\r\nfor i in range(len(s)):\r\n\tp=ord(s[i])-97\r\n\tc+=(i+1)*w[p]\r\nfor i in range(len(s)+1,len(s)+k+1):\r\n\tc+=i*max(w)\r\nprint(c)", "s=input()\r\nk=int(input())\r\narr=list(map(int,input().split(\" \")))\r\nm=max(arr)\r\nans=0\r\nfor i in range(1,len(s)+k+1):\r\n if i<=len(s):\r\n word=s[i-1]\r\n ans+=i*arr[ord(word)-97]\r\n else:\r\n ans+=i*m\r\nprint(ans)", "def f(s):\r\n v=0\r\n for i in range(len(s)):\r\n v+=d[s[i]]*(i+1)\r\n return v\r\n \r\n\r\n\r\ns=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nd={}\r\nm=0\r\nmax_character=''\r\nfor i in range(len(l)):\r\n d[chr(97+i)]=l[i]\r\n if l[i]>m:\r\n m=l[i]\r\n max_character=chr(97+i)\r\n\r\n\r\nfor i in range(k):\r\n s+=max_character\r\n\r\nprint(f(s))\r\n\r\n", "string=input()\r\nnumadd=int(input())\r\nlval1=input().split(' ')\r\nlval=[int(x) for x in lval1]\r\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']\r\nmaxvalue=lval.index(max(lval))\r\nstring+=numadd*alphabet[maxvalue]\r\nperfect=0\r\nfor charsa in range(1, len(string)+1):\r\n perfect+=charsa*int(lval[alphabet.index(string[charsa-1])])\r\nprint(perfect)\r\n", "import string\r\ns = input()\r\nk = int(input())\r\nw = [int(x) for x in input().split()]\r\ntotal = 0\r\ni = 1\r\nwhile i<= len(s):\r\n d = string.ascii_lowercase.index(s[i-1])\r\n total = total + i*w[string.ascii_lowercase.index(s[i-1])]\r\n i = i+1\r\nw.sort()\r\nj = len(s)+1\r\nwhile j <= len(s)+k:\r\n total = total + w[-1]*j\r\n j = j+1\r\nprint(total)", "s=input()\r\nn=int(input())\r\nL=[int(i) for i in input().split()]\r\nm=max(L)\r\nans=0\r\nfor j in range(len(s)+n):\r\n\tif(j<len(s)):\r\n\t\tans+=L[ord(s[j])-97]*(j+1)\t\r\n\telse:\r\n\t\tans+=m*(j+1)\r\nprint(ans)\t", "s=input()\r\nn=int(input())\r\nvalue=0\r\nl=list(map(int,input().split()))\r\nk=max(l)\r\nfor i in range(n+len(s)):\r\n if(i<len(s)):\r\n value+=((i+1)*(l[ord(s[i])-ord('a')]))\r\n else:\r\n value+=((i+1)*k)\r\nprint(value)\r\n", "S = list(map(lambda x: ord(x) - ord('a'), list(input())))\nN = int(input())\nW = list(map(int, input().split()))\nS = S + [W.index(max(W))] * N\nprint(sum([(i + 1) * W[v] for i, v in enumerate(S)]))\n", "s=input()\r\ns1=''\r\ns2=''\r\nans=0\r\nn=int(input())\r\narr=list(map(int,input().split()))\r\na=['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\ns1+=n*(a[arr.index(max(arr))])\r\ns2=s+s1\r\nfor i in range (1,len(s2)+1):\r\n ans+=i*arr[a.index(s2[i-1])]\r\nprint(ans)\r\n", "t = input()\r\nb = int(input())\r\nd = list(map(int,input().split()))\r\nr = 0\r\nfor i in range(len(t)):\r\n\tr = r + (i+1)*d[ord(t[i])- 97]\r\nprint(r+max(d)*((b*len(t))+(b*(b+1))//2))", "s = input()\r\nk = int(input())\r\na = [int(x) for x in input().split()]\r\nb = [chr(x) for x in range(97,123)]\r\nj = 1\r\nproduct = 0\r\nfor i in range(len(s)):\r\n product += j*a[b.index(s[i])]\r\n j += 1\r\np = 1\r\nwhile p <= k:\r\n product += j*int(max(a))\r\n j += 1\r\n p += 1\r\nprint(product)\r\n", "import sys\nfrom collections import defaultdict\nfrom heapq import nlargest\nInput=lambda:map(int,input().split())\n\ns = input()\nt = len(s)\nk = int(input())\nSUM = 0\nw = list(Input())\nfor i in range(1,t+1):\n SUM+=(i*w[ord(s[i-1])-97])\na = max(w)\nfor i in range(t+1,t+k+1):\n SUM+=(i*a)\n\nprint(SUM)\n\n\n\n", "inp = input()\r\nN = int(input())\r\narr = input().split(' ')\r\nfor i in range(len(arr)):\r\n arr[i] = int(arr[i])\r\nmax = max(arr)\r\nsum = 0\r\nfor i in range(len(inp)):\r\n sum += int(arr[ord(inp[i]) - 97]) * (int(i)+1)\r\nfor i in range(N):\r\n sum += (i+len(inp)+1)* max\r\n\r\nprint(sum)", "import math\r\nfrom sys import stdin, stdout\r\ninput, print = stdin.readline, stdout.write\r\n\r\n\r\ndef str_input():\r\n s = input()\r\n return s[:len(s)-1]\r\n\r\n\r\ndef char_list_input():\r\n s = input()\r\n return list(s[:len(s)-1])\r\n\r\n\r\ndef list_input(type):\r\n return list(map(type, input().split()))\r\n\r\n\r\ndef multi_input():\r\n return map(int, input().split())\r\n\r\n\r\ndef main():\r\n s = str_input()\r\n n = int(input())\r\n a = list_input(int)\r\n mval = max(a)\r\n i = 0\r\n ans = 0\r\n for ch in s:\r\n i += 1\r\n ind = ord(ch)-ord('a')\r\n ans += i*a[ind]\r\n for i in range(len(s)+1, len(s)+n+1):\r\n ans += i*mval\r\n print(f\"{ans}\\n\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "a=input()\r\nk=int(input())\r\nz=list(map(int,input().split()))\r\nresult=0\r\nfor i in range(len(a)):\r\n result+=z[(ord(a[i])-97)]*(i+1)\r\nfor i in range (k):\r\n result+=max(z)*(i+1+len(a))\r\nprint(result)\r\n", "s = input()\r\na= int(input())\r\nb= list(map(int,input().split()))\r\nd = max(b)\r\ne = 0\r\nfor i in range(1,len(s)+1):\r\n g = s[i-1]\r\n\r\n e+= i*b[ord(g)-97]\r\n \r\n \r\nfor i in range(len(s)+1,len(s)+1+a):\r\n e+=i*d\r\nprint(e)\r\n ", "try:\r\n s = input()\r\n k = int(input())\r\n c = list(map(int, input().split()))\r\n x = max(c)\r\n cost = 0\r\n for i in range(len(s)):\r\n cost += c[ord(s[i])-97]*(i+1)\r\n for i in range(len(s), len(s)+k):\r\n cost += (i+1)*max(c)\r\n print(cost)\r\nexcept:\r\n pass", "s = input()\r\nk = int(input())\r\nl = list(map(int,input().split()))\r\nd = ['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\nsum = 0\r\nfor num in range(len(s)):\r\n sum += (num+1)*(l[d.index(s[num])])\r\nt = max(l)\r\nfor n in range(k):\r\n sum += t*(len(s)+(n+1))\r\nprint(sum)", "import sys\r\narr = ['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\ndef fn(s,k,a):\r\n b = a.copy()\r\n l = len(s)\r\n v = 0\r\n l1= []\r\n for i in range(l):\r\n v = v + a[arr.index(s[i])]*(i+1)\r\n for i in range(k):\r\n v = v + max(a)*(i+l+1)\r\n \r\n return v \r\n \r\n \r\nif __name__ == '__main__': \r\n input = sys.stdin.read()\r\n data = list(map(str, input.split()))\r\n s = list(data[0])\r\n k = int(data[1])\r\n a = list(map(int,data[2:]))\r\n print(fn(s,k,a))", "\r\n\r\nk = input()\r\nn = int(input())\r\nl = list(map(int,input().split()))\r\nal = ['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\n\r\nz = sorted(l)[-1]\r\nm = len(k) + n\r\ncount = 0\r\nsum = 0\r\nfor i in range(1,m+1):\r\n if count<=len(k)-1:\r\n ind = al.index(k[count])\r\n sum+=l[ind]*i\r\n count+=1\r\n\r\n else:\r\n sum+=z*i\r\nprint(sum)\r\n\r\n\r\n", "s = input().strip()\nk = int(input().strip())\narr = list(map(int, input().strip().split()))\nn = len(s)\nx = max(arr)\nans = 0\nfor i in range(1, n+1):\n\tans += i*arr[ord(s[i-1])-97]\nfor i in range(n+1, n+k+1):\n\tans += i*x\nprint(ans)", "s = list(input())\r\nn = int(input())\r\nw = list(map(int, input().split()))\r\n\r\ndef getPos(char):\r\n return ord(char) - 97\r\n\r\nsize_string = 0\r\n\r\nfor i in range(len(s)):\r\n size_string += w[getPos(s[i])] * (i+1)\r\n\r\nmax_w = max(w)\r\n\r\nfor i in range(len(s)+1, len(s)+n+1):\r\n size_string += i*max_w\r\n\r\nprint(size_string)", "import string\r\ns=input()\r\nn=int(input())\r\nl=[int(x) for x in input().split()]\r\nd={}\r\nval=0\r\nlc=[x for x in(string.ascii_lowercase)]\r\nfor i in range(26):\r\n d[lc[i]]=l[i]\r\nle=len(s)\r\nm=max(l)\r\nfor i in range(le):\r\n val=val+(i+1)*d[s[i]]\r\nfor i in range(n):\r\n val=val+((le+i+1)*m)\r\n\r\nprint(val)\r\n", "s=input()\r\nn=int(input())\r\nx=list(map(int,input().split()))\r\nans=0\r\nfor i in range(len(s)):\r\n ans+=(i+1)*(x[ord(s[i])-97])\r\nxx=len(s)+1\r\nfor i in range(n):\r\n ans+=xx*max(x)\r\n xx+=1\r\nprint(ans)", "p=input().rstrip()\r\nx=list(p)\r\nk=int(input())\r\ns=0;\r\nQ=input().rstrip().split(' ')\r\nfor i in range(0,len(x)):\r\n t=(i+1)*int(Q[ord(x[i])-97])\r\n s=s+t;\r\nQ.sort(key=int,reverse=True)\r\nfor i in range(0,k):\r\n t=(len(x)+i+1)*int(Q[0])\r\n s=s+t;\r\nprint(s)\r\n", "import string\r\ns = input()\r\nn = int(input())\r\n\r\nalphabet = string.ascii_lowercase\r\n\r\nvalues = input().split()\r\nmax = 0\r\n\r\nadict={}\r\nfor a in range(len(values)):\r\n values[a] = int(values[a])\r\n adict[alphabet[a]] = (values[a])\r\n if values[a]>max:\r\n max = values[a]\r\n \r\ntotal = 0\r\nfor a in range(len(s)):\r\n total += ((a+1)*adict[s[a]])\r\n\r\nb = len(s)\r\nc = 0\r\nwhile c<n:\r\n b+=1\r\n total += (b*max)\r\n c+=1\r\nprint(total) ", "s = input()\nk = int(input())\na = list(map(int, input().split()))\nl = 'abcdefghijklmnopqrstuvwxyz'\nd = {}\ntotal_sum = 0\nfor p in range(len(l)):\n d[l[p]] = a[p]\nfor i in range(len(s)):\n total_sum += (i + 1) * d[s[i]]\nfor j in range(k):\n total_sum += (j + 1 + len(s)) * max(a)\nprint(total_sum)\n", "s = input()\r\nk = int(input())\r\nl = [int(x) for x in input().split()]\r\ntotal = 0\r\nfor i in range(len(s)):\r\n total += (i+1)*(l[ord(s[i])-97])\r\nmaxi = max(l)\r\nwhile(k>0):\r\n i+=1\r\n total += (i+1)*maxi\r\n k-=1\r\nprint(total)\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\n\r\nvalue = 0\r\nmaximum = max(w)\r\n\r\nfor i in range(len(s)):\r\n value += (i + 1) * w[ord(s[i]) - ord('a')]\r\n\r\nfor j in range(len(s) + 1, len(s) + k + 1):\r\n value += maximum * j\r\n\r\nprint(value)\r\n", "def alphabet_position(x):\n return ord(x) & 31\n\ns = input()\nn = int(input())\nsize = len(s)\nl = list(map(int, input().split()))\nmax = max(l)\nans = 0\nfor i in range(size+1,size+n+1):\n ans += (i * max)\nfor i in range(1,len(s)+1):\n ans += (i * l[alphabet_position(s[i-1])-1])\nprint(ans)\n\t\t \t\t \t \t\t\t \t \t\t \t\t\t \t\t\t\t \t\t", "import string\r\ns = input()\r\nk = int(input())\r\nlst = list(map(int, input().split()))\r\nd = {}\r\ni = 0\r\nfor e in string.ascii_lowercase:\r\n d[e] = lst[i] \r\n i += 1\r\nm = max(d.values())\r\nchar = ''\r\nfor i,v in d.items():\r\n if v == m:\r\n char = i\r\n break\r\ns += char*k\r\nscore = 0\r\ni = 1\r\nfor e in s:\r\n score += d[e]*i\r\n i += 1\r\nprint(score)", "def index_(letter):\r\n import string\r\n key = string.ascii_lowercase.index(letter)\r\n return key\r\n\r\n\r\ns = input()\r\nk = int(input())\r\na = []\r\nb = []\r\nsum = 0\r\na = input().split()\r\nfor i in range(26):\r\n ele = int(a[i])\r\n b.append(ele)\r\nfor i in range(len(s)):\r\n sum =sum + (i+1)*b[index_(s[i])]\r\nfor i in range(len(s)+1, len(s)+k+1):\r\n sum =sum + i*max(b)\r\nprint(sum)\r\n", "s=str(input())\r\nk=int(input())\r\na=[int(x) for x in input().split()]\r\n\r\nans=0\r\nl=len(s)\r\nfor i in range(0,l):\r\n ans+=(i+1)*a[ord(s[i])-97]\r\n# print(ans)\r\nmaxi=max(a)\r\nans+=maxi*(l*k+(k*(k+1))/2)\r\nprint(int(ans))\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\ns = input()[:-1]\r\nx = len(s)\r\nn = int(input())\r\nw = list(map(int, input().split()))\r\nc = 0\r\nc = sum(range(len(s)+1, x+1+n)) * max(w)\r\n\r\nfor i in range(1, x+1):\r\n c += w[ord(s[i-1])-97] * i\r\nprint(c)\r\n", "# cook your dish here\r\nal=[chr(i) for i in range(97,97+26)]\r\ns=input()\r\nn=int(input())\r\nx=list(map(int,input().split()))\r\ny=max(x)\r\nz=al[x.index(y)]\r\ns=s+(z*n)\r\nsum=0\r\nfor i in range(len(s)):\r\n sum+=(i+1)*x[al.index(s[i])]\r\nprint(sum)\r\n", "from string import ascii_lowercase as lower\r\ns=input()\r\nk = int(input())\r\nlis = list(map(int,input().split()))\r\nx={}\r\nfor i,j in zip(lower,lis):\r\n x[i]=j\r\nval=0\r\nnxt=1\r\nfor i in s:\r\n val+=nxt*x[i]\r\n nxt+=1\r\nma = max(x,key=x.get)\r\nres = [x for x in range(len(s)+1,len(s)+k+1)]\r\nfor i in res:\r\n val+=i*x[ma]\r\nprint(val)", "s=input()\r\nk=int(input())\r\nl=[int(i) for i in input().split()]\r\nval=0\r\nfor i in range (0,len(s)):\r\n val=val+l[ord(s[i])-97]*(i+1)\r\nl.sort()\r\nval=val+(k*(k+2*(len(s))+1)*l[-1])//2\r\nprint(val)", "# http://codeforces.com/problemset/problem/447/B\n\na = list(input())\nn = int(input())\nb = list(map(int, input().split()))\n\nres = 0\n\nfor i in range(len(a)):\n kod = ord(a[i]) - 97\n res+= b[kod]*(i+1)\n\nfor i in range(n):\n res+= max(b)*(len(a)+i+1)\nprint(res)\n", "'''input\nmmzhr\n3\n443 497 867 471 195 670 453 413 579 466 553 881 847 642 269 996 666 702 487 209 257 741 974 133 519 453\n'''\n\ndef main():\n\n\n s = input()\n k = int(input())\n val = list(map(int, input().split()))\n maxVal = max(val)\n\n # print(maxVal)\n stringVal = 0\n for index, i in enumerate(s):\n stringVal += (index+1)*val[ord(i) - ord('a')]\n\n print(stringVal + (k*len(s) + (k*(k+1))//2)*maxVal)\n\n\n\n\n\n\nif __name__ == '__main__':\n main()\n", "first=list(input())\r\ndigits=int(input())\r\nvalues=[int(i) for i in input().split()]\r\nletters=list(\"abcdefghijklmnopqrstuvwxyz\")\r\nmaxvalue=max(values)\r\nwordvalues=[]\r\nfor i in first:\r\n\tindex=letters.index(i)\r\n\twordvalues.append(values[index])\r\ncount=0\r\nwhile count!=digits:\r\n\twordvalues.append(maxvalue)\r\n\tcount+=1\r\nfinalvalue=0\r\nfor i in range(len(wordvalues)):\r\n\tfinalvalue+= wordvalues[i]*(i+1)\r\nprint(finalvalue)\r\n\r\n\t", "a = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\n\r\nresult = 0\r\nfor i in range(len(a)):\r\n result += (i+1)*w[ord(a[i])-ord('a')]\r\n\r\nfor i in range(len(a),len(a)+k):\r\n result += (i+1)*max(w)\r\nprint(result)", "s, k = input(), int(input())\nw = [int(i) for i in input().split()]\nres = sum((i + 1) * w[ord(c) - ord(\"a\")] for i, c in enumerate(s)) + max(w) * sum(i + 1 + len(s) for i in range(k))\nprint(res)\n", "m = list(input())\nstr = [int(ord(x)-97) for x in m]\nk = int(input())\narray = [int(x) for x in input().split(\" \")]\n\nlargest = 0\nfor x in array:\n if(x > largest):\n largest = x\n\n\ntot = 0\n\nfor x in range(len(str)):\n tot += (x+1)*array[str[x]]\n\nfor x in range(k):\n tot += (x+len(str)+1)*largest\n\n\t\n\nprint(tot)\n", "s=input()\r\nk=int(input())\r\nx=input()\r\nxx=x.split( )\r\nfor i in range(0,26):\r\n xx[i]=int(xx[i])\r\nh={'a':xx[0],'b':xx[1],'c':xx[2],'d':xx[3],'e':xx[4],'f':xx[5],'g':xx[6],'h':xx[7],'i':xx[8],'j':xx[9],'k':xx[10],'l':xx[11],'m':xx[12],'n':xx[13],'o':xx[14],'p':xx[15],'q':xx[16],'r':xx[17],'s':xx[18],'t':xx[19],'u':xx[20],'v':xx[21],'w':xx[22],'x':xx[23],'y':xx[24],'z':xx[25]}\r\nt=0\r\nfor i in range(0,len(s)):\r\n t+=((i+1)*h[s[i]])\r\ny=max(xx)\r\nn=len(s)+k\r\nj=len(s)\r\njj=j*(j+1)/2\r\nnn=n*(n+1)/2\r\nll=nn-jj\r\nt+=(ll*y)\r\nprint(int(t))\r\n", "n=input()\nk=int(input())\nl=list(map(int, input().split()))\nx=max(l)\nans=0\nj=1\nfor i in n:\n\tans+=(l[ord(i)-97]*j)\n\tj+=1\nan=j+(k-1)\nans+=((k*(j+an)//2)*x)\nprint(ans)\n", "n=input()\r\nk=int(input())\r\nq=input().split(\" \")\r\nq=list(map(int,q))\r\n# q.sort(reverse=True)\r\nw=max(q)\r\nsum=0\r\ns=len(n)+k\r\nfor i in range (k):\r\n # print(len(n)+k-i,q[i])\r\n # print(s,i,w)\r\n sum+=(s-i)*w\r\n # print(sum)\r\nfor i in range (len(n)):\r\n y=(ord(n[i]))\r\n # print(q[97-y])\r\n sum+=(i+1)*q[abs(97-y)]\r\nprint(sum)", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\ne=max(l)\r\nans=0\r\nfor i in range(len(s)+k):\r\n if i<len(s):\r\n ans+=(i+1)*l[ord(s[i])-97]\r\n else:\r\n ans+=(i+1)*e\r\n\r\nprint(ans)\r\n", "s = input()\r\nk = int(input())\r\nval = list(map(int, input().split()))\r\nans=0\r\nfor i in range(len(s)):\r\n ans+=(i+1)*val[ord(s[i])-ord(\"a\")]\r\nmaxi=max(val)\r\nfor i in range(len(s),len(s)+k):\r\n ans+=(i+1)*maxi\r\nprint(ans)", "s=input()\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\nans=0\r\nn=len(s)\r\nfor i in range(n):\r\n ans+=w[ord(s[i])-ord('a')]*(i+1)\r\nw.sort()\r\nprint(ans+(2*n+k+1)*k//2*w[25])", "from sys import*\r\ninput= stdin.readline\r\ns=input()\r\nd=int(input())\r\nl=list(map(int,input().split()))\r\nm=max(l)\r\nn=len(s.strip())\r\nc=0\r\nfor i in range(n):\r\n x=ord(s[i])-97\r\n c+=l[x]*(i+1)\r\nfor i in range(n+1,n+d+1):\r\n c+=(m*i)\r\nprint(c)\r\n ", "string=input()\r\nasci=[]\r\nfor letter in string:\r\n\tasci.append(ord(letter)-97)\r\nn=int(input())\r\nvalues=list(map(int,input().split()))\r\nmaxValue=max(values)\r\ncount=1\r\ns=0\r\nfor i in asci:\r\n\ts+=values[i]*count\r\n\tcount+=1\r\nfor i in range(n):\r\n\ts+=maxValue*count\r\n\tcount+=1\r\nprint(s)\r\n\t", "# your code goes here\r\n# your code goes here\r\n# your code goes here\r\ns = input()\r\nk = int(input())\r\nw = [int(x) for x in input().split()]\r\nx = max(w)\r\nans = 0\r\n\r\nfor i in range(1, len(s)+1):\r\n\tans += i * w[ord(s[i-1]) - ord('a')]\r\n\r\nfor i in range(len(s)+1, len(s)+1+k):\r\n\tans += i * x\r\n\t\r\nprint(ans)\r\n", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nm=max(l)\r\nans=0\r\nfor i in range(len(s)):\r\n ans+=(i+1)*l[ord(s[i]) - ord('a')]\r\n \r\nfor i in range(len(s)+1, len(s)+1+k):\r\n ans+=i*m\r\n \r\nprint(ans)\r\n\r\n \r\n ", "s=input()\r\nl=int(input())\r\nw=list(map(int,input().split()))\r\na=['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\nf=0\r\nz=len(s)\r\ny=max(w)\r\nfor i in range(z):\r\n k=a.index(s[i:i+1])\r\n f=f+(i+1)*w[k]\r\nfor i in range(l):\r\n f=f+(z+i+1)*y\r\nprint(f)", "s=input()\r\nk=int(input())\r\nar=list(map(int,input().split(' ')))\r\n# print(ar)\r\n# print(n)\r\n# print(chr(122))\r\n\r\ndict={}\r\nfor i in range(26):\r\n dict[chr(i+97)]=ar[i]\r\n\r\n# print(dict)\r\n# print(dict['b'])\r\nscore=0\r\nfor i in range(len(s)):\r\n score+= dict[str(s[i])]*(i+1)\r\n\r\nfor i in range(len(s)+1,k+len(s)+1):\r\n score+=max(ar)*i\r\nprint(score)", "a = input()\r\nk = int(input())\r\nb = list(map(int,input().split()))\r\nans = 0\r\nfor i in range(1,len(a)+1):\r\n ans+=i*b[ord(a[i-1])-ord('a')]\r\nma = max(b)\r\nfor i in range(k):\r\n ans+=(i+len(a)+1)*ma\r\nprint(ans)", "s=input()\r\nk=int(input())\r\nw=list(map(int,input().split()))\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\nu=max(w)\r\np=0\r\n\r\nfor i in range(len(s)):\r\n p+=(i+1)*w[x.index(s[i])]\r\nfor i in range(k):\r\n p+=(i+len(s)+1)*u\r\n \r\nprint(p)\r\n \r\n", "import sys\r\nlst = ['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\ndict1={}\r\ns = input()\r\nk = int(input())\r\nlst1=list(map(int,input().split()))\r\nfor i in range(len(lst)):\r\n dict1[lst[i]]= lst1[i]\r\n \r\nmaxi = -sys.maxsize -1\r\ntot =0\r\nfor i in range(len(s)):\r\n tot = tot + dict1[s[i]]*(i+1)\r\nmaxi = max(lst1)\r\n\r\nfor j in range(k):\r\n tot += maxi*(len(s)+j+1)\r\n \r\nprint(tot)", "s = list(input())\r\nk = int(input())\r\na = [int(i) for i in input().split()]\r\nv = 0\r\nfor i, d in enumerate(s):\r\n v += (i + 1) * a[ord(d) - 97]\r\nm = max(a)\r\nfor j in range(k):\r\n v += m * (j + i + 2)\r\n #print(m, j + i + 2)\r\nprint(v)", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nmp = dict()\r\nx = 'a'\r\nfor i in range(len(w)):\r\n mp[chr(i+ord('a'))] = w[i]\r\n\r\nans = 0\r\nln = len(s)\r\nfor i in range(ln):\r\n ans += mp[s[i]]*(i+1)\r\n# print(ans)\r\nmx = max(w)\r\nml = ln + k\r\nmul = (ml*(ml+1))//2 - (ln*(ln+1))//2\r\nans += mul*mx\r\nprint(ans)\r\n", "import sys\r\nfrom math import *\r\nfrom collections import Counter, defaultdict, deque\r\ninput = sys.stdin.readline\r\nmod = 10**9+7\r\n\r\ns = input()\r\ns = list(s)\r\ns.pop()\r\nk = int(input())\r\narr = [int(i) for i in input().split()]\r\nt = max(arr)\r\nans = 0\r\ncount = 1\r\nfor i in range(len(s)):\r\n ans += (arr[ord(s[i])-ord('a')])*count\r\n count += 1\r\nfor i in range(len(s), len(s)+k):\r\n ans += t*count\r\n count += 1\r\nprint(ans)\r\n", "s=input()\r\ns=list(s)\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nx=max(l)\r\nc=0\r\nfor i,j in enumerate(s):\r\n h=(ord(j)-97)\r\n c+=(i+1)*(l[h])\r\nprint(\"\")\r\nfor j in range(i+2,i+n+2):\r\n h=x*j\r\n c+=h\r\nprint(c)", "\ndef solve(s,k,w):\n ans = 0\n for i in range(len(s)):\n ans += (i+1)*w[ord(s[i])-ord('a')]\n maxi = max(w)\n for i in range(len(s),len(s)+k):\n ans += (i+1)*maxi\n return ans\n\n\n\n\n\nif __name__ == '__main__':\n t = 1\n while t:\n s = input()\n k = int(input())\n w = list(map(int,input().split()))\n print(solve(s,k,w))\n t -= 1\n", "s = input()\nk = int(input() )\nw = list(map(int,input().split() ) )\nr = sum([(i+1) * w[ord(s[i]) - ord('a') ] for i in range(len(s) ) ] )\n\nmx = max(w)\nr += sum([(i + len(s) + 1) * mx for i in range(k) ] )\nprint(r)\n", "s,n=input(),int(input())\nl,out=list(map(int,input().split())),0\nfor i in range(len(s)):\n out+=l[(ord(s[i])-97)]*(i+1)\nfor i in range(len(s),len(s)+n):\n out+=(i+1)*max(l)\nprint(out)\n \t\t\t \t\t\t \t \t \t \t \t\t", "n = input()\r\nm = int(input())\r\nl = list(map(int, input().split()))\r\nc = l.index(max(l))\r\nfor j in range(m):\r\n n+=chr(ord('a')+c)\r\ns = 0\r\nfor i in range(len(n)):\r\n s+=(i+1)*(l[ord(n[i])-ord('a')])\r\nprint(s)\r\n", "s=input()\r\nk=int(input())\r\nn='abcdefghijklmnopqrstuvwxyz'\r\nd={}\r\nl=list(map(int,input().split()))\r\nm=max(l)\r\nfor i in range(len(n)):\r\n d[n[i]]=l[i]\r\nres=0\r\nfor i in range(len(s)):\r\n res=res+((i+1)*d[s[i]])\r\nfor i in range(k):\r\n res=res+(len(s)+i+1)*m\r\nprint(res)", "import sys\r\n\r\ninput = lambda: sys.stdin.buffer.readline().decode().strip()\r\n# print = sys.stdout.write\r\ninl = lambda: list(map(int, input().split()))\r\n\r\n\r\ndef char_pos(letter):\r\n return ord(letter) - 97\r\n\r\n\r\ndef char_from_pos(pos):\r\n return chr(pos + 97)\r\n\r\n\r\ns = list(input())\r\nk = int(input())\r\nw = inl()\r\n\r\nmax_char = char_from_pos(w.index(max(w)))\r\ns.extend([max_char] * k)\r\n\r\nans = [(i + 1) * w[char_pos(let)] for i, let in enumerate(s)]\r\nprint(sum(ans))\r\n", "def main():\n s = [ord(i) - ord('a') for i in input()]\n k = int(input())\n w = [int(i) for i in input().split()]\n \n s = [w[i] for i in s] + [max(w) for i in range(k)]\n \n result = 0\n for i in range(len(s)):\n result += s[i] * (i + 1)\n \n print(result)\n\n\nmain()\n", "alph = \"abcdefghijklmnopqrstuvwxyz\"\r\ns = input()\r\n\r\nk = int(input())\r\nl = list(map(int, input().split()))\r\nm = max(l)\r\nsu = 0\r\nfor i, v in enumerate(s):\r\n su += (i+1)*(l[alph.index(v)])\r\n\r\nfor i in range(len(s)+1, len(s)+1+k):\r\n su += i*m\r\nprint(su)\r\n", "s = input()\r\nk = int(input())\r\na = list(map(int, input().split()))\r\nans = 0\r\nt = 0\r\nfor i in s:\r\n t += 1\r\n ans += a[ord(i) - ord('a')] * (t)\r\nx = max(a)\r\nans += ((len(s) + k) * (len(s) + k + 1) // 2 - len(s) * (len(s) + 1) // 2) * x\r\nprint(ans) ", "def dzy(s, k, lst):\r\n m, result = max(lst), 0\r\n for i in range(1, len(s) + 1):\r\n result += lst[ord(s[i - 1]) - ord('a')] * i\r\n for i in range(len(s) + 1, len(s) + 1 + k):\r\n result += m * i\r\n return result\r\n\r\n\r\nt = input()\r\nK = int(input())\r\na = [int(j) for j in input().split()]\r\nprint(dzy(t, K, a))\r\n", "s = input()\r\nk = int(input())\r\nl = list(map(int,input().split()))\r\nm = max(l)\r\nn = len(s)\r\nc = 0\r\nfor i in range(n):\r\n c += (i+1)*l[ord(s[i])-97]\r\n \r\nfor i in range(n+1,n+1+k):\r\n c += i*m\r\n \r\nprint(c)\r\n", "s=input()\r\nk=int(input())\r\nans=0\r\nl=[int(i) for i in input().split()]\r\nfor i in range(len(s)):\r\n ans+=((i+1)*(l[(ord(s[i])-97)]))\r\nfor i in range(len(s)+1,len(s)+k+1):\r\n ans+=(i*max(l))\r\nprint(ans)", "s = input()\r\nn = int(input())\r\nw = list(map(int, input().split(\" \")))\r\nk = max(w)\r\nans = 0\r\nit = 0\r\nfor lit in s:\r\n it += 1\r\n ans += w[ord(lit)-ord('a')]*it\r\nfor i in range(n):\r\n it += 1\r\n ans += k*it\r\nprint(ans)", "s = input()\nk = int(input())\nwi = list(map(int, input().split()))\nres = 0\nfor i in range(len(s)):\n\tres += wi[ord(s[i])-97]*(i+1)\nprint(res+max(wi)*(k*(k+1)//2 + len(s)*k))", "nn = str(input())\r\nextra = int(input())\r\nv = str(input())\r\nv1 = v.split()\r\nmaxs = 0\r\ndicts = {}\r\ncounter = 97\r\nfor i in v1:\r\n k = int(i)\r\n if int(i) > maxs:\r\n maxs = k \r\n dicts[chr(counter)] = k \r\n counter += 1 \r\ntotal = 0\r\nc = 1\r\nfor i in nn:\r\n total += c * dicts[i]\r\n c += 1 \r\n\r\nfor i in range(extra):\r\n total += c * maxs \r\n c += 1\r\nprint(total)", "s = input()\r\nk=int(input())\r\nL=list(map(int,input().split()))\r\n\r\nv = max(L)\r\nS = 0\r\nSS = 0\r\nLeft = []\r\nvL = []\r\nvR = []\r\nfor i in range(len(s)):\r\n x = ord(s[i])-ord('a')\r\n S+=L[x]*(i+1)\r\n SS+=L[x]\r\n Left.append(S)\r\n vL.append(SS)\r\nRight = []\r\nSS = 0\r\nS = 0\r\nfor i in range(len(s)-1,-1,-1):\r\n x = ord(s[i])-ord('a')\r\n S+=L[x]*(i+1)\r\n SS+=L[x]\r\n Right=[S]+Right\r\n vR=[SS]+vR\r\nans = (((1+k)*k)//2)*v+S\r\nf = (((1+k)*k)//2)*v\r\nfor i in range(len(s)):\r\n x = ord(s[i])-ord('a')\r\n inc = i+2\r\n tmp = Left[i]+((((inc+inc-1+k)*k))//2)*v\r\n\r\n if(i+1<len(s)):\r\n tmp += Right[i+1]+k*vR[i+1]\r\n ans=max(ans,tmp)\r\nprint(ans)\r\n\r\n", "from sys import stdin,stdout\nfrom math import sqrt\nnmbr = lambda: int(stdin.readline())\nlst = lambda: list(map(int, stdin.readline().split()))\ns=list(input())\nk=nmbr()\na=lst();sm=0\nfor i in range(len(s)):\n sm+=(i+1)*a[ord(s[i])-97]\nmx=max(a)\np=len(s)+1\nwhile k>0:\n sm+=p*mx\n p+=1\n k-=1\nprint(sm)\n \t\t\t \t \t\t \t\t\t \t \t \t\t\t\t \t\t", "s = input()\r\nk = int(input())\r\ndata = list(map(int, input().split()))\r\n\r\nresult = 0\r\nfor i in range(len(s)):\r\n result += (i+1)*data[ord(s[i])-ord('a')]\r\n\r\nmaximum = max(data)\r\nfor i in range(len(s),len(s)+k):\r\n result += maximum*(i+1)\r\n\r\nprint(result)", "s=input()\r\nk=int(input())\r\narr=list(map(int,input().split()));dict={};ans=0\r\nfor i in range(26):\r\n dict[chr(i+97)]=arr[i]\r\ndict={k:v for k,v in sorted(dict.items(),key=lambda x:x[1],reverse=True)}\r\nfor i in range(len(s)):\r\n ans+=(i+1)*dict[s[i]]\r\nfor i in range(k):\r\n ans+=(len(s)+i+1)*(max(dict.values()))\r\nprint(ans)", "s=input()\r\nk=int(input())\r\na=[int(x) for x in input().split()]\r\nw=0\r\nfor i in range(len(s)):\r\n\tw+=a[ord(s[i])-97]*(i+1)\r\nt=max(a)\r\nfor i in range(len(s)+1,len(s)+k+1):\r\n\tw+=t*i \r\nprint(w)", "\r\ns = input()\r\nn = int(input())\r\n#n, k = (map(int, input().split()))\r\n\r\ns1 = list(map(str, input().split()))\r\ndict =dict()\r\n#print(int('a'))\r\nfor i in range(0,26):\r\n dict[chr(ord('a')+i)] = int(s1[i])\r\n#for i in range(0, 26):\r\n# d[chr(i)+chr('a')] = s1[i]\r\n\r\nmax = 0\r\nfor i in range(0, len(s1)):\r\n if(int(s1[i])>max):\r\n max = int(s1[i])\r\n\r\ncount = 0\r\nfor i in range(0, len(s)):\r\n count +=(i+1)*dict[s[i]]\r\n\r\nfor j in range(len(s), len(s)+n):\r\n count += max*(j+1)\r\nprint(count)\r\n\r\n", "\r\ns = input()\r\nk = int(input())\r\nlst = list(map(int, input().split()))\r\ntot = 0\r\ni = 1\r\nfor c in s:\r\n tot += lst[ord(c) - 97] * i\r\n i+= 1\r\n\r\nn = len(s)\r\ntot += ((n+k)*(n+k+1) // 2 - n * (n + 1) // 2) * max(lst)\r\nprint(tot)", "a = list(input())\r\nn = int(input())\r\nw = list(map(int,input().split()))\r\n\r\ncount = 0\r\n\r\nfor i in range(len(a)):\r\n\tcount+= (i+1)*w[ord(a[i])-97]\r\n\r\nk = max(w)\r\nfor i in range(n):\r\n\tcount+= (len(a)+1+i)*k\r\n\r\nprint(count)\r\n", "s = input()\r\nk = int(input())\r\nd={}\r\np = list(map(int,input().split()))\r\nfor i in range(len(p)):\r\n d[chr(97+i)]=p[i]\r\nsum=0\r\ng=0\r\nfor i in s:\r\n g+=1\r\n if i in d.keys():\r\n sum+=(d[i]*g)\r\nfor i in range(k):\r\n g+=1\r\n sum+=(g*max(p))\r\nprint(sum)\r\n", "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\r\n# import math\r\n# from itertools import *\r\n# import random\r\n# import calendar\r\n# import datetime\r\n# import webbrowser\r\n\r\nstring = input()\r\nk = int(input())\r\narr = list(map(int, input().split()))\r\nsum_ = 0\r\nfor i in range(0, len(string)):\r\n temp = ord(string[i]) - 97\r\n sum_ += (i+1) * arr[temp]\r\narr.sort(reverse=True)\r\nfor i in range(len(string), len(string) + k):\r\n sum_ += (i+1) * arr[0]\r\nprint(sum_)\r\n", "s = input()\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nb = max(a)\r\nans, e = 0, 1\r\nfor i in range(n):\r\n s += chr(a.index(b) + 97)\r\nfor i in range(len(s)):\r\n ans += e * a[ord(s[i]) - 97]\r\n e += 1\r\nprint(ans)\r\n\r\n", "string = str(input())\r\nk = int(input())\r\nletters = list(map(int,input().split()))\r\nmE = max(letters)\r\nadd = 0\r\nfor i in range(len(string)):\r\n\tadd += (letters[(ord(string[i])-ord('a'))])*(i+1)\r\nfor i in range(len(string),len(string)+k):\r\n\tadd += mE*(i+1)\r\nprint(add)", "# -*- coding: utf-8 -*-\n\"\"\"Untitled55.ipynb\n\nAutomatically generated by Colaboratory.\n\nOriginal file is located at\n https://colab.research.google.com/drive/1v6PP0OshdTxKNIc5VZxU4RfLOIEQakeT\n\"\"\"\n\nx=input()\nn=int(input())\nl1=list(map(int,input().split()))\nl2=list(x)\nsum=0\nfor i in range(0,len(l2)):\n y=ord(l2[i])-97\n sum=sum+(i+1)*l1[y]\nc=max(l1)\nfor j in range(len(l2)+1,len(l2)+n+1):\n sum=sum+j*c\nprint(sum)", "# -----Arkp-----#\r\nfrom math import *\r\nfrom collections import defaultdict\r\n\r\ndef solve(s,k,l):\r\n res=0\r\n str_len=len(s)\r\n for i in range(str_len):\r\n res+=(l[ord(s[i])-97]*(i+1))\r\n # print(l[ord(s[i])-97])\r\n m=max(l)\r\n for i in range(str_len+1,str_len+k+1):\r\n res+=m*i\r\n return res\r\n\r\n\r\n\r\ns=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nprint(solve(s,k,l))", "s = input()\r\nk = int(input())\r\nwts = list(map(int, input().split()))\r\ntot = 0\r\nm = max(wts)\r\ni = 0\r\nwhile i<len(s):\r\n tot += (i+1)*wts[ord(s[i])-ord('a')]\r\n i += 1\r\ntot += m*(k*(2*(i+1)+(k-1))//2)\r\nprint(tot)\r\n", "s = input()\r\nk = int(input())\r\nlis = list(map(int,input().split()))\r\nsum = 0\r\nfor i in range(len(s)):\r\n sum += (1+i) * lis[(ord(s[i])-97)]\r\nx = max(lis)\r\ni = len(s)+1\r\nfor j in range(k):\r\n sum += i * x\r\n i += 1\r\nprint(sum)\r\n", "d={}\r\nfor i in range(97,123):\r\n d.update({chr(i):i-97})\r\n\r\ns=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nm=max(l)\r\nc=0\r\nfor i in range(len(s)):\r\n x=d[s[i]]\r\n c=c+(i+1)*l[x]\r\nfor i in range(len(s),len(s)+k):\r\n c=c+m*(i+1)\r\nprint(c)\r\n", "def solve():\r\n s1 = input()\r\n k = int(input())\r\n arr = list(map(int,input().split()))\r\n val = max(arr)\r\n ans = 0\r\n for i in range(len(s1)):\r\n ans+= (i+1)*(arr[ord(s1[i])-ord('a')])\r\n for i in range(k):\r\n ans+= (len(s1)+i+1)*val\r\n print(ans)\r\nsolve()\r\n\r\n", "def main():\r\n\ts = input()\r\n\tk = int(input())\r\n\tw = [int(x) for x in input().split()]\r\n\r\n\tansw = 0\r\n\tfor i in range(0, len(s)):\r\n\t\tansw += (i + 1) * w[ord(s[i]) - ord(\"a\")]\r\n\r\n\tbest = max(w)\r\n\r\n\tdef triangle(n):\r\n\t\treturn n * (n + 1) // 2\r\n\t\t\r\n\tansw += best * (triangle(len(s) + k) - triangle(len(s)))\r\n\r\n\tprint(answ)\r\n\r\nif __name__ == \"__main__\":\r\n\tmain()", "#n = int(input())\n#n, m = map(int, input().split())\ns = input()\nk = int(input())\nc = list(map(int, input().split()))\nn = len(s)\nl = max(c) * (2 * n + k + 1) * k // 2 \nfor i in range(n):\n l += (i + 1) * c[ord(s[i]) - 97]\nprint(l)\n \n ", "\r\ns=input()\r\n\r\nn=int(input())\r\n\r\nl=list(map(int,input().split()))\r\n\r\ndic={}\r\nfor i in range(0,len(l)):\r\n dic[i] = l[i]\r\n\r\ndlist = sorted(dic.items(),key = lambda x:x[1],reverse=True)\r\nsecond=dlist[0][1]\r\nfirst=dlist[0][0]\r\n\r\nfor i in range(0,n):\r\n s += chr(first+97)\r\n# print(s)\r\nval = 0\r\nfor i in range(0,len(s)):\r\n val += (i+1)*dic[ord(s[i])-97]\r\n \r\nprint(val)", "s, k = input(), int(input())\r\nw = dict(zip('abcdefghijklmnopqrstuvwxyz', map(int,input().split())))\r\n\r\nprint(sum(i * w[ch] for i, ch in enumerate(s, 1)) +\r\n max(w.values()) * k * (2 * len(s) + k + 1) // 2)", "s=list(input())\r\n\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nm=max(l)\r\nd={}\r\nans=0\r\nfor i in range(26):\r\n d[chr(97+i)]=l[i]\r\n# print(d)\r\nc=1\r\nfor i in range(len(s)):\r\n ans+=c*d[s[i]]\r\n c+=1\r\nfor i in range(n):\r\n \r\n ans+=c*(m)\r\n c+=1\r\nprint(ans)", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nc, l = 0, len(s)\r\nfor i in range(1, l + 1):\r\n c += i * w[ord(s[i - 1]) - 97]\r\nc += max(w) * ((l + k) * (l + k + 1) // 2 - l * (l + 1) // 2)\r\nprint(c)", "s = input()\r\nk = int(input())\r\nw = list(map(int,input().split()))\r\nm = max(w)\r\nsum = m * (2 * len(s) + k + 1) * k // 2\r\nfor i in range(len(s)):\r\n sum += w[ord(s[i])-ord('a')] * (i+1)\r\nprint(sum)", "s = input()\r\nk = int(input())\r\nz = list(map(int, input().split()))\r\nal = \"abcdefghijklmnopqrstuvwxyz\"\r\nsum = 0\r\nx = max(z)\r\nfor i in range(len(s)):\r\n sum += z[al.index(s[i])] * (i + 1)\r\nfor i in range(len(s), len(s) + k):\r\n sum += x * (i + 1)\r\nprint(sum)", "s=input();q,w=0,len(s)\r\nk,a=int(input())+w,list(map(int,input().split()))\r\nfor i in range(w):q+=(a[ord(s[i])-97])*(i+1)\r\nprint(q+max(a)*(k*(k+1)//2-w*(w+1)//2))", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\n\r\nl = [ord(c) - 97 for c in s]\r\nma = max(w)\r\nj = 1\r\nsu = 0\r\nfor t in [w[i] for i in l] + [ma] * k:\r\n su += j * t\r\n j += 1\r\n\r\nprint(su)", "def solve():\r\n s = input()\r\n k = int(input())\r\n abc = list(map(int, input().split()))\r\n # ind = abc.index(max(abc))\r\n sum1 = 0\r\n for i in range(len(s)):\r\n sum1 += abc[ord(s[i]) - 97] * (i + 1)\r\n sum2 = 0\r\n for i in range(k):\r\n sum2 += len(s) + i + 1\r\n print(sum1 + sum2 * max(abc))\r\n\r\n\r\nfor _ in range(1):\r\n solve()\r\n", "s = list(input())\r\ni = int(input())\r\nvalues = list(input().split())\r\nmx = values[0]\r\n\r\nnum = 0\r\n\r\nfor j in values:\r\n if int(j) > int(mx):\r\n mx = j\r\n\r\nfor j in range(len(s)):\r\n num += int(values[int(ord(s[j]) - 97)]) * int(j+1)\r\n\r\nfor j in range(len(s)+1, len(s)+i+1, 1):\r\n num += (j) * int(mx)\r\nprint(num)", "s = input()\nk = int(input())\nw = list(map(int, input().rstrip().split()))\nmaxm = max(w)\ncount = 0\nn = len(s)\nfor i in range(n):\n ind = ord(s[i]) - 97\n count += (i + 1) * w[ind]\na = (n) * (n + 1) // 2\nb = (n + k) * (n + k + 1) // 2\ncount += (b - a) * maxm\nprint(int(count))", "#n,t=map\r\ns=input()\r\nk=int(input())\r\nmaxx=-1\r\nsums=0\r\na = list(map(int,input().strip().split()))[:26]\r\nfor i in range(0,26): \r\n\tmaxx=max(maxx,a[i])\r\n\r\nfor i in range(0,len(s)): \r\n\tif i<=len(s):\r\n\t\tx1=int(a[ord(s[i])-ord('a')])\r\n\t\tx=(i+1)*x1\r\n\t\tsums=sums+x\r\n\r\nval=len(s)+1\r\nwhile k!=0:\r\n\tsums+=val*maxx\r\n\tval+=1\r\n\tk-=1\r\n\r\nprint(sums)\r\n", "def string():\r\n\ts = input()\r\n\tn = int(input())\r\n\tweights = list(map(int, input().split()))\r\n\talpha = list(\"abcdefghijklmnopqrstuvwxyz\")\r\n\td = dict(zip(alpha, weights))\r\n\tfunc = 0\r\n\tfor i in range(1, len(s)+1):\r\n\t\tfunc += d[s[i-1]]*i\r\n\tm = max(weights)\r\n\tfor i in range(len(s)+1, len(s)+n+1):\r\n\t\tfunc += m*i\r\n\tprint(func)\r\nstring()", "s = input()\r\nk = int(input())\r\nv = list(map(int, input().split()))\r\nw = {chr(ord('a') + i): v[i] for i in range(26)}\r\n\r\nmax_val = 0\r\nmax_key = ''\r\nfor key in w.keys():\r\n if w[key] > max_val:\r\n max_val = w[key]\r\n max_key = key\r\n\r\ns += max_key * k\r\ns_val = 0\r\nfor i in range(1, len(s) + 1):\r\n s_val += w[s[i - 1]] * i\r\n\r\nprint(s_val)", "from sys import stdin; inp = stdin.readline\r\ndef IA(): return list(map(int, inp().split()))\r\ndef FA(): return list(map(float, inp().split()))\r\ndef SA(): return inp().split()\r\ndef I(): return int(inp())\r\ndef F(): return float(inp())\r\ndef S(): return inp()\r\nfrom string import ascii_lowercase\r\n\r\ndef main():\r\n a = ascii_lowercase\r\n s = S()\r\n k = I()\r\n w = IA()\r\n _max = max(w)\r\n t = index = 0\r\n n = len(s)-1\r\n\r\n while n > 0:\r\n c = s[index]\r\n i = a.index(c)\r\n v = w[i]\r\n t += (index+1)*v \r\n index += 1\r\n n-=1\r\n \r\n while k > 0:\r\n t += (index+1)*_max\r\n k-=1\r\n index+=1\r\n return t\r\n \r\n \r\n \r\n \r\n \r\n\r\nif __name__ == '__main__':\r\n print(main())", "s = input()\r\nk = int(input())\r\nw = list(input().split())\r\nalphabet = list(\"abcdefghijklmnopqrstuvwxyz\")\r\nfor num in range(0, 26):\r\n w[num] = int(w[num])\r\ns = list(s)\r\ncount = 0\r\nvalue = 0\r\nfor num in range(0, len(s)): \r\n qwerty = alphabet.index(s[num])\r\n xxx = w.pop(qwerty)\r\n value += xxx * (num + 1)\r\n w.insert(qwerty, xxx)\r\nwhile count < k:\r\n add = max(w)\r\n value += add * (count + 1 + len(s))\r\n count += 1\r\nprint (value)\r\n", "a=list(input());n=int(input());b=list(map(int,input().split()));o=0\r\nfor i in range(len(a)):\r\n kod=ord(a[i])-97;o+=b[kod]*(i+1)\r\nfor i in range(n):o+=max(b)*(len(a)+i+1)\r\nprint(o)", "s, k = input(), int(input())\r\nweights = list(map(int, input().split()))\r\nprint(sum((i + 1) * weights[ord(letter) - 97] for i, letter in enumerate(s)) + sum((i + len(s)) * max(weights) for i in range(1, k + 1)))", "n = input()\r\nk = int(input())\r\na = list(map(int , input().split()))\r\ns = 0\r\nfor i in range(len(n)):\r\n s+=(a[ord(n[i])-97])*(i+1)\r\nx = max(a)\r\nj = len(n)+1\r\nfor i in range(k):\r\n s+=j*x\r\n j+=1\r\nprint(s)\r\n", "s=input()\r\nk=int(input())\r\nmp={}\r\na=list(map(int,input().split()))\r\nans=0\r\nmax=-1\r\n\r\nfor i in range(len(a)):\r\n mp[chr(97+i)]=a[i]\r\n if(a[i]>max):\r\n max=a[i]\r\n\r\nfor i in range(len(s)):\r\n ans+=mp[s[i]]*(i+1)\r\n \r\n\r\nfor j in range(len(s)+1,len(s)+k+1):\r\n ans+=j*max\r\n\r\n\r\nprint(ans)\r\n \r\n ", "#list(map(int,input().split()))\r\n\r\n\r\n\r\n\r\n\r\n\r\ndef slv() :\r\n s=input()\r\n k=int(input())\r\n v=list(map(int,input().split()))\r\n ans=0\r\n for i in range(len(s)) :\r\n ans+=v[ord(s[i])-ord('a')]*(i+1)\r\n v.sort()\r\n for i in range(k) :\r\n ans+=v[25]*(i+1+len(s))\r\n print(ans)\r\n\r\n \r\n# t=int(input())\r\n# while(t) :\r\n# slv()\r\n# t-= 1\r\nslv()\r\n\r\n\r\n", "s=input()\r\nn=int(input())\r\nw=list(map(int,input().rsplit()))\r\na=max(w)\r\nb=0\r\nj=1\r\nfor i in range (1,n+1):\r\n b=b+(len(s)+i)*a\r\nfor i in (s):\r\n c=ord(i)\r\n d=c-97\r\n b=b+w[d]*j\r\n j=j+1\r\n\r\nprint(b)", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nmax1=0\r\nfor i in l:\r\n if i>max1:\r\n max1=i\r\nsum=0\r\nfor i in range(len(s)):\r\n sum+=l[ord(s[i])-97]*(i+1)\r\nsum+=(len(s)*k + ((k)*(k+1))//2)*max1\r\n\r\nprint(sum)\r\n", "str = input()\nk = int(input())\narr = list(map(int,input().split()))\nalphabets = ['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']\nbig = max(arr)\nans = []\nfor i in str:\n ans.append(alphabets.index(i))\ncount = 0\nfor i in range(len(str)):\n count += (i+1) * arr[ans[i]]\nfor i in range(len(str),len(str)+k):\n count += (i+1) * big\nprint(count)\n", "st = (input())\r\nn = int(input())\r\nresult = 0\r\nl = list(map(int,input().split()))\r\nfor i in range (0,len(st)):\r\n j = ord(st[i])-96\r\n result += (i+1)* (l[j-1])\r\nmaxi = max(l)\r\nk = len(st)+1\r\nfor i in range(k,k+n):\r\n result +=i*maxi\r\nprint(result)\r\n ", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sat Aug 29 00:53:29 2020\r\n\r\n@author: DELL\r\n\"\"\"\r\ns=input()\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\nv='abcdefghijklmnopqrstuvwxyz'\r\nc=0\r\nfor i in range(len(s)):\r\n b=v.find(s[i])\r\n f=w[b]\r\n c+=((i+1)*f)\r\nfor i in range(len(s)+1,len(s)+k+1):\r\n c+=(i*max(w))\r\nprint(c)\r\n ", "s = input()\r\nk = int(input())\r\nw = list(map(int,input().split()))\r\ncount1 = 0\t\r\nfor i in range(len(s)):\r\n\tcount1 += (i+1)*w[ord(s[i])-97]\r\nfor j in range(len(s)+1,len(s)+k+1):\r\n\tcount1 += j*max(w)\r\nprint(count1)\t\r\n", "from sys import stdin\r\nstdin.readline\r\ndef mp(): return list(map(int, stdin.readline().strip().split()))\r\ndef it():return int(stdin.readline().strip())\r\n\r\n\r\ns=input()\r\nn=it()\r\nl=mp()\r\n# k=list(enumerate(l,ord('a')))\r\n# print(k)\r\nans=ans2=0\r\nfor i in range(len(s)):\r\n\tans+=l[(ord(s[i])-97)]*(i+1)\r\nfor j in range(len(s),len(s)+n):\r\n\tans2+=(j+1)*max(l)\r\nprint(ans+ans2)\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nvalue = 0\r\nfor i in range(len(s)):\r\n value += (i + 1) * w[ord(s[i]) - ord('a')]\r\nfor i in range(len(s) + 1, len(s) + k + 1):\r\n value += max(w) * i\r\nprint(value)", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nc=[]\r\nfor i in s:\r\n c.append(ord(i)-97)\r\nm=max(l)\r\n\r\nS=0\r\nfor i in range(len(s)+k):\r\n S=S+(i+1)*l[c[i]] if i<len(s) else S+(i+1)*m\r\nprint(S)", "string = input()\nk = int(input())\nvals = list(map(int, input().split()))\ndi = {chr(97+i):val for i, val in enumerate(vals)}\n\nma = max(vals)\n\npre = 0\n\nfor index, value in enumerate(string):\n pre += (index+1) * di[value]\n\nsub = (len(string) * (len(string) + 1)) // 2\noi = len(string) + k\nsumn = (oi*(oi+1))//2 - sub\n\nprint(pre + (sumn * ma))", "s = input()\r\nk = int(input())\r\nw = list(map(int,input().split()))\r\nm = max(w)\r\nans = 0\r\nfor i in range(len(s)):\r\n ans += w[ord(s[i])-97]*(i+1)\r\nfor i in range(len(s),len(s)+k):\r\n ans += m*(i+1)\r\nprint(ans)\r\n", "alpha = ['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\n\r\nstring = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\n\r\ndictWeight = {}\r\nmaxWeight = max(w)\r\nfor i in range(len(w)):\r\n dictWeight[alpha[i]] = w[i]\r\n\r\nans = 0\r\n\r\nfor i in range(1, 1 + len(string)):\r\n ans += i * dictWeight[string[i-1]] \r\n\r\nfor i in range(len(string) + 1, len(string) +k + 1):\r\n ans += i * maxWeight\r\nprint(ans)\r\n", "str = input()\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\nsum = 0\r\nfor i in range(1,len(str)+1):\r\n sum += i*(arr[ord(str[i-1]) - 97])\r\nfor i in range(len(str)+1, len(str)+n+1):\r\n sum += i*max(arr)\r\nprint(sum)\r\n \r\n", "s=input()\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\no=max(l)\r\nindex=l.index(o)\r\nchar=chr(index+97)\r\ns=s+n*char\r\ncount1=0\r\nfor i in range(len(s)):\r\n count1=count1+(i+1)*l[ord(s[i])-97]\r\nprint(count1)\r\n", "s = input()\r\nn = len(s)\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nres = 0\r\nfor i in range(n):\r\n res += (i + 1) * (w[ord(s[i]) - ord('a')])\r\nres += (n + 1 + n + k) * k // 2 * max(w)\r\nprint(res)\r\n", "special_string = input()\r\nk=int(input())\r\nval_chars=list(map(int,input().split()))\r\nval=0\r\nl=len(special_string)\r\n\r\n\r\nfor x in range(l):\r\n y=val_chars[ord(special_string[x])-97]\r\n val=val+y*(x+1)\r\n\r\n\r\nval=val+max(val_chars)*(k*l+k*(k+1)*0.5)\r\nprint(int(val))", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nm = max(w)\r\nw2 = ['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\nd = dict()\r\nfor i, j in zip(w, w2):\r\n d[j] = i\r\n\r\ns_score = 0\r\nfor i in range(len(s)):\r\n s_score += d[s[i]] * (i+1)\r\n\r\ni += 1\r\n\r\nk_score = 0\r\nfor j in range(i, i+k):\r\n k_score += m * (j+1)\r\n\r\nprint(s_score + k_score)", "s=str(input())\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nc=0\r\nl1=list(s)\r\nfor i in range(len(l1)):\r\n c+=l[ord(l1[i])-97]*(i+1)\r\nfor i in range(k):\r\n c+=max(l)*(len(l1)+i+1)\r\nprint(c)", "\r\ns = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nDict = {}\r\ncounter = 0\r\nfor i in range(97, 123):\r\n Dict[chr(i)] = w[i-97]\r\nm = max(Dict.values())\r\nfor i in range(len(s)):\r\n counter += Dict[s[i]] * (i + 1)\r\nfor i in range(len(s)+1, len(s) + k + 1):\r\n counter += m * i\r\nprint(counter)\r\n# CodeForcesian\r\n# ♥\r\n# Lifan\r\n", "class CodeforcesTask447BSolution:\n def __init__(self):\n self.result = ''\n self.string = ''\n self.k = 0\n self.values = []\n\n def read_input(self):\n self.string = input()\n self.k = int(input())\n self.values = [int(x) for x in input().split(\" \")]\n\n def process_task(self):\n values = {}\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n for x in range(len(alphabet)):\n values[alphabet[x]] = self.values[x]\n total_value = 0\n mx_val = max(self.values)\n for i in range(len(self.string)):\n total_value += (i + 1) * values[self.string[i]]\n for i in range(len(self.string), len(self.string) + self.k):\n total_value += (i + 1) * mx_val\n self.result = str(total_value)\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask447BSolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n", "x=input()\r\nn=int(input())\r\nm=list(map(int,input().split()))[:26]\r\ns=1\r\na=0\r\nfor i in x:\r\n d=(ord(i)-97)\r\n f=m[d]*s\r\n s=s+1\r\n a=a+f\r\nq=max(m)\r\nwhile (s<=len(x)+n):\r\n a=a+q*s\r\n s=s+1\r\n \r\nprint(a)\r\n", "s = input()\r\nk = int(input())\r\nweights = list(map(int, input().split()))\r\nj = 1\r\ncurrent = 0\r\nfor i, v in enumerate(s):\r\n ind = ord(v) - ord(\"a\")\r\n current += j* weights[ind]\r\n j += 1\r\n\r\n\r\n\r\nmaxi = max(weights)\r\n\r\nfor i in range(k):\r\n current += j * maxi\r\n j += 1\r\n\r\nprint(current)", "import string \r\n\r\n\r\nvalue = input()\r\nk = int(input())\r\ncounts = list(map(int,input().split()))\r\nlowers = list(string.ascii_lowercase)\r\nmapp = {}\r\nmax_value = 0\r\nmax_char = None\r\nfor i, count in enumerate(counts):\r\n if count > max_value:\r\n max_char = lowers[i]\r\n max_value = count\r\n mapp[lowers[i]] = count\r\nresult = 0\r\nvalue += k * max_char\r\nfor i, ch in enumerate(value):\r\n result += (i+1) * mapp[ch] \r\n\r\nprint(result)", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nt = max(l)\r\nsum=0\r\nfor i in range(len(s)):\r\n sum+=((i+1)*l[(ord(s[i])-ord('a'))])\r\nu=len(s)+1\r\nwhile(k>0):\r\n k-=1\r\n sum+=t*u\r\n u+=1\r\nprint(sum)\r\n", "a=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nq=max(l)\r\nn=len(a)\r\ns=0\r\n#print(ord(a[1]))\r\nfor i in range(len(a)):\r\n s+=(i+1)*(l[ord(a[i])-97])\r\nfor i in range(n,n+k):\r\n s+=(i+1)*(q)\r\nprint(s)", "s, k, w = input(), int(input()), list(map(int, input().split()))\r\nc, x = [], 0\r\nfor i in s:\r\n c.append(ord(i) - 97)\r\nm = max(w)\r\nfor i in range(len(s) + k):\r\n x = x + (i + 1) * w[c[i]] if i < len(s) else x + (i + 1) * m\r\nprint(x)", "s = input()\r\nk = int(input())\r\nw = list(map(int,input().split()))\r\nt = max(w)\r\nd = 0\r\nfor i in range(len(s)):\r\n d += (i+1)*w[ord(s[i])-97]\r\nfor i in range(len(s),len(s)+k):\r\n d += (i+1)*t\r\nprint(d)", "s=input()\r\nn=int(input())\r\nd=list(map(int,input().split()))\r\nm=max(d)\r\nx=0\r\ntry:\r\n for i in range(len(s)):\r\n x+=d[(ord(s[i])-97)]*(i+1)\r\nexcept:\r\n pass\r\nfor j in range(len(s)+1,len(s)+n+1):\r\n x+=j*m \r\nprint(x)\r\n", "s=[ ord(i)-ord('a') for i in input()]\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nans=0;maxi=-1;count=1\r\nfor i in s:\r\n ans+=count*(a[i])\r\n count+=1\r\nans+=max(a)*(n*len(s)+n*(n+1)//2)\r\nprint(ans)\r\n", "s = input()\r\nn = eval(input())\r\nvalue = list(map(eval,input().split()))\r\nans = 0\r\nfor i in range(len(s)):\r\n ans += value[ord(s[i])-ord('a')]*(i+1)\r\nmaxn = max(map(lambda x:x,value))\r\nans += (len(s)*2+n+1)*n*maxn/2\r\nprint(int(ans))", "a=input()\r\nk=int(input())\r\ns=list(map(int,input().split()))\r\nans=0\r\nfor i in range(len(a)):\r\n ans+=(i+1)*s[ord(a[i])-97]\r\ntemp=(max(s))\r\nres=((k*(len(a)+1+len(a)+k))//2)*temp\r\n#print(res)\r\nprint(ans+res)", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nf=0\r\nfor i in range(len(s)):\r\n f+=l[ord(s[i])-97]*(i+1)\r\nm=max(l)\r\nfor j in range(len(s)+1,len(s)+k+1):\r\n f+=m*j\r\nprint(f)", "# You lost the game.\ns = str(input())\nk = int(input())\nL = list(map(int, input().split()))\nr = 0\nfor i in range(len(s)):\n r += L[\"abcdefghijklmnopqrstuvwxyz\".index(s[i])]*(i+1)\nfor i in range(k):\n r += (len(s)+1+i)*max(L)\nprint(r)\n", "string = input()\r\nk= int(input())\r\na = list(map(int, input().split()))[:26]\r\ntotal = 0\r\ni=0\r\nfor i in range(len(string)):\r\n total = total + (a[(ord(string[i]) - 97)]*(i+1))\r\nm = max(a)\r\nfor j in range(i+1, i+1+k):\r\n total = total + m*(j+1)\r\nprint(total)\r\n\r\n\r\n\r\n", "def main():\n s = input()\n k = int(input())\n weights = [int(_) for _ in input().split()]\n weight_s = 0\n\n for i in range(len(s)):\n weight_s += weights[ord(s[i]) - ord('a')] * (i + 1)\n\n max_weight = max(weights)\n\n for i in range(len(s) + 1, len(s) + k + 1):\n weight_s += max_weight * i\n\n print(weight_s)\n\n\nif __name__ == '__main__':\n main()\n", "#447B\r\ns=input()\r\nk=int(input())\r\na=[i for i in input().split()]\r\nb=[int(i)for i in a]\r\nt=max(b)\r\nsumm=0\r\nl=list(s)\r\n\r\n\r\nfor i in range(len(l)):\r\n summ+=(b[ord(l[i])-ord('a')])*(i+1)\r\nfor i in range(len(l)+1,len(l)+k+1):\r\n summ+=i*t\r\nprint(summ)\r\n", "s = input()\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\nm = max(arr)\r\nans = 0\r\ni = 1\r\nwhile i <= len(s):\r\n ans += i*arr[ord(s[i-1])-97]\r\n i += 1\r\nwhile i <= n+len(s):\r\n ans += m*i\r\n i += 1\r\nprint(ans)", "\r\nst = input()\r\nn = int(input())\r\nl = list(map(int, input().split()))\r\n\r\n\r\nans = 0\r\nfor i in range(len(st)):\r\n\tans += l[ord(st[i]) - 97] * (i + 1)\r\n\r\n\r\nma = max(l)\r\nle = len(st)\r\nfor i in range(n):\r\n\tans += ma * (le + i + 1)\r\n\r\n\r\n\r\nprint(ans)", "s = input()\r\nk = int(input())\r\np = list(map(int,input().split()))\r\nm = max(p)\r\ntotal = 0\r\nfor i in range(len(s)):\r\n total += p[ord(s[i])-ord('a')] * (i+1)\r\ntotal += m*(0.5 * k*k + 0.5 * k + k * len(s))\r\nprint(int(total))", "s, k = input(), int(input())\r\na = list(map(int, input().split()))\r\ns += k * chr(97 + a.index(max(a)))\r\nprint(sum(a[ord(s[i]) - 97] * (i + 1) for i in range(len(s))))\r\n", "import string\n\n\nS = input()\nK = int(input())\nW = list(map(int, input().split()))\n\nmaxw = max(W)\nfor i, w in enumerate(W):\n if w == maxw:\n argmaxi = i\n break\nans = 0\nfor i, s in enumerate(S):\n ans += W[string.ascii_lowercase.index(s)] * (i + 1)\nN = len(S)\nfor k in range(K):\n ans += W[argmaxi] * (k + N + 1)\nprint(ans)\n", "s=str(input())\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nc=a.copy()\r\na.sort(reverse=True)\r\nf,g=0,len(s)+1\r\nfor i in range(len(s)):\r\n d=ord(s[i])-96\r\n f+=c[d-1]*(i+1)\r\nfor i in range(n):\r\n f+=a[0]*g\r\n g+=1\r\nprint(f)", "#!/usr/bin/env python\n\n\ndef f(string, w):\n return sum([(i+1) * w[ord(string[i]) - ord('a')] for i in range(len(string))])\n\n\ndef main():\n string = input()\n k = int(input())\n w = list(map(int, input().split()))\n\n maxw = max(w)\n\n res = f(string, w)\n for i in range(k):\n res += (len(string) + i + 1) * maxw\n\n print(res)\nif __name__ == '__main__':\n main()\n", "s=input()\r\np=int(input())\r\nL=list(map(int,input().split()))\r\nz=max(L)\r\nsuma=0\r\nj=1\r\nfor k in s:\r\n suma+=j*L[ord(k)-97]\r\n j+=1\r\nprint(suma+z*p*(2*len(s)+1+p)//2)", "import sys\r\ninput = sys.stdin.readline\r\n\r\ns = input().rstrip()\r\nk = int(input().rstrip())\r\nw = list(map(int, input().rstrip().split()))\r\n\r\nresult = 0\r\nfor i in range(len(s)):\r\n result += w[ord(s[i])-ord('a')]*(i+1)\r\n\r\nfor i in range(len(s),len(s)+k):\r\n greed = max(w)\r\n result += greed*(i+1)\r\n\r\nprint(result)", "s = input()\r\n\r\nk = int(input())\r\nl_n = list(map(int, input().split()))\r\nm = max(l_n)\r\n\r\nt = 0\r\nfor i in range(len(s)):\r\n t += (i + 1)*l_n[ord(s[i]) - ord('a')]\r\n\r\nprint(m * ((len(s) + k) * (len(s) + k + 1) // 2 - len(s)*(len(s) + 1) // 2) + t)", "ptr = input()\nk = int(input())\nlst = list(map(int, input().split()))\nabc = list(\"abcdefghijklmnopqrstuvwxyz\")\ntotal = 0\nfor i, x in enumerate(list(ptr), start=1):\n total += i*lst[abc.index(x)]\np = len(ptr) + 1\nmaxa = max(lst)\nfor i in range(p, p+k):\n total += i*maxa\n\nprint(total)\n", "s = input()\r\nk = int(input())\r\nalpha1 = list(map(int, input().split()))\r\nalpha2 = {chr(ord('a') + i) : i for i in range(26)}\r\nval = 0\r\nn = len(s)\r\nfor i in range(n):\r\n val += (alpha1[alpha2[s[i]]] * (i+1))\r\nalpha1.sort()\r\nfor i in range(n+1, n+k+1):\r\n val += (alpha1[-1]*i)\r\nprint(val)", "s = input()\r\nk = int(input())\r\nl = [int(x) for x in input().split()]\r\nans = (len(s) + 1 + len(s) + k) * k // 2 * max(l)\r\nfor i in range(len(s)):\r\n\tans += l[ord(s[i]) - ord('a')] * (i + 1)\r\nprint(ans)", "txt = input()\r\n\r\nnum = int(input())\r\n\r\natoz = list(map(int, input().split())) \r\n\r\nmaxw = 0\r\nmaxz = 0\r\nfor i in range(26):\r\n if atoz[i] >= maxz:\r\n maxz = atoz[i]\r\n maxw = i\r\n \r\ntxt += chr(maxw + 97) * num \r\n\r\nsum = 0\r\nfor i in range(len(txt)):\r\n sum += (atoz[ord(txt[i]) - 97]) * (i+1)\r\nprint(sum)", "alpha = {'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,\r\n 'w':23,'x':24,'y':25,'z':26}\r\ns = input()\r\nk = int(input())\r\nscore = list(map(int,input().split()))\r\nscore1 = list(score)\r\nscore.sort(reverse = True)\r\n\r\nvalue = 0\r\nfor i in range(len(s)):\r\n value += score1[alpha[s[i]]-1]*(i+1)\r\n #print(value)\r\nfor i in range(len(s)+1,len(s)+1+k):\r\n value += score[0]*i\r\nprint(value)\r\n ", "s=input()\r\nk=int(input())\r\na=[int(x) for x in input().split()]\r\nres=0\r\nfor i in range(len(s)):\r\n res+=a[ord(s[i])-97]*(i+1)\r\nres+=(k*(k+1+2*len(s))//2)*max(a)\r\nprint(res)", "s=input()\r\nk=int(input())\r\narr=[int(x) for x in input().split()]\r\nans=0\r\nfor i in range(len(s)):\r\n ans+=(i+1)*arr[ord(s[i])-97]\r\nm=max(arr)\r\nfor i in range(len(s)+1,len(s)+k+1):\r\n ans+=(i*m)\r\nprint(ans) ", "s=input()\r\ns1=\"abcdefghijklmnopqrstuvwxyz\"\r\nk=int(input())\r\narr=list(map(int,input().split()))\r\nmax_val=max(arr)\r\nx=s1[arr.index(max_val)]\r\nfor i in range(k):\r\n s+=x\r\ntotal=0\r\nfor i in range(len(s)):\r\n c=s[i]\r\n total+=((i+1)*(arr[s1.index(c)]))\r\nprint(total)", "s=['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\n\r\n\r\nt=input()\r\n\r\nk=int(input())\r\n\r\nl=list(map(int,input().split()))\r\n\r\n\r\np=0\r\n\r\n\r\nfor j in range(len(t)):\r\n p+=(j+1)*l[s.index(t[j])]\r\n\r\n\r\nprint(p+max(l)*(sum([i for i in range(len(t)+1,len(t)+1+k)])))\r\n", "s = list(input())\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\n\r\n\r\ndef weight(letter):\r\n return w[ord(letter)-ord('a')]\r\n\r\n\r\ns_sum = 0\r\nfor i in range(len(s)):\r\n c = s[i]\r\n s_sum += (i+1)*weight(c)\r\n\r\nm = max(w)\r\n\r\nfor i in range(len(s)+1, len(s)+k+1):\r\n s_sum += i*m\r\n\r\nprint(s_sum)\r\n", "# cook your dish here\r\ns=input()\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nval=0\r\nfor i in range(len(s)):\r\n val=val+(i+1)*a[(ord(s[i])-97)]\r\nm=max(a)\r\nl=a.index(m)\r\n# print(val)\r\nif(n==0):\r\n print(val)\r\nelse:\r\n ans=0\r\n for i in range(len(s),len(s)+n):\r\n ans=ans+(i+1)*m\r\n print(ans+val) ", "s=input()\r\nn=int(input())\r\nw=list(map(int,input().split()))\r\nv=0\r\nj=1\r\nfor i in s:\r\n v+=(j*w[ord(i)-97])\r\n j+=1\r\nwhile(j<=len(s)+n):\r\n v+=(j*max(w))\r\n j+=1\r\nprint(v)", "s = input()\r\nk = int(input())\r\nz = input()\r\nz = z.split()\r\nz = [int(x) for x in z]\r\n\r\ns = [ord(x)-ord('a') for x in s]\r\np = [z[x] for x in s]\r\nmx = max(z)\r\nfor i in range(k):\r\n p.append(mx)\r\n\r\nsm = 0\r\nfor i in range(len(p)):\r\n sm = sm + p[i] * (i+1)#; print(p[i])\r\nprint (sm)", "#447B\r\ns = input()\r\nn = int(input())\r\nw = list(map(int, input().split()))\r\ntemp = []\r\ntotal = 0\r\nfor i in s:\r\n temp.append(w[ord(i)-97])\r\nm = max(w)\r\nfor i in range(n):\r\n temp.append(m)\r\n# print(temp) \r\nfor i in range(0,len(s)+n):\r\n total+= temp[i] * (i+1)\r\nprint(total) ", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nfs=0\r\nfor i in range(len(s)):\r\n fs+=w[ord(s[i])-97]*(i+1)\r\nm=max(w)\r\nfor i in range(len(s),len(s)+k):\r\n fs+=m*(i+1)\r\nprint(fs)", "s=input()\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nm=max(l)\r\n#s=s+chr(m+96)*n\r\nc=0\r\nj=1\r\nfor i in range(1,len(s)+1):\r\n #print(l[ord(s[i-1])-96-1])\r\n c+=(l[ord(s[i-1])-96-1])*i\r\n j+=1\r\n#print(c)\r\n\r\n#print(j)\r\nfor i in range(n):\r\n c+=j*m\r\n j+=1\r\nprint(c)", "import string\nl = list(str(input()))\nk = int(input())\na = list(string.ascii_lowercase)\nb = [int(n1) for n1 in input().split()]\nb,a = zip(*sorted(zip(b,a),reverse=True))\nl = l + (k*list(a[0]))\nsum1 = 0\nfor i in range(len(l)):\n\tfor j in range(len(a)):\n\t\tif a[j]==l[i]:\n\t\t\tsum1 = sum1 + (i+1)*b[j]\nprint(sum1)", "ll=lambda:map(int,input().split())\r\nt=lambda:int(input())\r\nss=lambda:input()\r\nlx=lambda x:map(int,input().split(x))\r\nfrom math import log10 ,log2,ceil,factorial as fac,gcd\r\n#from itertools import combinations_with_replacement as cs \r\n#from functools import reduce\r\n#from bisect import bisect_right as br,bisect_left as bl\r\n#from collections import Counter\r\n#from math import inf\r\n\r\n\r\n \r\n\r\n\r\n#for _ in range(t()):\r\ndef f():\r\n \r\n \r\n s=ss()\r\n n=t()\r\n a=list(ll())\r\n\r\n x=max(a)\r\n p=0\r\n for i in range(len(s)+1,len(s)+n+1):\r\n \r\n p+=x*i\r\n\r\n for i in range(len(s)):\r\n p+=(i+1)*a[(ord(s[i])-ord('a'))]\r\n print(p)\r\n \r\n \r\n\r\n \r\n\r\n \r\n \r\n \r\nf()\r\n\r\n'''\r\n50 5 5 5 10 40\r\n\r\n5 5 5 \r\n \r\n'''\r\n", "inp=input()\r\nk=int(input())\r\nl1=[int(x) for x in input().split()]\r\nout=0\r\nfor i in range(0,len(inp)):\r\n ind=ord(inp[i])-ord('a')\r\n out+=(l1[ind]*(i+1))\r\nleng=len(inp)\r\nval=((k*leng)+(k*(k+1)//2))\r\nval*=max(l1)\r\nout+=val\r\nprint(out) \r\n", "def main():\n s = input()\n l = len(s)\n n = int(input())\n p = list(map(int, input().split()))\n Max = 0\n for i in range (26):\n Max = max([Max, p[i]])\n ans = 0\n for i in range (l):\n ans = ans + p[ord(s[i]) - (ord('a'))] * (i + 1)\n l = l + 1\n for i in range (n) :\n ans += Max * l\n l = l + 1\n print (ans)\nmain()\n\n \t\t \t \t \t\t \t\t\t \t \t\t", "# cook your dish here\r\ns = input()\r\nk = int(input())\r\na1 = list(map(int, input().split()))\r\ncount = 0\r\narr = ['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\n# list(arr)\r\n# print(arr)\r\nfor i in range(len(s)):\r\n # print(s[i],a[i])\r\n b = arr.index(s[i])\r\n # print(b)\r\n count += (i+1)*a1[b]\r\nfor j in range(len(s),len(s)+k):\r\n count+= (j+1)*max(a1)\r\nprint(count)", "s=input().rstrip()\r\nk=int(input())\r\na=list(map(int,input().rstrip().split()))\r\np=dict()\r\nj=0\r\nfor i in range(97,97+26):\r\n p[chr(i)]=a[j]\r\n j+=1\r\nvalue=0\r\nl=0\r\nfor i in range(len(s)):\r\n value+=(i+1)*p[s[i]]\r\nmaxi=max(a)\r\nfor i in range(len(s),len(s)+k):\r\n value+=(i+1)*(maxi)\r\nprint(value)", "s=input()\r\nk=int(input())\r\nsan=list(map(int,input().split()))\r\nc=0\r\nfor i in range(len(s)):\r\n c+=(i+1)*(san[ord(s[i])-97])\r\nc+=max(san)*((len(s)+k)*(len(s)+k+1)-(len(s))*(len(s)+1))/2\r\nprint(int(c))\r\n", "s=input()\r\nn=int(input())\r\nl=[int(x) for x in input().split()]\r\nl1=[\"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\ncount=0\r\nfor i in range(1,len(s)+1):\r\n count+=i*l[l1.index(s[i-1])]\r\nfor j in range(len(s)+1,n+1+len(s)):\r\n count+=j*max(l)\r\nprint(count) ", "s = input()\r\nk = int(input())\r\na = list(map(int,input().split()))\r\nma = 1\r\nans = 0\r\nfor i in range(len(a)):\r\n if a[ma] < a[i]:\r\n ma = i\r\nfor i in range(len(s)):\r\n ans += a[ord(s[i]) - ord('a')] * (i + 1)\r\nfor i in range(len(s), len(s) + k):\r\n ans += a[ma] * (i + 1)\r\nprint(ans)", "s=input()\r\nn=int(input())\r\nl=[int(x) for x in input().split()]\r\ncount=0\r\nfor i in range(len(s)):\r\n x=ord(s[i])-97\r\n #print(l[x])\r\n count+=(i+1)*l[x]\r\n #print(i+1,l[x])\r\ni+=1\r\nfor j in range(n):\r\n count+=(i+1)*(max(l))\r\n #print(i+1,max(l))\r\n i+=1\r\nprint(count)", "s = input()\nk = int(input())\nw = [int(x) for x in input().split()]\nalpha = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\",\n \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\nmaxs = max(w)\nsums = 0\nfor i in range(len(s)):\n for j in range(len(alpha)):\n if s[i] == alpha[j]:\n sums += (i + 1) * w[j]\nfor i in range(len(s), len(s) + k):\n sums += (i + 1) * maxs\nprint(sums)\n", "s=input()\r\nk=int(input())\r\nn=len(s)\r\nl1=list(map(int,input().split()))\r\nans=0\r\nfor i in range(len(s)):\r\n ans+=(i+1)*l1[ord(s[i])-97]\r\nans+= max(l1)*(k*(2*(n+1)+(k-1)))//2\r\nprint(ans)", "import string\r\n\r\n\r\ndef string_adding(s,k,seq) :\r\n\tindex = 0\r\n\ttotal = 0\r\n\tlargest = max(seq)\r\n\treference = dict(zip(list(string.ascii_lowercase),seq))\r\n\twhile index < (len(s) + k) :\r\n\t\tif index < len(s):\r\n\t\t\ttotal += reference[s[index]]*(index+1)\r\n\t\telse :\r\n\t\t\ttotal += largest*(index+1)\r\n\t\tindex += 1\r\n\treturn total\r\n\r\n\r\n\r\ns = input()\r\nx = int(input())\r\nn = list(map(int,input().split()))\r\nprint (string_adding(s,x,n))\r\n\r\n\r\n\r\n\r\n\t\t\t\r\n\r\n\r\n\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nans = 0\r\n_max = max(w)\r\n\r\nn = len(s)\r\nfor i in range(n):\r\n ans += (i+1)*w[ord(s[i])-97]\r\nfor i in range(k):\r\n ans += (i+n+1)*_max\r\n\r\nprint(ans)", "x = input()\r\nb = int(input())\r\nc = input()\r\nc = c.split(\" \")\r\nfor i in range(len(c)):\r\n c[i] = int(c[i])\r\n\r\nd = ['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\ne = {}\r\n\r\nfor j in range(len(d)):\r\n e[d[j]] = c[j]\r\n\r\nmaxi = 0\r\nf = ''\r\nfor k in range(len(d)):\r\n if e[d[k]] > maxi:\r\n maxi = e[d[k]]\r\n f = d[k]\r\ng = ''\r\nfor l in range(b):\r\n g = g + f\r\n\r\nh = x + g\r\n\r\ns = 0\r\nfor m in range(len(h)):\r\n s = s + ((m+1)*e[h[m]])\r\nprint(s)", "s = input()\r\nk = int(input())\r\nd = list(map(int, input().split()))\r\nans = 0 \r\nfor i in range(len(s)):\r\n ans += (i+1)*d[ord(s[i]) - ord('a')]\r\nmaxi = max(d)\r\nfor i in range(k):\r\n ans += (i+len(s)+1)*maxi\r\n\r\nprint(ans)", "s=input(\"\")\nk=int(input(\"\"))\nW=[int(i) for i in input(\"\").split()]\nM=len(s)+k\nC=0\nT=0\nfor x in range(0,len(s)):\n if 0<=(ord(s[x])-97)<=25:\n T+=W[ord(s[x])-97]*(x+1)\nA=-1\nfor i in range(0,len(W)):\n if W[i]>A:\n A=W[i]\nwhile M > len(s):\n T+=M*A\n M-=1\nprint(T)\n\n\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nn = len(s)\r\nvalue = 0\r\nfor i in range(n):\r\n value += (i+1) * w[ord(s[i]) - ord(\"a\")]\r\nm = max(w)\r\nfor i in range(n, n+k):\r\n value += (i+1) * m\r\nprint(value)", "from collections import defaultdict\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()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\ns = input()\r\nk, n = inp(), len(s)\r\nk += n\r\nw = inlt()\r\nans = 0\r\n\r\nfor i, c in enumerate(s):\r\n # print(i + 1, ord(c)-ord('a'), w[ord(c)-ord('a')])\r\n ans += (i + 1)*(w[ord(c)-ord('a')])\r\n \r\nextra = ((k*(k + 1)) // 2 - (n*(n + 1) // 2)) * max(w)\r\n\r\nprint(ans + extra)", "s = input();\r\nk = int(input())\r\nl = list(map(int ,input().split()))\r\nm = max(l)\r\nadd = 0\r\nfor j,i in enumerate(s,1):\r\n x = ord(i)-97\r\n add += j*l[x]\r\nfor i in range(len(s)+1,len(s)+1+k):\r\n add += i*m;\r\nprint(add)", "s=input()\r\nk=int(input())\r\nalpha=[*map(int,input().split())]\r\ncnt=0\r\nfor i in range(len(s)):\r\n cnt+=(i+1)*(alpha[ord(s[i])-ord(\"a\")])\r\nfor i in range(len(s)+1,len(s)+k+1):\r\n cnt+=i*max(alpha)\r\nprint(cnt)\r\n\r\n", "s = input()\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\ncur = 0\r\nfor i in range(len(s)):\r\n cur += (i + 1) * a[(ord(s[i]) - ord('a'))]\r\nm, b = len(s), max(a)\r\nfor i in range(n):\r\n cur += (m + i + 1) * b\r\nprint(cur)", "s = list(input())\r\nk = int(input())\r\nl = list(map(int, input().split()))\r\nnum = 0\r\nfor i in range(len(s)):\r\n a = s[i]\r\n b = ord(a) - ord('a')\r\n num += l[b] * (i + 1)\r\nc = max(l)\r\nd = len(s)\r\nnum += c * (d + 1 + d + k) * k / 2\r\nprint(int(num))", "import string\r\ns = input()\r\nln = len(s)\r\nnum = int(input())\r\narr = list(map(int, input().split()))\r\nmapping = {char:val for char, val in zip(string.ascii_lowercase, arr)}\r\n\r\nmx = max(arr)\r\n\r\nans = sum(mapping[char] * i for i, char in enumerate(s, start=1))\r\n\r\nfor n in range(ln+1, ln+num+1):\r\n ans += n * mx\r\nprint(ans)\r\n", "s=input()\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\nl=len(s)\r\nans=0\r\nfor i in range(l):\r\n ans+=(i+1)*(w[ord(s[i])-97])\r\nz=max(w)\r\nans+=z*((l*k)+(k*(k+1)/2))\r\nprint(int(ans))\r\n", "\r\ns=input()\r\nk=int(input())\r\nchars=list(map(int,input().split()))\r\nm=max(chars)\r\nres=0\r\nfor i in range(len(s)):\r\n \r\n order=ord(s[i].lower())-ord('a')\r\n res+=chars[order]*(i+1)\r\nfor i in range(len(s)+1,k+len(s)+1):\r\n res+=m*i\r\nprint(res)\r\n", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nans=0\r\nfor i in range(len(s)):\r\n ans+=l[ord(s[i])-97]*(i+1)\r\nm=max(l)\r\nidx=len(s)+1\r\nfor i in range(k):\r\n ans+=idx*m\r\n idx+=1\r\nprint(ans)\r\n\r\n\r\n", "s = input()\r\nk = int(input())\r\n\r\narr = list(map(int, input().strip().split()))\r\n\r\nmaxs = max(arr)\r\nsums = 0\r\nfor x in range(len(s)):\r\n \r\n \r\n sums += (x+1)*(arr[ord(s[x]) - 97])\r\n \r\nfor x in range(len(s)+1,len(s)+k+1):\r\n \r\n sums += x*maxs\r\nprint(sums)\r\n ", "x=input()\r\nk=int(input())\r\na=list(map(int,input().split()))\r\nc=[]\r\nl=0\r\nfor i in range(97,123):\r\n c.append([a[i%97],chr(i)])\r\nfor i in range(len(x)):\r\n for j in range(len(c)):\r\n if(x[i]==c[j][1]):\r\n l+=(i+1)*c[j][0]\r\n break\r\nfor i in range(len(x)+1,len(x)+k+1):\r\n l+=(i*max(a))\r\nprint(l)\r\n", "s=input()\r\nk=int(input())\r\narr=list(map(int,input().split()))\r\n\r\nx=max(arr)\r\nans=0\r\nfor i in range(1,k+1):\r\n ans+=x*(len(s)+i)\r\nt=1\r\nfor i in s:\r\n ans+=(arr[ord(i)-ord(\"a\")])*(t)\r\n t+=1\r\nprint(ans)\r\n\r\n\r\n", "s= input()\r\nn= int(input())\r\navals,z,maxi,alpha= list(map(int, input().split())),0,0,list(\"abcdefghijklmnopqrstuvwxyz\")\r\nfor i in range(len(s)): z+=(i+1)*avals[alpha.index(s[i])]\r\nfor e in avals: maxi= max(maxi, e)\r\nfor i in range(n): z+= maxi*(len(s)+1+i)\r\nprint(z)\r\n\r\n\r\n\r\n", "s=input()\r\nk=int(input())\r\na=list(map(int, input().split()))\r\nans=0\r\nl=len(s)\r\nt=max(a)\r\nd={}\r\nfor i in range(26):\r\n d[chr(97+i)]=a[i]\r\nfor i in range(l):\r\n ans+=d[s[i]]*(i+1)\r\nans+=t*((k+l+1)*(k+l)//2-(l+1)*(l)//2)\r\nprint(ans)\r\n \r\n", "s=input()\r\nk=int(input())\r\na=list(map(int,input().split()))\r\nsum_=0\r\nfor i in range(len(s)):\r\n sum_+=a[ord(s[i])-97]*(i+1)\r\np=max(a)\r\nfor i in range(len(s)+1,len(s)+k+1):\r\n sum_+=(i)*p\r\nprint(sum_)\r\n", "s1=input()\r\nn=int(input())\r\nl1=list(map(int,input().split()))\r\nindex=l1.index(max(l1))\r\ns1+=chr(97+index)*n\r\nsum1=0\r\nfor i in range (len(s1)):\r\n sum1+=l1[ord(s1[i])-97]*(i+1)\r\nprint(sum1)", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nans = 0\r\nfor i in range(len(s)):\r\n ans += w[ord(s[i]) - ord('a')] * (i + 1)\r\nprint(ans + max(w) * (2 * len(s) + k + 1) * k // 2)\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nresult = 0\r\nfor i, ch in enumerate(s):\r\n result += w[ord(ch) - ord('a')] * (i + 1)\r\nfor i in range(len(s) + 1, len(s) + k + 1):\r\n result += max(w) * i\r\nprint(result)\r\n", "s=input()\r\nk=int(input())\r\nA=['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\nc=list(map(int,input().split()))\r\nl=len(s)\r\nu=max(c)\r\ncost=0\r\nfor i in range (len(s)):\r\n\tcost=cost+(i+1)*c[A.index(s[i])]\r\nfor i in range(k):\r\n\tcost=cost+(l+i+1)*u\r\nprint(cost)", "'''\r\ndef main():\r\n import sys\r\n sys.stdin.readline()\r\n sys.stdout.write()\r\nif __name__=='__main__':\r\n main()\r\n'''\r\n#401\r\n'''\r\ndef main():\r\n import sys\r\n a,b=map(int,sys.stdin.readline().split())\r\n if a>b:\r\n if a-b==1:\r\n s=''\r\n for i in range(a+b):\r\n if i&1:\r\n s+='1'\r\n else:\r\n s+='0'\r\n else:\r\n s='-1'\r\n elif b>a:\r\n if b<=2*(a+1):\r\n s=''\r\n if b-a==1:\r\n for i in range(a+b):\r\n if i&1:\r\n s+='0'\r\n else:\r\n s+='1'\r\n else:\r\n n=b-a-1\r\n i=0\r\n flag=0\r\n while i<a+b:\r\n if flag&1:\r\n s+='0'\r\n else:\r\n if n:\r\n s+='11'\r\n n-=1\r\n i+=1\r\n else:\r\n s+='1'\r\n i+=1\r\n flag=~flag\r\n else:\r\n s='-1'\r\n else:\r\n s=''\r\n for i in range(a+b):\r\n if i&1:\r\n s+='1'\r\n else:\r\n s+='0'\r\n sys.stdout.write(s)\r\nif __name__=='__main__':\r\n main()\r\n'''\r\n#508B\r\n'''\r\ndef main():\r\n import sys\r\n n=sys.stdin.readline().strip()\r\n lodd=int(n[-1])\r\n odd=0\r\n even=0\r\n s=''\r\n j=0\r\n for i in n:\r\n if ord(i)&1:\r\n odd+=1\r\n else:\r\n even+=1\r\n feven=int(i)\r\n feindex=j\r\n if(feven<lodd):\r\n break\r\n j+=1\r\n if even:\r\n for i in range(len(n)):\r\n if i==feindex:\r\n sys.stdout.write(n[-1])\r\n elif i==len(n)-1:\r\n sys.stdout.write(str(feven))\r\n else:\r\n sys.stdout.write(n[i])\r\n else:\r\n sys.stdout.write('-1')\r\nif __name__=='__main__':\r\n main()\r\n'''\r\n#447B\r\ndef main():\r\n import sys\r\n s=sys.stdin.readline().strip()\r\n n=int(sys.stdin.readline())\r\n tup=tuple(map(int,sys.stdin.readline().split()))\r\n maxim=max(tup)\r\n score=0\r\n for i in range(len(s)):\r\n score+=(i+1)*tup[ord(s[i])-97]\r\n d=n*(2*len(s)+n+1)//2\r\n score+=maxim*d\r\n sys.stdout.write(str(score))\r\nif __name__=='__main__':\r\n main()\r\n", "def love(s,arr,k):\r\n cnt=1\r\n ans=0\r\n for i in s:\r\n ans+=cnt*(arr[ord(i)-97])\r\n cnt+=1\r\n maxi=max(arr)\r\n while k:\r\n ans+=cnt*maxi\r\n cnt+=1\r\n k-=1\r\n return ans\r\n\r\na=input()\r\nk=int(input())\r\nlst=list(map(int,input().strip().split()))\r\nprint(love(a,lst,k))", "s = input().strip()\r\nk = int(input().strip())\r\nvals = list(map(int, input().strip().split()))\r\ntotal = 0\r\nfor i in range(len(s)):\r\n val = vals[ord(s[i]) - 97]\r\n total += (i + 1) * val\r\n#print(total)\r\ni += 2\r\nfor j in range(k):\r\n total += max(vals) * i\r\n i = i + 1\r\nprint(total)", "import string\r\na=input()\r\nk=int(input())\r\nw=dict(zip(string.ascii_lowercase,map(int,input().split())))\r\nz=len(a)\r\nc=max(w.values())*(z+z+k+1)*k//2\r\nfor i in range(z):c+=w[a[i]]*(i+1)\r\nprint(c)", "s=input()\r\nk=(int(input()))\r\nw=list(map(int, input().split()))\r\nwm=max(w)\r\nans=0\r\nls=len(s)\r\nfor i in range(ls):\r\n ans+=(i+1)*w[ord(s[i])-ord(\"a\")]\r\nfor i in range(ls,k+ls):\r\n ans+=(i+1)*wm\r\nprint(ans)", "import sys\r\n\r\ninput = lambda: sys.stdin.buffer.readline().decode().strip()\r\n# print = sys.stdout.write\r\ninl = lambda: list(map(int, input().split()))\r\n\r\n\r\ndef char_pos(letter):\r\n return ord(letter) - 97\r\n\r\n\r\ndef char_from_pos(pos):\r\n return chr(pos + 97)\r\n\r\n\r\ns = list(input())\r\nk = int(input())\r\nw = inl()\r\n\r\nans = sum([(i + 1) * w[char_pos(let)] for i, let in enumerate(s)])\r\nans += sum(range(len(s) + 1, len(s) + k + 1)) * max(w)\r\n\r\nprint(ans)\r\n", "s=input()\r\nn=int(input())\r\nl1=list(map(int,input().split()))\r\nans=0\r\nl2=['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(len(s)):\r\n xz=l1[l2.index(s[i])]\r\n ans+=xz*(i+1)\r\nmx=max(l1)\r\n\r\nfor j in range(n):\r\n ans+= (len(s)+j+1)*mx\r\nprint(ans)", "s = input()\r\nk = int(input())\r\nvalue = [-1] + list(map(int,input().split()))\r\ndef indexx(alpha):\r\n return ord(alpha)-96\r\nmaxi = max(value)\r\nres = 0\r\nlength = len(s)\r\nfor i in range(1,length+1):\r\n res += i*value[indexx(s[i-1])]\r\nres += maxi*k*(2*length+1+k)//2\r\nprint(res)", "\r\nnum_inp=lambda: int(input())\r\narr_inp=lambda: list(map(int,input().split()))\r\nsp_inp=lambda: map(int,input().split())\r\nstr_inp=lambda:input()\r\ns=input()\r\na=len(s)\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nc=0\r\nfor x in range(a):\r\n\tc+=l[ord(s[x])-97]*(x+1)\r\nc+=((n*n+n+2*a*n)*max(l))//2\r\nprint(c)", "s,ans = input(), 0\r\nk = int(input())\r\nsp = list(map(int, input().split()))\r\nfor i in range(1, len(s) + 1):\r\n ans += i * (sp[ord(s[i - 1]) - 97])\r\nfor j in range(i + 1, k + 1 + i):\r\n ans += j * max(sp)\r\nprint(ans)", "s = input()\r\nn = int(input())\r\nvals = [int(w) for w in input().split()]\r\nmaxVal = -1\r\nfor val in vals:\r\n maxVal = max(maxVal, val)\r\nresult = 0\r\nfor (index, char) in enumerate(s):\r\n i = ord(char)-97\r\n result += vals[i]*(index+1)\r\nfor i in range(len(s)+1,len(s)+n+1):\r\n result += maxVal*i\r\nprint(result)", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\ninitial=0\r\nc=1\r\nfor i in s:\r\n ind=ord(i)-97\r\n initial+=l[ind]*c\r\n c+=1\r\nprint(initial+(((k*c)+(k*(k-1))//2)*max(l)))", "s=input()\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\nd={}\r\na=97\r\nfor i in w:\r\n d[chr(a)]=i\r\n a=a+1\r\n#print(d)\r\nm=max(w)\r\nc=0\r\nfor i in range(len(s)+k):\r\n if(i<len(s)):\r\n c=c+d[s[i]]*(i+1)\r\n else:\r\n c=c+(i+1)*m\r\nprint(c)\r\n \r\n", "s, n = input(), int(input())\r\nz = [int(x) for x in input().split()]\r\n\r\nans = 0\r\nfor i in range(len(s)):\r\n ans += (i+1)*z[ord(s[i])-ord('a')]\r\n\r\nfor i in range(n):\r\n ans += (i + 1 + len(s))*max(z)\r\n\r\nprint(ans)\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nans = 0\r\nfor i in range(len(s)):\r\n ans += (i + 1) * w[ord(s[i]) - ord('a')]\r\nfor i in range(len(s) + 1, k + len(s) + 1):\r\n ans += i * max(w)\r\nprint(ans)", "s = input()\r\nk = int(input())\r\nw = [int(x) for x in input().split()]\r\nprint(sum(x * w[ord(y) - ord('a')] for x, y in zip(range(1, len(s) + 1), s)) + (k * (k + 1) // 2 + k * len(s)) * max(w))", "def alphabet_position(x):\r\n return ord(x) & 31\r\n\r\ns = input()\r\nn = int(input())\r\nsize = len(s)\r\nl = list(map(int, input().split()))\r\nmax = max(l)\r\nans = 0\r\nfor i in range(size+1,size+n+1):\r\n ans += (i * max)\r\nfor i in range(1,len(s)+1):\r\n ans += (i * l[alphabet_position(s[i-1])-1])\r\nprint(ans)", "import math\ns = input()\nx = int(input())\nwc = [int(i) for i in input().split()]\nr = 0\nfor i, c in enumerate(s):\n r += (i+1)*wc[ord(c)-ord(\"a\")]\nmwc = max(wc)\nfor i in range(len(s), len(s)+x):\n r += (i+1)*mwc\nprint(r)\n", "s=input()\nl=len(s)\nn=int(input())\na=list(map(int,input().split()))\nm=max(a)\nans=m*((((l+n)*(l+n+1))//2) - ((l*(l+1)//2)))\nfor i in range(l):\n\tans+=a[ord(s[i])-ord('a')]*(i+1)\nprint(ans)\n", "line = input()\nl=len(line)\nk = int(input())\ns = list(map(int,input().split()))\n\nma = max(s)\nans = 0\nfor i,x in enumerate(line):\n ans += s[ord(x)-ord('a')]*(i+1)\nfor j in range(k):\n ans += ma * (l+j+1)\nprint(ans)\n", "s = input()\r\nk = int(input())\r\nvals = list(map(int,input().split()))\r\nalphabets = \"abcdefghijklmnopqrstuvwxyz\"\r\nss=alphabets[vals.index(max(vals))]\r\ns = s+ss*k\r\nscore = 0\r\nfor i,v in enumerate(s):\r\n score+=vals[alphabets.index(v)]*(i+1)\r\nprint(score)", "def get_max_value():\r\n\tstring = input()\r\n\tsuffix_chars_count = int(input())\r\n\tweights = list(map(int, input().split()))\r\n\r\n\tvalue = 0\r\n\tfor index, char in enumerate(string):\r\n\t\tvalue += (index+1)*weights[ord(char)-97]\r\n\r\n\tfor index in range(len(string)+1, len(string)+suffix_chars_count+1):\r\n\t\tvalue += index*max(weights)\r\n\r\n\tprint(value)\r\n\r\n\r\nget_max_value()\r\n", "s = input()\nk = int(input())\nalph = list(map(int,input().split()))\nsum=0\nfor i in range(len(s)):\n\tsum += (i+1)*alph[ord(s[i])-97]\np = max(alph)\nn = len(s)+k\ns = len(s)\nsum +=((n*(n+1)//2-s*(s+1)//2))*p\nprint(sum)\n", "t = input()\r\nk = int(input())\r\nw = [int(x) for x in input().split()]\r\ntotal = 0\r\nfor i in range(len(t)):\r\n total = total + w[ord(t[i])-97]*(i+1)\r\nfor i in range(k):\r\n total = total + max(w)*(len(t)+i+1)\r\nprint(total)", "k,n = input(),int(input())\r\nl = list(map(int,input().split()))\r\nprint(sum([i*(l[ord(k[i-1])-97]) if i<=len(k) else max(l)*i for i in range(1,len(k)+n+1)]))", "alp='abcdefghijklmnopqrstuvwxyz'\r\nstring=input()\r\nk1=int(input())\r\nalpha=dict()\r\nvalue=input().split(' ')\r\nfor i,j in zip(alp,value):\r\n alpha[i]=int(j)\r\nkey_max = max(alpha.keys(), key=(lambda k: alpha[k]))\r\nsum1=0\r\nj=1\r\nfor i in string:\r\n sum1=sum1+j*alpha[i]\r\n j=j+1\r\nwhile(k1>0):\r\n sum1=sum1+j*alpha[key_max]\r\n j=j+1\r\n k1=k1-1\r\nprint(sum1)", "s = input()\r\nk, n = int(input()), len(s)\r\nt = list(map(int, input().split()))\r\nprint((k * n + (k * (k + 1)) // 2) * max(t) + sum(t[ord(s[i]) - 97] * (i + 1) for i in range(n)))\r\n", "def triangle(n):\n return n * (n + 1) >> 1\n\n\ns = input()\nk = int(input())\nw = list(map(int, input().split()))\nprint(\n sum(i * w[ord(si) - 97] for i, si in enumerate(s, 1))\n + ((triangle(k + len(s)) - triangle(len(s))) * max(w))\n)\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Jul 13 19:36:10 2020\r\n\r\n@author: HP\r\n\"\"\"\r\n\r\ns = input()\r\nk = int(input())\r\nl= list(map(int, input().split()))\r\n \r\nmaxl1=max(l)\r\ncount= 0\r\n \r\nfor i in range(1, len(s) + 1):\r\n count += l[ord(s[i - 1]) - ord('a')] * i\r\n \r\nfor i in range(len(s) + 1, len(s) + 1 + k):\r\n count += maxl1 * i\r\n \r\nprint(count)", "a = list(input())\r\nn = int(input())+1\r\nb = list(map(int,input().split()))\r\nz =0\r\nfor i in range(1,len(a)+1):\r\n\tz+=b[ord(a[i-1])-97]*i\r\nfor i in range(len(a)+1,len(a)+n):\r\n\tz+=i*max(b)\r\nprint(z)", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split(' ')))\r\n\r\nsum = 0\r\n\r\nfor index, el in enumerate(s):\r\n sum += w[ord(el)-97] * (index+1)\r\n \r\nmax_w = max(w);\r\nresult = max_w * (((len(s)+1) + (len(s)+k))/2) * k\r\nprint(int(sum + result))", "s=input()\r\nk=int(input())\r\nvalues=list(map(int,input().split()))\r\nmydict={}\r\nsumm=0\r\nfor i in range(26):\r\n mydict[chr(97+i)]=values[i]\r\nite=1\r\nwhile ite<=len(s):\r\n summ+=((ite)*(mydict[s[ite-1]]))\r\n ite+=1\r\nm=max(values)\r\nwhile ite<=len(s)+k:\r\n summ+=(ite*m)\r\n ite+=1\r\nprint(summ)", "import math\r\ndef inp(): return int(input())\r\ndef inps(): return map(int, input().split())\r\ndef inpl(): return [int(n) for n in input().split() if n.isdigit()]\r\n\r\ns = input()\r\nk = inp()\r\nl = inpl()\r\nr = 0\r\nfor i in range(0,len(s)):\r\n r += l[ord(s[i])-ord('a')] * (i+1)\r\nmx = 0\r\nfor i in l : mx = max(mx,i)\r\nr += (2 * len(s) + k + 1) * k * mx / 2\r\nprint(int(r))", "s=input()\r\nk=int(input())\r\na=list(map(int,input().split()))\r\nn=len(s)\r\ntot=0\r\nj=1\r\nfor i in range(n):\r\n tot+=j*(a[ord(s[i])-97])\r\n j+=1\r\nm=0\r\np=0\r\nfor i in range(26):\r\n if m<a[i]:\r\n m=a[i]\r\n p=m \r\nwhile j<=n+k:\r\n tot+=(j*p)\r\n j+=1\r\nprint(tot) \r\n", "s = input()\ns = list(s)\nn = len(s)\nk = int(input())\narr = [int(i) for i in input().split()]\nmx = max(arr)\nvalue = 0\nfor i in range(n):\n c = s[i]\n value += (i+1)*arr[ord(c)-ord('a')]\nisu = ((i+1+k)*(i+k+2))//2 - ((i+1)*(i+2))//2\nvalue += mx*isu\nprint(value)\n", "\r\ns=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\n# print(97-ord(\"a\"))\r\ntot=0\r\nma=max(l)\r\nfor i in range(1,len(s)+k+1):\r\n\tif i<=len(s):\r\n\t\ttot+=l[ord(s[i-1])-97]*i\r\n\telse:\r\n\t\ttot+=ma*i\r\nprint(tot)", "from string import ascii_lowercase\nimport heapq\n\ntext = input()\ntext = list(text)\nk = int(input())\nweights = map(int, input().split())\n\nn = len(text)\n\nletter_weights = {i:j for i, j in zip(ascii_lowercase, weights)}\n\ntext_weights = [i * letter_weights[j] for i, j in enumerate(text, start=1)]\n\nmax_weight_to_be_added = max(letter_weights.values())\n\nmax_weight_to_be_added = [max_weight_to_be_added * a for a in range(n+1, n+k+1)]\nprint(sum(text_weights + max_weight_to_be_added))", "s = input()\r\nk = int(input())\r\nw = list(map(int,input().split()))\r\nans = 0\r\ncnt = 0\r\nmx = 0\r\nfor i in s:\r\n cnt = cnt+1\r\n ans = ans+w[ord(i)-ord('a')]*cnt\r\nfor i in range(len(w)):\r\n if w[i]>mx:\r\n mx = w[i]\r\nfor i in range(k):\r\n cnt = cnt+1\r\n ans = ans+mx*cnt\r\nprint(ans)\r\n", "s = str(input())\r\nk = int(input())\r\na = list(map(int,input().split()))\r\nhey = 'abcdefghijklmnopqrstuvwxyz'\r\nd = {}\r\nt = {}\r\nfor i in range(len(a)):\r\n d[hey[i]] = a[i]\r\n t[a[i]] = hey[i]\r\nget = max(a)\r\nmaximum = t[get]\r\ns += str(maximum)*(k)\r\nans = 0\r\nfor i in range(len(s)):\r\n ans += d[s[i]]*(i+1)\r\nprint(ans)", "s=input()\r\nn=int(input())\r\nc=0\r\nl=[int(i) for i in input().split()]\r\nfor i in range(len(s)):\r\n asc=ord(s[i])-97\r\n c+=(i+1)*l[asc]\r\nl.sort(reverse=True)\r\nfor i in range(1,n+1):\r\n c+=(len(s)+i)*l[0]\r\nprint(c)", "import math,sys,re,itertools\r\nrs,ri,rai=input,lambda:int(input()),lambda:list(map(int, input().split()))\r\ns = rs()\r\nk = ri()\r\nw = rai()\r\nm = max(w)\r\nmi = w.index(m)\r\nres = 0\r\nfor i in range(k):\r\n s += chr(ord('a') + mi)\r\nfor i, ch in enumerate(s):\r\n res += (i+1) * w[ord(ch) - ord('a')]\r\nprint(res)\r\n", "import sys\r\ninput=sys.stdin.readline\r\ns=input().rstrip()\r\nn=len(s)\r\nk=int(input())\r\nlst=list(map(int,input().split()))\r\nm=max(lst)\r\nidx=lst.index(m)\r\nalpha= [chr(x) for x in range(ord('a'), ord('z') + 1)]\r\nchar=alpha[idx]\r\ndic={}\r\nfor i in range(26):\r\n dic[alpha[i]]=lst[i]\r\nval=0\r\nfor j in range(len(s)):\r\n val+=dic[s[j]]*(j+1)\r\nval+=dic[char]*(n*k+k*(k+1)//2)\r\nprint(val)\r\n", "s=input()\r\nj=[\"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\nk=int(input())\r\nl=list(map(int,input().split()))\r\na=max(l)\r\nd=0\r\nfor i in range(k+len(s)):\r\n if(i<len(s)):\r\n d=d+(i+1)*(l[j.index(s[i])])\r\n else:\r\n d=d+((i+1)*a)\r\nprint(d)", "s = input()\r\nk= int(input())\r\nl=list(map(int,input().split()))\r\nindex=0\r\nm=max(l)\r\n\r\nsu=0\r\nfor i in range(len(s)):\r\n n= ord(s[i])-97\r\n su+= (i+1)*(l[n])\r\n\r\nfor i in range(k):\r\n ind=len(s)+i+1\r\n su+= m*ind\r\n\r\nprint(su)\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int,input().split()))\r\nc = 0\r\ni = 0\r\nwhile i<len(s):\r\n c += w[ord(s[i])-97]*(i+1)\r\n i+=1\r\nm = max(w)\r\nfor j in range(k):\r\n c+=m*(i+1)\r\n i+=1\r\nprint(c)", "l=list(input())\r\nn=int(input())\r\nq=[]\r\nh=\"a\"\r\nfor i in range(0, 26): \r\n\tq.append(h) \r\n\th= chr(ord(h)+1) \r\ncount=0\r\np=[]\r\nc=0\r\ns=list(map(int,input().split()))\r\nfor i in range(1,len(l)+n+1):\r\n\tif i-1<len(l):\r\n\t\tr=q.index(l[i-1])\r\n\t\tcount+=s[r]*i\r\n\telse:\r\n\t\tr=max(s)\r\n\t\tc+=1\r\n\t\tcount+=i*r\r\nprint(count)", "# Contest: 20 - 2100 <= Codeforces Rating <= 2199 (https://a2oj.com/ladder?ID=20)\n# Problem: (6) DZY Loves Strings (Difficulty: 2) (http://codeforces.com/problemset/problem/447/B)\n\ndef rint():\n return int(input())\n\n\ndef rints():\n return list(map(int, input().split()))\n\n\ns = input()\nk = rint()\nw = rints()\nmw = max(w)\nprint(sum((w[ord(s[i]) - ord('a')] if i < len(s) else mw) * (i + 1) for i in range(len(s) + k)))\n", "g=input()\r\nalpha=\"abcdefghijklmnopqrstuvwxyz\"\r\nt=list(alpha)\r\ndic={}\r\nk=int(input())\r\nr=input()\r\ntt=r.split()\r\nfor i in range(0,len(r.split())):\r\n\tdic[t[i]]=int(tt[i])\t\r\nresult=0\r\nfor i in range(0,len(g)):\r\n\tresult=result+(i+1)*dic[g[i]]\r\nkey=max(dic.values())\t\r\nfor h in range(len(g),len(g)+k):\r\n\tresult=result+(h+1)*key\r\nprint(result)\t\r\n\r\n", "a = 97\r\nst = input()\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\nmx = max(arr)\r\nans = 0\r\nfor i in range(len(st) + n):\r\n if (i < len(st)): ans = ans + arr[ord(st[i]) - a] * (i + 1)\r\n else: ans = ans + mx * (i + 1)\r\nprint(ans)\r\n\r\n", "import string\r\ns=input()\r\nk=int(input())\r\na=list(map(int, input().split()))\r\nb=0\r\nfor i in range(len(s)):\r\n p=string.ascii_lowercase.index(s[i])\r\n b=b+a[p]*(i+1)\r\nif k==0:\r\n print(b)\r\nelse:\r\n m=max(a)\r\n c=list(range(len(s)+1,len(s)+k+1))\r\n c1=[i * m for i in c]\r\n b=b+sum(c1)\r\n print(b)", "s = input()\r\nn = int(input())\r\nlets = list(map(int,input().split()))\r\nc = 0\r\nx = 1\r\nfor i in s:\r\n p = lets[ord(i) - 97]\r\n #print(i, p, x)\r\n c+=(p*x)\r\n x+=1\r\n#print(x)\r\nmx = max(lets)\r\nfor i in range(n):\r\n c+=(mx * x)\r\n x+=1\r\nprint(c)", "from sys import *\r\nfrom math import *\r\nfrom sys import stdin,stdout\r\nfrom collections import *\r\n\r\nint_arr = lambda : list(map(int,stdin.readline().strip().split()))\r\nstr_arr = lambda :list(map(str,stdin.readline().split()))\r\nget_str = lambda : map(str,stdin.readline().strip().split())\r\nget_int = lambda: map(int,stdin.readline().strip().split())\r\nget_float = lambda : map(float,stdin.readline().strip().split())\r\n\r\n\r\nmod = 1000000007\r\nsetrecursionlimit(1000)\r\n\r\ns = str(input())\r\nk = int(input())\r\narr = int_arr()\r\ntot = 0\r\nl = len(s)\r\nmx = max(arr)\r\nlst = list('abcdefghijklmnopqrstuvwxyz')\r\nfor i in range(l + k):\r\n if i < l :\r\n tot += (i + 1) * arr[ord(s[i]) - ord('a')]\r\n else:\r\n tot += (i + 1) * mx\r\nprint(tot)\r\n\r\n\r\n \r\n\r\n\r\n\r\n#for _ in range(int(input())):\r\n\r\n", "string = input()\r\nk = int(input())\r\nlst = list(map(int, input().split()))\r\nrs = 0\r\nfor i in range(0, len(string)):\r\n rs += (i + 1) * lst[ord(string[i]) - 97]\r\nfor i in range(0, k):\r\n rs += (i + len(string) + 1) * max(lst)\r\nprint(rs)", "s = input()\r\nk = int(input())\r\nweights = list(map(int, input().split())) \r\n\r\nmax_value = 0\r\nfor i in range(len(s)):\r\n char_weight = weights[ord(s[i]) - ord('a')]\r\n max_value += (i + 1) * char_weight\r\n\r\nmax_weight = max(weights)\r\nfor i in range(len(s) + 1, len(s) + k + 1):\r\n max_value += i * max_weight\r\n\r\nprint(max_value)\r\n", "s = input()\r\nk = int(input())\r\nw = [int(el) for el in input().split()]\r\n\r\nans = 0\r\nzp = ord('a')\r\ni = 1\r\n\r\nfor el in s:\r\n\tans += i * w[ord(el) - zp]\r\n\ti += 1\r\n\r\nmaxw = max(w)\r\n\r\nwhile k:\r\n\tans += i * maxw\r\n\tk -= 1\r\n\ti += 1\r\n\r\nprint(ans)\r\n", "s=input()\r\nk=int(input())\r\nM = list(map(int,input().split()))\r\n\r\nan = 0\r\nfor i,q in enumerate(s):\r\n an += M[ord(q)-97]*(i+1)\r\nan += ((len(s)+1)+(len(s)+k))*k//2*max(M)\r\nprint(an)", "s = input()\r\nn = int(input())\r\na = list(map(int,input().split()))\r\nmaxi = max(a)\r\nres = 0\r\nfor i in range(len(s)):\r\n res += (a[ord(s[i]) - ord('a')] * (i + 1))\r\nfor j in range(len(s)+1 , len(s)+n+1):\r\n res += (maxi * j)\r\nprint(res)", "# import sys \r\n# sys.stdin=open(\"input.in\",'r')\r\n# sys.stdout=open(\"out.out\",'w')\r\nx=input()\r\nn=int(input())\r\ns=list(map(int,input().split()))\r\nv=0\r\nfor i in range(len(x)):\r\n\tm=ord(x[i])-97\r\n\tv+=(i+1)*s[m]\r\ns.sort()\r\ni+=2\r\nwhile n:\r\n\tv+=i*s[-1]\r\n\tn-=1\r\n\ti+=1\r\nprint(v)", "st=input()\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\nw2={chr(ord('a')+i):w[i] for i in range(26)}\r\nm=max(w)\r\nprint(sum([w2[st[i]]*(i+1) for i in range(len(st))])+sum([i*m for i in range(len(st)+1,len(st)+1+k)]))", "s=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nt=[chr(x) for x in range(ord('a'), ord('z') + 1)]\r\nd={}\r\nfor i in range(26):\r\n if t[i] not in d:\r\n d[t[i]]=l[i]\r\nm=max(l)\r\ni=l.index(m)\r\ns=s+t[i]*k\r\nr=0\r\nfor i in range(len(s)):\r\n r=r+((i+1)*d[s[i]])\r\nprint(r)", "s = input()\r\nk = int(input())\r\nl = list(map(int, input().split()))\r\nm = max(l)\r\nc = 0\r\nf = 0\r\nfor i in s:\r\n f+=1\r\n c += l[ord(i)-97] * (f)\r\nfor i in range(k):\r\n f+=1\r\n c += m * f\r\nprint(c)", "from string import ascii_lowercase\ndef main():\n s = input()\n k = int(input())\n w = list(map(int,input().split()))\n func = dict(zip(ascii_lowercase,w))\n z = max(w)\n score = 0\n j = 1\n for i in s:\n score += func[i]*j\n j += 1\n score += ((len(s)*k + (k*(k+1))//2)*z)\n print(score)\nif __name__ == '__main__':\n main()\n", "s=input()\r\nk=int(input())\r\nnums=[int(nums) for nums in input().split()]\r\nmaxvalue=0\r\nfor index in range(len(s)):\r\n maxvalue+=(index+1)*(nums[ord(s[index])-97])\r\nn=len(s)\r\ntemp=0\r\nfor index in range(k):\r\n n+=1\r\n temp+=n\r\nn=max(nums)\r\nmaxvalue+=(n*temp)\r\nprint(maxvalue)", "str=input()\r\nnum=int(input())\r\nli=list(map(int,input().split()))\r\nmx=max(li)\r\nans=0\r\nfor i in range(0,len(str)):\r\n ans+=(i+1)*(li[ord(str[i])-ord('a')])\r\nval=len(str)+1\r\nwhile(num!=0):\r\n ans+=mx*val\r\n num=num-1\r\n val=val+1\r\nprint(ans)", "s=input()\r\nk=int(input())\r\narr=list(map(int,input().split()))\r\nsu=0\r\nfor j in range(len(s)):\r\n su+=(j+1)*arr[ord(s[j])-97]\r\n#print (su)\r\nn=k+len(s)\r\n#print (max(arr))\r\nt=((n*(n+1))/2-(k*(k+1))/2)\r\n#print (t)\r\nprint (int(su+max(arr)*((n*(n+1))/2-(len(s)*(len(s)+1))/2)))", "s=input()\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\nd={chr(97+i):w[i] for i in range(26)}\r\nm=0\r\nfor i in range(len(s)+k):\r\n\tif i<len(s):\r\n\t\tm+=((i+1)*d[s[i]])\r\n\tif i>=len(s):\r\n\t\tm+=(i+1)*max(d.values())\r\nprint(m)", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nresult = 0\r\n\r\nfor c in range(len(s)):\r\n\tresult += (w[ord(s[c])-97] * (c+1))\r\nm = max(w)\r\nfor c in range(c+1, c+k+1):\r\n\tresult += (m * (c+1))\r\nprint(result)\r\n", "s=input()\r\nl=len(s)\r\nk=int(input())\r\ndict1={}\r\nlist1=list(map(int,input().split()))\r\nfor i in range(26):\r\n dict1[chr(97+i)]=list1[i]\r\nss=0\r\nlist1.sort(reverse=True)\r\nfor i in range(1,l+1):\r\n ss+=i*(dict1[s[i-1]])\r\nc=l+1\r\nfor i in range(k):\r\n ss+=c*(list1[0])\r\n c+=1\r\nprint(ss)", "st=input()\r\nn=int(input())\r\nthat=list(st)\r\nl=list(map(int,input().split()))\r\nalpha=[]\r\nch=\"a\"\r\nfor i in range(26):\r\n alpha.append(ch)\r\n ch=str(chr(ord(ch)+1))\r\nfor i in range(n):\r\n that.append(alpha[l.index(max(l))])\r\ns=0\r\nc=1\r\nfor i in that:\r\n s+=c*l[alpha.index(i)]\r\n c+=1\r\nprint(s)", "initial_string = input()\r\nnum_additional_chars = int(input())\r\nweights = list(map(int, input().strip().split(' ')))\r\nmax_weight = max(weights)\r\n\r\naOrdinal = ord('a')\r\nresult = sum((i+1) * weights[ord(character)-aOrdinal] for i, character in enumerate(initial_string))\r\nresult += sum((i+1+len(initial_string)) * max_weight for i in range(0, num_additional_chars))\r\n\r\nprint(result)\r\n", "s = input()\r\np = [(ord(i)-96) for i in s]\r\nn = int(input())\r\nl = list(map(int,input().split()))\r\ntotal=0\r\nfor i,j in enumerate(p):\r\n total+=(i+1)*l[j-1]\r\n\r\nt=max(l)\r\nfor i in range(len(s),len(s)+n):\r\n total+=t*(i+1)\r\nprint(total)\r\n", "alp = {'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}\r\ns = list(input())\r\nk = int(input())\r\nval = list(map(int,input().split()))\r\ntot = 0\r\ni = 1\r\nwhile(i <= len(s)):\r\n x = alp[s[i-1]]\r\n x = val[x]\r\n tot = tot + (i * x)\r\n i = i + 1\r\nk = k + len(s)\r\nx = max(val)\r\nwhile(i <= k):\r\n tot = tot + (i * x)\r\n i = i + 1\r\nprint(tot)", "#n, m = input().split()\n#n = int (n)\n#m = int (m)\n#k = int (k)\ns = input()\nn = int(input())\n\na = list(map(int, input().split()))\n#a = list(map(int, input().split()))\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 = []\n \n#h = [\"\"] * n\n#f1 = sorted(f, key = lambda tup: tup[0])\n\n#f1 = sorted(t, key = lambda tup: tup[0])\nm = max(a)\no = 0\nj = 1\nx = False\nfor i in range(len(s)):\n if(a[ord(s[i])-97] <= m or x):\n o += (j) * a[ord(s[i])-97] \n j += 1\n else:\n # print(int(o), j, i )\n o += m * n* (j+n+j-1)/ 2\n j += n\n x = True\n # print(int(o), j, i )\nif ( not x):\n #print(int(o), j, i )\n o += m * n* (j+n+j-1)/ 2\n j += n\n x = True\n #print(int(o), j, i )\n \nprint(int(o))\n", "n=(input())\r\nk=int(input())\r\na=list(map(int,input().split()))\r\nm=max(a)\r\ni=a.index(m)\r\nsum=0\r\nj=1\r\nwhile j<=len(n):\r\n s=ord(n[j-1])-97\r\n t=a[s]\r\n sum+=j*t\r\n j+=1\r\nj=len(n)\r\nwhile k>0:\r\n sum+=(k+j)*m\r\n k-=1\r\nprint(sum)", "s = input()\r\nk = int(input())\r\nw = {chr(a):int(x) for a,x in enumerate(input().split(),97)}\r\nsumm = sum([w[x]*i for i,x in enumerate(s,1)])\r\nmaxi = max(w.values())\r\na = len(s)+1\r\nn = k\r\nd = a+k-1\r\nsumofap = n*(a+d)//2\r\nsumm+= maxi*(sumofap)\r\nprint(summ)", "a=input()\r\nb=int(input())\r\nc=list(map(int,input().split()))\r\nd=0\r\nfor _ in range(len(a)):\r\n d+=c[ord(a[_])-97]*(_+1)\r\nprint(d+max(c)*(b*(b+1)//2+len(a)*b))\r\n\r\n\r\n# CodeBy: RAHUL MAHAJAN\r\n# A2OJ: rahulmahajan\r\n# CC: anonymous0201\r\n# CF: rahulmahajan\r\n# CSES: rahulmahajan", "s = input()\r\nk = int(input())\r\narr = [int(i) for i in input().split()]\r\nbrr=[i for i in arr]\r\nz = \"abcdefghijklmnopqrstuvwxyz\"\r\nd = {}\r\nfor i in range(26):\r\n d.update({z[i]:arr[i]})\r\nbrr.sort(reverse=True)\r\nans = 0\r\nfor i in range(len(s)):\r\n ans = ans + (i + 1) * d[s[i]]\r\nx = 0\r\nfor i in range(len(s) + 1, len(s) + k + 1):\r\n ans = ans + i * brr[0]\r\n x = x + 1\r\nprint(ans)\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Dec 8 16:34:06 2020\r\n\r\n@author: harshvardhan\r\n\"\"\"\r\n\r\n\r\n\r\ns = input(\"\")\r\nk = int(input())\r\nls = list(map(int,input().split()))\r\n\r\ncost = 0\r\nfor i in range(len(s)):\r\n curr = ord(s[i])-97\r\n cost+=((i+1)*(ls[curr]))\r\n\r\ni = i+1\r\nfor j in range(k):\r\n cost+= ((i+1)*(max(ls)))\r\n i+=1\r\n \r\nprint(cost)\r\n\r\n", "s = input()\r\nk = int(input())\r\nw = list(map(int, input().split()))\r\nm = max(w)\r\nc = 0\r\nfor i, sym in enumerate(s):\r\n\tc += w[ord(sym) - ord('a')] * (i + 1)\r\nfor i in range(len(s), len(s) + k):\r\n\tc += m * (i + 1)\r\nprint(c)\r\n", "s = input()\r\nk = int(input())\r\narr = {}\r\nbrr = list(map(int,input().split()))\r\nfor i in range(26):\r\n arr[chr(97+i)] = brr[i]\r\nres = 0\r\nfor i in range(len(s)):\r\n #print(arr[s[i]])\r\n res += arr[s[i]] * (i+1)\r\n\r\nmaxx = 0\r\nfor i in arr:\r\n if arr[i] > maxx:\r\n maxx = arr[i]\r\ni = len(s) + 1\r\n\r\nwhile i <= len(s) + k:\r\n res += maxx*i\r\n i += 1\r\nprint(res)\r\n", "import fileinput\r\nimport heapq\r\n\r\nline_counter = 0\r\n\r\ncurrent_problem = None\r\n\r\nclass Problem:\r\n def set_input_string(self, input_string):\r\n self.input_string = input_string\r\n def set_num_additional_chars(self, num_additional_chars):\r\n self.num_additional_chars = num_additional_chars\r\n def set_weights(self, weights):\r\n self.weights = weights\r\n def set_max_weight(self, max_weight):\r\n self.max_weight = max_weight\r\n def calculate_result(self):\r\n aOrdinal = ord('a')\r\n result = 0\r\n for index, character in enumerate(self.input_string):\r\n result += (index+1) * self.weights[ord(character) - aOrdinal]\r\n relative_index = len(self.input_string)\r\n for i in range(relative_index, relative_index + self.num_additional_chars):\r\n result += (i+1) * self.max_weight\r\n return result\r\n\r\ndef director(directive):\r\n return {\r\n 0 : process_input_string,\r\n 1 : process_additional_input_chars,\r\n 2 : process_character_map_and_print_result\r\n }[directive]\r\n\r\ndef process_input_string(input_line):\r\n lower_input = input_line.lower()\r\n global current_problem\r\n current_problem = Problem()\r\n current_problem.set_input_string(lower_input)\r\n\r\ndef process_additional_input_chars(input_line):\r\n current_problem.set_num_additional_chars(int(input_line))\r\n\r\ndef process_character_map_and_print_result(input_line):\r\n prioritized_weights = []\r\n current_problem.set_weights(list(map(int, input_line.strip().split(' '))))\r\n\r\n weights = [(input[1], input[0]) for input in enumerate(current_problem.weights)]\r\n [heapq.heappush(prioritized_weights, weight) for weight in current_problem.weights]\r\n\r\n max_weight = heapq.nlargest(1, prioritized_weights)\r\n current_problem.set_max_weight(max_weight[0])\r\n\r\n print(current_problem.calculate_result())\r\n\r\nfor input_line in fileinput.input():\r\n director(line_counter%3)(input_line.strip())\r\n line_counter += 1\r\n", "import sys\r\nimport math\r\nfrom sys import stdin, stdout\r\n \r\n# TAKE INPUT\r\ndef get_ints_in_variables():\r\n return map(int, sys.stdin.readline().strip().split())\r\ndef get_int(): return int(input())\r\ndef get_ints_in_list(): return list(\r\n map(int, sys.stdin.readline().strip().split()))\r\ndef get_list_of_list(n): return [list(\r\n map(int, sys.stdin.readline().strip().split())) for _ in range(n)]\r\ndef get_string(): return sys.stdin.readline().strip()\r\n \r\ndef main():\r\n # Write Your Code Here\r\n st = input()\r\n k = int(input())\r\n alpha = {\"a\":0, \"b\":1, \"c\":2, \"d\":3, \"e\":4, \"f\":5, \"g\":6,\r\n \"h\":7, \"i\":8, \"j\":9, \"k\":10, \"l\":11, \"m\":12, \"n\":13,\r\n \"o\":14, \"p\":15, \"q\":16, \"r\":17, \"s\":18, \"t\":19, \"u\":20,\r\n \"v\":21, \"w\":22, \"x\":23, \"y\":24, \"z\":25}\r\n arr = get_ints_in_list()\r\n mx = 0\r\n for x in range(0, 26):\r\n if mx < arr[x]:\r\n mx = arr[x]\r\n\r\n i = 1\r\n res = 0 \r\n for j in range(0, len(st)):\r\n res += (i*arr[alpha[st[j]]])\r\n i += 1 \r\n\r\n for _ in range(0, k):\r\n res += (i*mx)\r\n i += 1\r\n print(res)\r\n\r\n# calling main Function\r\nif __name__ == \"__main__\":\r\n main()", "# your code goes here\r\ns=input()\r\nk=int(input())\r\nl=list(map(int,input().split()))\r\nn=len(s)\r\nft=n+1\r\nsu=2*ft+k-1\r\nsu=k*su\r\nsu=su//2\r\nsu=max(l)*su\r\nsu1=0\r\nfor i in range(len(s)):\r\n\tind=ord(s[i])-97\r\n\tsu1=su1+(i+1)*l[ind]\r\nprint(su1+su)\r\n\t", "s=input().upper()\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\nz=len(s)\r\nsum=0\r\ntheDict ={chr(y):y-64 for y in range(65,91)}\r\nfor j in range(len(s)):\r\n sum+=w[theDict[s[j]]-1]*(j+1)\r\nn=max(w)\r\nfor i in range(1,k+1):\r\n\tsum+=(i+z)*n\r\nprint(sum)", "string = list(str(input()))\r\ncharToInsert = int(input())\r\narray = list(map(int,input().split()))\r\ncounter = 0\r\nfor i in range(0,len(string)):\r\n buffer = ord(string[i])-97\r\n counter+=array[buffer]*(i+1)\r\n\r\ny = max(array)\r\n\r\nfor i in range(len(string)+1,len(string)+charToInsert+1):\r\n counter+= i*y\r\nprint(counter)", "s, k = input(), int(input())\r\na = *map(int, input().split()),\r\ns += k * chr(a.index(max(a)) + 97)\r\nprint(sum(a[ord(s[i]) - 97] * (i + 1) for i in range(len(s))))", "def solve(k,s,arr):\n\td={}\n\tx= 'abcdefghijklmnopqrstuvwxyz'\n\tmx=-1\n\tfor i in range(26) :\n\t\td[x[i]]=arr[i]\n\t\tmx=max(mx , arr[i])\n\t\n\tval =0\n\tfor i in range(len(s)) :\n\t\tval += (i+1)*d[s[i]]\n\t\n\tadd = ((k)*(k+2*len(s)+1))/2\n\n\n\treturn int(val + add*mx)\n\t\n\n\n\n\n\t\n\n\t\n\n \n \n \nfrom sys import stdin\ninput = stdin.readline\n\ns=input().strip()\nn=int(input())\nl=[int(x) for x in input().split()]\n\n\n\nprint(solve(n,s,l))", "s=input()\nn=int(input())\nL=[int(i) for i in input().split()]\nm=max(L)\nans=0\nfor j in range(len(s)+n):\n\tif(j<len(s)):\n\t\tans+=L[ord(s[j])-97]*(j+1)\t\n\telse:\n\t\tans+=m*(j+1)\nprint(ans)\t", "s = input()\nk = int(input())\nl = list(map(int, input().split()))\n\nmx = max(l)\nans = 0\n\nfor i in range(len(s)):\n\tans += (i + 1) * l[ord(s[i]) - ord('a')]\n\t\nans += (k/2) * mx * (2*(len(s) + 1) + k - 1)\nprint (int(ans))\n", "try: \r\n a=input()\r\n \r\n k=int(input())\r\n l=list(map(int,input().split()))\r\n num=len(a)\r\n \r\n t=0\r\n for i in range(num):\r\n \tt+=l[ord(a[i])-97]*(i+1)\r\n t+=max(l)*(2*num*k+k**2+k)//2\r\n print(t)\r\nexcept:pass ", "def main():\n\tt = input()\n\tk = int(input())\n\tw = [int(x) for x in input().split()]\n\n\ts, n = 0, len(t)\n\tfor i in range(n):\n\t\ts += w[ord(t[i])-ord('a')] * (i + 1)\n\n\tmax_w = max(w)\n\n\ts += n * k * max_w\n\ts += k * (k + 1) * max_w // 2\n\n\tprint(s)\n\nif __name__ == '__main__':\n\tmain()", "f=lambda:map(int,input().split())\r\nsp=input()\r\nv=0\r\nk=int(input())\r\nl=list(f())\r\nfor i in range(len(sp)):\r\n v+=(i+1)*(l[ord(sp[i])-ord('a')])\r\nprint(v+sum(range(i+2,i+k+2))*max(l))", "z=input()\r\nd=int(input())\r\ndi={}\r\nx=list(map(int,input().split()))\r\nc=0\r\nfor i in range(97,123):\r\n if di.get(chr(i),0)==0:\r\n di[chr(i)]=x[c]\r\n c+=1\r\nma=max(di.values())\r\nw=0\r\nfor i in range(len(z)+d):\r\n if i<len(z):\r\n w+=di[z[i]]*(i+1)\r\n else:\r\n w+=ma*(i+1)\r\nprint(w)\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "s= input()\r\nn=int(input())\r\narr= list(map(int,input().split()))\r\nar= []\r\nl= len(s)\r\np = max(arr)\r\nfor t in range(l):\r\n ar += [arr[ord(s[t])- 97]]\r\nfor y in range(n):\r\n ar += [p]\r\nsum = 0\r\n#print(ar)\r\nfor g in range(l+ n):\r\n sum += ((g + 1) * ar[g])\r\nprint(sum)\r\n \r\n \r\n \r\n \r\n", "R=lambda:map(int, input().split())\r\n\r\ns = input()\r\nn = int(input())\r\na = list(R())\r\nm = max(a)\r\n\r\nans = 0\r\nfor j in range(len(s)+n):\r\n if j < len(s):\r\n ans += a[ord(s[j])- 97] *(j+1)\r\n else:\r\n ans += m * (j+1)\r\n\r\nprint(ans)", "s, k, w, sm = input(), int(input()), list(map(int, input().split())), 0\r\nprint(sum(w[ord(s[i-1])-97]*i if(i<len(s)+1) else i*max(w) for i in range(1,k+len(s)+1)))", "s = input()\r\nk = int(input())\r\nl = list(map(int ,input().split()))\r\n\r\nm = max(l)\r\nans = 0\r\nfor i in range(len(s)):\r\n ans += l[ord(s[i]) - 97] * (i + 1)\r\nfor i in range(1 , k + 1):\r\n ans += m * (len(s) + i)\r\n \r\nprint(ans)", "from sys import stdin\r\nfrom sys import stdout\r\ns = stdin.readline()\r\nk = stdin.readline()\r\nt = stdin.readline()\r\nk=int(k)\r\nt=t.strip('\\n')\r\ncode = str.split(t)\r\ns=s.strip('\\n')\r\nmaxi = 0\r\nfor i in code:\r\n if int(i)>maxi:\r\n maxi = int(i)\r\n\r\ntotalLen = len(s) + k\r\n\r\nmaxValue = 0\r\nfor i in range(len(s)+1,totalLen+1):\r\n maxValue+= maxi*i\r\nj=1\r\nfor i in s:\r\n maxValue+= int(code[(ord(i)-97)]) * j\r\n j+=1\r\nstdout.write(str(maxValue))\r\n", "string, k, alpha = [input() for x in range(3)]\nk = int(k)\nalpha = [int(x) for x in alpha.split()]\n\nmaximum = max(alpha)\n\ndef stringValue(string, k, maximum):\n total = 0\n\n # calculate k\n n = k + len(string) # since the summation formula starts from index 1\n kValue = maximum * (n*(n+1)/2) # summation starting from 1 till end\n realKValue = kValue - (maximum*(len(string)*(len(string)+1)/2)) # summation from 1 till len(string)\n total += realKValue\n # calculating the string value\n for i in range(len(string)):\n total += (i+1)*alpha[ord(string[i])-97] # a ascii is 97\n\n return int(total)\n\nprint (stringValue(string, k, maximum))\n", "s = input()\r\nn = len(s)\r\nk = int(input())\r\nweights = list(map(int, input().split()))\r\ncurr_score = sum([weights[ord(s[i])-ord('a')]*(i+1)for i in range(n)])\r\nweights.sort(reverse=True)\r\ncurr_score += weights[0]*(n*k + ((k)*(k+1))//2)\r\nprint(curr_score)", "n=input()\r\nk=int(input())\r\nw=list(map(int,input().split()))\r\nm=max(w)\r\nx=0\r\nfor i in range(len(n)):\r\n a=ord(n[i])-97\r\n x+=(i+1)*w[a]\r\nfor i in range(len(n),len(n)+k):\r\n x+=m*(i+1)\r\nprint(x)\r\n", "s = input()\r\nn = int(input())\r\nalpha = list(map(int, input().split()))\r\nbig = sorted(alpha, reverse=True)\r\ntotal = 0\r\nfor i in range(len(s)):\r\n total += (i+1) * alpha[ord(s[i]) - ord('a')]\r\nfor j in range(n):\r\n total += big[0] * (len(s) + 1 + j)\r\nprint(total)", "string = str(input())\r\n\r\nk = int(input())\r\n\r\nalphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',\r\n 'v', 'w', 'x', 'y', 'z']\r\n\r\n#weights = [int(x) for x in str(input()).split(\" \")]\r\n\r\ndic = {}\r\nfor count, x in enumerate(str(input()).split(\" \")):\r\n dic.update({alphabet[count]: int(x)})\r\n\r\nmax_w = max(dic.values())\r\n\r\nall_sum = 0\r\nfor count, sym in enumerate(string):\r\n all_sum += (count+1) * dic[str(sym)]\r\n\r\nfor new in range(len(string) + 1, len(string) + k + 1):\r\n all_sum += new * max_w\r\n\r\nprint(all_sum)" ]
{"inputs": ["abc\n3\n1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "mmzhr\n3\n443 497 867 471 195 670 453 413 579 466 553 881 847 642 269 996 666 702 487 209 257 741 974 133 519 453", "ajeeseerqnpaujubmajpibxrccazaawetywxmifzehojf\n23\n359 813 772 413 733 654 33 87 890 433 395 311 801 852 376 148 914 420 636 695 583 733 664 394 407 314", "uahngxejpomhbsebcxvelfsojbaouynnlsogjyvktpwwtcyddkcdqcqs\n34\n530 709 150 660 947 830 487 142 208 276 885 542 138 214 76 184 273 753 30 195 722 236 82 691 572 585", "xnzeqmouqyzvblcidmhbkqmtusszuczadpooslqxegldanwopilmdwzbczvrwgnwaireykwpugvpnpafbxlyggkgawghysufuegvmzvpgcqyjkoadcreaguzepbendwnowsuekxxivkziibxvxfoilofxcgnxvfefyezfhevfvtetsuhwtyxdlkccdkvqjl\n282\n170 117 627 886 751 147 414 187 150 960 410 70 576 681 641 729 798 877 611 108 772 643 683 166 305 933", "pplkqmluhfympkjfjnfdkwrkpumgdmbkfbbldpepicbbmdgafttpopzdxsevlqbtywzkoxyviglbbxsohycbdqksrhlumsldiwzjmednbkcjishkiekfrchzuztkcxnvuykhuenqojrmzaxlaoxnljnvqgnabtmcftisaazzgbmubmpsorygyusmeonrhrgphnfhlaxrvyhuxsnnezjxmdoklpquzpvjbxgbywppmegzxknhfzyygrmejleesoqfwheulmqhonqaukyuejtwxskjldplripyihbfpookxkuehiwqthbfafyrgmykuxglpplozycgydyecqkgfjljfqvigqhuxssqqtfanwszduwbsoytnrtgc\n464\n838 95 473 955 690 84 436 19 179 437 674 626 377 365 781 4 733 776 462 203 119 256 381 668 855 686", "qkautnuilwlhjsldfcuwhiqtgtoihifszlyvfaygrnivzgvwthkrzzdtfjcirrjjlrmjtbjlzmjeqmuffsjorjyggzefwgvmblvotvzffnwjhqxorpowzdcnfksdibezdtfjjxfozaghieksbmowrbeehuxlesmvqjsphlvauxiijm\n98\n121 622 0 691 616 959 838 161 581 862 876 830 267 812 598 106 337 73 588 323 999 17 522 399 657 495", "tghyxqfmhz\n8\n191 893 426 203 780 326 148 259 182 140 847 636 778 97 167 773 219 891 758 993 695 603 223 779 368 165", "nyawbfjxnxjiyhwkydaruozobpphgjqdpfdqzezcsoyvurnapu\n30\n65 682 543 533 990 148 815 821 315 916 632 771 332 513 472 864 12 73 548 687 660 572 507 192 226 348", "pylrnkrbcjgoytvdnhmlvnkknijkdgdhworlvtwuonrkhrilkewcnofodaumgvnsisxooswgrgtvdeauyxhkipfoxrrtysuepjcf\n60\n894 206 704 179 272 337 413 828 119 182 330 46 440 102 250 191 242 539 678 783 843 431 612 567 33 338", "vhjnkrxbyhjhnjrxvwxmhxwoxttbtqosfxtcuvhfjlkyfspeypthsdkkwnqdpxdlnxsgtzvkrgqosgfjrwetqbxgoarkjhrjbspzgblsapifltkfxbfdbxqwoohlgyzijmiwnpmveybyzvasoctxsmgjehpyysmqblwnmkappbecklqjfmxhlyceordroflnposohfplrvijxbwvqdtvzhobtrumiujnyrfbwthvciinuveoizkccelxtaveiiagryqnyvsgfnipnavrtmdqlcnldepocbpzmqnarkdvykds\n276\n364 244 798 82 582 9 309 950 286 547 892 371 569 159 705 975 740 845 655 179 130 993 255 552 882 657", "gsaddmezrnttfalbwlqbnedumvikplfosw\n12\n290 850 872 361 483 895 152 118 974 619 701 154 899 285 328 712 669 984 407 340 851 775 324 892 554 860", "a\n0\n5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "lol\n3\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"], "outputs": ["41", "29978", "1762894", "2960349", "99140444", "301124161", "30125295", "136422", "2578628", "9168707", "144901921", "809931", "5", "21"]}
UNKNOWN
PYTHON3
CODEFORCES
420
e1478fe113da588a61423b6304a9e4dc
Godsend
Leha somehow found an array consisting of *n* integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that the remaining parts are glued together into one array and the game continues. The second player can choose a subsegment of non-zero length with an even sum and remove it. Loses the one who can not make a move. Who will win if both play optimally? First line of input data contains single integer *n* (1<=≤<=*n*<=≤<=106) — length of the array. Next line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=109). Output answer in single line. "First", if first player wins, and "Second" otherwise (without quotes). Sample Input 4 1 3 2 3 2 2 2 Sample Output First Second
[ "n = int(input())\r\na = list(map(int,input().split()))\r\nk = sum(a)\r\nif k%2 == 1:\r\n print('First')\r\nelse:\r\n found = False\r\n for x in a:\r\n if x % 2 == 1:\r\n found = True\r\n break\r\n if found:\r\n print('First')\r\n else:\r\n print('Second')", "n=int(input())\r\nprint(\"First\" if 1 in [int(e)%2 for e in input().split()] else \"Second\")", "n = int(input())\r\nl = list(map(int,input().split()))\r\no = len([i for i in l if i%2==1])\r\nif o>=1:\r\n print('First')\r\nelse:\r\n print('Second')", "import sys\r\nimport math\r\n\"\"\"files=False\r\nif files:\r\n fn='symposium'\r\n sys.stdin=open(fn+'.in')\r\n sys.stdout=open(fn+'.out',mode='w')\r\n\"\"\"\r\n\r\ndef ria():\r\n return [int(i) for i in input().split()]\r\nsz=ria()[0]\r\nar=ria()\r\nsuma=sum(ar)\r\nif suma%2==1:\r\n print('First')\r\n exit(0)\r\nthere=False\r\ntherek=False\r\nfor i in ar:\r\n if i%2==1:\r\n there=True\r\n if i%2==0:\r\n therek=True\r\n\r\nif (there and len(ar)>2) or (not therek):\r\n print('First')\r\nelse:\r\n print('Second')\r\n", "n = input()\r\nprint(\"First\" if any(int(i) % 2 for i in list(input().split())) else \"Second\")", "#!/usr/bin/env python3\r\nn=int(input())\r\ns=0\r\no = False\r\na = input().split(' ')\r\nfor i in a:\r\n s += int(i)\r\n if o is False and int(i)%2==1:\r\n o = True\r\nif s%2==1 or o:\r\n print('First')\r\nelse:\r\n print('Second')\r\n", "n,flag=int(input()),0\r\na=[int(i) for i in input().split()]\r\nfor i in a:\r\n if(i%2!=0):\r\n flag=1 \r\n break\r\n \r\nif(flag==1):\r\n print('First')\r\nelse:\r\n print('Second')", "n = int(input())\r\nll = list(map(int,input().split()))\r\nodd = 0\r\neven = 0\r\nfor i in ll:\r\n if i % 2 == 0:\r\n even += 1\r\n else:\r\n odd += 1\r\nif odd == 0:\r\n print('Second')\r\nelse:\r\n print('First')\r\n", "n=int(input())\nl=list(map(int,input().split()))\nj=0\nfor q in l:\n if q%2:\n j+=1\nif j:\n print(\"First\")\nelse:\n print(\"Second\")", "n = int(input())\r\nl = [int(i) for i in input().split()]\r\nfor i in l:\r\n if i % 2 == 1:\r\n print(\"First\")\r\n exit(0)\r\nprint(\"Second\")\r\n ", "n=int(input())\r\na=list(map(int, input().split()))\r\nif sum(a)%2!=0:\r\n print('First')\r\nelse:\r\n test=0\r\n for i in a:\r\n if i%2!=0:\r\n test=1\r\n break\r\n if not test:\r\n print('Second')\r\n else:\r\n print('First')", "n = int(input())\r\nprint(\"First\" if sum([i % 2 for i in list(map(int, input().split()))]) else \"Second\")", "n = int(input())\r\na = [int(x) for x in input().split()]\r\ncheck = 0\r\nfor i in a:\r\n if i%2!=0:\r\n check = 1\r\n break\r\nif check:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "n = int(input())\r\nm = input()\r\nlit = list(map(int, m.split()))\r\nlit.sort()\r\nodd = 0\r\neven = 0\r\nsum = 0\r\nsum_odd = 0\r\nsum_even = 0\r\nodd_list=[]\r\nfor item in lit:\r\n if (item % 2 == 1):\r\n odd = odd + 1\r\n odd_list.append(item)\r\n\r\nif (odd == 0):\r\n print(\"Second\")\r\n\r\nelse:\r\n print(\"First\")\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n = int(input())\r\na = [1 for i in map(int,input().split()) if i%2 == 1]\r\n\r\nif len(a) == 0:\r\n\tprint(\"Second\")\r\nelse :\r\n\tprint(\"First\")\r\n", "n=int(input())\r\ns=input().split()\r\ndef f(x):\r\n if x[-1] in '02468':\r\n return 0\r\n return 1\r\nv=0\r\nfor i in range(n):\r\n if s[i][-1] in '02468':\r\n None\r\n else:\r\n v+=1\r\nif str(v)[-1] in '02468':\r\n if v>0:\r\n print('First')\r\n else:\r\n print('Second')\r\nelse:\r\n print('First')\r\n \r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\no,e=0,0\r\nfor i in l:\r\n if i%2==0:\r\n e=e+1 \r\n else:\r\n o=o+1 \r\nif o%2==1:\r\n print(\"First\")\r\nelse:\r\n if o==0:\r\n print(\"Second\")\r\n elif o%2==0:\r\n print(\"First\")", "n=int(input())\r\narr=list(map(int,input().split()))[:n]\r\nflag=0\r\nfor i in range(n):\r\n if(arr[i] & 1):\r\n flag=1\r\n break\r\nif(flag==1):\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "n=int(input())\r\nl=list(map(lambda x:int(x[-1]),input().split()))\r\n\r\nk=0\r\nwhile True:\r\n\tj=sum(l)\r\n\tif k%2==0:\r\n\t\tif j%2!=0:\r\n\t\t\tprint('First')\r\n\t\t\tbreak\r\n\t\telse:\r\n\t\t\tfor x in range(len(l)):\r\n\t\t\t\tif l[x]%2==1:\r\n\t\t\t\t\tl=l[:x]+l[x+1:]\r\n\t\t\t\t\tbreak\r\n\t\t\telse:\r\n\t\t\t\tprint('Second')\r\n\t\t\t\tbreak\r\n\r\n\telse:\r\n\t\tif j%2==0:\r\n\t\t\tprint('Second')\r\n\t\t\tbreak\r\n\t\telse:\r\n\t\t\tfor x in range(len(l)):\r\n\t\t\t\tif l[x]%2==0:\r\n\t\t\t\t\tl=l[:x]+l[x+1:]\r\n\t\t\t\t\tbreak\r\n\t\t\telse:\r\n\t\t\t\tprint('First')\r\n\t\t\t\tbreak\r\n\tk+=1\r\n", "'''input\n2\n2 2\n'''\nn = int(input())\na = list(map(int, input().split()))\nif sum(a) % 2 == 1:\n\tprint(\"First\")\nelse:\n\tprint(\"First\" if any(i % 2 == 1 for i in a) else \"Second\")\n", "n=int(input())\r\na=[int(x) for x in input().split()]\r\nc=0\r\nflag=0\r\nfor i in range(n):\r\n if a[i]%2!=0:\r\n flag=1\r\n break\r\nif flag==1:\r\n print('First')\r\nelse:\r\n print('Second') ", "n = int(input())\nr = sum(map(lambda x: int(x)%2, input().split()))\nif r > 0:\n print('First')\nelse:\n print('Second')\n", "import sys\r\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\ntot = sum(a)\r\nodd = False\r\nfor i in a:\r\n if i & 1:\r\n odd = True\r\n break\r\nprint('First' if odd else 'Second')", "n = int(input())\r\nl = list(map(int, input().split()))\r\ncount = True\r\nfor i in l:\r\n\tif i%2 == 1:\r\n\t\tcount = False\r\nif count:\r\n\tprint(\"Second\")\r\nelse:\r\n\tprint(\"First\")", "second = True\r\nn = int(input())\r\narray = list(map(int, input().strip().split()))\r\nfor i in array:\r\n\tif i % 2 == 1:\r\n\t\tsecond = False\r\n\t\tbreak\r\nif second:\r\n\tprint(\"Second\")\r\nelse:\r\n\tprint(\"First\")", "x = int(input())\na = list(map(int, input().split()))\nif sum(a) % 2 == 1:\n\tprint(\"First\")\nelif sum(a) % 2 == 0:\n\tfor c in range(x):\n\t\tif a[c] % 2 == 1 or a[-1-c] % 2 == 1:\n\t\t\tresp = \"First\"\n\t\t\tbreak\n\t\telse:\n\t\t\tresp = \"Second\"\n\tprint(resp)\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nfor i in a:\r\n\tif i%2!=0:\r\n\t\tprint(\"First\")\r\n\t\tsys.exit(0)\r\n\r\nprint(\"Second\")\r\n", "n = input()\r\narr = list(map(int, input().split()))\r\no = 0\r\nfor i in arr:\r\n if i%2 == 1:\r\n o += 1\r\nif o % 2 == 1:\r\n print('First')\r\nelif o % 2 == 0 and o != 0:\r\n print('First')\r\nelse:\r\n print('Second')", "lenofarray=int(input())\r\nnumbers=list(map(int,input().split()))\r\nwinner=\"Second\"\r\nfor i in numbers:\r\n if(i%2!=0):\r\n winner=\"First\"\r\n break\r\nprint(winner)", "n = int(input())\r\narr = [int(x) for x in input().split()]\r\n\r\nprint('First' if any(x % 2 == 1 for x in arr) else 'Second')\r\n", "import sys\r\nn=int(sys.stdin.readline())\r\nm=list(map(int,sys.stdin.readline().split()))\r\np='Second'\r\nfor i in m:\r\n if i%2==1:\r\n p='First'\r\n break\r\nsys.stdout.write(str(p))", "n=int(input())\r\nlist1=list(map(int,input().split()))\r\nif sum(list1)%2!=0:\r\n print(\"First\")\r\n exit()\r\nodd_sum=0\r\nfor x in list1:\r\n if x%2!=0:\r\n odd_sum+=1\r\nif odd_sum%2==0 and odd_sum!=0:\r\n print(\"First\")\r\n exit()\r\n\r\nprint(\"Second\")", "import sys\r\n\r\nn = int(input())\r\nlst = input()\r\nlst = lst.split(\" \")\r\nlst = [ int(x) for x in lst ]\r\n\r\noddSum = 0\r\nevenSum = 0\r\noddTurn = True\r\n\r\nfor num in lst:\r\n if num % 2 == 0:\r\n evenSum += num\r\n else:\r\n oddSum += num\r\n\r\nremaining = n\r\n\r\nif oddSum == 0:\r\n print(\"Second\")\r\n sys.exit()\r\nelif evenSum == 0:\r\n print(\"First\")\r\n sys.exit()\r\n\r\n\r\n\r\nwhile True:\r\n if oddTurn:\r\n remaining -= oddSum\r\n oddTurn = False\r\n\r\n if remaining <= 0:\r\n print(\"First\")\r\n break\r\n else:\r\n remaining -= evenSum\r\n oddTurn = True\r\n\r\n if remaining <= 0:\r\n print(\"First\")\r\n break\r\n", "n=int(input())\r\narr= list(map(int, input().rstrip().split()))\r\noe=0\r\nfor i in range(n):\r\n if(arr[i]%2==1):\r\n oe+=1\r\nif(oe==0):\r\n print('Second')\r\nelse:\r\n print('First')", "n=int(input())\r\na=list(map(int,input().split()))\r\nl=[i for i in a if i%2==1]\r\nif len(l)==0:\r\n print(\"Second\")\r\nelse:\r\n if len(l)%2==0:\r\n print(\"First\")\r\n else:\r\n print(\"First\")\r\n", "a = int(input())\r\nb = input().split()\r\ne = 0\r\nfor i in range(a):\r\n d = int(b[i])\r\n if d % 2 == 0:\r\n e += 1\r\nif e == a:\r\n print('Second')\r\nelse:\r\n print('First')", "from sys import *\r\ninput = lambda:stdin.readline()\r\n\r\nint_arr = lambda : list(map(int,stdin.readline().strip().split()))\r\nstr_arr = lambda :list(map(str,stdin.readline().split()))\r\nget_str = lambda : map(str,stdin.readline().strip().split())\r\nget_int = lambda: map(int,stdin.readline().strip().split())\r\nget_float = lambda : map(float,stdin.readline().strip().split())\r\n\r\n\r\nmod = 1000000007\r\nsetrecursionlimit(1000)\r\n\r\nn = int(input())\r\narr = int_arr()\r\n\r\ntot = sum(arr)\r\nif tot % 2 != 0:\r\n print('First')\r\nelse:\r\n flag = 0\r\n for i in range(n):\r\n if arr[i] % 2 != 0:\r\n flag = 1\r\n break\r\n print('Second' if flag == 0 else 'First')", "n=int(input())\r\na=list(map(int, input().split()))\r\nodd_count = len(list(filter(lambda x: (x%2 != 0) , a)))\r\nif sum(a)%2!=0:\r\n print(\"First\")\r\nelse:\r\n if odd_count==0:\r\n print(\"Second\")\r\n else:\r\n print(\"First\")", "import sys\r\ndef input(): return sys.stdin.readline().strip()\r\ndef iinput(): return int(input())\r\ndef minput(): return map(int, input().split()) \r\ndef listinput(): return list(map(int, input().split()))\r\nn=iinput()\r\na=listinput()\r\nss=0\r\nfor i in a:\r\n ss+=i%2\r\nif ss:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "input()\r\nprint(\"First\" if any(True for i in list(map(int, input().split())) if i % 2 == 1) else \"Second\")", "n=int(input())\r\np=[int(x) for x in input().split()]\r\nif sum(p)%2!=0:\r\n print('First')\r\nelse:\r\n\r\n for i in range (0,n):\r\n p[i]=p[i]%2\r\n if p.count(1)==0:\r\n print('Second')\r\n else:\r\n print('First')\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n = int(input())\r\nnums = list(map(int,input().split()))\r\nisOk = False\r\nfor i in nums:\r\n\tif i & 1:\r\n\t\tisOk = True\r\n\t\tbreak\r\nprint(\"First\" if isOk else \"Second\")\r\n", "input(); ans = 0\r\nfor _ in map(int, input().split()): ans |= (_&1)\r\nprint([\"Second\", \"First\"][ans]);", "n = int(input())\na = list(map(int, input().split()))\n\ntot = sum(a)\nif tot % 2 == 1:\n print(\"First\")\nelse:\n all_even = True\n for a_i in a:\n if a_i % 2 == 1:\n all_even = False\n break\n if all_even:\n print(\"Second\")\n else:\n print(\"First\")\n", "length = int(input())\r\nlistofNum = input()\r\nlistofNum = list(map(int, listofNum.split()))\r\n\r\nFirstflag = False\r\n\r\nsum = 0\r\nfor x in listofNum:\r\n sum += x\r\n\r\nif (sum%2 == 1):\r\n Firstflag = True\r\nelse:\r\n for x in listofNum:\r\n if x%2 == 1:\r\n Firstflag = True\r\n\r\nif Firstflag:\r\n print('First')\r\nelse:\r\n print('Second')", "n = int(input().strip())\r\na = [ int(i)%2 for i in input().strip().split(' ')]\r\nif sum(a)%2==1:\r\n\tprint('First')\r\nelse:\r\n\tif sum(a)==0:\r\n\t\tprint('Second')\r\n\telse:\r\n\t\tprint('First')", "# 0 1 0 1 1 0 0 0 1\n#\n# 0 1 1 0 1 0 1 0\n#\n# 0 0 1 1 0 0\n\nn = input()\nl = list(map(int,input().split(\" \")))\n\ncounter= 0\nfor i in l:\n if i%2==0:\n counter+=1\nif counter==len(l):\n print(\"Second\")\nelse:\n print(\"First\")\n", "import sys\n\nnumbers = ''\n\ni = 0\nfor line in sys.stdin:\n\ti += 1\n\tif i == 1:\n\t\tcontinue\n\tif i == 2:\n\t\tnumbers = line[:-1]\n\t\tbreak\n\nnumbers = numbers.split(' ')\n\nfor num in numbers:\n\tif int(num) % 2 == 1:\n\t\tprint(\"First\")\n\t\tbreak\nelse:\n\tprint(\"Second\")", "input()\r\nprint('First' if sum(list(map(lambda x: int(x)%2, input().split()))) else 'Second')\r\n\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\ns=sum(a)\r\nif s%2==0:\r\n f=0\r\n for i in range(n):\r\n if a[i]%2==1:\r\n f=1\r\n break\r\n if f:\r\n print(\"First\")\r\n else:\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")", "n=int(input())\r\narr=list(map(int,input().split()))\r\nfor i in range(len(arr)):\r\n arr[i]=arr[i]%2\r\nif arr.count(0)==n:\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")", "n=int(input())\r\na=list(map(int,input().split()))\r\nfor i in a:\r\n\tif i%2!=0:\r\n\t\tprint(\"First\")\r\n\t\tbreak\r\nelse:\r\n\tprint(\"Second\")", "input()\r\nv = list(map(int, input().split()))\r\n\r\nprint(\"First\" if any([x%2==1 for x in v]) else \"Second\")\r\n\r\n\r\n", "n = int(input())\r\na = [int(i) for i in input().split()]\r\nif sum(a)%2!=0:\r\n print(\"First\")\r\nelse:\r\n odd, even = 0, 0\r\n for i in range(n):\r\n if a[i]%2==0:\r\n even+=1\r\n else:\r\n odd+=1\r\n if odd==0:\r\n print(\"Second\")\r\n elif odd%2==0:\r\n print(\"First\")\r\n else:\r\n print(\"Second\")", "input()\r\nA = list(map(int, input().split()))\r\nprint('First' if sum(A) % 2 else 'First' if any(a % 2 for a in A) else 'Second')", "input()\r\nprint('SFeicrosntd'[sum(int(c) % 2 for c in input().split()) != 0::2])\r\n", "def f(l):\r\n return 'First' if sum([i%2>0 for i in l])>0 else 'Second'\r\n\r\n_ = input()\r\nl = list(map(int,input().split()))\r\nprint(f(l))\r\n", "n = int(input())\r\nnumbers = list(map(int, input().split()))\r\n\r\nfor i in numbers:\r\n if (i % 2 != 0):\r\n print(\"First\")\r\n exit()\r\nprint(\"Second\")", "def main():\n import re\n input()\n for m in re.finditer(r'\\d*(\\d)',input()):\n if ord(m.group(1)) & 1:\n print(\"First\")\n return\n print(\"Second\")\n\n\nif __name__ == '__main__':\n main()\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\nflag = 0\r\ns = 0\r\nfor i in range(n):\r\n s+=l[i]\r\n if l[i]%2!=0:\r\n flag = 1\r\n\r\nif s%2!=0:\r\n print(\"First\")\r\nelse:\r\n if flag == 1:\r\n print(\"First\")\r\n else:\r\n print(\"Second\")", "input();print(\"SFeicrosntd\"[any(i%2for i in map(int,input().split()))::2])", "n = int(input())\r\na = map(int, input().split())\r\nprint(\"First\" if sum([i%2 for i in a]) else \"Second\")\r\n", "n = int(input())\r\na = list(map(int,input().split()))\r\n\r\nfirst_win = False\r\n\r\nfor i in a:\r\n\tif i%2!=0:\r\n\t\tfirst_win = True\r\n\t\tbreak\r\n\r\nif first_win:\r\n\tprint(\"First\")\r\nelse:\r\n\tprint(\"Second\")", "\r\n\r\nn = int(input())\r\n\r\narr = list(map(int,input().split()))\r\n\r\nfor i in arr :\r\n if i % 2 != 0 :\r\n print('First')\r\n exit()\r\n\r\nprint('Second')\r\n\r\n", "n=int(input())\r\nmass=input().split()\r\nfor i in range(n):\r\n mass[i]=int(mass[i])%2\r\nif sum(mass)%2==1:\r\n print('First')\r\nelse:\r\n if 1 in mass:\r\n print('First')\r\n else:\r\n print('Second')", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Aug 20 11:03:55 2017\n\n@author: root\n\"\"\"\ndef sol():\n\tn = int(input())\n\tints = [int(num) for num in input().split(\" \")]\n\tfor num in ints:\n\t\tif num % 2 == 1:\n\t\t\tprint(\"First\")\n\t\t\treturn\n\n\tprint(\"Second\")\n\treturn\n\nif __name__==\"__main__\":\n\tsol()", "cnt = lambda s, x: s.count(x)\r\nii = lambda: int(input())\r\nsi = lambda: input()\r\nf = lambda: map(int, input().split())\r\ndgl = lambda: list(map(int, input()))\r\nil = lambda: list(map(int, input().split()))\r\nn=ii()\r\no,e=0,0\r\nsm=0\r\nl=il()\r\nfor i in range(n):\r\n sm+=l[i]\r\n if l[i]&1:\r\n o+=1\r\n else:\r\n e+=1\r\nif sm & 1:\r\n print('First')\r\nelif o>0:\r\n print('First')\r\nelse:\r\n print('Second')", "n=int(input())\r\na=list(map(int,input().split()))\r\no,e=0,0\r\nfor i in range(n):\r\n\tif a[i]%2==0:\r\n\t\te+=1\r\n\telse:\r\n\t\to+=1\r\nif sum(a)%2==0 and o==0:\r\n\tprint(\"Second\")\r\nelse:\r\n\tprint(\"First\")", "n= int(input())\r\na= [int(i) for i in input().split()]\r\nz=0\r\nfor i in range(len(a)):\r\n if (a[i]%2)!=0:\r\n print (\"First\")\r\n z=1\r\n break\r\nif z!=1:\r\n print (\"Second\")\r\n", "n = int(input())\r\na = list(map(int,input().split()))\r\n\r\ns = sum(a)\r\nif s%2 == 1:\r\n\tprint(\"First\")\r\nelse :\r\n\tflag = 0\r\n\tfor i in a:\r\n\t\tif i%2==1: \r\n\t\t\tflag = 1\r\n\t\t\tbreak\r\n\tif flag :\r\n\t\tprint(\"First\")\r\n\telse :\r\n\t\tprint(\"Second\")\r\n", "n=int(input())\r\nw=[int(k) for k in input().split()]\r\na, b=0, 0\r\nfor j in w:\r\n if j%2:\r\n a+=1\r\n b+=j\r\nif b%2:\r\n print(\"First\")\r\nelif a:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "def main():\r\n n = int(input())\r\n a = [int(c) for c in input().split()]\r\n neven = sum(1 for e in a if e % 2 == 0)\r\n\r\n print('Second' if neven == n else 'First')\r\n \r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "t = int(input())\narr = list(map(int,input().split(' ')))\nodd = -1\nif sum(arr)%2==1:\n print('First')\nelse:\n pos = -1\n for i in range(0,t):\n if arr[i]%2==1:\n pos = i\n if pos == -1:\n print('Second')\n else:\n print('First')\n", "n=int(input())\r\nprint('First' if any(int(i)%2!=0 for i in input().split()) else 'Second')\r\n\r\n\r\n'''\r\nc=0\r\nflag=0\r\nfor i in range(n):\r\n if a[i]%2!=0:\r\n flag=1\r\n break\r\nif flag==1:\r\n print('First')\r\nelse:\r\n print('Second') \r\n''' ", "n = int(input())\r\na = list(map(int , input().split()))\r\nfirst_won = False\r\nsums = sum(a)\r\nif sums%2:\r\n print(\"First\")\r\nelse:\r\n for i in a:\r\n if i%2:\r\n first_won = True\r\n break\r\n if first_won:\r\n print(\"First\")\r\n else:\r\n print(\"Second\")\r\n", "n=int(input())\r\nm=list(map(int,input().split()))\r\nfor i in m:\r\n if i%2==1:\r\n print('First')\r\n break\r\nelse:\r\n print('Second')", "# B. Godsend\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nc=0\r\nfor i in a:\r\n if i%2==0:\r\n c+=1\r\nif c==n:\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")", "n = int(input())\r\ns = [int(i) for i in input().split()]\r\nd = []\r\nc = sum(s)\r\n\r\nfor i in range(n):\r\n\tif s[i]%2!=0:\r\n\t\td.append(s[i])\r\n\r\nif c%2!=0:\r\n\tprint(\"First\")\r\nelif not d:\r\n\tprint(\"Second\")\r\nelse:\r\n\tprint(\"First\")", "n = int(input())\r\nli = list(map(int,input().split()))\r\nc = 0\r\nfor i in range(n):\r\n if li[i]%2==1:\r\n c = 1\r\n break\r\nif c==1:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n\r\n", "n=int(input())\r\nlst=list(map(int,input().split(' ')))\r\ncountodd=0\r\nfor i in lst:\r\n if (i%2)==1:\r\n countodd+=1\r\nif (countodd)>0:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n ", "n= int(input())\r\na=list(map(int,input().split()))\r\nc=0\r\nfor i in a:\r\n if i&1:\r\n c=c+1\r\nif c>0:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n", "#t1=int(input())\r\n#for i in range(t1):\r\nn=int(input())\r\n#n,k = map(int, input().strip().split(' '))\r\nlst = list(map(int, input().strip().split(' ')))\r\nif sum(lst)%2!=0:\r\n print('First')\r\nelse:\r\n f=0\r\n for i in range(n):\r\n if lst[i]%2!=0:\r\n f=1\r\n print('First')\r\n break\r\n if f==0:\r\n print('Second')", "n = int(input())\r\nl = list(map(int,input().split()))\r\nc = \"Second\"\r\nfor i in l:\r\n if i%2 == 1:\r\n c = \"First\"\r\n break\r\nprint(c)", "def nik(rud,panda):\r\n lfa=0\r\n for x in rud:\r\n if x%2!=0:\r\n lfa=1\r\n print(\"First\") if panda%2!=0 or lfa==1 else print(\"Second\")\r\nn=int(input())\r\nrud=list(map(int,input().split(\" \")))\r\npanda=sum(rud)\r\nnik(rud,panda)", "n = int(input())\r\nele = list(map(int,input().split()))\r\nflag=sum(ele)\r\nods=0\r\nevens=0\r\nfor i in ele:\r\n if i%2==0:\r\n evens+=1\r\n else:\r\n ods+=1\r\nif ods>0 :\r\n print(\"First\")\r\nelse :\r\n print(\"Second\")", "n=int(input())\r\nl=[int(i) for i in input().split()]\r\nprint('First' if any(i&1 for i in l) else 'Second')\r\n", "input();print('First'if any(int(i)%2 for i in input().split())else'Second')", "n = int(input())\r\narr = map(int, input().split())\r\n\r\nif sum(map(lambda x: x % 2, arr)) == 0:\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")\r\n", "n = int(input())\r\nlis = list(map(int,input().split()))\r\nev=0\r\nfor i in lis:\r\n if i%2==0:\r\n ev+=1\r\nif ev==n:\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")\r\n", "n = int(input())\r\nr = lambda : list(map(int, input().split()))\r\narr = r()\r\n\r\ns = sum(arr)\r\nif s%2:\r\n print(\"First\")\r\nelse:\r\n if any(i%2 for i in arr):\r\n print(\"First\")\r\n else:\r\n print(\"Second\")", "n = int(input())\narr = [int(x) for x in input().split()]\n\nodd = False\nfor num in arr:\n if num & 1:\n odd = True\n\nprint('First' if odd else 'Second')\n", "n=int(input());c=0\r\ns=[int(x) for x in input().split()]\r\nx=sum(s)\r\nif x%2!=0:\r\n print(\"First\")\r\nelse:\r\n for ele in s:\r\n if ele%2!=0:\r\n print(\"First\")\r\n break\r\n else:\r\n print(\"Second\")\r\n\r\n\r\n \r\n", "n = int(input())\r\n\r\nlst = list(map(int, input().split()))\r\nev = 0\r\nfor i in lst:\r\n if i%2==0: ev+=1\r\n\r\nprint(\"Second\" if ev == n else \"First\")\r\n\r\n\r\n\r\n", "\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nc=0\r\nfor i in range(n):\r\n if a[i]%2==1:c+=1\r\n if c>0:break\r\nif c>0:print('First')\r\nelse:print('Second')", "input(); res = 'Second'\nfor i in map(int, input().split()):\n\tif i & 1:\n\t\tres = 'First'; break\nprint(res)", "n = int(input())\r\na = [0 if int(_) % 2 == 0 else 1 for _ in input().split()]\r\na = sum(a)\r\nif a % 2 == 0 and a != 0:\r\n a -= 1\r\nif a % 2 == 1:\r\n print('First')\r\nelse:\r\n print('Second')", "n=int(input())\r\nm=map(int,input().split())\r\nprint([\"Second\",\"First\"][any([i%2 for i in m])])\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\nT = 0\r\nfor i in range(n):\r\n if a[i] % 2 == 1:\r\n T += 1 \r\n \r\nif T == 0:\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")", "from sys import stdin, stdout\n\ndef main():\n n=int(stdin.readline().strip())\n arr=[int(x) for x in stdin.readline().strip().split(' ')]\n even,odd = 0,0\n for x in arr:\n if x%2==1: odd+=1\n else: even+=1\n return 'Second' if odd==0 else 'First'\n\nstdout.write(str(main()))\n", "n = int(input())\r\narr = list(map(int,input().split()))\r\nsa = sum(arr)\r\nif all(x%2==0 for x in arr):\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")", "N = int(input())\r\nA = [int(i) for i in input().split()]\r\nfor n in A:\r\n if(n%2):\r\n print(\"First\")\r\n break\r\nelse:\r\n print(\"Second\")\r\n", "n = int(input())\r\nnum = list(map(int, input().split()))\r\nans = 0\r\nfor a in num:\r\n ans += a%2\r\nif ans == 0:\r\n print('Second')\r\nelse:\r\n print('First')", "# print (\"Input n\")\nn = int(input())\n\n# print (\"Input the array\")\na = [int(x) for x in input().split()]\n\ndone = False\nfor x in a:\n if x%2 == 1:\n print(\"First\")\n done = True\n break\nif not done:\n print(\"Second\")\n \n", "from math import *\r\nimport itertools as it\r\nfrom collections import *\r\n\r\nEPS = 1e-9\r\ndef get_int() : return int(input().strip())\r\ndef get_string(): return input().strip()\r\ndef get_array() : return list(map(int, input().strip().split(' ')))\r\n\r\ndef print_array(a, glue = ' '):\r\n print(glue.join(map(str, a)))\r\n\r\ndef print_grid(grid, glue = ' '):\r\n for row in grid:\r\n print_array(row, glue)\r\n\r\n#====================================#\r\n\r\ndef solve():\r\n n = get_int()\r\n a = get_array()\r\n return 'Second' if all(x % 2 == 0 for x in a) else 'First'\r\n \r\n\r\nntest = 1\r\n# ntest = get_int()\r\nfor _ in range(ntest):\r\n print(solve())\r\n", "n = int(input())\na = map(int, input().split())\nfor x in a:\n if x % 2:\n print('First')\n exit(0)\nprint('Second')\n", "n=int(input())\r\na=list(map(int,input().split(' ')))\r\nflag=0\r\nfor i in range(0,n):\r\n if a[i]%2==1:\r\n flag=1\r\n break\r\n\r\nif flag==1:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n ", "##n = int(input())\r\n##a = list(map(int, input().split()))\r\n##print(' '.join(map(str, res)))\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\n\r\ntot = sum(a)\r\nif tot%2 == 1:\r\n print('First')\r\nelse:\r\n for ai in a:\r\n if ai%2 == 1:\r\n print('First')\r\n exit(0)\r\n print('Second')", "import sys, math\r\n\r\nn = int(sys.stdin.readline())\r\narr = list(map(int, sys.stdin.readline().split()))\r\nodd = 0\r\nfor i in arr:\r\n if i % 2:\r\n odd += 1\r\nprint('First' if odd >= 1 else 'Second')\r\n\r\n", "entrada = int(input())\r\ndado = list(map(int, input().split()))\r\nif sum(dado) % 2 == 1:\r\n\tprint(\"First\")\r\nelif sum(dado) % 2 == 0:\r\n\tfor c in range(entrada):\r\n\t\tif dado[c] % 2 == 1 or dado[-1-c] % 2 == 1:\r\n\t\t\tresp = \"First\"\r\n\t\t\tbreak\r\n\t\telse:\r\n\t\t\tresp = \"Second\"\r\n\tprint(resp)", "n=int(input())\r\nS=input()\r\na=tuple(map(int, S.split()))\r\nda,db=0,0\r\nfor i in range(n):\r\n if (a[i]%2==1):\r\n da+=1\r\n db+=a[i]\r\nif (db%2==1):\r\n print(\"First\")\r\nelse:\r\n if (da>=1):\r\n print(\"First\")\r\n else:\r\n print(\"Second\")\r\n", "n=int(input())\na=[int(x) for x in input().split()]\nc=0\nfor i in a:\n if(i%2):\n c+=1\nif(c>0):\n print('First')\nelse:\n print('Second')\n", "n = int(input())\r\nA = list(map(int,input().split(' ')))\r\nif sum(A)%2 != 0:\r\n print(\"First\")\r\nelse:\r\n flg = 0\r\n for i in range(0,n):\r\n if A[i]%2 != 0:\r\n flg = 1\r\n break;\r\n if flg == 1: print(\"First\")\r\n else: print(\"Second\")\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n", "n = int(input())\r\nlst = list(map(int, input().split()))\r\nif sum(lst) % 2 == 1:\r\n print(\"First\")\r\nelif sum(1 for x in lst if x % 2 == 1) == 0:\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")\r\n", "n = int(input())\r\narr = list(map(int,input().strip().split()))[:n]\r\nflag = 0\r\nfor i in range(n):\r\n if(arr[i] % 2 == 1):\r\n flag = 1\r\n break\r\nif flag == 1:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "n=int(input())\r\narr=list(map(int,input().strip().split(' ')))\r\nans=0\r\nfor i in arr:\r\n\tif(i%2==1):\r\n\t\tans=1\r\n\t\tbreak\r\nif(ans==0):\r\n\tprint(\"Second\")\r\nelse:\r\n\tprint(\"First\")\r\n\r\n", "n = int(input())\r\nd = input().split()\r\n\r\nfor i in range(n):\r\n if (int(d[i]) % 2 == 1):\r\n print(\"First\")\r\n exit()\r\n\r\nprint(\"Second\")\r\n", "k=int(input())\r\na=list(map(int,input().split()))\r\nif any(i%2!=0 for i in a):\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "n = int(input())\r\nstr = input()\r\nls = [int(u) for u in str.split()]\r\n\r\nsum=0\r\nfor u in ls:\r\n sum += u\r\ncond = False\r\nif sum%2 != 0:\r\n print('First')\r\nelse:\r\n for u in ls:\r\n if u%2 != 0:\r\n cond = True\r\n if cond == True:\r\n print(\"First\")\r\n else:\r\n print(\"Second\")\r\n", "n=int(input())\r\nm=list(map(int,input().split()))\r\np='Second'\r\nfor i in m:\r\n if i%2==1:\r\n p='First'\r\n break\r\nprint(p) ", "n=int(input())\r\nnumber=list(map(int,input().split()))\r\nif sum(number)%2!=0:\r\n print('First')\r\nelse:\r\n flag=0\r\n for i in number:\r\n if i%2!=0:\r\n flag=1\r\n print('First')\r\n break\r\n if flag==0:\r\n print('Second')", "n=int(input())\r\na=list(map(int,input().split()))\r\nflag=0\r\nfor i in range(n):\r\n if a[i]%2==1:\r\n flag=1\r\n break\r\nif flag:\r\n print('First')\r\nelse:\r\n print('Second')", "\r\n\r\ndef main_function():\r\n n = int(input())\r\n a = [int(i) for i in input().split(\" \")]\r\n counter_even = 0\r\n counter_odd = 0\r\n for i in a:\r\n if i % 2 == 0:\r\n counter_even += 1\r\n else:\r\n counter_odd += 1\r\n if counter_odd > 0:\r\n print(\"First\")\r\n else:\r\n print(\"Second\")\r\n \r\n\r\n\r\n\r\nmain_function()", "n=int(input())\r\nl=list(map(int,input().split()))\r\ns=sum(l)\r\nif s%2==1:print(\"First\")\r\nelse:\r\n\tf=0\r\n\tfor x in l:\r\n\t\tif x%2==1:f=1;break\r\n\tprint([\"Second\",\"First\"][f==1])", "n=int(input())\r\nL=list(map(int,input().split()))\r\nc=0\r\nfor i in range(0,n):\r\n if(L[i]%2!=0):\r\n print('First')\r\n c=1\r\n break\r\nif(c==0):\r\n print('Second')", "n=int(input())\r\na=list(map(int,input().split()))\r\nflag=0\r\nfor i in range (0,n):\r\n if(a[i]%2):\r\n flag=1\r\n \r\nif flag:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "n=int(input())\r\nl=list(map(int,input().split()))\r\nif(sum(l)%2==1):\r\n print('First')\r\nelse:\r\n for i in l:\r\n if(i%2==1):\r\n print('First')\r\n quit()\r\n print('Second')\r\n \r\n \r\n ", "import math\r\na = input()\r\nb = input().split()\r\nodd = 0\r\nfor i in b:\r\n if int(i) % 2 != 0:\r\n odd += 1\r\nif odd > 0:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n\r\n\r\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\nfor i in l:\r\n if i&1:\r\n print(\"First\")\r\n exit()\r\nprint(\"Second\")", "n=int(input())\r\na=[int(i) for i in input().split()]\r\nfor i in range(n):\r\n if a[i]%2!=0:\r\n print(\"First\")\r\n exit()\r\n elif i==n-1:\r\n print(\"Second\")", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nc = 0\r\nfor i in a:\r\n c += i % 2\r\nans = \"First\" if c else \"Second\"\r\nprint(ans)", "n=int(input())\r\nprint([\"Second\", \"First\"][any([int(x)%2!=0 for x in input().split()])])", "n=int(input())\r\na=list(map(int,input().split()))\r\nod=0\r\nev=0\r\nfor i in range(n):\r\n if a[i]%2==0:\r\n ev+=1\r\n else:\r\n od+=1\r\nif od>0:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "n=int(input())\r\nl=list(map(int,input().split()))\r\noddcount = 0\r\nevencount=0\r\nfor i in l:\r\n if(i&1==1):\r\n oddcount+=1\r\n else:\r\n evencount+=1\r\nif(evencount==n):\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")", "n=int(input())\r\na=list(map(int,input().split()))\r\nflag=0\r\nfor i in a:\r\n if(i%2):\r\n flag=1\r\n \r\nif flag:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nc=0\r\nfor i in range(n):\r\n\tif l[i]%2!=0:\r\n\t\tc+=1\r\ns=sum(l)\r\nif s%2!=0 or (s%2==0 and c>0):\r\n\tprint(\"First\")\r\nelse:\r\n\tprint(\"Second\")", "n = input()\nli = [int(x) for x in input().split()]\nfor elem in li:\n if elem % 2 == 1:\n print('First')\n break\nelse:\n print('Second')\n", "import sys\r\ninput=sys.stdin.buffer.readline\r\n\r\nn=int(input())\r\narr=list(map(int,input().split()))\r\nodd=0\r\nfor x in arr:\r\n\tif x%2==0:\r\n\t\tcontinue\r\n\telse:\r\n\t\todd=1\r\n\t\tbreak\r\n\r\nif sum(arr)%2==1:\r\n\tprint(\"First\")\r\nelse:\r\n\tif odd>0:\r\n\t\tprint(\"First\")\r\n\telse:\r\n\t\tprint(\"Second\")\r\n\t\t\t\t#unknown_2433", "input()\r\nif any([x%2 for x in map(int, input().split())]):\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n", "arr_len = int(input())\r\narr = [int(x) for x in str(input()).split()]\r\n\r\nprint_stat = \"Second\"\r\n\r\nfor i in range(arr_len):\r\n if(arr[i] % 2 == 1):\r\n print_stat = \"First\"\r\n break\r\n \r\nprint(print_stat)", "input()\nfor x in input().split():\n if int(x)%2:\n print('First')\n exit()\nprint('Second')", "n=int(input())\r\na=list(map(int,input().split()))\r\nfor i in a:\r\n if i%2:\r\n print(\"First\")\r\n exit(0)\r\nprint(\"Second\")", "from collections import deque\r\nn = int(input())\r\narray = list(map(int, input().split()))\r\nodds = [x for x in array if x & 1]\r\nevens = [x for x in array if not x & 1]\r\nc_odd = len(odds)\r\nc_even = len(evens)\r\nif c_odd > 0:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\ns = sum(a)\r\n\r\nif s&1:\r\n print(\"First\")\r\nelse:\r\n if s > 1:\r\n m = float(\"+inf\")\r\n for i in a:\r\n if i&1:\r\n m = min(m, i)\r\n if m != float(\"+inf\"):\r\n s = m\r\n print(\"First\")\r\n else:\r\n print(\"Second\")\r\n else:\r\n print(\"Second\")\r\n", "n=int(input())\r\nji=0\r\nou=0\r\na=input().split()\r\nfor i in range(n):\r\n a[i]=int(a[i])\r\n if a[i]%2==0:\r\n ou=ou+1\r\n else:\r\n ji=ji+1\r\nif ji!=0:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n\r\n", "n=int(input())\r\nl=[int(i) for i in input().split()]\r\ns=0\r\nfor i in l:\r\n s= (s+i)%2\r\nif (s==1):\r\n print ('First')\r\nelse:\r\n f=0\r\n for i in l:\r\n if (i%2!=0):\r\n f=1\r\n break\r\n if (f==1):\r\n print ('First')\r\n else:\r\n print ('Second')\r\n\r\n", "def solve():\n n = int(input())\n a = list(map(int, input().split()))\n if sum(a) % 2 == 0:\n if all(x % 2 == 0 for x in a):\n return False\n else:\n return True\n else:\n return True\n\n\ndef main():\n if solve():\n print('First')\n else:\n print('Second')\n\n\nif __name__ == '__main__':\n main()\n", "n=int(input())\r\narr=input().strip().split()\r\nfor num in arr:\r\n if int(num) %2==1:\r\n print(\"First\")\r\n exit()\r\nprint(\"Second\")", "n=int(input())\r\na=list(map(int,input().split()))\r\noddeven=[]\r\ns=sum(a)\r\nodd=0\r\neven=0\r\n\r\nfor i in a:\r\n if(i%2==0):\r\n even+=1\r\n oddeven.append(0)\r\n else:\r\n odd+=1\r\n oddeven.append(1)\r\n \r\nif(s%2!=0):\r\n print(\"First\")\r\nelse:\r\n if(odd==0):\r\n print(\"Second\")\r\n else:\r\n print(\"First\")\r\n \r\n \r\n", "import sys\r\nn = int(input())\r\ngame = list(map(int, input().split()))\r\nfor num in game:\r\n if (num % 2 == 1):\r\n print(\"First\")\r\n sys.exit()\r\nprint(\"Second\")", "n = int(input())\r\nl = list(map(int,input().split()))\r\nt = sum(l)\r\nk = 0\r\nfor i in range(n):\r\n\tif l[i]%2 == 1:\r\n\t\tk = k + 1\r\nif t%2 == 1:\r\n print(\"First\")\r\nelif k == 0:\r\n print(\"Second\")\r\nelse:\r\n\tprint(\"First\")", "from sys import stdin\r\nstdin.readline()\r\na = list(map(int,stdin.readline().split()))\r\nodd = 0\r\nfor x in a:\r\n odd += x%2\r\nif odd%2==1:\r\n print('First')\r\nelse:\r\n if odd>=2:\r\n print('First')\r\n else:\r\n print('Second')", "n = int(input())\r\n\r\narr = list(map(int,input().strip().split()))\r\n\r\nif sum(arr)%2==1:\r\n print(\"First\")\r\nelse:\r\n st = 0\r\n for x in arr:\r\n if x%2==1:\r\n print(\"First\")\r\n st = 1\r\n break\r\n if st==0:\r\n print(\"Second\")", "n=int(input()) \r\na=list(map(int,input().split()))\r\nflag=False\r\nfor i in a:\r\n if(i&1):\r\n flag=True\r\n break\r\nif(flag):\r\n print('First')\r\nelse:\r\n print('Second')\r\n", "n=int(input())\r\nl=list(map(int, input().split()))\r\nc=0\r\nfor i in range(n):\r\n\tc+=int(l[i]%2)\r\nif(c==0):\r\n\tprint('Second')\r\nelse:\r\n\tprint('First')", "n = int(input())\r\nnums = list(map(int,input().split()))\r\nsum_ = 0\r\nisOk = False\r\nfor i in nums:\r\n\tsum_ += i\r\n\tif sum_ & 1:\r\n\t\tisOk = True\r\nprint(\"First\" if isOk else \"Second\")\r\n", "n = int(input())\r\narr = list(map(int,input().split()))\r\ncnt = 0\r\nfor i in arr:\r\n if i % 2 == 1:\r\n cnt+=1\r\nif cnt%2==1:\r\n print(\"First\")\r\nelif cnt:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n", "input()\r\nprint('SFeicrosntd'[any(int(c)%2 for c in input().split())::2])", "input(); print((\"Second\", \"First\")[any(int(i) % 2 for i in input().split())])", "n = int(input())\na = (map(int,input().split()))\nfor i in a:\n if i%2==1:\n print('First')\n exit()\nprint('Second')\n", "n=int(input())\r\na=list(map(int,input().split()))\r\n\r\nfor i in range(n):\r\n\tif a[i]%2==1:\r\n\t\tprint('First')\r\n\t\tbreak\r\nelse:\r\n\tprint('Second')", "input()\r\nprint(['Second','First'][any(i%2 for i in map(int,input().split()))])", "s=int(input())\nss=list(map(int,input().split()))\nflag=0\nfor i in range(s):\n\tif ss[i]%2==1:\n\t\tflag=1\n\t\tbreak\nif flag:\n\tprint('First')\nelse:\n\tprint('Second')\n", "n=int(input())\r\na=list(map(int, input().split()))\r\n\r\nfor el in a:\r\n if el&1:\r\n print('First')\r\n break\r\nelse:\r\n print('Second')", "n=int(input())\nl=list(map(int,input().split(' ')))\nif(sum(l)%2!=0):print('First')\nelse:\n if(all([x%2==0 for x in l])):print('Second')\n else:print('First')\n", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\nIII_found = False\r\nfor i in a:\r\n if i % 2 == 1:\r\n III_found = True\r\n break\r\n\r\nprint(('First', 'Second')[sum(a) % 2 == 0 and not III_found])\r\n", "n = int(input())\r\na = list(map(int,input().split()))\r\nc = 0\r\nv = 0\r\n\r\n \r\nfor i in a:\r\n if i%2 == 0:\r\n c+=1\r\n \r\n else:\r\n v+=1\r\n \r\nif c == len(a):\r\n print(\"Second\")\r\n\r\nelse:\r\n print(\"First\")\r\n ", "n=int(input())\r\na=list(map(int, input().split()))\r\nc=0\r\nfor i in a:\r\n if i%2!=0:\r\n c+=1\r\nif c==0:\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")", "n = int(input())\na = [*map(int, input().split())]\nprint('SFeicrosntd'[sum([v % 2 for v in a])>0::2])\n \t \t\t\t\t\t \t \t\t \t\t\t \t\t\t \t\t", "import sys\r\ninput = sys.stdin.buffer.readline\r\n\r\ninput()\r\nv = list(map(int, input().split()))\r\n\r\nprint(\"First\" if any([x % 2 == 1 for x in v]) else \"Second\")\r\n", "import sys\n\nn = int(input())\narr = list(map(int, input().split()))\n\nflag = False\nsum = False\nfor i in arr:\n if i % 2 == 1:\n sum = ~sum\n flag = True\n\nif(sum == True):\n print(\"First\")\nelif(flag == True):\n print(\"First\")\nelse:\n print(\"Second\")\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\nfor i in range(n):\r\n if(l[i]%2 != 0):\r\n print(\"First\")\r\n exit()\r\nprint(\"Second\")\r\n#kalay))", "n = int(input())\r\narr = list(map(int,input().split()))\r\ncount = 0\r\nfor i in arr:\r\n if i%2==1:\r\n count+=1 \r\n print(\"First\")\r\n break \r\nif count==0:\r\n print(\"Second\")", "n= input()\r\nl = (list(map(int,input().split())))\r\n\r\nfor i in l:\r\n if i%2!=0:\r\n print(\"First\")\r\n exit()\r\n\r\nprint(\"Second\")\r\n\r\n\r\n\r\n\r\n", "from collections import Counter\r\nn=int(input())\r\narr=list(map(int,input().split()))\r\ns=[arr[0]]\r\npar=[s[0]%2]\r\nfor i in range(1,n):\r\n s.append(s[i-1]+arr[i])\r\n par.append(s[i]%2)\r\ncou=Counter(par)\r\nif cou[1]==0:\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")\r\n", "'''input\r\n4\r\n1 3 2 3\r\n'''\r\ninput()\r\narr = [a % 2 for a in list(map(int, input().split()))]\r\n \r\nif 1 in arr:\r\n print('First')\r\nelse:\r\n print('Second')\r\n \r\n", "import math\r\nimport sys\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nb = sum([1 for i in a if i % 2])\r\nc = n - b\r\nif not b :\r\n print('Second')\r\nelse:\r\n print('First')\r\n", "n=int(input())\nprint(['Second','First'][any(int(i)%2 for i in input().split())])", "n=int(input())\r\nnums=list(map(int,input().split()))\r\nc=0\r\nfor i in nums:\r\n if i%2==1:\r\n c+=1\r\n\r\nif c>0:\r\n print('First')\r\nelse:\r\n print('Second') \r\n", "n = int(input())\r\nl = map(int,list(input().split()))\r\ns=0\r\nfor i in l:\r\n if i%2:\r\n print(\"First\")\r\n s=1\r\n break\r\nif s!=1 :\r\n print(\"Second\")", "n = int(input())\nnumbers = list(map(int, input().split()))\ns = sum(numbers)\nodd = sum( n % 2 != 0 for n in numbers)\n\n#Odd sum\nif s % 2 != 0:\n print(\"First\")\n#Even sum, even numbers\n#for example 2,2,2,2. First player cant win\nelif odd == 0:\n print(\"Second\")\n#Even sum, mixed numbers\n#for example 2,3,2,2,3. First player leaves one odd number -> odd sum left.\n#This odd sum cannot be transformed to an even sum by player two, so player one wins.\nelse:\n print(\"First\")\n\n", "n=int(input())\r\narr=list(map(int,input().split()))\r\nif sum(arr)%2:\r\n print(\"First\")\r\n\r\nelse:\r\n o=0\r\n for el in arr:\r\n if el%2:\r\n o+=1\r\n if o:\r\n print(\"First\")\r\n else:\r\n \r\n print(\"Second\")", "import sys\r\nnumberOfIntegers = sys.stdin.readline()\r\nIntegers = sys.stdin.readline()\r\n\r\nnumber = int( numberOfIntegers ) \r\neachInteger = Integers.split()\r\n#print (3 % 2)\r\nstillOkay = True\r\nfor i in range( -1 , number - 1 ):\r\n #print ( eachInteger[i] )\r\n eachInteger[i] = int( eachInteger[i] )\r\n if eachInteger[i] % 2 == 0:\r\n pass\r\n elif eachInteger[i] % 2 == 1:\r\n stillOkay = False\r\n#print (eachInteger[0])\r\n#print (stillOkay)\r\nif stillOkay == True:\r\n print ( \"Second\" )\r\nelse :\r\n print ( \"First\" )\r\n \r\n\r\n \r\n", "n=int(input())\r\nnums=[int(nums) for nums in input().split()]\r\nstopindex=0\r\nstopbit=0\r\nplayerturn=0\r\nwhile(stopbit!=1):\r\n currentsum=0\r\n stopindex=-1\r\n if playerturn==0:\r\n for i in range(len(nums)):\r\n if nums[i]!=-1:\r\n currentsum+=nums[i]\r\n if currentsum%2==1:\r\n stopindex=i\r\n if stopindex==-1:\r\n stopbit=1\r\n break\r\n else:\r\n for i in range(stopindex+1):\r\n nums[i]=-1\r\n playerturn=1\r\n else:\r\n for i in range(len(nums)):\r\n if nums[i]!=-1:\r\n currentsum+=nums[i]\r\n if currentsum%2==0:\r\n stopindex=i\r\n if stopindex==-1:\r\n stopbit=1\r\n break\r\n else:\r\n for i in range(stopindex+1):\r\n nums[i]=-1\r\n playerturn=0\r\nif playerturn==0:\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")", "len_array = int(input())\narray = input().split()\narray = [int(a) for a in array]\nbooli = True\nfor item in array:\n if item%2 == 1:\n booli =False\n break\nif booli:\n print(\"Second\")\nelse:\n print(\"First\")", "import sys, random\r\ninput = lambda: sys.stdin.readline().rstrip()\r\nn = int(input())\r\na = list(map(lambda x: int(x)%2, input().split()))\r\nprint(\"First\" if sum(a) else \"Second\")", "n = int(input())\na = list(map(int, input().split()))\nfor i in range (n):\n if a[i] % 2 != 0:\n print('First')\n exit()\nprint('Second')\n", "n = int(input())\na = list(map(int, input().split()))\nodd = 0\n\nfor i in range(n):\n\tif(a[i] % 2 != 0):\n\t\todd += 1\n\nif(odd == 0):\n\tprint('Second')\nelse:\n\tprint('First')\n", "n = int(input())\r\na = map(int, input().split())\r\nans = 0\r\nfor x in a:\r\n ans += x % 2\r\nif ans > 0:\r\n print('First')\r\nelse:\r\n print('Second')", "n = input()\r\na = map(int, input().strip().split())\r\nok = False \r\n\r\nfor i in a:\r\n if i&1 :\r\n ok = True \r\n \r\nif ok:\r\n print(\"First\")\r\nelse:\r\n print('Second')", "import math\r\nI = lambda:int(input())\r\nID = lambda:map(int, input().split())\r\nIL = lambda:list(ID())\r\nn = I()\r\na = IL()\r\nodd = even = 0\r\nfor i in a:\r\n if i&1:\r\n odd+=1\r\n else:\r\n even+=1\r\nif odd == 0:\r\n print('Second')\r\n exit()\r\nif sum(a)%2:\r\n print('First')\r\n exit()\r\nprint('First')\r\n", "n=int(input())\nS=input()\na=tuple(map(int, S.split()))\nda,db=0,0\nfor i in range(n):\n if (a[i]%2==1):\n da+=1\n db+=a[i]\nif (db%2==1):\n print(\"First\")\nelse:\n if (da>=1):\n print(\"First\")\n else:\n print(\"Second\")\n\n\t\t \t\t\t\t \t\t\t\t \t \t \t\t\t \t \t", "n=int(input())\r\narr=list(map(int,input().split()))\r\nchck=0\r\nfor item in arr:\r\n if item%2!=0:\r\n print(\"First\")\r\n chck=1\r\n break\r\nif chck==0:\r\n print(\"Second\")", "import sys\r\nimport math\r\nfrom collections import OrderedDict\r\ndef input(): return sys.stdin.readline().strip()\r\ndef iinput(): return int(input())\r\ndef minput(): return map(int, input().split()) \r\ndef listinput(): return list(map(int, input().split()))\r\nn=iinput()\r\na=listinput()\r\no=[]\r\ne=[]\r\nfor i in a:\r\n\tif i%2==0:e.append(i)\r\n\telse:o.append(i)\r\nif sum(a)%2==0 and len(o)==0:print('Second')\r\nelse:print('First')\r\n", "n = int(input())\r\narr= [int(x) for x in input().split()]\r\nodd = 0\r\nfor i in range(n):\r\n if (arr[i] % 2 == 1):\r\n odd = 1\r\n break\r\nif (odd):\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "from sys import stdin\r\nstdin.readline()\r\nprint('Second' if sum([x%2 for x in map(int,stdin.readline().split())])==0 else 'First')", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\nsumm = 0\r\nfor x in a:\r\n summ += x\r\n\r\nif summ % 2 != 0:\r\n print('First')\r\nelse:\r\n ans = 'Second'\r\n for x in a:\r\n if x % 2 != 0:\r\n ans = 'First'\r\n break\r\n else:\r\n continue\r\n print(ans)\r\n", "a = int(input())\r\nl = list(map(int,input().split()))\r\n\r\na = sum(l)\r\n\r\nif a % 2 == 0:\r\n fl = False\r\n for i in range(len(l)):\r\n if l[i] % 2 != 0:\r\n fl = True\r\n break\r\n \r\n if fl == False:\r\n print(\"Second\")\r\n else:\r\n print(\"First\")\r\nelse:\r\n print(\"First\")", "n=int(input())\r\na=list(map(int,input().strip().split()))\r\nif sum(a)%2!=0:\r\n print('First')\r\nelse:\r\n c=0\r\n d=0\r\n for i in range(n):\r\n if a[i]%2==0:\r\n c=c+1\r\n else:\r\n d=d+1\r\n if d==0:\r\n print('Second')\r\n else:\r\n print('First')", "n = int(input())\r\nl = list(map(int,input().split()))\r\nodd = sum(x%2 for x in l)\r\nif odd==0:\r\n print ('Second')\r\nelse:\r\n print ('First')", "n = int(input())\na = [int(x) for x in input().split()]\neven = 0\nodd = 0\nfor i in range(0,n):\n\tif a[i]%2==0:\n\t\teven += 1\n\telse:\n\t\todd += 1\n\nif n==even:\n\tprint(\"Second\")\nelse:\n\tprint(\"First\")", "n = int(input())\na = input()\nuneven = False\ns = 0\nfor i in a.split():\n v = int(i)\n if v % 2:\n uneven = True\n s += v\n\nif s % 2 or uneven:\n print('First')\nelse:\n print('Second')", "def main():\r\n\tn = int(input())\r\n\tL = [int(x) for x in input().split()]\r\n\tprint(solver(L))\r\n\r\ndef solver(L):\r\n\tfor x in L:\r\n\t\tif x % 2 == 1:\r\n\t\t\treturn 'First'\r\n\treturn 'Second'\r\n\r\nmain()\r\n\r\n#print(solver([2, 2]))\r\n", "n=int(input())\r\nmp=map(int,input().split())\r\nprint([\"Second\",\"First\"][any([i%2 for i in mp])])", "\r\nX=int(input())\r\nB=[int(x) for x in str(input()).split()]\r\ntot=sum(B)\r\nif tot%2==1:\r\n print('First')\r\nelse:\r\n i=0\r\n for x in B:\r\n if x%2==1:\r\n i=1\r\n if i==0:\r\n print('Second')\r\n else:\r\n print('First')\r\n ", "n = int(input())\r\na = list(map(int, input().split()))\r\nc = 0\r\nfor i in a:\r\n if i % 2 == 0: c += 1\r\nif c == n: print(\"Second\")\r\nelse: print(\"First\")", "n=int(input())\r\na=list(map(int,input().strip().split()))\r\nf=0\r\nfor i in range(n):\r\n if a[i]%2!=0:\r\n print(\"First\")\r\n f=1\r\n break\r\nif f==0:\r\n print(\"Second\")\r\n", "n=int(input())\na=list(map(int,input().split()))\ns=0\nfor i in a:\n if i&1:\n s+=1\nif s:\n print(\"First\")\nelse:\n print(\"Second\")", "input()\r\nprint(\"First\" if 1 in [int(x) % 2 for x in input().strip().split()] else \"Second\")", "n = int(input())\r\na = list(map(int,input().split()))\r\nodd = [ele for ele in a if ele%2 != 0]\r\nif len(odd) != 0:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "n = int(input().strip())\n\nline = list(map(int, input().strip().split()))\n\ncheck = False\n\nfor i in line:\n if i%2 != 0:\n print(\"First\")\n check = True\n break\n \nif check == False:\n print(\"Second\")\n\n\n", "n = int(input())\r\nw = list(map(int, input().split()))\r\nfor i in w:\r\n if i % 2 == 1:\r\n print('First')\r\n break\r\nelse:\r\n print(\"Second\")", "# @author Matheus Alves dos Santos\n\nlenght = int(input())\nvalues = map(int, input().split())\nfirst_wins = False\n\nfor i in values:\n if (i % 2):\n first_wins = True\n break\n\nprint(\"First\") if (first_wins) else print(\"Second\")\n", "n = int(input()) \r\narray = list(map(int,input().split())) \r\nodd=0 \r\nflag = 0\r\nfor each in array:\r\n if(each%2==1):\r\n flag = 1 \r\n break\r\n\r\nif(flag==0):\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")\r\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\ns = []\r\nfor i in range(len(l)):\r\n if l[i]%2 == 1:\r\n s.append(i)\r\n l[i] = 1\r\n\r\n else:\r\n l[i] = 0\r\n\r\nx = sum(l)\r\nif len(s) == 0:\r\n print(\"Second\")\r\n exit()\r\n\r\nif (len(s) == len(l)):\r\n print(\"First\")\r\n exit()\r\n\r\nprint(\"First\")\r\n\r\n\r\n\r\n", "def main():\n n, l = int(input()), [ord(s[-1]) & 1 for s in input().split()]\n s = sum(l) & 1\n print((\"Second\", \"First\")[s or not s and any(l)])\n\n\nif __name__ == '__main__':\n main()\n", "n = int(input())\r\na = [int(x)%2 for x in input().split()]\r\nif 1 in a:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")\r\n", "n = input()\r\nN = input().split()\r\nN = [int(i) for i in N]\r\nodd = 0\r\nfor i in N:\r\n if i%2 == 1:\r\n odd += 1\r\nif odd > 0:\r\n print(\"First\")\r\nelse:\r\n print(\"Second\")", "input()\r\nprint('First' if any(a % 2 for a in map(int, input().split())) else 'Second')", "n = int(input())\r\na = [int(x)%2 for x in input().split()]\r\n\r\nif sum(a)%2:\r\n print('First')\r\nelif 1 not in a:\r\n print('Second')\r\nelse:\r\n print('First')", "x=int(input())\r\ns=sum([int(n)%2 for n in input().split()])\r\nif s!=0:\r\n print('First')\r\nelse:\r\n print('Second')", "input()\nprint((\"Second\", \"First\")[any(ord(s[-1]) & 1 for s in input().split())])", "n = int(input())\r\narr = list(map(int,input().split()))\r\nsa = sum(arr)\r\nif sa%2==1:\r\n print(\"First\")\r\nelif all(x%2==0 for x in arr):\r\n print(\"Second\")\r\nelse:\r\n print(\"First\")", "n=int(input())\r\nm=list(map(int,input().split()))\r\ns=sum(m)\r\nif s%2==1:\r\n print('First')\r\nelse:\r\n for i in m:\r\n if i%2==1:\r\n print('First')\r\n break\r\n else:\r\n print('Second')" ]
{"inputs": ["4\n1 3 2 3", "2\n2 2", "4\n2 4 6 8", "5\n1 1 1 1 1", "4\n720074544 345031254 849487632 80870826", "1\n0", "1\n999999999", "2\n1 999999999", "4\n3 3 4 4", "2\n1 2", "8\n2 2 2 1 1 2 2 2", "5\n3 3 2 2 2", "4\n0 1 1 0", "3\n1 2 2", "6\n2 2 1 1 4 2", "8\n2 2 2 3 3 2 2 2", "4\n2 3 3 4", "10\n2 2 2 2 3 1 2 2 2 2", "6\n2 2 1 1 2 2", "3\n1 1 2", "6\n2 4 3 3 4 6", "6\n4 4 3 3 4 4", "4\n1 1 2 2", "4\n1 3 5 7", "4\n2 1 1 2", "4\n1 3 3 2", "5\n3 2 2 2 2", "3\n2 1 1", "4\n1000000000 1000000000 1000000000 99999999", "4\n2 2 1 1", "5\n2 3 2 3 2", "1\n1", "4\n1000000000 1000000000 1000000000 1", "5\n2 2 2 1 1", "6\n2 1 1 1 1 2", "6\n1 2 2 2 2 1", "11\n2 2 2 2 2 1 2 2 2 2 2", "5\n1 3 2 2 2", "3\n2 3 2", "2\n1 1", "5\n4 4 4 3 3", "5\n3 3 4 4 4", "1\n2"], "outputs": ["First", "Second", "Second", "First", "Second", "Second", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "First", "Second"]}
UNKNOWN
PYTHON3
CODEFORCES
223
e14b7011b3fe8a743e826ee023646996
Kitahara Haruki's Gift
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? The first line contains an integer *n* (1<=≤<=*n*<=≤<=100) — the number of apples. The second line contains *n* integers *w*1,<=*w*2,<=...,<=*w**n* (*w**i*<==<=100 or *w**i*<==<=200), where *w**i* is the weight of the *i*-th apple. 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 Input 3 100 200 100 4 100 100 100 200 Sample Output YES NO
[ "n = int(input())\nw = [int(x) for x in input().split()]\nones = sum([1 if x==100 else 0 for x in w])\ntwos = sum([1 if x==200 else 0 for x in w])\nif (ones*100+twos*200)%200 !=0:\n print(\"NO\")\nelse:\n need = (ones*100 + twos*200)//2\n ans = False\n for i in range(twos+1):\n if 200*i <= need and (need-200*i) <= ones*100:\n ans = True\n if ans:\n print(\"YES\")\n else:\n print(\"NO\")\n", "n = int(input())\r\n\r\nc = list(map(str,input().split()))\r\nhund = c.count('100')\r\ntwohund = c.count('200')\r\nif hund==0 and twohund%2==0:\r\n print('YES')\r\nelif twohund==0 and hund%2==0:\r\n print(\"YES\")\r\nelif twohund%2==0 and hund%2==0:\r\n print(\"YES\")\r\nelif twohund%2==1 and hund%2==0 and hund>0 :\r\n print(\"YES\")\r\nelse:print('NO')", "n=int(input())\r\na=[str(a)for a in input().split()]\r\nif '100' not in a:\r\n if n%2==0:print(\"YES\")\r\n else:print(\"NO\")\r\nelse:\r\n z=a.count(\"100\")\r\n if z%2==0:print(\"YES\")\r\n else:print(\"NO\")\r\n ", "n=int(input())\r\nA=list(map(int,input().split()))\r\na = A.count(100)\r\nb= A.count(200)\r\nk=b%2\r\na-=k*2\r\nif(a>=0 and a%2==0):print(\"YES\")\r\nelse: print(\"NO\")", "n=int(input())\r\narr=list(map(int,input().split()))\r\nsum_arr=sum(arr)\r\nif(sum_arr%200!=0):\r\n print(\"NO\")\r\nelse:\r\n h=arr.count(100)\r\n t=arr.count(200)\r\n if(h==0 and t%2!=0):\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")", "n=int(input())\r\n #u=sorted(n)\r\n #a=set(map(int,input().split()))\r\na=list(map(int,input().split()))\r\n #l=set(a)\r\nans=s=f=0\r\ns=a.count(100)\r\nf=a.count(200)\r\nif(f%2==0 and s%2==0 ):\r\n print(\"YES\")\r\nelif(f%2==1 and s%2==0 and s>=2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "n=int(input())\r\nn_list=list(map(int,input().split()))\r\na=n_list.count(100)\r\nb=n_list.count(200)\r\nif a%2 != 0:\r\n print(\"NO\")\r\nelif b%2 != 0 and a<2:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\") ", "import math as mt\r\nfrom collections import defaultdict,deque\r\nfrom bisect import bisect_left as b_l\r\nfrom bisect import bisect_right as b_r\r\nimport sys\r\n\r\nn=int(input())\r\na=[int(x) for x in input().split()]\r\ncnt1,cnt2=0,0\r\nfor i in a:\r\n if(i==100):\r\n cnt1+=1\r\n else:\r\n cnt2+=1\r\nif(cnt1&1):\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\" if(cnt1==0 and cnt2&1) else \"YES\")", "n = int(input())\r\n\r\nl_w = list(map(int, input().split()))\r\n\r\nn200 = 0\r\nn100 = 0\r\n\r\nfor w in l_w:\r\n if w == 200:\r\n n200 += 1\r\n else:\r\n n100 += 1\r\n\r\nfor i in range(n200 + 1):\r\n for j in range(n100 + 1):\r\n if i * 200 + j * 100 == (n200 - i) * 200 + (n100 - j) * 100:\r\n print(\"YES\")\r\n quit()\r\nprint(\"NO\")", "n=int(input())\r\ndic={\"100\":0,\"200\":0}\r\nfor j in input().split(\" \"):\r\n dic[j]+=1\r\nrhs=(dic[\"100\"]+2*dic[\"200\"])\r\nif rhs%2!=0:\r\n print(\"NO\")\r\nelse:\r\n l=[1 for x in range(dic[\"100\"]+1) for y in range(dic[\"200\"]+1) if 2*x+4*y==rhs]\r\n if len(l)>0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n ", "from collections import defaultdict\r\n\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\n\r\n# Initialize a defaultdict with default value 0\r\nfrequency = defaultdict(int)\r\n\r\n# Count the frequency of each element in the array\r\nfor k in arr:\r\n frequency[k] += 1\r\n\r\nq1 = frequency[100]\r\nq2 = frequency[200]\r\n\r\n# Divide 200's equally\r\nbaki_200 = q2 % 2\r\nbaki_100 = q1 - (baki_200 * 2)\r\n\r\nif baki_100 >= 0 and baki_100 % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\ncount1=int(0)\r\ncount2=int(0)\r\nfor i in range(n):\r\n if l[i]==100:\r\n count1+=1\r\n else:\r\n count2+=1\r\nif count1%2==0 and count2%2==0:\r\n print(\"YES\")\r\nelif count1%2==1 and count2%2==1:\r\n print(\"NO\")\r\nelif count1%2==0 and count2%2==1:\r\n if count1==0:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = int(input())\na = [int(i) for i in input().split()]\n\ncnt = [0, 0]\nfor i in a:\n cnt[i // 100 - 1] += 1\n\ncnt[1] %= 2\n\ncnt[0] -= cnt[1] * 2\n\nprint(\"YES\" if cnt[0] % 2 == 0 and cnt[0] >= 0 else \"NO\")\n", "n = input()\r\nv = [x for x in input().split()]\r\no = v.count('100')\r\nt = v.count('200')\r\n\r\nif o%2==0 and (o > 0 or t%2 == 0):\r\n print('YES')\r\nelse:\r\n print('NO')", "n = int(input())\r\nweights = [int(w) for w in input().split(\" \", n-1)]\r\nk = sum(weights)/2\r\nif (k%200==0) or (k%100==0 and 100 in weights):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=int(input())\r\nx=list(map(int,input().split()))\r\nd=sum(x)\r\nif d%200==0 and (len(x)%2==0 or (len(x)%2==1 and 100 in x and 200 in x)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n=int(input())\r\nlst=list(map(int,input().split()))\r\none,two=0,0\r\nfor i in lst:\r\n if(i==100):\r\n one+=1\r\n else:\r\n two+=1\r\nif((one==0 and two%2!=0) or (two==0 and one%2!=0) or(one%2!=0 and two%2!=0) or(two%2==0 and one%2!=0) ):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n \r\n\r\n\r\n \r\n ", "n = int(input())\nw = [int(i) for i in input().split(\" \")]\n\nif(w.count(100)%2 == 1):\n print(\"NO\")\nelse:\n if(w.count(200)%2 == 0):\n print(\"YES\")\n elif(w.count(200)%2 == 1 and w.count(100) >= 2):\n print(\"YES\")\n else:\n print(\"NO\")\n\t\t\t\t \t\t \t \t\t \t\t\t \t\t", "n = int(input())\r\nw = list(map(int, input().split()))\r\none = w.count(100)\r\ntwo = w.count(200)\r\nb_200 = two%2\r\nb_100 = one - (b_200*2)\r\nif(b_100>=0 and b_100%2 == 0):\r\n print('YES')\r\nelse:\r\n print('NO')", "a=[*open(0)][1].split()\r\na,b=[a.count('100'),a.count('200')]\r\nprint('YNEOS'[(a+2*b)%2 or b%2 and a<2::2])", "\r\na=input()\r\nb=list(map(int,input().split()))\r\ng={200:0,100:0}\r\ndef ok(b):\r\n #print(b)\r\n val=0 \r\n for i in b:\r\n g[i]=g[i]+1 \r\n val=val+i\r\n if val%2==1:\r\n return \"NO\"\r\n b=val//2\r\n i=0 \r\n while True:\r\n if g[200]!=0 and i+200<=b:\r\n if i+200==b or i+100==b:\r\n return \"YES \"\r\n i=i+200\r\n elif g[100]!=0 and i+100<=b:\r\n if i+100==b:\r\n return \"YES\"\r\n i=i+100\r\n else:\r\n return \"NO\"\r\nprint(ok(b))", "n=int(input())\r\na=list(map(int,input().split()))\r\ns=sum(a)\r\nif s%200==0:\r\n if n %2==0:\r\n print(\"YES\")\r\n else:\r\n if (s/100-n)==s/200:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n = int(input())\narr = list(map(int, input().split()))\n\ncnt_200 = arr.count(200)\ncnt_100 = arr.count(100)\n\nif cnt_200%2 == 0:\n if cnt_100%2 == 0:\n print('YES')\n else:\n print('NO')\nelse:\n if cnt_100%2 == 0 and cnt_100 >= 2:\n print('YES')\n else:\n print('NO')\n", "n=int(input())\r\nL=list(map(int,input().split()))\r\nif (sum(L)/2)%100!=0:\r\n print(\"NO\")\r\nelif 100 not in L and n%2!=0:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\") ", "n=int(input())\r\nx1=0\r\nx2=0\r\nl=list(map(int,input().split())) \r\nll=[i for i in l if i==100]\r\nl=[i for i in l if i==200]\r\nfor i in range(len(l)):\r\n if i%2==0:x1+=2\r\n else : x2+=2\r\nfor i in range(len(ll)):\r\n if x1>x2:x2+=1\r\n else : x1+=1\r\n \r\nif x1==x2 :\r\n print(\"YES\")\r\nelse : print(\"NO\")", "k = int(input())\r\nj = [int(i) / 100 for i in input().split()]\r\nprint(\"YES\" if sum(j) % 4 == 0 or (sum(j) % 2 == 0 and 1 in j) else \"NO\")", "'''n = int(input())\r\nl = list(map(int, input().split(\" \")))\r\nsumm = sum(l)\r\nhalf = summ/2\r\na = l.count(100)\r\nb = l.count(200)\r\nif summ % 200 != 0:\r\n print(\"NO\")\r\nelse:\r\n ans = False\r\n for i in range(0, b+1):\r\n if (i*200 <= half and half - 200*i <= a*100):\r\n ans = True\r\n if (ans):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n'''\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\nprint('NO' if sum(a) / 100 % 2 or n == 1 or (sum(x %\r\n 200 for x in a) == 0 and n % 2) else 'YES')\r\n", "a=int(input())\r\nl=list(map(int,input().split()))\r\nm,n=0,0\r\nfor i in l:\r\n\tif i==100:\r\n\t\tm+=1\r\n\telse:n+=1\r\nif m%2 or m==0 and n%2:\r\n\tprint('NO')\r\nelse:print('YES')", "import sys\r\nimport math\r\nimport copy\r\nfrom collections import deque\r\nfrom collections import *\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n\r\ndef ll(): return list(map(int, input().split()))\r\n\r\n\r\ndef lf(): return list(map(float, input().split()))\r\n\r\n\r\ndef ls(): return list(map(str, input().split()))\r\n\r\n\r\ndef mn(): return map(int, input().split())\r\n\r\n\r\ndef nt(): return int(input())\r\n\r\n\r\ndef ns(): return input()\r\nn=nt()\r\nk=ll()\r\nl=Counter()\r\nfor x in k:\r\n l[x]+=1\r\nif l[100]%2==0 and l[200]%2==0:\r\n print(\"YES\")\r\nelif l[100]%2==0 and l[100]!=0 and l[200]%2==1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def main():\n n = int(input())\n elems = list(sorted(map(int, input().split(' '))))\n\n s1, s2 = 0, 0\n\n while elems:\n x = elems.pop()\n if s1 > s2:\n s2 += x\n else:\n s1 += x\n\n print(\"YES\" if s1 == s2 else \"NO\")\n\n\nif __name__ == \"__main__\":\n main()\n", "n = int(input())\nls = list(map(int,input().split(\" \")))\nl = 0\nfor i in range(n):\n if ls[i]==100: l+=1\nif l%2==0 and l>0: print(\"YES\")\nelif l == 0 and n%2 == 0:print(\"YES\")\nelse:print(\"NO\")\n", "n = int(input())\r\nlst = list(map(int,input().split()))\r\na = lst.count(100)\r\nb = lst.count(200)\r\n\r\n#print(lst)\r\nif(a % 2 == 1 or (b % 2 == 1 and a == 0)):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "n = int(input())\r\nl = list(map(int,input().split()))\r\na = l.count(100)\r\nb = l.count(200)\r\nif a%2==0 and b%2==0:\r\n print(\"YES\")\r\nelse:\r\n if b%2==0 and a%2!=0:\r\n print(\"NO\")\r\n elif b%2!=0:\r\n if (a-2)%2==0 and a>=2:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "n = int(input())\r\na = [int(i) for i in input().split()]\r\n\r\np = a.count(100) \r\nq = a.count(200)\r\n\r\nif((p == 0 and q%2 == 0) or (q == 0 and p%2 == 0)) :\r\n print(\"YES\")\r\nelse:\r\n if((p%2 == 0 and q%2 == 0 and p>0) or (p%2 == 0 and q%2 != 0 and p>0) ):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n", "count = int(input())\r\napples = input().split()\r\nsto = apples.count('100')\r\ndv = apples.count('200')\r\n \r\nif sto % 2 == 1 or (dv % 2 == 1 and sto < 2):\r\n print('NO')\r\nelse:\r\n print('YES')", "import sys\r\ninput = lambda :sys.stdin.readline().rstrip()\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\n \r\n# for _ in range(int(input())):\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\ns=sum(l)\r\ns=s//100\r\nif (s%2!=0):\r\n print(\"NO\")\r\nelse:\r\n s=s//2\r\n if (s%2==0):\r\n print(\"YES\")\r\n else:\r\n if(l.count(100)>=2):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "n=int(input())\r\na=list(map(int,input().split()))\r\nif sum(a)%2!=0:\r\n print(\"NO\")\r\nelse:\r\n c1=0\r\n c2=0\r\n for i in a:\r\n if i==100:\r\n c1=c1+1\r\n else:\r\n c2=c2+1\r\n if c2%2==0:\r\n if c1%2==0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n if c1<2:\r\n print(\"NO\")\r\n elif c1%2!=0:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")", "n = int(input())\narray = list(map(int, input().split()))\narray.sort(reverse=True)\na = 0\nb = 0\n\nfor x in array:\n if a > b:\n b += x\n else:\n a += x\n\nif a == b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "def solve(a,target,res,i=0,curr=[]):\r\n if(target==0):\r\n res.append(curr[:])\r\n return\r\n if target<0:\r\n return\r\n for x in range(i,len(a)):\r\n curr.append(a[x])\r\n solve(a,target-a[x],res,x+1,curr)\r\n curr.pop()\r\n\r\nfrom collections import Counter\r\nn=int(input())\r\na = list(map(int,input().split()))\r\ndic = Counter(a)\r\nx = dic[100]\r\ny = dic[200]\r\n# print(dic,x,y)\r\n\r\ns = sum(a)\r\n\r\n#knapsack\r\ntarget = s//2\r\n\r\ndp = [[False for i in range(target+1)]for j in range(n+1)]\r\nfor i in range(n+1):\r\n for j in range(target+1):\r\n if i==0 and j==0:\r\n dp[i][j] = True\r\n elif(i==0 and j!=0):\r\n dp[i][j] = False\r\n elif(i!=0 and j==0):\r\n dp[i][j] = True\r\nfor i in range(1,n+1):\r\n for j in range(1,target+1):\r\n if(a[i-1]<=j):\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\nans = dp[n][target]\r\n\r\nif ans:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\r\n", "def main():\r\n n = int(input())\r\n seq = list(map(int, input().split()))\r\n a = 0\r\n b = 0\r\n for i in range(n):\r\n a += (seq[i] == 100)\r\n b += (seq[i] == 200)\r\n sm = sum(seq) // 2\r\n if sm % 100:\r\n print(\"NO\")\r\n else:\r\n ans = False\r\n for i in range(b + 1):\r\n if 200 * i <= sm and sm - 200 * i <= a * 100:\r\n ans = True\r\n if ans:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "from collections import Counter\r\n\r\n\r\ndef main():\r\n input()\r\n weights = [int(i) for i in input().split()]\r\n weights = Counter(weights)\r\n\r\n if not 100 in weights:\r\n # Only 200s\r\n print(\"YES\" if weights[200] % 2 == 0 else \"NO\")\r\n return\r\n\r\n if not 200 in weights:\r\n # Only 100s\r\n print(\"YES\" if weights[100] % 2 == 0 else \"NO\")\r\n return\r\n\r\n weights[200] %= 2\r\n if weights[200] == 1:\r\n print(\"YES\" if (weights[100] - 2 >=\r\n 0 and weights[100] % 2 == 0) else \"NO\")\r\n return\r\n else:\r\n print(\"YES\" if weights[100] % 2 == 0 else \"NO\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n = int(input())\r\nw = list(map(int, input().split()))\r\n\r\ntotal = 0\r\n\r\nfor i in w:\r\n total += i\r\n\r\nif total%200 == 0 and n%2==1:\r\n for i in w:\r\n if i != 200:\r\n print(\"YES\")\r\n break\r\n else: print(\"NO\")\r\nelif total%200 == 0:\r\n print(\"YES\")\r\nelse: print(\"NO\")", "n=int(input())\r\nw=list(map(int,input().split(\" \")))\r\nw_100 = w.count(100)\r\nw_200 = w.count(200)\r\nif w_100 % 2 ==1 or (w_200 % 2 == 1 and w_100 == 0):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n", "#文字列入力はするな!!\r\n#carpe diem\r\n\r\n'''\r\n ██╗ ██╗ ███╗ ███╗ ██╗ ████████╗\r\n ██║ ██║ ████╗ ████║ ██║ ╚══██╔══╝\r\n═════════██╠════════██╠═══██╔████╔██╠═══██╠══════██╠══════════\r\n ██║ ██║ ██║╚██╔╝██║ ██║ ██║\r\n ███████╗ ██║ ██║ ╚═╝ ██║ ██║ ██║\r\n ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\r\n'''\r\n\r\n#文字列入力はするな!!\r\n#carpe diem\r\n\r\nn=int(input())\r\nL=list(map(int,input().split()))\r\n\r\n\r\none=L.count(100)\r\ntwo=L.count(200)\r\n\r\ntotal=sum(L)//2\r\n\r\nif one%2!=0 or (one==0 and two%2!=0):\r\n print('NO')\r\nelse:\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#carpe diem \r\n#carpe diem", "n=int(input())\r\nl=list(map(int,input().split()))\r\nh1=l.count(100)\r\nh2=l.count(200)\r\nif n==1:\r\n print(\"NO\")\r\nelse:\r\n if h1==0 and h2%2==1:\r\n print(\"NO\")\r\n else:\r\n if sum(l)//100%2==0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "from collections import defaultdict\r\n\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\n\r\n# Initialize a defaultdict with default value 0\r\nfrequency = defaultdict(int)\r\n\r\n# Count the frequency of each element in the array\r\n#for k in arr:\r\n#frequency[k] += 1\r\n\r\nq1, q2 = sum(arr) // 2, sum(arr) // 2\r\narr.sort()\r\nif sum(arr) % 2 != 0:\r\n print(\"NO\")\r\nelse:\r\n for i in range(n - 1, -1, -1):\r\n if arr[i] <= q1:\r\n q1 -= arr[i]\r\n arr[i] = 0\r\n\r\n for i in range(n - 1, -1, -1):\r\n if arr[i] <= q2:\r\n q2 -= arr[i]\r\n arr[i] = 0\r\n\r\nif q1 == 0 and q2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = int(input())\r\nl = list(map(int, input().split()))\r\ns = sum(l)\r\n#print(s)\r\nif(n==1):\r\n print(\"NO\")\r\nelif(s%400 == 0 or (s%200 == 0 and 100 in l)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "n = int(input())\r\nlist1 = [int(num) for num in input().split()]\r\nones=0\r\ntwos=0\r\nfor i in range(0,n):\r\n if(list1[i]==100):\r\n ones+=1\r\n else:\r\n twos+=1\r\ntotal = 100*ones +200*twos\r\nhalf = total//2\r\nif(half%100!=0):\r\n print(\"NO\")\r\nelse:\r\n nn = half//100\r\n if(nn%2==0):\r\n print(\"YES\")\r\n else:\r\n if(ones>=2):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "from collections import Counter\r\n\r\n\r\ndef main():\r\n n = get_int()\r\n nums = get_list_int()\r\n counter = Counter(nums)\r\n total = sum(nums)\r\n target_sum = total // 2\r\n\r\n cur_sum = 0\r\n while cur_sum < target_sum:\r\n if counter[100] and cur_sum + 100 == target_sum:\r\n print(\"YES\")\r\n return\r\n\r\n if counter[200]:\r\n cur_sum += 200\r\n counter[200] -= 1\r\n else:\r\n cur_sum += 100\r\n counter[100] -= 1\r\n\r\n if cur_sum == target_sum:\r\n print(\"YES\")\r\n return\r\n\r\n print(\"NO\")\r\n\r\n\r\ndef get_int() -> int:\r\n return int(input())\r\n\r\n\r\ndef get_list_int() -> list[int]:\r\n return [int(x) for x in input().split(\" \")]\r\n\r\n\r\ndef get_list_str() -> list[str]:\r\n return input().split(\" \")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n=int(input())\r\na=[str(a)for a in input().split()]\r\nif n==1:\r\n print(\"NO\")\r\nelse:\r\n if '100' not in a:\r\n if n%2==0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n z=a.count(\"100\")\r\n if z%2==0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n\r\n\r\n", "n = int(input())\r\nnums = [int(x)//100 for x in input().split()]\r\nif sum(nums)%2 == 1 or (min(nums)==2 and sum(nums)%4!=0):\r\n\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")", "\n\nn = int(input())\n\narr = list(map(int,input().split(' ')))\n\na,b = 0,0\nfor e in arr:\n if e==100:\n a+=1\n else:\n b+=1\n\nif a%2==1:\n print(\"NO\")\nelse:\n if b%2==0:\n print(\"YES\")\n else:\n if a>1:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\n\n\n\n ", "from sys import stdin\r\ndef input(): return stdin.readline()[:-1]\r\nn=int(input())\r\na=list(map(int,input().split()))\r\ncnt1=cnt2=0\r\nfor i in range(n):\r\n\tif a[i]==100:\r\n\t\tcnt1+=1\r\n\telse:\r\n\t\tcnt2+=1\r\nif cnt2%2==0:\r\n\tif cnt1%2==0:\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")\r\nelse:\r\n\tif cnt1%2==0 and cnt1:\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")", "import sys\r\n\r\ndef _input(): return map(int, input().split())\r\n \r\nn = int(input())\r\nlst = list(_input())\r\no = lst.count(100); t = lst.count(200)\r\nif n==1: print(\"NO\")\r\nelif o == 0: \r\n print(\"YES\" if t%2==0 else \"NO\")\r\nelif t==0: print(\"YES\" if o%2==0 else \"NO\")\r\nelif o%2==0: print(\"YES\")\r\nelse: print(\"NO\")\r\n\r\n", "n=int(input())\r\n\r\na=0\r\nb=0\r\n\r\napples=[int(i) for i in input().split()]\r\n\r\na=apples.count(100)\r\nb=apples.count(200)\r\n\r\nif(a%2==0):\r\n if(b%2==0):\r\n print(\"YES\")\r\n elif(a>=2):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")", "n=int(input())\r\nar=list(map(int,input().split()))\r\nif (sum(ar)/2)%100!=0 or n%2 and ar.count(100)<1:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "n = int(input())\nw = list(map(int, input().split()))\n\no = 0\nt = 0\nfor i in range(n):\n if w[i] == 100:\n o += 1\n else:\n t += 1\n\nif o %2 == 0 and t %2 == 0:\n print('YES')\nelif o %2 == 0 and 2 <= o:\n print('YES')\nelse:\n print('NO')", "n = int(input())\r\nW = list(map(int, input().split()))\r\n\r\nprint('NO' if sum(W)%200 or n%2 and W.count(100)<1 else 'YES')", "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############ ---- Input Functions ---- ############\r\n\r\ndef Kitahara_Harukis_Gift():\r\n n = inp()\r\n appleList = inlt()\r\n\r\n num100 = appleList.count(100)\r\n num200 = appleList.count(200)\r\n\r\n if num100 % 2 == 0 and num200 % 2 == 0:\r\n print(\"YES\")\r\n elif num100 % 2 != 0:\r\n print(\"NO\")\r\n elif num200 % 2 != 0:\r\n if num100 >= 2:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n return\r\n\r\nKitahara_Harukis_Gift()", "n = int(input())\r\n\r\na = list(map(int, input().split()))\r\n\r\nfrom collections import Counter\r\n\r\nc = Counter(a)\r\n\r\na100 = c[100]\r\na200 = c[200]\r\n\r\nrest_pair= a200%2 \r\nrest_100 = a100 - 2*rest_pair\r\n\r\nif rest_100 >= 0 and rest_100%2 == 0:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "from re import L\r\n\r\n\r\nnumber = int(input())\r\napples = list(map(int, input().split()))\r\n\r\nsum = 0\r\ntwo_hundred = 0\r\none_hundred = 0\r\n\r\nfor apple in apples:\r\n sum += apple\r\n if apple == 100:\r\n one_hundred += 1\r\n else:\r\n two_hundred += 1\r\n\r\nflag = False\r\nif sum % 200 != 0:\r\n print(\"NO\")\r\nelse:\r\n if len(apples) == 1:\r\n print(\"NO\")\r\n else:\r\n for a in range(101):\r\n for b in range(101):\r\n for c in range(101):\r\n for d in range(101):\r\n if (100 * (a+c) + 200 * (b+d) == sum and \r\n a+c == one_hundred and \r\n b+d == two_hundred and \r\n (100*a + 200*b == sum/2) and \r\n (100*c + 200*d == sum/2)):\r\n flag = True\r\n if flag == True:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "n = int(input())\nvalues = list(map(int, input().split()))\nvalues.sort(reverse=True)\n\na, b = 0, 0\nfor value in values:\n if a <= b:\n a += value\n else:\n b += value\n\nif a == b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "n = int(input())\r\n\r\na = list(map(int , input().split()))\r\nh = 0 \r\n\r\nfor el in a :\r\n if(el == 100):\r\n h += 1 \r\n\r\nif(h % 2 == 1 or (n % 2 == 1 and h == 0)):\r\n print('NO')\r\nelse:\r\n print('YES')", "n = int(input())\r\na = [int(x) for x in input().split()]\r\nres = \"NO\" if (sum(a )/100)%2 != 0 or (min(a) == 200 and n%2 != 0) else \"YES\"\r\nprint(res)\r\n", "i = int(input())\r\nl = list(map(int,input().split()))\r\na = l.count(100)%2\r\nb = l.count(200)%2\r\nif a == 1:\r\n print('NO'); exit()\r\nif b == 1 and l.count(100) > 1: print('YES'); exit()\r\nif a == 0 and b == 0: print('YES'); exit()\r\nprint('NO')", "def main() -> None:\r\n n = int(input())\r\n all = [int(x) for x in input().split()]\r\n s = sum(all)\r\n _ = all.count(100)\r\n __ = all.count(200)\r\n if (s // 100) % 2 != 0:\r\n print('NO')\r\n else:\r\n for i in range(min((s // 2) // 200, __) + 1):\r\n if (s // 2 - i * 200) // 100 <= _:\r\n print('YES')\r\n break\r\n else:\r\n print('NO')\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n = int(input())\r\nl = list(map(int, input().split()))\r\nls = sum(l)\r\nres = 'NO'\r\n\r\nif (ls/2)%100 == 0:\r\n ls2 = ls/2\r\n thcr = ls2//200\r\n thc = l.count(200)\r\n s = ls2 - min(thc, thcr) * 200 \r\n ohcr = s//100\r\n if l.count(100) >= ohcr:\r\n res = 'YES'\r\n\r\nprint(res)", "\r\nn=int(input())\r\n\r\ninp=input().split()\r\nL=[]\r\nones=0\r\ntwos=0\r\nfor i in inp:\r\n h=int(i)\r\n if h==200:\r\n twos+=1\r\n else:\r\n ones+=1\r\n L+=[h]\r\nif ones%2==0:\r\n if twos%2==0:\r\n print(\"YES\")\r\n else:\r\n if ones!=0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")\r\n ", "apples = int(input())\r\ngrams = list(map(int, input().split()))\r\nhundred = grams.count(100)\r\ntwoHundred = grams.count(200)\r\nif apples == 1:\r\n print(\"NO\")\r\nelif apples % 2 != 0:\r\n if twoHundred % 2 != 0 and twoHundred < apples:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelif apples % 2 == 0:\r\n if hundred % 2 == 0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "n = int(input())\r\nl = list(map(int,input().split(' ')))\r\n\r\ndef function(array):\r\n a100 = array.count(100)\r\n a200 = array.count(200)\r\n\r\n if a100 % 2 == 0 and a200 % 2 == 0:\r\n print('YES')\r\n elif a100 % 2 == 0 and a200 % 2 == 1 and a100 > 0:\r\n print('YES')\r\n else: \r\n print('NO')\r\n \r\nfunction(l)\r\n", "n = int(input())\r\nm = list(map(int, input().split()))\r\nif (m.count(100) == 0) or (m.count(200) == 0):\r\n if n%2 == 0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n if m.count(100)%2 == 0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "n = int(input())\na = list(map(int, input().split()))\np = a.count(100)\ns = a.count(200)\nif p == 0:\n if s%2 == 0:\n print(\"YES\")\n else :\n print('NO')\nelse :\n if (p-2*(s%2))%2 == 0:\n print(\"YES\")\n else :\n print(\"NO\")", "n=int(input())\r\nnums=list(map(int,input().split()))\r\nhmap={}\r\nfor item in nums:\r\n hmap[item]=1+hmap.get(item,0)\r\nif (hmap.get(100,0))%2!=0 or ((hmap.get(200,0))%2!=0 and hmap.get(100,0)==0):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\") ", "n = int(input())\r\narr = list(map(int, input().split()))\r\nif len(arr) == 1:\r\n print('NO')\r\nelse:\r\n dict1 = {}\r\n for num in arr:\r\n dict1[num] = arr.count(num)\r\n\r\n if 100 not in dict1.keys():\r\n if len(arr) & 1 == 0:\r\n print('YES')\r\n else:\r\n print('NO')\r\n else:\r\n if (dict1[100] & 1 == 0):\r\n print('YES')\r\n else:\r\n print('NO')\r\n", "n = int(input())\r\na = sorted([int(_) for _ in input().split()])\r\nif (sum(a) // 100) % 2 == 1:\r\n print(\"NO\")\r\n exit()\r\nf, s = 0, 0\r\nif a.count(200) % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n if a.count(100) == 0:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n", "n=int(input())\r\nl=list(map(int, input().split()))\r\nc=set(l)\r\nif len(c)==1:\r\n if n%2==0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n p = len([i for i, x in enumerate(l) if x == 100])\r\n q = len([i for i, x in enumerate(l) if x == 200])\r\n if p%2==0 and q%2==0:\r\n print(\"YES\")\r\n elif p%2!=0 and q%2!=0:\r\n print(\"NO\")\r\n elif p%2==0 and q%2!=0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "import sys\r\nimport math\r\nimport collections\r\nimport heapq\r\ninput=sys.stdin.readline\r\nn=int(input())\r\nl=[int(i) for i in input().split()]\r\nk1=l.count(100)\r\nk2=l.count(200)\r\nif(k1%2==0 and k2%2==0):\r\n print(\"YES\")\r\nelse:\r\n if(k1%2==1 and k2%2==0):\r\n print(\"NO\")\r\n elif(k1%2==0 and k2%2==1):\r\n if(k1>=2):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"NO\")", "from collections import Counter\r\nn = int(input())\r\na = list(map(int,input().split()))\r\nc = Counter(a)\r\nhun = c[100]\r\ntwohun = c[200]\r\nif hun!=0 and twohun!=0 :\r\n if ((twohun*200+hun*100)/2)%100==0:\r\n print(\"YES\")\r\n else :\r\n print(\"NO\")\r\nelif twohun==0 :\r\n if hun%2==0 :\r\n print(\"YES\")\r\n else :\r\n print(\"NO\")\r\nelif hun==0 :\r\n if twohun%2==0 :\r\n print(\"YES\")\r\n else :\r\n print(\"NO\")\r\n", "n = int(input())\narr = list(map(int, input().split()))\n\ncnt_200 = arr.count(200)\ncnt_100 = arr.count(100)\n\nif cnt_100%2 == 0 and (cnt_200%2 == 0 or cnt_200%2 == 1 and cnt_100 >= 2):\n print('YES')\nelse:\n print('NO')\n", "n = int(input())\r\nl = list(map(int, input().split(\" \")))\r\nsumm = sum(l)\r\nhalf = summ/2\r\na = l.count(100)\r\nb = l.count(200)\r\nif summ % 200 != 0:\r\n print(\"NO\")\r\nelse:\r\n ans = False\r\n for i in range(0, b+1):\r\n if (i*200 <= half and half - 200*i <= a*100):\r\n ans = True\r\n if (ans):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "n= int(input())\r\nl=[int(i) for i in input().split()]\r\ncnt1=l.count(100)\r\ncnt2=l.count(200)\r\nmysum=sum(l)\r\nif(mysum%200!=0):\r\n print(\"NO\")\r\nelse:\r\n if(mysum%400!=0):\r\n if(cnt1>=2):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n\r\n\r\n", "from math import *\r\n\r\n\r\ndef main():\r\n n = input()\r\n W = list(sorted(map(int, input().split())))\r\n if W.count(200) % 2 == 0 and W.count(100) % 2 == 0:\r\n print(\"YES\")\r\n else:\r\n if W.count(100) % 2 == 0 and W.count(200) % 2 == 1:\r\n print(\"YES\" if W.count(100) > 1 else \"NO\")\r\n else:\r\n print(\"NO\")\r\n\r\nif __name__ == '__main__':\r\n main()", "n=int(input())\r\na=input().split()\r\nb=[int(i) for i in a]\r\nif sum(b)%200!=0:\r\n print(\"NO\")\r\nelse:\r\n k=sum(b)//2\r\n if k%200==0:\r\n l=k//200\r\n c=0\r\n else:\r\n l=k//200\r\n c=1\r\n flag=False\r\n while l>=0:\r\n if b.count(200)>=l and b.count(100)>=c:\r\n flag=True\r\n break\r\n else:\r\n l=l-1\r\n c=c+2\r\n if flag==True:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n \r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nm,t=0,0\r\nfor i in l:\r\n if i==100:\r\n m+=1\r\n else:\r\n t+=1\r\nh='NO'\r\nif n>1:\r\n if (m==0 and t%2==0) or (m!=0 and m%2==0):\r\n h='YES'\r\n else:\r\n pass\r\nprint(h)", "n = int(input())\r\nls = list(map(int,input().split()))\r\nsu = sum(ls)\r\nif su%400 == 0 or (su%200 == 0 and 100 in ls):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = int(input())\r\na = list(map(int,input().split()))\r\na.sort()\r\ns = sum(a)\r\n\r\nif n == 1:\r\n print('NO')\r\nelse:\r\n one = a.count(100)\r\n two = a.count(200)\r\n f = 0\r\n for i in range(one+1):\r\n for j in range(two+1):\r\n if i+2*j == one-i+2*two-2*j:\r\n f = 1\r\n break\r\n if f == 0:\r\n print('NO')\r\n else:\r\n print('YES')\r\n", "n = int(input())\r\na = list(map(int, input().split(\" \")))\r\nc_100 = a.count(100)\r\nc_200 = a.count(200)\r\nif c_100 % 2 == 1 or (c_200 % 2 == 1 and c_100 == 0):\r\n\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")", "n = int(input())\r\na = list(map(int, input().split()))\r\nv = \"YES\"\r\nif(sum(a)%200==0):\r\n\tif(n%2!=0):\r\n\t\tif(100 not in a):\r\n\t\t\tv = \"NO\"\r\nelse:\r\n\tv = \"NO\"\r\n\r\nprint(v)", "n = int(input())\r\nw = sorted(list(map(int, input().split())), reverse=True)\r\nh = sum(w) // 2\r\nans = 0\r\nfor i in w:\r\n if h >= ans + i:\r\n ans += i\r\n if h == ans:\r\n print(\"YES\")\r\n break\r\nif h != ans:\r\n print(\"NO\")", "from collections import Counter\r\n\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\nd = Counter(arr)\r\na = d[100]\r\nb = d[200]\r\n# print(d)\r\nif b == 0:\r\n if d[100] % 2 == 0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelif a == 0:\r\n if d[200] % 2 == 0:\r\n print(\"YES\")\r\n else:\r\n print('NO')\r\nelse:\r\n total = sum(arr) // 100\r\n if total % 2 == 1:\r\n print(\"NO\")\r\n else:\r\n var = 2 * b - a\r\n if var % 2 == 1:\r\n print(\"NO\")\r\n else:\r\n # print(\"Yes\")\r\n if var % 2 == 0 and var // 2 <= b:\r\n print(\"YES\")\r\n elif var % 2 == 1 and b >= 1 and (var + 1) // 2 <= b:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "import sys\r\nfrom math import sqrt,ceil,floor,gcd\r\nfrom collections import Counter\r\n\r\ninput = lambda:sys.stdin.readline()\r\n\r\ndef int_arr(): return list(map(int,input().split()))\r\ndef str_arr(): return list(map(str,input().split()))\r\ndef get_str(): return map(str,input().split())\r\ndef get_int(): return map(int,input().split())\r\ndef get_flo(): return map(float,input().split())\r\ndef lcm(a,b): return (a*b) // gcd(a,b)\r\n\r\nmod = 1000000007\r\n\r\ndef solve(n,arr):\r\n arr.sort(reverse = True)\r\n a,b = arr[0],0\r\n for i in range(1,n):\r\n if a != b:\r\n b += arr[i]\r\n else:\r\n a += arr[i]\r\n\r\n print(\"YES\" if a == b else \"NO\")\r\n\r\n\r\n\r\n# for _ in range(int(input())):\r\nn = int(input())\r\narr = int_arr()\r\nsolve(n,arr)\r\n ", "n=int(input())\r\narr=list(map(int,input().split()))\r\n\r\n\r\ncount_100=arr.count(100)\r\ncount_200=arr.count(200)\r\n\r\nif count_100 %2 ==0 and (count_200%2==0 or count_100>0):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "n = int(input())\r\nw = list(map(int, input().split()))\r\na, b = w.count(100), w.count(200)\r\n\r\nif((b % 2 and (a % 2 or a == 0)) or (b % 2 == 0 and a % 2)):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "n=int(input())\r\narr=list(map(int,input().split()))\r\narr.sort()\r\nsuml=sum(arr)\r\nc1=arr.count(100)\r\nc2=arr.count(200)\r\nif n==1 or (suml//2)%100==50:\r\n print(\"NO\")\r\nelse:\r\n if c1==0 or c2==0:\r\n if n%2==0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n \r\n \r\n", "n = int(input())\r\narr = list(map(int,input().split()))\r\nc1 = arr.count(100)\r\nc2 = n - c1\r\nif c1 & 1:\r\n print('NO')\r\nelif c1 == 0 and c2&1:\r\n print('NO')\r\nelse:\r\n print('YES')", "from collections import Counter\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nc=Counter(l)\r\nfind=sum(l)//2\r\nwhile find>=200:\r\n if c[200]>0:\r\n c[200]-=1\r\n find-=200\r\n else:\r\n break\r\n\r\nwhile find>=100:\r\n if c[100]>0:\r\n c[100]-=1\r\n find-=100\r\n else:\r\n break\r\nb=0\r\nfor x in c:\r\n b+=x*c[x]\r\nif b==sum(l)//2 and find==0:\r\n print('YES')\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n", "n = int(input())\r\n\r\na = list(map(int,input().split()))\r\n\r\nnet = sum(a)\r\n\r\nif net%200:\r\n print(\"NO\")\r\n exit()\r\n\r\n\r\nt = net//2\r\n\r\ntset = set()\r\ntset.add(0)\r\n\r\nfor i in range(n):\r\n cset = tset.copy()\r\n for j in tset:\r\n cset.add(j+a[i])\r\n tset = cset\r\n if t in tset:\r\n print(\"YES\")\r\n exit()\r\n\r\nprint(\"NO\")\r\n\r\n\r\n ", "n = input() #WERE WEIGHT IS 100/ 200\r\nres = [int(x) for x in input().split()]\r\nif (sum(res)/2)%100 == 0:\r\n amount_200 = (sum(res)/2)//200\r\n if amount_200 <= res.count(200):\r\n amount_100 = (sum(res)/2 - (200 * ((sum(res)/2)//200)))//100\r\n if amount_100 <= res.count(100):\r\n print('YES')\r\n else:\r\n print('NO')\r\n else:\r\n amount_200 = res.count(200)\r\n amount_100 = (sum(res)/2 - (amount_200 * 200))//100\r\n if amount_100 <= res.count(100):\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')", "n = int(input())\r\nwtlst = [int (x) for x in input().split()]\r\nc1 = wtlst.count(100)\r\nc2 = wtlst.count(200)\r\ntc1 = c1 * 100\r\ntc2 = c2 * 200\r\nif(c1%2!=0):\r\n print('NO')\r\nelif(c1==0 and c2%2==0):\r\n print('YES')\r\nelif(c1==0 and c2%2!=0):\r\n print('NO')\r\nelif(c1==c2):\r\n print('YES')\r\nelif(c1%2==0 and tc1>=tc2):\r\n print('YES')\r\nelif(c1%2==0 and tc1<tc2):\r\n print('YES')", "\r\nn = int(input())\r\n\r\narr = list(map(int, input().split()))\r\n\r\nn100_count = 0\r\nn200_count = 0\r\n\r\nfor item in arr:\r\n\r\n if item == 100:\r\n n100_count += 1\r\n else:\r\n n200_count += 1\r\n\r\nif (not (n200_count % 2)) and (not (n100_count % 2)):\r\n print(\"YES\")\r\nelif (not (n200_count % 2)) and (n100_count % 2):\r\n print(\"NO\")\r\n\r\nelif (n200_count % 2) and (not (n100_count % 2)):\r\n\r\n if n100_count == 0:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\none = 0\r\ntwo = 0\r\nfor i in range(len(a)):\r\n if a[i] == 100:\r\n one+=1\r\n else:\r\n two+=1\r\n \r\ntwo = two%2\r\none = one - 2*two\r\n\r\nif one%2==0 and one>=0:\r\n print(\"YES\")\r\nelse: print(\"NO\")", "n = int(input())\r\n\r\narr = list(map(int,input().split()))\r\n\r\n# print(arr)\r\n\r\nif n==1:\r\n\tprint(\"NO\")\r\nelif n==2:\r\n\tif arr[0] == arr[1]:\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")\r\nelse:\r\n\tct1=0\r\n\tct2=0\r\n\r\n\tfor num in arr:\r\n\t\tif num==100:\r\n\t\t\tct1+=1\r\n\t\telse:\r\n\t\t\tct2+=1\r\n\r\n\ttotal = ct1 * 100 + ct2 * 200;\r\n\t\r\n\thalf = total // 2\r\n\r\n\twhile half>=200 and ct2>=1:\r\n\t\thalf -=200\r\n\t\tct2-=1\r\n\r\n\twhile half>=100 and ct1>=1:\r\n\t\thalf -=100\r\n\t\tct1 -=1\r\n\r\n\tif(half!=0): print(\"NO\")\r\n\telse: print(\"YES\")\r\n\r\n\r\n\r\n" ]
{"inputs": ["3\n100 200 100", "4\n100 100 100 200", "1\n100", "1\n200", "2\n100 100", "2\n200 200", "100\n200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200", "100\n200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200", "52\n200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 100 200 100 200 200 200 100 200 200", "2\n100 200", "2\n200 100", "3\n100 100 100", "3\n200 200 200", "3\n200 100 200", "4\n100 100 100 100", "4\n200 200 200 200", "100\n200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200", "100\n200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 100 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200", "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "100\n100 100 200 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 200 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 200 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "100\n100 100 100 100 100 100 100 100 200 100 100 200 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 200 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "99\n200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200", "99\n200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200", "99\n200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200", "99\n200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200", "99\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "99\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 200 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "99\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 200 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 200 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100", "100\n100 100 200 100 100 200 200 200 200 100 200 100 100 100 200 100 100 100 100 200 100 100 100 100 100 100 200 100 100 200 200 100 100 100 200 200 200 100 200 200 100 200 100 100 200 100 200 200 100 200 200 100 100 200 200 100 200 200 100 100 200 100 200 100 200 200 200 200 200 100 200 200 200 200 200 200 100 100 200 200 200 100 100 100 200 100 100 200 100 100 100 200 200 100 100 200 200 200 200 100", "100\n100 100 200 200 100 200 100 100 100 100 100 100 200 100 200 200 200 100 100 200 200 200 200 200 100 200 100 200 100 100 100 200 100 100 200 100 200 100 100 100 200 200 100 100 100 200 200 200 200 200 100 200 200 100 100 100 100 200 100 100 200 100 100 100 100 200 200 200 100 200 100 200 200 200 100 100 200 200 200 200 100 200 100 200 200 100 200 100 200 200 200 200 200 200 100 100 100 200 200 100", "100\n100 200 100 100 200 200 200 200 100 200 200 200 200 200 200 200 200 200 100 100 100 200 200 200 200 200 100 200 200 200 200 100 200 200 100 100 200 100 100 100 200 100 100 100 200 100 200 100 200 200 200 100 100 200 100 200 100 200 100 100 100 200 100 200 100 100 100 100 200 200 200 200 100 200 200 100 200 100 100 100 200 100 100 100 100 100 200 100 100 100 200 200 200 100 200 100 100 100 200 200", "99\n100 200 200 200 100 200 100 200 200 100 100 100 100 200 100 100 200 100 200 100 100 200 100 100 200 200 100 100 100 100 200 200 200 200 200 100 100 200 200 100 100 100 100 200 200 100 100 100 100 100 200 200 200 100 100 100 200 200 200 100 200 100 100 100 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 100 200 100 200 200 200 200 100 200 100 100 100 100 100 100 100 100 100", "99\n100 200 100 100 100 100 200 200 100 200 100 100 200 100 100 100 100 100 100 200 100 100 100 100 100 100 100 200 100 200 100 100 100 100 100 100 100 200 200 200 200 200 200 200 100 200 100 200 100 200 100 200 100 100 200 200 200 100 200 200 200 200 100 200 100 200 200 200 200 100 200 100 200 200 100 200 200 200 200 200 100 100 200 100 100 100 100 200 200 200 100 100 200 200 200 200 200 200 200", "99\n200 100 100 100 200 200 200 100 100 100 100 100 100 100 100 100 200 200 100 200 200 100 200 100 100 200 200 200 100 200 100 200 200 100 200 100 200 200 200 100 100 200 200 200 200 100 100 100 100 200 200 200 200 100 200 200 200 100 100 100 200 200 200 100 200 100 200 100 100 100 200 100 200 200 100 200 200 200 100 100 100 200 200 200 100 200 200 200 100 100 100 200 100 200 100 100 100 200 200", "56\n100 200 200 200 200 200 100 200 100 100 200 100 100 100 100 100 200 200 200 100 200 100 100 200 200 200 100 200 100 200 200 100 100 100 100 100 200 100 200 100 200 200 200 100 100 200 200 200 200 200 200 200 200 200 200 100", "72\n200 100 200 200 200 100 100 200 200 100 100 100 100 200 100 200 100 100 100 100 200 100 200 100 100 200 100 100 200 100 200 100 100 200 100 200 100 100 200 200 200 200 200 100 100 200 200 200 200 100 100 100 200 200 100 100 100 100 100 200 100 100 200 100 100 200 200 100 100 200 100 200", "32\n200 200 200 100 100 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 200 200", "48\n200 200 200 200 200 200 100 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 100 200 100 200 200 200 200 200 200", "60\n100 100 200 200 100 200 100 200 100 100 100 100 100 100 200 100 100 100 200 100 200 100 100 100 100 100 200 100 200 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 200 100 100 100", "24\n200 200 100 100 200 100 200 200 100 200 200 200 200 200 100 200 200 200 200 200 200 200 200 100", "40\n100 100 200 200 200 200 100 100 100 200 100 100 200 200 100 100 100 100 100 200 100 200 200 100 200 200 200 100 100 100 100 100 200 200 100 200 100 100 200 100", "5\n200 200 200 200 200", "9\n100 100 100 200 100 100 200 100 200", "1\n200", "7\n200 200 200 100 200 200 200", "4\n100 100 200 200", "6\n100 100 100 200 200 200", "4\n200 100 100 200", "5\n100 100 100 100 200"], "outputs": ["YES", "NO", "NO", "NO", "YES", "YES", "YES", "NO", "YES", "NO", "NO", "NO", "NO", "NO", "YES", "YES", "YES", "NO", "YES", "NO", "YES", "NO", "NO", "NO", "YES", "NO", "NO", "YES", "NO", "YES", "NO", "YES", "YES", "NO", "YES", "YES", "YES", "YES", "NO", "YES", "YES", "NO", "NO", "YES", "NO", "NO", "YES", "NO", "YES", "YES"]}
UNKNOWN
PYTHON3
CODEFORCES
102
e182ab5da357b6cd08d11902dd0b81d8
Cats Transport
Zxr960115 is owner of a large farm. He feeds *m* cute cats and employs *p* feeders. There's a straight road across the farm and *n* hills along the road, numbered from 1 to *n* from left to right. The distance between hill *i* and (*i*<=-<=1) is *d**i* meters. The feeders live in hill 1. One day, the cats went out to play. Cat *i* went on a trip to hill *h**i*, finished its trip at time *t**i*, and then waited at hill *h**i* for a feeder. The feeders must take all the cats. Each feeder goes straightly from hill 1 to *n* without waiting at a hill and takes all the waiting cats at each hill away. Feeders walk at a speed of 1 meter per unit time and are strong enough to take as many cats as they want. For example, suppose we have two hills (*d*2<==<=1) and one cat that finished its trip at time 3 at hill 2 (*h*1<==<=2). Then if the feeder leaves hill 1 at time 2 or at time 3, he can take this cat, but if he leaves hill 1 at time 1 he can't take it. If the feeder leaves hill 1 at time 2, the cat waits him for 0 time units, if the feeder leaves hill 1 at time 3, the cat waits him for 1 time units. Your task is to schedule the time leaving from hill 1 for each feeder so that the sum of the waiting time of all cats is minimized. The first line of the input contains three integers *n*,<=*m*,<=*p* (2<=≤<=*n*<=≤<=105,<=1<=≤<=*m*<=≤<=105,<=1<=≤<=*p*<=≤<=100). The second line contains *n*<=-<=1 positive integers *d*2,<=*d*3,<=...,<=*d**n* (1<=≤<=*d**i*<=&lt;<=104). Each of the next *m* lines contains two integers *h**i* and *t**i* (1<=≤<=*h**i*<=≤<=*n*,<=0<=≤<=*t**i*<=≤<=109). Output an integer, the minimum sum of waiting time of all cats. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. Sample Input 4 6 2 1 3 5 1 0 2 1 4 9 1 10 2 10 3 12 Sample Output 3
[ "def solve(A, B, C):\r\n N = len(B) + 1\r\n M = len(C)\r\n \r\n a = [0] * N\r\n for i in range(1, N):\r\n a[i] += a[i - 1] + B[i - 1]\r\n \r\n b = [0] * M\r\n s = [0] * M\r\n dp = [0] * M\r\n k = [0] * M\r\n \r\n for i in range(M):\r\n b[i] = C[i][1] - a[C[i][0] - 1]\r\n \r\n b.sort()\r\n \r\n for i in range(M - 1, -1, -1):\r\n b[i] -= b[0]\r\n \r\n for i in range(M):\r\n s[i] = s[i - 1] + b[i] if i > 0 else 0\r\n \r\n for i in range(M):\r\n dp[i] = b[i] * (i + 1) - s[i]\r\n \r\n q = [0] * (10**5 + 9)\r\n \r\n for i in range(1, A):\r\n for j in range(M):\r\n k[j] = dp[j] + s[j]\r\n \r\n H = 0\r\n T = -1\r\n \r\n for j in range(M):\r\n while H < T and (k[q[H + 1]] - k[q[H]]) < b[j] * (q[H + 1] - q[H]):\r\n H += 1\r\n \r\n while H < T and (k[q[T]] - k[q[T - 1]]) * (j - q[T]) > (k[j] - k[q[T]]) * (q[T] - q[T - 1]):\r\n T -= 1\r\n \r\n T += 1\r\n q[T] = j\r\n dp[j] = k[q[H]] + b[j] * (j - q[H]) - s[j]\r\n \r\n return str(dp[M - 1])\r\n\r\nt = 1\r\n# t = int(input()) # Uncomment this line to take input for 't'\r\nwhile t > 0:\r\n n, m, p = map(int, input().split())\r\n arr = list(map(int, input().split()))\r\n brr = []\r\n for _ in range(m):\r\n brr.append(list(map(int, input().split())))\r\n print(solve(p, arr, brr))\r\n t -= 1\r\n\r\n" ]
{"inputs": ["4 6 2\n1 3 5\n1 0\n2 1\n4 9\n1 10\n2 10\n3 12"], "outputs": ["3"]}
UNKNOWN
PYTHON3
CODEFORCES
1
e186d5e1fd55287a9b94b5ef95540968
Distances to Zero
You are given the array of integer numbers *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array. The first line contains integer *n* (1<=≤<=*n*<=≤<=2·105) — length of the array *a*. The second line contains integer elements of the array separated by single spaces (<=-<=109<=≤<=*a**i*<=≤<=109). Print the sequence *d*0,<=*d*1,<=...,<=*d**n*<=-<=1, where *d**i* is the difference of indices between *i* and nearest *j* such that *a**j*<==<=0. It is possible that *i*<==<=*j*. Sample Input 9 2 1 0 3 0 0 3 2 4 5 0 1 2 3 4 7 5 6 0 1 -2 3 4 Sample Output 2 1 0 1 0 0 1 2 3 0 1 2 3 4 2 1 0 1 2 3 4
[ "n = int(input())\r\nln = list(map(int, input().split()))\r\n\r\nzeros = []\r\nzeros.append(10**6)\r\nfor i, item in enumerate(ln):\r\n if item == 0:\r\n zeros.append(i)\r\nzeros.append(10**6)\r\n\r\n\r\n# 1 4 0 5\r\nj = 0\r\nres = [0]*n\r\nfor i in range(n):\r\n if ln[i] == 0:\r\n j += 1\r\n res[i] = min(abs(i-zeros[j]), abs(i-zeros[j+1]))\r\n\r\nprint(*res)\r\n \r\n ", "import sys, math\r\ninput=sys.stdin.readline\r\nINF=int(1e9)+7\r\n\r\ndef solve():\r\n n=int(input())\r\n data=list(map(int, input().split()))\r\n result=[INF]*n\r\n for i in range(n):\r\n if data[i]==0:\r\n result[i]=0\r\n idx=i-1\r\n while idx>=0 and data[idx]!=0:\r\n result[idx]=min(result[idx],i-idx)\r\n idx-=1\r\n idx=i+1\r\n while idx<n and data[idx]!=0:\r\n result[idx]=min(result[idx],idx-i)\r\n idx+=1\r\n print(*result,sep=' ')\r\n \r\n\r\n \r\nt=1\r\nwhile t:\r\n t-=1\r\n solve()\r\n", "\r\n\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nres=[0]*n\r\nld=[0]*n\r\nrd=[0]*n\r\ndistance=float('inf')\r\nfor i in range(n):\r\n if a[i]==0:\r\n distance=0\r\n else:\r\n distance+=1\r\n ld[i]=distance\r\ndistance=float('inf')\r\nfor i in range(n-1,-1,-1):\r\n if a[i]==0:\r\n distance=0\r\n else:\r\n distance+=1\r\n rd[i]=distance\r\nres=[min(rd[i],ld[i]) for i in range(n)]\r\nprint(*res)\r\n\r\n", "n=int(input())\r\nls=list(map(int,input().split()))\r\nls1=ls.copy()\r\nmi=0x3f3f3f3f\r\nfor i in range(n):\r\n if ls1[i]!=0:\r\n ls1[i]=mi\r\n else:\r\n mi=0\r\n mi+=1\r\nls.reverse()\r\nmi=0x3f3f3f3f\r\nfor i in range(n):\r\n if ls[i]!=0:\r\n ls[i]=mi\r\n else:\r\n mi=0\r\n mi+=1\r\nls.reverse()\r\nlst=[0 for i in range(n)]\r\nfor i in range(n):\r\n lst[i]=min(ls1[i],ls[i])\r\nprint(*lst)\r\n", "n=int(input())\r\na=list(input().split())\r\nb=[i for i in range(n) if a[i]==\"0\"]\r\nc=\"\"\r\nj=0\r\nfor i in range(n):\r\n if b[0]>=i:\r\n t=b[0]-i\r\n c+=\"{} \".format(t)\r\n elif j!=len(b)-1:\r\n t=min(abs(i-b[j]),abs(i-b[j+1]))\r\n if t==0:\r\n j+=1\r\n c+=\"{} \".format(t)\r\n else:\r\n c+=\"{} \".format(i-b[j])\r\nprint(c)\r\n \r\n", "def qa():\r\n n, k = map(int, input().split())\r\n if k > n :\r\n print('-1')\r\n return\r\n matrix = [[0]*n for _ in range(n)]\r\n for i in range(k):\r\n matrix[i][i] = 1\r\n for line in matrix:\r\n print(' '.join(map(str,line)))\r\ndef qb():\r\n _ = input()\r\n d = [*map(int,input().split())]\r\n zeroIndex = [0 if v == 0 else len(d) for i, v in enumerate(d) ]\r\n counter = len(d)\r\n for i in range(len(d)):\r\n if zeroIndex[i] == 0:\r\n counter = 0\r\n continue\r\n counter += 1\r\n zeroIndex[i] = min(counter, zeroIndex[i])\r\n counter = len(d)\r\n for i in range(len(d)-1,-1,-1):\r\n if zeroIndex[i] == 0:\r\n counter = 0\r\n continue\r\n counter += 1\r\n zeroIndex[i] = min(counter, zeroIndex[i])\r\n print(' '.join(map(str,zeroIndex)))\r\nqb()", "n = int(input())\r\na = list(map(int,input().split()))\r\nINF = 10**9\r\npr = [INF for i in range(n+2)]\r\nsuff = [INF for j in range(n+2)]\r\nfor i in range(n):\r\n if not a[i]:\r\n pr[i+1] = 0\r\n suff[i+1] = 0\r\n \r\nfor i in range(1,n+2):\r\n pr[i] = min(pr[i],pr[i-1]+1)\r\ni = n\r\nwhile i >= 0:\r\n suff[i] = min(suff[i], suff[i+1]+1)\r\n i -= 1\r\nfor i in range(n):\r\n print(min(pr[i+1],suff[i+1]),end=\" \")", "n=int(input())\r\nl=list(map(int,input().split()))\r\ns=l.count(0)\r\nind=l.index(0)\r\nm=[]\r\nif s==n:\r\n for i in range(n):\r\n print(0,end=' ')\r\nelse:\r\n for i in range(n):\r\n if l[i]==0:\r\n m.append(i)\r\n c=0\r\n i=0\r\n while c!=s-1:\r\n while(abs(m[c]-i)<abs(m[c+1]-i)) and i<n:\r\n print(abs(m[c]-i),end=' ')\r\n i=i+1\r\n c=c+1\r\n for j in range(i,n):\r\n print(abs(m[c]-j),end=' ')\r\n \r\n ", "from typing import Tuple, List\r\n \r\n \r\ndef read_input() -> Tuple[List[int], int]:\r\n n = int(input())\r\n outdoors = [int(_) for _ in input().strip().split()]\r\n return outdoors, n\r\n \r\n \r\ndef get_next_zero(outdoors: List[int], n: int) -> str:\r\n result = [0] * len(outdoors)\r\n zero_list = [i for i in range(n) if outdoors[i] == 0]\r\n \r\n for house in range(0, zero_list[0] + 1):\r\n result[house] = zero_list[0] - house\r\n \r\n for pos in range(len(zero_list) - 1):\r\n zero_1, zero_2 = zero_list[pos], zero_list[pos + 1]\r\n for house in range(zero_1, zero_2):\r\n result[house] = min(house - zero_1, zero_2 - house)\r\n \r\n for house in range(zero_list[-1], len(outdoors)):\r\n result[house] = house - zero_list[-1]\r\n \r\n return ' '.join(str(_) for _ in result)\r\n \r\n \r\ndef main() -> None:\r\n outdoors, n = read_input()\r\n print(get_next_zero(outdoors, n))\r\n \r\n \r\nif __name__ == '__main__':\r\n main()", "import sys\r\n\r\ninf = 1 << 30\r\n\r\ndef solve():\r\n n = int(input())\r\n a = [inf if ai != '0' else 0 for ai in input().split()]\r\n\r\n for i in range(n):\r\n if a[i] == 0:\r\n for j in range(i - 1, -1, -1):\r\n if a[j] > i - j:\r\n a[j] = i - j\r\n else:\r\n break\r\n\r\n for j in range(i + 1, n):\r\n if a[j] > j - i:\r\n a[j] = j - i\r\n else:\r\n break\r\n\r\n print(*a)\r\n\r\nif __name__ == '__main__':\r\n solve()", "n = int(input())\r\na = list(map(int,input().split()))\r\ns = [i for i in range(n) if a[i]==0]\r\nc=0\r\nfor i in range(n):\r\n if c+1<len(s) and (abs(s[c]-i)>abs(s[c+1]-i)):\r\n c+=1\r\n print(abs(i-s[c]))", "n = int(input())\r\na = list(map(int, input().strip().split()))\r\nres = [-1] * n\r\nzero = []\r\nfor i in range(n):\r\n if a[i] == 0:\r\n zero.append(i)\r\n\r\np1 = zero[0]\r\np2 = zero[-1]\r\nc = 0\r\nfor i in range(p1+1):\r\n res[i] = abs(i - p1)\r\nfor i in range(n-1,p2-1,-1):\r\n res[i] = abs(i - p2)\r\nfor i in range(p1+1, p2):\r\n pr = zero[c]\r\n su = zero[c+1]\r\n res[i] = min(abs(i-pr), abs(i-su))\r\n if i+1 > su:\r\n c += 1\r\n pr, su = su, zero[c+1]\r\nprint(\" \".join(map(str, res)))", "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, arr):\n zeroind = -10 ** 6\n left = [zeroind] * n\n right = [zeroind] * n\n for i in range(n):\n if arr[i] == 0:\n left[i] = 0\n zeroind = i\n left[i] = i - zeroind\n zeroind = 10 ** 6\n for i in range(n-1, -1, -1):\n if arr[i] == 0:\n right[i] = 0\n zeroind = i\n right[i] = zeroind-i\n result = [min(left[i], right[i]) for i in range(n)]\n return joint(result)\n\n\ndef main():\n n = read()\n arr = readlines()\n print(solve(n, arr))\n\n\nmain()\n", "import sys\r\n\r\nn = int(sys.stdin.readline())\r\n\r\na = sys.stdin.readline().strip().split()\r\n\r\ndef findDistancesToZero(n,a):\r\n pos_zero_left = a.index('0')\r\n pos_zero_right = a.index('0')\r\n pos = 0\r\n positions = ''\r\n while pos<n:\r\n worked = False\r\n while pos<=pos_zero_right: \r\n print(str(min(abs(pos-pos_zero_left),abs(pos-pos_zero_right))),end=' ')\r\n pos+=1\r\n worked = True\r\n pos_zero_left = pos_zero_right\r\n try:\r\n pos_zero_right = a.index('0',pos) \r\n except:\r\n pos_zero_right = pos_zero_left\r\n False\r\n if worked:\r\n pos-=1\r\n if pos_zero_left == pos_zero_right: \r\n pos+=1\r\n while pos<n:\r\n print(str(abs(pos-pos_zero_left)),end=' ')\r\n pos+=1\r\n pos-=1\r\n pos+=1 \r\n return positions\r\n\r\nfindDistancesToZero(n,a)\r\n", "import bisect\r\nn=int(input());a=list(map(int,input().split()));ind=[];ans=[]\r\nfor j in range(n):\r\n if a[j]==0:ind.append(j)\r\nfor i in range(n):\r\n if a[i]!=0:\r\n p=bisect.bisect_left(ind,i)\r\n if p==0:ans.append(abs(ind[0]-i))\r\n elif p==len(ind):ans.append(abs(ind[-1]-i))\r\n else:ans.append(min(abs(ind[p]-i),abs(ind[p-1]-i)))\r\n else:ans.append(0)\r\nprint(*ans)", "from bisect import bisect_left as bl\r\nt=int(input())\r\na=list(map(int,input().split()))\r\nq,l=[],[0]*t\r\nfor i in range(t):\r\n if a[i]==0:\r\n q.append(i)\r\nr=len(q)\r\nfor i in range(t):\r\n if a[i]!=0:\r\n p=bl(q,i)\r\n if p==0:\r\n l[i]=q[0]-i\r\n elif p==r:\r\n l[i]=i-q[-1]\r\n else:\r\n l[i]=min(i-q[p-1],q[p]-i)\r\nprint(*l)", "n = int(input())\na, *l = (i for i, s in enumerate(input().split()) if s == '0')\nres = list(range(a, 0, -1))\nfor b in l:\n w = (b - a + 1) // 2\n res += range(w)\n res += range(b - a - w, 0, -1)\n a = b\nres += range(n - a)\nprint(' '.join(map(str, res)))\n", "n = int(input())\r\nA = list(map(int, input().split()))\r\nINF = 10**18\r\nL = [INF]*n\r\nfor i in range(n):\r\n if A[i] == 0:\r\n L[i] = 0\r\n else:\r\n if i-1 >= 0:\r\n L[i] = L[i-1]+1\r\nR = [INF]*n\r\nfor i in reversed(range(n)):\r\n if A[i] == 0:\r\n R[i] = 0\r\n else:\r\n if i+1 <= n-1:\r\n R[i] = R[i+1]+1\r\nans = [0]*n\r\nfor i in range(n):\r\n ans[i] = min(L[i], R[i])\r\nprint(*ans)\r\n", "def read_ints():\n return list(map(int, input().split()))\n\n\ndef zeros(d):\n inf = 10000000000\n l = -inf\n for i, x in enumerate(d, 1):\n if x == 0:\n yield l, i\n l = i\n yield l, inf\n\n\nif __name__ == '__main__':\n n = int(input())\n num = read_ints()\n\n print(*(min(i - a, b - i) for a, b in zeros(num) for i in range(max(a, 0) + 1, min(n, b) + 1)))\n", "import sys\r\n#import random\r\nfrom bisect import bisect_left as lb\r\nfrom collections import deque\r\n#sys.setrecursionlimit(10**8)\r\nfrom queue import PriorityQueue as pq\r\nfrom math import *\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\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\nmod = 10**9 + 7\r\n\r\nn = ii()\r\na = il()\r\n\r\npre = []\r\nx = float('inf')\r\n\r\nfor i in range (n) :\r\n if (a[i] == 0) :\r\n x = 0\r\n pre.append(x)\r\n x += 1\r\n continue\r\n else :\r\n pre.append(x)\r\n x += 1\r\n\r\nsuf = []\r\nx = float('inf')\r\n\r\nfor i in range (n-1,-1,-1) :\r\n if (a[i] == 0) :\r\n x = 0\r\n suf.append(x)\r\n x += 1\r\n continue\r\n else :\r\n suf.append(x)\r\n x += 1\r\n\r\nsuf.reverse()\r\n\r\nfor i in range (n) :\r\n print(min(pre[i],suf[i]),end=\" \")\r\n", "def print_distance(arr, n):\r\n # инициализирует массив размером n с 0\r\n\r\n ans = [0 for i in range(n)]\r\n\r\n # если первый элемент равен 0, то\r\n\r\n # расстояние будет 0\r\n\r\n if (arr[0] == 0):\r\n\r\n ans[0] = 0\r\n\r\n else:\r\n\r\n ans[0] = 10 ** 9 # если не 0, то инициализировать\r\n\r\n # с максимальным значением\r\n\r\n # ход в цикле от 1 до n и\r\n\r\n # сохранить расстояние слева\r\n\r\n for i in range(1, n):\r\n\r\n # добавить 1 к расстоянию от\r\n\r\n # Предыдущая\r\n\r\n ans[i] = ans[i - 1] + 1\r\n\r\n # если текущий элемент равен 0, то\r\n\r\n # расстояние будет 0\r\n\r\n if (arr[i] == 0):\r\n ans[i] = 0\r\n\r\n # если последний элемент равен нулю, то будет 0\r\n\r\n # иначе пусть ответ будет тем, что было найдено, когда\r\n\r\n # пройденная форма слева направо\r\n\r\n if (arr[n - 1] == 0):\r\n ans[n - 1] = 0\r\n\r\n # пройти справа налево и сохранить\r\n\r\n # минимальное расстояние, если найдено из\r\n\r\n # справа налево или слева направо\r\n\r\n for i in range(n - 2, -1, -1):\r\n\r\n # хранить минимальное расстояние от\r\n\r\n # слева направо или справа налево\r\n\r\n ans[i] = min(ans[i], ans[i + 1] + 1)\r\n\r\n # если это 0, то минимум будет\r\n\r\n # всегда будет 0\r\n\r\n if (arr[i] == 0):\r\n ans[i] = 0\r\n\r\n # распечатать массив ответов\r\n\r\n for i in ans:\r\n print(i, end=\" \")\r\n\r\n\r\nn = int(input())\r\na = [int(i) for i in input().split()]\r\nprint_distance(a, n)", "n=int(input())\r\nl=list(map(str,input().split()))\r\nz=[]\r\nfor i in range(n):\r\n if l[i]=='0':\r\n z.append(i)\r\nans=[]\r\nfor i in range(0,z[0]):\r\n ans.append(z[0]-i)\r\nfor i in range(len(z)-1):\r\n x=(z[i+1]-z[i])//2\r\n for j in range(z[i],z[i]+x+1):\r\n ans.append(j-z[i])\r\n for j in range(z[i]+x+1,z[i+1]):\r\n ans.append(z[i+1]-j)\r\nfor j in range(z[len(z)-1],n):\r\n ans.append(j-z[len(z)-1])\r\nprint(*ans)\r\n ", "n=int(input())\r\na=[]\r\na=list(map(int,input().split()))\r\n\r\ndist = pow(10,9)\r\nd=[dist]*len(a)\r\n\r\nfor i in range(len(a)):\r\n if(a[i]==0):\r\n d[i]=0\r\n dist = 0\r\n elif(dist < d[i]):\r\n dist+=1\r\n d[i] = dist\r\n\r\nfor i in range(len(a)-1,-1,-1):\r\n #print(dist)\r\n if(a[i]==0):\r\n d[i]=0\r\n dist = 0\r\n elif(dist + 1 < d[i]):\r\n dist+=1\r\n d[i] = dist\r\nfor i in d:\r\n print(str(i)+' ',end='')\r\n", "def main():\r\n n = int(input())\r\n a = list(map(int, input().split()))\r\n\r\n zero_i = None\r\n f = []\r\n for i, ai in enumerate(a):\r\n if ai == 0:\r\n zero_i = i\r\n\r\n if zero_i is None:\r\n f.append(n)\r\n else:\r\n f.append(i - zero_i)\r\n\r\n zero_i = None\r\n b = []\r\n for i, ai in enumerate(reversed(a)):\r\n if ai == 0:\r\n zero_i = i\r\n\r\n if zero_i is None:\r\n b.append(n)\r\n else:\r\n b.append(i - zero_i)\r\n\r\n res = (min(fi, bi) for fi, bi in zip(f, reversed(b)))\r\n for x in res:\r\n print(x, end=' ')\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "str_count = input()\r\n#str_count = '7'\r\ncount = int(str_count)\r\nstr_params = input()\r\n#str_params = '5 6 0 1 -2 3 4'\r\narr = [int(s) for s in str_params.split(' ')]\r\n\r\n\r\n\r\nlast_zero = -count\r\ndist = [0 for x in range(count)]\r\nfor i in range(count):\r\n\tif arr[i]==0:\r\n\t\tfor j in range((max(last_zero+1, -i)+i)//2, i):\r\n\t\t\tdist[j] = i-j\r\n\t\tlast_zero = i\r\n\telse:\r\n\t\tdist[i] = i-last_zero\r\nprint (' '.join(map(str,dist)))", "n = int(input())\r\narr = list(map(int,input().split()))\r\nans = [-1 for i in range(n)]\r\nind = []\r\nfor i in range(n):\r\n if arr[i]==0:\r\n ind.append(i)\r\nd = 0\r\nfor i in range(n):\r\n if d+1 < len(ind) and (abs(ind[d]-i) > abs(ind[d+1]-i)):\r\n d += 1\r\n print(abs(i-ind[d]),end=' ')\r\n", "import io,os\r\ninput=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\nri=lambda: int(input())\r\nrl=lambda: list(map(int,input().split()))\r\nrs=lambda: input().decode().rstrip('\\n\\r')\r\nfrom collections import deque as dq\r\ninf=float(\"inf\")\r\nmod=10**9 + 7\r\nCases=1#ri()\r\nfor Case in range(Cases):\r\n zeros=[-inf]\r\n n=ri()\r\n a=rl()\r\n for i in range(n):\r\n if a[i]==0:\r\n zeros.append(i)\r\n zeros.append(inf)\r\n nowz=0;nextz=1\r\n for i in range(n):\r\n if i==zeros[nextz]:\r\n nowz,nextz=nextz,nextz+1\r\n print(min(abs(zeros[nowz]-i),abs(zeros[nextz]-i)),end=' ')\r\n\r\n\r\n", "n=int(input())\r\na=[s for s in input().split()]\r\nd=[n]*n\r\nfor i in range(n):\r\n if a[i]=='0':\r\n d[i]=0\r\n j=i-1\r\n k=0\r\n while j>=0 and a[j]!='0':\r\n k+=1\r\n if k<d[j]:\r\n d[j]=k\r\n j-=1\r\n j=i+1\r\n k=0\r\n while j<n and a[j]!='0':\r\n k+=1\r\n if k<d[j]:\r\n d[j]=k\r\n j+=1\r\nprint(' '.join([str(s) for s in d]))", "import sys\n\n\n# пропускает пробелы\n# возвращает первый непробел или пустую строку если файл кончился\ndef skip_spaces():\n c = ' '\n # выйти если файл кончился или прочитан neпробел\n while c.isspace():\n c = sys.stdin.read(1)\n return c\n\n\n# пропускает непробелы\n# возвращает первый пробел или пустую строку если файл кончился\ndef skip_nonspaces():\n c = '_' # или любой непробел\n # выйти если файл кончился или прочитан пробел\n while c != '' and not c.isspace():\n c = sys.stdin.read(1)\n return c\n\n\n# читает числа из файла, выдаёт флаги вида \"это ноль\"\n# по числу прочитанных чисел\ndef read_zeros():\n while True:\n # пропустить пробельные символы\n c = skip_spaces()\n if c == '': # признак конца файла\n break\n\n # ноль - единственное число начинающееся с символа '0'\n yield c == '0'\n\n # пропустить все символы до пробела или конца файла\n if skip_nonspaces() == '': # признак конца файла\n break\n\n\ndef dists():\n first = True\n k = 0\n for z in read_zeros():\n if z:\n if first:\n yield from range(k, 0, -1) # первый спуск\n first = False\n else:\n h = k // 2\n yield from range(h + 1) # подъём на холм\n yield from range(k - h - 1, 0, -1) # спуск с холма\n k = 0\n k += 1\n yield from range(k) # последний подъём\n\n\ndef main():\n # пропустить n\n skip_spaces()\n skip_nonspaces()\n\n first = True\n for d in dists():\n if first:\n first = False\n print(d, end='')\n else:\n print('', d, end='')\n print()\n\n\nmain()\n", "INF = 10000000\r\n\r\ndef main():\r\n\tn = int(input())\r\n\ta = input().split()\r\n\tb = [INF for x in range(n)]\r\n\tc = [INF for x in range(n)]\r\n\ttmpb = -INF\r\n\ttmpc = -INF\r\n\tfor i in range(n):\r\n\t\ts = int(a[i])\r\n\t\tif s == 0:\r\n\t\t\ttmpb = i\r\n\t\t\tb[i] = 0\r\n\t\telse :\r\n\t\t\tb[i] = i-tmpb\r\n\ta = list(reversed(a))\r\n\tfor i in range(n):\r\n\t\ts = int(a[i])\r\n\t\tif s == 0:\r\n\t\t\ttmpc = i\r\n\t\t\tc[i] = 0\r\n\t\telse :\r\n\t\t\tc[i] = i-tmpc\r\n\tans = \"\"\r\n\tfor i in range(n):\r\n\t\tif(b[i] < c[n-1-i]):\r\n\t\t\tans += str(b[i]) + \" \"\r\n\t\telse :\r\n\t\t\tans += str(c[n-1-i]) + \" \"\r\n\tprint(ans)\r\n\t\t\r\n\t\t\r\n\r\n\r\n\r\nmain()\r\n", "n = int(input())\n\nl = list(map(int, input().split()))\nans = [400001 for i in range(n)]\nzs=[]\nfor x in range(n):\n if l[x]==0:\n zs.append(x)\n ans[x]=0\n\nfor i in zs:\n lp=i-1\n rp=i+1\n cntL=1\n cntR=1\n while lp!=-1:\n \n if ans[lp]<=cntL:\n break\n ans[lp]=cntL\n cntL+=1\n lp-=1\n while rp!=n:\n if ans[rp]<=cntR:\n break\n ans[rp]=cntR\n cntR+=1\n rp+=1\n \nprint(' '.join([str(x) for x in ans]))\n", "##n = int(input())\r\n##a = list(map(int, input().split()))\r\n##print(' '.join(map(str, res)))\r\n\r\nimport bisect\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\n\r\nfw = []\r\nfor i in range(n):\r\n if a[i] == 0:\r\n fw.append(i)\r\n\r\nd = [1<<30 for i in range(n)]\r\nfor i in range(n):\r\n p = bisect.bisect_left(fw, i) \r\n if p < len(fw):\r\n d[i] = min(d[i], fw[p]-i)\r\n p = bisect.bisect_right(fw, i)\r\n if p > 0:\r\n p -= 1\r\n d[i] = min(d[i], i-fw[p])\r\nprint(' '.join(map(str, d)))", "#!/usr/bin/env python3\n\nMAX = 2*10**5 + 1\n\nn = int(input().strip())\nais = list(map(int, input().strip().split()))\n\ndleft = [MAX for _ in range(n)]\ndright = [MAX for _ in range(n)]\n\nfor i in range(n):\n\tif ais[i] == 0:\n\t\tdleft[i] = 0\n\telse:\n\t\tdleft[i] = MAX if i == 0 else dleft[i - 1] + 1\n\nfor i in reversed(range(n)):\n\tif ais[i] == 0:\n\t\tdright[i] = 0\n\telse:\n\t\tdright[i] = MAX if i == n - 1 else dright[i + 1] + 1\n\nd = [min(dl, dr) for dl, dr in zip(dleft, dright)]\nprint (' '.join(map(str, d)))\n", "def read_input():\r\n street_length = int(input())\r\n house_numbers = list(map(int, input().strip().split()))\r\n return street_length, house_numbers\r\n\r\n\r\ndef nearest_zero(street_length, house_numbers):\r\n counter = len(house_numbers) if house_numbers[0] != 0 else 0\r\n for i in range(0, len(house_numbers)):\r\n if house_numbers[i] == 0:\r\n counter = 0\r\n else:\r\n counter += 1\r\n house_numbers[i] = counter\r\n\r\n for i in range(len(house_numbers)-1, -1, -1):\r\n if house_numbers[i] == 0:\r\n counter = 0\r\n else:\r\n counter += 1\r\n house_numbers[i] = min(counter, house_numbers[i])\r\n\r\n return ' '.join(map(str, house_numbers))\r\n\r\n\r\ndef main():\r\n house_numbers, street_length = read_input()\r\n print(nearest_zero(house_numbers, street_length))\r\n\r\n\r\nif __name__ == '__main__':\r\n main()", "n=int(input())\r\na=[bool(int(e)) for e in input().split()]\r\nd=[n]*n\r\nI=-n\r\nfor i in range(n):\r\n if a[i]:\r\n d[i]=min(d[i],abs(i-I))\r\n else:\r\n d[i]=0\r\n I=i\r\nI=2*n\r\nfor i in range(n-1,-1,-1):\r\n if a[i]:\r\n d[i]=min(d[i],abs(i-I))\r\n else:\r\n I=i\r\nprint(*d)", "#!/usr/bin/env python3\r\n\r\ndef main():\r\n try:\r\n while True:\r\n n = int(input())\r\n a = list(map(int, input().split()))\r\n b = [0] * n\r\n last = 400000\r\n for i in range(n - 1, -1, -1):\r\n if a[i] == 0:\r\n last = i\r\n b[i] = last - i\r\n\r\n last = -400000\r\n for i in range(n):\r\n if a[i] == 0:\r\n last = i\r\n print(min(i - last, b[i]), end=' ')\r\n print()\r\n\r\n except EOFError:\r\n pass\r\n\r\nmain()\r\n", "n = int(input())\r\na = [int(i) for i in input().split()]\r\nj = -1\r\nmn = [1000000000] * n\r\n\r\nfor i in range(n):\r\n if a[i] == 0:\r\n mn[i] = 0\r\n continue\r\n if j == -1 or a[i - 1] == 0:\r\n j = i\r\n while j < n and a[j] != 0:\r\n j += 1\r\n if j == n:\r\n break\r\n mn[i] = j - i\r\n else:\r\n mn[i] = j - i\r\n\r\na = a[::-1]\r\nj = -1\r\n\r\nfor i in range(n):\r\n if a[i] == 0:\r\n continue\r\n if j == -1 or a[i - 1] == 0:\r\n j = i\r\n while j < n and a[j] != 0:\r\n j += 1\r\n if j == n:\r\n break\r\n mn[n - i - 1] = min(mn[n - i - 1], j - i)\r\n else:\r\n mn[n - i - 1] = min(mn[n - i - 1], j - i)\r\n\r\nprint(*mn)\r\n", "import math\r\n\r\n\r\ndef countDistance(outList, firstZero, secondZero):\r\n if secondZero != -1 and firstZero != -1:\r\n average = int(math.ceil((firstZero + secondZero) / 2))\r\n for i in range(firstZero, average, 1):\r\n outList[i] = i-firstZero\r\n for i in range(average, secondZero+1, 1):\r\n outList[i] = secondZero - i\r\n if secondZero == -1:\r\n for i in range(firstZero, len(outList), 1):\r\n outList[i] = i - firstZero\r\n if firstZero == -1:\r\n for i in range(0, secondZero+1, 1):\r\n outList[i] = secondZero - i\r\n\r\ninputList = []\r\noutputList = []\r\nsize = int(input())\r\ninputList = input().split()\r\nfor i in range(0, size, 1):\r\n inputList[i] = int(inputList[i])\r\n outputList.append(-1)\r\nlastZero = -1\r\nfor i in range(0, size, 1):\r\n if inputList[i] == 0:\r\n if lastZero != -1:\r\n countDistance(outputList, lastZero, i)\r\n lastZero = i\r\n else:\r\n lastZero = i\r\n countDistance(outputList, -1, lastZero)\r\nif lastZero != size-1:\r\n countDistance(outputList, lastZero, -1)\r\nfor elem in outputList:\r\n print(elem, end=\" \")", "#Bhargey Mehta (Sophomore)\r\n#DA-IICT, Gandhinagar\r\nimport sys, math, queue\r\n#sys.stdin = open(\"input.txt\", \"r\")\r\nMOD = 10**9+7\r\nsys.setrecursionlimit(1000000)\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nl = [None for i in range(n)]\r\nr = [None for i in range(n)]\r\nfor i in range(n):\r\n if a[i] == 0:\r\n l[i] = i\r\n elif l[i-1] is not None:\r\n l[i] = l[i-1]\r\n if a[-1-i] == 0:\r\n r[-1-i] = n-1-i\r\n elif r[-1-i+1] is not None:\r\n r[-1-i] = r[-1-i+1]\r\n\r\na = [-1 for i in range(n)]\r\nfor i in range(n):\r\n if l[i] is None:\r\n a[i] = r[i]-i\r\n elif r[i] is None:\r\n a[i] = i-l[i]\r\n else:\r\n a[i] = min(r[i]-i, i-l[i])\r\nprint(*a)", "def Posicion(L):\r\n i = 1\r\n A = L\r\n for k in range (len(L)):\r\n if L[k]!=0:\r\n A[k]=i\r\n i +=1\r\n else:\r\n i=1\r\n return A \r\ndef SepararDerecha(L):\r\n B=[]\r\n Mayork = 0\r\n for k in range (len(L)):\r\n if L[k]==0:\r\n if k > Mayork:\r\n Mayork = k\r\n c = Mayork+1\r\n while c < len(L):\r\n B.append(L[c])\r\n c += 1\r\n return B\r\ndef SepararIzquierda(L):\r\n B = []\r\n k = 0\r\n while L[k]!=0:\r\n B.append(L[k])\r\n k += 1\r\n return B\r\ndef Invertir(L):\r\n B =[]\r\n k=len(L)-1\r\n while k>=0:\r\n B.append(L[k])\r\n k -=1\r\n return B \r\nN = int(input())\r\nL = input()\r\nL = L.split()\r\nA = []\r\nfor k in range (len(L)):\r\n A.append(int(L[k]))\r\nPI = SepararIzquierda(A)\r\nz = len(PI)\r\nPIII = []\r\nfor k in range (len(PI)):\r\n PIII.append(z)\r\n z-=1\r\npizquierda = len(PIII)\r\nPD = SepararDerecha(A)\r\nPD = Posicion(PD)\r\npderecha = len(PD)\r\nD = []\r\nfor k in range (pizquierda,len(A)-pderecha):\r\n D.append(A[k])\r\nAI = Posicion(D)\r\nAD = Invertir(D)\r\nAD = Posicion(AD)\r\nAD = Invertir(AD)\r\nB = []\r\nfor k in range (len(AD)):\r\n if AD[k] < AI[k]:\r\n B.append(AD[k])\r\n else:\r\n B.append(AI[k])\r\nC =[]\r\nfor k in range (len(PIII)):\r\n C.append(PIII[k])\r\nfor k in range (len(B)):\r\n C.append(B[k])\r\nfor k in range (len(PD)):\r\n C.append(PD[k])\r\nRespuesta = str(C[0])\r\nfor k in range (1,len(C)):\r\n Respuesta += ' ' + str(C[k])\r\nprint(Respuesta)\r\n", "n = int(input())\r\nlist = [None] * n\r\ns = input().split();\r\nfor i in range(0,n):\r\n\tlist[i] = int(s[i])\r\na = [100100100] * n\r\nlast = -1\r\nfor i in range(0,n):\r\n\tif list[i] == 0:\r\n\t\tlast = i\r\n\tif last > -1:\r\n\t\ta[i] = min(a[i], abs(i-last))\r\nlast = -1\r\nfor i in range(n-1, -1, -1):\r\n\tif list[i] == 0:\r\n\t\tlast = i\r\n\tif last > -1:\r\n\t\ta[i] = min(a[i], abs(i-last))\r\nfor i in range(0,n):\r\n\tprint(a[i], end=\" \")", "n = int(input())\r\nl = list(map(int,input().split()))\r\nans = [n] * n\r\nzero_ind = -1\r\n\r\nfor i in range(n):\r\n if l[i] == 0 :\r\n zero_ind = i\r\n ans[i] = 0\r\n\r\n elif zero_ind >= 0 :\r\n ans[i] = abs(i-zero_ind)\r\n\r\n#print(ans)\r\nzero_ind = -1\r\nfor i in range(n-1 , -1 , -1 ):\r\n if l[i] == 0 :\r\n zero_ind = i\r\n\r\n elif zero_ind >= 0 and ans[i] > abs(zero_ind - i):\r\n ans[i] = zero_ind - i\r\n\r\nprint(*ans)", "n = int(input())\r\ns = input().split(' ')\r\nv = []\r\nz = []\r\nfor a in s:\r\n v.append(int(a))\r\n if v[len(v)-1] == 0:\r\n z.append(len(v)-1);\r\nz.append(9999999999999)\r\n\r\nind = 0\r\nfor i in range(0, len(v)):\r\n d1 = abs(i - z[ind])\r\n d2 = abs(i - z[ind+1]);\r\n print(d1 if d1 < d2 else d2, end=' ')\r\n if d2 < d1:\r\n ind+=1", "from operator import le\nfrom re import M\n\n\nn = int(input())\n\narr = [int(x) for x in input().split()]\n\nleft = [float('inf')] * n\nright = [float('inf')] * n\n\nif arr[0] == 0:\n left[0] = 0\nfor i in range(1, n):\n if arr[i] == 0:\n left[i] = 0\n else:\n left[i] = left[i-1]+1\n\nif arr[-1] == 0:\n right[-1] = 0\nfor i in range(n-2, -1, -1):\n if arr[i] == 0:\n right[i] = 0\n else:\n right[i] = right[i+1]+1\n\nfor i in range(n):\n print(min(left[i], right[i]), end=' ')\nprint()\n", "n=int(input())\r\na=list(map(int,input().split()))\r\ndict={}\r\ndict[0]=[]\r\nfor i in range(len(a)):\r\n if(a[i]==0):\r\n dict[a[i]].append(i)\r\narray=dict[0]\r\nc=0\r\nfor k in range(len(a)):\r\n if (c == len(array)-1):\r\n print(abs(array[c]- k), end=\" \")\r\n elif(abs(array[c]-k) <= abs(array[c+1]-k)):\r\n print(abs(array[c]-k),end=\" \")\r\n else:\r\n print(abs(array[c + 1] - k),end=\" \")\r\n c+=1", "from collections import deque\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\ndef bfs():\r\n q = deque()\r\n dist = [-1] * n\r\n for i in range(n):\r\n if a[i] == 0:\r\n q.append(i)\r\n dist[i] = 0\r\n while q:\r\n i = q.popleft()\r\n di = dist[i]\r\n for j in G[i]:\r\n if dist[j] == -1:\r\n dist[j] = di + 1\r\n q.append(j)\r\n return dist\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nG = [[] for _ in range(n)]\r\nfor i in range(n - 1):\r\n G[i].append(i + 1)\r\n G[i + 1].append(i)\r\nd = bfs()\r\nprint(*d)", "N = int(input())\r\nA = list(map(int, input().split()))\r\nans = [1e18] * N\r\nfor i in range(N):\r\n\tif A[i] != 0:\r\n\t\tcontinue\r\n\tans[i] = 0\r\n\tj = i - 1\r\n\twhile j >= 0 and A[j] != 0:\r\n\t\tans[j] = min(ans[j], i - j)\r\n\t\tj -= 1\r\n\tj = i + 1\r\n\twhile j < N and A[j] != 0:\r\n\t\tans[j] = min(ans[j], j - i)\r\n\t\tj += 1\r\nfor i in range(N):\r\n\tprint(ans[i], end = ' ')\r\nprint()", "sums = lambda n: int(n * (n + 1) / 2) # sum from 1 to n\r\ndef im(): return map(int, input().split())\r\ndef il(): return list(map(int, input().split()))\r\ndef ii(): return int(input())\r\n\r\n\r\ndef solve():\r\n n = ii()\r\n ls = il()\r\n ls2 = [10**9]*n\r\n\r\n index = ls.index(0)\r\n\r\n counter = 0\r\n for i in range(index, n):\r\n if ls[i] == 0:\r\n ls2[i] = 0\r\n counter = 0\r\n else:\r\n ls2[i] = counter\r\n \r\n counter+=1\r\n\r\n index = ls[::-1].index(0)\r\n index = n-index-1\r\n\r\n counter = 0\r\n for i in range(index, -1, -1):\r\n if ls[i] == 0:\r\n ls2[i] = 0\r\n counter = 0\r\n else:\r\n ls2[i] = min(ls2[i], counter)\r\n \r\n counter+=1\r\n\r\n \r\n\r\n return ls2\r\n\r\n\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n #for _ in range(ii()):\r\n ls = solve()\r\n for i in ls:\r\n print(i, end=' ')\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "i1=int(input())\r\nar=list(map(str,input().split()))\r\nflag=False\r\nini=0\r\nfor i in range(len(ar)):\r\n if(ar[i]=='0' and not(flag)):\r\n flag=True\r\n ini=i\r\n for m in range(i+1):\r\n print(i-m,end=' ') \r\n elif(ar[i]=='0' and flag):\r\n if((i-ini-1)%2==0):\r\n for m in range(1,int((i-ini-1)/2)+1):\r\n print(m,end=' ')\r\n for m in range(0,int((i-ini-1)/2)+1):\r\n print(int((i-ini-1)/2)-m,end=' ')\r\n else:\r\n for m in range(1,int((i-ini-1)/2)+1):\r\n print(m,end=' ')\r\n for m in range(0,int((i-ini-1)/2)+2):\r\n print(int((i-ini-1)/2)+1-m,end=' ')\r\n ini=i\r\n elif(i==len(ar)-1 and i!=0):\r\n for m in range(1,i-ini+1):\r\n print(m,end=' ')\r\n \r\n ", "n=int(input())\r\na=list(map(int,input().split()))\r\nL,R=[0]*n,[0]*n\r\nm=-2*10**9\r\nfor i in range(n):\r\n if a[i]==0:\r\n L[i],m=0,i\r\n else:\r\n L[i]=i-m\r\nm=2*10**9\r\nfor i in range(n-1,-1,-1):\r\n if a[i]==0:\r\n R[i],m=0,i\r\n else:\r\n R[i]=m-i\r\ns=\"\"\r\nfor i in range(n):\r\n s+=str(min(R[i],L[i]))+' '\r\nprint(s)\r\n", "n = int(input())\r\narr = [int(x) for x in input().split()]\r\nINF = 1 << 30\r\n\r\ni = 0\r\nlast_zero = -INF\r\nnearest_zero = [INF] * n\r\nwhile i < n:\r\n if arr[i] == 0:\r\n last_zero = i\r\n nearest_zero[i] = 0\r\n else:\r\n nearest_zero[i] = i - last_zero\r\n i += 1\r\n\r\ni = n - 1\r\nlast_zero = INF\r\nwhile i >= 0:\r\n if arr[i] == 0:\r\n last_zero = i\r\n else:\r\n nearest_zero[i] = min(nearest_zero[i], last_zero - i)\r\n i -= 1\r\n\r\nprint(\" \".join(map(str, nearest_zero)))\r\n", "def solve() -> None:\r\n\r\n n = int(input())\r\n a = list(map(int, input().split()))\r\n\r\n d = [n] * n\r\n\r\n zero = -n\r\n\r\n for i in range(n):\r\n if a[i] == 0:\r\n zero = i\r\n d[i] = min(i - zero, d[i])\r\n\r\n zero = n * 2\r\n\r\n for i in range(n - 1, -1, -1):\r\n if a[i] == 0:\r\n zero = i\r\n d[i] = min(zero - i, d[i])\r\n\r\n print(\" \".join(str(x) for x in d), flush=False)\r\n\r\nsolve()\r\n", "import math\nn = int(input())\ndata = []\ndata = list(map(int,input().split()))\nl = [0] * n\nr = [0] * n\np = 2 * n\np1 = 2 * n\ns = ''\nfor i in range(n):\n l[i] = p\n if data[i] == 0:\n p = i\n \nfor i in range(n - 1,-1, -1):\n r[i] = p1\n if data[i] == 0:\n p1 = i \n\nfor i in range(n): \n if data[i] != 0:\n print(min(abs((l[i] - i)),abs((r[i] - i))), end = ' ')\n else:\n print(0, end = ' ')\n \n\n ", "import sys\r\nimport string\r\nfrom heapq import *\r\nfrom bisect import *\r\n\r\nfrom collections import Counter, defaultdict\r\nfrom math import fsum, sqrt, gcd, ceil, factorial\r\nfrom operator import *\r\nfrom itertools import accumulate\r\n\r\ninf = float(\"inf\")\r\n# input = sys.stdin.readline\r\nflush = lambda: sys.stdout.flush\r\ncomb = lambda x, y: (factorial(x) // factorial(y)) // factorial(x - y)\r\nen = lambda x: list(enumerate(x))\r\n\r\n\r\n# inputs\r\n# ip = lambda : input().rstrip()\r\nip = lambda: input()\r\nii = lambda: int(input())\r\nr = lambda: map(int, input().split())\r\nrr = lambda: list(r())\r\n\r\nn = ii()\r\narr = rr()\r\n\r\nbrr = [i for i, j in en(arr) if not j]\r\nans = [0] * n\r\nx = len(brr) - 1\r\nfor i in range(n):\r\n if not arr[i]:\r\n continue\r\n a = bisect(brr, i)\r\n a = min(a, x)\r\n ans[i] = abs(brr[a] - i)\r\n a = max(a - 1, 0)\r\n ans[i] = min(ans[i], abs(brr[a] - i))\r\n\r\n\r\nprint(*ans)", "n = int(input())\r\nvalores = [int(e) for e in input().split(' ')]\r\n\r\nd_i = 1000000\r\ndistancias = [0 for i in range(n)]\r\n\r\n\r\nfor i in range(len(distancias)):\r\n d_i += 1\r\n distancias[i] = d_i\r\n if valores[i] == 0:\r\n distancias[i] = 0\r\n d_i = 0\r\n\r\n\r\nteste = False\r\nfor i in range(len(valores)-1, -1, -1):\r\n if valores[i] == 0:\r\n d_i = 0\r\n teste = True\r\n if teste: \r\n if d_i < distancias[i]:\r\n distancias[i] = d_i\r\n d_i += 1\r\n\r\n[print(e, end=' ') for e in distancias]\r\n\r\n\r\n", "n = int(input())\r\nnumIn = input().split()\r\n\r\nanswer = \"\"\r\nzeros = [len(numIn),]\r\nfor i in range(n):\r\n numIn[i] = int(numIn[i])\r\n if numIn[i] == 0:\r\n zeros.append(i)\r\nzeros.append(-1)\r\n\r\nzeros_cnt = 0\r\ncurrent_zero = zeros[zeros_cnt]\r\nnext_zero = zeros[zeros_cnt+1]\r\nfor i in range(n):\r\n current_val = numIn[i]\r\n if current_val == 0:\r\n zeros_cnt += 1\r\n current_zero = zeros[zeros_cnt]\r\n next_zero = zeros[zeros_cnt + 1]\r\n answer +=\"0 \"\r\n else:\r\n current_val = min(abs(current_zero-i),abs(next_zero-i))\r\n answer += str(current_val)+\" \"\r\n\r\nprint(answer)", "n = int(input())\r\na = list(map(int, input().split()))\r\nINF = float('inf')\r\ntmp = INF\r\nb = [INF] * n\r\nfor i in range(n):\r\n if a[i] == 0:\r\n tmp = 0\r\n b[i] = tmp\r\n tmp += 1\r\n\r\ntmp = INF\r\nfor i in range(n - 1, -1, -1):\r\n if a[i] == 0:\r\n tmp = 0\r\n b[i] = min(b[i], tmp)\r\n tmp += 1\r\n\r\nprint(*b)\r\n", "N = int( input() )\r\nA = list( map( int, input().split() ) )\r\nans = [ N for i in range( N ) ]\r\nprev = -N\r\nfor i in range( N ):\r\n if A[ i ] == 0:\r\n prev = i\r\n ans[ i ] = i - prev\r\nprev = N + N\r\nfor i in range( N - 1, -1, -1 ):\r\n if A[ i ] == 0:\r\n prev = i\r\n ans[ i ] = min( ans[ i ], prev - i )\r\nprint( *ans )\r\n", "i = int(input())\r\nl = list(map(int,input().split()))\r\np = -999999\r\nn = []\r\nfor x in range(i):\r\n if l[x] == 0: p=x\r\n n.append(x-p)\r\nn = n[::-1]\r\np = -9999999\r\nans = []\r\nfor x in range(i):\r\n if n[x] == 0: p=x\r\n ans.append(min(x-p,n[x]))\r\nprint(*ans[::-1])", "n = int(input())\r\ns = [int(i) for i in input().split()]\r\nd = [10**9+7 for i in range(n)]\r\ncnt = 0\r\n\r\nfor i in range(n):\r\n\tif s[i]==0:\r\n\t\td[i]=0\r\n\t\tcnt = 1\r\n\telif cnt:\r\n\t\td[i]=cnt\r\n\t\tcnt+=1\r\n\r\ncnt = 0\r\nfor i in range(n-1,-1,-1):\r\n\tif s[i]==0:\r\n\t\tcnt = 1\r\n\telif cnt:\r\n\t\tif d[i]>=cnt:\r\n\t\t\td[i]=cnt\r\n\t\tcnt+=1\r\n\r\n\r\nprint(*d)", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\ninf = 10 ** 9\r\nans = [inf] * n\r\nl = inf\r\nfor i in range(n):\r\n if not a[i]:\r\n l = 0\r\n \r\n ans[i] = min(ans[i], l)\r\n l += 1\r\n\r\nl = inf\r\nfor i in range(n - 1, -1, -1):\r\n if not a[i]:\r\n l = 0\r\n \r\n ans[i] = min(ans[i], l)\r\n l += 1\r\n \r\nprint(' '.join(map(str, ans)))", "import sys\r\n\r\nn = int(input())\r\na = [-1] + list(map(int, input().split())) + [-1]\r\ninf = 10**9\r\nleft, right = [inf]*(n+2), [inf]*(n+2)\r\n\r\nfor i in range(1, n+1):\r\n left[i] = 0 if a[i] == 0 else left[i-1]+1\r\nfor i in range(n, 0, -1):\r\n right[i] = 0 if a[i] == 0 else right[i+1]+1\r\n\r\nprint(*(min(l, r) for l, r in zip(left[1:-1], right[1:-1])))\r\n", "import bisect\r\ninput()\r\nnums = [int(x) for x in input().split()]\r\nzeroes = []\r\nfor idx, value in enumerate(nums):\r\n if value == 0:\r\n zeroes.append(idx)\r\nfor idx, i in enumerate(nums):\r\n idxval = bisect.bisect_left(zeroes, idx)\r\n if len(zeroes) > idxval > 0:\r\n print(min([abs(idx-zeroes[idxval-1]), abs(idx-zeroes[idxval])]), end = \" \")\r\n elif idxval == 0:\r\n print(abs(idx-zeroes[idxval]), end = \" \")\r\n elif idxval == len(zeroes):\r\n print(abs(idx-zeroes[idxval-1]), end = \" \")", "inf = 10**10\r\ninput()\r\nnums = [int(x) for x in input().split()]\r\n\r\ndef run(ns):\r\n curr = inf\r\n res = []\r\n for num in ns:\r\n if num == 0:\r\n curr = 0\r\n res.append(curr)\r\n curr += 1\r\n return res\r\n\r\nfw = run(nums)\r\nrew = (run(reversed(nums)))[::-1]\r\n\r\nprint(' '.join(str(min(fw[i], rew[i])) for i in range(len(nums))))\r\n", "n=int(input())\r\na=list(map(int,input().split())) \r\ndis=0 \r\nl=[]\r\nfor i in range(n):\r\n if a[i]==0:\r\n dis=0\r\n l.append(i)\r\n else:\r\n dis+=1\r\n a[i]=dis\r\n\r\ni=n-1\r\ndis=0\r\nwhile i>=0:\r\n if i<=l[-1] and i>=l[0]:\r\n \r\n if a[i]==0:\r\n dis=0\r\n else:\r\n dis+=1\r\n a[i]=min(a[i],dis)\r\n elif i<=l[0]:\r\n if a[i]==0:\r\n dis=0\r\n else:\r\n dis+=1\r\n a[i]=dis\r\n\r\n \r\n \r\n i-=1\r\nprint(*a)\r\n \r\n \r\n \r\n ", "n = int(input())\nl = list(map(int, input().split()))\narr = []\nfor i in range(n):\n if l[i] == 0: arr.append(i)\nfor i in range(arr[0], 0, -1):\n print(i, end = \" \")\nprint(0, end = \" \")\nfor i in range(1, len(arr)):\n temp = arr[i] - arr[i - 1]\n t1 = temp // 2\n for j in range(1, t1 + 1): print(j, end = \" \")\n if temp % 2 == 0: t1 += -1\n for j in range(t1, 0, -1): print(j, end = \" \")\n print(0, end = \" \")\nfor i in range(1, n - 1 - arr[len(arr) - 1] + 1):\n print(i, end = \" \")\n \t\t \t\t\t\t \t \t \t \t \t \t\t \t", "n=int(input())\r\na=list(map(int,input().split()))\r\nx=-10**9\r\nfor i in range(n):\r\n if a[i]==0:\r\n x=i\r\n a[i]=i-x\r\n\r\nx=10**9\r\nfor i in range(n-1,-1,-1):\r\n if a[i]==0:\r\n x=i\r\n a[i]=min(a[i],x-i)\r\n\r\nprint(*a)", "from math import *\r\nlength=int(input())\r\na=list(map(int,input().strip().split()))\r\np=[-inf]\r\nfor i in range(length):\r\n if a[i]==0:\r\n p.append(i)\r\np.append(inf)\r\ni=0\r\nj=1\r\nb=[0 for _ in range(length)]\r\nfor k in range(length):\r\n if k<p[j]:\r\n b[k]=min(k-p[i],p[j]-k)\r\n if k==p[j]:\r\n j+=1\r\n i+=1\r\nfor i in b:\r\n print(i,end=' ')\r\n", "def solve(n,a):\r\n prefix_dist = []\r\n suffix_dist = []\r\n\r\n INF = 1000000000\r\n\r\n prefix_dist.append(0 if a[0] == 0 else INF)\r\n for i in range(1,n):\r\n if a[i] == 0:\r\n prefix_dist.append(0)\r\n continue\r\n\r\n prefix_dist.append(min(prefix_dist[i-1]+1, INF))\r\n\r\n suffix_dist.append(0 if a[n-1] == 0 else INF)\r\n for i in range(n-2,-1,-1):\r\n if a[i] == 0:\r\n suffix_dist.append(0)\r\n continue\r\n \r\n suffix_dist.append(min(suffix_dist[n-i-2]+1, INF))\r\n\r\n suffix_dist = list(reversed(suffix_dist))\r\n\r\n sol = []\r\n for i in range(n):\r\n sol.append(min(prefix_dist[i],suffix_dist[i]))\r\n \r\n return sol\r\n\r\n\r\n\r\ndef main():\r\n n = int(input())\r\n a = [int(x) for x in input().split(' ')]\r\n print(*solve(n,a))\r\n\r\nif __name__ == \"__main__\":\r\n main()", "n = int(input())\r\na, v, p = list(map(int, input().split())), [n] * n, -n\r\nfor i in range(n):\r\n if a[i] == 0:\r\n p = i\r\n v[i] = min(v[i], i - p)\r\np = 2 * n\r\nfor i in range(n - 1, -1, -1):\r\n if a[i] == 0:\r\n p = i\r\n v[i] = min(v[i], p - i)\r\nprint(' '.join(map(str, v)))", "from math import *\r\nn=int(input())\r\na=list(map(int,input().split()))\r\ns,l=[],[]\r\nf=-inf\r\nfor i in range(n):\r\n if(a[i]==0):\r\n f=i\r\n l.append(f)\r\nf=inf\r\nr=[]\r\nfor i in range(n-1,-1,-1):\r\n if(a[i]==0):\r\n f=i\r\n r.append(f)\r\nr=r[::-1]\r\nfor i in range(n):\r\n m=min(i-l[i],r[i]-i)\r\n s.append(m)\r\nprint(*s)\r\n", "a=int(input())\r\nz=[]+[]\r\nfor i,j in zip(range(a),map(int,input().split())):\r\n if (not(j)):z+=[i]\r\nfor i in range(len(z)):\r\n if i==0:\r\n for j in range(z[0]):\r\n print(z[0]-j,end=\" \")\r\n if i!=len(z)-1:\r\n for j in range(z[i],z[i+1]):\r\n print(min(j-z[i],z[i+1]-j),end=\" \")\r\n if i==len(z)-1:\r\n for j in range(z[i],a):\r\n print(j-z[i],end=\" \")\r\n", "n= int( input())\na = input().split()\nd = [0 for x in range(n)]\ndist = n\nfor i in range(n):\n if a[i] == '0':\n dist = 0\n j = i\n while d[j] >= dist and j >= 0:\n d[j] = dist\n dist += 1\n j -= 1\n dist = 0\n else:\n dist += 1\n d[i] = dist\n\n\n\nprint(\" \".join([str(i) for i in d]))", "n = int(input())\na = list(map(int, input().split()))\n\ndist = [n] * n\nd = n\nfor i in range(n):\n if a[i] == 0:\n d = 0\n else:\n d += 1\n dist[i] = d\nd = n\nfor i in reversed(range(n)):\n if a[i] == 0:\n d = 0\n else:\n d += 1\n if d is not None:\n dist[i] = min(dist[i], d)\nprint(' '.join(map(str, dist)))\n", "import math\r\nimport string\r\n\r\n\r\n\r\ndef main_function():\r\n zeros = []\r\n n = int(input())\r\n a = [int(u) for u in input().split(\" \")]\r\n for i in range(len(a)):\r\n if a[i] == 0:\r\n zeros.append(i)\r\n start_index_for_zeros = 0\r\n collector = []\r\n for i in range(len(a)):\r\n #if a[i] != 0:\r\n current_index = zeros[start_index_for_zeros]\r\n if start_index_for_zeros == len(zeros) - 1:\r\n collector.append(abs(current_index - i))\r\n else:\r\n next_val = zeros[start_index_for_zeros + 1]\r\n distance_1 = abs(current_index - i)\r\n distance_2 = abs(next_val - i)\r\n if distance_1 < distance_2:\r\n collector.append(distance_1)\r\n else:\r\n collector.append(distance_2)\r\n start_index_for_zeros += 1\r\n print(\" \".join([str(i) for i in collector]))\r\n\r\n\r\nmain_function()", "n = int(input())\r\na = list(map(int,input().split()))\r\narr1 = []\r\nfor i in range(n):\r\n if a[i] == 0:\r\n arr1.append(i)\r\nl,m = 0,0\r\nlen1 = len(arr1)\r\n# print(arr1)\r\narr2 = []\r\nwhile l<n:\r\n if m == len1:\r\n arr2.append((abs(l-arr1[m-1])))\r\n l+=1\r\n elif l<=arr1[m]:\r\n if m!=0:\r\n b = min(l - arr1[m - 1], arr1[m] - l)\r\n arr2.append(b)\r\n l+=1\r\n else:\r\n k = arr1[m]-l\r\n arr2.append(k)\r\n l+=1\r\n else:\r\n m+=1\r\nprint(*arr2)", "#!/usr/bin/env python3\nfrom sys import stdin,stdout\n\ndef ri():\n return map(int, stdin.readline().split())\n#lines = stdin.readlines()\n\nn = int(input())\na = list(ri())\n\nfor i in range(n):\n if a[i] != 0:\n a[i] = -1\n\nfor i in range(n):\n if a[i] != 0:\n continue\n for j in range(i+1, n):\n if a[j] == 0:\n break\n if a[j] == -1 or a[j] > j-i:\n a[j] = j-i\n for j in range(i-1, -1, -1):\n if a[j] == 0:\n break\n if a[j] == -1 or a[j] > i-j:\n a[j] = i-j\n\nprint(\" \".join(map(str, a)))\n", "def zero(i):\r\n for j in range(i+1,n):\r\n if a[j] == 0:\r\n return j\r\n return -1\r\n\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nres = []\r\nzerol, zeror = 2 * 10**5 + 1, zero(-1)\r\nfor i in range(n):\r\n if a[i] != 0:\r\n res.append(min(abs(i-zeror), abs(i - zerol)))\r\n else:\r\n res.append(0)\r\n zerol, zeror = zeror, zero(i)\r\nprint(' '.join(map(str, res)))", "n = int(input())\r\na = list(map(int, input().split() ))\r\n\r\nx = [0]*len(a)\r\ny = [0]*len(a)\r\n\r\nc1 = 0\r\nz1 = False\r\nc2 = 0\r\nz2 = False\r\n\r\nfor i in range(len(a)):\r\n if a[i] == 0:\r\n z1 = True\r\n c1 = 1\r\n elif z1:\r\n x[i] = c1\r\n c1+=1\r\n else:\r\n x[i] = 0\r\n\r\n if a[n-i-1] == 0:\r\n z2 = True\r\n c2 = 1\r\n elif z2:\r\n y[n-i-1] = c2\r\n c2+=1\r\n else:\r\n y[n-i-1] = 0\r\n\r\nans = \"\"\r\nfor i in range(len(a)):\r\n if (x[i] == 0):\r\n if y[i] == 0:\r\n ans += \"0 \"\r\n else:\r\n ans += str(y[i]) + \" \"\r\n else:\r\n if y[i] == 0:\r\n ans += str(x[i]) + \" \"\r\n else:\r\n ans += str(min(x[i], y[i])) + \" \"\r\nprint(ans)\r\n \r\n\r\n \r\n", "n=int(input())\r\nl=[int(x) for x in input().split()]\r\nl2=[]\r\nfor i in range(len(l)):\r\n if (l[i]==0):\r\n l2.append(i)\r\ntemp=0\r\nl3=[]\r\nwhile(temp<n and temp<=l2[0]):\r\n l3.append(l2[0]-temp)\r\n temp+=1\r\nj=1\r\nwhile(j<len(l2)):\r\n while (temp<=l2[j]):\r\n d1=abs(l2[j-1]-temp)\r\n d2=abs(l2[j]-temp)\r\n l3.append(min(d1,d2))\r\n temp+=1\r\n j+=1\r\nfor i in range(temp,n,1):\r\n l3.append(abs(i-l2[int(len(l2))-1]))\r\nfor k in l3:\r\n print(k,end=\" \")", "n = int(input())\na = list(map(int, input().split()))\n\nans = [n for _ in range(n)]\ntmp = n\nfor i in range(n):\n if a[i] == 0:\n tmp = 0\n else:\n tmp += 1\n ans[i] = min(ans[i], tmp)\n\ntmp = n\nfor i in range(n - 1, -1 , -1):\n if a[i] == 0:\n tmp = 0\n else:\n tmp += 1\n ans[i] = min(ans[i], tmp)\n\nprint(' '.join(map(str, ans)))\n\n", "from sys import stdin,stdout, setrecursionlimit\r\nfrom math import gcd,floor,sqrt,log\r\nfrom collections import defaultdict as dd\r\nfrom bisect import bisect_left as bl,bisect_right as br\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\nstdstr =lambda: stdin.readline()\r\nstdint =lambda: int(stdin.readline())\r\nstdpr =lambda x: stdout.write(str(x))\r\n\r\nmod=1000000007\r\n\r\n# B. Distances to Zero\r\n\r\nabc = 'abcdefghijklmnopqrstuvwxyz'\r\n\r\ndef solve():\r\n n = inp()\r\n a = seq()\r\n \r\n l = 1000000007\r\n r = 1000000007\r\n \r\n ld = []\r\n lr = []\r\n \r\n for i in range(n):\r\n l+=1\r\n r+=1\r\n \r\n if a[i] == 0: l = 0\r\n if a[n-1-i] == 0: r = 0\r\n \r\n ld.append(l)\r\n lr.append(r)\r\n \r\n ans = []\r\n \r\n for i in range(n):\r\n ans.append( str( min(ld[i], lr[n-1-i]) ) )\r\n \r\n stdpr(' '.join(ans)+'\\n')\r\n \r\n# for tc in range(int(input())): solve()\r\nsolve()", "mod = 1000000007\r\nii = lambda : int(input())\r\nsi = lambda : input()\r\ndgl = lambda : list(map(int, input()))\r\nf = lambda : map(int, input().split())\r\nil = lambda : list(map(int, input().split()))\r\nls = lambda : list(input())\r\nn=ii()\r\nl=il()\r\nl2=[]\r\nfor i in range(n):\r\n if l[i]==0:\r\n l2.append(i)\r\nl2+=[10000000]\r\ni=0\r\nj=0\r\nwhile i<n:\r\n print(min(abs(i-l2[j]),abs(i-l2[j+1])),end=' ')\r\n if abs(i-l2[j])>=abs(i-l2[j+1]):\r\n j+=1\r\n i+=1", "n = int(input())\r\nl = list(map(int,input().split()))\r\nzero = []\r\nfor i in range(n):\r\n if l[i]==0:\r\n zero.append(i)\r\nz = len(zero)\r\nans = []\r\nfor i in range(n):\r\n if l[i] == 0:\r\n ans.append(0)\r\n elif i<zero[0]:\r\n ans.append(abs(zero[0]-i))\r\n elif i>zero[-1]:\r\n ans.append(abs(zero[-1]-i))\r\n else :\r\n\r\n left = int(0)\r\n right = int(z-1)\r\n while left<=right-2:\r\n mid = int((left+right)/2)\r\n if zero[mid]>i:\r\n right = mid\r\n if zero[mid]<i:\r\n left = mid\r\n ans.append(min(abs(zero[left]-i),abs(zero[right]-i)))\r\nprint(*ans)", "from collections import Counter\r\nimport math\r\n\r\ndef printArr(arr):\r\n for i in arr:\r\n print(i,end=\" \")\r\n \r\ndef proA(arr):\r\n pre=[-math.inf]*len(arr)\r\n suff=[math.inf]*len(arr)\r\n \r\n if(arr[0]==0):\r\n pre[0]=0\r\n \r\n if(arr[-1]==0):\r\n suff[-1]=len(arr)-1\r\n \r\n n=len(arr)\r\n for i in range(1,len(arr)):\r\n if(arr[i]==0):\r\n pre[i]=max(pre[i-1],i)\r\n else:\r\n pre[i]=pre[i-1]\r\n if(arr[n-1-i]==0):\r\n suff[n-i-1]=min(suff[n-i],n-1-i)\r\n else:\r\n suff[n-i-1]=suff[n-i]\r\n ans=[0]*n\r\n for i in range(n):\r\n ans[i]=min(abs(i-pre[i]),abs(i-suff[i]))\r\n printArr(ans)\r\n \r\nn=int(input())\r\narr=list(map(int,input().split()))\r\nproA(arr)", "BIG = 10000000000\n\ndef main(n, arr):\n dist = BIG\n res = []\n for x in arr:\n if x == 0:\n dist = 0\n elif dist != BIG:\n dist += 1\n res.append(dist)\n\n dist = BIG\n for i in range(len(arr)-1, -1, -1):\n x = arr[i]\n if x == 0:\n dist = 0\n elif dist != BIG:\n dist += 1\n\n if res[i] > dist:\n res[i] = dist\n\n print(' '.join(map(str, res)))\n\n\n\n\nn = int(input())\narr = [int(x) for x in input().split()]\nmain(n, arr)\n", "n = int(input())\na = [int(i) for i in input().split()]\ncount1 = [(n+1) for i in range(n)]\ncount2 = [(n+1) for i in range(n)]\nfor i in range(n):\n\tif(a[i] != 0 and i>0):\n\t\tcount1[i] = 1+count1[i-1]\n\tif(a[i] == 0):\n\t\tcount1[i] = 0\n\tif(a[n - i - 1] != 0 and i>0):\n\t\tcount2[n - i - 1] = 1+count2[n-i]\n\tif(a[n - i - 1] == 0):\n\t\tcount2[n - i - 1] = 0\n\t# print(count1[i])\nfor i in range(n):\n\tprint(min(count1[i],count2[i]),end=' ')", "input() \r\nnumbers = input().split()\r\n\r\ndistlist = []\r\ndist = -1\r\nfor i in numbers:\r\n\tif i == '0':\r\n\t\tdist = 0\r\n\tdistlist += [dist]\r\n\tif dist != -1:\r\n\t\tdist += 1\r\n\r\ndist = -1\r\nfor index, i in enumerate(reversed(numbers)):\r\n\tii = len(numbers) - index - 1\r\n\tif i == '0':\r\n\t\tdist = 0\r\n\tif dist != -1:\r\n\t\tdistlist[ii] = min(dist, distlist[ii]) if distlist[ii] != -1 else dist\r\n\t\tdist += 1\r\n\r\nprint(\" \".join(map(str, distlist)))", "n = int(input())\r\na = list(map(int, input().split()))\r\nans = [n for i in range(n)]\r\ntemp = -n\r\nfor i in range(n):\r\n if a[i] == 0:\r\n temp = i\r\n ans[i] = min(ans[i], abs(i - temp))\r\ntemp = -n\r\nfor i in range(n - 1, -1, -1):\r\n if a[i] == 0:\r\n temp = i\r\n ans[i] = min(ans[i], abs(i - temp))\r\nfor i in range(n):\r\n print(ans[i], end = \" \" )", "n = int(input())\nx = [int(a) for a in input().split()]\nL = [1000000 for i in range(0,n)]\nP = [1000000 for i in range(0,n)]\n\n# od lewej do prawej\nfor i in range(0,n):\n if x[i]==0:\n L[i] = 0\n elif i>0:\n L[i] = L[i-1]+1\n\n# od prawej do lewej\nfor i in range(n-1,-1,-1):\n if x[i]==0:\n P[i] = 0\n elif i<n-1:\n P[i] = P[i+1]+1\n\nfor i in range(0,n):\n print(min(L[i],P[i]), end=' ')\n ", "import sys\r\n\r\nints = [abs(int(l))*9999999 for l in sys.stdin.readlines()[1].strip().split(' ')]\r\nfor m in [1, -1]:\r\n last = None\r\n for i in range(len(ints))[::m]:\r\n if not ints[i]:\r\n last = i\r\n if last is not None:\r\n ints[i] = min(abs(i - last), ints[i])\r\n\r\nprint(\" \".join(map(str, ints)))", "N = int(input())\narray = list(map(int,input().split(\" \")))\ndistance = list()\nprev = float('-inf')\nfor i,n in enumerate(array):\n if n==0 : prev = i\n distance.append(i-prev)\nprev = float('inf')\nfor i in range(len(array)-1,-1,-1):\n if array[i]==0: prev = i\n distance[i] = min(distance[i],prev-i)\nprint(\" \".join([str(i) for i in distance]))", "from array import *\r\nn = int(input())\r\nar = list(map(int, input().split()))\r\ndist1 = []\r\ndist2 = []\r\nfor i in range(n):\r\n dist1.append(0)\r\n dist2.append(0)\r\n\r\nst = n\r\nfor i in range(n):\r\n if ar[i] != 0:\r\n dist1[i] = st\r\n else:\r\n st = 0\r\n st += 1\r\nst = n\r\nar.reverse()\r\nfor i in range(n):\r\n if ar[i] != 0:\r\n dist2[i] = st\r\n else:\r\n st = 0\r\n st += 1\r\ndist2.reverse()\r\nfor i in range(n):\r\n m = min(dist1[i], dist2[i])\r\n print(m, end=\" \");\r\nprint(\"\\n\")\r\n\r\n", "n = int( input() )\ntab = list( map( int, input(). split() ) )\nleft = [ 0 for x in range(n) ]\nright = [ 0 for x in range(n) ]\n\ndist = 10 ** 9\nfor i in range(n):\n dist = dist + 1\n if tab[i] == 0:\n dist = 0\n left[i] = dist\n\ndist = 10 ** 9\nfor i in range( n-1, -1, -1 ):\n dist = dist + 1\n if tab[i] == 0:\n dist = 0\n right[i] = dist\n \nfor i in range(n):\n print( min( left[i], right[i] ), end = ' ' )\nprint('')\n", "a=int(input())\r\nb=list(map(int,input().split()))\r\n\r\nif b[0]==0:\r\n x=[0]\r\n ct=0\r\nelse:\r\n x=[a]\r\n ct=a\r\n\r\nfor i in b[1:]:\r\n if i==0:\r\n x.append(0)\r\n ct=0\r\n else:\r\n ct+=1\r\n x.append(ct)\r\nif b[-1]==0:\r\n y=[0]\r\n ct=0\r\nelse:\r\n y=[a]\r\n ct=a\r\n\r\nfor i in b[:-1][::-1]:\r\n if i==0:\r\n y.append(0)\r\n ct=0\r\n\r\n else:\r\n ct+=1\r\n y.append(ct)\r\ny=y[::-1]\r\n\r\nfor i in range(a):\r\n print(min(x[i],y[i]),end=' ')\r\n", "# 803B\nimport collections\ndef do():\n N = int(input())\n nums = [int(i) for i in input().split(\" \")]\n q = collections.deque()\n seen = [0] * N\n res = [float('inf')] * N\n for i,n in enumerate(nums):\n if n == 0:\n q.append((i, 0))\n seen[i] = 1\n while q:\n cur, dis = q.popleft()\n res[cur] = min(res[cur], dis)\n for nx in [cur-1, cur+1]:\n if 0<=nx<N and not seen[nx]:\n q.append((nx, dis+1))\n seen[nx] = 1\n print(\" \".join(map(str, res)))\n\ndo()\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\nzeroes = []\r\nfor i in range(len(l)):\r\n if l[i]==0:\r\n zeroes.append(i)\r\nzero = -1\r\nfor i in range(n):\r\n zeroes.append(zeroes[-1])\r\ns = \"\"\r\nfor i in range(len(l)):\r\n if i > zeroes[zero+1]:\r\n zero += 1\r\n if l[i]==0:\r\n s +=\" 0\"\r\n else:\r\n try:\r\n s += \" \"+str(min(abs(i-zeroes[zero]),abs(i-zeroes[zero+1]),abs(i-zeroes[zero+2])))\r\n except:\r\n s += \" \"+str(min(abs(zeroes[zero+1]-i),abs(i-zeroes[zero])))\r\nprint(s[1:])\r\n", "import math\nimport re\nimport random\n\n\n\n\n\n\nn = int(input())\na = list(map(int, input().split()))\n\nb = []\nq = 0\nfor i in range(n):\n if a[i] != 0 and i != n-1:\n q += 1\n elif a[i] == 0 and i != n-1:\n b.append(q)\n q = 0\n elif a[i] == 0 and i == n-1:\n b.append(q)\n b.append(0)\n break\n else:\n q += 1\n b.append(q)\n break\n\n\nc = []\n\nfor j in range(len(b)):\n if j == 0:\n for i in range(b[0]):\n c.append(b[0] - i)\n c.append(0)\n elif j == len(b) - 1:\n for i in range(b[j]):\n c.append(i + 1)\n else:\n\n if b[j] % 2 == 0:\n for i in range(b[j]//2):\n c.append(i + 1)\n for i in range(b[j]//2):\n c.append(b[j]//2 - i)\n c.append(0)\n else:\n for i in range(b[j]//2 + 1):\n c.append(i + 1)\n for i in range(b[j]//2):\n c.append(b[j]//2 - i)\n c.append(0)\n\n\n#print(' '.join(map(str, b)))\n\nprint(' '.join(map(str, c)))\n\n\n#print('2 1 0 1 0 0 1 2 3 ')\n\n\n\n\n\n\n\n\n\n\n# n, k = map(int, input().split())\n#\n#\n# if k > n*n:\n# print (-1)\n# exit(0)\n#\n# a = [[0] * n for i in range(n)]\n#\n# for i in range(n):\n# if k == 0:\n# break\n# a[i][i] = 1\n# k -= 1\n# if k == 0:\n# break\n# elif k == 1:\n# a[i+1][i+1] = 1\n# break\n# else:\n# for j in range(i+1, min(n, i + 1 + k//2)):\n# a[i][j] = 1\n# a[j][i] = 1\n# k -= 2\n#\n#\n# for i in range(n):\n# print(' '.join(map(str, a[i])))\n\n\n# n = int(input())\n# a = list(map(int, input().split()))\n# #print(' '.join(map(str, a)))\n#\n#\n#\n# b = set()\n#\n# for el in a:\n# if el-1 in b:\n# b.discard(el-1)\n# b.add(el)\n# else:\n# b.add(el)\n#\n# print(len(b))\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\np = []\r\nfor i in range(n):\r\n if l[i] == 0:\r\n p.append(i)\r\nsum = []\r\nd = {}\r\nfor i in range(len(p)-1):\r\n d[(p[i]+p[i+1])//2] = p[i]\r\nd[n] = p[-1]\r\n\r\np = 0\r\nq = list(d.keys())\r\nfor i in range(n):\r\n if i<q[p]:\r\n sum.append(abs(d[q[p]]-i))\r\n elif i == q[p]:\r\n sum.append(abs(d[q[p]]-i))\r\n p+=1\r\nprint(*sum)", "n = int(input())\nx = list(map(int, input().split()))\nlist_of_zeros = []\nfor i in range(n):\n if x[i] == 0:\n list_of_zeros.append(i + 1)\nk = 0\nfor j in range(n):\n if j + 1 < list_of_zeros[0]:\n print(list_of_zeros[0] - j - 1, end=' ')\n elif j + 1 == list_of_zeros[k]:\n if k < len(list_of_zeros) - 1:\n k += 1\n print(0, end=' ')\n elif j + 1 > list_of_zeros[-1]:\n print(j + 1 - list_of_zeros[-1], end=' ')\n else:\n print(min(j + 1 - list_of_zeros[k - 1], list_of_zeros[k] - j - 1), end=' ')\n", "n=input()\r\nn=int(n)\r\nl=list(map(int,input().split()))\r\nd=[0]*n\r\npos=[]\r\nfor i in range(0,n):\r\n if(l[i]==0):\r\n pos.append(i)\r\nj=0\r\nt=1\r\nk1=pos[0]\r\nk2=k1\r\nk=len(pos)\r\nwhile(j<n):\r\n d[j]=min(abs(j-k1),abs(j-k2))\r\n j=j+1\r\n if(j>k2 and t<k):\r\n k1=k2\r\n k2=pos[t]\r\n t+=1\r\nfor i in range(0,n):\r\n print(d[i],end=' ')\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n\r\n \r\n ", "n = int(input())\r\narr = list(map(int,input().split()))\r\nres = [n for i in range(n)]\r\nzeroIdx = None\r\nfor i in range(len(arr)):\r\n if arr[i] == 0:\r\n zeroIdx = i\r\n res[i] = 0\r\n if zeroIdx != None:\r\n res[i] = abs(i - zeroIdx)\r\n else:\r\n res[i] = n\r\nzeroIdx = None\r\nfor i in range(len(arr) -1, -1, -1):\r\n if arr[i] == 0:\r\n zeroIdx = i\r\n res[i] = 0\r\n if zeroIdx != None:\r\n res[i] = min(res[i],abs(i - zeroIdx))\r\n else:\r\n res[i] = min(res[i],n)\r\nprint(*res)", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\nf = [None] * n\r\nb = [None] * n\r\n\r\npos = None\r\nfor i in range(n):\r\n if a[i] == 0:\r\n pos = i\r\n f[i] = pos\r\n\r\npos = None\r\nfor i in range(n - 1, -1, -1):\r\n if a[i] == 0:\r\n pos = i\r\n b[i] = pos\r\n\r\nfor i in range(n):\r\n fd = None if f[i] is None else i - f[i]\r\n bd = None if b[i] is None else b[i] - i\r\n if fd is None:\r\n print(bd, end=' ')\r\n elif bd is None:\r\n print(fd, end=' ')\r\n else:\r\n print(min(fd, bd), end=' ')\r\n", "n = int(input())\r\nA = list(map(int, input().split()))\r\nzeros = [i for i,a in enumerate(A) if a==0]\r\nk = 0\r\n\r\nfor i in range(n):\r\n if k+1 < len(zeros) and abs(zeros[k]-i) > abs(zeros[k+1]-i):\r\n k += 1\r\n print(abs(i-zeros[k]), end=' ')", "\r\nn = int(input())\r\narr = input().split(' ')\r\n\r\n\r\nlast_zeros = [0]*n\r\nlast_zero = -1\r\nfor i in range(n):\r\n arr[i] = int(arr[i])\r\n if arr[i] == 0:\r\n last_zero = i\r\n if last_zero == -1:\r\n last_zeros[i] = 10**10\r\n else:\r\n last_zeros[i] = i - last_zero\r\n\r\nlast_zero = -1\r\nfor i in reversed(range(n)):\r\n if arr[i] == 0:\r\n last_zero = i\r\n if last_zero != -1:\r\n last_zeros[i] = min(last_zeros[i], last_zero - i)\r\n\r\nfor el in last_zeros:\r\n print(el, end=' ')", "n=int(input())\r\na=list(map(int,input().split()))\r\nl,r,ll,rr,c=[0]*n,[0]*n,-10**9,10**9,[]\r\nfor i in range(n):\r\n if not a[i]:ll=i\r\n l[i]=i-ll\r\nfor i in range(n-1,-1,-1):\r\n if not a[i]:rr=i\r\n r[i]=rr-i\r\nfor i in range(n):c.append(str(min(l[i],r[i])))\r\nprint(' '.join(c))\r\n", "def solve():\r\n n = int(input())\r\n a = [int(x) for x in input().split(' ')]\r\n d = [float('inf')] * n\r\n prev = - float('inf')\r\n for i in range(n):\r\n if a[i] == 0:\r\n prev = i\r\n d[i] = min(d[i], i - prev)\r\n next = float('inf')\r\n for i in range(n - 1, -1, -1):\r\n if a[i] == 0:\r\n next = i\r\n d[i] = min(d[i], next - i)\r\n return d\r\n\r\nprint(*solve())\r\n\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=[];c=[0]*n\r\nfor i in range(n):\r\n if a[i]==0:\r\n b.append(i)\r\nfor i in range(b[0]+1):\r\n c[i]=abs(i-b[0])\r\nfor i in range(1,len(b)):\r\n for j in range(b[i-1]+1,b[i]+1):\r\n c[j]=min(abs(j-b[i-1]),abs(j-b[i]))\r\nfor i in range(b[-1]+1,n):\r\n c[i]=abs(i-b[-1])\r\nprint(*c)", "N = int(input())\r\nS = list(map(int,input().split()))\r\nS1 = [0]*len(S)\r\nS2 = [0]*len(S)\r\nzeroleft = -1\r\nzeroright = -1\r\nfor i in range(len(S)):\r\n if S[i] == 0:\r\n zeroleft = i\r\n break\r\nfor i in range(len(S)-1, -1, -1):\r\n if S[i] == 0:\r\n zeroright = len(S)-1-i\r\n break\r\nfor i in range(len(S)):\r\n if S[i] == 0:\r\n S1[i] = 0\r\n elif i == 0:\r\n S1[i] = zeroleft\r\n else: S1[i] = S1[i-1] + 1\r\nfor i in range(len(S)-1, -1, -1):\r\n if S[i] == 0:\r\n S2[i] = 0\r\n elif i == len(S)-1:\r\n S2[i] = zeroright\r\n else: S2[i] = S2[i+1] + 1\r\nfor j in range(len(S1)):\r\n S1[j] = min(S1[j], S2[j])\r\nprint(*S1)\r\n " ]
{"inputs": ["9\n2 1 0 3 0 0 3 2 4", "5\n0 1 2 3 4", "7\n5 6 0 1 -2 3 4", "1\n0", "2\n0 0", "2\n0 1", "2\n1 0", "5\n0 1000000000 1000000000 1000000000 1000000000", "5\n-1000000000 -1000000000 0 1000000000 1000000000", "5\n-1000000000 1000000000 1000000000 1000000000 0", "15\n1000000000 -1000000000 -1000000000 1000000000 -1000000000 -1000000000 -1000000000 1000000000 1000000000 -1000000000 -1000000000 -1000000000 -1000000000 1000000000 0", "15\n0 0 0 0 1000000000 -1000000000 -1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000 -1000000000 -1000000000 1000000000", "15\n-1000000000 1000000000 1000000000 -1000000000 -1000000000 1000000000 0 -1000000000 -1000000000 0 0 1000000000 -1000000000 0 -1000000000", "15\n-1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000 1000000000 1000000000 0 0 0 0", "4\n0 0 2 0", "15\n1 2 3 4 0 1 2 3 -5 -4 -3 -1 0 5 4", "2\n0 -1", "5\n0 -1 -1 -1 0", "5\n0 0 0 -1 0", "3\n0 0 -1", "3\n0 -1 -1", "12\n0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0", "18\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1", "30\n0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "1\n0", "1\n0", "1\n0", "2\n0 -1000000000", "2\n0 1000000000", "2\n-1000000000 0", "2\n0 0", "2\n0 0", "2\n0 0", "3\n0 -1000000000 -1000000000", "3\n0 1000000000 1000000000", "3\n1000000000 1000000000 0", "3\n0 0 -1000000000", "3\n0 1000000000 0", "3\n-1000000000 0 0", "3\n0 0 0", "3\n0 0 0", "3\n0 0 0", "4\n0 -1000000000 -1000000000 -1000000000", "4\n1000000000 -1000000000 0 -1000000000", "4\n1000000000 -1000000000 1000000000 0", "4\n0 0 -1000000000 1000000000", "4\n0 0 1000000000 -1000000000", "4\n-1000000000 1000000000 0 0", "4\n0 0 0 -1000000000", "4\n1000000000 0 0 0", "4\n1000000000 0 0 0", "4\n0 0 0 0", "4\n0 0 0 0", "4\n0 0 0 0", "5\n0 1000000000 1000000000 1000000000 1000000000", "5\n1000000000 -1000000000 -1000000000 1000000000 0", "5\n1000000000 -1000000000 1000000000 -1000000000 0", "5\n0 0 -1000000000 -1000000000 -1000000000", "5\n1000000000 0 -1000000000 0 -1000000000", "5\n1000000000 1000000000 1000000000 0 0", "5\n0 0 0 -1000000000 -1000000000", "5\n-1000000000 1000000000 0 0 0", "5\n1000000000 1000000000 0 0 0", "5\n0 0 0 0 -1000000000", "5\n0 0 1000000000 0 0", "5\n1000000000 0 0 0 0", "5\n0 0 0 0 0", "5\n0 0 0 0 0", "5\n0 0 0 0 0", "6\n0 1000000000 -1000000000 1000000000 -1000000000 1000000000", "6\n-1000000000 -1000000000 1000000000 1000000000 1000000000 0", "6\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0", "6\n0 0 1000000000 1000000000 -1000000000 -1000000000", "6\n0 0 1000000000 1000000000 -1000000000 -1000000000", "6\n-1000000000 1000000000 -1000000000 -1000000000 0 0", "6\n0 0 0 -1000000000 1000000000 1000000000", "6\n-1000000000 1000000000 -1000000000 0 0 0", "6\n-1000000000 -1000000000 1000000000 0 0 0", "6\n0 0 0 0 -1000000000 1000000000", "6\n0 0 0 -1000000000 1000000000 0", "6\n1000000000 1000000000 0 0 0 0", "6\n0 0 0 0 0 -1000000000", "6\n0 0 0 1000000000 0 0", "6\n1000000000 0 0 0 0 0", "6\n0 0 0 0 0 0", "6\n0 0 0 0 0 0", "6\n0 0 0 0 0 0", "7\n0 -1000000000 1000000000 -1000000000 -1000000000 -1000000000 -1000000000", "7\n1000000000 1000000000 -1000000000 0 -1000000000 1000000000 -1000000000", "7\n1000000000 1000000000 -1000000000 1000000000 -1000000000 -1000000000 0", "7\n0 0 1000000000 1000000000 1000000000 1000000000 -1000000000", "7\n0 1000000000 1000000000 -1000000000 1000000000 1000000000 0", "7\n1000000000 -1000000000 -1000000000 1000000000 -1000000000 0 0", "7\n0 0 0 1000000000 -1000000000 -1000000000 1000000000", "7\n-1000000000 0 0 -1000000000 0 -1000000000 1000000000", "7\n1000000000 1000000000 1000000000 -1000000000 0 0 0", "7\n0 0 0 0 -1000000000 -1000000000 1000000000", "7\n0 -1000000000 0 0 0 -1000000000 1000000000", "7\n1000000000 1000000000 1000000000 0 0 0 0", "7\n0 0 0 0 0 -1000000000 1000000000", "7\n0 -1000000000 0 0 0 0 -1000000000", "7\n-1000000000 1000000000 0 0 0 0 0", "7\n0 0 0 0 0 0 -1000000000", "7\n0 0 0 0 0 1000000000 0", "7\n1000000000 0 0 0 0 0 0", "7\n0 0 0 0 0 0 0", "7\n0 0 0 0 0 0 0", "7\n0 0 0 0 0 0 0", "8\n0 -1000000000 -1000000000 1000000000 1000000000 1000000000 1000000000 -1000000000", "8\n0 -1000000000 1000000000 1000000000 1000000000 -1000000000 1000000000 1000000000", "8\n1000000000 -1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000 0", "8\n0 0 -1000000000 -1000000000 1000000000 1000000000 1000000000 -1000000000", "8\n1000000000 0 0 -1000000000 -1000000000 1000000000 -1000000000 -1000000000", "8\n1000000000 -1000000000 1000000000 -1000000000 -1000000000 -1000000000 0 0", "8\n0 0 0 1000000000 1000000000 -1000000000 -1000000000 -1000000000", "8\n-1000000000 0 0 1000000000 1000000000 0 -1000000000 1000000000", "8\n1000000000 1000000000 1000000000 -1000000000 -1000000000 0 0 0", "8\n0 0 0 0 1000000000 1000000000 1000000000 -1000000000", "8\n1000000000 0 1000000000 -1000000000 0 -1000000000 0 0", "8\n-1000000000 -1000000000 -1000000000 -1000000000 0 0 0 0", "8\n0 0 0 0 0 1000000000 1000000000 -1000000000", "8\n-1000000000 0 -1000000000 0 0 1000000000 0 0", "8\n1000000000 1000000000 1000000000 0 0 0 0 0", "8\n0 0 0 0 0 0 -1000000000 -1000000000", "8\n0 0 0 1000000000 -1000000000 0 0 0", "8\n1000000000 1000000000 0 0 0 0 0 0", "8\n0 0 0 0 0 0 0 -1000000000", "8\n0 1000000000 0 0 0 0 0 0", "8\n1000000000 0 0 0 0 0 0 0", "8\n0 0 0 0 0 0 0 0", "8\n0 0 0 0 0 0 0 0", "8\n0 0 0 0 0 0 0 0"], "outputs": ["2 1 0 1 0 0 1 2 3 ", "0 1 2 3 4 ", "2 1 0 1 2 3 4 ", "0 ", "0 0 ", "0 1 ", "1 0 ", "0 1 2 3 4 ", "2 1 0 1 2 ", "4 3 2 1 0 ", "14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ", "0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 ", "6 5 4 3 2 1 0 1 1 0 0 1 1 0 1 ", "11 10 9 8 7 6 5 4 3 2 1 0 0 0 0 ", "0 0 1 0 ", "4 3 2 1 0 1 2 3 4 3 2 1 0 1 2 ", "0 1 ", "0 1 2 1 0 ", "0 0 0 1 0 ", "0 0 1 ", "0 1 2 ", "0 1 2 3 4 5 5 4 3 2 1 0 ", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ", "0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ", "0 ", "0 ", "0 ", "0 1 ", "0 1 ", "1 0 ", "0 0 ", "0 0 ", "0 0 ", "0 1 2 ", "0 1 2 ", "2 1 0 ", "0 0 1 ", "0 1 0 ", "1 0 0 ", "0 0 0 ", "0 0 0 ", "0 0 0 ", "0 1 2 3 ", "2 1 0 1 ", "3 2 1 0 ", "0 0 1 2 ", "0 0 1 2 ", "2 1 0 0 ", "0 0 0 1 ", "1 0 0 0 ", "1 0 0 0 ", "0 0 0 0 ", "0 0 0 0 ", "0 0 0 0 ", "0 1 2 3 4 ", "4 3 2 1 0 ", "4 3 2 1 0 ", "0 0 1 2 3 ", "1 0 1 0 1 ", "3 2 1 0 0 ", "0 0 0 1 2 ", "2 1 0 0 0 ", "2 1 0 0 0 ", "0 0 0 0 1 ", "0 0 1 0 0 ", "1 0 0 0 0 ", "0 0 0 0 0 ", "0 0 0 0 0 ", "0 0 0 0 0 ", "0 1 2 3 4 5 ", "5 4 3 2 1 0 ", "5 4 3 2 1 0 ", "0 0 1 2 3 4 ", "0 0 1 2 3 4 ", "4 3 2 1 0 0 ", "0 0 0 1 2 3 ", "3 2 1 0 0 0 ", "3 2 1 0 0 0 ", "0 0 0 0 1 2 ", "0 0 0 1 1 0 ", "2 1 0 0 0 0 ", "0 0 0 0 0 1 ", "0 0 0 1 0 0 ", "1 0 0 0 0 0 ", "0 0 0 0 0 0 ", "0 0 0 0 0 0 ", "0 0 0 0 0 0 ", "0 1 2 3 4 5 6 ", "3 2 1 0 1 2 3 ", "6 5 4 3 2 1 0 ", "0 0 1 2 3 4 5 ", "0 1 2 3 2 1 0 ", "5 4 3 2 1 0 0 ", "0 0 0 1 2 3 4 ", "1 0 0 1 0 1 2 ", "4 3 2 1 0 0 0 ", "0 0 0 0 1 2 3 ", "0 1 0 0 0 1 2 ", "3 2 1 0 0 0 0 ", "0 0 0 0 0 1 2 ", "0 1 0 0 0 0 1 ", "2 1 0 0 0 0 0 ", "0 0 0 0 0 0 1 ", "0 0 0 0 0 1 0 ", "1 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 0 0 ", "0 1 2 3 4 5 6 7 ", "0 1 2 3 4 5 6 7 ", "7 6 5 4 3 2 1 0 ", "0 0 1 2 3 4 5 6 ", "1 0 0 1 2 3 4 5 ", "6 5 4 3 2 1 0 0 ", "0 0 0 1 2 3 4 5 ", "1 0 0 1 1 0 1 2 ", "5 4 3 2 1 0 0 0 ", "0 0 0 0 1 2 3 4 ", "1 0 1 1 0 1 0 0 ", "4 3 2 1 0 0 0 0 ", "0 0 0 0 0 1 2 3 ", "1 0 1 0 0 1 0 0 ", "3 2 1 0 0 0 0 0 ", "0 0 0 0 0 0 1 2 ", "0 0 0 1 1 0 0 0 ", "2 1 0 0 0 0 0 0 ", "0 0 0 0 0 0 0 1 ", "0 1 0 0 0 0 0 0 ", "1 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 0 0 0 0 0 0 "]}
UNKNOWN
PYTHON3
CODEFORCES
109
e1c5ad14b20dbf5c26e55715bcabf8fe
Blog Photo
One popular blog site edits the uploaded photos like this. It cuts a rectangular area out of them so that the ratio of height to width (i.e. the *height*<=/<=*width* quotient) can vary from 0.8 to 1.25 inclusively. Besides, at least one side of the cut area should have a size, equal to some power of number 2 (2*x* for some integer *x*). If those rules don't indicate the size of the cut are clearly, then the way with which the cut part possesses the largest area is chosen. Of course, both sides of the cut area should be integer. If there are several answers to this problem, you should choose the answer with the maximal height. The first line contains a pair of integers *h* and *w* (1<=≤<=*h*,<=*w*<=≤<=109) which are the height and width of the uploaded photo in pixels. Print two integers which are the height and width of the cut area. Sample Input 2 1 2 2 5 5 Sample Output 1 1 2 2 5 4
[ "import math\r\nh,w = map(int,input().split())\r\nif h/w>=0.8 and h/w<=1.25 and ((math.log(h,2)%1==0) or (math.log(w,2)%1==0)):\r\n print(h,w)\r\nelse:\r\n w1 = 2**(math.log(w,2)//1)\r\n h1 = min(h,(w1*1.25)//1)\r\n h2 = 2**(math.log(h,2)//1)\r\n w2 = min(w,(h2*1.25)//1)\r\n if (h1/w1>=0.8 and h1/w1<=1.25) and (h2/w2>=0.8 and h2/w2<=1.25):\r\n if h1>=h2 and h1*w1>=h2*w2:\r\n print(int(h1),int(w1))\r\n else:\r\n print(int(h2),int(w2))\r\n elif (h1/w1>=0.8 and h1/w1<=1.25):\r\n print(int(h1),int(w1))\r\n else:\r\n print(int(h2),int(w2))", "import math\r\nh, w = map(int, input().split())\r\na = 1\r\nwhile (a << 1 <= h and a << 1 <= w):\r\n a <<= 1\r\nn = min(h, round(a * 5 / 4))\r\nm = min(w, round(a * 5 / 4))\r\nif n >= m:\r\n print(n, a)\r\nelse:\r\n print(a, m)", "import sys\r\nimport math\r\ndef input(): return sys.stdin.readline().strip()\r\ndef iinput(): return int(input())\r\ndef minput(): return map(int, input().split()) \r\ndef listinput(): return list(map(int, input().split()))\r\nh,w=minput()\r\nx=2**int(math.log2(h))\r\ny=2**int(math.log2(w))\r\nif x>y:\r\n x=int(min(x,y*1.25))\r\nelse:\r\n y=int(min(y,x*1.25))\r\nx1,y1=min(int(y*1.25),h),min(int(x*1.25),w)\r\nif x*y1>y*x1:\r\n print(x,y1)\r\nelse:\r\n print(x1,y)", "import math as qyb\r\na,b=map(int,input().split())\r\ncnt=1\r\nwhile 2**cnt<=a and 2**cnt<=b:\r\n cnt+=1\r\ncnt-=1\r\ncnt=2**cnt\r\nm1=min(a,cnt*1.25)\r\nm2=min(b,cnt*1.25)\r\nif m1>=m2:\r\n print(\"%d %d\"%(m1,cnt))\r\nelse:\r\n print(\"%d %d\"%(cnt,m2))", "from math import log\r\nh, w = map(int,input().split())\r\nff = 2**int(log(h)/log(2))\r\nss = 2**int(log(w)/log(2))\r\n\r\nif ff > ss :\r\n ff = min(ff,int(ss*1.25))\r\nelse:\r\n ss = min(ss,int(ff*1.25))\r\n\r\nff2 = min(int(ss*1.25), h)\r\nss2 = min(int(ff*1.25), w)\r\n\r\nif ff*ss2 > ss*ff2:\r\n print(ff,ss2)\r\nelse:\r\n print(ff2,ss)\r\n", "from re import I\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\nh, w = map(int, input().split())\r\npow2 = [1]\r\nfor _ in range(31):\r\n pow2.append(2 * pow2[-1])\r\nans, h0 = 0, 0\r\nfor i in pow2:\r\n if h < i:\r\n break\r\n j = min(5 * i // 4, w)\r\n if 4 * i > 5 * j or 4 * j > 5 * i:\r\n continue\r\n if ans < i * j:\r\n ans = i * j\r\n h0 = i\r\n elif ans == i * j and h0 < i:\r\n h0 = i\r\nfor j in pow2:\r\n if w < j:\r\n break\r\n i = min(5 * j // 4, h)\r\n if 4 * i > 5 * j or 4 * j > 5 * i:\r\n continue\r\n if ans < i * j:\r\n ans = i * j\r\n h0 = i\r\n elif ans == i * j and h0 < i:\r\n h0 = i\r\nw0 = ans // h0\r\nprint(h0, w0)", "import math\r\nh,w = map(int,input().split())\r\nff = 2**math.floor(math.log2(h))\r\nss = 2**math.floor(math.log2(w))\r\nif ff > ss :\r\n ff = min(ff, math.floor(ss*1.25))\r\nelse:\r\n ss = min(ss, math.floor(ff*1.25))\r\nff2 = min(math.floor(ss*1.25), h)\r\nss2 = min(math.floor(ff*1.25), w)\r\nif ff*ss2>ss*ff2:\r\n print(ff, ss2)\r\nelse:\r\n print(ff2, ss)", "import math\n\n\n\ns = input().split(' ');\n\nh = int(s[0])\n\nw = int(s[1])\n\n\n\n\n\nff = 2**math.floor(math.log2(h))\n\nss = 2**math.floor(math.log2(w))\n\n\n\nif ff > ss :\n\n ff = min(ff, math.floor(ss*1.25))\n\nelse:\n\n ss = min(ss, math.floor(ff*1.25))\n\n\n\n\n\nff2 = min(math.floor(ss*1.25), h)\n\nss2 = min(math.floor(ff*1.25), w)\n\n\n\nif ff*ss2>ss*ff2:\n\n print(ff, ss2)\n\nelse:\n\n print(ff2, ss)\n\n\n\n# Made By Mostafa_Khaled", "import math\r\n\r\nh,w = map(int, input().split())\r\n\r\na = 1<<(math.floor(math.log(h, 2)))\r\nif (a/0.8) > w:\r\n if a/w < 0.8 or a/w > 1.25:\r\n x = (0, 0)\r\n else:\r\n x = (a, w)\r\nelse:\r\n x = (a, int(a/0.8))\r\n \r\nb = 1<<(math.floor(math.log(w, 2)))\r\nif (b*1.25) > h:\r\n if h/b < 0.8 or a/w > 1.25:\r\n y = (0, 0)\r\n else:\r\n y = (h, b)\r\n \r\nelse:\r\n y = (int(b*1.25), b)\r\n \r\nif x[0]*x[1] > y[0]*y[1]:\r\n print(x[0], end=\" \")\r\n print(x[1])\r\nelse:\r\n print(y[0], end=\" \")\r\n print(y[1])", "c=1\r\nlis=[0]*35\r\nfor i in range(33):\r\n lis[i]=c\r\n c*=2\r\nh,w = map(int,input().split())\r\nans=[] \r\nfor i in range(32,-1,-1):\r\n if lis[i]<=h:\r\n l=1\r\n r=w\r\n while l<=r:\r\n mid = l + (r-l)//2\r\n if mid/lis[i]<1.25:\r\n l=mid+1\r\n else:\r\n r=mid-1\r\n if 0.8<=l/lis[i]<=1.25 and l<=w:\r\n ans.append([l*lis[i],lis[i],l])\r\n elif r!=0 and r<=w and 0.8<=r/lis[i]<=1.25:\r\n ans.append([r*lis[i],lis[i],r]) \r\nfor i in range(33):\r\n if lis[i]<=w:\r\n l=1\r\n r=h\r\n while l<=r:\r\n mid = l + (r-l)//2\r\n if 1.25>mid/lis[i]:\r\n l=mid+1\r\n else:\r\n r=mid-1\r\n if l<=h and 0.8<=lis[i]/l<=1.25:\r\n ans.append([l*lis[i],l,lis[i]])\r\n if r!=0 and r<=h and 0.8<=lis[i]/r<=1.25:\r\n ans.append([lis[i]*r,r,lis[i]])\r\nans.sort(reverse=True)\r\nprint(*ans[0][1:]) \r\n\r\n\r\n", "import sys\r\nfrom array import array # noqa: F401\r\n\r\n\r\ndef input():\r\n return sys.stdin.buffer.readline().decode('utf-8')\r\n\r\n\r\nh, w = map(int, input().split())\r\nans_h, ans_w = 1, 1\r\n\r\ny = 2\r\nwhile y <= h:\r\n x = min(w, (5 * y) // 4)\r\n if (4 * y + 4) // 5 <= x and ans_h * ans_w <= y * x:\r\n ans_h, ans_w = y, x\r\n y *= 2\r\n\r\nx = 2\r\nwhile x <= w:\r\n y = min(h, (5 * x) // 4)\r\n if (4 * x + 4) // 5 <= y:\r\n if ans_h * ans_w < y * x or ans_h * ans_w == y * x and ans_h < y:\r\n ans_h, ans_w = y, x\r\n x *= 2\r\n\r\nprint(ans_h, ans_w)\r\n", "from math import log\nh,w=map(int,input().split())\nff = 2**int(log(h)/log(2))\nss = 2**int(log(w)/log(2))\nif ff>ss :\n ff=min(ff,int(ss*1.25))\nelse:\n ss=min(ss,int(ff*1.25))\n\nff2=min(int(ss*1.25), h)\nss2=min(int(ff*1.25), w)\nif ff*ss2>ss*ff2:\n print(ff,ss2)\nelse:\n print(ff2,ss)\n", "def pow2_range(max):\r\n i = 1\r\n while i < max:\r\n yield i\r\n i = i * 2\r\n\r\ndef photo_cut():\r\n\th, w = map(int, input().split())\r\n\r\n\tgood_h, good_w = 0, 0\r\n\tfor i in pow2_range(h+1):\r\n\t\tm, n = i, min(w, i * 1.25)\r\n\t\tif (m * 4 > n * 5) or (n * 4 > m * 5):\r\n\t\t\tcontinue\r\n\r\n\t\tif((m * n) > (good_h * good_w)) or ((m * n) == (good_h * good_w)) and (m > good_h):\r\n\t\t\tgood_h = m\r\n\t\t\tgood_w = n\r\n\r\n\t\r\n\tfor j in pow2_range(w+1):\r\n\t\tm, n = min(h, j * 1.25), j\r\n\t\tif (m * 4 > n * 5) or (n * 4 > m * 5):\r\n\t\t\tcontinue\r\n\r\n\t\tif((m * n) > (good_h * good_w)) or ((m * n) == (good_h * good_w)) and (m > good_h):\r\n\t\t\tgood_h = m\r\n\t\t\tgood_w = n\r\n\t\r\n\tprint(int(good_h), int(good_w))\r\n\r\n\r\nphoto_cut()\r\n", "from math import log2\r\n\r\ns = input().split(' ');\r\nh = int(s[0])\r\nw = int(s[1])\r\n\r\nff = 2**int(log2(h))\r\nss = 2**int(log2(w))\r\n\r\nif ff > ss :\r\n ff = min(ff, int(ss*1.25))\r\nelse:\r\n ss = min(ss, int(ff*1.25))\r\n\r\nff2 = min(int(ss*1.25), h)\r\nss2 = min(int(ff*1.25), w)\r\n\r\nif ff*ss2>ss*ff2:\r\n print(ff, ss2)\r\nelse:\r\n print(ff2, ss)", "from math import log2, ceil, floor\r\nh, w = map(int, input().split())\r\nres = []\r\nfor i in range(int(log2(h)) + 1):\r\n temp_h = 2 ** i\r\n if int(ceil(temp_h / 1.25)) <= w:\r\n temp_w = min(w, int(floor(temp_h / .8)))\r\n s = temp_w * temp_h\r\n res.append([s, temp_h, temp_w])\r\nfor i in range(int(log2(w)) + 1):\r\n temp_w = 2 ** i\r\n if int(ceil(temp_w * 0.8)) <= h:\r\n temp_h = min(h, int(floor(temp_w * 1.25)))\r\n s = temp_w * temp_h\r\n res.append([s, temp_h, temp_w])\r\nres.sort(reverse=True)\r\nprint(*res[0][1:])\r\n" ]
{"inputs": ["2 1", "2 2", "5 5", "9 10", "15 13", "47 46", "99 100", "939 887", "4774 4806", "39271 49032", "483242 484564", "4939191 4587461", "9909199 9945873", "49829224 49889315", "49728622 49605627", "49934587 49239195", "48298903 49928606", "49874820 49474021", "48945079 49798393", "99692141 99232337", "998557701 924591072", "644590722 593296648", "792322809 775058858", "971840165 826141527", "944976601 976175854", "1000000000 1000000000"], "outputs": ["1 1", "2 2", "5 4", "8 10", "10 8", "40 32", "80 64", "640 512", "4096 4806", "32768 40960", "327680 262144", "4939191 4194304", "8388608 9945873", "41943040 33554432", "41943040 33554432", "41943040 33554432", "41943040 33554432", "41943040 33554432", "41943040 33554432", "83886080 67108864", "671088640 536870912", "644590722 536870912", "671088640 536870912", "671088640 536870912", "671088640 536870912", "671088640 536870912"]}
UNKNOWN
PYTHON3
CODEFORCES
15
e1c6638094e6ffa59cfa504b3bf9c472
Year of University Entrance
There is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the university. Each of students joins the group of his course and joins all groups for which the year of student's university entrance differs by no more than *x* from the year of university entrance of this student, where *x* — some non-negative integer. A value *x* is not given, but it can be uniquely determined from the available data. Note that students don't join other groups. You are given the list of groups which the student Igor joined. According to this information you need to determine the year of Igor's university entrance. The first line contains the positive odd integer *n* (1<=≤<=*n*<=≤<=5) — the number of groups which Igor joined. The next line contains *n* distinct integers *a*1,<=*a*2,<=...,<=*a**n* (2010<=≤<=*a**i*<=≤<=2100) — years of student's university entrance for each group in which Igor is the member. It is guaranteed that the input data is correct and the answer always exists. Groups are given randomly. Print the year of Igor's university entrance. Sample Input 3 2014 2016 2015 1 2050 Sample Output 2015 2050
[ "n = int(input())\r\ng = list(map(int, input().split()))\r\nprint(sum(g) // n)\r\n", "def main():\r\n groups = int(input())\r\n years = [int(x) for x in input().split()]\r\n years.sort()\r\n if groups == 1:\r\n print(years[0])\r\n elif groups == 3:\r\n print(years[1])\r\n elif groups == 5:\r\n print(years[2])\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()", "n = int(input())\r\nll=list(map(int,input().split()))\r\nll.sort()\r\nprint(ll[n//2])", "n = input()\r\nmy_str = input()\r\nmy_list = my_str.split(' ')\r\nprint(sorted(my_list)[len(my_list) // 2])", "a=int(input())\r\nv=list(map(int,input().split()))\r\nv.sort()\r\nprint(v[(a+1)//2-1])", "n=int(input())\r\na=list(map(int, input().split()))\r\nprint(sum(a)//n)", "__author__ = \"Ryabchun Vladimir\"\n\n\nn = int(input())\nsum_years = 0\ngroups = list(map(int, input().split()))\nfor elem in groups:\n sum_years += elem\nprint(int(sum_years / n))", "n=input()\r\nl=input().split(\" \")\r\nl.sort()\r\na=int(int(n)/2)\r\nprint(l[a])", "n=int(input())\r\narr=[int(i) for i in input().split(\" \")]\r\narr.sort()\r\nmid=n//2\r\nprint(arr[mid])\r\n", "t = int(input())\r\nx = sorted(list(map(int, input().split())))\r\nprint(sum(x)//t)\r\n", "n = list(map(int, input().split()))\r\nz = sorted(list(map(int, input().split())))\r\nprint(z[len(z)//2])\r\n", "n=int(input())\r\na=[int(s) for s in input().split()]\r\nprint(sum(a)//n)", "def god_postuplenia(lst):\r\n z = list()\r\n y = list()\r\n for elem in lst:\r\n z.append(min(2100, elem))\r\n y.append(max(2010, elem))\r\n return (min(z) + max(y)) // 2\r\n\r\n\r\nn = int(input())\r\na = [int(i) for i in input().split()]\r\nprint(god_postuplenia(a))\r\n", "# LUOGU_RID: 101648813\nn, *a = map(int, open(0).read().split())\r\na.sort()\r\nprint(a[n // 2])", "n = int(input())\r\nmas = list(map(int, input().split()))\r\nprint(int(sum(mas)/n))", "n = int(input())\ngroup_names = input().split()\nfor i in range(n):\n group_names[i] = int(group_names[i])\ngroup_names.sort()\nprint(group_names[n//2])", "n = int(input())\r\nyears = input().split(' ')\r\nyears = [int(x) for x in years]\r\nprint(int(sum(years) / len(years)))", "n = int (input())\r\nL= list( map ( int , input().split()))\r\n\r\nL.sort()\r\n\r\nprint(L[n//2])", "#! usr/bin/env python3\r\nyear = 0\r\nx = input()\r\ngroups = input().split(\" \")\r\n\r\nfor i in range(len(groups)):\r\n\tgroups[i] = int(groups[i])\r\n\tyear += groups[i]\r\n\r\nyear = int(year / len(groups))\r\nprint(year)", "n = int(input())\r\nk = list(map(int, input().split()))\r\nprint(sorted(k)[n//2])\r\n", "count = int(input())\r\n\r\nsum = 0\r\nyears = input().split(' ')\r\nfor y in years:\r\n sum += int(y)\r\nprint(int(sum/count))", "n=int(input())\r\nl=sorted(map(int,input().split()))\r\nif(n==1):\r\n print(l[0])\r\nelse:\r\n m=l[1]-l[0]\r\n n=l[len(l)-1]-l[1]\r\n k=abs(n-m)\r\n p=1\r\n for i in range(1,len(l)-1):\r\n c=l[i]-l[0]\r\n d=l[len(l)-1]-l[i]\r\n if(abs(c-d)<k):\r\n k=abs(c-d)\r\n p=i\r\n print(l[p])", "n = int(input())\r\nM = list(map(int, input().split()))\r\nM.sort()\r\nprint(M[len(M)//2])\r\n", "groups = int(input(\"\"))\nyearsnf = input(\"\")\nyears = yearsnf.split(\" \")\nyears.sort()\nprint(years[int(groups/2)])", "n=int(input(''))\r\nl=list(map(int,input().split()))\r\n\r\nm1,m2=min(l),max(l)\r\nprint((m1+m2)//2)", "n = int(input())\r\nentrance_years = list(map(int, input().split()))\r\n\r\nentrance_years.sort()\r\n\r\nmedian_index = n // 2\r\nigor_entrance_year = entrance_years[median_index]\r\n\r\nprint(igor_entrance_year)\r\n", "n = int(input())\r\n\r\nyears = list(map(int, input().split()))\r\nyears.sort()\r\n\r\nprint(years[n//2])", "n=int(input())\r\nA=input().split()\r\nprint(int((int(max(A))+int(min(A)))/2))", "n = int(input())\nall_ = 0\nm = list(map(int, input().split()))\nfor i in range(0,n):\n all_ = all_ + m[i]\nprint(all_//n)", "n = int(input())\r\nl = list(map(int, input().split()))\r\nl.sort()\r\nprint(l[n//2 if n%2 else n//2 - 1])", "n = int(input())\r\nlst = sorted([int(x) for x in input().split()])\r\nif len(lst) == 1:\r\n\tprint(lst[0])\r\nelse:\r\n\tprint(lst[len(lst) // 2])\r\n", "n = int(input())\r\ns = sorted(input().split())\r\nprint(s[n // 2])", "n = int(input())\r\nyears = sorted((map(int, input().split())))\r\nprint(years[len(years)//2])\r\n\r\n", "import statistics\r\n\r\nn = int(input())\r\narr = input().split(\" \")\r\nprint(statistics.median(arr))", "n = input()\r\nyears = [int(el) for el in input().split()]\r\nyears.sort()\r\nprint(years[int((len(years)-1)/2)])", "N = int( input() )\r\nA = list( map( int, input().split() ) )\r\nprint( min( A ) + max( A ) >> 1 )\r\n", "n = int(input())\r\narr = []\r\nstring = str(input())\r\nyears = string.split(\" \")\r\nfor i in years:\r\n arr.append(int(i))\r\narr.sort()\r\nprint(arr[n//2])", "n = int(input())\r\narr = list(map(int,input().split()))\r\narr.sort()\r\nprint(arr[len(arr) // 2])", "input1=(list(map(int,input().split()))) \r\ninput2=list(map(int,input().split())) \r\nmin=min(input2) \r\nmax=max(input2) \r\nprint((min+max)//2)\r\n", "n = int(input())\nannees = sorted([int(x) for x in input().split()])\nprint(annees[(n + 1) // 2 - 1])\n", "n = int(input())\nprint(sorted(input().split())[n // 2])\n", "def avg(arr):\r\n\treturn int(sum(arr) // len(arr))\r\nn = int(input())\r\ngoda = input().split(' ')\r\ngoda = [int(y) for y in goda]\r\nprint(avg(goda))", "n=int(input())\r\nrdl=[]\r\nrdl = list(map(int, input().split()))\r\nif n==1:\r\n print(rdl[0])\r\nelse:\r\n rdl.sort()\r\n if (rdl[n-1]-rdl[n//2] == rdl[n//2]-rdl[0]):\r\n print(rdl[n//2])\r\n elif rdl[n-1]-rdl[n//2] > rdl[n//2]-rdl[0]:\r\n print(rdl[n//2+1])\r\n else:\r\n print(rdl[n//2-1])\r\n\r\n", "n=int(input())\ny=sorted(map(int,input().split()))\nprint(y[(n-1)//2])\n \t\t \t \t\t \t\t \t \t \t\t", "def BubbleSort(A):\n for j in range(len(A)-1,0,-1):\n for i in range (0,j):\n if A[i]>A[i+1]:\n A[i],A[i+1]=A[i+1],A[i]\n return A\nn=int(input())\nA=list(map(int,input().split()))\nB=[]\nBubbleSort(A)\nif n==1:\n print(A[0])\nelif n==3:\n print(A[1])\nelse:\n print(A[2])\n\n\n\n\n", "n = input()\nn = int(n)\na = str()\n\na = input()\na = a.split()\na = list(map(int, a))\na.sort()\n\nif n == 1:\n print(a[0])\nelse:\n print(a[n//2])\n", "line = []\r\n\r\nwhile True:\r\n try:\r\n l = input()\r\n except EOFError:\r\n break\r\n line.append(l)\r\n\r\ngroups = line[0]\r\nline.pop(0)\r\n\r\nnumbers = line[0].split()\r\n\r\nsum = 0\r\nfor i in range(int(groups)):\r\n digit = int(numbers[i])\r\n sum += digit\r\n\r\ngraduationYear = sum//int(groups)\r\nprint(graduationYear)", "import math\r\nm = int(input())\r\n\r\na = list(map(int, input().split()))\r\na.sort()\r\nm = sum(a) // len(a)\r\ns = 100\r\nfor i in range(len(a)):\r\n if abs(a[i] - m) < s:\r\n s = abs(a[i] - m)\r\n r = a[i]\r\nprint(r)\r\n", "n=int(input())\r\n*a,=sorted(map(int,input().split()))\r\nx=(n-1)//2\r\nprint(a[x])", "n = int(input())\r\nline = list(map(int, input().split()))\r\nmi = min(line)\r\nma = max(line)\r\nprint(mi + (ma - mi) // 2)", "n = int(input())\r\na = list(map(int,input().split()))\r\na.sort()\r\nx = (n//2)+1\r\nprint(a[x-1])", "import statistics\r\nn = int(input())\r\nl_list = list(map(int, input().split()))\r\nl_list.sort()\r\n\r\nprint(statistics.median(l_list))\r\n", "n=int(input())\r\nlst=input().split()\r\nlst=[int(i) for i in lst]\r\nlst=sorted(lst)\r\nif(n==1):\r\n print(lst[0])\r\nelse:\r\n m=int(n/2)\r\n print(lst[m])", "a = input()\r\na = list(map(int, input().split()))\r\nm, M = min(a), max(a)\r\n\r\ndr = (M + m) / 2\r\nM = 2100\r\n\r\nfor i in a:\r\n if abs(i - dr) < M:\r\n M = abs(i - dr)\r\n m = i\r\n\r\nprint(m)", "n = int(input())\r\na, b = 2200, 2000\r\nfor x in map(int, input().split()):\r\n a = min(a, x)\r\n b = max(b, x)\r\nprint((a+b)//2)", "n,ar=int(input()),sorted(list(map(int,input().split())))\r\nprint(ar[n//2])\r\n", "n = int(input())\r\nyears = list(map(int, input().split()))\r\nmin_year = min(years)\r\nmax_year = max(years)\r\nprint((min_year + max_year) // 2)", "\ndef main():\n n = int(input())\n groups = set(map(int, input().split()))\n average = sum(groups)\n mid = average // len(groups)\n print(mid)\n\nmain()", "a=int(input())\r\nl=list(map(int,input().split()))\r\nprint((max(l)+min(l))//2)", "n=int(input())\r\na=list(map(int,input().split()))\r\nprint((max(a)+min(a))//2)\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\nmaxr = [0 for i in range(n)]\r\nfor i in range(n):\r\n for j in range(n):\r\n maxr[i] = max(maxr[i], abs(a[i] - a[j]))\r\nprint(a[maxr.index(min(maxr))])\r\n\r\n", "n=int(input())\r\nyears=list(map(int,input().split()))\r\nyears.sort()\r\nyear_index=len(years)//2\r\nprint(years[year_index])", "n = int(input())\r\na = [*map(int, input().split())]\r\n\r\na.sort()\r\n\r\nam = (len(a)//2)\r\nprint(a[am])", "n = int(input())\r\n*ar, = map(int,input().split())\r\nar.sort()\r\nprint(ar[int(n//2)])\r\n \r\n", "def university_entrance(years):\r\n years = sorted(years)\r\n mid = len(years) // 2\r\n print(years[mid])\r\n\r\n\r\nn = input()\r\nyears = list(map(int, input().split()))\r\nuniversity_entrance(years)\r\n", "import sys\nimport math\n\nnum = int(sys.stdin.readline())\nyears = [int(c) for c in sys.stdin.readline().split()]\nyears.sort()\nprint(years[math.floor(len(years)/2)])", "n = int(input())\r\na = sorted(int(x) for x in input().split())\r\nprint(a[n >> 1])", "n=int(input())\r\na=list(map(int,input().split()))\r\na.sort()\r\nx=(a[n-1]+a[0])//2\r\nfor i in range(n):\r\n if a[i]>=x:\r\n print(a[i])\r\n break", "n = int(input())\nl = list(map(int,input().split()))\nl.sort()\nif len(l)%2 == 0:\n\tprint(l[int(len(l)/2)]+1)\nelse:\n\tprint(l[int(len(l)/2)])\n\n\n\n\n\n\n\n\t\t\t \t\t\t\t \t \t \t \t \t \t\t\t\t\t\t \t \t\t", "n = int(input())\nyears = [int(x) for x in input().split()]\nprint(sum(years) // n)", "n=int(input())\r\na=sorted([int(a) for a in input().split()])\r\nprint(a[n//2])", "n = int(input())\r\nA = list(map(int, input().split()))\r\ns = 0\r\nfor x in A:\r\n s += x\r\ns /= n\r\nmn = 9999\r\nfor x in A:\r\n if abs(s - x) < mn:\r\n mn = abs(s - x)\r\n y = x\r\nprint(y)\r\n", "\r\nn = int(input())\r\nl = sorted(list(map(int, input().split())))\r\n\r\nwhile len(l) > 1:\r\n\tl.pop()\r\n\tl.pop(0)\r\n\r\nprint(l[0])", "#rough code\r\nn=int(input())\r\ny=list(map(int,input().split()))\r\ny.sort()\r\nif n==1:\r\n print(y[0])\r\nelse:\r\n print(y[(n+1)//2-1])", "n=int(input())\r\nl=list(map(int,input().split()))[:n]\r\nl.sort()\r\nk=(len(l)-1)//2\r\nif len(l)>1:\r\n print(l[k])\r\nelse:\r\n print(l[0])\r\n ", "count = input()\nyears = input().split(' ')\n\nyears = [int(y.strip()) for y in years]\n\nyears.sort()\n\nif len(years) == 1:\n print(years[0])\nelse:\n print(years[len(years) // 2])\n", "a=int(input())\r\nc=list (map(int,input().split()))\r\nb=(a-1)//2\r\nc.sort()\r\nprint(c[b])", "n=int(input ()) \nA=list (map (int, input (). split ())) \nB=0\nC=10000000000000\nfor i in range (n) :\n B=max (B, A[i]) \n C=min(C, A[i]) \nD=(C+B)//2\nprint (D)", "n = int(input())\ns = [int(x) for x in input().split()]\nprint(int((max(s) + min(s)) / 2))", "\r\nn = int(input())\r\nk = [int(i) for i in input().split()]\r\nk.sort()\r\nprint(k[n//2])", "n = int(input())\r\n\r\nyears = sorted([int(x) for x in input().split()])\r\n\r\nprint(years[int(n/2)])", "n=int(input())\r\nprint(round(sum(list(map(int, input().split())))/n))", "n = int(input())\r\nA = list(map(int,input().split()))\r\nprint(min(A)+int(n/2))\r\n", "n_ = int(input())\r\nn = []\r\n[n.append(int(i)) for i in input().split()]\r\nn.sort()\r\nif n_ == 1:\r\n print(n[0])\r\nelif n_ == 3:\r\n print(n[1])\r\nelse:\r\n print(n[2])", "a=int(input())\r\nn=sorted([*map(int,input().split())])\r\nprint(n[a//2])\r\n", "n = int(input())\nA = list(map(int, input().split()))\nA.sort()\nprint(A[(n - 1) // 2])\n", "n = input()\r\nyears = map(int, input().split(' '))\r\nyears = list(years)\r\nyears.sort()\r\nprint(years[len(years)//2])", "n=int(input())\r\na=[int(i) for i in input().split()]\r\na.sort()\r\nprint(a[n//2])\r\n", "n = int(input())\r\nw = set(input().split())\r\nprint(sorted(w)[n//2])\r\n", "n = int(input())\r\narray = list(map(int,input().split(' ')))\r\n\r\nif (n == 1):\r\n print(array[0])\r\nelse:\r\n for i in range(1,n):\r\n j = i - 1\r\n while (j >= 0 and array[j] > array[j+1]):\r\n t = array[j]\r\n array[j] = array[j+1]\r\n array[j+1] = t\r\n j = j - 1\r\n\r\n b = 1\r\n for i in range(0,n-2):\r\n if(array[i+1] - array[i] != 1):\r\n b = 0\r\n break\r\n if(b == 1):\r\n print(str(array[n//2]))\r\n \r\n", "##n = int(input())\r\n##a = list(map(int, input().split()))\r\n##print(' '.join(map(str, res)))\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\na.sort()\r\nprint(a[n//2])", "n=int(input())\r\na=list(map(int, input().split()))\r\na=sorted(a)\r\nprint(a[len(a)//2])\r\n", "len = int(input())\r\nenter = sorted(input().split())\r\nprint(enter[(len-1)//2])", "n=int(input())\r\nl= input()\r\nl = [int(i) for i in l.split()]\r\nl = sorted(l)\r\nprint(l[len(l)//2])", "n = int(input())\r\nl = list(map(int,input().split()))\r\nl.sort()\r\nprint(l[len(l)//2])", "n=int(input())\r\nl=sorted(list(map(int,input().split())))\r\nprint(l[n//2])\r\n", "n = int(input())\r\np = 0\r\nfor x in input().split():\r\n p = p + int(x)\r\nprint(p // n)", "n = int(input())\r\nlst = [int(i) for i in input().split()]\r\nlst.sort()\r\n\r\nif n == 1:\r\n print(lst[0])\r\nelif n == 3:\r\n print(lst[1])\r\nelse:\r\n print(lst[2])", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\ndata = sorted(map(int, input().split()))\r\nprint(data[n // 2])\r\n", "n = int(input())\r\nl = sorted(list(map(int,input().split())))\r\nprint(l[len(l)//2])", "n = int(input())\na = [ int(i) for i in input().split() ]\na.sort()\nprint(a[((n+1)//2)-1])", "input();r=[*map(int,input().split())]\r\nprint(max(r)+min(r)>>1)", "n = int(input())\r\narr = [int(s) for s in input().split()]\r\narr.sort()\r\nprint(arr[n // 2 ])\r\n", "def read_tokens():\n return input().strip().split(' ')\n\n\ndef read_ints():\n return [int(s) for s in read_tokens()]\n\n\nn = int(input())\narr = read_ints()\n\narr.sort()\nn = len(arr)\nprint(arr[n//2])\n", "def main():\n # print([x for x in input()])\n n = int(input())\n groups = input()\n # print(n, lines)\n # lines = input()\n # print(lines)\n # n, groups = lines\n groups = list(sorted(groups.split(' ')))\n n_map = {\n 1: 0,\n 3: 1,\n 5: 2,\n }\n print(groups[n_map[n]])\n\n\nif __name__ == \"__main__\":\n main()\n", "n=int(input())\r\nyr=[int(i) for i in input().split()]\r\nyr.sort()\r\nprint(yr[n//2])", "n = int(input())\r\ns = list(map(int, input().split()))\r\nprint(int((min(s) + max(s)) / 2))", "#!/usr/bin/env python3\n\n\ndef main():\n n = input()\n xs = sorted(int(x) for x in input().split())\n print(xs[len(xs) // 2])\n\n\nif __name__ == '__main__':\n main()\n", "lmp = lambda:list(map(int, input().split()))\r\nmp = lambda:map(int, input().split())\r\nintp = lambda:int(input())\r\ninp = lambda:input()\r\nfinp = lambda:float(input())\r\n\r\nn = intp()\r\na = lmp()\r\n\r\na.sort()\r\nn = n // 2\r\n\r\nprint(a[n])\r\n", "a = int(input())\nb = list(input().split(' '))\ns = 0\nfor i in b:\n s += int(i)\n\nprint(int(s / a))\n", "x = int(input())\r\na= list(map(int, input().split()))\r\na.sort()\r\nprint((a[0] + a[-1])//2)", "n=int(input())\r\nar=list(map(int,input().split()))[0:n]\r\ns_ar=sorted(ar)\r\nfor i in range (0,n):\r\n if(i==n//2):\r\n print(s_ar[i])", "n = int(input())\r\na = input().split()\r\na.sort()\r\n\r\nprint(str(a[n//2]))\r\n\r\n \r\n\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\na.sort()\r\nif n%2==1:\r\n ind=(n-1)//2\r\n result=a[ind]\r\nelif 2010 in a:\r\n ind=(n//2)-1\r\n result=a[ind]\r\nelif 2100 in a:\r\n ind=n//2\r\n result=a[ind]\r\nprint(result)\r\n\r\n#print(' '.join(map(str,a)))\r\n\r\n", "n = int(input())\r\ngroups = [int(i) for i in input().split()]\r\n\r\nt = max(groups)\r\nb = min(groups)\r\nprint(int((t + b) / 2))\r\n", "N = int(input())\r\nprint(sorted(list(map(int, input().split())))[N//2])\r\n\r\n# Hope the best for Ravens\r\n# Never give up\r\n", "n = int(input())\r\nnums = list(map(int, input().split(' ')))\r\nminX = 2100\r\nmaxX = 2010\r\nfor x in nums:\r\n minX = min(x,minX)\r\n maxX = max(x,maxX)\r\nprint((maxX+minX) // 2)", "n=int(input())\r\nnom=[int(x) for x in input().split()]\r\nif n==1:\r\n print(nom[0])\r\nelse:\r\n print(int(sum(nom)/n))", "from statistics import median\ninput()\nprint(median(map(int, input().split())))\n", "n=int(input())\r\nprint(sorted(input().split())[n//2])", "n = int(input())\r\nyears = [int(x) for x in input().strip().split()]\r\nyears.sort()\r\ndiffNew = []\r\nmid = (years[n-1] + years[0]) // 2\r\nif n == 1:\r\n print(years[0])\r\n exit()\r\ndiffs = []\r\nfor j in range(n):\r\n diff = abs(mid - years[j])\r\n diffs.append(diff)\r\ndiffNew = list(diffs)\r\ndiffs.sort()\r\nind = diffNew.index(diffs[0])\r\n# print(diffs)\r\n# print(diffNew)\r\n# print(ind)\r\nprint(years[ind])", "n=int(input(''))\r\nl=list(map(int,input().split()))\r\nif n==1:\r\n print(l[0])\r\nelse:\r\n x = abs(l[0] - l[1])\r\n m1,m2=min(l),max(l)\r\n print((m1+m2)//2)", "n=int(input())#number of groups which Igor joined\r\na=list(map(int,input().split()))\r\na.sort()\r\nprint(a[(len(a))//2])", "n=int(input())\r\nprint(sorted(list(map(int,input().split())))[n//2])\r\n", "n = int(input())\r\nys = [int(x) for x in input().split()]\r\nif n == 1:\r\n print(ys[0])\r\nelse:\r\n print(int(sum(ys)/n))", "n=int(input())\r\nk=input().split()\r\nif n==1:\r\n print(''.join(k))\r\nif n!=1:\r\n k.sort()\r\n if len(k)%2==0:\r\n print(k[len(k)/2-1])\r\n if len(k)%2!=0:\r\n print(k[len(k)//2])", "a=int(input())\r\nb=[]\r\nb=input().split(' ')\r\nc=int()\r\nfor i in range (a):\r\n c=c+int(b[i])\r\nprint(c//a)", "count = int(input())\r\ninput_text = input()\r\ninput_text = input_text.split(\" \")\r\nsum = 0\r\nfor elem in input_text:\r\n sum += int(elem)\r\nprint(int(sum/count))", "n=int(input())\r\nn1=list(map(int,input().split()))\r\nn1.sort()\r\ns=n//2\r\nprint(n1[s])\r\n", "n=int(input())\r\na=sorted([int(i) for i in input().split()])\r\nprint(a[n//2])", "#!/bin/python3\r\n \r\nimport sys\r\nimport statistics\r\n \r\n \r\nn = int(input().strip())\r\narr = [int(arr_temp) for arr_temp in input().strip().split(' ')]\r\n\r\nprint(statistics.median_low(arr))", "# https://codeforces.com/problemset/problem/769/A\r\n\r\nn = int(input())\r\nyears = sorted(map(int, input().split()))\r\nprint(years[n // 2])\r\n", "n = int(input())\r\nyears = list(map(int,input().split()))\r\nprint(sum(years)//n)", "x=int(input())\ny=list(map(int,input().split()))\ny.sort()\nif x%2==0:\n print(y[x//2-1])\nelse:\n print(y[x//2])\n\t\t\t \t \t \t\t\t \t\t\t\t \t\t\t", "n = int(input())\r\np = input()\r\np = p.split()\r\np = [int(x) for x in p]#; print(p)\r\na = sum(p)\r\nprint (a // len(p))", "n = int(input())\r\nl = list(map(int, input().split()))\r\nif n%2!=0:\r\n mid = n//2\r\nelse:\r\n mid = n//2 +1\r\nl.sort()\r\nprint(l[mid])", "n = int(input())\r\na = [int(el) for el in input().split()]\r\na.sort()\r\n\r\nprint(a[len(a) // 2])", "n = int(input())\r\nf = list(map(int, input().split()))\r\nf.sort()\r\ng = [-1,-1]\r\nfor i in f:\r\n if (g[-1] != i):\r\n g.append(i)\r\nprint(g[len(g)//2+1])\r\n", "n = int(input())\r\ngroup = list(map(int, input().split()))\r\nif n == 1:\r\n print(group[0])\r\nelse:\r\n group.sort()\r\n if n == 3:\r\n print(group[1])\r\n else:\r\n print(group[2])\r\n", "from sys import stdin, stdout\r\n\r\nn = int(stdin.readline())\r\nyears = sorted(list(map(int, stdin.readline().split())))\r\n\r\nif n == 1:\r\n stdout.write(str(years[0]))\r\nelif n == 3:\r\n stdout.write(str(years[1]))\r\nelif n == 5:\r\n stdout.write(str(years[2]))", "N=int(input())\r\nArray=list(map(int,input().split()))\r\nG1=(N-1)/2\r\nArray=sorted(Array)\r\nprint(Array[int(G1)])\r\n ", "num = int(input())\r\ngroups = list(map(int, input().split()))\r\ngroups.sort()\r\n\r\nprint(groups[len(groups) // 2])\r\n", "a=int(input())\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nt= list(map(int,input().split()))\r\n\r\n\r\nt.sort()\r\n\r\nif a%2==0:\r\n print(min(t))\r\nelse:\r\n print(t[a//2])\r\n \r\n", "n = int(input())\r\na = []\r\na = input().split()\r\ni = 0\r\ns = 0\r\nwhile i < n:\r\n s = s + int(a[i])\r\n i = i + 1\r\nx = s/n\r\nprint(int(x))\r\n\r\n \r\n\r\n\r\n\r\n \r\n", "\"\"\"\r\ninput:\r\n3\r\n2014 2016 2015\r\n\r\nouput:\r\n2015\r\n\"\"\"\r\n\r\ndef main():\r\n n = input()\r\n years = list(map(int, input().split()))\r\n print(int(sum(years)/len(years)))\r\n\r\nif __name__ == \"__main__\":\r\n main()", "num=input()\r\nspis=input().split(\" \")\r\na=int(min(spis))\r\nb=int(max(spis))\r\nprint((a+b)//2)", "n = int(input())\r\n\r\nm = list(map(int, input().split()))\r\n\r\nm = sorted(m)\r\n\r\nprint(m[n//2])\r\n", "def list_from_input():\n return list(map(int, input().split()))\n\ndef read():\n return eval(input())\n\ndef main():\n n = read()\n years = list_from_input()\n\n print(sorted(years)[n//2])\n\nmain()", "#!/usr/bin/env/python\r\n# -*- coding: utf-8 -*-\r\nn = int(input())\r\na = list(map(int, input().split()))\r\na.sort()\r\nprint(a[n // 2])\r\n", "n = int(input())\r\ngroups = [int(x) for x in input().split()]\r\ngroups.sort()\r\ny = int((n-1)/2)\r\nyear = groups[y]\r\nprint(year)", "n = int(input())\r\na = list(map(int, input().split()))\r\na.sort()\r\nif (n == 1):\r\n print(a[0])\r\nelif n == 3:\r\n print(a[1])\r\nelif n == 5:\r\n print(a[2])\r\n\r\n\r\n", "n = int(input())\r\narr = sorted([int(i) for i in input().strip().split(' ')])\r\nprint(arr[len(arr)//2])", "n = input()\r\nl = [int(x) for x in input().split()]\r\nprint((min(l)+max(l))//2)", "a=int(input())\r\nb=sorted(list(map(int, input().split())))\r\nif a==1:\r\n print(b[0])\r\nif a==3:\r\n print(b[1])\r\nif a==5:\r\n print(b[2])", "n = int(input())\ncourses = input().split(' ')\ncourses = [int(x) for x in courses]\n\nmi = float('inf')\nma = float('-inf')\n\nfor n in courses:\n if n < mi:\n mi = n\n if n > ma:\n ma = n\n\nans = int((ma - mi) / 2) + mi\nprint(ans)\n", "n = int(input())\r\nyears = sorted(list(map(int, input().split())))\r\nprint(years[n // 2])", "n=int(input())\r\n\r\nprint(int(sum(map(int,input().split()))/n))", "from statistics import median\r\nnum = int(input())\r\nprint(median([int(x) for x in input().split()]))", "n=int(input())\r\n\r\nl=list(map(int,input().split()))\r\n\r\na=sum(l)\r\n\r\nprint(a//n)\r\n", "n = int(input())\r\n\r\nsecond_arr = input().split()\r\n\r\nyears = [int(item) for item in second_arr]\r\n\r\nyears.sort()\r\n\r\nprint(years[n//2])", "N = int(input())\r\nyears = [int(i) for i in input().strip().split()]\r\nprint(int(sum(years)/N))", "n = int(input())\r\narr = list(map(int, input().split()))\r\narr.sort()\r\nprint((arr[0] + arr[-1]) // 2)", "# https://codeforces.com/problemset/problem/769/A\n\ndef solve(a):\n a.sort()\n mid = len(a) // 2\n return a[mid]\n\n\nn = input()\na = [int(e) for e in input().split()]\nprint(solve(a))\n", "\r\n\r\nn = int(input())\r\n\r\nx = [int(x) for x in input().split()]\r\nx.sort()\r\n\r\nprint(x[n // 2])", "n = int(input())\r\nlst = list(map(int, input().split()))\r\nprint (int((max(lst) + min(lst)) / 2))\r\n\r\n\r\n", "_, y = input(), (int(i) for i in input().split())\nmin_y, max_y = 2101, 2009\nfor i in y:\n min_y = min(min_y, i)\n max_y = max(max_y, i)\nres = (min_y + max_y) // 2\nprint(res)\n", "import sys\r\n\r\nfin = sys.stdin\r\nfout = sys.stdout\r\nn = int(fin.readline())\r\na = set(map(int, fin.readline().split()))\r\nfout.write(str(sum(a) // len(a)))\r\n", "x = int(input())\r\na = [int(s) for s in input().split()]\r\na_min = 2200\r\nfor i in range(x):\r\n if a[i] < a_min:\r\n a_min = a[i]\r\nprint(a_min + ((x - 1) //2))\r\n", "n = int(input())\r\na = []\r\ns = input().split(' ')\r\nfor i in range(n):\r\n a.append(int(s[i]))\r\n\r\na.sort()\r\nx = []\r\nfor i in range(n):\r\n y = max(a[i]-a[0],a[n-1]-a[i])\r\n x.append(y)\r\n\r\nmin = min(x)\r\nfor i in range(n):\r\n if x[i] == min:\r\n print(a[i])\r\n break", "n=int(input())\r\ncourses=list(map(int,input().split()))\r\ncourses.sort()\r\nprint(courses[n//2])", "'''input\r\n1\r\n2050\r\n'''\r\n\r\n# import sys\r\n# from pprint import pprint\r\n\r\n\r\nn = int(input())\r\narr = sorted([int(i) for i in input().split()])\r\nprint(arr[len(arr) // 2])\r\n", "a = int(input()) // 2\r\narr = list(map(int, input().split()))\r\narr.sort()\r\nprint(arr[a])\r\n", "n = int(input())\r\na = list(map(int,input().split()))\r\ns = a[0]\r\nif n>1:\r\n for i in range(1,n):\r\n s+=a[i]\r\nyear = s//n\r\nprint(year)\r\n", "n=int(input())\ns=input().split()\ns=sorted(s)\nprint(s[int(n/2)])\n", "\"\"\" Created by Shahen Kosyan on 3/4/17 \"\"\"\n\nif __name__ == \"__main__\":\n n = int(input())\n arr = [int(x) for x in input().split()]\n\n arr = sorted(arr)\n\n print(arr[len(arr) // 2])\n", "n = int(input())\r\nprint(sorted(input().split())[n//2]) ", "n = int(input())\r\nl = [int(x) for x in input().split()]\r\nl.sort()\r\nprint(l[n//2])", "n = int(input()) #Считываем количество групп\r\na = [int(i) for i in input().split()] #Считываем строку с цифрами в массив\r\na.sort() #сортируем массив при помощи сорт\r\nprint(a[n-1]-(n // 2))#В зависомсти от n вычисляем год a[n-1] - (n // 2)", "def Main():\r\n n = int(input())\r\n syears = input().split()\r\n years = []\r\n for item in syears:\r\n years.append(int(item))\r\n greatest = max (years)\r\n smallest = min (years)\r\n result = int((greatest+smallest)/2)\r\n print (result)\r\n\r\nMain()", "\r\n\r\nt=int(input())\r\narr=list(map(int,input().split()))\r\narr.sort()\r\nprint(arr[t//2])", "n, a = int(input()), list(map(int, input().split()))\nprint((min(a) + max(a)) >> 1)\n", "n=int(input())\r\ngroups=input().split(\" \")\r\n\r\ngroups=sorted(groups)\r\nprint(groups[n // 2])\r\n\r\n", "# before you win, you have to achieve failure\r\nn=int(input());a=list(map(int,input().split()))\r\na=sorted(a)\r\nprint(a[n//2])\r\n", "n = int(input())\r\na = list(map(int,input().split()))\r\na.sort()\r\nif(n==1):\r\n print(a[0])\r\nif(n==3):\r\n print(a[1])\r\nif(n==5):\r\n print(a[2])", "#rough code\r\nn=int(input())\r\ny=list(map(int,input().split()))\r\ny.sort()\r\nprint(y[(n+1)//2-1])", "T= int(input())\r\nL= list(map(int,input().split()))\r\n\r\nL.sort()\r\n\r\nif(T%2==0):\r\n\tprint(L[(T/2)-1])\r\nelse:\r\n\tprint(L[T//2])", "n=int(input())\r\ny=list(map(int,input().split()))\r\ny.sort()\r\nprint(y[round(n//2)])\r\n\r\n", "n = int(input())\r\ngroups = [int(g) for g in input().split(' ')]\r\n\r\nsum = 0\r\nfor group in groups:\r\n sum += group\r\n\r\nprint(sum // n)\r\n", "input()\nnums = list(map(int, input().split()))\nprint(sum(nums) // len(nums))", "al=int(input())\r\na=sorted(list(map(int,input().split())))\r\nprint(a[al//2])\r\n", "n = int(input())\na = list(map(int,input().split()))\na.sort()\nif n != 1:print(a[int(n // 2)])\nelse:print(a[0])\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\n\r\nl.sort()\r\nk=len(l)-1\r\nprint(l[k//2])", "import sys\r\n\r\ndef main():\r\n _, *l = map(int, sys.stdin.read().strip().split())\r\n return sum(l)//len(l)\r\n \r\nprint(main())\r\n", "import collections as col\r\nimport itertools as its\r\nimport operator\r\n\r\n\r\nclass Solver:\r\n def solve(self):\r\n n = int(input())\r\n a = list(map(int, input().split()))\r\n print((max(a) + min(a)) // 2)\r\n\r\n\r\nif __name__ == '__main__':\r\n s = Solver()\r\n s.solve()\r\n", "c = int(input())\r\n\r\ny = input()\r\ny = list(map(int, y.split()))\r\n\r\ny = sorted(y)\r\n\r\nprint (y[(len(y)//2)], end='\\n')", "\r\nn = input()\r\nyears = tuple(map(lambda x: int(x), input().split(' ')))\r\n\r\nprint((max(years)+min(years))//2)\r\n", "def solve(case_no):\r\n\tn = int(input())\r\n\ta = list(map(int, input().split()))\r\n\ta.sort()\r\n\tprint(a[n // 2])\r\n\t\r\nt = 1\r\n# t = int(input())\r\nfor i in range(1, t + 1):\r\n\tsolve(i)", "n = int(input())\r\ny = sum(int(i) for i in input().split()) // n\r\nprint(y)", "n=int(input());\r\nyears = input().split();\r\narr = list();\r\nfor j in range(len(years)):\r\n arr.append(int(years[j]));\r\n\r\nmin_value = min(arr);\r\nmax_value = max(arr);\r\n\r\nans = (min_value + max_value)//2;\r\nprint(ans)\r\n", "def Func(x,a):\r\n for i in range(len(a)):\r\n osnov=a[i]\r\n if Otlich(osnov,a[0:i]+a[i+1:len(a)],x):\r\n return [True,osnov]\r\n return [False]\r\ndef Otlich(osnov,a,x):\r\n for i in range(len(a)):\r\n if abs(a[i]-osnov) > x:\r\n return False\r\n return True\r\n \r\nn=int(input())\r\na=list(map(int,input().split()))\r\nx=1\r\nif len(a) == 1:\r\n print(a[0])\r\nelse:\r\n while x <= 100:\r\n b=Func(x,a)\r\n if not b[0]:\r\n x=x+1\r\n else:\r\n print(b[1])\r\n break\r\n \r\n", "n = int(input())\r\nA = list(map(int,input().split()))\r\nA.sort()\r\ni = 0\r\ni = n//2\r\nprint(A[i])", "n,s = int(input()),list(sorted(map(int,input().split())))\r\nprint(s[n // 2])" ]
{"inputs": ["3\n2014 2016 2015", "1\n2050", "1\n2010", "1\n2011", "3\n2010 2011 2012", "3\n2049 2047 2048", "5\n2043 2042 2041 2044 2040", "5\n2012 2013 2014 2015 2016", "1\n2045", "1\n2046", "1\n2099", "1\n2100", "3\n2011 2010 2012", "3\n2011 2012 2010", "3\n2012 2011 2010", "3\n2010 2012 2011", "3\n2012 2010 2011", "3\n2047 2048 2049", "3\n2047 2049 2048", "3\n2048 2047 2049", "3\n2048 2049 2047", "3\n2049 2048 2047", "5\n2011 2014 2012 2013 2010", "5\n2014 2013 2011 2012 2015", "5\n2021 2023 2024 2020 2022", "5\n2081 2079 2078 2080 2077", "5\n2095 2099 2097 2096 2098", "5\n2097 2099 2100 2098 2096", "5\n2012 2010 2014 2011 2013", "5\n2012 2011 2013 2015 2014", "5\n2023 2024 2022 2021 2020", "5\n2077 2078 2080 2079 2081", "5\n2099 2096 2095 2097 2098", "5\n2097 2100 2098 2096 2099", "5\n2011 2014 2013 2010 2012", "5\n2013 2011 2015 2012 2014", "5\n2024 2020 2021 2023 2022", "5\n2079 2080 2077 2081 2078", "5\n2095 2097 2096 2098 2099", "5\n2099 2096 2100 2097 2098", "5\n2034 2033 2036 2032 2035", "5\n2030 2031 2033 2032 2029", "5\n2093 2092 2094 2096 2095", "5\n2012 2015 2014 2013 2011", "5\n2056 2057 2058 2059 2060"], "outputs": ["2015", "2050", "2010", "2011", "2011", "2048", "2042", "2014", "2045", "2046", "2099", "2100", "2011", "2011", "2011", "2011", "2011", "2048", "2048", "2048", "2048", "2048", "2012", "2013", "2022", "2079", "2097", "2098", "2012", "2013", "2022", "2079", "2097", "2098", "2012", "2013", "2022", "2079", "2097", "2098", "2034", "2031", "2094", "2013", "2058"]}
UNKNOWN
PYTHON3
CODEFORCES
202
e1d1777c58d7782a80342ff92b03a1c9
Zublicanes and Mumocrates
It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The election campaigns of both parties include numerous demonstrations on *n* main squares of the capital of Berland. Each of the *n* squares certainly can have demonstrations of only one party, otherwise it could lead to riots. On the other hand, both parties have applied to host a huge number of demonstrations, so that on all squares demonstrations must be held. Now the capital management will distribute the area between the two parties. Some pairs of squares are connected by (*n*<=-<=1) bidirectional roads such that between any pair of squares there is a unique way to get from one square to another. Some squares are on the outskirts of the capital meaning that they are connected by a road with only one other square, such squares are called dead end squares. The mayor of the capital instructed to distribute all the squares between the parties so that the dead end squares had the same number of demonstrations of the first and the second party. It is guaranteed that the number of dead end squares of the city is even. To prevent possible conflicts between the zublicanes and the mumocrates it was decided to minimize the number of roads connecting the squares with the distinct parties. You, as a developer of the department of distributing squares, should determine this smallest number. The first line of the input contains a single integer *n* (2<=≤<=*n*<=≤<=5000) — the number of squares in the capital of Berland. Next *n*<=-<=1 lines contain the pairs of integers *x*,<=*y* (1<=≤<=*x*,<=*y*<=≤<=*n*,<=*x*<=≠<=*y*) — the numbers of the squares connected by the road. All squares are numbered with integers from 1 to *n*. It is guaranteed that the number of dead end squares of the city is even. Print a single number — the minimum number of roads connecting the squares with demonstrations of different parties. Sample Input 8 1 4 2 4 3 4 6 5 7 5 8 5 4 5 5 1 2 1 3 1 4 1 5 Sample Output 1 2
[ "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\ndef make_graph(n, m):\r\n x, s = [0] * (2 * m), [0] * (n + 3)\r\n for i in range(0, 2 * m, 2):\r\n u, v = map(int, input().split())\r\n s[u + 2] += 1\r\n s[v + 2] += 1\r\n x[i], x[i + 1] = u, v\r\n for i in range(3, n + 3):\r\n s[i] += s[i - 1]\r\n G = [0] * (2 * m)\r\n for i in range(2 * m):\r\n j = x[i] + 1\r\n G[s[j]] = x[i ^ 1]\r\n s[j] += 1\r\n return G, s\r\n\r\ndef bfs(s):\r\n q = [s]\r\n dist = [inf] * (n + 1)\r\n dist[s] = 0\r\n for k in range(n):\r\n i = q[k]\r\n di = dist[i]\r\n for v in range(s0[i], s0[i + 1]):\r\n j = G[v]\r\n if dist[j] == inf:\r\n q.append(j)\r\n dist[j] = di + 1\r\n return q, dist\r\n\r\nn = int(input())\r\nG, s0 = make_graph(n, n - 1)\r\nif n == 2:\r\n ans = 1\r\n print(ans)\r\n exit()\r\nfor i in range(1, n + 1):\r\n if not s0[i + 1] - s0[i] == 1:\r\n s = i\r\n break\r\ninf = pow(10, 9) + 1\r\np, dist = bfs(s)\r\ndp = [[] for _ in range(n + 1)]\r\ncnt = [0] * (n + 1)\r\nfor i in p[::-1]:\r\n if s0[i + 1] - s0[i] == 1:\r\n dp[i] = [inf, 0]\r\n cnt[i] = 1\r\n continue\r\n x = []\r\n for v in range(s0[i], s0[i + 1]):\r\n j = G[v]\r\n if dist[i] < dist[j]:\r\n cnt[i] += cnt[j]\r\n x.append(j)\r\n dpi, m = [0], 0\r\n for j in x:\r\n dpj = dp[j]\r\n l = cnt[j]\r\n m += l\r\n dp0 = [inf] * (m + 1)\r\n for u in range(m - l + 1):\r\n dpiu = dpi[u]\r\n for v in range(l + 1):\r\n dp0[u + v] = min(dp0[u + v], dpiu + dpj[v], dpiu + dpj[l - v] + 1)\r\n dpi = dp0\r\n dp[i] = list(dpi)\r\nans = dp[s][cnt[s] >> 1]\r\nprint(ans)" ]
{"inputs": ["8\n1 4\n2 4\n3 4\n6 5\n7 5\n8 5\n4 5", "5\n1 2\n1 3\n1 4\n1 5", "11\n1 7\n2 1\n2 9\n6 2\n7 10\n1 3\n5 2\n3 8\n8 11\n2 4", "20\n2 18\n15 18\n18 4\n4 20\n20 6\n8 6\n1 8\n9 6\n11 9\n11 12\n19 4\n3 9\n9 7\n7 13\n10 3\n16 20\n1 5\n5 17\n10 14", "11\n9 2\n9 4\n8 9\n7 9\n3 9\n5 9\n6 9\n10 9\n1 9\n11 9", "15\n4 12\n1 12\n1 6\n9 1\n7 4\n12 5\n15 9\n11 1\n13 9\n14 9\n9 2\n3 5\n10 2\n3 8", "16\n15 6\n5 9\n3 15\n9 11\n7 15\n1 2\n14 6\n8 9\n14 12\n10 16\n3 13\n8 1\n3 1\n9 4\n10 1", "17\n15 6\n2 8\n15 2\n8 3\n16 4\n13 7\n11 5\n10 1\n2 12\n16 8\n12 9\n11 8\n1 8\n5 17\n13 11\n14 13", "18\n5 7\n3 9\n16 17\n18 13\n3 15\n3 18\n17 11\n12 8\n1 2\n5 16\n17 4\n1 4\n8 1\n6 5\n4 18\n10 5\n14 17", "19\n3 19\n13 19\n11 6\n15 19\n7 14\n12 18\n8 16\n7 4\n11 12\n7 10\n11 14\n2 17\n9 7\n3 11\n2 7\n1 7\n16 2\n5 17", "21\n3 19\n3 17\n4 3\n11 3\n3 16\n8 3\n7 3\n3 21\n3 9\n13 3\n18 3\n12 3\n3 1\n10 3\n3 5\n3 20\n3 14\n3 2\n6 3\n3 15", "21\n7 8\n20 7\n7 6\n14 7\n3 7\n7 19\n7 9\n2 7\n4 7\n16 7\n7 5\n7 13\n7 10\n15 7\n7 11\n7 17\n7 21\n18 7\n7 1\n7 12", "23\n3 9\n9 15\n9 19\n10 9\n9 4\n9 8\n1 9\n9 6\n9 21\n9 18\n20 9\n9 13\n9 23\n14 9\n5 9\n12 9\n9 16\n2 9\n11 9\n17 9\n7 9\n22 9", "23\n15 6\n15 23\n15 10\n11 15\n15 19\n15 7\n12 15\n15 8\n4 15\n22 15\n20 15\n17 15\n3 15\n15 13\n21 15\n15 16\n9 15\n5 15\n14 15\n1 15\n15 18\n2 15"], "outputs": ["1", "2", "2", "1", "5", "1", "2", "2", "1", "2", "10", "10", "11", "11"]}
UNKNOWN
PYTHON3
CODEFORCES
1
e24711b2b5950e08097da53153bb27f7
Curfew
Instructors of Some Informatics School make students go to bed. The house contains *n* rooms, in each room exactly *b* students were supposed to sleep. However, at the time of curfew it happened that many students are not located in their assigned rooms. The rooms are arranged in a row and numbered from 1 to *n*. Initially, in *i*-th room there are *a**i* students. All students are currently somewhere in the house, therefore *a*1<=+<=*a*2<=+<=...<=+<=*a**n*<==<=*nb*. Also 2 instructors live in this house. The process of curfew enforcement is the following. One instructor starts near room 1 and moves toward room *n*, while the second instructor starts near room *n* and moves toward room 1. After processing current room, each instructor moves on to the next one. Both instructors enter rooms and move simultaneously, if *n* is odd, then only the first instructor processes the middle room. When all rooms are processed, the process ends. When an instructor processes a room, she counts the number of students in the room, then turns off the light, and locks the room. Also, if the number of students inside the processed room is not equal to *b*, the instructor writes down the number of this room into her notebook (and turns off the light, and locks the room). Instructors are in a hurry (to prepare the study plan for the next day), so they don't care about who is in the room, but only about the number of students. While instructors are inside the rooms, students can run between rooms that are not locked and not being processed. A student can run by at most *d* rooms, that is she can move to a room with number that differs my at most *d*. Also, after (or instead of) running each student can hide under a bed in a room she is in. In this case the instructor will not count her during the processing. In each room any number of students can hide simultaneously. Formally, here is what's happening: - A curfew is announced, at this point in room *i* there are *a**i* students. - Each student can run to another room but not further than *d* rooms away from her initial room, or stay in place. After that each student can optionally hide under a bed. - Instructors enter room 1 and room *n*, they count students there and lock the room (after it no one can enter or leave this room). - Each student from rooms with numbers from 2 to *n*<=-<=1 can run to another room but not further than *d* rooms away from her current room, or stay in place. Each student can optionally hide under a bed. - Instructors move from room 1 to room 2 and from room *n* to room *n*<=-<=1. - This process continues until all rooms are processed. Let *x*1 denote the number of rooms in which the first instructor counted the number of non-hidden students different from *b*, and *x*2 be the same number for the second instructor. Students know that the principal will only listen to one complaint, therefore they want to minimize the maximum of numbers *x**i*. Help them find this value if they use the optimal strategy. The first line contains three integers *n*, *d* and *b* (2<=≤<=*n*<=≤<=100<=000, 1<=≤<=*d*<=≤<=*n*<=-<=1, 1<=≤<=*b*<=≤<=10<=000), number of rooms in the house, running distance of a student, official number of students in a room. The second line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=109), *i*-th of which stands for the number of students in the *i*-th room before curfew announcement. It is guaranteed that *a*1<=+<=*a*2<=+<=...<=+<=*a**n*<==<=*nb*. Output one integer, the minimal possible value of the maximum of *x**i*. Sample Input 5 1 1 1 0 0 0 4 6 1 2 3 8 0 1 0 0 Sample Output 1 2
[ "read = lambda: map(int, input().split())\r\nn, d, b = read()\r\nd += 1\r\nt, a = 0, [0] * (n + 1)\r\nfor i, x in enumerate(read()):\r\n t += x\r\n a[i + 1] = t\r\nprint(max(i - min(a[min(n, i * d)], (a[n] - a[max(0, n - i * d)])) // b for i in range(n + 3 >> 1)))" ]
{"inputs": ["5 1 1\n1 0 0 0 4", "6 1 2\n3 8 0 1 0 0", "5 1 1\n1 1 0 3 0", "5 1 1\n4 0 0 1 0", "2 1 1\n0 2", "100 66 30\n0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25 27 15 53 29 56 30 24 50 39 39 46 4 14 44 16 55 48 15 54 25 4 44 15 29 55 22 49 52 9 2 22 15 14 33 24 38 11 48 27 34 29 8 37 47 36 54 45 24 31 1434", "100 2 1\n0 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 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 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 0 0 0 0 0 4 3 1 2 8 5 1 9 1 2 12 7 5 0 7 2 11 3 17", "100 3 1\n5 8 5 7 1 2 6 4 3 2 3 2 5 4 0 5 6 0 2 0 2 3 2 3 3 2 4 2 1 1 2 2 3 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "39 1 1\n0 1 2 0 0 1 1 1 0 1 2 2 2 0 0 2 2 0 0 1 1 2 0 1 0 2 1 0 2 2 1 0 0 3 2 0 1 2 1", "39 3 1\n0 1 1 0 0 2 0 1 3 1 1 1 0 0 1 1 0 0 2 0 1 1 0 1 0 1 2 3 1 0 0 0 0 5 2 0 4 3 0", "50 1 1\n2 0 0 0 2 4 1 0 1 2 2 1 0 0 1 2 0 0 1 2 0 0 0 1 1 0 0 2 1 1 2 0 4 2 0 0 2 2 1 1 1 4 0 0 0 2 0 0 1 1", "50 2 1\n0 1 1 1 1 1 1 0 2 2 0 0 1 1 2 0 1 0 1 2 0 1 1 0 1 2 3 0 0 1 0 3 1 1 1 1 1 1 3 0 0 0 2 0 2 2 0 3 2 0", "100 10 1\n0 0 0 0 1 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 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 97 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "100 4 1\n0 0 0 0 0 0 0 0 0 1 1 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 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 90 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0", "100 66 1\n0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 1 0 0 1 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 0 0 1 74", "100 1 1\n0 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 2 4 8 1 5 4 4 3 1 2 3 8 18 15 4 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "100 1 1\n0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 6 3 4 2 6 3 4 5 2 5 0 0 0 0 0 0 0 0 0 1 3 5 6 3 1 2 5 1 1 2 0 0 0 0 0 0 0 0 0 3 5 0 0 1 2 2 1 5 7", "30 1 30\n61 4 40 32 23 35 2 87 20 0 57 21 30 7 16 34 38 18 0 51 61 9 41 22 15 43 47 15 23 48", "30 2 25\n21 17 30 1 11 13 5 33 21 36 16 54 4 18 28 41 9 42 14 19 39 55 20 4 15 53 13 78 23 17", "30 3 30\n19 0 64 36 55 24 8 2 6 20 28 58 53 53 56 72 37 7 1 4 96 13 20 51 15 4 13 33 40 12", "100 2 25\n23 47 16 0 81 70 6 4 31 26 56 58 33 34 23 141 24 18 7 7 2 13 15 8 34 115 7 30 6 7 14 62 3 0 7 73 4 7 5 35 17 26 34 33 12 3 23 27 3 40 2 5 10 10 4 56 50 36 4 14 22 17 7 13 22 85 30 7 10 28 60 35 3 27 0 3 7 52 12 10 74 14 56 54 17 1 50 11 23 2 71 31 11 5 9 10 13 7 16 14", "100 3 30\n20 10 8 3 97 20 40 4 58 24 105 56 26 21 66 1 126 4 21 46 8 2 9 21 0 13 24 53 58 23 3 107 1 22 189 3 31 4 31 0 3 0 9 43 19 74 92 7 71 22 46 26 31 49 18 3 10 9 9 110 30 2 40 21 33 4 11 14 47 4 1 37 3 19 18 63 10 53 19 35 11 57 8 3 11 27 23 5 45 15 127 27 23 48 3 8 20 33 5 28", "100 99 15\n0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30", "100 1 17\n0 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 0 0 0 0 56 47 53 49 41 42 52 56 61 42 97 52 55 55 39 54 57 53 67 43 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 22 25 23 27 42 24 28 15 19 19 0 0 0 0 0 0 0 0 0 29 28 33 27 22 25 25 30 31 61", "100 1 24\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 151 150 159 159 147 121 143 143 138 138 127 127 128 123 159 159 128 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "100 5 30\n2 5 2 4 5 2 5 6 6 4 3 6 7 1 3 4 1 6 1 3 4 3 5 3 1 5 1 2 0 5 1 0 4 3 2 7 3 3 1 2 3 1 4 1 1 2 1 3 2 4 0 4 2706 4 1 4 3 7 4 4 4 2 1 7 3 1 4 4 2 5 2 2 2 0 1 2 2 6 3 5 2 5 3 0 3 0 6 2 4 1 4 4 4 3 1 2 4 1 1 2", "100 5 30\n1 1 1 1 1 0 1 1 1 2 0 2 1 0 0 1 0 0 0 0 1 0 2 0 0 1 0 0 2 1 0 1 2 1 2 3 1 1 1 1 0 0 2 1 0 1 1 1 1 0 0 1 0 0 1 0 2 0 2911 2 2 1 3 3 1 2 2 1 1 0 0 2 0 3 1 1 2 0 1 0 0 0 0 1 0 1 1 1 3 1 3 1 0 1 0 0 0 1 2 0"], "outputs": ["1", "2", "0", "1", "0", "0", "27", "16", "0", "0", "0", "0", "4", "7", "0", "32", "25", "0", "0", "0", "0", "0", "0", "15", "33", "4", "8"]}
UNKNOWN
PYTHON3
CODEFORCES
1
e252f37a5a13caef34246bf269d2c655
Broken BST
Let *T* be arbitrary binary tree — tree, every vertex of which has no more than two children. Given tree is rooted, so there exists only one vertex which doesn't have a parent — it's the root of a tree. Every vertex has an integer number written on it. Following algorithm is run on every value from the tree *T*: 1. Set pointer to the root of a tree. 1. Return success if the value in the current vertex is equal to the number you are looking for 1. Go to the left child of the vertex if the value in the current vertex is greater than the number you are looking for 1. Go to the right child of the vertex if the value in the current vertex is less than the number you are looking for 1. Return fail if you try to go to the vertex that doesn't exist Here is the pseudo-code of the described algorithm: The described algorithm works correctly if the tree is binary search tree (i.e. for each node the values of left subtree are less than the value in the node, the values of right subtree are greater than the value in the node). But it can return invalid result if tree is not a binary search tree. Since the given tree is not necessarily a binary search tree, not all numbers can be found this way. Your task is to calculate, how many times the search will fail being running on every value from the tree. If the tree has multiple vertices with the same values on them then you should run algorithm on every one of them separately. First line contains integer number *n* (1<=≤<=*n*<=≤<=105) — number of vertices in the tree. Each of the next *n* lines contains 3 numbers *v*, *l*, *r* (0<=≤<=*v*<=≤<=109) — value on current vertex, index of the left child of the vertex and index of the right child of the vertex, respectively. If some child doesn't exist then number <=-<=1 is set instead. Note that different vertices of the tree may contain the same values. Print number of times when search algorithm will fail. Sample Input 3 15 -1 -1 10 1 3 5 -1 -1 8 6 2 3 3 4 5 12 6 7 1 -1 8 4 -1 -1 5 -1 -1 14 -1 -1 2 -1 -1 Sample Output 2 1
[ "from sys import stdin\r\ninput=lambda :stdin.readline()[:-1]\r\n\r\nn=int(input())\r\npar=[-1]*n\r\nleft=[-1]*n\r\nright=[-1]*n\r\na=[0]*n\r\nfor i in range(n):\r\n v,l,r=map(int,input().split())\r\n a[i]=v\r\n l-=1\r\n r-=1\r\n if l!=-2:\r\n par[l]=i\r\n left[i]=l\r\n if r!=-2:\r\n par[r]=i\r\n right[i]=r\r\n\r\nroot=-1\r\nfor i in range(n):\r\n if par[i]==-1:\r\n root=i\r\n\r\nok=set()\r\ntodo=[(root,0,10**9+10)]\r\nwhile todo:\r\n v,L,R=todo.pop()\r\n if L>R:\r\n continue\r\n if L<=a[v]<=R:\r\n ok.add(a[v])\r\n if left[v]!=-1:\r\n todo.append((left[v],L,min(R,a[v]-1)))\r\n if right[v]!=-1:\r\n todo.append((right[v],max(a[v]+1,L),R))\r\n\r\nans=n\r\nfor i in a:\r\n if i in ok:\r\n ans-=1\r\n\r\nprint(ans)", "from collections import defaultdict, deque\r\nimport sys\r\nn = int(input())\r\na = [[]] * (n + 1)\r\ncnt = defaultdict(int)\r\nhasParent = [False] * (n + 2)\r\nfor i in range(n):\r\n val, l, r = list(map(int, input().split()))\r\n a[i+1] = [val, l, r]\r\n cnt[val] += 1\r\n hasParent[l + 1] = True\r\n hasParent[r + 1] = True\r\nroot = 1\r\nwhile hasParent[root+1]:\r\n root += 1\r\n\r\nans = n\r\nq = deque([(root, 0, 10 ** 9)])\r\nwhile q:\r\n i, l, r = q.popleft()\r\n if i < 0: continue \r\n oV, oL, oR = a[i]\r\n if l <= oV and oV <= r:\r\n ans -= cnt[oV]\r\n if l < oV:\r\n q.append((oL, l, min(r, oV - 1)))\r\n if r > oV:\r\n q.append((oR, max(l, oV + 1), r))\r\n \r\nprint(ans)", "from collections import defaultdict, deque\nimport sys\ninput = sys.stdin.readline\n\ndef bfs(x):\n q = deque()\n q.append((x, -inf, inf))\n while q:\n i, l, r = q.popleft()\n ci = c[i]\n if l <= ci <= r:\n ok[ci] = 1\n l0, r0 = G[i]\n if not l0 == -1:\n q.append((l0, l, min(r, ci - 1)))\n if not r0 == -1:\n q.append((r0, max(l, ci), r))\n return\n\nn = int(input())\nG = [()]\nc = [-1]\ns = set()\nfor i in range(1, n + 1):\n v, l, r = map(int, input().split())\n G.append((l, r))\n c.append(v)\n s.add(l)\n s.add(r)\nfor i in range(1, n + 1):\n if not i in s:\n x = i\n break\nok = defaultdict(lambda : 0)\ninf = pow(10, 9) + 7\nbfs(x)\nans = 0\nfor i in range(1, n + 1):\n if not ok[c[i]]:\n ans += 1\nprint(ans)\n\t \t\t \t\t\t \t\t \t\t \t\t \t \t \t \t\t", "import re\r\nimport functools\r\nimport random\r\nimport sys\r\nimport os\r\nimport math\r\nfrom collections import Counter, defaultdict, deque\r\nfrom functools import lru_cache, reduce, cmp_to_key\r\nfrom itertools import accumulate, combinations, permutations\r\nfrom heapq import nsmallest, nlargest, heappushpop, heapify, heappop, heappush\r\nfrom io import BytesIO, IOBase\r\nfrom copy import deepcopy\r\nimport threading\r\nfrom typing import *\r\nfrom operator import add, xor, mul, ior, iand, itemgetter\r\nimport bisect\r\nBUFSIZE = 4096\r\ninf = float('inf')\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 = IOWrapper(sys.stdin)\r\nsys.stdout = IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\ndef I():\r\n return input()\r\n\r\ndef II():\r\n return int(input())\r\n\r\ndef MII():\r\n return map(int, input().split())\r\n\r\ndef LI():\r\n return list(input().split())\r\n\r\ndef LII():\r\n return list(map(int, input().split()))\r\n\r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n\r\ndef LGMI():\r\n return list(map(lambda x: int(x) - 1, input().split()))\r\n\r\nfrom types import GeneratorType\r\ndef bootstrap(f, stack=[]):\r\n def wrappedfunc(*args, **kwargs):\r\n if stack:\r\n return f(*args, **kwargs)\r\n else:\r\n to = f(*args, **kwargs)\r\n while True:\r\n if type(to) is GeneratorType:\r\n stack.append(to)\r\n to = next(to)\r\n else:\r\n stack.pop()\r\n if not stack:\r\n break\r\n to = stack[-1].send(to)\r\n return to\r\n return wrappedfunc\r\n\r\nclass Tree:\r\n def __init__(self, data, left=None, right=None):\r\n self.data = data\r\n self.left = left\r\n self.right = right\r\n\r\nn = II()\r\nnodes = []\r\ninv = [0] * n\r\nfor _ in range(n):\r\n v, l, r = MII()\r\n if l > 0: l -= 1; inv[l] += 1\r\n if r > 0: r -= 1; inv[r] += 1\r\n nodes.append([v, l, r])\r\nroot = -1\r\nfor i in range(n):\r\n if inv[i] == 0: root = i\r\ntree = Tree(nodes[root][0])\r\n\r\n@bootstrap\r\ndef dfs(idx, tree):\r\n if nodes[idx][1] != -1:\r\n left_idx = nodes[idx][1]\r\n tree.left = Tree(nodes[left_idx][0])\r\n yield dfs(left_idx, tree.left)\r\n if nodes[idx][2] != -1:\r\n right_idx = nodes[idx][2]\r\n tree.right = Tree(nodes[right_idx][0])\r\n yield dfs(right_idx, tree.right)\r\n yield\r\n\r\ndfs(root, tree)\r\n\r\ntmp = []\r\n@bootstrap\r\ndef getRange(node, minimum, maximum):\r\n if minimum <= node.data <= maximum: tmp.append(node.data)\r\n if node.left: yield getRange(node.left, minimum, min(maximum, node.data - 1))\r\n if node.right: yield getRange(node.right, max(minimum, node.data + 1), maximum)\r\n yield\r\n\r\ngetRange(tree, -inf, inf)\r\nsearched = set(sorted(tmp))\r\n\r\nans = 0\r\nfor num, l, r in nodes:\r\n if num not in searched:\r\n ans += 1\r\nprint(ans)", "from collections import Counter, deque\r\nfrom math import inf\r\n\r\n\r\nclass TreeNode:\r\n def __init__(self, val, left=None, right=None):\r\n self.val = val\r\n self.left = left\r\n self.right = right\r\n\r\n\r\nn = int(input())\r\nnodes = [TreeNode(-1) for _ in range(n)]\r\nhas_fa = [0] * n\r\ncnt = Counter()\r\nfor i in range(n):\r\n v, l, r = map(int, input().split())\r\n nodes[i].val = v\r\n cnt[v] += 1\r\n if l > 0:\r\n l -= 1\r\n has_fa[l] = 1\r\n nodes[i].left = nodes[l]\r\n if r > 0:\r\n r -= 1\r\n has_fa[r] = 1\r\n nodes[i].right = nodes[r]\r\n\r\nroot_idx = has_fa.index(0)\r\nroot = nodes[root_idx]\r\nq = deque([(root, -inf, inf)])\r\nres = n\r\nwhile q:\r\n node, mi, mx = q.popleft()\r\n x = node.val\r\n if mi <= x <= mx:\r\n res -= cnt[x]\r\n if node.left:\r\n q.append((node.left, mi, min(x - 1, mx)))\r\n if node.right:\r\n q.append((node.right, max(x + 1, mi), mx))\r\nprint(res)\r\n", "from collections import Counter\r\nfrom math import inf\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 return wrappedfunc\r\n\r\n\r\nclass TreeNode:\r\n def __init__(self, val, left=None, right=None):\r\n self.val = val\r\n self.left = left\r\n self.right = right\r\n\r\n\r\nn = int(input())\r\nnodes = []\r\nhas_fa = [0] * n\r\ncnt = Counter()\r\nfor _ in range(n):\r\n v, left_idx, right_idx = map(int, input().split())\r\n cnt[v] += 1\r\n if left_idx > 0:\r\n left_idx -= 1\r\n has_fa[left_idx] = 1\r\n if right_idx > 0:\r\n right_idx -= 1\r\n has_fa[right_idx] = 1\r\n nodes.append([v, left_idx, right_idx])\r\nroot_idx = has_fa.index(0)\r\nroot = TreeNode(nodes[root_idx][0])\r\n\r\n\r\n@bootstrap\r\ndef build(idx, node):\r\n if nodes[idx][1] != -1:\r\n left_idx = nodes[idx][1]\r\n node.left = TreeNode(nodes[left_idx][0])\r\n yield build(left_idx, node.left)\r\n if nodes[idx][2] != -1:\r\n right_idx = nodes[idx][2]\r\n node.right = TreeNode(nodes[right_idx][0])\r\n yield build(right_idx, node.right)\r\n yield\r\n\r\n\r\nbuild(root_idx, root)\r\ns = set()\r\n\r\n\r\n@bootstrap\r\ndef dfs(node, mi, mx):\r\n x = node.val\r\n if mi <= x <= mx:\r\n # global res\r\n # res -= cnt[x]\r\n s.add(x)\r\n if node.left:\r\n yield dfs(node.left, mi, min(x-1, mx))\r\n if node.right:\r\n yield dfs(node.right, max(x+1, mi), mx)\r\n yield\r\n\r\n\r\ndfs(root, -inf, inf)\r\nres = 0\r\nfor x, _, _ in nodes:\r\n if x not in s:\r\n res += 1\r\nprint(res)\r\n", "from collections import defaultdict, deque\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\ndef bfs(x):\r\n q = deque()\r\n q.append((x, -inf, inf))\r\n while q:\r\n i, l, r = q.popleft()\r\n ci = c[i]\r\n if l <= ci <= r:\r\n ok[ci] = 1\r\n l0, r0 = G[i]\r\n if not l0 == -1:\r\n q.append((l0, l, min(r, ci - 1)))\r\n if not r0 == -1:\r\n q.append((r0, max(l, ci), r))\r\n return\r\n\r\nn = int(input())\r\nG = [()]\r\nc = [-1]\r\ns = set()\r\nfor i in range(1, n + 1):\r\n v, l, r = map(int, input().split())\r\n G.append((l, r))\r\n c.append(v)\r\n s.add(l)\r\n s.add(r)\r\nfor i in range(1, n + 1):\r\n if not i in s:\r\n x = i\r\n break\r\nok = defaultdict(lambda : 0)\r\ninf = pow(10, 9) + 7\r\nbfs(x)\r\nans = 0\r\nfor i in range(1, n + 1):\r\n if not ok[c[i]]:\r\n ans += 1\r\nprint(ans)", "# Problem: D. Broken BST\r\n# Contest: Codeforces - Educational Codeforces Round 19\r\n# URL: https://codeforces.com/contest/797/problem/D\r\n# Memory Limit: 256 MB\r\n# Time Limit: 1000 ms\r\n\r\nimport sys\r\nimport bisect\r\nimport random\r\nimport io, os\r\nfrom bisect import *\r\nfrom collections import *\r\nfrom contextlib import redirect_stdout\r\nfrom itertools import *\r\nfrom array import *\r\nfrom functools import lru_cache\r\nfrom types import GeneratorType\r\nfrom heapq import *\r\nfrom math import sqrt, gcd, inf\r\n\r\nif sys.version >= '3.8': # ACW没有comb\r\n from math import comb\r\n\r\nRI = lambda: map(int, sys.stdin.buffer.readline().split())\r\nRS = lambda: map(bytes.decode, sys.stdin.buffer.readline().strip().split())\r\nRILST = lambda: list(RI())\r\nDEBUG = lambda *x: sys.stderr.write(f'{str(x)}\\n')\r\n\r\nMOD = 10 ** 9 + 7\r\nPROBLEM = \"\"\"https://codeforces.com/contest/797/problem/D\r\n\r\n输入 n(1≤n≤1e5) 和一棵二叉树的 n 个节点,每行输入 x l r,对应节点值 [0,1e9] 和左右儿子的编号 [1,n],如果没有则为 -1。\r\n输入保证恰好有一个节点没有父节点,即根节点。\r\n\r\n如下是一个在二叉搜索树中查找元素的伪代码:\r\nbool find(TreeNode t, int x) {\r\n if (t == null)\r\n return false;\r\n if (t.value == x)\r\n return true;\r\n if (x < t.value)\r\n return find(t.left, x);\r\n else\r\n return find(t.right, x);\r\n}\r\nfind(root, x);\r\n\r\n把二叉树的每个节点值应用上述代码,输出你会得到多少次 false。\r\n注意节点值可能有重复的。\r\n输入\r\n3\r\n15 -1 -1\r\n10 1 3\r\n5 -1 -1\r\n输出 2\r\n解释 5 和 15 是找不到的\r\n\"\"\"\r\n\"\"\"https://codeforces.com/contest/797/submission/190439455\r\n\r\n考虑有多少个节点值可以找到。\r\n参考 https://www.bilibili.com/video/BV14G411P7C1/ 的方法一,把合法查询范围作为递归参数传下去。\r\n如果节点值 x 在范围内,则有 cnt[x] 个 x 可以找到。\r\n\r\n注:用 cnt 是因为有重复的节点,这些节点值都可以找到(即使某些节点无法访问到)。\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# ms\r\ndef solve():\r\n n, = RI()\r\n a = []\r\n has_fa = [False] * n\r\n cnt = Counter()\r\n for i in range(n):\r\n v, l, r = RI()\r\n l -= 1\r\n r -= 1\r\n cnt[v] += 1\r\n a.append((v, l, r))\r\n if l >= 0:\r\n has_fa[l] = True\r\n if r >= 0:\r\n has_fa[r] = True\r\n root = 0\r\n while has_fa[root]:\r\n root += 1\r\n ans = n\r\n q = deque([(root, 0, 10 ** 9)])\r\n while q:\r\n i, l, r = q.popleft()\r\n v, x, y = a[i]\r\n if l <= v <= r:\r\n ans -= cnt[v]\r\n if l < v and x >= 0:\r\n q.append((x, l, min(r, v - 1)))\r\n if r > v and y >= 0:\r\n q.append((y, max(l, v + 1), r))\r\n print(ans)\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()\r\n" ]
{"inputs": ["3\n15 -1 -1\n10 1 3\n5 -1 -1", "8\n6 2 3\n3 4 5\n12 6 7\n1 -1 8\n4 -1 -1\n5 -1 -1\n14 -1 -1\n2 -1 -1", "1\n493041212 -1 -1", "10\n921294733 5 9\n341281094 -1 -1\n35060484 10 -1\n363363160 -1 -1\n771156014 6 8\n140806462 -1 -1\n118732846 4 2\n603229555 -1 -1\n359289513 3 7\n423237010 -1 -1", "10\n911605217 -1 -1\n801852416 -1 -1\n140035920 -1 9\n981454947 10 2\n404988051 6 3\n307545107 8 7\n278188888 4 1\n523010786 -1 -1\n441817740 -1 -1\n789680429 -1 -1", "10\n921072710 6 8\n727122964 -1 -1\n248695736 2 -1\n947477665 -1 -1\n41229309 -1 -1\n422047611 3 9\n424558429 -1 4\n665046372 -1 5\n74510531 -1 -1\n630373520 7 1", "1\n815121916 -1 -1", "1\n901418150 -1 -1", "3\n2 -1 -1\n1 1 3\n2 -1 -1", "4\n20 2 3\n16 4 -1\n20 -1 -1\n20 -1 -1", "3\n2 2 3\n1 -1 -1\n1 -1 -1", "4\n7122 2 3\n87 4 -1\n7122 -1 -1\n7122 -1 -1", "4\n712222 2 3\n98887 4 -1\n712222 -1 -1\n712222 -1 -1", "3\n6 2 3\n5 -1 -1\n5 -1 -1", "4\n1 -1 2\n0 3 -1\n100 -1 4\n1 -1 -1", "4\n98 2 3\n95 4 -1\n98 -1 -1\n98 -1 -1", "3\n15 2 3\n1 -1 -1\n1 -1 -1", "4\n6 2 -1\n6 3 4\n6 -1 -1\n7 -1 -1", "3\n2 2 3\n3 -1 -1\n3 -1 -1", "4\n1 -1 2\n0 3 -1\n1 -1 4\n0 -1 -1", "4\n1 2 3\n2 -1 -1\n3 4 -1\n2 -1 -1", "1\n0 -1 -1", "3\n5 2 -1\n6 -1 3\n5 -1 -1", "10\n2 -1 -1\n1 -1 8\n2 4 9\n5 -1 2\n5 7 6\n1 -1 1\n4 -1 -1\n0 -1 -1\n8 5 10\n5 -1 -1", "8\n6 -1 -1\n0 5 -1\n4 6 7\n3 -1 -1\n4 3 1\n1 -1 -1\n2 8 4\n2 -1 -1", "4\n5 3 -1\n1 4 -1\n3 -1 2\n1 -1 -1", "3\n10 2 3\n5 -1 -1\n5 -1 -1"], "outputs": ["2", "1", "0", "7", "7", "7", "0", "0", "0", "0", "0", "0", "0", "0", "2", "0", "0", "1", "0", "2", "0", "0", "1", "3", "7", "2", "0"]}
UNKNOWN
PYTHON3
CODEFORCES
8
e2626de63784e9b7531e6074e35aabfc
k-Tree
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,<=2,<=3,<=...,<=*k*. The picture below shows a part of a 3-tree. Help Dima find an answer to his question. As the number of ways can be rather large, print it modulo 1000000007 (109<=+<=7). A single line contains three space-separated integers: *n*, *k* and *d* (1<=≤<=*n*,<=*k*<=≤<=100; 1<=≤<=*d*<=≤<=*k*). Print a single integer — the answer to the problem modulo 1000000007 (109<=+<=7). Sample Input 3 3 2 3 3 3 4 3 2 4 5 2 Sample Output 3 1 6 7
[ "#author: sushmanth\r\n\r\nfrom sys import stdin\r\ninput = stdin.readline\r\n\r\ninp = lambda : list(map(int,input().split()))\r\n\r\nmod = (10 ** 9) + 7\r\ndef answer():\r\n\r\n dp = [[0 , 0] for i in range(n + 1)]\r\n dp[0][0] = 1\r\n\r\n for i in range(1 , n + 1):\r\n\r\n for j in range(k , 0 , -1):\r\n if(i - j < 0):continue\r\n if(j < d):\r\n dp[i][0] += dp[i - j][0]\r\n dp[i][0] %= mod\r\n else:\r\n dp[i][1] += dp[i - j][0]\r\n dp[i][1] %= mod\r\n\r\n dp[i][1] += dp[i - j][1]\r\n dp[i][1] %= mod\r\n\r\n\r\n return dp[n][1]\r\n\r\nfor T in range(1):\r\n\r\n n , k , d = inp()\r\n\r\n print(answer())\r\n \r\n\r\n \r\n \r\n\r\n \r\n", "dp = []\r\nmod = 1000000007\r\n\r\ndef main():\r\n n, k, d = input().split()\r\n n = int(n)\r\n k = int(k)\r\n d = int(d)\r\n dp.append(1)\r\n\r\n for i in range(1, n+1):\r\n dp.append(0)\r\n sup = 1\r\n while i - sup >= 0 and sup <= k:\r\n dp[i] += dp[i - sup]\r\n sup = sup+1\r\n\r\n whole = dp[n]\r\n dp[0] = 1\r\n\r\n for i in range(1, n+1):\r\n dp[i] = 0\r\n sup = 1\r\n while i - sup >= 0 and sup <= (d-1):\r\n dp[i] += dp[i - sup]\r\n sup = sup+1\r\n\r\n print((whole-dp[n])%mod)\r\n\r\nmain()", "n,k,d=map(int,input().split())\r\nmod=10**9+7\r\n\r\n\r\nfrom functools import lru_cache\r\n@lru_cache(maxsize=None)\r\ndef calc(x,flag):\r\n if x==0:\r\n return flag\r\n ANS=0\r\n for i in range(1,k+1):\r\n if x>=i:\r\n if i>=d:\r\n ANS+=calc(x-i,1)\r\n else:\r\n ANS+=calc(x-i,flag)\r\n else:\r\n break\r\n return ANS%mod\r\n\r\nprint(calc(n,0))\r\n\r\n", "mod = 1000000007\r\nn, k, d = list(map(int, input().split()))\r\ndp = [0] * 105\r\ndp_take = [0] * 105\r\ndp[0] = 1\r\ndp_take[0] = 1\r\nfor i in range(1, n + 1):\r\n for j in range(i - k, i):\r\n dp[i] = dp[i] + dp[j]\r\n for j in range( i - d + 1, i):\r\n dp_take[i] = dp_take[i] + dp_take[j]\r\nprint((dp[n] - dp_take[n])% mod)", "def 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 = stack.append(f(*args, **kwargs))\r\n while True:\r\n try:\r\n to = stack.append(stack[-1].send(to))\r\n except StopIteration as e:\r\n stack.pop()\r\n to = e.value\r\n if not stack:\r\n break\r\n return to\r\n \r\n return wrappedfunc\r\n \r\n@bootstrap\r\ndef go(curs,ddc):\r\n # print(curs,ddc)\r\n if (curs==n):\r\n if (ddc==1):\r\n return 1 \r\n return 0 \r\n if (curs>n):\r\n return 0 \r\n if (dp[ddc][curs]!=-1):\r\n return dp[ddc][curs] \r\n\r\n c = 0 \r\n for i in range(1,k+1):\r\n if (i>=d):\r\n c+=(yield go(curs+i,ddc|1)) \r\n else:\r\n c+=(yield go(curs+i,ddc)) \r\n dp[ddc][curs]=c%(10**9+7) \r\n return c%(10**9+7) \r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nn,k,d = map(int,input().split()) \r\nans = 0 \r\ndp = [ ] \r\nfor i in range(2):\r\n x = [ ] \r\n for j in range(n+1):\r\n x.append(-1) \r\n dp.append(x) \r\n\r\nprint(go(0,0)) \r\n", "import sys\r\nimport math\r\nimport bisect\r\nimport heapq\r\nimport itertools\r\nfrom itertools import accumulate\r\nfrom sys import stdin,stdout\r\nfrom math import gcd,floor,sqrt,log, ceil,inf\r\nfrom collections import defaultdict, Counter, deque\r\nimport heapq\r\nfrom bisect import bisect_left,bisect_right, insort_left, insort_right\r\nmod=1000000007\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\ndef get_int(): return int(sys.stdin.readline().strip())\r\ndef get_list_strings(): return list(map(str, sys.stdin.readline().strip().split()))\r\n \r\ndef solve():\r\n n,k,d = get_ints()\r\n memo = defaultdict(int)\r\n def dp(target,isd):\r\n if target == 0:\r\n if isd: return 1\r\n else: return 0\r\n state = (target,isd)\r\n if state not in memo:\r\n ans = 0\r\n for i in range(1,k+1):\r\n if i >= d: isd = True\r\n if target - i >=0:\r\n memo[state] += dp(target-i,isd) % mod\r\n\r\n return memo[state] % mod\r\n return dp(n,False) % mod\r\n \r\n\r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\nif __name__ == \"__main__\":\r\n print(solve())", "import sys\r\nimport math\r\nimport copy\r\nimport itertools\r\nimport bisect\r\nfrom heapq import heappop, heappush, heapify\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\ndef ilst():\r\n return list(map(int,input().split()))\r\n \r\ndef islst():\r\n return list(map(str,input().split()))\r\n \r\ndef inum():\r\n return map(int,input().split())\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\nn,k,d = inum()\r\nmod = 1000000007\r\n\r\ndp = [[0,0] for i in range(n+1)]\r\ndp[0][0] = 1\r\nfor i in range(1,n+1):\r\n for j in range(1,k+1):\r\n if i-j < 0:\r\n break \r\n # dp[i][0] += dp[i-j][0]\r\n\r\n if j >= d:\r\n dp[i][1] += dp[i-j][0]\r\n dp[i][0] += dp[i-j][0]\r\n else:\r\n dp[i][0] += dp[i-j][0]\r\n dp[i][1] += dp[i-j][1]\r\n\r\nprint(dp[n][1]%mod)", "# https://codeforces.com/problemset/problem/431/C\r\n\r\nimport math\r\nimport random\r\nimport heapq\r\n\r\nfrom collections import *\r\nfrom bisect import *\r\nfrom time import *\r\nfrom functools import *\r\n\r\nmod = 1000000007\r\nmemo = [[-1 for _ in range(2)] for _ in range(101)]\r\n\r\ndef solve(n, k, d, flag=0):\r\n\tif memo[n][flag] != -1:\r\n\t\treturn memo[n][flag]\r\n\r\n\tif n == 0 and flag == 1:\r\n\t\treturn 1\r\n\r\n\tif n <= 0:\r\n\t\treturn 0\r\n\r\n\tcount = 0\r\n\tfor i in range(1, k+1):\r\n\t\t# flag = 1 if flag == 1 or i >= d else 0\r\n\t\tcount += solve(n-i, k, d, 1 if flag == 1 or i >= d else 0) % mod\r\n\r\n\tmemo[n][flag] = count % mod\r\n\r\n\treturn memo[n][flag]\r\n\r\nif __name__ == \"__main__\":\r\n\tn, k, d = list(map(int, input().split(\" \")))\r\n\r\n\tprint(solve(n, k, d))", "MOD = 1000000007\nn, k, d = list(map(int, input().split()))\n\ndp = [[0, 0] for _ in range(n + 1)]\ndp[0][0] = 1\n\nfor i in range(1, n + 1):\n for j in range(1, min(i + 1, k + 1)):\n if j < d:\n dp[i][0] += dp[i - j][0]\n dp[i][1] += dp[i - j][1]\n dp[i][0] %= MOD\n else:\n dp[i][1] += dp[i - j][1] + dp[i - j][0]\n dp[i][1] %= MOD\n\nprint(dp[-1][1])\n", "import sys\r\ninput = sys.stdin.readline\r\nnum = 1000000007\r\n\r\nn, k, d = [int(x) for x in input().split()]\r\ndp = [0]*(n+1)\r\n \r\nfor i in range(1, n+1):\r\n if i <= k:\r\n dp[i] = 1\r\n for j in range(1, k+1):\r\n if (i-j) > 0:\r\n dp[i] += dp[i-j]\r\n \r\ndp1 = [0]*(n+1)\r\n\r\n# print(dp1)\r\n \r\nfor i in range(1, n+1):\r\n if ((i <= k) and (i < d)):\r\n dp1[i] = 1\r\n for j in range(1, k+1):\r\n if j >= d:\r\n continue\r\n if (i-j) > 0:\r\n dp1[i] += dp1[i-j]\r\n # print(i, j, '>>', dp1)\r\n \r\n# print(dp1)\r\n# print(dp)\r\nprint((dp[-1] - dp1[-1])%num)\r\n \r\n \r\n", "mod = 10**9 + 7 \r\nn,k,d = list(map(int, input().split()))\r\ndp = [[0] * 2 for _ in range(n + 1)] \r\ndp[0][0] = 1 \r\nfor s in range(1, n + 1):\r\n for x in range(2):\r\n for i in range(1, k + 1):\r\n if s - i < 0:\r\n continue \r\n ch = x \r\n if x == 1:\r\n if i >= d:\r\n ch = 0 \r\n dp[s][x] += dp[s - i][ch] \r\n dp[s][x] %= mod \r\nprint(dp[n][1])\r\n\"\"\"\r\nstate: 1 -> n\r\n \r\nbase case: s < 0: 0 \r\n s == 0: -> \r\n\r\n\"\"\"", "n, k, d = list(map(int,input().split()))\r\nmod = 10 ** 9 + 7\r\n# table[i][0] = sum of all previous terms where i - i2 < k [0]s\r\n# table[i][1] = sum of rest from [0]s + sum of all the previous ones that can be got to in 1 move\r\n# Therefore we can prefix sum each 0s bit and each 1s bit\r\n# dp[0][0] = 1\r\n\r\ndp = [[0,0] for i in range(n+k+1)]\r\ndp[k][0] = 1\r\n\r\nfor i in range(k,n+k+1):\r\n for j in range(1,min(d,n)):\r\n dp[i][0] = (dp[i][0]+dp[i-j][0])%mod\r\n \r\n for j in range(d,min(n,k)+1):\r\n dp[i][1] = (dp[i][1] + dp[i-j][0])%mod\r\n \r\n for j in range(1,min(k,n)+1):\r\n dp[i][1] = (dp[i][1] + dp[i-j][1])%mod\r\nprint(dp[n+k][1])", "MOD = 10**9 + 7\r\n\r\ndef calc(n, mx):\r\n if mx <= 0: return 0\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(1, min(i, mx) + 1):\r\n dp[i] += dp[i - j]\r\n if dp[i] >= MOD:\r\n dp[i] -= MOD\r\n return dp[n]\r\n\r\nn, k, d = map(int, input().split())\r\nprint((calc(n, k) - calc(n, d - 1)) % MOD)", "n,k,d=map(int,input().split())\r\nMOD=10**9+7\r\ndef f(s,mx):\r\n dp=[1]*(s+1)\r\n for i in range(1,s+1):\r\n dp[i]=sum(dp[max(0,i-mx):i])\r\n return dp[s]\r\n\r\nprint((f(n,k)-f(n,d-1))%MOD)", "def main():\r\n n, k, d = list(map(int, input().split()))\r\n dp = [[0 for j in range(k+1)] for i in range(n+1)]\r\n dp[0][0], dp[1][1] = 1, 1\r\n for i in range(2, n+1):\r\n for j in range(1, min(k+1, i+1)):\r\n for l in range(1, min(i+1, k+1)):\r\n if l >= j:\r\n dp[i][j] += max(dp[i-l])\r\n else:\r\n dp[i][j] += dp[i-l][j]\r\n print(dp[n][d] % (10**9 + 7))\r\n\r\nif __name__ == \"__main__\":\r\n main()", "n,k,d=map(int,input().split())\r\n\r\ndef fun(n,k,d,f,dp):\r\n if n==0:\r\n if f==1:\r\n return 1\r\n return 0\r\n if n<0:\r\n return 0\r\n if dp[n][f]!=-1:\r\n return dp[n][f]\r\n ans=0\r\n mod=10**9+7\r\n for i in range(1,k+1):\r\n if i<d:\r\n ans=(ans+fun(n-i,k,d,f,dp))%mod\r\n else:\r\n ans=(ans+fun(n-i,k,d,1,dp))%mod\r\n dp[n][f]=ans%mod\r\n return ans%mod\r\ndp=[[-1,-1] for i in range(n+1)]\r\nans=fun(n,k,d,0,dp)\r\nprint(ans)\r\n", "mod = 1000000007\nn, k, d = map(int, input().split())\n\n\nf = [[-1 for _ in range(n+1)] for _ in range(n+1)]\n\ndef tree(x, y):\n if x > n:\n return 0\n if x == n and y >= d:\n return 1\n\n if f[x][y] != -1:\n return f[x][y]\n f[x][y] = 0\n for i in range(1, k+1):\n f[x][y] += tree(x+i, max(i, y))\n f[x][y] %= mod\n return f[x][y]\n\nprint(tree(0, 0))\n\n\t\t\t\t \t\t\t \t\t\t \t\t\t \t\t\t\t \t", "\"\"\"\r\n## NOTE\r\n- good knapsack variant\r\n- converting \"at least\" to \"exactly\":\r\n - \"at least d\" == \"exactly max\" - \"exactly d-1\"\r\n\r\n## INFO\r\n431_C_KTree\r\nhttps://codeforces.com/problemset/problem/431/C\r\n\r\n## TAGS\r\n- dp\r\n- implementation\r\n- trees\r\n- *1600\r\n\r\n## TESTS\r\n-in:\r\n3 3 2\r\n-out:\r\n3\r\n\r\n-in:\r\n3 3 3\r\n-out:\r\n1\r\n\r\n-in:\r\n4 3 2\r\n-out:\r\n6\r\n\r\n-in:\r\n4 5 2\r\n-out:\r\n7\r\n\r\n\"\"\"\r\n\r\n#%%\r\n\r\nimport sys\r\nimport time\r\n\r\nstart_time = time.time()\r\nFILE = False\r\n\r\n# ---------------------- HELPER INPUT FUNCTIONS ----------------------#\r\n\r\n\r\ndef get_int():\r\n return int(sys.stdin.readline())\r\n\r\n\r\ndef get_str():\r\n return sys.stdin.readline().strip()\r\n\r\n\r\ndef get_list_int():\r\n return list(map(int, sys.stdin.readline().split()))\r\n\r\n\r\ndef get_list_str():\r\n return list(sys.stdin.readline().split())\r\n\r\n\r\n# -------------------------- SOLVE FUNCTION --------------------------#\r\n\r\n\r\ndef solve():\r\n \"\"\"\r\n approach 1: converting \"at least d\"\r\n n=3\r\n k=3\r\n d=2\r\n\r\n 0 1 2 3\r\n [0 0 0 0]\r\n [1 1 2 2+1+1]\r\n [1 0 1 1+1+]\r\n [1 1 1 1+1+1]\r\n \"\"\"\r\n n, k, d = get_list_int()\r\n mod = 10**9 + 7\r\n\r\n dp1 = [0] * (n + 1)\r\n dp1[0] = 1\r\n\r\n # making exactly k\r\n for j in range(1, n + 1):\r\n for c in range(1, k + 1):\r\n if j >= c:\r\n dp1[j] += dp1[j - c]\r\n\r\n dp2 = [0] * (n + 1)\r\n dp2[0] = 1\r\n # making exactly d - 1\r\n for j in range(1, n + 1):\r\n for c in range(1, d - 1 + 1):\r\n if j >= c:\r\n dp2[j] += dp2[j - c]\r\n\r\n print((dp1[-1] - dp2[-1]) % mod)\r\n\r\n\r\n# -------------------------- MAIN FUNCTION --------------------------#\r\n\r\n\r\ndef main():\r\n if FILE:\r\n sys.stdin = open(\"./src/codeforces/input.txt\", \"r\")\r\n\r\n solve()\r\n\r\n if FILE:\r\n print(\"\\033[95m\" + \"> time elapsed: \", (time.time() - start_time) * 1000.0, \"ms\")\r\n\r\n\r\nmain()\r\n", "def main():\r\n n, k, d = list(map(int, input().split()))\r\n dp = [[0 for j in range(d+1)] for i in range(n+1)]\r\n dp[1][1] = 1\r\n for i in range(1, d+1):\r\n dp[0][i] = 1\r\n for i in range(2, n+1):\r\n for j in range(1, d+1):\r\n if i > j:\r\n for l in range(1, min(k+1, i+1)):\r\n if l < j:\r\n dp[i][j] += dp[i-l][j]\r\n else:\r\n dp[i][j] += dp[i-l][1]\r\n elif i == j:\r\n dp[i][j] = 1\r\n\r\n print(dp[n][d] % (10**9+7))\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()", "import sys\r\nsys.setrecursionlimit(10**7)\r\nn,k,d=map(int,input().split())\r\nmod=1000000007\r\ndp=[[0]*(103) for _ in range(2)]\r\ndp[1][0]=1\r\nfor target in range(1,n+1):\r\n for flag in range(2):\r\n for x in range(1,k+1):\r\n if x<=target:\r\n dp[flag][target]+=dp[flag or x>=d][target-x]\r\nprint(dp[0][target]%mod)\r\n# print(rec(n,0)%mod)\r\n\r\n", "n,k,d=map(int,input().split())\r\na=[[1],[1]]\r\nfor i in range(1,n+1):\r\n a[0].append(sum(a[0][max(i-d+1,0):]))\r\n a[1].append(sum(a[1][max(i-k,0):]))\r\nprint((a[1][-1]-a[0][-1])%(10**9+7))", "\n\ndef solve_rec(n, k, d, has_d_edge):\n paths = 0\n for i in range(1,k+1):\n if n-i < 0:\n continue\n elif n-i == 0:\n if has_d_edge or i >= d:\n paths += 1\n else:\n if i >= d:\n has_d_edge = True\n paths += solve_rec(n-i, k, d, has_d_edge)\n return paths\n\nn, k, d = map(int, input().split())\ndp = {}\n\ndef call_solve():\n return solve(n, 0)\n\ndef solve(n, has_d_edge):\n if n < 0:\n return 0\n if n == 0:\n return has_d_edge\n if (n, has_d_edge) in dp.keys():\n return dp[(n, has_d_edge)]\n\n num_of_paths = 0\n for k_i in range(1,k+1):\n if k_i < d:\n num_of_paths += solve(n-k_i, has_d_edge)\n else: # k_i >= d\n num_of_paths += solve(n-k_i, 1)\n num_of_paths %= 1000000007\n dp[(n, has_d_edge)] = num_of_paths\n return num_of_paths\n\nprint(call_solve())\n\n\t\t\t\t\t \t \t \t\t \t\t \t\t\t\t\t \t", "import math\r\n\r\ndef solve():\r\n n, k, d = map(int, input().split())\r\n dp = [0] * (n + 1)\r\n dp1 = [0] * (n + 1)\r\n dp[0] = 1\r\n dp1[0] = 1\r\n\r\n for i in range(1, n + 1):\r\n for j in range(1, k + 1):\r\n if i - j >= 0:\r\n dp[i] += dp[i - j]\r\n\r\n for i in range(1, n + 1):\r\n for j in range(1, d):\r\n if i - j >= 0:\r\n dp1[i] += dp1[i - j]\r\n\r\n M = 1000000007\r\n result = (dp[n] - dp1[n]) % M\r\n print(result)\r\n\r\ndef 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\nif __name__ == \"__main__\":\r\n main()\r\n", "def ans(n, kd):\r\n if kd <= 0:\r\n return 0\r\n dp = [1] + [0] * n\r\n for i in range(1, n + 1):\r\n for j in range(1, min(i, kd) + 1):\r\n dp[i] += dp[i - j]\r\n if dp[i] >= res:\r\n dp[i] -= res\r\n return dp[n]\r\n\r\n\r\nn, k, d = map(int, input().split())\r\nres = 10 ** 9 + 7\r\nprint((ans(n, k) - ans(n, d - 1)) % res)", "mod = 10**9 + 7\n\ndef add(a, b):\n a += b\n if a >= mod:\n a -= mod\n return a\n\ndef main():\n n, k, d = map(int, input().split())\n\n dp = [[0, 0] for _ in range(n + 1)]\n dp[0][0] = 1\n dp[0][1] = 0\n\n for i in range(1, n + 1):\n dp[i][0] = dp[i][1] = 0\n\n for j in range(1, k + 1):\n if i - j < 0:\n break\n\n if j < d:\n dp[i][0] = add(dp[i][0], dp[i - j][0])\n dp[i][1] = add(dp[i][1], dp[i - j][1])\n else:\n dp[i][1] = add(dp[i][1], dp[i - j][0])\n dp[i][1] = add(dp[i][1], dp[i - j][1])\n\n print(dp[n][1])\n\nif __name__ == \"__main__\":\n main()\n", "n,k,d = map(int,input().split())\r\nmemo = {}\r\nc = False\r\ndef dfs(n,c):\r\n if (n,c) in memo:\r\n return memo[(n,c)]\r\n if n == 0:\r\n if c:\r\n return 1\r\n else:\r\n return 0\r\n if n < 0:\r\n return 0\r\n val = 0\r\n for i in range(1,k+1):\r\n if i >= d:\r\n val += dfs(n-i,True)\r\n else:\r\n val += dfs(n-i,c)\r\n \r\n memo[(n,c)] = val\r\n return memo[(n,c)]\r\nprint((dfs(n,c))%((10**9)+7))", "\r\nimport time\r\nimport sys\r\nfrom collections import *\r\nfrom bisect import *\r\nfrom heapq import *\r\n\r\ninput = sys.stdin.readline\r\n\r\nis_debug = '_local_debug_' in globals()\r\n\r\n#int input\r\ndef inp():\r\n return(int(input()))\r\n\r\n#list input\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\n\r\n#string input\r\ndef insr():\r\n return input()[:-1]\r\n\r\n#strings input\r\ndef inss(n):\r\n return [insr() for _ in range(n)]\r\n\r\n#variables input\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\n#matrix input\r\ndef inmt(n):\r\n return [inlt() for _ in range(n)]\r\nmod = 10**9+7\r\nclass Solution(object):\r\n def input(self):\r\n # 读入数据,返回一个参数列表\r\n # 例如:读取一个整数n和一个字符串s\r\n # return (n, s)\r\n return invr()\r\n\r\n def solve(self, n, k, d):\r\n ans = 0\r\n #flag:0表示还没有出现过权值大于等于d的边,1表示出现过\r\n #n:剩余的权值\r\n #返回值:构造出n的路径数\r\n memo = {}\r\n def dp(flag, n):\r\n if n == 0:\r\n return flag\r\n if n < 0:\r\n return 0\r\n if (flag, n) in memo:\r\n return memo[(flag, n)]\r\n ans = 0\r\n for i in range(1, k + 1):\r\n if i >= d:\r\n ans += dp(1, n - i)\r\n else:\r\n ans += dp(flag, n - i)\r\n ans %= mod\r\n memo[(flag, n)] = ans\r\n return ans\r\n ans = dp(0, n)\r\n return ans\r\n\r\n def output(self,ans):\r\n print(ans)\r\n\r\ndef solve(i):\r\n sol = Solution()\r\n param = sol.input()\r\n if is_debug: start = time.time()\r\n ans = sol.solve(*param)\r\n sol.output(ans)\r\n if is_debug:\r\n end = time.time()\r\n print(f'Case{i} Time: {(end - start) * 1000} ms')\r\n\r\n#对于只有一个样例的题目,将inp()改为1\r\n#t = inp() \r\nt = 1\r\nif is_debug: start = time.time()\r\nfor i in range(1, t + 1):\r\n solve(i)\r\nif is_debug:\r\n end = time.time()\r\n print(f'Total Time: {(end - start) * 1000} ms')", "n,k,d = map(int,input().split())\r\nMOD = int(1e9+7)\r\ndp = [1]\r\nfor i in range(1,min(k+1,n+1)):\r\n dp.append(2**(i-1)%MOD)\r\nfor i in range(k+1,n+1):\r\n s = 0\r\n for j in range(i-1,i-k-1,-1):\r\n s = (s%MOD + dp[j]%MOD)%MOD\r\n dp.append(s)\r\n\r\n#print(dp)\r\nfirst_val = dp[-1]\r\n\r\nk = d-1\r\ndp = [1]\r\nfor i in range(1,min(k+1,n+1)):\r\n dp.append(2**(i-1)%MOD)\r\nfor i in range(k+1,n+1):\r\n s = 0\r\n for j in range(i-1,i-k-1,-1):\r\n s = (s%MOD + dp[j]%MOD)%MOD\r\n dp.append(s)\r\n#print(dp)\r\nsecond_val = dp[-1]\r\n\r\nprint((first_val%MOD - second_val%MOD)%MOD)\r\n", "n, k, d = list(map(int, input().split()))\r\nmodulo = (10 ** 9 + 7)\r\nmemo = {}\r\ndef dynammic(target, oooo):\r\n if target == n:\r\n return oooo\r\n \r\n if target > n:\r\n return 0\r\n \r\n if (target, oooo) in memo:\r\n return memo[(target, oooo)]\r\n \r\n memo[(target, oooo)] = 0\r\n for i in range(1, k + 1):\r\n memo[(target, oooo)] += dynammic(target + i, oooo or i >= d)\r\n\r\n return memo[(target, oooo)] % modulo\r\n\r\nprint(dynammic(0, False))\r\n ", "import sys, io, os\r\nimport math\r\nimport bisect\r\nimport heapq\r\nimport string\r\nfrom collections import defaultdict,Counter,deque\r\nfrom functools import lru_cache\r\ninput = sys.stdin.readline\r\nsys.setrecursionlimit(200)\r\n \r\ndef I():\r\n return input()\r\n \r\ndef II():\r\n return int(input())\r\n \r\ndef MII():\r\n return map(int, input().split())\r\n \r\ndef LI():\r\n return list(input().split())\r\n \r\ndef LII():\r\n return list(map(int, input().split()))\r\n \r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n \r\ndef LGMI():\r\n return list(map(lambda x: int(x) - 1, input().split()))\r\n \r\ndef WRITE(out):\r\n return print('\\n'.join(map(str, out)))\r\n \r\ndef WS(out):\r\n return print(' '.join(map(str, out)))\r\n \r\ndef WNS(out):\r\n return print(''.join(map(str, out)))\r\n\r\ndef WSNOPRINT(out):\r\n return ''.join(map(str, out))\r\n\r\n'''\r\n\r\n'''\r\ndef solve():\r\n n, k, d = MII()\r\n mod = 10**9 + 7\r\n cache = defaultdict(int)\r\n\r\n def dfs(n, y):\r\n if (n,y) in cache:\r\n return cache[(n,y)]\r\n if n < 0:\r\n return 0\r\n if n == 0:\r\n return 1 if y else 0\r\n\r\n ans = 0\r\n for i in range(1, k+1):\r\n ans += dfs(n-i, i >= d or y) % mod\r\n cache[(n,y)] = ans\r\n return ans % mod\r\n\r\n print(dfs(n,False))\r\n\r\nsolve()", "mod = 1e9 + 7\r\n\r\n\r\ndef add(a, b):\r\n return (a + b) - mod * (a + b >= mod)\r\n\r\n\r\nn, k, d = map(int, input().split())\r\ndp = [[0]*2 for i in range(101)]\r\ndp[0][0] = 1\r\n\r\nfor i in range(1, n+1):\r\n for j in range(1, k+1):\r\n if i - j < 0:\r\n break\r\n if j < d:\r\n dp[i][0] = add(dp[i][0], dp[i - j][0])\r\n dp[i][1] = add(dp[i][1], dp[i - j][1])\r\n else:\r\n dp[i][1] = add(dp[i][1], dp[i - j][0])\r\n dp[i][1] = add(dp[i][1], dp[i - j][1])\r\n\r\nprint(int(dp[n][1]))", "inp=input().split()\r\nn=int(inp[0])\r\nk=int(inp[1])\r\nd=int(inp[2])\r\nif (n==1 and d<=n):\r\n print(1)\r\nelif (n==1 and d>n):\r\n print(0)\r\nelse:\r\n dp=[0 for i in range(n+1)]\r\n dp2=[0 for i in range(n+1)]\r\n dp[1]=1\r\n dp2[1]=1\r\n s1,s2,s3,s4,c,c2,k2=1,0,1,0,0,0,d-1\r\n for i in range(2,n+1):\r\n if i>k:\r\n dp[i]=s1-s2\r\n c=c+1\r\n s2=s2+dp[c]\r\n else:\r\n dp[i]=1+s1\r\n if (k2>0 and i>k2):\r\n dp2[i]=s3-s4\r\n c2=c2+1\r\n s4=s4+dp2[c2]\r\n elif k2>0:\r\n dp2[i]=1+s3\r\n s1=s1+dp[i]\r\n s3=s3+dp2[i]\r\n ans=(dp[n]-dp2[n])%1000000007\r\n print(ans)", "def f(n, k):\r\n if t[n][k] is None:\r\n if n == 0 or k == 1:\r\n t[n][k] = 1\r\n else:\r\n t[n][k] = 0\r\n for j in range(1, min(n, k) + 1):\r\n t[n][k] += f(n - j, k)\r\n return t[n][k]\r\n\r\n\r\nt = []\r\nfor i in range(101):\r\n t.append([None] * 101)\r\nn, k, d = map(int, input().split())\r\nprint((f(n, k) - f(n, d - 1)) % 1000000007)\r\n\r\n", "\r\n\r\nn,k,d=map(int, input().split())\r\ndp=[[-1 for _ in range(105)] for _ in range(105)]\r\n\r\ndef ss(a,b):\r\n if a<0:\r\n return 0\r\n if a==0:\r\n if b>=d:\r\n return 1 \r\n return 0\r\n if dp[a][b]!=-1:\r\n return dp[a][b]\r\n x=0\r\n for i in range(1,k+1):\r\n x+=ss(a-i,max(b,i))\r\n \r\n dp[a][b]=x%1000000007\r\n return dp[a][b]\r\n\r\nprint(ss(n,0))\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\n\r\ndef f(x):\r\n d = [0]*(n+101)\r\n d[0] = 1\r\n i = 0\r\n while i < n+1:\r\n d[i] %= M\r\n for j in range(1, x+1):\r\n d[i+j] += d[i]\r\n i += 1\r\n return d[n]\r\n\r\n\r\nM = 10**9+7\r\nn, k, d = map(int, input().split())\r\nprint((f(k)%M - f(d-1)%M)%M)", "import sys\r\ninput=sys.stdin.readline\r\n\r\nMOD=10**9+7\r\nn,k,d=map(int,input().split())\r\nfrom functools import cache\r\n@cache\r\ndef f(s,flag):\r\n if s==0:return flag\r\n cur=0\r\n for i in range(1,k+1):\r\n if s-i>=0:\r\n cur+=f(s-i,(flag or i>=d))\r\n return cur\r\nprint(f(n,0)%MOD)", "a,m,n=map(int,input().split())\r\nA=[1];B=[1]\r\nfor i in range(1,a+1):\r\n A+=[sum(A[max(i-m,0):])]\r\n B+=[sum(B[max(i-n+1,0):])]\r\nprint((A[-1]-B[-1])%(10**9+7))", "# import sys\r\n# sys.stdin = open('input.txt', 'r')\r\n\r\nfrom array import array\r\n\r\n\r\nn,k,d= map(int,input().split(\" \"))\r\nm =1000000007\r\ndp=[]\r\n\r\nfor r in range(n+1):\r\n\tdp.append(array(\"I\",[0])*(k+1))\r\n\r\n\r\ndp[0][0]=1\r\n\r\n\r\nfor t in range(1,k+1):\r\n\tif(t<=n):\r\n\t\tdp[t][t]+=dp[0][0]\r\n\r\n\r\n\r\n\r\nfor r in range(1,n+1):\r\n\tfor q in range(1,k+1):\r\n\t\tfor z in range(1,k+1):\r\n\r\n\t\t\tif r+z<=n:\r\n\t\t\t\tif(z>q):\r\n\t\t\t\t\tdp[r+z][z]+=(dp[r][q]%m)\r\n\t\t\t\t\tdp[r+z][z]%=m\r\n\r\n\t\t\t\telse:\r\n\t\t\t\t\tdp[r+z][q]+=(dp[r][q]%m)\r\n\t\t\t\t\tdp[r+z][q]%=m\r\n\r\nanswer = 0\r\nfor t in range(k-d+1):\r\n\tanswer+=dp[n][d+t]\r\n\tanswer%=m\r\n\r\nprint(answer)\r\n\r\n\r\n\r\n\r\n", "from sys import stdin, stdout \n\nn, k, d = map(int, stdin.readline().split())\n# dp[sum][depth][has d?]\nMOD = int(1e9 + 7)\n\ndp = [[[0] * 2 for _ in range(n + 1)] for _ in range(n + 1)]\ndp[0][0][0] = 1\n\nfor depth in range(1, n + 1):\n for sum in range(1, n + 1):\n for add in range(1, k + 1):\n if sum - add >= 0:\n dp[sum][depth][0] += dp[sum - add][depth - 1][0]\n dp[sum][depth][0] %= MOD\n if add >= d: \n dp[sum][depth][1] += dp[sum - add][depth - 1][0]\n dp[sum][depth][1] %= MOD\n else:\n dp[sum][depth][1] += dp[sum - add][depth - 1][1]\n dp[sum][depth][1] %= MOD \n\n# print(dp)\nans = 0\nfor i in range(0, n + 1):\n ans += dp[n][i][1]\n ans %= MOD \nprint(ans)\n", "import sys\nfrom math import *\n# from pprint import pprint as pprint\n# from sympy.ntheory.modular import crt\nimport heapq\nfrom copy import *\nfrom collections import *\nimport functools\nfrom itertools import *\nfrom math import sqrt, ceil\nimport threading\nimport time\n\n# fin = sys.stdin.read().strip().split(\"\\n\")\n\nMOD = 1000000007\n\n\ndef solve():\n\n @functools.lru_cache(maxsize=None)\n def dp(i, remains, isIncluded):\n if remains == 0:\n if isIncluded:\n return 1\n return 0\n\n ret = 0\n for next in range(1, k + 1):\n if next > remains:\n break\n ret += dp(i + 1, remains - next, isIncluded or (next >= d))\n ret %= MOD\n return ret % MOD\n\n n, k, d = [int(c) for c in input().strip().split()]\n print(dp(0, n, False))\n\n\nsolve()\n\n# t = int(input())\n# for _ in range(t):\n# solve()\n", "n, k, d = map(int, input().split())\r\n\r\ndp = [[0] * 2 for _ in range(n + 1)]\r\n\r\nmod = 10**9 + 7\r\n\r\ndp[0][0] = 1\r\nfor i in range(1, n + 1):\r\n for j in range(1, d):\r\n if j > i: break\r\n dp[i][0] += dp[i - j][0]\r\n dp[i][0] %= mod\r\n dp[i][1] += dp[i - j][1]\r\n dp[i][1] %= mod\r\n for j in range(d, k + 1):\r\n if j > i: break\r\n dp[i][1] += dp[i - j][0] + dp[i - j][1]\r\n dp[i][1] %= mod\r\n \r\nprint(dp[-1][1])", "import sys\nfrom collections import deque, defaultdict, Counter\nfrom functools import lru_cache\n\n############ constants ############\nMOD = 1000000007\n\n############ Input Functions ############\ninput = sys.stdin.readline\n\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############ Output Functions ############\ndef oupNum(n):\n sys.stdout.write(str(n) + \"\\n\")\n\ndef oupList(lst):\n sys.stdout.write(\" \".join(map(str, lst)) + \"\\n\")\n\n\n############ Recursion Trick ############ \ndef bootstrap(f, stack=[]):\n def wrappedfunc(*args, **kwargs):\n if stack:\n return f(*args, **kwargs)\n else:\n to = stack.append(f(*args, **kwargs))\n while True:\n try:\n to = stack.append(stack[-1].send(to))\n except StopIteration as e:\n stack.pop()\n to = e.value\n if not stack:\n break\n return to\n return wrappedfunc\n\n\ndef main():\n @bootstrap\n def dfs(rest, k, depth, must, hasMust):\n if rest < 0: return 0\n if rest == 0 and hasMust: return 1\n if rest == 0: return 0\n \n if (rest, depth, hasMust) in memo:\n return memo[(rest, depth, hasMust)]\n \n answer = 0\n for n in range(1, k+1):\n answer += yield dfs(rest-n, k, depth+1, must, hasMust or n >= must)\n memo[(rest, depth, hasMust)] = answer\n return answer\n\n total, k, must = inlt()\n memo = {}\n oupNum(dfs(total, k, 0, must, False) % MOD)\n\n\nif __name__ == '__main__':\n main()", "# DO NOT EDIT THIS\r\nimport functools\r\nimport math\r\nimport sys\r\n\r\ninput = sys.stdin.readline\r\nfrom collections import deque, defaultdict\r\nimport heapq\r\nimport bisect\r\ndef counter(a):\r\n c = defaultdict(lambda : 0) # way faster than Counter\r\n for el in a:\r\n c[el] += 1\r\n return c\r\n\r\ndef inp(): return [int(k) for k in input().split()]\r\ndef si(): return int(input())\r\ndef st(): return input()\r\n\r\nmxi = 10**10\r\nmod = 10**9 + 7\r\n\r\n# DO NOT EDIT ABOVE THIS\r\n\r\nn, k, d = inp()\r\n\r\n# base case: remaining_weight == 0, 1 valid construction if d\r\n# recurrence:\r\n# for w in 1..min(k, remaining_weight):\r\n# total += dp(remaining_weight - w, (w >= d) | prev_d)\r\n#\r\n\r\n\r\ndp = [[0] * (k + 1) for _ in range(n + 1)]\r\n\r\[email protected]_cache(None)\r\ndef dp(remaining_weight=n, had_big_enough=False):\r\n if remaining_weight == 0:\r\n return 1 if had_big_enough else 0\r\n\r\n tot = 0\r\n for w in range(1, min(k + 1, remaining_weight + 1)):\r\n tot += dp(remaining_weight - w, had_big_enough or (w >= d))\r\n tot %= mod\r\n\r\n return tot\r\n\r\nprint(dp())\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n, k, d = [int(i) for i in input().split()]\r\n\r\ndp = [[-1 for _ in range(200)] for _ in range(200)]\r\nmod = 1000000007\r\ndef recur(b,c):\r\n if b < 0:\r\n return 0\r\n if b == 0:\r\n if c >=d:\r\n return 1\r\n return 0\r\n\r\n if dp[b][c] != -1:\r\n return dp[b][c]\r\n\r\n total = 0\r\n for i in range(1, k+1):\r\n total += recur(b-i, max(c,i))\r\n total %= mod\r\n total%= mod\r\n dp[b][c] = total\r\n return dp[b][c]\r\n\r\nprint(recur(n,0))", "n,k,d=map(int,input().split())\r\nmod=1000000007\r\nl= [[0] * (n + 1) for i in range(2)]\r\nl[0][0]=1\r\nfor i in range(1,n+1): \r\n for j in range(1,k+1): \r\n if i>=j: \r\n l[1][i]+=l[1][i-j]\r\n if j>=d: \r\n l[1][i]+=l[0][i-j]\r\n else:l[0][i]+=l[0][i-j]\r\nprint(l[1][n]%mod)", "from functools import lru_cache\r\nMOD = 1000000007\r\nn,k,d = map(int,input().split())\r\n@lru_cache(None)\r\ndef dfs(total = 0,max_edge = 0):\r\n if total > n:\r\n return 0\r\n if total == n:\r\n if max_edge >= d:\r\n return 1\r\n return 0\r\n res = 0\r\n for i in range(1,k + 1):\r\n res = (res + dfs(total + i,max(max_edge,i))) % MOD\r\n return res\r\nprint(dfs())", "from collections import defaultdict\r\ndicts = defaultdict(int)\r\ndef solve(amount,level,n,k,d,maxim):\r\n \r\n if amount == n and maxim >= d:\r\n return 1\r\n if amount >= n:\r\n return 0\r\n if (amount, maxim) in dicts:\r\n return dicts[(amount, maxim)]\r\n temp = 0\r\n for val in range(1,k+1):\r\n if amount+val <= n:\r\n temp += solve(amount+val,level+1,n,k,d,max(val,maxim))\r\n dicts[(amount, maxim)] = temp\r\n return dicts[(amount,maxim)]\r\n \r\nn,k,d = map(int,input().split())\r\nprint(solve(0, 0,n, k, d,0)%(1000000007))", "n, k, d = map(int, input().split())\r\ndp1 = [0] * 10000\r\ndp2 = [0] * 10000\r\ndp1[0] = 1 # represent empty path\r\ndp2[0] = 1 # represent empty path\r\nMOD = 1000 * 1000 * 1000 + 7\r\nfor i in range(n):\r\n for j in range(1, k + 1):\r\n dp1[i + j] += dp1[i]\r\n dp1[i + j] %= MOD\r\n for j in range(1, d):\r\n dp2[i + j] += dp2[i]\r\n dp2[i + j] %= MOD\r\nif d > n:\r\n print(0)\r\nelse:\r\n print(int(((dp1[n] - dp2[n]) % MOD)))", "from collections import defaultdict\r\ndicts = defaultdict(int)\r\ndef solve(amount,n,k,d,maxim):\r\n \r\n if amount >= n:\r\n if amount == n and maxim >= d:\r\n return 1\r\n return 0\r\n if (amount,maxim) not in dicts:\r\n for val in range(1,k+1):\r\n if amount+val <= n:\r\n dicts[(amount, maxim)] += solve(amount+val,n,k,d,max(val,maxim)) \r\n return dicts[(amount,maxim)]\r\n \r\nn,k,d = map(int,input().split())\r\nprint(solve(0, n, k, d,0)%(1000000007))\r\n", "from sys import stdin\r\n\r\n\r\nmod = 10**9 + 7\r\n\r\n\r\ndef solve():\r\n n, k, d = map(int, stdin.readline().split())\r\n\r\n if d > n:\r\n print(0)\r\n return\r\n\r\n dp = [[0, 0] for _ in range(n + 1)]\r\n dp[n][1] = 1\r\n\r\n for sm in range(n - 1, -1, -1):\r\n for edge_found in 0, 1:\r\n for i in range(1, min(k, n - sm) + 1):\r\n dp[sm][edge_found] = (dp[sm][edge_found] + dp[sm + i][int(edge_found or i >= d)]) % mod\r\n\r\n print(dp[0][0])\r\n\r\n\r\nsolve()\r\n", "\r\nfrom ensurepip import bootstrap\r\n\r\n\r\nn, k , d = map(int, input().split())\r\nmod = 10**9 + 7\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 = stack.append(f(*args, **kwargs))\r\n while True:\r\n try:\r\n to = stack.append(stack[-1].send(to))\r\n except StopIteration as e:\r\n stack.pop()\r\n to = e.value\r\n if not stack:\r\n break\r\n return to\r\n \r\n return wrappedfunc\r\n\r\nmemo = {}\r\n@bootstrap\r\ndef dp(cur, d_taken):\r\n if (cur, d_taken) in memo: return memo[cur, d_taken]\r\n if cur > n:\r\n return 0\r\n \r\n if cur == n and d_taken:\r\n return 1\r\n \r\n res = 0\r\n for choice in range(1, k+1):\r\n if choice >= d:\r\n res += (yield dp(cur + choice, True))%mod\r\n else:\r\n res += (yield dp(cur + choice, d_taken))%mod\r\n \r\n memo[cur, d_taken] = res%mod\r\n return memo[cur, d_taken]\r\n\r\nprint(dp(0, False))", "for _ in range(1):\r\n n,k,d=map(int,input().split())\r\n dp=[0]*(n+1)\r\n dp[0]=1\r\n dp2=[0]*(n+1)\r\n dp2[0]=1\r\n for i in range(1,n+1):\r\n for j in range(0,k+1):\r\n if i-j<0:\r\n break\r\n dp[i]+=dp[i-j]\r\n for i in range(1,n+1):\r\n for j in range(0,d):\r\n if i-j<0:\r\n break\r\n dp2[i]+=dp2[i-j]\r\n m=10**9 + 7\r\n print((dp[n]-dp2[n])%m)\r\n\r\n\r\n \r\n", "import sys\r\ninput=sys.stdin.readline\r\nm=1000000007\r\n\r\n#------------------------------------#\r\n\r\nlim,n,d=map(int,input().split())\r\nL1=[0]*lim\r\nL1[0]=1\r\nL2=[0]*lim\r\ncount=0\r\nfor _ in range(lim):\r\n tempL1=[0]*lim\r\n tempL2=[0]*lim\r\n for i in range(1,n+1):\r\n for k in range(lim):\r\n if k+i>lim:\r\n continue\r\n elif k+i==lim:\r\n count=(count+L2[k])%m\r\n if i>=d:\r\n count=(count+L1[k])%m\r\n else:\r\n tempL2[k+i]=(tempL2[k+i]+L2[k])%m\r\n if i>=d:\r\n tempL2[k+i]=(tempL2[k+i]+L1[k])%m\r\n else:\r\n tempL1[k+i]=(tempL1[k+i]+L1[k])%m\r\n L1=list(tempL1)\r\n L2=list(tempL2)\r\nprint(count)", "\"\"\"\r\n## NOTE\r\n- good knapsack variant\r\n- converting \"at least\" to \"exactly\":\r\n - \"at least d\" == \"exactly max\" - \"exactly d-1\"\r\n- hard\r\n\r\n## INFO\r\n431_C_KTree\r\nhttps://codeforces.com/problemset/problem/431/C\r\n\r\n## TAGS\r\n- dp\r\n- implementation\r\n- trees\r\n- *1600\r\n\r\n## TESTS\r\n-in:\r\n3 3 2\r\n-out:\r\n3\r\n\r\n-in:\r\n3 3 3\r\n-out:\r\n1\r\n\r\n-in:\r\n4 3 2\r\n-out:\r\n6\r\n\r\n-in:\r\n4 5 2\r\n-out:\r\n7\r\n\r\n\"\"\"\r\n\r\n#%%\r\n\r\nimport sys\r\nimport time\r\nfrom functools import lru_cache\r\n\r\nstart_time = time.time()\r\nFILE = False\r\n\r\n# ---------------------- HELPER INPUT FUNCTIONS ----------------------#\r\n\r\n\r\ndef get_int():\r\n return int(sys.stdin.readline())\r\n\r\n\r\ndef get_str():\r\n return sys.stdin.readline().strip()\r\n\r\n\r\ndef get_list_int():\r\n return list(map(int, sys.stdin.readline().split()))\r\n\r\n\r\ndef get_list_str():\r\n return list(sys.stdin.readline().split())\r\n\r\n\r\n# -------------------------- SOLVE FUNCTION --------------------------#\r\n\r\n\r\ndef solve_atleast_exactly():\r\n \"\"\"\r\n approach 1: converting \"at least d\" to two \"exactly\" calculations\r\n https://codeforces.com/contest/431/submission/33873745\r\n \"\"\"\r\n n, k, d = get_list_int()\r\n mod = 10**9 + 7\r\n\r\n dp1 = [0] * (n + 1)\r\n dp1[0] = 1\r\n\r\n # making exactly k\r\n for j in range(1, n + 1):\r\n for c in range(1, k + 1):\r\n if j >= c:\r\n dp1[j] += dp1[j - c]\r\n\r\n dp2 = [0] * (n + 1)\r\n dp2[0] = 1\r\n # making exactly d - 1\r\n for j in range(1, n + 1):\r\n for c in range(1, d - 1 + 1):\r\n if j >= c:\r\n dp2[j] += dp2[j - c]\r\n\r\n print((dp1[-1] - dp2[-1]) % mod)\r\n\r\n\r\ndef solve_top_down():\r\n \"\"\"\r\n https://codeforces.com/contest/431/submission/143360531\r\n \"\"\"\r\n n, k, d = get_list_int()\r\n mod = 10**9 + 7\r\n\r\n @lru_cache(None)\r\n def dp(remain, condition):\r\n if remain == 0:\r\n # if we make n and have seen an number at least d\r\n return int(condition)\r\n\r\n ans = 0\r\n for c in range(1, k + 1):\r\n if c > remain:\r\n continue\r\n if c >= d:\r\n # we pick\r\n ans += dp(remain - c, True)\r\n else:\r\n ans += dp(remain - c, condition)\r\n\r\n return ans % mod\r\n\r\n print(dp(n, False))\r\n\r\n\r\n# -------------------------- MAIN FUNCTION --------------------------#\r\n\r\n\r\ndef main():\r\n if FILE:\r\n sys.stdin = open(\"./src/codeforces/input.txt\", \"r\")\r\n\r\n # solve_atleast_exactly()\r\n solve_top_down()\r\n\r\n if FILE:\r\n print(\"\\033[95m\" + \"> time elapsed: \", (time.time() - start_time) * 1000.0, \"ms\")\r\n\r\n\r\nmain()\r\n", "n,k,d=map(int,input().split())\r\nsto=[0]*(n+1)\r\nsto2=[0]*(n+1)\r\ncheck=[False]*(n+1)\r\ncheck2=[False]*(n+1)\r\ndef dp (sum,k,sto,check):\r\n if(sum<0) :\r\n return 0\r\n if(sum==0):\r\n return 1\r\n if(check[sum]==True):\r\n return sto[sum]\r\n out=0\r\n for i in range (1,k+1):\r\n out=out+dp(sum-i,k,sto,check)\r\n sto[sum]=out\r\n check[sum]=True\r\n return out\r\n\r\ndef dplim (sum,k,d,sto2,check2):\r\n if(sum<0) :\r\n return 0\r\n if(sum==0):\r\n return 1\r\n if (check2[sum] == True):\r\n return sto2[sum]\r\n out=0\r\n for i in range (1,d):\r\n out=out+dplim(sum-i,k,d,sto2,check2)\r\n sto2[sum]=out\r\n check2[sum]=True\r\n return out\r\ndp(n,k,sto,check)\r\ndplim(n,k,d,sto2,check2)\r\nx=(sto[n]-sto2[n])%1000000007\r\nprint(x)", "\r\n# from sortedcontainers import SortedSet\r\nfrom ast import Mod\r\nfrom collections import OrderedDict\r\nfrom io import BytesIO, IOBase\r\nimport os\r\nimport threading\r\nimport collections\r\nfrom tkinter import E\r\nfrom types import GeneratorType\r\nfrom itertools import combinations, permutations\r\nfrom functools import lru_cache\r\nimport bisect\r\nimport sys\r\nfrom array import array\r\nimport heapq\r\nfrom collections import Counter\r\nimport math\r\nfrom collections import defaultdict\r\nfrom collections import deque\r\nfrom copy import deepcopy\r\n\r\ninput = sys.stdin.readline\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\nn, k, d = map(int, input().split())\r\n\r\n\r\n\r\ndp = [[None for i in range(2)] for z in range(n + 1)]\r\n\r\n@bootstrap\r\ndef dfs(totalSum, state):\r\n if not totalSum:\r\n if state:\r\n yield 1\r\n yield 0; \r\n \r\n if totalSum < 0:\r\n yield 0\r\n \r\n \r\n if dp[totalSum][state] is not None:\r\n yield dp[totalSum][state] \r\n \r\n \r\n \r\n currentSum = 0\r\n for i in range(1, k + 1):\r\n newState = 1 if i >= d else 0\r\n newState |= state\r\n currentSum += (yield dfs(totalSum - i, newState))\r\n currentSum %= (10**9 + 7)\r\n \r\n dp[totalSum][state] = currentSum\r\n yield currentSum\r\n \r\n\r\n\r\nprint(dfs(n, 0))\r\n\r\n \r\n \r\n \r\n\r\n", "from collections import defaultdict\r\n\r\nn, k, d = map(int, input().split())\r\nmemo = defaultdict(list)\r\n\r\ndef dp(n):\r\n if n == 0:\r\n memo[0] = [1, 0] \r\n return memo[0]\r\n\r\n if memo[n]: return memo[n]\r\n\r\n memo[n] = [0, 0]\r\n\r\n for i in range(1, k + 1):\r\n if i > n: continue\r\n memo[n][0] += dp(n - i)[0]\r\n if i >= d:\r\n memo[n][1] += memo[n - i][0]\r\n\r\n elif memo[n-i][1]:\r\n memo[n][1] += memo[n-i][1]\r\n \r\n return memo[n]\r\n\r\nprint(dp(n)[1] % 1000000007)", "from functools import lru_cache\r\n\r\n\r\n@lru_cache(None)\r\ndef rec(curr=0, flag=False):\r\n if curr == n:\r\n if flag:\r\n return 1\r\n return 0\r\n\r\n elif curr > n:\r\n return 0\r\n\r\n res = 0\r\n for i in range(1, k + 1):\r\n res = (res + (rec(curr + i, flag or i >= d) % m)) % m\r\n return res\r\n\r\n\r\nn, k, d = list(map(int, input().split()))\r\nm = 10 ** 9 + 7\r\nprint(rec())\r\n", "import functools\n[starting_weight, k, minimum_weight] = [int(x) for x in input().split(\" \")]\n\[email protected]\ndef paths(weight, satisfied):\n if weight < 0:\n return 0\n if weight == 0:\n return satisfied\n total_paths = 0\n for i in range(1, min(weight, k) + 1):\n total_paths += paths(weight - i, satisfied or i >= minimum_weight)\n return total_paths\n\nprint(paths(starting_weight, False) % 1000000007)\n", "n,k,d=map(int, input().split())\na=[[1],[1]]\nfor i in range(1,n+1):\n a[0].append(sum(a[0][max(i-d+1,0):]))\n a[1].append(sum(a[1][max(i-k,0):]))\nprint(int((a[1][-1]-a[0][-1])%(10**9+7)))\n\n\t \t \t\t \t \t\t \t \t \t\t\t", "target, k, d = map(int, input().split())\r\nmod = 1000000007\r\n\r\nmemo = {}\r\n\r\ndef dp(val, valid, weight):\r\n if val == target and valid:\r\n return 1\r\n \r\n if val >= target or weight > k:\r\n return 0\r\n \r\n if not valid and weight >= d:\r\n valid = True\r\n \r\n state = (val, valid, weight)\r\n \r\n if state not in memo:\r\n memo[state] = dp(val + weight, valid, 1) + dp(val, valid, weight + 1)\r\n \r\n return memo[state]\r\n\r\nprint(dp(0, False, 1) % mod)", "n,k,d = list(map(int,input().split()))\r\nmodulo = 10**9+7\r\ndef F(n,x):\r\n f = [1]+[0]*n\r\n for i in range(1,n+1):\r\n f[i] = sum(f[max(i-x,0):i])\r\n return f[n]\r\n\r\nprint((F(n,k)-F(n,d-1))%modulo)\r\n", "n,k,d = [int(e) for e in input().split() ]\r\nmemory = [[-1]*k]*101\r\ncount = 0 \r\nif n < d:\r\n print(0)\r\nelse:\r\n D = [[],[]]\r\n D[0].append(1) \r\n # print(D)\r\n for i in range(1,n+1): \r\n tmp= 0 \r\n for j in range(1, min(i+1 , d )):\r\n # print(len(D[0]),i, j)\r\n tmp += D[0][i - j]\r\n D[0].append(tmp)\r\n for i in range(d):\r\n D[1].append(0) \r\n D[1].append(1) \r\n for i in range(d+1 , n+1):\r\n tmp= 0 \r\n for j in range(1, min(k+1,n+1) ):\r\n # print(i-j)\r\n if i-j >=0 :\r\n if j < d : \r\n tmp += D[1][i - j]\r\n else: \r\n tmp += D[0][i-j] + D[1][i-j]\r\n D[1].append(tmp)\r\n # print(D)\r\n print(D[1][n]%1000000007)\r\n", "n, k, d = [int(x) for x in input().split()]\n\nf = [[0 for j in range(n + 1)] for i in range(n + 1)]\ng = [[0 for j in range(n + 1)] for i in range(n + 1)]\n\n#f[x][y] = the number of paths length x with weight y\n\nf[0][0], g[0][0] = 1, 1\n\nf_count, g_count = 0, 0 \nfor x in range(n):\n for y in range(x, n):\n if f[x][y] == 0:\n break\n\n for diff in range(1, k + 1):\n try:\n f[x + 1][y + diff] += f[x][y]\n if y + diff == n: f_count += (f[x][y])\n except:\n break\n\n for diff in range(1, d):\n try:\n g[x + 1][y + diff] += g[x][y]\n if y + diff == n: g_count += (g[x][y])\n except:\n break\n\nprint((f_count - g_count) % (10 ** 9 + 7))\n\n\n\n\n\n\n\n ", "#I = lambda: [int(i) for i in input().split()]\r\n#import io, os, sys\r\n#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n \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\nmod = 1000000007\r\n# print(\"Case #\"+str(_+1)+\":\",)\r\n \r\nfrom collections import Counter,defaultdict,deque\r\n#from heapq import heappush,heappop,heapify\r\nimport sys\r\nimport math\r\nimport bisect\r\ndef lcm(a,b):\r\n return ((a*b)//math.gcd(a,b))\r\n \r\n \r\nfor _ in range(1):\r\n n ,k ,d = map(int,input().split())\r\n dp1 = [0 for i in range(n+1)]\r\n dp1[0] = 1\r\n for i in range(1,n+1):\r\n for j in range(1,k+1):\r\n if j<=i:\r\n dp1[i] = (dp1[i-j] + dp1[i])%mod\r\n dp2 = [0 for i in range(n+1)]\r\n dp2[0] = 1\r\n for i in range(1,n+1):\r\n for j in range(1,d):\r\n if j<=i:\r\n dp2[i] = (dp2[i-j] + dp2[i])%mod\r\n\r\n print((dp1[n]-dp2[n])%mod)\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", "def main():\r\n MOD = 1_000_000_007\r\n n, k, d = read_ints()\r\n\r\n dp = [[0] * 2 for _ in range(n+1)]\r\n dp[n][0] = 1\r\n for i in range(n, -1, -1):\r\n for ki in range(1, k+1):\r\n if i - ki >= 0:\r\n dp[i-ki][ki>=d] += dp[i][0]\r\n dp[i-ki][1] += dp[i][1]\r\n\r\n dp[i-ki][0] %= MOD\r\n dp[i-ki][1] %= MOD\r\n\r\n print(dp[0][1])\r\n\r\n\r\ndef input(): return next(test).strip()\r\ndef read_ints(): return [int(c) for c in input().split()]\r\ndef print_lines(lst): print('\\n'.join(map(str, lst)))\r\n\r\n\r\nif __name__ == \"__main__\":\r\n import sys\r\n from os import environ as env\r\n if 'COMPUTERNAME' in env and 'L2A6HRI' in env['COMPUTERNAME']:\r\n sys.stdout = open('out.txt', 'w')\r\n sys.stdin = open('in.txt', 'r')\r\n\r\n test = iter(sys.stdin.readlines())\r\n\r\n main()\r\n", "mod=10**9+7\r\nn,k,d=map(int,input().split())\r\ndp0=[0]*(n+1)\r\ndp1=[0]*(n+1)\r\ndp0[0]=1\r\nfor i in range(1,n+1):\r\n for j in range(1,k+1):\r\n if i-j<0:\r\n break\r\n if j<d:\r\n dp0[i]+=dp0[i-j]\r\n dp0[i] %= mod\r\n dp1[i]+=dp1[i-j]\r\n dp1[i] %= mod\r\n else:\r\n dp1[i]+=dp0[i-j]\r\n dp1[i] %= mod\r\n dp1[i]+=dp1[i-j]\r\n dp1[i] %= mod\r\n \r\nprint(dp1[n])", "from functools import cache\n\n\n@cache\ndef f(n, b):\n return (\n int(n == 0 and b)\n if n <= 0\n else sum(f(n - i, b or i >= d) for i in range(1, k + 1)) % MOD\n )\n\n\nMOD = 1_000_000_007\nn, k, d = map(int, input().split())\nprint(f(n, False))\n", "\r\nm,n,k = map(int , input().split())\r\ncount = 0\r\n\r\ncache = {}\r\ndef backtrack(node=0 , weight=0 , flag=0):\r\n if (node , weight , flag) in cache:\r\n return cache[(node , weight, flag)]\r\n if weight > m :\r\n return 0\r\n\r\n if weight == m and flag:\r\n return 1\r\n \r\n res = 0\r\n for i in range(1,n+1):\r\n res += backtrack(i , weight+i , flag or (i >= k))\r\n cache[(node , weight , flag)] = res\r\n return res\r\n \r\nprint(backtrack()%1000000007)", "import collections\nimport heapq\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom io import BytesIO, IOBase\nimport os\n######################################################################################\n#--------------------------------------funs here-------------------------------------#\n######################################################################################\ndef values(): return tuple(map(int, sys.stdin.readline().split()))\ndef inlsts(): return [int(i) for i in sys.stdin.readline().split()]\ndef inp(): return int(sys.stdin.readline())\ndef instr(): return sys.stdin.readline().strip()\ndef words(): return [i for i in sys.stdin.readline().strip().split()]\ndef chars(): return [i for i in sys.stdin.readline().strip()]\n######################################################################################\n#--------------------------------------code here-------------------------------------#\n######################################################################################\ndef solve():\n mod=7+10**9\n n,k,d=values()\n dp={}\n def rec(sm,x): \n if sm==n and x:return 1\n if sm>=n:return 0\n if (sm,x) in dp:return dp[(sm,x)]\n ans=0\n for i in range(1,k+1):\n ans=(ans%mod+rec(sm+i,x or i>=d)%mod)%mod\n dp[(sm,x)]=ans\n return ans\n \n print(rec(0,0))\n\n\nif __name__ == \"__main__\":\n # for i in range(inp()):\n solve()\n", "MOD = int(1e9 + 7)\r\n\r\n\r\ndef solve():\r\n n, k, d = map(int, input().split())\r\n\r\n dp = []\r\n dp2 = []\r\n for _ in range(n + 1):\r\n dp.append([0 for __ in range(n + 1)])\r\n dp2.append([0 for __ in range(n + 1)])\r\n\r\n dp[0][0] = 1\r\n ans = 0\r\n for i in range(1, n + 1):\r\n for j in range(1, n + 1):\r\n for p in range(1, k + 1):\r\n if j - p >= 0:\r\n dp[i][j] += dp[i - 1][j - p]\r\n dp[i][j] %= MOD\r\n\r\n ans += dp[i][n]\r\n ans %= MOD\r\n\r\n dp2[0][0] = 1\r\n ans2 = 0\r\n for i in range(1, n + 1):\r\n for j in range(1, n + 1):\r\n for p in range(1, d):\r\n if j - p >= 0:\r\n dp2[i][j] += dp2[i - 1][j - p]\r\n dp2[i][j] %= MOD\r\n\r\n ans2 += dp2[i][n]\r\n ans2 %= MOD\r\n\r\n print((ans + MOD - ans2) % MOD)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n solve()\r\n", "n, k, d = list(map(int,input().split()))\r\nmod = 10 ** 9 + 7\r\n \r\ndp = [[0,0] for i in range(n+k+1)]\r\ndp[k][0] = 1\r\n \r\nfor i in range(k,n+k+1):\r\n for j in range(1,min(d,n)):\r\n dp[i][0] = (dp[i][0]+dp[i-j][0])%mod\r\n \r\n for j in range(d,min(n,k)+1):\r\n dp[i][1] = (dp[i][1] + dp[i-j][0])%mod\r\n \r\n for j in range(1,min(k,n)+1):\r\n dp[i][1] = (dp[i][1] + dp[i-j][1])%mod\r\nprint(dp[n+k][1])", "import sys\r\nsys.setrecursionlimit(10**7)\r\n\r\ndef call(amount, flag):\r\n if amount > n:\r\n return 0\r\n if amount == n:\r\n return flag\r\n\r\n if dp[amount][flag] != -1:\r\n return dp[amount][flag]\r\n\r\n cnt = 0\r\n\r\n for i in range(1, k+1):\r\n cnt += call(amount + i, flag or (i >= d)) % INF\r\n\r\n dp[amount][flag] = cnt % INF\r\n return dp[amount][flag]\r\n\r\nn, k, d = map(int, input().split())\r\ndp = [[-1] * 3 for _ in range(n + 1)]\r\nINF = 1000000007\r\n\r\nprint(call(0, 0))\r\n", "n, k, d = map(int, input().split())\r\nA = [0] + [0] * n\r\nB = [1] + [0] * n\r\nfor i in range(n):\r\n\tvg = min(n + 1, i + k + 1)\r\n\tvg2 = min(n + 1, i + d)\r\n\tfor j in range(i + d, vg):\r\n\t\tA[j] += B[i]\r\n\tfor j in range(i + 1, vg):\r\n\t\tA[j] += A[i]\r\n\tfor j in range(i + 1, vg2):\r\n\t\tB[j] += B[i]\r\nprint(A[n] % 1000000007)\r\n", "m=1000000007\r\nn,k,d=map(int,input().split())\r\ndef solve(n,d,dp):\r\n if n<0: return 0\r\n if n==0: return 1\r\n if dp[n]!=-1: return dp[n]\r\n res=0\r\n for i in range(1,d):\r\n res+=solve(n-i,d,dp)\r\n dp[n]=res%m\r\n return res\r\n\r\nprint((solve(n,k+1,[-1]*(n+1))-solve(n,d,[-1]*(n+1))+m)%m)\r\n", "a, b, c = list(map(int,input().split()))\r\ndp = [[-1 for i in range(2)] for i in range(10005)]\r\nmod = int(1e9+7)\r\n\r\ndef KTree(Sum, flag):\r\n if Sum >= a:\r\n return Sum == a and flag == 1\r\n if dp[Sum][flag] != -1:\r\n return dp[Sum][flag]\r\n pick = 0\r\n for i in range(1, b + 1):\r\n pick += KTree(Sum + i, flag or (i >= c))\r\n pick %= mod\r\n dp[Sum][flag] = pick\r\n return dp[Sum][flag]\r\nprint(KTree(0, 0))", "n,k,d=map(int,input().split())\r\nq=[0]*(n+1)\r\nq[0]=1\r\nfor j in range(1,n+1):\r\n for i in range(1,k+1):\r\n if j>=i:\r\n q[j]+=q[j-i]\r\nw=[0]*(n+1)\r\nw[0]=1\r\nfor j in range(1,n+1):\r\n for i in range(1,d):\r\n if j>=i:\r\n w[j]+=w[j-i]\r\nprint((q[-1]-w[-1])%1000000007)\r\n" ]
{"inputs": ["3 3 2", "3 3 3", "4 3 2", "4 5 2", "28 6 3", "5 100 1", "50 6 3", "10 13 6", "20 16 14", "1 10 1", "8 11 4", "16 5 4", "5 26 17", "35 47 42", "11 6 2", "54 60 16", "47 5 1", "70 6 1", "40 77 77", "96 9 6", "52 46 4", "74 41 28", "100 100 100", "99 99 5", "100 100 1", "98 98 64", "28 74 2", "86 69 62", "9 17 14", "73 72 12", "41 98 76", "1 1 1", "1 100 100", "1 100 1", "1 100 2", "2 100 2", "2 100 1", "50 50 1", "100 50 50", "3 2 2", "100 50 3", "90 97 24", "31 8 8", "78 90 38", "100 13 11", "100 45 8", "31 8 4", "35 95 9", "45 5 3", "1 5 5", "89 75 59", "90 100 30", "89 73 32", "100 90 80"], "outputs": ["3", "1", "6", "7", "110682188", "16", "295630102", "48", "236", "1", "47", "16175", "0", "0", "975", "931055544", "164058640", "592826579", "0", "362487247", "27907693", "806604424", "1", "700732369", "988185646", "237643149", "134217727", "217513984", "0", "426374014", "0", "1", "0", "1", "0", "1", "2", "949480669", "661237556", "2", "494224664", "413496885", "52532592", "744021655", "883875774", "367847193", "924947104", "927164672", "252804490", "0", "179807625", "697322870", "152673180", "11531520"]}
UNKNOWN
PYTHON3
CODEFORCES
77
e28053549a307d4c6f596921d5df6f25
Homework
Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of *n* small Latin letters; the task was to learn the way the letters that the string contains are written. However, as Gerald is too lazy, he has no desire whatsoever to learn those letters. That's why he decided to lose some part of the string (not necessarily a connected part). The lost part can consist of any number of segments of any length, at any distance from each other. However, Gerald knows that if he loses more than *k* characters, it will be very suspicious. Find the least number of distinct characters that can remain in the string after no more than *k* characters are deleted. You also have to find any possible way to delete the characters. The first input data line contains a string whose length is equal to *n* (1<=≤<=*n*<=≤<=105). The string consists of lowercase Latin letters. The second line contains the number *k* (0<=≤<=*k*<=≤<=105). Print on the first line the only number *m* — the least possible number of different characters that could remain in the given string after it loses no more than *k* characters. Print on the second line the string that Gerald can get after some characters are lost. The string should have exactly *m* distinct characters. The final string should be the subsequence of the initial string. If Gerald can get several different strings with exactly *m* distinct characters, print any of them. Sample Input aaaaa 4 abacaba 4 abcdefgh 10 Sample Output 1 aaaaa 1 aaaa 0
[ "from collections import Counter\r\n\r\ns = input()\r\nk = int(input())\r\nC = sorted(Counter(s).items(), key=lambda x: -x[1])\r\n\r\nwhile k and C:\r\n ch, n = C.pop()\r\n x = min(k,n)\r\n s = s.replace(ch, '', x)\r\n k -= x\r\n\r\nprint(len(set(s)))\r\nprint(s)", "dic = {}\ns_str = input()\nfor c in s_str:\n\tif c in dic:\n\t\tdic[c] += 1\n\telse:\n\t\tdic[c] = 1\n\nk = int(input())\n\ncdns = sorted(dic.items(), key=lambda x:x[1])\n\nkeys = set()\n\n\nfor key,value in cdns:\n\tif value <= k:\n\t\tkeys.add(key)\n\t\tk -= value\n\telse:\n\t\tbreak\nresult_str = ''\nfor c in s_str:\n\tif c not in keys:\n\t\tresult_str += c\n\ncount = len(cdns) - len(keys)\nprint(count)\nprint(result_str)\n", "import collections\r\ns=input()\r\nk=int(input())\r\n\r\nd1=dict()\r\nfor i in s:\r\n if i in d1:d1[i]+=1\r\n else:d1[i]=1\r\nd1=sorted(d1.items(), key=lambda x: x[1])\r\nA=set()\r\nans=0\r\n#print(d)\r\nfor i in d1:\r\n if k-i[1]>=0:\r\n A.add(i[0])\r\n k-=i[1]\r\n ans+=1\r\nprint(len(d1)-ans)\r\nfor i in s:\r\n if i not in A:\r\n print(i,end=\"\")\r\n \r\n\r\n", "s=input()\r\nk=int(input())\r\nl=list(s)\r\nl1=[]\r\nif k >=len(s):\r\n print('0')\r\n print('')\r\nelse:\r\n ls=list(set(l))\r\n lcount=[]\r\n for i in ls:\r\n lcount.append(l.count(i))\r\n lcount.sort(reverse=True)\r\n lsum = 0\r\n for i in range(len(ls)):\r\n lsum += lcount[i]\r\n if lsum >= len(s)-k:\r\n break\r\n ls.sort(key=lambda x: l.count(x),reverse=True)\r\n end1=i+1\r\n ls = ls[:i+1]\r\n for p in range(len(l)):\r\n if l[p] in ls:\r\n l1.append(l[p])\r\n print(end1)\r\n s=''\r\n for q in l1:\r\n s+=q\r\n print(s)", "'''input\n'''\nimport 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 functools import cmp_to_key\n\n\nsys.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))\nsort = lambda x,compare: sorted(x, key=cmp_to_key(compare))\n\nmod=1000000007\n\ndef isKthBitSet(num, pos):\n return num & (1 << pos)\n\ndef setKthBit(num, pos):\n return num | (1 << pos)\n\ndef compare(a, b):\n\tif a[1] > b[1]:\n\t\treturn 1\n\treturn -1\n\n\t\n#main code\nd = {}\nstring = strng()\nk = stdint()\nfor c in string:\n\tif c in d:\n\t\td[c] += 1\n\telse:\n\t\td[c] = 1\nlst = list(sorted(d.items(), key=cmp_to_key(compare)))\nfor i in range(len(lst)):\n\t#print(k, lst[i][1])\n\tif k == 0:\n\t\tbreak\n\tif lst[i][1] < k:\n\t\tk -= lst[i][1]\n\t\tlst[i] = (lst[i][0], 0)\n\telse:\n\t\tlst[i]= (lst[i][0], lst[i][1] - k)\n\t\tbreak\n\t\nlst = dict(lst)\ncount = 0\nfor item in lst:\n\tif lst[item] != 0:\n\t\tcount += 1\nprint(count)\nfor c in string:\n\tif lst[c] > 0:\n\t\tprint(c, end=\"\")\n\t\tlst[c] -= 1\n\t\t\t \t\t \t\t\t\t \t\t \t \t\t\t\t\t \t\t \t", "s = input()\nn = int(input())\n\ncnt = [0]*26\nfor i in s:\n cnt[ord(i)-ord('a')] += 1\ncnt = [(cnt[i], chr(ord('a')+i)) for i in range(26)]\ncnt.sort(key= lambda x:x[0])\ncnt = [i for i in cnt if i[0] > 0]\nss = set()\nfor i in cnt:\n if n>=i[0]:\n n-=i[0]\n ss.add(i[1])\nt = ''\nfor i in s:\n if i not in ss:\n t+=i\nprint(len(set(list(t))))\nprint(t)\n", "s, t, n = 0, input(), int(input())\r\np = {i: 0 for i in 'abcdefghijklmnopqrstuvwxyz'}\r\nfor i in t: p[i] += 1\r\np = {i: p[i] for i in p if p[i]}\r\nq = sorted((k, i) for i, k in p.items())\r\nfor k, i in q:\r\n if n < k: break\r\n t = t.replace(i, '')\r\n n -= k\r\n s += 1\r\nprint(len(p) - s)\r\nprint(t)", "import sys\r\nimport string\r\n\r\nfrom collections import Counter, defaultdict\r\nfrom math import fsum, sqrt, gcd, ceil, factorial\r\nfrom operator import add\r\nfrom itertools import accumulate, count\r\n\r\ninf = float(\"inf\")\r\n# input = sys.stdin.readline\r\nflush = lambda: sys.stdout.flush\r\ncomb = lambda x, y: (factorial(x) // factorial(y)) // factorial(x - y)\r\n\r\n\r\n# inputs\r\n# ip = lambda : input().rstrip()\r\nip = lambda: input()\r\nii = lambda: int(input())\r\nr = lambda: map(int, input().split())\r\nrr = lambda: list(r())\r\n\r\n\r\ns = ip()\r\nk = ii()\r\n\r\narr = Counter(s)\r\nbrr = set()\r\nf = True\r\nwhile 1:\r\n if not f or not arr:\r\n break\r\n x = min(arr.values())\r\n for i in string.ascii_lowercase:\r\n if arr[i] == x:\r\n if k >= x:\r\n k -= x\r\n brr.add(i)\r\n del arr[i]\r\n else:\r\n f = False\r\n break\r\n\r\nprint(len(arr.keys()))\r\nfor i in s:\r\n if i not in brr:\r\n print(i,end=\"\")", "'''input\r\n'''\r\nimport sys\r\nimport math\r\nimport bisect\r\nfrom sys import stdin,stdout\r\nfrom math import gcd,floor,sqrt,log\r\nfrom collections import defaultdict as dd\r\nfrom bisect import bisect_left as bl,bisect_right as br\r\nfrom functools import cmp_to_key\r\n\r\n\r\nsys.setrecursionlimit(100000000)\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\nstdstr =lambda: stdin.readline()\r\nstdint =lambda: int(stdin.readline())\r\nstdpr =lambda x: stdout.write(str(x))\r\nsort = lambda x,compare: sorted(x, key=cmp_to_key(compare))\r\n\r\nmod=1000000007\r\n\r\ndef isKthBitSet(num, pos):\r\n return num & (1 << pos)\r\n\r\ndef setKthBit(num, pos):\r\n return num | (1 << pos)\r\n\r\ndef compare(a, b):\r\n\tif a[1] > b[1]:\r\n\t\treturn 1\r\n\treturn -1\r\n\r\n\t\r\n#main code\r\nd = {}\r\nstring = strng()\r\nk = stdint()\r\nfor c in string:\r\n\tif c in d:\r\n\t\td[c] += 1\r\n\telse:\r\n\t\td[c] = 1\r\nlst = list(sorted(d.items(), key=cmp_to_key(compare)))\r\nfor i in range(len(lst)):\r\n\t#print(k, lst[i][1])\r\n\tif k == 0:\r\n\t\tbreak\r\n\tif lst[i][1] < k:\r\n\t\tk -= lst[i][1]\r\n\t\tlst[i] = (lst[i][0], 0)\r\n\telse:\r\n\t\tlst[i]= (lst[i][0], lst[i][1] - k)\r\n\t\tbreak\r\n\t\r\nlst = dict(lst)\r\ncount = 0\r\nfor item in lst:\r\n\tif lst[item] != 0:\r\n\t\tcount += 1\r\nprint(count)\r\nfor c in string:\r\n\tif lst[c] > 0:\r\n\t\tprint(c, end=\"\")\r\n\t\tlst[c] -= 1", "s = list(input())\r\nk = int(input())\r\ndictionary = [0] * 26\r\ntemp = []\r\nfor i in range(26):\r\n temp.append(chr(ord('a') + i))\r\nd = 0\r\nfor i in s:\r\n if dictionary[ord(i) - ord('a')] == 0:\r\n d += 1\r\n dictionary[ord(i) - ord('a')] += 1\r\nfor i in range(26):\r\n for j in range(26 - i - 1):\r\n if dictionary[j] > dictionary[j + 1]:\r\n dictionary[j], dictionary[j + 1] = dictionary[j + 1], dictionary[j]\r\n temp[j], temp[j + 1] = temp[j + 1], temp[j]\r\nfor i in range(26):\r\n if dictionary[i] != 0 and dictionary[i] <= k:\r\n for j in range(len(s)):\r\n if s[j] == temp[i]:\r\n s[j] = '#'\r\n d -= 1\r\n k -= dictionary[i]\r\nprint(d)\r\nfor i in s:\r\n if i != '#':\r\n print(i, end='')\r\n", "from operator import itemgetter\r\n\r\n\r\ndef dif_c(s):\r\n cs = set()\r\n i = 0\r\n for c in s:\r\n if not c in cs:\r\n cs.add(c)\r\n i += 1\r\n return i\r\n\r\n\r\nclass CodeforcesTask101ASolution:\r\n def __init__(self):\r\n self.result = ''\r\n self.word = ''\r\n self.k = 0\r\n\r\n def read_input(self):\r\n self.word = input()\r\n self.k = int(input())\r\n\r\n def process_task(self):\r\n chars = map(chr, range(97, 123))\r\n occurs = []\r\n for c in chars:\r\n occurs.append((c,self.word.count(c)))\r\n occurs = sorted(occurs, key=itemgetter(1))\r\n sums = []\r\n for x in range(len(occurs)):\r\n l_sum = 0\r\n letters = []\r\n i = x\r\n while l_sum < self.k:\r\n if l_sum + occurs[i][1] <= self.k:\r\n if occurs[i][1]:\r\n letters.append(occurs[i][0])\r\n l_sum += occurs[i][1]\r\n i += 1\r\n if i == len(occurs):\r\n break\r\n sums.append((letters, l_sum, len(letters)))\r\n #if l_sum == self.k:\r\n # break\r\n sums = sorted(sums, key=itemgetter(2), reverse=True)\r\n #print(sums)\r\n #print(occurs)\r\n new_word = self.word\r\n for char in sums[0][0]:\r\n new_word = new_word.replace(char, \"\")\r\n self.result = \"{0}\\n{1}\".format(dif_c(self.word) - sums[0][2], new_word)\r\n\r\n\r\n def get_result(self):\r\n return self.result\r\n\r\n\r\nif __name__ == \"__main__\":\r\n Solution = CodeforcesTask101ASolution()\r\n Solution.read_input()\r\n Solution.process_task()\r\n print(Solution.get_result())\r\n", "#n,k = map(int, input().strip().split(' '))\r\n#lst = list(map(int, input().strip().split(' ')))\r\ns=input()\r\ns=list(s)\r\nk1=int(input())\r\nlst = list( dict.fromkeys(s) )\r\nfreq = {} \r\nfor items in lst: \r\n freq[items] = s.count(items) \r\n\r\nf={k: v for k, v in sorted(freq.items(), key=lambda item: item[1])}\r\n\r\nt=0\r\ns1=[]\r\nfor i in f.keys():\r\n if t+f[i]<=k1:\r\n t+=f[i]\r\n s1.append(i)\r\n\r\ni=0\r\nwhile(i<len(s)):\r\n if s[i] in s1:\r\n del s[i]\r\n else:\r\n i+=1\r\nlst = list( dict.fromkeys(s) )\r\nprint(len(lst))\r\nfor i in range(len(s)):\r\n print(s[i],end=\"\")\r\n \r\n\r\n", "from collections import Counter\r\ns=input()\r\nk=int(input())\r\nc=Counter(s)\r\nseen=set()\r\nans=[[c[el],el] for el in c]\r\nans.sort(reverse=True)\r\nwhile ans and ans[-1][0]<=k:\r\n _,ch=ans.pop()\r\n seen.add(ch)\r\n k-=_\r\nans=\"\"\r\np=set()\r\nfor el in s:\r\n if el not in seen:\r\n ans+=el\r\n p.add(el)\r\nprint(len(p))\r\nprint(ans)", "s=input()\r\nar=sorted([[s.count(c),c] for c in set(s)])\r\nres=len(ar)\r\nlef=int(input())\r\ndl=set()\r\nfor e in ar:\r\n if(e[0]<=lef):\r\n lef-=e[0]\r\n dl.add(e[1])\r\n res-=1\r\nprint(res)\r\nprint(''.join([x for x in s if x not in dl]))\r\n", "\r\na = input()\r\nk = int(input())\r\ntemp = ''\r\ndictx = {}\r\nfor i in ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',\r\n 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',\r\n 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',\r\n 'y', 'z']:\r\n dictx[i] = 0\r\n\r\nfor i in a:\r\n dictx[i] += 1\r\n\r\ndictx2 = {}\r\nfor i in dictx:\r\n if dictx[i] != 0:\r\n dictx2[i] = dictx[i]\r\n\r\nsortx = sorted(dictx2, key=lambda key: dictx2[key])\r\n\r\nwhile k > 0 and sortx != []:\r\n if dictx2[sortx[0]] > k:\r\n k = 0\r\n else:\r\n k -= dictx2[sortx[0]]\r\n for i in a:\r\n if i != sortx[0]:\r\n temp += i\r\n a = temp\r\n temp = ''\r\n sortx = sortx[1:]\r\n \r\nprint(len(set([i for i in a])))\r\nprint(a)\r\n", "s=input()\r\nk=int(input())\r\na=[]\r\nfor x in set(s):\r\n a.append([s.count(x),x])\r\na.sort()\r\nfor z in a:\r\n if z[0]>k:break\r\n k-=z[0]\r\n s=s.replace(z[1],'')\r\nprint(len(set(s)))\r\nprint(s)\r\n\r\n \r\n \r\n", "import sys\r\nimport math\r\n\r\nst = input()\r\nk = int(input())\r\n\r\nd = dict()\r\nalla = 0\r\nfor i in st:\r\n if i in d:\r\n d[i] += 1\r\n else:\r\n d[i] = 1\r\n alla += 1\r\n\r\nf = sorted(d.items(), key = lambda x: x[1])\r\n\r\nv = set()\r\np = 0\r\nfor i in f:\r\n if(k - i[1] >= 0):\r\n v.add(i[0])\r\n k -= i[1]\r\n p += 1\r\n else:\r\n break\r\n\r\nprint(alla - p)\r\nfor i in st:\r\n if i not in v:\r\n sys.stdout.write(i)\r\n ", "from collections import Counter\r\nstr_line = input()\r\nnum = int(input())\r\n\r\nif len(str_line) < num:\r\n print(0)\r\n print(\"\")\r\nelse:\r\n re_ch = []\r\n c = Counter(str_line)\r\n c = sorted(c.items(),key=lambda x : x[1])\r\n c = dict(c)\r\n remove = 0\r\n for k, v in c.items():\r\n if remove + v <= num:\r\n remove += v\r\n re_ch.append(k)\r\n for ch in re_ch:\r\n str_line = str_line.replace(ch, \"\", c[ch])\r\n print(len(c.keys()) - len(re_ch))\r\n print(str_line)\r\n", "# Submitted using https://github.com/Nirlep5252/codeforces-cli\n# >.<\n\ns = input()\nss = s\nk = int(input())\n\nc = {a: s.count(a) for a in set(s)}\nchars_freq = c.copy()\nuwu = sorted(chars_freq.items(), key = lambda x: x[1])\n\nfor e, i in uwu:\n if i <= k:\n k -= i\n del chars_freq[e]\n ss = ss.replace(e, \"\")\n else:\n chars_freq[e] = i - k\n k = 0\n break\n\nprint(len(set(ss)))\nprint(ss)\n", "# LUOGU_RID: 104929878\ns = input()\r\nk = int(input())\r\nfor c, ch in sorted([[s.count(x), x] for x in set(s)]):\r\n if c <= k:\r\n k -= c\r\n s = s.replace(ch, '')\r\nprint(len(set(s)))\r\nprint(s)\r\n", "s = input()\r\nn = int(input())\r\n\r\nsetS = set(s)\r\ncounts = {x : 0 for x in setS}\r\n\r\nfor c in s:\r\n counts[c] += 1\r\n\r\ndef key(c):\r\n return counts[c]\r\n\r\nss = list(setS)\r\nss.sort(key = key)\r\nlnSS = len(ss)\r\nr = 0\r\nnr = 0\r\nwhile nr < n:\r\n if r < lnSS and nr + counts[ss[r]] <= n:\r\n nr += counts[ss[r]] \r\n r += 1\r\n else:\r\n break\r\n\r\nprint(lnSS - r)\r\nfor i in range(r):\r\n s = s.replace(ss[i] , '')\r\nprint(s)\r\n", "s = input()\r\nn = int(input())\r\nx = len(s)\r\n\r\nif x<=n:\r\n print(0,\"\\n\")\r\nelse:\r\n dic = {}\r\n for i in s:\r\n dic[i] = dic.get(i,0) + 1\r\n dic = {k: v for k, v in sorted(dic.items(), key=lambda item: item[1])}\r\n c = 0\r\n m = []\r\n for i,j in dic.items():\r\n c+=j\r\n \r\n if c>n:\r\n m.append(i)\r\n \r\n else:\r\n s = s.replace(i,\"\")\r\n \r\n print(len(m))\r\n print(s)", "s = input()\r\nk = int(input())\r\n\r\nd = {}\r\nfor el in s:\r\n if el in d:\r\n d[el] += 1\r\n else:\r\n d[el] = 1\r\n \r\nd = [[x,y] for x, y in sorted(d.items(), key=lambda x: x[1])]\r\n#print(d)\r\nidx = 0\r\nwhile k > 0 and idx < len(d):\r\n change = min(k, d[idx][1])\r\n d[idx][1] -= change\r\n k -= change\r\n if change == d[idx][1]:\r\n idx += 1\r\n \r\n \r\nd = {k: v for k, v in d}\r\n\r\ns = list(s)\r\nfor i in range(len(s)):\r\n if s[i] not in d or (s[i] in d and d[s[i]] == 0):\r\n s[i] = '#'\r\n else:\r\n d[s[i]] -= 1\r\n \r\n \r\n\r\ns = ''.join([x for x in s if x != '#'])\r\nprint(len(set(s)))\r\nprint(s)\r\n \r\n", "from collections import Counter\n\ns = list(input())\nk = int(input())\n\nif k >= len(s):\n print(0)\n print()\n exit()\n\ncnt = Counter(s)\n\nfor _ in range(k):\n minimum = min(cnt, key=cnt.get)\n cnt[minimum] -= 1\n if cnt[minimum] == 0:\n del cnt[minimum]\n\nprint(len(cnt))\nfor char in s:\n if char in cnt:\n print(char, end=\"\")\nprint()\n", "x = {}\r\nr = input()\r\nk = int(input())\r\nf = []\r\nfor i in r:\r\n if x.get(i):\r\n x[i]+=1\r\n else:\r\n x[i]=1\r\n f.append(i)\r\nx = {k: v for k, v in sorted(x.items(), key=lambda item: item[1])}\r\nl = []\r\nfor i, j in x.items():\r\n k = k - j\r\n if k < 0:\r\n break\r\n elif k==0:\r\n l.append(i)\r\n else:\r\n l.append(i)\r\nprint(len(f) - len(l))\r\nfor i in r:\r\n if i not in l:\r\n print(i,end=\"\")\r\n", "from collections import *\r\n\r\ns = input()\r\nk = int(input())\r\nn = len(s)\r\nif k >= n:\r\n print(0)\r\n print()\r\nelse:\r\n lst = Counter(s)\r\n count = sorted(lst.items(), key=lambda x: -x[1])\r\n while k and count:\r\n key = count[-1][0]\r\n value = lst[count[-1][0]]\r\n count.pop()\r\n mn = min(k, value)\r\n s = s.replace(key, \"\", mn)\r\n k -= mn\r\n print(len(set(s)))\r\n print(s)", "s=input()\r\nk=int(input())\r\nn=len(s)\r\nfrom collections import Counter \r\nc=Counter(s)\r\nfrom collections import defaultdict \r\nd=defaultdict(list)\r\nfor i in range(n):\r\n d[s[i]].append(i)\r\ncount=0 \r\nans=['']*n \r\nli=[[i,c[chr(i)]] for i in range(97,123)]\r\nli.sort(key=lambda x:x[1])\r\nfor i in range(len(li)):\r\n if li[i][1]<=k:\r\n k-=li[i][1]\r\n li[i][1]=0 \r\n elif k<li[i][1]:\r\n k=0 \r\n li[i][1]-=k \r\ncnt=0 \r\nfor i in range(len(li)):\r\n if li[i][1]>0:\r\n count+=1 \r\n chrctr=chr(li[i][0])\r\n cnt=0 \r\n for ind in d[chrctr]:\r\n ans[ind]=chrctr\r\n cnt+=1 \r\n if cnt==li[i][1]:\r\n break \r\nprint(count)\r\nprint(''.join(ans))", "from collections import Counter,defaultdict\r\ns=input().rstrip()\r\nk=int(input())\r\nd=Counter(s)\r\nd1=defaultdict(list)\r\nfor i in range(len(s)):\r\n d1[s[i]].append(i)\r\nl=[]\r\nfor x in d:\r\n l.append([x,d[x]])\r\na=sorted(l,key=lambda x:(x[1]))\r\nfor i in range(len(a)):\r\n if k<=0:\r\n break\r\n else:\r\n if k>=a[i][1]:\r\n k-=a[i][1]\r\n d1[a[i][0]]=[]\r\n else:\r\n d1[a[i][0]]=d1[a[i][0]][k:]\r\n k=0\r\nans=['0']*len(s)\r\nc=0\r\nfor x in d1:\r\n if len(d1[x])>0:c+=1\r\n for y in d1[x]:\r\n ans[y]=x\r\nres=''\r\nfor x in ans:\r\n if x!='0':res+=x\r\nprint(c)\r\nprint(res)", "kata=input()\r\nbanyak=int(input())\r\nkat=\"abcdefghijklmnopqrstuvwxyz\"\r\narr=[0]*26\r\nfor i in range(len(kata)):\r\n for j in range(26):\r\n if kata[i]==kat[j]:\r\n arr[j]+=1\r\n break\r\ntotal=0\r\n\r\nfor i in range(len(arr)):\r\n if(arr[i]>0):\r\n total+=1\r\nif(banyak>=len(kata)):\r\n print(\"0\",end=\"\\n\")\r\n print()\r\nelif(total==1):\r\n print(\"1\",end=\"\\n\")\r\n print(kata,end=\"\\n\")\r\n\r\nelif(banyak==0):\r\n print(total,end=\"\\n\")\r\n print(kata,end=\"\\n\")\r\nelse:\r\n Arr1=[]\r\n for i in range(26):\r\n if(arr[i]!=0):\r\n Arr1+=[[i,arr[i]]]\r\n for i in range(len(Arr1)):\r\n for j in range(i+1,len(Arr1)):\r\n if(Arr1[i][1]>Arr1[j][1]):\r\n temp=Arr1[i]\r\n Arr1[i]=Arr1[j]\r\n Arr1[j]=temp\r\n Hitung=0\r\n m=0\r\n saring=\"\"\r\n while(Hitung>-1 and m<len(Arr1)-1):\r\n Hitung+=int(Arr1[m][1])\r\n if(Hitung>banyak):\r\n break\r\n else:\r\n saring+=kat[Arr1[m][0]]\r\n total=total-1\r\n m=m+1\r\n output=\"\"\r\n for i in range(len(kata)):\r\n status=True\r\n for j in range(len(saring)):\r\n if kata[i]==saring[j]:\r\n status=False\r\n break\r\n \r\n if status==True:\r\n output+=kata[i]\r\n\r\n print(total,end=\"\\n\")\r\n print(output,end=\"\\n\")\r\n", "st=input()\r\nk=int(input())\r\ndic={}\r\nfor x in st:\r\n\tif x in dic:\r\n\t\tdic[x] += 1\r\n\telse:\r\n\t\tdic[x] = 1\r\nwhile len(dic):\r\n\tx = min(dic,key=dic.get)\r\n\tif k>=dic[x]:\r\n\t\tk -= dic[x]\r\n\t\tdel dic[x]\r\n\telse:\r\n\t\tbreak\r\nres=[]\r\nfor i in st:\r\n\tif i in dic:\r\n\t\tres.append(i)\r\nprint(len(dic))\r\nprint(*res,sep=\"\")# 1698175154.8552086", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\ns = list(input().rstrip())\r\nk = int(input())\r\ncnt = [0] * 26\r\nfor i in s:\r\n cnt[i - 97] += 1\r\nx = 0\r\ninf = pow(10, 9) + 1\r\nfor i in range(26):\r\n if not cnt[i]:\r\n cnt[i] = inf\r\nwhile True:\r\n mi = min(cnt)\r\n if x + mi > k:\r\n break\r\n x += mi\r\n cnt[cnt.index(mi)] = inf\r\nans = []\r\nfor i in s:\r\n if cnt[i - 97] ^ inf:\r\n ans.append(chr(i))\r\nm = 0\r\nfor i in cnt:\r\n m += min(1, i % inf)\r\nprint(m)\r\nsys.stdout.write(\"\".join(ans))", "from collections import Counter\r\n\r\nclass solve:\r\n def __init__(self):\r\n s=input()\r\n k=int(input())\r\n c=Counter(s).most_common()[::-1]\r\n count=0\r\n rem=set()\r\n for i in c:\r\n if i[1]<=k:\r\n k-=i[1]\r\n rem.add(i[0])\r\n else:\r\n count+=1\r\n ans=\"\"\r\n for i in s:\r\n if i not in rem:\r\n ans+=i\r\n print(count)\r\n print(ans)\r\n\r\nobj=solve()", "I=input\r\ns=I()\r\nC={}\r\nfor x in set(s):C[x]=s.count(x)\r\nk=int(I())\r\nt=sorted(set(s),key=lambda x:C[x])\r\nwhile t and C[t[0]]<=k:k-=C[t[0]];s=s.replace(t[0],'');t=t[1:]\r\nprint(len(set(s)))\r\nprint(s)", "s=input(\"\")\nd=dict()\nk=int(input())\nb=s \nsetS=set()\nfor i in s:\n if i not in setS:\n d.update({i:s.count(i)})\n setS.update(i)\ncnt=0\ndel_cnt=0\nl=list(d.items())\nl.sort(key=lambda a: a[1])\nfor i,j in l:\n if del_cnt+j<=k:\n b=b.replace(i,\"\")\n del_cnt+=j \ncnt=len(set(b))\nprint(cnt)\nprint(b)\n", "s=input()\nk=int(input())\na=[]\nfor x in set(s):\n a.append([s.count(x),x])\na.sort()\nfor z in a:\n if z[0]>k:\n break\n k-=z[0]\n s=s.replace(z[1],'')\nprint(len(set(s)))\nprint(s)\n", "# C. Homework\r\nfrom collections import Counter\r\nS, K = input(), int(input())\r\ncount = Counter(S)\r\nasd = sorted(count, key=lambda x: count[x])\r\nans = len(count)\r\nfor a in asd:\r\n cnt = count[a]\r\n if K >= cnt:\r\n K -= cnt\r\n ans -= 1\r\n count[a] = 0\r\n else:\r\n count[a] -= K\r\n K = 0\r\n if K == 0: break\r\n\r\nprint(ans)\r\nfor x in S:\r\n if count[x] == 0: continue\r\n count[x] -= 1\r\n print(x, end=\"\")\r\nprint()\r\n", "import sys\r\ninput = sys.stdin.readline\r\nfrom collections import Counter\r\n\r\ns = input()[:-1]\r\nn = len(s)\r\nk = int(input())\r\nif k >= n:\r\n print(0)\r\n print('')\r\nelse:\r\n c = Counter()\r\n for i in s:\r\n c[i] += 1\r\n x = c.most_common()\r\n i = len(x) - 1\r\n while k > 0:\r\n k -= x[i][1]\r\n if k < 0:\r\n break\r\n s = s.replace(x[i][0],'')\r\n i -= 1\r\n print(i+1)\r\n print(s)", "from collections import defaultdict\n\ndef main():\n s = input()\n k = int(input())\n n = len(s)\n # nums = map(int, input().split())\n\n cspace = defaultdict(int)\n for c in s:\n cspace[c] += 1\n cnums = list(cspace.items())\n cnums.sort(key=lambda x: x[1])\n dup_num = 0\n dup_cs = set()\n for c, cnum in cnums:\n if dup_num + cnum > k:\n break\n dup_num += cnum\n dup_cs.add(c)\n\n for c in dup_cs:\n s = s.replace(c, '')\n\n print(len(set(s)))\n print(s)\n\nmain()\n", "\r\nfrom collections import defaultdict\r\n\r\ns = input()\r\nk = int(input())\r\ncub = defaultdict(int)\r\nfor c in s:\r\n\tcub[c] += 1\r\n\r\npares = list(cub.items())\r\npares = sorted(pares, key = lambda x: x[1])\r\npares = [list(x) for x in pares]\r\n\r\nfor i in range(len(pares)):\r\n\tpar = pares[i]\r\n\tif k>= par[1]:\r\n\t\tk -= par[1]\r\n\t\tpar[1] = 0\r\n\r\ncub = {}\r\ngood = 0\r\nfor a,b in pares:\r\n\tcub[a] = b\r\n\tif b:\r\n\t\tgood += 1\r\n\r\nns = ''\r\nfor c in s:\r\n\tif cub[c]>0:\r\n\t\tns += c\r\n\t\tcub[c] -= 1\r\n\r\nprint(good)\r\nprint(ns)\r\n\r\n# C:\\Users\\Usuario\\HOME2\\Programacion\\ACM", "a=input()\r\nL = list(a)\r\nB=[]\r\nk = int(input())\r\nD={}\r\nfor i in L:\r\n if i not in D: D[i]=L.count(i) \r\n else: pass\r\nfor i,v in D.items():\r\n B+=[[v,i]]\r\nB.sort()\r\no=0\r\nfor j in B:\r\n if j[0]<=k:\r\n o+=1\r\n k-=j[0]\r\n a=a.replace(j[1],'')\r\n else:\r\n break\r\nprint(len(B)-o)\r\nprint(a)", "from collections import defaultdict\n\ndef main():\n s = input()\n k = int(input())\n n = len(s)\n # nums = map(int, input().split())\n\n cspace = defaultdict(int)\n for c in s:\n cspace[c] += 1\n cnums = list(cspace.items())\n cnums.sort(key=lambda x: x[1])\n dup_num = 0\n dup_cs = set()\n for c, cnum in cnums:\n if dup_num + cnum > k:\n break\n dup_num += cnum\n dup_cs.add(c)\n\n if dup_num == 0:\n news = s\n else:\n news = ''\n rear = front = 0\n while front < n:\n if s[front] in dup_cs:\n # concat\n news += s[rear:front]\n rear = front + 1\n front += 1\n if front != rear:\n news += s[rear:front]\n\n print(len(set(news)))\n print(news)\n\nmain()\n", "from collections import Counter\r\nimport operator\r\nimport random\r\n\r\na=list(input())\r\nk=int(input())\r\n\r\nomap=(Counter(a))\r\nx=sorted(omap.items(), key = operator.itemgetter(1))\r\ni=0\r\nwhile(k>0 and i<len(x)):\r\n\tif(x[i][1]<=k):\r\n\t\tk=k-x[i][1]\r\n\t\tdel omap[x[i][0]]\r\n\telse:\r\n\t\tomap[x[i][0]]=omap[x[i][0]]-k\r\n\t\tk=0\r\n\ti+=1\r\nprint(len(omap))\r\nans=\"\"\r\nfor i in a:\r\n if i in omap:\r\n ans+=i\r\n omap[i]-=1\r\n if omap[i]==0:\r\n del omap[i]\r\n \r\n#print(len(omap))\r\nprint(ans)", "s = input()\r\nk = int(input())\r\nn = len(s)\r\n\r\nc = {}\r\n\r\nfor x in set(s) : c[x] = s.count(x)\r\n\r\ndp = sorted(set(s), key = lambda x : c[x])\r\n\r\nwhile dp and c[dp[0]] <= k:\r\n k -= c[dp[0]]\r\n s = s.replace(dp[0],\"\")\r\n dp = dp[1:]\r\n \r\nprint(len(set(s)))\r\nprint(s)" ]
{"inputs": ["aaaaa\n4", "abacaba\n4", "abcdefgh\n10", "aaaaaaaaaaaaaaaaaaaa\n19", "abcdefghijjihgedcba\n0", "aababcabcdabcde\n9", "xyzuvwxyz\n4", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n99", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n0", "abcdefghijklmnopqrstuvwxyz\n17", "abcdefghijklmnopqrstuvwxyz\n0", "abcdefghijklmnopqrsttsrqponmlkjihgfedcba\n0", "aaaaaaaaaaaaaaaaaaaaaeeeeeeeeeeeeeeeeeeee\n20", "xyxjvqrbehasypiekxwjhurlrnegtkiplbogkgxwubzhlyvjwj\n24", "clpdaxnimfkubdxtpjwtjkqh\n21", "jeliuewohkqtghdneuuhcputwiddnmkbhhnlxxbfjunhcd\n50", "zgwmpjfeiwtfagp\n62", "halasouqgfxfcrwhqgllaqiphaxekljz\n87", "zimxucbrzojfqvizcopkplrpnvihveqpgvzszkubftoozrydxijokjxfhdfjracjonqupmnhadtsotxrxmwgno\n51", "geovcaxzjyhxbpnbkbsxfpkyofopxquzzxeigdflfumisevzsjdywehxconimkkbvjyxbqlnmaphvnngcjqoefqkfzmiruubbcmv\n24", "jsreqtehsewsiwzqbpniwuhbgcrrkxlgbhuobphjigfuinffvvatrcxnzbcxjazrrxyiwxncuiifzndpvqahwpdfo\n67", "uwvkcydkhbmbqyfjuryqnxcxhoanwnjubuvpgfipdeserodhh\n65", "xclfxmeqhfjwurwmazpysafoxepb\n26", "hlhugwawagrnpojcmzfiqtffrzuqfovcmxnfqukgzxilglfbtsqgtsweblymqrdskcxjtuytodzujgtivkmiktvskvoqpegoiw\n27", "cky\n79", "oodcvb\n16", "lfbfwdoeggorzdsxqnpophbcjcatphjsewamrgzjszf\n20", "ksnizygvqy\n42", "myenljgyxkwcfyzjcpffsucstschcevbzh\n44", "yumufcicodkpuhvifnvi\n36", "fntrmjfquczybyjllywsqwllsxdmqynmyfcqhakftitvvfbxtqktbfsvvvanjbkqubyxu\n63", "smiclwubkoobnapkkletsnbbsvihqbvikochzteaewjonkzvsqrbjkywsfcvczwretmhscowapcraof\n45", "lwkjydpagifuvbhifryskegmzuexfksazfurlsnzfrgvuxcazitfchimmvomdnbdirzccstmuvlpghwskinayvucodiwn\n16", "a\n0", "bbb\n100000", "aa\n2", "a\n1", "aaaa\n4"], "outputs": ["1\naaaaa", "1\naaaa", "0", "1\naaaaaaaaaaaaaaaaaaaa", "10\nabcdefghijjihgedcba", "2\naabababab", "3\nxyzxyz", "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "1\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "9\nrstuvwxyz", "26\nabcdefghijklmnopqrstuvwxyz", "20\nabcdefghijklmnopqrsttsrqponmlkjihgfedcba", "1\naaaaaaaaaaaaaaaaaaaaa", "8\nxyxjrhykxwjhrlrklkxwhlyjwj", "2\nxxtt", "0", "0", "0", "7\nzxrzojvzopprpvvpvzzoozrxjojxjrjopoxrxo", "16\neovxzjyxbpnbkbxfpkyofopxquzzxeiffumievzjyexonimkkbvjyxbqnmpvnnjqoefqkfzmiuubbmv", "4\nrwiwiwrrxiirxxrrxiwxiiw", "0", "1\nxxx", "15\nlugwwgomzfiqtffzuqfovmxfqukgzxilglftsqgtswlmqskxtutozugtivkmiktvskvoqgoiw", "0", "0", "8\nffwoggozspopjpjswgzjszf", "0", "0", "0", "1\nyyyyyy", "6\nscwbkoobkksbbsbkocwoksbkwsccwscowco", "17\nlwkydagifuvifryskgmzufksazfurlsnzfrgvucazifcimmvmdndirzccsmuvlgwskinayvucdiwn", "1\na", "0", "0", "0", "0"]}
UNKNOWN
PYTHON3
CODEFORCES
43
e28950364eeabec68304f41b59baaf3a
Yaroslav and Two Strings
Yaroslav thinks that two strings *s* and *w*, consisting of digits and having length *n* are non-comparable if there are two numbers, *i* and *j* (1<=≤<=*i*,<=*j*<=≤<=*n*), such that *s**i*<=&gt;<=*w**i* and *s**j*<=&lt;<=*w**j*. Here sign *s**i* represents the *i*-th digit of string *s*, similarly, *w**j* represents the *j*-th digit of string *w*. A string's template is a string that consists of digits and question marks ("?"). Yaroslav has two string templates, each of them has length *n*. Yaroslav wants to count the number of ways to replace all question marks by some integers in both templates, so as to make the resulting strings incomparable. Note that the obtained strings can contain leading zeroes and that distinct question marks can be replaced by distinct or the same integers. Help Yaroslav, calculate the remainder after dividing the described number of ways by 1000000007 (109<=+<=7). The first line contains integer *n* (1<=≤<=*n*<=≤<=105) — the length of both templates. The second line contains the first template — a string that consists of digits and characters "?". The string's length equals *n*. The third line contains the second template in the same format. In a single line print the remainder after dividing the answer to the problem by number 1000000007 (109<=+<=7). Sample Input 2 90 09 2 11 55 5 ????? ????? Sample Output 1 0 993531194
[ "p = int(1e9+7)\r\n\r\ndef solv(A,B):\r\n global p\r\n n = len(A)\r\n A = [-1 if c=='?' else int(c) for c in A]\r\n B = [-1 if c=='?' else int(c) for c in B]\r\n s = [1,0,0,0]\r\n for i in range(n):\r\n if A[i]<0 and B[i]<0:\r\n si,ai,bi,ti=10,45,45,100\r\n elif A[i]<0:\r\n si,ai,bi,ti=1,9-B[i],B[i],10\r\n elif B[i]<0:\r\n si,ai,bi,ti=1,A[i],9-A[i],10\r\n else:\r\n si,ai,bi,ti=(A[i]==B[i],A[i]>B[i],B[i]>A[i],1)\r\n s[3] = (s[3]*ti%p+s[1]*bi%p+s[2]*ai%p)%p\r\n s[2] = (s[2]*(bi+si)%p+s[0]*bi%p)%p\r\n s[1] = (s[1]*(ai+si)%p+s[0]*ai%p)%p\r\n s[0] = s[0]*si%p\r\n return s[3]\r\n\r\n_ = input()\r\nA = input()\r\nB = input()\r\nprint(solv(A,B))\r\n\r\n", "n, s = int(input()), 0\r\ns1, s2 = str(input()), str(input())\r\nb1, b2 = False, False\r\nfor i in range(n):\r\n if s1[i] != '?' and s2[i] != '?':\r\n if ord(s1[i]) < ord(s2[i]):\r\n b1 = True\r\n if ord(s1[i]) > ord(s2[i]):\r\n b2 = True\r\n s += (s1[i] == '?') + (s2[i] == '?')\r\nans1, ans2, ans3 = 1, 1, 1\r\nfor i in range(n):\r\n if s1[i] == '?' and s2[i] == '?':\r\n ans1 = (ans1 * 55) % 1000000007\r\n ans2 = (ans2 * 55) % 1000000007\r\n ans3 = (ans3 * 10) % 1000000007\r\n elif s1[i] == '?':\r\n ans1 = (ans1 * (ord(s2[i]) - ord('0') + 1)) % 1000000007\r\n ans2 = (ans2 * (10 - ord(s2[i]) + ord('0'))) % 1000000007\r\n elif s2[i] == '?':\r\n ans1 = (ans1 * (10 - ord(s1[i]) + ord('0'))) % 1000000007\r\n ans2 = (ans2 * (ord(s1[i]) - ord('0') + 1)) % 1000000007\r\nprint((10 ** s - (not b2) * ans1 - (not b1) * ans2 + (not b1 and not b2) * ans3) % 1000000007)", "from functools import reduce\r\nn, s1, s2, f1, f2 = int(input()), str(input()), str(input()), lambda x: reduce((lambda a, b: (a * b) % 1000000007), x, 1), lambda x: reduce((lambda a, b: a or b), x, False)\r\nprint((10 ** sum([(s1[i] == '?') + (s2[i] == '?') for i in range(n)]) - (not f2([s1[i] != '?' and s2[i] != '?' and ord(s1[i]) > ord(s2[i]) for i in range(n)])) * f1([55 if s1[i] == '?' and s2[i] == '?' else (ord(s2[i]) - ord('0') + 1) if s1[i] == '?' else (10 - ord(s1[i]) + ord('0')) if s2[i] == '?' else 1 for i in range(n)]) - (not f2([s1[i] != '?' and s2[i] != '?' and ord(s1[i]) < ord(s2[i]) for i in range(n)])) * f1([55 if s1[i] == '?' and s2[i] == '?' else (10 - ord(s2[i]) + ord('0')) if s1[i] == '?' else (ord(s1[i]) - ord('0')) + 1 if s2[i] == '?' else 1 for i in range(n)]) + (not f2([s1[i] != '?' and s2[i] != '?' and ord(s1[i]) < ord(s2[i]) for i in range(n)]) and not f2([s1[i] != '?' and s2[i] != '?' and ord(s1[i]) > ord(s2[i]) for i in range(n)])) * f1([10 if s1[i] == '?' and s2[i] == '?' else 1 for i in range(n)])) % 1000000007)" ]
{"inputs": ["2\n90\n09", "2\n11\n55", "5\n?????\n?????", "10\n104?3?1??3\n?1755?1??7", "10\n6276405116\n6787?352?9", "10\n0844033584\n0031021311", "10\n???0?19?01\n957461????", "10\n8703870339\n994987934?", "10\n?8?528?91?\n45??06???1", "10\n8030456630\n83406?6890", "1\n?\n?", "2\n12\n?9", "3\n??1\n?12", "3\n?12\n??1", "5\n??15?\n?32??", "5\n??25?\n?32??", "5\n??55?\n?32??", "5\n?32??\n??55?"], "outputs": ["1", "0", "993531194", "91015750", "46", "0", "983368000", "9", "980398000", "5", "0", "1", "890", "890", "939500", "812550", "872950", "872950"]}
UNKNOWN
PYTHON3
CODEFORCES
3
e29a81b722db7b430a0a5ff0aaf2aa1f
A Map of the Cat
If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat. However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat. You have met a cat. Can you figure out whether it's normal or grumpy? none none Sample Input Sample Output
[ "# coding: utf-8\r\n\r\nresponse = input('9\\n')\r\n\r\nprint('grumpy') if response in ['terrible', 'worse', 'are you serious?', \"don't even\", 'no way', 'go die in a hole'] else print('normal')", "print(9)\r\ns=input()\r\nif 'go die in a hole'==s or 'are you serious?'==s or 'terrible'==s or 'worse'==s or 'no way'==s or \"don't even\"==s:\r\n print('grumpy')\r\nelse:\r\n print('normal')\r\n", "for i in range(0, 10):\r\n\tprint(i, flush=True)\r\n\ts = input()\r\n\tif s != 'no':\r\n\t\tprint(['normal','grumpy'][s[-2:] in 'lenuseay'], flush=True)\r\n\t\tbreak", "for i in range(1, 11):\n s = input( str(i) + \"\\n\")\n if(s==\"great\" or s==\"cool\" or s==\"not bad\" or s==\"don't touch me\" or s==\"don't think so\"):\n print(\"normal\")\n quit()\n if(s==\"don't even\" or s==\"are you serious\" or s==\"no way\" or s==\"worse\" or s==\"terrible\" or s==\"go die in a hole\"):\n print(\"grumpy\")\n quit()\nquit()\n", "import sys\r\ndef check(s):\r\n if s == 'no':\r\n return 'dn'\r\n elif s in ['great','don\\'t think so','don\\'t touch me','not bad','cool']:\r\n return 'n'\r\n else:\r\n return 'g'\r\nprint(0)\r\nsys.stdout.flush()\r\nt = check(input())\r\nfor i in range(1,10):\r\n if t == 'dn':\r\n print(i)\r\n sys.stdout.flush()\r\n t = check(input())\r\n elif t == 'n':\r\n print('normal')\r\n sys.stdout.flush()\r\n sys.exit(0)\r\n else:\r\n print('grumpy')\r\n sys.stdout.flush()\r\n sys.exit(0)", "grumpy=['are you serious','go die in a hole','worse',\r\n 'terrible','don\\'t even','no way']\r\nfor i in range(10):\r\n print(i)\r\n s=input().strip()\r\n if s=='no': continue\r\n if s in grumpy: print('grumpy')\r\n else: print('normal')\r\n break", "for i in range(10):\r\n print(i, flush = True)\r\n s = input()\r\n \r\n if s != \"no\":\r\n if s in [\"great\",\"don't think so\", \"don't touch me\",\"not bad\", \"cool\"]:\r\n print('normal', flush = True)\r\n else:\r\n print('grumpy', flush = True)\r\n break", "norm = [\"great!\",\"don't touch me\",\"cool\",\"don't think so\",\"not bad\"]\r\ncrum = [\"are you serious?\",\"worse\",\"terrible\",\"no way\",\"go die in a hole\",\"don,t even\"]\r\nfor i in range(10):\r\n print(i)\r\n a = input()\r\n if a in crum:\r\n print(\"grumpy\")\r\n break\r\n elif a in norm:\r\n print(\"normal\")\r\n break\r\n", "print('grumpy' if input('9\\n')[-2:] in ['s?', 'le', 'se', 'ay', 'en'] else 'normal')", "# from io import BytesIO\r\n# import os\r\n# input = BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nfor i in range(10):\r\n print(i)\r\n t = input()\r\n if t in ['no way', \"go die in a hole\", \"are you serious\", \"worse\", \"terrible\", \"don't even\"]:\r\n print('grumpy')\r\n exit(0)\r\n elif t != 'no':\r\n print(\"normal\")\r\n exit(0)\r\n", "i = 1\r\nwhile True:\r\n print(i)\r\n s = input()\r\n if s == 'are you serious?' or s == 'no way' or s == \"don't even\" or s == 'terrible' or s == 'do die in a hole' or s == 'worse':\r\n print('grumpy')\r\n break\r\n elif s == \"don't think so\" or s == \"don't touch me\" or s == 'cool' or s == 'great!' or s == 'not bad':\r\n print('normal')\r\n break\r\n else:\r\n i += 1", "print(1)\r\na=input()\r\ni=2\r\nwhile a=='no':\r\n print(i)\r\n a=input()\r\n i+=1\r\nz=['not bad', 'cool', 'great',\"don't think so\",\"don't touch me\"]\r\nif a in z:\r\n print(\"normal\")\r\nelse:\r\n print('grumpy')\r\n\r\n\r\n\r\n\r\n\r\n", "print(9)\nprint('ngorrummaply'[input()[-2:]in'lenuseay'::2])", "for i in range(10):\r\n print(i)\r\n s = input()\r\n if s in [\"great!\", \"don't think so\", \"not bad\", \"cool\" , \"don't touch me\"]:\r\n print(\"normal\")\r\n exit(0)\r\n if s in [\"no way\", \"don't even\", \"are you serious?\", \"worse\", \"terrible\"]:\r\n print(\"grumpy\")\r\n exit(0)", "\nnormal = [\"great!\", \"don't think so\", \"not bad\", \"don't touch me\", \"cool\"]\ngrumpy = [\"don't even\", \"no way\", \"are you serious?\", \"worse\", \"terrible\", \"go die in a hole\"]\nfor i in range(0, 10):\n print(i)\n s = input()\n if (s in normal):\n print(\"normal\")\n break\n else: \n if (s in grumpy):\n print(\"grumpy\")\n break", "nc=[\"great\",\"think\",\"touch\",\"bad\",\"cool\"]\ngc=[\"even\",\"serious\",\"die\",\"worse\",\"terrible\",\"way\"]\nn=0\nwhile True:\n print(n)\n r=input()\n for x in nc:\n if x in r:\n exit(print(\"normal\"))\n\n for x in gc:\n if x in r:\n exit(print(\"grumpy\"))\n\n n+=1\n", "normal = [\"don't think so\",\"don't touch me\",\"not bad\",\"cool\",\"great\"]\ngrumpy = [\"are you serious?\",\"go die in a hole\",\"worse\",'terrible',\"don't even\"]\nfor i in range(0,10):\n print(i)\n S = input()\n if S in normal:\n print(\"normal\")\n break\n elif S in grumpy:\n print(\"grumpy\")\n break\n", "B = ['great', 'great!', \"don't think so\", 'not bad', 'cool']\r\nC = ['are you serious', 'are you serious?', 'go die in a hole', 'worse', 'terrible', 'no way', \"don't even\"]\r\n\r\nfor i in range(9,-1,-1):\r\n print(i)\r\n S = input()\r\n if S in C:\r\n print(\"grumpy\")\r\n break\r\n elif S in B:\r\n print(\"normal\")\r\n break", "print(9)\r\nx=input()\r\nif 'go die in a hole'==x or 'are you serious?'==x or 'terrible'==x or 'worse'==x or 'no way'==x or \"don't even\"==x:\r\n print('grumpy')\r\nelse:\r\n print('normal')", "from sys import stdin, stdout\ndef read():\n\treturn stdin.readline().rstrip()\n\ndef read_int():\n\treturn int(read())\n\ndef read_ints():\n\treturn list(map(int, read().split()))\n\ndef solve():\n\tnormal_dict = [\"great\", \"not bad\", \"touch\", \"think\", \"cool\"]\n\tgrumpy_dict = [\"even\", \"serious\", \"worse\", \"terrible\", \"die\", \"way\"]\n\tfor i in range(6):\n\t\tprint(i)\n\t\tstdout.flush()\n\t\tr = read()\n\t\tfor x in normal_dict:\n\t\t\tif x in r:\n\t\t\t\tprint(\"normal\")\n\t\t\t\tstdout.flush()\n\t\t\t\treturn\n\t\tfor x in grumpy_dict:\n\t\t\tif x in r:\n\t\t\t\tprint(\"grumpy\")\n\t\t\t\tstdout.flush()\n\t\t\t\treturn\n\nsolve()\n", "l=['great',\"don't think so\",\"not bad\",\"cool\",\"don't touch me\"]\r\nfor i in range(9):\r\n\tprint(i)\r\n\tn=input()\r\n\tif (n==\"no\"):\r\n\t\tcontinue\r\n\tif n in l:\r\n\t\tprint(\"normal\")\r\n\t\texit()\r\n\telse:\r\n\t\tprint(\"grumpy\")\r\n\t\texit()", "for i in range(10):\r\n print(i)\r\n reaction = input()\r\n if reaction in ['great', 'don\\'t think so', 'not bad', 'cool', 'don\\'t touch me']:\r\n print('normal')\r\n break\r\n elif reaction in ['don\\'t even', 'are you serious?', 'no way', 'go die in a whole', 'worse', 'terrible']:\r\n print('grumpy')\r\n break", "# LUOGU_RID: 101738871\nprint(input('9\\n')[-2:] in ['s?', 'le', 'se',\r\n 'ay', 'en'] and 'grumpy' or 'normal')\r\n", "print(9, flush=True)\r\nprint(['normal','grumpy'][input()[-2:] in 'lenuseay'], flush=True)" ]
{"inputs": ["5 0 1 2 5 3 5 4 5 5", "5 5 5 6 6 7 8 9 10 11", "10 6 5 7 5 6 11 5 8 9", "7 10 8 9 6 5 5 11 5 6", "5 5 4 5 2 5 5 0 1 3", "0 4 3 5 5 5 2 1 5 5", "3 5 5 0 5 5 2 5 4 1", "5 4 5 1 5 5 0 5 2 3", "5 5 1 2 5 5 4 3 0 5", "7 10 5 5 11 6 5 9 6 8", "6 5 10 5 5 7 8 11 9 6", "5 5 5 5 5 0 4 2 3 1", "11 5 6 5 9 5 10 8 7 6", "5 9 8 10 7 11 5 6 5 6", "5 8 10 11 5 6 5 6 7 9", "5 5 6 11 6 10 9 5 8 7", "1 5 5 2 5 0 3 5 5 4", "5 5 2 5 4 5 3 1 0 5"], "outputs": ["Correct answer 'normal'", "Correct answer 'grumpy'", "Correct answer 'grumpy'", "Correct answer 'grumpy'", "Correct answer 'normal'", "Correct answer 'normal'", "Correct answer 'normal'", "Correct answer 'normal'", "Correct answer 'normal'", "Correct answer 'grumpy'", "Correct answer 'grumpy'", "Correct answer 'normal'", "Correct answer 'grumpy'", "Correct answer 'grumpy'", "Correct answer 'grumpy'", "Correct answer 'grumpy'", "Correct answer 'normal'", "Correct answer 'normal'"]}
UNKNOWN
PYTHON3
CODEFORCES
24
e2bca028d9266e692bf63ce037440cc9
Bath Queue
There are *n* students living in the campus. Every morning all students wake up at the same time and go to wash. There are *m* rooms with wash basins. The *i*-th of these rooms contains *a**i* wash basins. Every student independently select one the rooms with equal probability and goes to it. After all students selected their rooms, students in each room divide into queues by the number of wash basins so that the size of the largest queue is the least possible. Calculate the expected value of the size of the largest queue among all rooms. The first line contains two positive integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=50) — the amount of students and the amount of rooms. The second line contains *m* integers *a*1,<=*a*2,<=... ,<=*a**m* (1<=≤<=*a**i*<=≤<=50). *a**i* means the amount of wash basins in the *i*-th room. Output single number: the expected value of the size of the largest queue. Your answer must have an absolute or relative error less than 10<=-<=9. Sample Input 1 1 2 2 2 1 1 2 3 1 1 1 7 5 1 1 2 3 1 Sample Output 1.00000000000000000000 1.50000000000000000000 1.33333333333333350000 2.50216960000000070000
[ "import functools,math,itertools,time\nu=functools.lru_cache(maxsize=None)\nn,m=map(int,input().split())\ns=[*map(int,input().split())]\nt=u(lambda x:1 if x<2 else x*t(x-1))\nc=u(lambda r,n:t(n)/t(r)/t(n-r))\np=u(lambda n,k:n**k)\nw=u(lambda n,k:math.ceil(n/k))\nr=u(lambda k,n:max(k,n))\nh=u(lambda i,j,l:c(l,i)*p(j-1,i-l)/p(j,i))\n\nfor i,j in itertools.product(range(1,n+1),range(1,m+1)):\n for l in range(i+1):\n h(i,j,l)\n@u\ndef d(i,j,k):\n if j:\n q=0\n for l in range(i + 1):\n q+=h(i,j,l)*d(i-l,j-1,r(k,w(l,s[j-1])))\n return q\n return k\nprint(d(n,m,0))\n\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\n \r\ndef I():\r\n return input()\r\n \r\ndef II():\r\n return int(input())\r\n \r\ndef MII():\r\n return map(int, input().split())\r\n \r\ndef LI():\r\n return list(input().split())\r\n \r\ndef LII():\r\n return list(map(int, input().split()))\r\n \r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n \r\ndef LGMI():\r\n return list(map(lambda x: int(x) - 1, input().split()))\r\n \r\ninf = float('inf')\r\n \r\n# from types import GeneratorType\r\n \r\n# def bootstrap(f, stack=[]):\r\n# def wrappedfunc(*args, **kwargs):\r\n# if stack:\r\n# return f(*args, **kwargs)\r\n# else:\r\n# to = f(*args, **kwargs)\r\n# while True:\r\n# if type(to) is GeneratorType:\r\n# stack.append(to)\r\n# to = next(to)\r\n# else:\r\n# stack.pop()\r\n# if not stack:\r\n# break\r\n# to = stack[-1].send(to)\r\n# return to\r\n# return wrappedfunc\r\n \r\n# RANDOM = random.getrandbits(32)\r\n \r\n# class Wrapper(int):\r\n# def __init__(self, x):\r\n# int.__init__(x)\r\n \r\n# def __hash__(self):\r\n# return super(Wrapper, self).__hash__() ^ RANDOM\r\n\r\n# from types import GeneratorType\r\n\r\n# def bootstrap(f, stack=[]):\r\n# def wrappedfunc(*args, **kwargs):\r\n# if stack:\r\n# return f(*args, **kwargs)\r\n# else:\r\n# to = f(*args, **kwargs)\r\n# while True:\r\n# if type(to) is GeneratorType:\r\n# stack.append(to)\r\n# to = next(to)\r\n# else:\r\n# stack.pop()\r\n# if not stack:\r\n# break\r\n# to = stack[-1].send(to)\r\n# return to\r\n# return wrappedfunc\r\n\r\n# RANDOM = random.getrandbits(32)\r\n\r\n# class Wrapper(int):\r\n# def __init__(self, x):\r\n# int.__init__(x)\r\n\r\n# def __hash__(self):\r\n# return super(Wrapper, self).__hash__() ^ RANDOM\r\n\r\nm, n = MII()\r\nnums = LII()\r\n\r\ncomb = [[1] * (m + 1) for _ in range(m + 1)]\r\nfor i in range(1, m + 1):\r\n for j in range(1, m + 1):\r\n comb[i][j] = comb[i-1][j] + comb[i][j-1]\r\n\r\ndp = [[0] * (m + 1) for _ in range(m + 1)]\r\ndp[0][0] = 1\r\n\r\nfor i in range(n):\r\n new_dp = [[0] * (m + 1) for _ in range(m + 1)]\r\n for curr in range(m + 1):\r\n for j in range(m + 1):\r\n if curr + j > m: break\r\n for k in range(m + 1):\r\n prob = comb[m - j - curr][curr] * (1 / (n - i)) ** curr * (1 - 1 / (n - i)) ** (m - j - curr)\r\n new_dp[j + curr][max(k, (curr + nums[i] - 1) // nums[i])] += prob * dp[j][k]\r\n dp = new_dp\r\n\r\nprint(sum(dp[m][i] * i for i in range(m + 1)))", "import sys\n\nMAX_N = 55\n\nline = list(map(int, sys.stdin.readline().split(\" \")))\nstudc = line[0]\nroomc = line[1]\n\narr = list(map(int, sys.stdin.readline().split(\" \")))\n\nncr = [[0 for i in range(MAX_N)] for j in range(MAX_N)]\nncr[0][0] = 1\nfor i in range(1, MAX_N):\n ncr[i][0] = 1;\n for j in range(1, MAX_N):\n ncr[i][j] = ncr[i - 1][j - 1] + ncr[i - 1][j]\n\nupto = [0 for i in range(MAX_N)] # upto[i] of ways to pick such that no queue exceeds i people\nfor i in range(1, MAX_N):\n dp = [[0 for j in range(MAX_N)] for k in range(MAX_N)]\n dp[0][0] = 1\n for j in range(roomc):\n for k in range(0, min(studc, i * arr[j]) + 1):\n for l in range(0, studc - k + 1):\n dp[j + 1][k + l] += dp[j][l] * ncr[studc - l][k]\n \n upto[i] = dp[roomc][studc]\n \nans = 0;\nfor i in range(1, MAX_N):\n ans += (upto[i] - upto[i - 1]) * i\n\nprint('%.12f' % (ans / (roomc ** studc)))\n" ]
{"inputs": ["1 1\n2", "2 2\n1 1", "2 3\n1 1 1", "7 5\n1 1 2 3 1", "10 4\n8 4 7 6", "5 5\n5 5 5 5 5", "7 4\n1 2 3 4", "50 50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "30 30\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "20 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "1 50\n47 24 49 50 4 21 42 22 34 48 45 15 31 18 12 10 4 45 45 42 49 13 12 9 7 5 30 18 22 50 15 16 25 18 5 41 3 26 19 18 22 5 8 10 16 50 43 44 6 43", "1 50\n46 45 44 49 48 48 47 42 48 47 47 48 39 47 48 49 50 48 50 46 48 46 50 47 45 50 41 49 39 44 46 47 43 47 42 47 49 40 49 50 50 50 48 50 48 47 49 46 46 42", "1 50\n9 1 1 4 1 9 7 4 3 10 1 7 4 7 2 5 13 2 3 3 2 1 2 1 1 7 7 5 2 6 1 8 2 6 2 15 2 3 1 2 4 8 6 2 6 11 1 2 1 1", "50 1\n27", "50 1\n48", "50 1\n4", "20 35\n48 40 49 37 36 44 48 42 37 42 18 44 47 47 41 45 49 47 47 50 16 24 42 24 36 37 45 48 36 43 44 25 34 30 42", "50 50\n3 12 1 3 6 2 5 14 2 4 4 1 6 9 4 2 3 19 7 6 4 1 7 4 1 3 6 3 2 4 4 1 6 1 3 1 1 4 1 6 1 2 2 4 12 12 1 5 5 2", "50 50\n21 35 15 42 44 1 50 4 26 21 43 41 50 33 47 3 21 14 33 34 43 44 16 41 35 27 3 4 7 14 15 35 27 36 46 13 3 48 32 20 15 33 38 36 39 22 45 7 16 50", "50 50\n50 48 38 45 50 48 38 48 49 49 50 50 49 50 38 48 45 40 43 49 48 43 50 50 50 42 47 50 49 34 48 47 48 50 50 50 49 47 48 49 48 48 50 39 45 47 48 47 45 50", "50 50\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 49 49 49 50 49 50 50 50 50 48 50 49 50 50 50 50 48 50 50 50 49 50 50 50 50 50 50 50 50 50 50 49 50 50", "50 50\n2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1", "44 5\n40 48 45 43 17", "3 49\n4 2 9 21 22 25 6 9 15 10 37 3 8 6 14 1 3 3 18 1 9 11 8 5 20 21 10 25 35 16 14 18 2 5 12 6 9 8 3 6 19 18 1 13 12 33 4 2 16", "19 17\n50 46 38 48 41 41 40 45 47 50 49 33 46 44 46 48 36", "12 34\n47 50 49 45 48 50 49 45 50 48 43 49 50 47 49 49 50 50 45 43 45 44 50 47 50 49 47 49 49 42 50 50 50 49", "35 40\n12 1 4 8 1 9 1 11 1 1 8 8 16 1 6 5 3 1 6 4 6 2 4 6 2 1 1 16 2 2 3 1 1 2 2 3 8 12 1 4", "10 6\n1 1 1 1 1 1", "50 50\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50", "50 50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "50 50\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50", "1 1\n50"], "outputs": ["1.00000000000000000000", "1.50000000000000000000", "1.33333333333333350000", "2.50216960000000070000", "1.08210754394531210000", "1.00000000000000020000", "2.11712646484374910000", "3.80545467981579130000", "3.49298980907245000000", "3.23123684379753670000", "1.00000000000000000000", "1.00000000000000000000", "1.00000000000000000000", "2.00000000000000000000", "2.00000000000000000000", "13.00000000000000000000", "0.99999999999999978000", "2.83614403586073620000", "1.40898003277183290000", "0.99999999999999156000", "0.99999999999999156000", "3.71403384155135140000", "1.00121533621041100000", "1.00374843815077060000", "0.99999999999999967000", "1.00000000000000000000", "2.65978492228475400000", "3.44474669607021380000", "0.99999999999999156000", "3.80545467981579130000", "1.44158938050050490000", "1.00000000000000000000"]}
UNKNOWN
PYTHON3
CODEFORCES
3
e2c2354fd6b205a5686ab9e5bc4c2f43
Easy Number Challenge
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). The first line contains three space-separated integers *a*, *b* and *c* (1<=≤<=*a*,<=*b*,<=*c*<=≤<=100). Print a single integer — the required sum modulo 1073741824 (230). Sample Input 2 2 2 5 6 7 Sample Output 20 1520
[ "a, b , c = map(int ,input().split())\r\n\r\nli = a*b*c +1\r\nfactor = [1]*li\r\nfor i in range(2,li):\r\n for j in range(i,li,i):\r\n factor[j]+=1\r\n\r\nsm = 0\r\nfor i in range(1,a+1):\r\n for j in range(1,(b+1)):\r\n for h in range(1,(c+1)//2+1):\r\n sm += factor[i * j * h ]\r\n \r\n if h != c-h+1:\r\n sm += factor[i * j * (c-h+1)]\r\n \r\n\r\nprint(sm % 1073741824)", "a,b,c=map(int,input().split())\r\nl=(a*b*c)+1\r\nd=[1]*l\r\nfor i in range(2,l):\r\n j=i\r\n while j < l :\r\n d[j]+=1\r\n j+=i\r\nsum=0\r\nfor i in range(1,a+1):\r\n for j in range(1,b+1):\r\n for k in range(1,c+1):\r\n sum+=d[i*j*k]\r\nprint(sum)\r\n", "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]\r\ndef divisor(x):\r\n y=0\r\n ans=1\r\n for i in p:\r\n y=1\r\n if x < i:break\r\n while x%i==0 and x>= i:\r\n x/=i\r\n y+=1\r\n ans*=y\r\n return ans\r\na,b,c=map(int,input().split())\r\nq={}\r\nans = 0\r\nfor i in range(1,a+1) :\r\n for j in range(1,b+1) :\r\n for k in range(1,c+1) :\r\n x=i*j*k\r\n if x not in q :\r\n q[x]=divisor(x)\r\n ans+=q[x]\r\nprint(ans % 1073741824)", "def divisor(n):\r\n 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]\r\n k = 1\r\n for i in p:\r\n j = 1\r\n if n < i:\r\n break\r\n while n % i == 0 and n >= i:\r\n n /= i\r\n j += 1\r\n k *= j\r\n return k\r\ndef solve():\r\n a,b,c=map(int,input().split())\r\n ans=0\r\n dic = {}\r\n for i in range(1,a+1):\r\n for j in range(1,b+1):\r\n for k in range(1,c+1):\r\n l = i*j*k\r\n if l not in dic:\r\n dic[l] = divisor(l)\r\n ans +=dic[l]\r\n print(ans%1073741824)\r\n \r\nif __name__ == '__main__':\r\n solve()", "# def number_divisables(n):\r\n# res = 0\r\n# for i in range(1,n+1):\r\n# if (n%i == 0):\r\n# res+=1 \r\n# return res\r\n\r\ndef prime_factorization(n):\r\n factors = {}\r\n i = 2\r\n while i * i <= n:\r\n while n % i == 0:\r\n if i not in factors:\r\n factors[i] = 0\r\n factors[i] += 1\r\n n //= i\r\n i += 1\r\n if n > 1:\r\n factors[n] = 1\r\n return factors\r\n\r\ndef number_divisables(number):\r\n factors = prime_factorization(number)\r\n divisors_count = 1\r\n for count in factors.values():\r\n divisors_count *= (count + 1)\r\n return divisors_count\r\n\r\n\r\ni, j, k = map(int,input().split())\r\n\r\ntrack = [0] * (i*j*k) + [0]\r\n# print(track)\r\nres = 0\r\n\r\nfor i_i in range(1, i+1):\r\n for j_i in range(1, j+1):\r\n for k_i in range(1, k+1):\r\n current = i_i * j_i * k_i\r\n if (track[current] == 0):\r\n current_number_divisable = number_divisables(current)\r\n track[current] = current_number_divisable\r\n \r\n res+=track[current]\r\n \r\n \r\nprint(res)", "a,b,c = map(int,input().split())\r\nfreq = [0]*(a*b*c+1)\r\nmx = a*b*c+1\r\nans = 0\r\nfor s in range(1,a+1):\r\n for d in range(1,b+1):\r\n for f in range(1,c+1):\r\n freq[s*d*f]+=1\r\nfor u in range(2,mx):\r\n for j in range(u,mx,u):\r\n ans+=freq[j]\r\nans+=sum(freq)\r\nprint(ans)", "from math import sqrt\r\na, b, c = map(int, input().split(' '))\r\n\r\ndef get_num_divs(n):\r\n r = 0\r\n for i in range (1, int(sqrt(n)) + 1):\r\n if n % i == 0:\r\n # perfect squares\r\n if i == n // i:\r\n r += 1\r\n else:\r\n r += 2\r\n return r\r\n\r\nm = {}\r\ndef d(t):\r\n if t in m:\r\n return m[t]\r\n m[t] = get_num_divs(t)\r\n return m[t]\r\n\r\ns = 0\r\nfor i in range(1, a + 1):\r\n for j in range(1, b + 1):\r\n for k in range(1, c + 1):\r\n s += d(i*j*k) % 1073741824\r\nprint(s % 1073741824)", "import math\r\na,b,c=map(int,input().split())\r\nans=0\r\nd=[0]*(1000001)\r\nfor i in range(1,1000001):\r\n j=i\r\n while j<=1000000:\r\n d[j]+=1\r\n j+=i\r\n\r\nfor i in range(1,a+1):\r\n for j in range(1,b+1):\r\n for k in range(1,c+1):\r\n ans+=d[(i*j*k)]\r\n \r\nprint(ans%1073741824)\r\n", "a,b,c=map(int,input().split());n=a*b*c+1;d=[1]*n\r\nfor i in range(2,n):\r\n for j in range(i,n,i):d[j]+=1\r\nprint(sum([d[i*j*k]for i in range(1,a+1)for j in range(1,b+1)for k in range(1,c+1)])%(1<<30))" ]
{"inputs": ["2 2 2", "5 6 7", "91 42 25", "38 47 5", "82 29 45", "40 15 33", "35 5 21", "71 2 1", "22 44 41", "73 19 29", "76 12 17", "16 10 49", "59 99 33", "17 34 25", "21 16 9", "31 51 29", "26 41 17", "85 19 5", "36 61 45", "76 58 25", "71 48 13", "29 34 53", "72 16 41", "8 21 21", "11 51 5", "70 38 49", "13 31 33", "53 29 17", "56 18 53", "55 45 45", "58 35 29", "67 2 24", "62 96 8", "21 22 100", "64 12 36", "4 9 20", "7 99 4", "58 25 96", "9 19 32", "45 16 12", "40 6 100", "46 93 44", "49 31 28", "89 28 8", "84 17 96", "91 96 36", "86 90 24", "4 21 45", "100 7 28", "58 41 21", "53 31 5", "41 28 36", "44 18 24", "3 96 16", "98 34 100", "82 31 32", "85 25 20", "35 12 8", "39 94 48", "27 99 28", "22 28 16", "80 15 4", "23 9 44", "33 16 36", "36 6 24", "98 92 12", "90 82 100", "77 79 31", "81 21 19", "31 96 7", "34 89 95", "18 86 27", "13 76 11", "76 3 3", "15 93 87", "63 90 23", "58 83 7", "16 18 99", "60 8 35", "22 87 4", "73 25 44", "36 3 32", "27 93 20", "67 90 100", "18 84 36", "68 14 28", "71 8 12", "7 5 96", "50 95 32", "13 22 24", "4 12 8", "100 9 88", "95 2 28", "54 77 20", "49 19 4", "58 86 99", "9 76 83", "64 2 27", "63 96 11", "3 93 91", "100 100 100", "1 5 1"], "outputs": ["20", "1520", "3076687", "160665", "3504808", "460153", "55282", "811", "1063829", "1047494", "330197", "146199", "7052988", "306673", "45449", "1255099", "402568", "139747", "3253358", "3635209", "1179722", "1461871", "1309118", "54740", "38092", "4467821", "274773", "621991", "1518698", "3751761", "1706344", "45108", "1257040", "1274891", "687986", "7302", "36791", "4812548", "91192", "167557", "558275", "6945002", "1158568", "441176", "4615400", "12931148", "6779764", "58045", "429933", "1405507", "144839", "1135934", "436880", "70613", "13589991", "2502213", "1142825", "50977", "6368273", "2276216", "198639", "76139", "170773", "441858", "88626", "3475151", "35482866", "6870344", "812886", "458123", "11308813", "1116623", "206844", "6118", "4007595", "4384553", "819473", "702678", "363723", "133986", "2478308", "50842", "1393947", "27880104", "1564297", "646819", "119311", "46328", "5324602", "124510", "3347", "2334910", "82723", "2573855", "55037", "21920084", "1554836", "49141", "1898531", "555583", "51103588", "10"]}
UNKNOWN
PYTHON3
CODEFORCES
9
e319d416e5dc2aab18120817702c6393
Feed with Candy
The hero of the Cut the Rope game is a little monster named Om Nom. He loves candies. And what a coincidence! He also is the hero of today's problem. One day, Om Nom visited his friend Evan. Evan has *n* candies of two types (fruit drops and caramel drops), the *i*-th candy hangs at the height of *h**i* centimeters above the floor of the house, its mass is *m**i*. Om Nom wants to eat as many candies as possible. At the beginning Om Nom can make at most *x* centimeter high jumps. When Om Nom eats a candy of mass *y*, he gets stronger and the height of his jump increases by *y* centimeters. What maximum number of candies can Om Nom eat if he never eats two candies of the same type in a row (Om Nom finds it too boring)? The first line contains two integers, *n* and *x* (1<=≤<=*n*,<=*x*<=≤<=2000) — the number of sweets Evan has and the initial height of Om Nom's jump. Each of the following *n* lines contains three integers *t**i*,<=*h**i*,<=*m**i* (0<=≤<=*t**i*<=≤<=1; 1<=≤<=*h**i*,<=*m**i*<=≤<=2000) — the type, height and the mass of the *i*-th candy. If number *t**i* equals 0, then the current candy is a caramel drop, otherwise it is a fruit drop. Print a single integer — the maximum number of candies Om Nom can eat. Sample Input 5 3 0 2 4 1 3 1 0 8 3 0 20 10 1 5 5 Sample Output 4
[ "from copy import deepcopy\r\n\r\ndef getBetter(h, a):\r\n maxi = -1\r\n im = -1\r\n for i in range(len(a)):\r\n if (h >= a[i][0]):\r\n if (maxi < a[i][1]):\r\n im = i\r\n maxi = a[i][1]\r\n return(im, maxi)\r\n\r\nn, h0 = map(int, input().split())\r\n\r\nlolipops0 = [[], []]\r\n\r\nfor i in range(n):\r\n t, h, m = map(int, input().split())\r\n lolipops0[t].append((h, m))\r\n\r\nlolipops0[1].sort()\r\nlolipops0[0].sort()\r\n\r\nlolipops1 = deepcopy(lolipops0)\r\n\r\nlol0 = getBetter(h0, lolipops0[0])\r\nt1 = 0\r\nh1 = h0\r\nlol1 = getBetter(h0, lolipops0[1])\r\nt2 = 1 # ---- WARNING --------\r\nh2 = h0\r\nwhile(lol0[0] >= 0 or lol1[0] >=0):\r\n if (lol0[0] > -1):\r\n if (len(lolipops0[t1 % 2]) != 1 and lol0[0] != -1):\r\n lolipops0[t1 % 2].pop(lol0[0])\r\n else:\r\n lolipops0[t1 % 2] = []\r\n t1 += 1\r\n h1 += lol0[1]\r\n lol0 = getBetter(h1, lolipops0[t1 % 2])\r\n if (lol1[0] > -1):\r\n if (len(lolipops1[t2 % 2]) != 1 and lol1[0] != -1):\r\n lolipops1[t2 % 2].pop(lol1[0])\r\n else:\r\n lolipops1[t2 % 2] = []\r\n t2 += 1\r\n h2 += lol1[1]\r\n lol1 = getBetter(h2, lolipops1[t2 % 2])\r\nprint(max(t1, t2 - 1))", "from sys import stdin\r\n\r\n\r\ndef solve(t):\r\n vis0, vis1 = [False] * len(a0), [False] * len(a1)\r\n ans, cur = 0, jmp\r\n while True:\r\n if t == 0:\r\n for i, (h, m) in enumerate(a0):\r\n if h <= cur and not vis0[i]:\r\n cur += m\r\n vis0[i], ans = True, ans + 1\r\n break\r\n else:\r\n break\r\n else:\r\n for i, (h, m) in enumerate(a1):\r\n if h <= cur and not vis1[i]:\r\n cur += m\r\n vis1[i], ans = True, ans + 1\r\n break\r\n else:\r\n break\r\n t ^= 1\r\n return ans\r\n\r\n\r\ninput = lambda: stdin.buffer.readline().rstrip(b'\\r\\n').decode('ascii')\r\nn, jmp = map(int, input().split())\r\na0, a1 = [], []\r\nfor i in range(n):\r\n t, h, m = map(int, input().split())\r\n if t == 0:\r\n a0.append((h, m))\r\n else:\r\n a1.append((h, m))\r\n\r\na0.sort(key=lambda x: (x[1], x[0]), reverse=True)\r\na1.sort(key=lambda x: (x[1], x[0]), reverse=True)\r\nprint(max(solve(0), solve(1)))\r\n", "\r\nn, x = (int(x) for x in input().split())\r\n\r\ncs = []\r\nfor i in range(n):\r\n cs.append([int(x) for x in input().split()])\r\n if cs[-1][0] > 0:\r\n cs[-1][0] = 1\r\n\r\ndef try_eat(t0):\r\n h0 = x\r\n used = set()\r\n while True:\r\n m0 = 0\r\n i0 = -1\r\n for i, (t, h, m) in enumerate(cs):\r\n if t != t0 and h <= h0 and m > m0 and i not in used:\r\n m0 = m\r\n i0 = i\r\n if i0 == -1:\r\n break\r\n\r\n used.add(i0)\r\n h0 += cs[i0][2]\r\n t0 = 1 - t0\r\n\r\n return len(used)\r\n\r\nprint(max(try_eat(0), try_eat(1)))", "n,x = map(int,input().split())\r\nk = [[],[]]\r\ndef add(s):\r\n t,h,m = map(int,s.split())\r\n k[t].append([h,m])\r\n[add(input()) for _ in range(n)]\r\ndef calc(t):\r\n cur = x\r\n ans = 0\r\n mark = [[False] * len(k[0]),[False] * len (k[1])]\r\n while True:\r\n w = 0\r\n id = 0\r\n for i in range(len(k[t])):\r\n if mark[t][i] == False and w < k[t][i][1] and cur >= k[t][i][0]:\r\n w = k[t][i][1]\r\n id = i\r\n if w == 0: break\r\n ans += 1\r\n cur += w\r\n mark[t][id] = True\r\n t = 1 - t\r\n return ans\r\nsol = max(calc(0),calc(1))\r\nprint (sol)", "nw = input().split()\r\nnumCandies = int(nw[0])\r\nweight = int(nw[1])\r\n\r\nthm1 = []\r\nthm2 = []\r\n\r\nfor i in range(numCandies):\r\n val = input().split()\r\n val = [int(x) for x in val]\r\n if val[0] == 0:\r\n thm1.append(val)\r\n else:\r\n thm2.append(val)\r\n\r\n\r\ndef get_candy(woc, tlist):\r\n ind = -1\r\n maxm = -1\r\n for k in range(len(tlist)):\r\n if tlist[k][1] <= woc:\r\n if maxm < tlist[k][2]:\r\n maxm = tlist[k][2]\r\n ind = k\r\n if ind >= 0:\r\n val1 = tlist.pop(ind)\r\n return val1\r\n return None\r\n\r\n\r\ncount = [0, 0]\r\nfor i in range(2):\r\n candyType = i\r\n initialWeight = weight\r\n thm1c = thm1[:]\r\n thm2c = thm2[:]\r\n while True:\r\n if candyType == 0:\r\n candy = get_candy(initialWeight, thm1c)\r\n if candy is not None:\r\n chm = candy\r\n h = chm[1]\r\n m = chm[2]\r\n initialWeight += m\r\n count[i] += 1\r\n candyType = 1\r\n else:\r\n break\r\n else:\r\n candy = get_candy(initialWeight, thm2c)\r\n if candy is not None:\r\n chm = candy\r\n h = chm[1]\r\n m = chm[2]\r\n initialWeight += m\r\n count[i] += 1\r\n candyType = 0\r\n else:\r\n break\r\nprint(max(count))\r\n", "import copy\r\nn , xx = map(int, input().split())\r\nfirstorig = list()\r\nsecondorig = list()\r\nfor i in range(n):\r\n t, h, m = map(int, input().split())\r\n if t == 0: firstorig.append((h, m))\r\n else: secondorig.append((h,m))\r\n\r\n#print(len(firstorig), len(secondorig))\r\nfirstres = 0\r\nfirst = copy.deepcopy(firstorig)\r\nsecond = copy.deepcopy(secondorig)\r\ncurmaxjump = xx\r\n\r\nwhile True:\r\n #print(len(first), len(second), firstres)\r\n if len(first)>0:\r\n i = 0\r\n weight = 0\r\n for x in range(len(first)):\r\n if first[x][0] <= curmaxjump and first[x][1] > weight:\r\n weight = first[x][1]\r\n i = x\r\n if weight > 0:\r\n firstres+=1\r\n curmaxjump+=weight\r\n first.pop(i)\r\n else: break\r\n else: break\r\n if len(second)>0:\r\n i = 0\r\n weight = 0\r\n for x in range(len(second)):\r\n if second[x][0] <= curmaxjump and second[x][1] > weight:\r\n weight = second[x][1]\r\n i = x\r\n if weight > 0:\r\n firstres+=1\r\n curmaxjump+=weight\r\n second.pop(i)\r\n else: break\r\n else: break\r\n\r\nsecondres = 0\r\ncurmaxjump = xx\r\nfirst = copy.deepcopy(firstorig)\r\nsecond = copy.deepcopy(secondorig)\r\n\r\nwhile True:\r\n #print(len(first), len(second), curmaxjump)\r\n if len(second)>0:\r\n i = 0\r\n weight = 0\r\n for x in range(len(second)):\r\n if second[x][0] <= curmaxjump and second[x][1] > weight:\r\n weight = second[x][1]\r\n i = x\r\n if weight > 0:\r\n secondres+=1\r\n curmaxjump+=weight\r\n second.pop(i)\r\n else: break\r\n else: break\r\n #print(len(first), len(second), firstres)\r\n if len(first)>0:\r\n i = 0\r\n weight = 0\r\n for x in range(len(first)):\r\n if first[x][0] <= curmaxjump and first[x][1] > weight:\r\n weight = first[x][1]\r\n i = x\r\n if weight > 0:\r\n secondres+=1\r\n curmaxjump+=weight\r\n first.pop(i)\r\n else: break\r\n else: break\r\n\r\n\r\n#print(firstres)\r\n#print(firstres, secondres)\r\nprint(max(firstres, secondres))", "import queue\nn,maxh=[int(x) for x in input().split()]\ncar=[]\nfru=[]\nhcar=queue.PriorityQueue(2000)\nhfru=queue.PriorityQueue(2000)\nfor i in range(n):\n\ta,b,c=[int(x) for x in input().split()]\n\tif a==0:\n\t\tcar.append((b,c))\n\telse:\n\t\tfru.append((b,c))\npcar=0\nmcar=len(car)\npfru=0\nmfru=len(fru)\ncar.sort()\nfru.sort()\neaten=0\ndef getinh():\n\tglobal pcar\n\tglobal pfru\n\twhile pcar<mcar and car[pcar][0]<=maxh:\n\t\thcar.put(-car[pcar][1])\n\t\tpcar+=1\n\twhile pfru<mfru and fru[pfru][0]<=maxh:\n\t\thfru.put(-fru[pfru][1])\n\t\tpfru+=1\ngetinh()\nwhile (not hcar.empty()) and (not hfru.empty()):\n\teaten+=2\n\tmaxh-=hcar.get()+hfru.get()\n\tgetinh()\nif hcar.empty():\n\tnow=0\nelse:\n\tnow=1\n\nwhile True:\n\tif now==0:\n\t\tif hfru.empty():\n\t\t\tbreak\n\t\telse:\n\t\t\tnow=1\n\t\t\tmaxh-=hfru.get()\n\telse:\n\t\tif hcar.empty():\n\t\t\tbreak\n\t\telse:\n\t\t\tnow=0\n\t\t\tmaxh-=hcar.get()\n\teaten+=1\n\tgetinh()\nprint(eaten)\n", "import itertools\r\nimport operator\r\n\r\n\r\nn, x = map(int, str.split(input()))\r\na = []\r\nb = []\r\nfor _ in range(n):\r\n\r\n t, h, m = map(int, str.split(input()))\r\n (a if t else b).append((h, m))\r\n\r\nbest = 0\r\nfor ca, cb in ((a, b), (b, a)):\r\n\r\n cx = x\r\n count = 0\r\n ca, cb = ca[:], cb[:]\r\n while True:\r\n\r\n available = tuple(filter(lambda candy: candy[1][0] <= cx, enumerate(ca)))\r\n if available:\r\n\r\n i, candy = max(available, key=lambda candy: candy[1][1])\r\n ca.pop(i)\r\n count += 1\r\n cx += candy[1]\r\n\r\n else:\r\n\r\n break\r\n\r\n ca, cb = cb, ca\r\n\r\n best = max(best, count)\r\n\r\nprint(best)\r\n", "#from itertools import *\r\n#from math import *\r\n#from bisect import *\r\n#from collections import *\r\n#from random import *\r\n#from decimal import *\r\n#from heapq import *\r\n#from itertools import * # Things Change ....remember :)\r\nimport sys\r\ninput=sys.stdin.readline\r\ndef inp():\r\n return int(input())\r\ndef st():\r\n return input().rstrip('\\n')\r\ndef lis():\r\n return list(map(int,input().split()))\r\ndef ma():\r\n return map(int,input().split())\r\nt=1\r\nwhile(t):\r\n t-=1\r\n n,x=ma()\r\n x1=x\r\n maxx=0\r\n r=[]\r\n for i in range(n):\r\n a=lis()\r\n r.append(a)\r\n x=x1\r\n vis=[0]*n\r\n for i in range(n):\r\n cm=x\r\n mass=0\r\n for j in range(n):\r\n if(i%2==0):\r\n if(vis[j]==0 and r[j][0]==0 and x>=r[j][1]):\r\n if(r[j][2]>mass):\r\n pos=j\r\n mass=r[j][2]\r\n else:\r\n if(vis[j]==0 and r[j][0]==1 and x>=r[j][1]):\r\n if(r[j][2]>mass):\r\n pos=j\r\n mass=r[j][2]\r\n if(mass==0):\r\n break\r\n x+=mass\r\n maxx+=1\r\n vis[pos]=1\r\n maxx1=0\r\n x=x1\r\n vis=[0]*n\r\n for i in range(n):\r\n cm=x\r\n mass=0\r\n for j in range(n):\r\n if(i%2):\r\n if(vis[j]==0 and r[j][0]==0 and x>=r[j][1]):\r\n if(r[j][2]>mass):\r\n pos=j\r\n mass=r[j][2]\r\n else:\r\n if(vis[j]==0 and r[j][0]==1 and x>=r[j][1]):\r\n if(r[j][2]>mass):\r\n pos=j\r\n mass=r[j][2]\r\n if(mass==0):\r\n break\r\n x+=mass\r\n maxx1+=1\r\n vis[pos]=1\r\n print(max(maxx,maxx1)) \r\n \r\n", "import sys\r\nimport math\r\ninput = sys.stdin.readline\r\n\r\nif __name__ == '__main__':\r\n\r\n n, x = map(int, input().split())\r\n arr = []\r\n for i in range(n):\r\n t, h, m = map(int, input().split())\r\n arr.append([t, h, m])\r\n\r\n t1index, t2index, t1, t2 = -1, -1, 0, 0\r\n for i in range(n):\r\n if arr[i][0] == 0:\r\n if arr[i][1] <= x and arr[i][2] > t1:\r\n t1index = i\r\n t1 = arr[i][2]\r\n else:\r\n if arr[i][1] <= x and arr[i][2] > t2:\r\n t2index = i\r\n t2 = arr[i][2]\r\n\r\n ans = 0\r\n if t1index != -1:\r\n taken = {}\r\n height = x\r\n\r\n possible_index = t1index\r\n while possible_index != -1:\r\n taken[possible_index] = 1\r\n height += arr[possible_index][2]\r\n prev_type = arr[possible_index][0]\r\n possible_index, possible_height = -1, 0\r\n for i in range(n):\r\n if i not in taken and arr[i][0] != prev_type and arr[i][1] <= height:\r\n if arr[i][2] > possible_height:\r\n possible_index, possible_height = i, arr[i][2]\r\n\r\n ans = max(ans, len(taken))\r\n\r\n if t2index != -1:\r\n taken = {}\r\n height = x\r\n\r\n possible_index = t2index\r\n while possible_index != -1:\r\n taken[possible_index] = 1\r\n height += arr[possible_index][2]\r\n prev_type = arr[possible_index][0]\r\n possible_index, possible_height = -1, 0\r\n for i in range(n):\r\n if i not in taken and arr[i][0] != prev_type and arr[i][1] <= height:\r\n if arr[i][2] > possible_height:\r\n possible_index, possible_height = i, arr[i][2]\r\n\r\n ans = max(ans, len(taken))\r\n\r\n print(ans)", "import sys\ndef solve(t):\n vis0, vis1 = [False] * len(a0), [False] * len(a1)\n ans, cur = 0, jmp\n while True:\n if t == 0:\n for i, (h, m) in enumerate(a0):\n if h <= cur and not vis0[i]:\n cur += m\n vis0[i], ans = True, ans + 1\n break\n else:\n break\n else:\n for i, (h, m) in enumerate(a1):\n if h <= cur and not vis1[i]:\n cur += m\n vis1[i], ans = True, ans + 1\n break\n else:\n break\n t ^= 1\n return ans\n\ninput = sys.stdin.readline\nn,jmp=map(int,input().split())\na1=[]\na0=[]\nfor i in range(n):\n t,h,m=map(int,input().split())\n if t==1:\n a1.append((h,m))\n else:\n a0.append((h,m))\na1.sort(key=lambda x:(x[1],x[0]),reverse=True)\na0.sort(key=lambda x:(x[1],x[0]),reverse=True)\nprint(max(solve(0),solve(1)))\n", "from bisect import bisect_left\r\nn, x = map(int, input().split())\r\ns, a, b = 0, [[], []], [[], []]\r\nfor i in range(n):\r\n t, h, m = map(int, input().split())\r\n a[t].append((h, m))\r\nfor t in [0, 1]:\r\n a[t].sort(key = lambda x: x[0])\r\n for h, m in a[t]:\r\n if h > x: break\r\n b[t].append(m)\r\n b[t].sort()\r\nfor t in [0, 1]:\r\n y, i, c = x, [len(b[0]), len(b[1])], [b[0][:], b[1][:]]\r\n while c[t]:\r\n y += c[t].pop()\r\n t = 1 - t\r\n while i[t] < len(a[t]):\r\n h, m = a[t][i[t]]\r\n if h > y: break\r\n c[t].insert(bisect_left(c[t], m), m)\r\n i[t] += 1\r\n s = max(s, i[0] + i[1] - len(c[0]) - len(c[1]))\r\nprint(s)", "n,x=map(int,input().split())\r\na=[]\r\nb=[]\r\nfor i in range(n):\r\n t,h,m=map(int,input().split())\r\n if t:\r\n a.append((h,m))\r\n else:\r\n b.append((h,m))\r\ncounter1=0;\r\nnow=True\r\na1=a[:]\r\nb1=b[:]\r\nx2=x\r\nwhile 1:\r\n if now:\r\n if(len(a)==0):\r\n break;\r\n \r\n i=0\r\n maxx=0\r\n mi=0\r\n for kor in a:\r\n if kor[0]<=x and maxx<kor[1]:\r\n maxx=kor[1]\r\n mi=i\r\n i+=1\r\n if maxx==0:\r\n break\r\n x+=maxx\r\n a.pop(mi)\r\n counter1+=1\r\n now=False\r\n else:\r\n if(len(b)==0):\r\n break;\r\n i=0\r\n maxx=0\r\n mi=0\r\n for kor in b:\r\n if kor[0]<=x and maxx<kor[1]:\r\n maxx=kor[1]\r\n mi=i\r\n i+=1\r\n if(maxx==0):\r\n break;\r\n x+=maxx\r\n b.pop(mi)\r\n counter1+=1\r\n now=True\r\n \r\ncounter2=0;\r\nnow=False\r\nwhile 1:\r\n if now:\r\n if(len(a1)==0):\r\n break;\r\n i=0\r\n maxx=0\r\n mi=0\r\n for kor in a1:\r\n if kor[0]<=x2 and maxx<kor[1]:\r\n maxx=kor[1]\r\n mi=i\r\n i+=1\r\n if maxx==0:\r\n break\r\n x2+=maxx\r\n a1.pop(mi)\r\n counter2+=1\r\n now=False\r\n else:\r\n if(len(b1)==0):\r\n break;\r\n i=0\r\n maxx=0\r\n mi=0\r\n for kor in b1:\r\n if kor[0]<=x2 and maxx<kor[1]:\r\n maxx=kor[1]\r\n mi=i\r\n i+=1\r\n if(maxx==0):\r\n break;\r\n x2+=maxx\r\n b1.pop(mi)\r\n counter2+=1\r\n now=True\r\nprint(counter1 if counter1>counter2 else counter2) \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n", "def solve ( p, n, x, t, h, m ):\r\n used, xx, ans = [0] * n, x, 0\r\n while ( True ):\r\n k = -1\r\n for i in range( n ): \r\n if ( used[i] == 0 ) and ( t[i] == p ) and ( h[i] <= xx ) and ( ( k == -1 ) or ( m[i] > m[k] ) ): k = i\r\n if ( k == -1 ): break\r\n ans += 1\r\n xx += m[k]\r\n used[k] = 1\r\n p = p ^ 1\r\n return ans\r\n \r\nn, x = map( int, input().split() )\r\nt, h, m = [0] * n, [0] * n, [0] * n\r\nfor i in range( n ): t[i], h[i], m[i] = map( int, input().split() )\r\nprint ( max( solve( 0, n, x, t, h, m ), solve( 1, n, x, t, h, m ) ) )", "import sys\r\nimport math\r\ninput = sys.stdin.readline\r\nfrom queue import PriorityQueue\r\n\r\ndef maxCandies(arr, prev, x, n):\r\n q0, q1 = PriorityQueue(), PriorityQueue()\r\n i, candies = 0, 0\r\n while i < n:\r\n while i < n and arr[i][1] <= x:\r\n if arr[i][0] == 0:\r\n q0.put(-1 * arr[i][2])\r\n else:\r\n q1.put(-1 * arr[i][2])\r\n i += 1\r\n if prev == 0:\r\n if q1.empty(): return candies\r\n x += -1 * q1.get()\r\n candies += 1\r\n else:\r\n if q0.empty(): return candies\r\n x += -1 * q0.get()\r\n candies += 1\r\n prev = 1 if prev == 0 else 0\r\n\r\n while True:\r\n if prev == 0:\r\n if q1.empty(): return candies\r\n x += -1 * q1.get()\r\n candies += 1\r\n else:\r\n if q0.empty(): return candies\r\n x += -1 * q0.get()\r\n candies += 1\r\n prev = 1 if prev == 0 else 0\r\n\r\n\r\nif __name__ == '__main__':\r\n\r\n n, x = map(int, input().split())\r\n arr = []\r\n for i in range(n):\r\n t, h, m = map(int, input().split())\r\n arr.append([t, h, m])\r\n\r\n arr.sort(key=lambda x: x[1])\r\n\r\n print(max(maxCandies(arr, 0, x, n), maxCandies(arr, 1, x, n)))\r\n\r\n\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\ndef f(q, w, h):\r\n c = 0\r\n d = [0]*len(q)\r\n e = [0]*len(w)\r\n while 1:\r\n oc = -1\r\n op = -1\r\n for i in range(len(q)):\r\n if q[i][0] <= h:\r\n if d[i] == 0:\r\n if q[i][1] > oc:\r\n oc = q[i][1]\r\n op = i\r\n else:\r\n break\r\n if oc == -1:\r\n break\r\n else:\r\n h += oc\r\n c += 1\r\n d[op] = 1\r\n\r\n oc = -1\r\n op = -1\r\n for i in range(len(w)):\r\n if w[i][0] <= h:\r\n if e[i] == 0:\r\n if w[i][1] > oc:\r\n oc = w[i][1]\r\n op = i\r\n else:\r\n break\r\n if oc == -1:\r\n break\r\n else:\r\n h += oc\r\n c += 1\r\n e[op] = 1\r\n\r\n return c\r\n\r\n\r\nn, x = map(int, input().split())\r\nl = []\r\nr = []\r\nfor i in range(n):\r\n a, b, c = map(int, input().split())\r\n if a == 0:\r\n l.append((b, c))\r\n else:\r\n r.append((b, c))\r\nl.sort()\r\nr.sort()\r\nprint(max(f(l, r, x), f(r, l, x)))\r\n", "import sys\r\nfrom operator import itemgetter\r\ndef main():\r\n\tstr = sys.stdin.readline()\r\n\ttokens = str.split()\r\n\tn = int(tokens[0])\r\n\tx = int(tokens[1])\r\n\ts1=[]\r\n\ts2=[]\r\n\tfor i in range(n):\r\n\t\tstr = sys.stdin.readline()\r\n\t\ttokens = str.split()\r\n\t\tt = int(tokens[0])\r\n\t\th = int(tokens[1])\r\n\t\tm = int(tokens[2])\r\n\t\tif t==0:\r\n\t\t\ts1.append((h,m))\r\n\t\telse:\r\n\t\t\ts2.append((h,m))\r\n\t\t\r\n\ts1 = sorted(s1, key=itemgetter(0)) # secondary key, height, ascending\r\n\ts1 = sorted(s1, key=itemgetter(1), reverse=True) # primary key, mass, descending\r\n\ts2 = sorted(s2, key=itemgetter(0))\r\n\ts2 = sorted(s2, key=itemgetter(1), reverse=True)\r\n\t\t\r\n\ts1A = s1[:]\r\n\ts2A = s2[:]\r\n\tjumpA = x\r\n\tcandiesA = 0\r\n\tcurrentA = s1A\r\n\twhile True:\r\n\t\tfound = 0\r\n\t\tfor i in range(len(currentA)):\r\n\t\t\tif currentA[i][0] <= jumpA:\r\n\t\t\t\tfound = 1\r\n\t\t\t\tcandiesA = candiesA + 1\r\n\t\t\t\tjumpA = jumpA + currentA[i][1]\r\n\t\t\t\tdel currentA[i]\r\n\t\t\t\tbreak\r\n\t\t\t\r\n\t\tif found == 1:\r\n\t\t\tif currentA == s1A:\r\n\t\t\t\tcurrentA = s2A\r\n\t\t\telse:\r\n\t\t\t\tcurrentA = s1A\r\n\t\telse:\r\n\t\t\tbreak\r\n\t\t\r\n\ts1B = s1[:]\r\n\ts2B = s2[:]\r\n\tjumpB = x\r\n\tcandiesB = 0\r\n\tcurrentB = s2B\r\n\twhile True:\r\n\t\tfound = 0\r\n\t\tfor i in range(len(currentB)):\r\n\t\t\tif currentB[i][0] <= jumpB:\r\n\t\t\t\tfound = 1\r\n\t\t\t\tcandiesB = candiesB + 1\r\n\t\t\t\tjumpB = jumpB + currentB[i][1]\r\n\t\t\t\tdel currentB[i]\r\n\t\t\t\tbreak\r\n\t\t\t\r\n\t\tif found == 1:\r\n\t\t\tif currentB == s1B:\r\n\t\t\t\tcurrentB = s2B\r\n\t\t\telse:\r\n\t\t\t\tcurrentB = s1B\r\n\t\telse:\r\n\t\t\tbreak\r\n\t\r\n\tprint(max(candiesA,candiesB))\r\nif __name__ == \"__main__\":\r\n main()\r\n" ]
{"inputs": ["5 3\n0 2 4\n1 3 1\n0 8 3\n0 20 10\n1 5 5", "5 2\n1 15 2\n1 11 2\n0 17 2\n0 16 1\n1 18 2", "6 2\n1 17 3\n1 6 1\n0 4 2\n1 10 1\n1 7 3\n1 5 1", "7 2\n1 14 1\n1 9 2\n0 6 3\n0 20 2\n0 4 2\n0 3 1\n0 9 2", "8 2\n0 20 3\n1 5 2\n1 4 1\n1 7 1\n0 1 3\n1 5 3\n1 7 2\n1 3 1", "9 2\n0 1 1\n1 8 2\n1 11 1\n0 9 1\n1 18 2\n1 7 3\n1 8 3\n0 16 1\n0 12 2", "10 2\n0 2 3\n1 5 2\n0 7 3\n1 15 2\n0 14 3\n1 19 1\n1 5 3\n0 2 2\n0 10 2\n0 10 3", "2 1\n0 1 1\n1 2 1", "2 1\n1 1 1\n0 2 1", "2 1\n0 1 1\n0 2 1", "2 1\n1 1 1\n1 2 1", "2 1\n0 1 1\n1 3 1", "2 1\n1 1 1\n0 3 1", "1 1\n1 2 1", "3 4\n1 1 2\n1 4 100\n0 104 1", "3 4\n1 1 100\n1 4 2\n0 104 1", "3 100\n0 1 1\n1 1 1\n1 1 1", "4 20\n0 10 10\n0 20 50\n1 40 1\n1 40 1", "4 2\n0 1 1\n0 2 3\n1 4 1\n1 5 1", "3 10\n0 9 1\n0 10 10\n1 20 1", "3 5\n0 4 1\n0 5 10\n1 15 5", "3 4\n0 2 1\n0 3 3\n1 6 5", "3 3\n0 1 1\n0 2 100\n1 10 1", "3 2\n0 1 1\n0 2 2\n1 4 4", "5 3\n0 1 5\n0 1 5\n0 1 5\n1 1 10\n1 1 1", "3 2\n0 1 1\n0 2 2\n1 4 2", "4 10\n0 20 1\n1 1 9\n1 2 11\n1 3 8", "7 1\n0 1 99\n1 100 1\n0 100 1\n0 101 1000\n1 1000 1\n0 1000 1\n1 1000 1", "4 3\n0 1 1\n0 2 100\n0 3 1\n1 100 1", "3 3\n0 1 100\n0 2 1\n1 100 100", "3 2\n0 1 1\n0 2 100\n1 10 1", "3 1\n0 1 1\n1 1 5\n0 7 1", "3 5\n0 2 3\n1 9 10\n0 4 4", "3 3\n0 2 1\n0 3 2\n1 5 10"], "outputs": ["4", "0", "0", "0", "2", "1", "9", "2", "2", "1", "1", "1", "1", "0", "3", "3", "3", "4", "4", "3", "3", "3", "3", "3", "5", "3", "3", "7", "3", "3", "3", "3", "3", "3"]}
UNKNOWN
PYTHON3
CODEFORCES
17
e31d0e9399172420275ca466ad9e6e90
Old Berland Language
Berland scientists know that the Old Berland language had exactly *n* words. Those words had lengths of *l*1,<=*l*2,<=...,<=*l**n* letters. Every word consisted of two letters, 0 and 1. Ancient Berland people spoke quickly and didn’t make pauses between the words, but at the same time they could always understand each other perfectly. It was possible because no word was a prefix of another one. The prefix of a string is considered to be one of its substrings that starts from the initial symbol. Help the scientists determine whether all the words of the Old Berland language can be reconstructed and if they can, output the words themselves. The first line contains one integer *N* (1<=≤<=*N*<=≤<=1000) — the number of words in Old Berland language. The second line contains *N* space-separated integers — the lengths of these words. All the lengths are natural numbers not exceeding 1000. If there’s no such set of words, in the single line output NO. Otherwise, in the first line output YES, and in the next *N* lines output the words themselves in the order their lengths were given in the input file. If the answer is not unique, output any. Sample Input 3 1 2 3 3 1 1 1 Sample Output YES 0 10 110 NO
[ "class Node(object):\r\n\r\n\r\n def __init__(self, char: str):\r\n self.char = char\r\n self.left = None\r\n\r\n self.right=None\r\n\r\n self.done=0\r\n self.parent=None\r\n self.len=0\r\n\r\nze=Node(\"\")\r\na=Node(\"\")\r\na.parent=ze\r\ncurr=a\r\n\r\nn=int(input())\r\nb=list(map(int,input().split()))\r\nc=[]\r\nfor j in range(n):\r\n c.append([b[j],j])\r\n\r\nc.sort()\r\nposs=1\r\nst=[\"\"]\r\nans=[\"\" for i in range(n)]\r\nfor j in c:\r\n val,ind=j\r\n while(curr.done==1):\r\n curr=curr.parent\r\n\r\n st.pop()\r\n\r\n\r\n if curr==ze:\r\n poss=0\r\n break\r\n\r\n if poss==0:\r\n break\r\n else:\r\n while(curr.len!=val):\r\n if curr.left==None:\r\n ne=Node(\"0\")\r\n curr.left=ne\r\n ne.len=curr.len+1\r\n ne.parent=curr\r\n curr=curr.left\r\n st.append(curr.char)\r\n elif curr.right==None:\r\n ne = Node(\"1\")\r\n curr.right = ne\r\n ne.len = curr.len + 1\r\n ne.parent = curr\r\n curr = curr.right\r\n st.append(curr.char)\r\n curr.done=1\r\n curr1=curr\r\n while(curr1.char==\"1\"):\r\n curr1.parent.done=1\r\n curr1= curr1.parent\r\n\r\n ans[ind]=\"\".join(st)\r\n\r\nif poss:\r\n print(\"YES\")\r\n for j in ans:\r\n print(j)\r\n\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", "class Node:\r\n def __init__(self) -> None:\r\n self.child = {}\r\n self.count = 0\r\n\r\n\r\nC = [\"0\", \"1\"]\r\n\r\n\r\ndef addWord(root, length, word=\"\"):\r\n if length == 0:\r\n if root.count == 0 and len(root.child) == 0:\r\n root.count = 1\r\n return word\r\n else:\r\n return \"\"\r\n\r\n for ch in C:\r\n if ch not in root.child:\r\n root.child[ch] = Node()\r\n if root.child[ch].count == 0:\r\n w = addWord(root.child[ch], length - 1, word + ch)\r\n if w != \"\":\r\n return w\r\n\r\n return \"\"\r\n\r\n\r\ndef printTree(root, word=\"\"):\r\n if root.count > 0:\r\n print(word)\r\n for ch in root.child:\r\n printTree(root.child[ch], word + ch)\r\n\r\n\r\nroot = Node()\r\nn = int(input())\r\na = input().split()\r\nflag = True\r\nwords = []\r\nfor length in a:\r\n word = addWord(root, int(length))\r\n if word:\r\n words.append(word)\r\n else:\r\n flag = False\r\n break\r\n\r\nif flag:\r\n print(\"YES\")\r\n for word in words:\r\n print(word)\r\nelse:\r\n print(\"NO\")\r\n", "import sys\r\nsys.setrecursionlimit(100000)\r\nMAX = 1005\r\nclass Node:\r\n len = 0\r\n id = 0\r\n str = \"\"\r\n def __init__(self, len, id, str):\r\n self.len = len\r\n self.id = id\r\n self.str = str\r\n\r\ndef dfs(t, s):\r\n global cnt\r\n global flag\r\n global n\r\n if (t == b[cnt].len):\r\n b[cnt].str = s\r\n cnt += 1\r\n return\r\n if cnt == n:\r\n return\r\n dfs(t + 1, s + '0')\r\n if cnt == n:\r\n return\r\n dfs(t + 1, s + '1')\r\n\r\nif __name__ == \"__main__\":\r\n n = int(input())\r\n a = list(map(int, input().split()))\r\n b = []\r\n for i in range(n):\r\n b.append(Node(a[i], i, \"\"))\r\n cnt = 0\r\n b.sort(key = lambda node: node.len, reverse = False)\r\n\r\n dfs(0, \"\")\r\n if cnt < n:\r\n print('NO')\r\n else:\r\n print('YES')\r\n b.sort(key = lambda node: node.id, reverse = False)\r\n for i in range(n):\r\n print(b[i].str)\r\n", "n = int(input())\r\nl = list(map(int, input().split()))\r\nfor i in range(n):\r\n l[i] = (l[i], i)\r\nl.sort(key=lambda x : x[0])\r\ncurrentWord = \"\"\r\nfirstL = l[0][0]\r\nfor i in range(firstL):\r\n currentWord += '0'\r\nans = ['' for _ in range(n)]\r\nans[l[0][1]] = currentWord\r\nfor i in range(1, n):\r\n haveNext = False\r\n while True:\r\n lastChar = currentWord[-1]\r\n currentWord = currentWord[:-1]\r\n if lastChar == '0':\r\n currentWord += '1'\r\n haveNext = True\r\n break\r\n elif len(currentWord) == 0:\r\n break\r\n if not haveNext:\r\n print(\"NO\")\r\n import sys\r\n sys.exit()\r\n while len(currentWord) < l[i][0]:\r\n currentWord += '0'\r\n ans[l[i][1]] = currentWord\r\nprint('YES')\r\nfor s in ans:\r\n print(s)\r\n", "import sys\r\nsys.setrecursionlimit(1000000)\r\n\r\nclass Node:\r\n def __init__(self, val):\r\n self.child = dict()\r\n self.is_blocked = False\r\n self.val = val\r\n\r\nclass Trie:\r\n def __init__(self):\r\n self.root = Node('')\r\n \r\n def add(self, length, id, res):\r\n st = [self.root]\r\n while length and len(st):\r\n u = st[-1]\r\n length -= 1\r\n if 0 not in u.child:\r\n u.child[0] = Node('0')\r\n if not u.child[0].is_blocked:\r\n st.append(u.child[0])\r\n else:\r\n if 1 not in u.child:\r\n u.child[1] = Node('1')\r\n if not u.child[1].is_blocked:\r\n st.append(u.child[1])\r\n else:\r\n u.is_blocked = True\r\n length += 2\r\n st.pop()\r\n if length == 0:\r\n st[-1].is_blocked = True\r\n res[id] = ''.join(node.val for node in st)\r\n return True\r\n return False\r\n \r\nif __name__ == \"__main__\":\r\n n = int(input())\r\n a = list(map(int, input().split()))\r\n a = sorted([(a[i], i) for i in range(n)])\r\n\r\n trie = Trie()\r\n res = [None] * n\r\n for length, i in a:\r\n if not trie.add(length, i, res):\r\n print('NO')\r\n exit()\r\n\r\n print('YES')\r\n for length in res:\r\n print(length)", "n = int(input())\r\nl = list(map(int, input().split()))\r\n\r\no = list(range(n))\r\no.sort(key = lambda i : -l[i])\r\nans = [''] * n\r\n\r\ns = 0\r\nlst = 10 ** 3\r\nfor i in o :\r\n s >>= lst - l[i]\r\n lst = l[i]\r\n if i != o[0] :\r\n s += 1\r\n if s >= (1 << l[i]) :\r\n print('NO')\r\n exit()\r\n ans[i] = bin(s)[2:]\r\n ans[i] = '0' * (l[i] - len(ans[i])) + ans[i]\r\nprint('YES')\r\nprint('\\n'.join(ans))", "#!/usr/bin/python3\r\n\r\ncounts = [0]*1024\r\nfor x in range(len(counts)): counts[x] = []\r\nN = int(input())\r\nx = [int(t) for t in input().strip().split()]\r\nfor i,t in enumerate(x): counts[t].append(i)\r\n\r\n\r\ncurr = 0\r\nans = [0]*N\r\nfor i in range(1,1024):\r\n\twhile len(counts[i]) > 0:\r\n\t\tx = bin(curr)[2:]\r\n\t\tif len(x) > i:\r\n\t\t\tprint(\"NO\")\r\n\t\t\texit(0)\r\n\t\telse: x = \"0\"*(i-len(x)) + x\r\n\t\tans[counts[i].pop()] = x\r\n\t\tcurr += 1\r\n\tcurr = 2*curr\r\nprint(\"YES\")\r\nprint(\"\\n\".join(ans))", "from sys import stdin\r\nn = int(stdin.readline())\r\na = [int(x) for x in stdin.readline().split()]\r\na = [(a[x], x) for x in range(n)]\r\na.sort()\r\nhigh = a[-1][0]\r\ntotal = 1<<high\r\na2 = a[:]\r\na = [[high-x[0], x[1]] for x in a]\r\n\r\ncurrent = 0\r\n\r\nwords = []\r\n\r\nfor b in a:\r\n x = b[0]\r\n words.append((b[1],current>>x, -x+high))\r\n current += 1<<x\r\n\r\nif current > total:\r\n print('NO')\r\nelse:\r\n words.sort()\r\n print('YES')\r\n for bruh,x,y in words:\r\n fmt = '{0:0' + str(y) + 'b}'\r\n print(fmt.format(x))\r\n \r\n", "import sys\r\nsys.setrecursionlimit(1050)\r\n\r\nclass Node:\r\n def __init__(self, depth, parent):\r\n self.depth = depth\r\n self.parent = parent\r\n self.left = None\r\n self.right = None\r\n self.leaf = False\r\n \r\nstacks = {}\r\n\r\ndef traverse(node, symbols):\r\n if node.leaf:\r\n s = ''.join(symbols)\r\n stacks.setdefault(len(s), []).append(s)\r\n return\r\n if node.left != None:\r\n symbols.append('0')\r\n traverse(node.left, symbols)\r\n symbols.pop()\r\n if node.right != None:\r\n symbols.append('1')\r\n traverse(node.right, symbols)\r\n symbols.pop()\r\n\r\nn = int(input())\r\noriginal_lengths = list(map(int, input().split()))\r\nlengths = sorted(original_lengths[:])\r\nroot = Node(0, None)\r\ncurr = root\r\nfor i in range(lengths[0]):\r\n curr.left = Node(curr.depth+1, curr)\r\n curr = curr.left\r\ncurr.leaf = True\r\nfor length in lengths[1:]:\r\n curr = curr.parent\r\n while curr.right != None:\r\n if curr == root:\r\n print('NO')\r\n sys.exit()\r\n curr = curr.parent\r\n curr.right = Node(curr.depth+1, curr)\r\n curr = curr.right\r\n while curr.depth != length:\r\n curr.left = Node(curr.depth+1, curr)\r\n curr = curr.left\r\n curr.leaf = True\r\nprint('YES')\r\ntraverse(root, [])\r\nfor length in original_lengths:\r\n print(stacks[length].pop())", "N = int(input())\r\nA = list(map(int, input().split()))\r\nX = [(A[i], i) for i in range(N)]\r\nX.sort()\r\nMIN = [0]\r\nANS = [\"\"] * N\r\nfor tt in range(N):\r\n x, y = X[tt]\r\n\r\n while len(MIN) < x:\r\n MIN.append(0)\r\n\r\n ANS[y] = \"\".join(map(str, MIN))\r\n MIN[-1] += 1\r\n\r\n for i in range(len(MIN) - 1, -1, -1):\r\n if MIN[i] == 2:\r\n MIN[i] = 0\r\n if i - 1 < 0 and tt != N - 1:\r\n print(\"NO\")\r\n exit()\r\n MIN[i - 1] += 1\r\nprint(\"YES\")\r\nfor ans in ANS:\r\n print(ans)\r\n", "import sys\r\nimport operator\r\nimport queue\r\nsys.setrecursionlimit(100000)\r\n\r\n# global constant\r\nINF = int(1e7+1)\r\nMAX = 2\r\n\r\n# For testing\r\n#sys.stdin = open(\"INP.txt\", 'r')\r\n#sys.stdout = open(\"OUT.txt\", 'w')\r\n\r\n# global variables\r\nans = 1000*[None]\r\n\r\n# classes\r\n\r\n\r\nclass Pair:\r\n def __init__(self, first, second):\r\n self.first = first\r\n self.second = second\r\n\r\n\r\nclass node:\r\n def __init__(self):\r\n self.countLeaf = 0\r\n self.child = MAX*[None]\r\n self.isValid = True\r\n\r\n# functions\r\n\r\n\r\ndef addWord(root, length, string):\r\n if length == 0:\r\n return True, string\r\n if not root.child[0] or root.child[0].isValid:\r\n string+='0'\r\n if not root.child[0]:\r\n root.child[0] = node()\r\n if length==1:\r\n root.child[0].isValid = False\r\n ret, string = addWord(root.child[0], length-1, string)\r\n if root.child[0] and root.child[1] and not root.child[0].isValid and not root.child[1].isValid:\r\n root.isValid = False\r\n return ret, string\r\n\r\n elif not root.child[1] or root.child[1].isValid:\r\n string+='1'\r\n if not root.child[1]:\r\n root.child[1] = node()\r\n if length==1:\r\n root.child[1].isValid = False\r\n ret, string = addWord(root.child[1], length-1, string)\r\n if root.child[0] and root.child[1] and not root.child[0].isValid and not root.child[1].isValid:\r\n root.isValid = False\r\n return ret, string\r\n return False, string\r\n\r\n# main function\r\ndef main():\r\n n = int(input())\r\n a = list(map(int, input().split()))\r\n for i in range(n):\r\n a[i] = Pair(a[i], i)\r\n a.sort(key = lambda x: x.first)\r\n\r\n root = node()\r\n for word in a:\r\n flag, string = addWord(root, word.first, '')\r\n if not flag:\r\n print(\"NO\")\r\n raise SystemExit\r\n ans[word.second] = string\r\n print(\"YES\")\r\n for i in range(n):\r\n print(ans[i])\r\n\r\nmain()\r\n", "class Node():\r\n def __init__(self):\r\n self.child = dict()\r\n self.count = 0\r\n self.weight = 0\r\n\r\ndef addWord(root, s):\r\n s = \"\"\r\n tmp = root\r\n length = 0\r\n flag = False\r\n for i in range(s):\r\n if len(tmp.child) == 0:\r\n tmp.child[0] = Node()\r\n tmp = tmp.child[0]\r\n elif len(tmp.child) == 1:\r\n if tmp.child[0].count > 0:\r\n tmp.child[1] = Node()\r\n tmp = tmp.child[1]\r\n tmp.count+=1\r\n else:\r\n tmp = tmp.child[0]\r\n elif len(tmp.child) == 2:\r\n if tmp.child[0].count > 0 and tmp.child[1].count > 0:\r\n return True\r\n elif tmp.child[0].count == 0:\r\n tmp = tmp.child[0]\r\n else:\r\n tmp = tmp.child[1]\r\n tmp.count+=1\r\n return False\r\n\r\n for ch in s:\r\n length += 1\r\n if ch in tmp.child:\r\n tmp = tmp.child[ch]\r\n if tmp.count > 0:\r\n flag = True\r\n if length == len(s):\r\n flag = True\r\n else:\r\n tmp.child[ch] = Node()\r\n tmp = tmp.child[ch]\r\n tmp.weight+=1\r\n tmp.count += 1\r\n return flag\r\n\r\n\r\ndef find(root,s):\r\n tmp = root\r\n for ch in s:\r\n if ch in tmp.child:\r\n tmp = tmp.child[ch]\r\n else:\r\n return 0\r\n return tmp.weight\r\n\r\ndef isWord(node):\r\n return node.count != 0\r\n\r\ndef isEmpty(node):\r\n return len(node.child) == 0\r\n\r\ndef removeWord(root, s, level, size):\r\n if root == None:\r\n return False\r\n if level == size:\r\n if root.count > 0:\r\n root.count-=1\r\n return True\r\n return False\r\n ch = s[level]\r\n flag = removeWord(root.child[ch],s,level+1,size)\r\n if flag == True and isWord(root.child[ch]) == False and isEmpty(root.child[ch]):\r\n tmp = root.child[ch]\r\n del tmp\r\n del root.child[ch]\r\n return flag\r\n\r\nn = int(input())\r\ncur = 0\r\nword = [\"\" for _ in range(n)]\r\n\r\ndef dfs(string, depth):\r\n global cur, n, ar, word\r\n\r\n if cur >= n:\r\n return \r\n\r\n if ar[cur][0] == depth:\r\n word[ar[cur][1]] = string\r\n cur += 1\r\n return\r\n\r\n string += '0'\r\n dfs(string, depth + 1)\r\n\r\n string = string[:-1] + '1'\r\n dfs(string, depth + 1)\r\n\r\n string = string[:-1]\r\n\r\nlength = [int(i) for i in input().split()]\r\nar = [[length[i],i] for i in range(n)]\r\nar.sort()\r\n\r\ndfs(\"\",0)\r\nif cur < n:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n for i in range(n):\r\n print(word[i])", "class Node:\r\n def __init__(self):\r\n self.child = dict()\r\n self.is_blocked = False\r\n self.parent = None\r\n\r\ndef add_word(root, length, pos):\r\n cur = root\r\n i = 0\r\n word = [0] * length\r\n while i < length:\r\n next_char = -1\r\n for j in range(2):\r\n if j not in cur.child or not cur.child[j].is_blocked:\r\n next_char = j\r\n break\r\n\r\n if next_char == -1:\r\n if cur == root:\r\n return False\r\n else:\r\n cur.is_blocked = True\r\n cur = cur.parent\r\n i -= 1\r\n else:\r\n if next_char not in cur.child:\r\n cur.child[next_char] = Node()\r\n cur.child[next_char].parent = cur\r\n cur = cur.child[next_char]\r\n word[i] = next_char\r\n i += 1\r\n\r\n cur.is_blocked = True\r\n ans[pos] = ''.join(str(x) for x in word)\r\n return True\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n n = int(input())\r\n lengths = list(map(int, input().split()))\r\n lengths = sorted([(lengths[i], i) for i in range(n)])\r\n ans = ['' for _ in range(n)]\r\n root = Node()\r\n for leng, pos in lengths:\r\n if not add_word(root, leng, pos):\r\n print('NO')\r\n exit()\r\n\r\n print('YES')\r\n for w in ans:\r\n print(w)\r\n", "def get_next(b):\r\n if not b:\r\n b.append(0)\r\n return \r\n add = 1 \r\n remember = 0\r\n for i in range(len(b) - 1 , -1 , -1):\r\n temp = b[i] + add + remember \r\n if temp > 1:\r\n temp = 0 \r\n remember = 1 \r\n else:\r\n remember = 0\r\n add = 0 \r\n b[i] = temp \r\n\r\ndef is_largest(b):\r\n if not b:\r\n return False \r\n for i in range(len(b)):\r\n if b[i] == 0:\r\n return False \r\n\r\n return True \r\ndef solve():\r\n N = int(input())\r\n items =[]\r\n index = 0\r\n for length in map(int,input().split()):\r\n items.append((index,length))\r\n index += 1\r\n items = sorted(items,key=lambda item: item[1])\r\n result = []\r\n results = [0 for _ in range(N)]\r\n for item in items:\r\n index,length = item \r\n if is_largest(result):\r\n print('NO')\r\n break \r\n if result:\r\n get_next(result)\r\n else:\r\n result = [0 for _ in range(length)]\r\n while len(result) < length:\r\n result.append(0)\r\n\r\n results[index] = ''.join(str(num) for num in result)\r\n else:\r\n print('YES')\r\n for result in results:\r\n print(result)\r\n\r\nsolve()\r\n" ]
{"inputs": ["3\n1 2 3", "3\n1 1 1", "10\n4 4 4 4 4 4 4 4 4 4", "20\n6 7 7 7 7 6 7 7 7 7 7 7 7 7 7 7 7 7 6 7", "30\n9 10 8 10 10 10 10 10 7 7 10 10 10 10 10 10 10 10 10 10 9 10 10 10 10 10 10 10 4 3", "50\n10 10 10 10 10 10 9 9 10 10 9 10 10 10 10 9 8 7 8 10 10 10 7 9 10 10 9 9 9 10 10 10 9 10 10 10 10 10 9 10 10 7 8 9 9 8 9 6 6 6", "100\n17 18 22 15 14 18 9 21 14 19 14 20 12 15 9 23 19 20 19 22 13 22 17 11 21 22 8 17 23 18 21 23 22 23 15 18 21 17 17 9 13 21 23 19 18 23 15 14 17 19 22 23 12 16 23 16 20 9 12 17 18 11 10 17 16 21 8 21 16 19 21 17 12 20 14 16 17 10 22 20 17 13 15 19 9 22 12 20 20 13 19 16 18 7 15 18 6 18 19 21", "20\n4 4 3 4 4 4 4 4 4 4 4 3 3 2 1 4 4 3 3 3", "30\n6 7 7 6 7 7 7 7 7 7 7 7 7 7 7 5 7 7 7 7 2 1 5 3 7 3 2 7 5 1", "65\n7 8 6 9 10 9 10 10 9 10 10 10 10 10 10 9 9 10 9 10 10 6 9 7 7 6 8 10 10 8 4 5 2 3 5 3 6 5 2 4 10 4 2 8 10 1 1 4 5 3 8 5 6 7 6 1 10 5 2 8 4 9 1 2 7", "85\n7 9 8 9 5 6 9 8 10 10 9 10 10 10 10 7 7 4 8 7 7 7 9 10 10 9 10 9 10 10 10 8 8 10 10 10 10 10 10 10 10 10 10 10 10 10 10 9 7 10 4 2 9 3 3 6 2 6 5 6 4 1 7 3 7 7 5 8 4 5 4 1 10 2 9 3 1 4 2 9 9 3 5 6 8", "10\n4 4 4 4 4 4 4 4 2 2", "20\n5 4 5 5 5 6 5 6 4 5 6 4 5 4 2 4 6 4 4 5", "30\n7 8 6 4 2 8 8 7 7 10 4 6 4 7 4 4 7 6 7 9 7 3 5 5 10 4 5 8 5 8", "50\n4 7 9 7 7 5 5 5 8 9 9 7 9 7 7 6 5 6 4 9 6 5 6 6 5 7 7 6 6 6 5 8 2 7 8 7 6 5 7 9 8 7 5 6 6 8 6 6 7 7", "100\n8 12 6 10 6 11 5 11 11 7 5 6 7 9 11 9 4 11 7 8 12 7 7 7 10 9 6 6 5 7 6 7 10 7 8 7 7 8 9 8 5 10 7 7 6 6 7 8 12 11 5 7 12 10 7 7 10 7 11 11 5 7 6 10 8 6 8 11 8 7 5 7 7 5 6 8 7 7 10 6 5 9 5 5 11 8 7 6 7 8 8 7 7 7 6 6 6 5 8 7", "20\n2 3 4 4 2 4 4 2 4 4 3 4 4 3 1 3 3 3 2 1", "30\n6 6 6 5 6 7 3 4 6 5 2 4 6 4 5 4 6 5 4 4 6 6 2 1 4 4 6 1 6 7", "65\n9 7 8 6 6 10 3 9 10 4 8 3 2 8 9 1 6 3 2 7 9 7 8 10 10 4 5 6 8 8 7 10 10 8 6 6 4 8 8 7 6 9 10 7 8 7 3 3 10 8 9 10 1 9 6 9 2 7 9 10 8 10 3 7 3", "85\n9 10 4 5 10 4 10 4 5 7 4 8 10 10 9 6 10 10 7 1 10 8 4 4 7 6 3 9 4 4 9 6 3 3 8 9 8 8 10 6 10 10 4 9 6 9 4 3 4 5 8 6 1 5 9 9 9 7 10 10 7 10 4 4 8 2 1 8 10 10 7 1 3 10 7 10 4 5 10 1 10 8 6 2 10", "200\n11 23 6 1 15 6 5 9 8 9 13 11 7 21 14 17 8 8 12 6 18 4 9 20 3 9 6 9 9 12 18 5 22 5 16 20 11 6 22 10 5 6 8 19 9 12 14 2 10 6 7 7 18 17 4 16 9 13 3 10 15 8 8 9 13 7 8 18 12 12 13 14 9 8 5 5 22 19 23 15 11 7 23 7 5 3 9 3 15 9 22 9 2 11 21 8 12 7 6 8 10 6 12 9 11 8 7 6 5 7 8 9 10 7 19 12 14 9 6 7 2 7 8 4 12 21 14 4 11 12 9 13 17 4 10 8 17 3 9 5 11 6 4 11 1 13 10 10 8 10 14 23 17 8 20 23 23 23 14 7 18 5 10 21 9 7 7 7 4 23 13 8 9 22 7 4 8 12 8 19 17 11 10 8 8 7 7 13 6 13 14 14 22 2 10 11 5 1 14 13", "1\n1", "2\n1 1", "2\n1000 1", "3\n1 1 2", "3\n1 2 1000"], "outputs": ["YES\n0\n10\n110", "NO", "YES\n0000\n0001\n0010\n0011\n0100\n0101\n0110\n0111\n1000\n1001", "YES\n000000\n0000110\n0000111\n0001000\n0001001\n000001\n0001010\n0001011\n0001100\n0001101\n0001110\n0001111\n0010000\n0010001\n0010010\n0010011\n0010100\n0010101\n000010\n0010110", "YES\n001101010\n0011011000\n00110100\n0011011001\n0011011010\n0011011011\n0011011100\n0011011101\n0011000\n0011001\n0011011110\n0011011111\n0011100000\n0011100001\n0011100010\n0011100011\n0011100100\n0011100101\n0011100110\n0011100111\n001101011\n0011101000\n0011101001\n0011101010\n0011101011\n0011101100\n0011101101\n0011101110\n0010\n000", "YES\n0001110010\n0001110011\n0001110100\n0001110101\n0001110110\n0001110111\n000101100\n000101101\n0001111000\n0001111001\n000101110\n0001111010\n0001111011\n0001111100\n0001111101\n000101111\n00010010\n0000110\n00010011\n0001111110\n0001111111\n0010000000\n0000111\n000110000\n0010000001\n0010000010\n000110001\n000110010\n000110011\n0010000011\n0010000100\n0010000101\n000110100\n0010000110\n0010000111\n0010001000\n0010001001\n0010001010\n000110101\n0010001011\n0010001100\n0001000\n00010100\n000110110\n0001...", "YES\n00001011110101100\n000010111101101110\n0000101111011111100110\n000010111100010\n00001011101100\n000010111101101111\n000010000\n000010111101111101010\n00001011101101\n0000101111011101110\n00001011101110\n00001011110111101110\n000010110100\n000010111100011\n000010001\n00001011110111111011100\n0000101111011101111\n00001011110111101111\n0000101111011110000\n0000101111011111100111\n0000101110010\n0000101111011111101000\n00001011110101101\n00001011000\n000010111101111101011\n0000101111011111101001\n00000110...", "NO", "NO", "NO", "NO", "YES\n1000\n1001\n1010\n1011\n1100\n1101\n1110\n1111\n00\n01", "YES\n10110\n0100\n10111\n11000\n11001\n111100\n11010\n111101\n0101\n11011\n111110\n0110\n11100\n0111\n00\n1000\n111111\n1001\n1010\n11101", "YES\n1110110\n11111010\n111000\n0110\n00\n11111011\n11111100\n1110111\n1111000\n1111111110\n0111\n111001\n1000\n1111001\n1001\n1010\n1111010\n111010\n1111011\n111111110\n1111100\n010\n11000\n11001\n1111111111\n1011\n11010\n11111101\n11011\n11111110", "YES\n0100\n1101110\n111111010\n1101111\n1110000\n01100\n01101\n01110\n11111000\n111111011\n111111100\n1110001\n111111101\n1110010\n1110011\n101010\n01111\n101011\n0101\n111111110\n101100\n10000\n101101\n101110\n10001\n1110100\n1110101\n101111\n110000\n110001\n10010\n11111001\n00\n1110110\n11111010\n1110111\n110010\n10011\n1111000\n111111111\n11111011\n1111001\n10100\n110011\n110100\n11111100\n110101\n110110\n1111010\n1111011", "YES\n11101100\n111111111100\n011100\n1111110010\n011101\n11111110100\n00010\n11111110101\n11111110110\n1011000\n00011\n011110\n1011001\n111110100\n11111110111\n111110101\n0000\n11111111000\n1011010\n11101101\n111111111101\n1011011\n1011100\n1011101\n1111110011\n111110110\n011111\n100000\n00100\n1011110\n100001\n1011111\n1111110100\n1100000\n11101110\n1100001\n1100010\n11101111\n111110111\n11110000\n00101\n1111110101\n1100011\n1100100\n100010\n100011\n1100101\n11110001\n111111111110\n11111111001\n00110\n110...", "NO", "NO", "NO", "NO", "NO", "YES\n0", "YES\n0\n1", "YES\n10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...", "NO", "YES\n0\n10\n1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000..."]}
UNKNOWN
PYTHON3
CODEFORCES
14
e32e231b443af9f76b845068a3b5735c
Dividing Orange
One day Ms Swan bought an orange in a shop. The orange consisted of *n*·*k* segments, numbered with integers from 1 to *n*·*k*. There were *k* children waiting for Ms Swan at home. The children have recently learned about the orange and they decided to divide it between them. For that each child took a piece of paper and wrote the number of the segment that he would like to get: the *i*-th (1<=≤<=*i*<=≤<=*k*) child wrote the number *a**i* (1<=≤<=*a**i*<=≤<=*n*·*k*). All numbers *a**i* accidentally turned out to be different. Now the children wonder, how to divide the orange so as to meet these conditions: - each child gets exactly *n* orange segments; - the *i*-th child gets the segment with number *a**i* for sure; - no segment goes to two children simultaneously. Help the children, divide the orange and fulfill the requirements, described above. The first line contains two integers *n*, *k* (1<=≤<=*n*,<=*k*<=≤<=30). The second line contains *k* space-separated integers *a*1,<=*a*2,<=...,<=*a**k* (1<=≤<=*a**i*<=≤<=*n*·*k*), where *a**i* is the number of the orange segment that the *i*-th child would like to get. It is guaranteed that all numbers *a**i* are distinct. Print exactly *n*·*k* distinct integers. The first *n* integers represent the indexes of the segments the first child will get, the second *n* integers represent the indexes of the segments the second child will get, and so on. Separate the printed numbers with whitespaces. You can print a child's segment indexes in any order. It is guaranteed that the answer always exists. If there are multiple correct answers, print any of them. Sample Input 2 2 4 1 3 1 2 Sample Output 2 4 1 3 3 2 1
[ "l=[int(l) for l in input().split()]\r\np=[int(n) for n in input().split()]\r\nnum=0\r\nif (l[0]==1):\r\n for index in p:\r\n print(index) \r\nelse: \r\n for index in range(l[1]):\r\n word=str(p[index])\r\n for x in range(1,l[0]):\r\n num+=1 \r\n if (num not in p):\r\n word=word+\" \"+str(num)\r\n else:\r\n while (num in p):\r\n num+=1\r\n word=word+\" \"+str(num) \r\n print(word)\r\n ", "n, k = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\nans = [[x] for x in a]\nptr = 0\nfor i in range(n * k):\n\ti += 1\n\tif i in a:\n\t\tcontinue\n\tans[ptr].append(i)\n\tptr += 1\n\tif ptr >= k:\n\t\tptr = 0\nprint('\\n'.join(' '.join(str(x) for x in l) for l in ans))\n", "N,K = map(int,input().split())\r\nArr = list(map(int,input().split()))\r\nDict = {}\r\nfor i in range(1,N*K + 1):\r\n Dict[i] = 1\r\nfor i in range(K):\r\n Dict[Arr[i]] = 0\r\n\r\nfor i in range(K):\r\n Num = N - 1\r\n print(Arr[i],end = ' ')\r\n for key in Dict.keys():\r\n if Dict[key] == 1:\r\n print(key,end = ' ')\r\n Dict[key] = 0\r\n Num = Num - 1\r\n if Num == 0:\r\n print()\r\n break", "n, k = map(int, input().split())\r\n\r\ndaf = list(map(int, input().split()))\r\n\r\ndaf2 = set()\r\n\r\nfor i in range(1, n*k + 1, 1):\r\n if i not in daf:\r\n daf2.add(i)\r\n\r\nfor i in range(k):\r\n has = [daf[i]]\r\n for j in range(n-1):\r\n has.append(daf2.pop())\r\n print(*has)\r\n", "n,k = input().split()\r\nn=int(n)\r\nk=int(k)\r\narr=[]\r\nfor i in range(1,n*k+1):\r\n\tarr.append(i)\r\nl = list(map(int,input().split()))\r\nx=0\r\nfor i in range(0,k):\r\n\tarr.remove(l[i])\r\nfor i in range(0,k):\r\n\tprint(l[i], end=\" \")\r\n\tfor j in range(0,n-1):\r\n\t\tprint(arr[x], end=\" \")\r\n\t\tx=x+1\r\n\tprint()", "def inp():\r\n return map(int, input().split())\r\n\r\n\r\ndef arr_inp():\r\n return [int(x) for x in input().split()]\r\n\r\n\r\ndef print_arr(arr):\r\n print(*arr, sep=' ')\r\n\r\n\r\nn, k = inp()\r\na = arr_inp()\r\nextra, len, old,c = [], 0, 0, 0\r\n\r\nfor i in range(1, n * k + 1):\r\n if (i not in a):\r\n extra.append(i)\r\n len += 1\r\n\r\n if (len > 0 and len % (n - 1) == 0 and len > old):\r\n ix1, ix2 = c*(n-1), len\r\n print(a[c], end=' ')\r\n print_arr(extra[ix1:ix2])\r\n old = len\r\n c+=1\r\n\r\n if(n==1):\r\n print(a[i-1])\r\n\r\n", "n,k=map(int,input().split())\r\nl=list(map(int,input().split()))\r\na=[0]*((n*k)+1)\r\nfor i in range(k):\r\n\ta[l[i]]=i+1\r\n\r\nb=[[0]*n for i in range(k)]\r\nfor i in range(k):\r\n\tprint(l[i],end=\" \")\r\n\tj=1\r\n\ts=0\r\n\twhile(j<n*k+1):\r\n\t\tif s==n-1:\r\n\t\t\tbreak\r\n\t\t\r\n\t\tif a[j]==0:\r\n\t\t\tprint(j,end=\" \")\r\n\t\t\ta[j]=-1\r\n\t\t\ts+=1\r\n\t\tj+=1\r\n\tprint()\r\n\r\n\r\n\r\n\r\n\r\n", "n,k = map(int,input().split())\r\nls = list(map(int,input().split()))\r\nps = [q for q in range(1,n*k+1) if q not in ls]\r\nps = iter(ps)\r\nfor i in range(k):\r\n print(ls[i],end=' ')\r\n for q in range(n-1):\r\n print(next(ps),end=' ')\r\n print()", "n,k=map(int,input().split())\r\n\r\nL=list(map(int,input().split()))\r\nS=[]\r\nfor i in range(k):\r\n S.append([])\r\nind=0\r\nfor i in range(1,n*k+1):\r\n if(i in L):\r\n x=L.index(i)\r\n S[x].append(i)\r\n else:\r\n S[ind].append(i)\r\n ind+=1\r\n if(ind==k):\r\n ind=0\r\nfor i in range(k):\r\n for j in range(n):\r\n print(S[i][j],end=\" \")\r\n print()\r\n", "n , k = map(int,input().split())\r\nl = [int(i) for i in input().split()]\r\nl2 = [[i] for i in l]\r\np = 0\r\n#print(l2)\r\n\r\nfor i in range(n*k):\r\n if i+1 in l :\r\n continue\r\n\r\n l2[p].append(i+1)\r\n p+=1\r\n if p >= k : p = 0\r\n\r\nfor i in l2 :\r\n print(*i)", "# https://codeforces.com/problemset/problem/244/A\n# 900\n\nn, k = map(int, input().split())\n\nd = {}\nl = []\nfor s in input().split():\n s = int(s)\n d[s] = True\n l.append(s)\n\nfor s in l:\n print(s, end=\"\")\n c = 1\n for i in range(1, (n*k)+1):\n if d.get(i) is None:\n print(\"\", i, end=\"\")\n d[i] = True\n c += 1\n\n if c == n:\n break\n \n print()", "n,k = map(int,input().split())\r\nl=list(map(int,input().split()))\r\ni=1\r\nfor j in range(k):\r\n m=[l[j]]\r\n while len(m)!=n:\r\n if i in l:\r\n i+=1\r\n else:\r\n m.append(i)\r\n i+=1\r\n print(' '.join(str(m[z]) for z in range(n)))", "n, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\n\r\nb = []\r\nfor i in range(1, n * k + 1):\r\n\tb.append(i)\r\n\r\nfor i in a:\r\n\tb[i - 1] = 0\r\n\r\nt = 0\r\nfor i in range(k):\r\n\tprint(a[i], end=\" \")\r\n\tp = n - 1\r\n\twhile p > 0:\r\n\t\tif b[t] > 0:\r\n\t\t\tprint(b[t], end=\" \")\r\n\t\t\tp -= 1\r\n\t\tt += 1\r\n\tprint()", "\"\"\"\r\n Author : Ashish Sasmal\r\n Python3 / PyPy3\r\n\"\"\"\r\n\r\nfrom sys import stdin as sin\r\ndef aint():return int(input())\r\ndef amap():return map(int,sin.readline().split())\r\ndef alist():return list(map(int,sin.readline().split()))\r\ndef astr():return input()\r\n\r\n\r\nn,k = amap()\r\na = alist()\r\nans = []\r\nfor i in a:\r\n ans.append([i])\r\n\r\nfor i in range(k):\r\n c = 0\r\n if c<n-1:\r\n for j in range(1,n*k+1):\r\n if j not in a:\r\n ans[i].append(j)\r\n a.append(j)\r\n c+=1\r\n if c==n-1:\r\n break\r\nfor i in ans:\r\n print(*i)", "n,k=map(int,input().split())\n\nL=list(map(int,input().split()))\nExplored=[False]*(n*k+1)\nAns=[]\n\nfor i in range(k):\n Ans.append([])\n\nfor i in range(k):\n Ans[i].append(L[i])\n Explored[L[i]]=True\nind=0\nfor i in range(1,n*k+1):\n if(Explored[i]):\n continue\n Ans[ind].append(i)\n ind+=1\n if(ind>=k):\n ind=0\nfor i in range(k):\n print(Ans[i][0],end=\"\")\n for j in range(1,n):\n print(\" \"+str(Ans[i][j]),end=\"\")\n print()\n", "n,k=map(int,input().split())\r\narr=list(map(int,input().split()))\r\nvar=1\r\nfor i in range(k):\r\n cnt=1\r\n print(arr[i],end=' ')\r\n while cnt!=n:\r\n if var not in arr:\r\n print(var,end=' ')\r\n cnt=cnt+1\r\n var=var+1\r\n print('\\n',end='')\r\n\r\n", "ar = []\r\nfor i in input().split():\r\n ar.append(int(i))\r\nar2 = []\r\nfor i in input().split():\r\n ar2.append(int(i))\r\ntemp = list(set(range(1, ar[0]*ar[1]+1))-set(ar2))\r\nfor i in range(len(ar2)):\r\n res = []\r\n res.append(ar2[i])\r\n while (len(res) != ar[0]):\r\n res.append(temp[0])\r\n temp.pop(0)\r\n print(*res)\r\n", "n, k = map(int, input().strip().split())\na = list(map(int, input().strip().split()))\nchildren = {}\n\nfor index, number in enumerate(a):\n children[index + 1] = [number]\n\nnext_child = 1\n\nfor i in range(1, (n * k) + 1):\n if i not in a:\n if len(children[next_child]) == n:\n next_child += 1\n children[next_child].append(i)\n\nfor child in range(1, k + 1):\n print(* children[child])\n", "n,k=list(map(int,input().split()))\r\na=list(map(int,input().split()))\r\nl=[]\r\nfor i in range(1,n*k+1):\r\n l.append(i)\r\nm=list(set(l)-set(a))\r\nfor i in range(k):\r\n for j in range(n-1):\r\n print(m[0],end=\" \")\r\n m.remove(m[0])\r\n\r\n print(a[i])\r\n \r\n\r\n", "c = 1\n\n\ndef main():\n n, k = map(int, input().split())\n l = list(range(1, n * k + 1))\n aa = list(map(int, input().split()))\n for a in aa:\n l[a - 1] = 0\n res, it = [], iter(filter(None, l))\n n -= 1\n for a in aa:\n res.append(a)\n for _ in range(n):\n res.append(next(it))\n print(' '.join(map(str, res)))\n res.clear()\n\n\nif __name__ == '__main__':\n main()", "n, k = map(int, input().split())\r\narr = list(map(int, input().split()))\r\ntrack, ans, oranges = [], [], list(range(1, k * n + 1))\r\nfor i in range(len(arr)):\r\n ls = [arr[i]]\r\n c = 1\r\n track.append(arr[i])\r\n for e in range(len(oranges)):\r\n if oranges[e] not in track and oranges[e] not in arr:\r\n ls.append(oranges[e])\r\n track.append(oranges[e])\r\n c += 1\r\n if c == n:\r\n ans.append(ls)\r\n break\r\nfor i in ans:\r\n print(*i)", "n,k = map(int, input().split())\r\na = list(map(int, input().split()))\r\nb = 1\r\nfor i in range(k):\r\n print(a[i],end=\" \")\r\n c = 0\r\n while c < (n-1):\r\n if b not in a:\r\n print(b,end=\" \")\r\n c += 1\r\n b += 1\r\n else:\r\n b += 1\r\n print()\r\n", "n,k = map(int, input().split())\r\nb = list(map(int, input().split()))\r\na = [-1 for i in range(n*k+1)] # a[i] is the id of the child receiving the i-th piece\r\n\r\nfor i in range(k):\r\n a[b[i]] = i # b[i] is the index of piece that i-th child wants\r\n\r\nt = 1\r\nfor i in range(k): # loop for each child i\r\n print(b[i], end=\" \")\r\n for j in range(n-1):\r\n # trying to assign the t-th piece to child i\r\n while a[t] != -1:\r\n t+=1\r\n a[t] = i\r\n print(t, end=\" \")\r\n print()\r\n", "from collections import deque\r\n\r\ndef main():\r\n n, k = list(map(int, input().split()))\r\n a = list(map(int, input().split()))\r\n q = deque()\r\n for i in range(n*k):\r\n if i + 1 not in a:\r\n q.append(i+1)\r\n\r\n d = {i:[] for i in range(k)}\r\n for i in range(k):\r\n d[i].append(a[i])\r\n\r\n while q:\r\n for i in range(k):\r\n for j in range(n - 1):\r\n elem = q.popleft()\r\n d[i].append(elem)\r\n\r\n for i in range(k):\r\n print(*d[i])\r\n\r\nif __name__ == \"__main__\":\r\n main()", "n, k = map(int,input().split())\r\nai = list(map(int,input().split()))\r\nfree = list(set([i for i in range(1,n*k+1)]) - set(ai))\r\nn2 = n - 1\r\nfor i in range(k):\r\n print(ai[i],end=\" \")\r\n print(\" \".join(list(map(str,free[n2*i:n2*(i+1)]))))\r\n", "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\ndivided_oranges = []\nfor i in range(k):\n divided_oranges.append([a[i]])\n\nremaining = [segment for segment in range(1, n * k + 1) if segment not in a]\nfor i in range(len(remaining)):\n divided_oranges[i % k].append(remaining[i])\n\nfor child_orange in divided_oranges:\n print(\" \".join(str(orange) for orange in child_orange))\n", "n, k = map(int,input().split())\r\na = list(map(int,input().split()))\r\ni = 1\r\nfor j in range(k):\r\n r=[a[j]]\r\n while len(r)!=n:\r\n if i in a:\r\n i+=1\r\n else:\r\n r.append(i)\r\n i+=1\r\n print(' '.join(str(r[z]) for z in range(n)))", "\r\nn, k = map(int, input().split())\r\nl = list(map(int, input().split()))\r\n\r\nans = [[i] for i in l]\r\n\r\ni = 1\r\ntarget = 0\r\nwhile i < n * k + 1:\r\n\tif i in l:\r\n\t\ti += 1\r\n\telse:\r\n\t\tif len(ans[target]) < n:\r\n\t\t\tans[target].append(i)\r\n\t\t\ti += 1\r\n\t\telse:\r\n\t\t\ttarget += 1\r\n\r\nfor i in ans:\r\n\tprint(*i)\r\n\r\n", "n, k = [int(i) for i in input().split()]\ns = set(range(1,n*k+1))\na = [set([int(i)]) for i in input().split()]\nfor aa in a:\n s -= aa\nfor i in range(k):\n for j in range(n-len(a[i])):\n a[i].add(s.pop())\n print(' '.join([str(j) for j in list(a[i])]))\n", "n, k = list(map(int, input(\"\").split(\" \")))\r\nin_data = list(map(int, input(\"\").split(\" \")))\r\nelse_data = []\r\n\r\nfor i in range(n*k):\r\n if i+1 not in in_data:\r\n else_data.append(i+1)\r\n\r\ndata = []\r\n\r\nfor i in range(k):\r\n arr = []\r\n arr.append(in_data[i])\r\n for j in range(n-1):\r\n arr.append(else_data[len(else_data)-1])\r\n else_data.pop()\r\n data.append(arr)\r\n\r\n\r\nfor row in data:\r\n print(\" \".join(str(x) for x in row))", "#CF Round 150. Div II Prob. A - Dividing Orange\r\nimport sys\r\n\r\nIn = sys.stdin\r\nn, k = [int(x) for x in In.readline().split()]\r\narr, s, cnt = [int(x) for x in In.readline().split()], set(), 1;\r\ns.update(arr)\r\nfor i in range(k):\r\n c = [arr[i]]\r\n for j in range(n - 1):\r\n while (cnt in s):\r\n cnt += 1;\r\n c.append(cnt)\r\n cnt += 1;\r\n sep = ' '\r\n print (sep.join(map(str, c)))", "a=[int(x) for x in input().split()]\r\nn=a[0]\r\nk=a[1]\r\nlst=[]\r\ndic={}\r\nc=0\r\nfor i in range(1,(n*k)+1):\r\n lst.append(i)\r\nb=[int(x) for x in input().split()]\r\nfor i in range(len(b)):\r\n dic[i]=[b[i]]\r\n lst.remove(b[i])\r\ndivide=len(lst)//k #2 \r\nfor i in range(k):\r\n for j in range(divide): #0\r\n dic[i].append(lst[c]) #dic[0]=[2,1]\r\n lst.remove(lst[c]) #lst=[3]\r\nfor key in dic.values():\r\n for i in range(len(key)):\r\n if i==len(key)-1:\r\n print(key[i])\r\n else:\r\n print(key[i],end=' ')", "n, k = map(int, input().split())\r\n\r\na = list(map(int, input().split()))\r\ns = set([x for x in range(1, n*k+1)])\r\nfor i in a:\r\n s.remove(i)\r\n\r\nfor i in range(k):\r\n c = []\r\n c.append(str(a[i]))\r\n for _ in range(1, n):\r\n c.append(str(s.pop()))\r\n print(' '.join(c))\r\n", "n, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\nd = {}\r\nfor x in range(k):\r\n d[x] = str(a[x])\r\nu = [i for i in range(1, n*k+1) if str(i) not in d.values()]\r\nfor x in range(n*k-k):\r\n d[x%k] += \" {}\".format(u[x])\r\nfor m in d:\r\n print(d[m])", "params = [int(item) for item in input().split()]\r\nn = params[0]\r\nk = params[1]\r\n\r\nwants = [int(item) for item in input().split()]\r\n\r\ntemp = set(wants)\r\ntotal = set(range(1, n*k + 1))\r\n\r\nleft = list(total - temp)\r\ndivide_left = len(left)/k\r\n\r\nfor i in wants:\r\n count = 0\r\n print(i, end=\" \")\r\n while count < divide_left:\r\n print(left[0], end=\" \")\r\n left.pop(0)\r\n count=count+1\r\n\r\n", "n,k=map(int,input().split())\r\nlis_1=list(map(int,input().split()))\r\nlis_2=[]\r\nc=n*k\r\nfor i in range(0,c):\r\n lis_2.append(1)\r\nfor i in range(0,k):\r\n lis_2[lis_1[i]-1]=2\r\nfor i in range(0,k):\r\n lis_3=[]\r\n cunt=1\r\n lis_3.append(lis_1[i])\r\n for j in range(0,c):\r\n if(cunt<n):\r\n if(lis_2[j]==1):\r\n lis_2[j]=0\r\n lis_3.append(j+1)\r\n cunt+=1\r\n print(*lis_3)", "n,k=map(int,input().split())\r\na=list(range(1,n*k+1))\r\nora=[[] for _ in ' '*k]\r\nfor i, j in enumerate(map(int,input().split()),0):\r\n ora[i].append(j)\r\n a.remove(j)\r\nfor i in ora:\r\n while len(i)<n:\r\n i.append(a.pop())\r\nfor i in ora:\r\n print(*i)", "n, k = list(map(int, input().split()))\nl = list(range(1, n*k + 1))\nd = {}\na = list(map(int, input().split()))\nfor i in range(len(a)):\n d[i] = [a[i]]\n l.remove(a[i])\nfor i in range((n-1)*(k)):\n d[i%k] = d[i%k] + [l[i]]\nfor k, v in d.items():\n for i in v:\n print(i, end=' ')\n", "I=lambda:map(int,input().split())\r\nn,k=I()\r\nb=*I(),\r\nexec('r=['+k*'[],'+']')\r\nfor i,x in enumerate(b):r[i]+=[x]\r\ni=0\r\nfor j in range(1,n*k+1):\r\n if j in b: continue\r\n while len(r[i])==n:i+=1\r\n r[i]+=[j]\r\nfor i in range(k):print(*r[i])", "n,k=map(int,input().split())\r\nb=[0]*(n*k)\r\nc=[]\r\ncount=0\r\na=list(map(int,input().split()))\r\nfor i in range(1,n*k + 1):\r\n if i not in a:\r\n c.append(i)\r\nfor i in range(k):\r\n b[n*i]=a[i]\r\nfor i in range(n*k):\r\n if b[i]==0:\r\n b[i]=c[count]\r\n count+=1\r\nfor i in range(n*k):\r\n if (i+1)%n==0:\r\n print(b[i])\r\n else:\r\n print(b[i],end=' ')\r\n \r\n ", "n, k = [int(i) for i in input().split()]\ndata = [int(i) for i in input().split()]\nbox = [0 for i in range(n * k)]\na, b = 0, n * k\nfor i in range(k):\n box[data[i] - 1] = 1\n print(data[i], end = ' ')\n c = 1\n for j in range(a, b):\n if box[j] == 0 and c < n and (not j + 1 in data):\n print(j + 1, end = ' ')\n box[j] = 1\n c += 1\n elif c == n:\n a = j\n break\n print()\n \n \n ", "I = lambda: map(int, input().split())\r\n\r\nn, k = I()\r\nA = list(I())\r\nX = set(range(1, n*k+1)) - set(A)\r\n\r\nfor i in range(k):\r\n print(A[i], *(X.pop() for _ in range(n-1)))", "import sys\r\nimport math\r\n\r\n#to read string\r\nget_string = lambda: sys.stdin.readline().strip()\r\n#to read list of integers\r\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\r\n#to read integers\r\nget_int = lambda: int(sys.stdin.readline())\r\n#to print fast\r\n#pt = lambda x: sys.stdout.write(str(x)+'\\n')\r\n\r\n#--------------------------------WhiteHat010--------------------------------------#\r\nn,k = get_int_list()\r\nlst = get_int_list()\r\nnk = list(range(1,n*k+1))\r\n\r\nfor i in range(k):\r\n nk.remove(lst[i])\r\n\r\nmatrix = [ [lst[i]] for i in range(k)]\r\nfor i in range(k):\r\n start = i*(n-1)\r\n end = (i+1)*(n-1)\r\n matrix[i].extend(nk[start:end])\r\nfor i in range(k):\r\n print(*matrix[i])", "[n, k] = [int(x) for x in input().split()]\r\na = [int(x) for x in input().split()]\r\narr = list(range(1,n*k+1))\r\nfor i in a:\r\n arr[i-1]=0\r\nj = 0\r\nfor i in a:\r\n print(i,end=' ')\r\n count = 1\r\n while(count<n):\r\n if(arr[j]!=0):\r\n print(arr[j],end=' ')\r\n count=count+1\r\n j=j+1\r\n print('')\r\n", "'''''''''''\r\n Auhtor : code_marshal\r\n Method : jisko jo chaiye de do\r\n'''''''''''\r\n\r\nn, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\ntotal = [i+1 for i in range(n * k)]\r\nanswers = [()] * k\r\nfor i in range(k): answers[i] += (a[i],); total.remove(a[i])\r\nsikandar, count, lolo, j = len(total) / k, 0, tuple(), 0\r\nfor i in total:\r\n lolo += (i,)\r\n count += 1\r\n if count == sikandar: answers[j] += lolo; j += 1; lolo = tuple(); count = 0\r\nfor i in answers: print(*list(i), end = \"\\n\")\r\n", "n,k=map(int,input().split())\r\n\r\nL=list(map(int,input().split()))\r\n\r\nTaken=[False]*(n*k+1)\r\n\r\nfor item in L:\r\n Taken[item]=True\r\nind=1\r\nfor i in range(k):\r\n cnt=1\r\n print(L[i],end=\" \")\r\n \r\n while(cnt<n):\r\n while(Taken[ind]):\r\n ind+=1\r\n \r\n print(ind,end=\" \")\r\n ind+=1\r\n cnt+=1\r\n print()\r\n", "n, k = map(int, input().split())\r\nmoo = list(map(int, input().split()))\r\npor = set()\r\nfor i in range(n*k):\r\n por.add(i+1)\r\nblu = []\r\nfor i in range(k):\r\n tig = [moo[i]]\r\n x = moo[i]\r\n por.remove(x)\r\n blu.append(tig)\r\nfor i in range(k):\r\n for j in range(n-1):\r\n blu[i].append(por.pop())\r\nfor i in range(k):\r\n for j in range(n):\r\n print(blu[i][j], end=\" \")\r\n print(\"\")", "# http://codeforces.com/contest/244/problem/A\n\nnumber_per_child, number_of_children = input().strip().split()\nnumber_per_child = int(number_per_child)\nnumber_of_children = int(number_of_children)\n\nnumber_of_segs = number_of_children * number_per_child\npriority = input().strip().split()\n\nprefarence = {}\nfor i in range(0,len(priority)):\n priority[i] = int(priority[i])\n prefarence[priority[i]] = i\n# print(prefarence) \n\n\ndistribution = {}\nfor i in range(0,number_of_children):\n distribution[i] = []\n\ntemp = 1\nfor x in distribution:\n count = 0\n while(count < number_per_child - 1):\n if(not (temp in prefarence)):\n distribution[x].append(temp)\n temp = temp + 1\n count = count + 1\n else:\n temp = temp + 1\n\n\nfor x in prefarence:\n distribution[prefarence[x]].append(x)\n# print(prefarence)\n# print(distribution)\n\nans = \"\"\nfor x in distribution:\n for y in distribution[x]:\n ans = ans + str(y) + \" \"\n if (x != number_of_children - 1):\n ans = ans + \"\\n\"\n\n\nprint(ans)\n", "n,k=list(map(int,input().split()));p=[]\r\na=list(map(int,input().split()))\r\nfor i in range(1,n*k+1):\r\n if i not in a:\r\n p.append(i)\r\nfor i in range(k):\r\n print(a[i],*p[i*(n-1):(i+1)*(n-1)])\r\n\r\n", "I=lambda:list(map(int,input().split()))\r\nn,k=I()\r\na=I()\r\ns=list(range(1,n*k+1))\r\nfor i in a:s.remove(i)\r\nfor i in range(k):print(' '.join(map(str,[a[i]]+s[i::k])))", "[n, k] = [int(x) for x in input().split()]\r\na = [int(x) for x in input().split()]\r\narr = list(range(1,n*k+1))\r\nfor i in a:\r\n arr.remove(i)\r\nj = 0;\r\nfor i in a:\r\n print(i,*arr[j:j+n-1])\r\n j = j+n-1\r\n ", "import sys\r\nimport math\r\n \r\nn, k = [int(x) for x in (sys.stdin.readline()).split()]\r\nan = [int(x) for x in (sys.stdin.readline()).split()]\r\n\r\nk = [0] * (n * k) \r\nfor i in an:\r\n k[i - 1] = 1\r\n \r\nj = 0 \r\nfor i in an:\r\n v = []\r\n count = 0\r\n \r\n while(count != n - 1):\r\n if(k[j] != 1):\r\n v.append(str(j + 1))\r\n count += 1\r\n j += 1\r\n v.append(str(i))\r\n print(\" \".join(v))", "n, k = map(int, input().split())\r\ns = [int(i) for i in input().split()]\r\na = [x for x in range(1, n * k + 1) if x not in s]\r\n\r\nfor i in range(k):\r\n print(s[i], *a[i * (n - 1):(i + 1) * (n - 1)])\r\n", "def con(n):\r\n p = []\r\n for s in n:\r\n s = str(s)\r\n p.append(s)\r\n return \" \".join(p)\r\n\r\n\r\nn, k = input().split()\r\nn = int(n)\r\nk = int(k)\r\na = list(map(int, input().split()))\r\ni = 0\r\nl = []\r\nfor s in range(n*k+1):\r\n if s not in a and s != 0:\r\n l.append(s)\r\n\r\nwhile i < k:\r\n z = []\r\n j = 0\r\n while len(z) < n - 1:\r\n z.append(l[j])\r\n l.pop(j)\r\n z.append(a[i])\r\n print(con(z))\r\n i += 1\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\nb = [[] for i in range(k)]\r\nfor i in range(k):\r\n b[i].append(a[i])\r\nc = set(range(1, n * k + 1))\r\nfor i in a:\r\n c.discard(i)\r\nc = list(c)\r\nfor i in range(k):\r\n for j in range(n - 1):\r\n b[i].append(c.pop())\r\nfor i in b:\r\n print(*i)\r\n", "n, k = map(int, input().split())\nres = [[] for _ in range(k)]\nused = set()\nfor i, val in enumerate(input().split()):\n val = int(val)\n used.add(val)\n res[i].append(val)\ni = 0\nfor val in range(1, n*k+1):\n if val in used:\n continue\n while len(res[i]) == n:\n i += 1\n res[i].append(val)\nfor i in res:\n print(*i)", "n,k = map(int, input().split())\r\narr = list(map(int, input().split()))\r\noranges = list(range(1, n*k + 1))\r\nchild = {i:[] for i in range(1, k+1)}\r\nfor i in range(k):\r\n\tchild[i+1].append(arr[i])\r\nremain = list(set(oranges) - set(arr))\r\nptr = 0\r\nfor i in range(k):\r\n\tchild[i+1].extend(remain[ptr:ptr+n-1])\r\n\tptr += n-1\r\n\tprint(*child[i+1])\r\n\r\n", "n, k = (int(i) for i in input().split())\na = [int(i) for i in input().split()]\no = [i for i in range(1, k * n + 1) if i not in set(a)]\nfor i in range(k):\n print(a[i], *o[i * (n - 1) : (i + 1) * (n - 1)])\n", "n, k = [int(c) for c in input().split()]\r\nsegments = [int(c) for c in input().split()]\r\nsegments_set = set(segments)\r\npool = [i for i in range(1, k*n+1) if i not in segments_set]\r\n\r\nfor s in segments:\r\n res = [s] + [pool.pop() for _ in range(n-1)]\r\n print(*res)\r\n", "n, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\norange = [x for x in range(1, n*k +1)]\r\nseg = []\r\nfor i in range(k):\r\n seg.append([a[i]])\r\n orange.remove(a[i])\r\nfor i in range(k):\r\n while len(seg[i]) < n:\r\n seg[i].append(orange.pop())\r\n print(*seg[i])", "n, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\n\r\nslices = [i for i in range(1, (n * k) + 1)]\r\n\r\nchildren = [[] for i in range(k)]\r\n\r\nfor i in range(k):\r\n seg = a[i]\r\n children[i].append(seg)\r\n slices.remove(seg)\r\n\r\nfor i, seg in enumerate(slices):\r\n children[i % k].append(seg)\r\n\r\nfor child in children:\r\n print (' '.join([str(s) for s in child]))", "#!/usr/bin/env python3\nfrom sys import stdin, stdout\n\n\ndef solve():\n n, k = map(int,stdin.readline().split())\n li = list(map(int,stdin.readline().split()))\n vis = [-1 for i in range(n*k)]\n for i in range(k):\n vis[li[i]-1] = i\n\n ans = [list() for i in range(k)]\n p = 0\n for i in range(n*k):\n if vis[i]<0:\n ans[p].append(i+1)\n p += 1\n p %= k\n else:\n ans[vis[i]].append(i+1)\n\n for l in ans:\n for e in l:\n print(e,end=' ')\n print()\n\n\nLOCAL_TEST = not __debug__\nif LOCAL_TEST:\n infile = __file__.split('.')[0] + '-test.in'\n stdin = open(infile, 'r')\n\ntcs = (int(stdin.readline().strip()) if LOCAL_TEST else 1)\nt = 1\nwhile t <= tcs:\n solve()\n t += 1", "n, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\ni = 1\r\nfor x in a:\r\n ans = [x]\r\n while len(ans) != n:\r\n while i in a:\r\n i += 1\r\n ans.append(i)\r\n i += 1\r\n print(*ans)", "n,k=map(int,input().split())\r\na=list(map(int,input().split()))\r\nb=[];c=list(range(1,(n*k)+1))\r\nfor i in range(k):\r\n b.append(a[i])\r\n c.remove(a[i])\r\nm=0\r\nfor i in range(k):\r\n print(b[i],end=' ')\r\n print(*c[m:m+n-1]);m+=(n-1)", "n , k = map(int , input().split()) \r\ndisaire = list(map(int , input().split())) \r\nrest = [i for i in range(1 , n*k + 1) if i not in disaire]\r\ncounter = 0 \r\nfor i in range(k): \r\n boy = \"\" \r\n l , x = 0 , 0\r\n while x < n -1 : \r\n if rest[l] != 0 : \r\n boy += str(rest[l]) +\" \" \r\n rest[l] = 0\r\n x+=1\r\n l+= 1 \r\n boy += str(disaire[counter]) + \" \"\r\n counter += 1 \r\n print(boy)\r\n", "a,b = map(int,input().split())\r\nls = list(map(int,input().split()))\r\nls2 = list(range(1,a*b+1))\r\nls4 = []\r\nls3 = []\r\n\r\nfor i in range(b):\r\n\r\n ls3.append(ls[i])\r\n l = a - 1\r\n j=0\r\n while(l>0):\r\n if ls2[j] not in ls4 and ls2[j] not in ls:\r\n ls3.append(ls2[j])\r\n ls4.append(ls2[j])\r\n l-=1\r\n j+=1\r\n\r\n\r\n print(*ls3)\r\n ls3=[]", "n,k = list(map(int, input().split(\" \")))\r\nx = list(map(int, input().split(\" \")))\r\nj=1\r\nfor i in range(k):\r\n print(x[i],end=\" \")\r\n k=0\r\n while k<n-1:\r\n if j not in x:\r\n print(j,end=\" \")\r\n k+=1\r\n j+=1\r\n print()\r\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nn, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\n\r\ncheck = [False] * (n * k + 1)\r\nfor i in range(k):\r\n check[a[i]] = True\r\n\r\nnow = 1\r\nfor i in range(k):\r\n print(a[i], end=' ')\r\n for j in range(n - 1):\r\n while check[now]:\r\n now += 1\r\n check[now] = True\r\n print(now, end=' ')\r\n\r\n now += 1\r\n print()\r\n", "n,k=map(int,input().split())\r\ncompulsory=list(map(int,input().split()))\r\n\r\nanswer=[[] for _ in range(1000)]\r\nmark=[False for _ in range(1000)]\r\n\r\n\r\nfor i in range(len(compulsory)):\r\n mark[compulsory[i]]=True\r\n answer[i].append(compulsory[i])\r\n\r\n#print(answer) \r\nk1=0\r\nj=0\r\nfor i in range(1,n*k+1):\r\n if mark[i]:\r\n continue\r\n answer[k1].append(i)\r\n j+=1\r\n if j%(n-1)==0:\r\n k1+=1\r\n\r\nfor i in range(k):\r\n for temp in answer[i]:\r\n print(temp,end=\" \")\r\n print()\r\n \r\n", "n, k = map(int, input().split())\r\narr = [int(i) for i in input().split()]\r\nres = [[i] for i in arr]\r\np = 0\r\nfor i in range(n * k):\r\n if i+1 in arr:\r\n continue\r\n res[p].append(i+1)\r\n p += 1\r\n if p >= k: p = 0\r\nfor i in res:\r\n print(*i)\r\n", "n, k = map(int, input().split())\narr = [int(x) for x in input().split()]\nstatus = [1 for x in range(n*k + 1)]\nfor x in arr:\n status[x] = 2\nj = int(1)\nfor i in range(k):\n print(arr[i], end = ' ')\n for _ in range(n - 1):\n while(status[j] == 2):\n j += 1\n print(j, end = ' ')\n j += 1\n\n print()\n", "n,k=map(int,input().split())\r\nl=n*k+1\r\nCount=[0]*(l)\r\nCount[0]=1\r\nA=[int(x) for x in input().split()]\r\nB=[]\r\nfor i in A:\r\n Count[i]=1\r\n B.append([i])\r\nindex=1\r\nfor i in range(k):\r\n cnt=0\r\n while cnt!=n-1:\r\n while(index<l and Count[index]==1):\r\n index+=1\r\n while(index<l and Count[index]==0 and cnt!=n-1):\r\n cnt+=1\r\n B[i].append(index)\r\n Count[index]=1\r\n index+=1\r\nfor i in B:\r\n for j in i:\r\n print(j,end=' ')\r\n print()\r\n ", "n,k=map(int,input().split())\na=[int(x) for x in input().split()]\nj=1\nfor i in range(k):\n # print(a[i],end=' ')\n l=[a[i]]\n while len(l)!=n:\n if j not in a:\n l.append(j)\n j+=1\n l.sort()\n print(*l)\n", "n,k=map(int,input().split())\r\nl=list(map(int,input().split()))\r\ns=1\r\nfor i in range(k) :\r\n p=n-1\r\n print(l[i],end=' ')\r\n while(p>0):\r\n if s not in l:\r\n print(s,end=' ')\r\n p=p-1\r\n s=s+1\r\n print()\r\n ", "n,k=map(int,input().split())\r\nans=[[] for _ in range(k)]\r\nvis=[0]*(n*k)\r\na=list(map(int,input().split()))\r\nfor i in range(k):\r\n ans[i].append(a[i])\r\n vis[a[i]-1]=1\r\nfor i in ans:\r\n for j in range(n*k):\r\n if vis[j]==0:\r\n vis[j]=1\r\n i.append(j+1)\r\n if len(i)==n:\r\n break\r\nfor i in ans:\r\n print(*i)\r\n\r\n", "\nI=lambda:list(map(int,input().split()))\nn,k=I()\na=I()\ns=list(range(1,n*k+1))\nfor i in a:s.remove(i)\nfor i in range(k):print(' '.join(map(str,[a[i]]+s[i::k])))\n\t\t \t \t \t\t\t\t\t\t\t \t \t \t\t\t \t", "n,k=[int(x) for x in input().split()]\r\nl=list(map(int,input().split()))\r\nm=n*k;\r\np=[]\r\nfor i in range(1,m+1):\r\n if i not in l:\r\n p.append(i)\r\nf=int(0) \r\nfor i in range(0,k):\r\n ans=[]\r\n ans.append(l[i])\r\n if(f<len(p)):\r\n for j in range(0,n-1):\r\n ans.append(p[f])\r\n f=f+1\r\n print(*ans,end=\"\\n\") \r\n", "n,m=map(int,input().split())\r\nl=list(map(int,input().split()))\r\nl1={i for i in range(1,n*m+1) }\r\nfor x in l:\r\n out=[]\r\n out.append(x)\r\n l1.remove(x)\r\n j=1\r\n ch=[]\r\n for x1 in l1 :\r\n if x1 not in l :\r\n if j!=n :\r\n j+=1\r\n out.append(x1)\r\n ch.append(x1)\r\n else :\r\n break\r\n for x1 in ch :\r\n l1.remove(x1)\r\n print(' '.join(map(str,out)))\r\n \r\n \r\n \r\n", "n,k=map(int,input().split())\r\na=list(map(int,input().split()))\r\nj=1\r\nl=1\r\nfor i in range(k):\r\n print(a[i],end=' ')\r\n while l!=(n):\r\n if j not in a:\r\n print(j,end=' ')\r\n l+=1\r\n j+=1\r\n l=1 \r\n print('\\n')", "n, k = [int(x) for x in input().split()]\r\n\r\narr = [int(x) for x in input().split()]\r\n\r\nsegms = [x for x in range(1, n*k + 1)]\r\n\r\ndiff = set(segms) - set(arr)\r\ndiff = list(diff)\r\nans = []\r\n#print(\"diff\", diff)\r\nfor i in range(k):\r\n ans.append([arr[i]] + diff[:n - 1])\r\n diff = diff[n - 1:]\r\n\r\nfor ele in ans:\r\n print(*ele)", "n,k=list(map(int, input().split()))\r\na=list(map(int, input().split()))\r\nb=1\r\nfor i in range(k):\r\n print(a[i],end=' ')\r\n c=0\r\n for j in range(b,n*k+1):\r\n if j not in a:\r\n print(j,end=' ')\r\n c += 1\r\n if c==n-1:\r\n print()\r\n b=j+1\r\n break\r\n print()", "n, k = list(map(int, input().split()))\narr = list(map(int, input().split()))\narr = [0] + arr\nbrr = [0] * (n * k + 1)\nfor i in range(1, k+1):\n brr[arr[i]] = i\nfor i in range(1, k+1):\n count = n - 1\n j = 1\n while count > 0:\n if brr[j] == 0:\n brr[j] = i\n count -= 1\n j += 1\ncrr = sorted([(brr[i], i) for i in range(1, n * k+1)])\nprint(*[crr[i][1] for i in range(n * k)])\n", "arr = input().split()\r\nn = int(arr[0])\r\nk = int(arr[1])\r\narr = input().split()\r\ns = set()\r\nfor ch in arr:\r\n\ts.add(int(ch))\r\nfor ch in arr:\r\n\tprint(ch, end = ' ')\r\n\tctr = 0\r\n\tptr = 1\r\n\twhile ctr < n - 1:\r\n\t\tif ptr not in s:\r\n\t\t\tprint(str(ptr), end = ' ')\r\n\t\t\tctr += 1\r\n\t\t\ts.add(ptr)\r\n\t\tptr += 1\r\n\tprint('')\r\n\t", "# parsing input\nn, k = map(int, input().split(\" \"))\nwished_slices = input().split(\" \")\nwished_slices = [int(el) for el in wished_slices]\nstart_slice = 1\n\ntotal_slices = n * k\n\nfor child in range(0, k):\n print(wished_slices[child], end=' ')\n slices_given = 1\n for slice in range(1, total_slices + 1):\n if slice not in wished_slices:\n print(slice, end=' ')\n wished_slices.append(slice)\n slices_given = slices_given + 1\n if slices_given >= n:\n break\n # next row for the next child\n print()", "n, k = [int(x) for x in input().split(' ')]\r\na = [int(x) for x in input().split(' ')]\r\nb = [i for i in range(1, n * k + 1) if i not in a]\r\n\r\nfor i in range(k):\r\n print(*([a[i]] + b[i*(n-1):(i+1)*(n-1)]))\r\n", "from math import sqrt, ceil, log\r\nfrom heapq import heapify, heappush, heappop\r\nfrom collections import defaultdict\r\nfrom bisect import bisect_left, bisect_right\r\n\r\nioint = lambda: int(input())\r\nioarr = lambda: list(map(int, input().split(\" \")))\r\nprnys = lambda: print(\"YES\")\r\nprnno = lambda: print(\"NO\")\r\n\r\nMAX = 10**9\r\n\r\n# n = ioint()\r\nn, k = ioarr()\r\n\r\narr = ioarr()\r\nst = set(arr)\r\n\r\npos = 0\r\ncur = 1\r\nwhile pos < k:\r\n print(arr[pos], end=\" \")\r\n\r\n cnt = 1\r\n while cnt < n:\r\n if cur not in st:\r\n cnt += 1\r\n print(cur, end=\" \")\r\n cur += 1\r\n\r\n print(\"\")\r\n pos += 1\r\n", "I=lambda:map(int,input().split())\r\nn,k=I();a=list(I());b=list(range(1,n*k+1))\r\nfor i in a:b.remove(i)\r\nfor i in range(k):\r\n print(' '.join(map(str,[a[i]]+b[i*(n-1):i*(n-1)+n-1])))", "n,k = map(int,input().split())\nl = list(map(int,input().split()))\nd = dict()\nb=[]\nfor i in range(len(l)):\n\tif (i+1) not in d:\n\t\td[i+1] = []\n\t\td[i+1].append(l[i])\n#print (d)\t\nfor i in range(1,n*k+1):\n\tif i not in l:\n\t\tb.append(i)\n#print (b)\nj=1\ncount = 0\nfor i in range(len(b)):\n\tif count == n-1:\n\t\tcount = 0\n\t\tj+=1\n\td[j].append(b[i])\n\tcount+=1\n#print (d)\t\t\nfor i in d:\n\tfor j in range(len(d[i])):\n\t\tprint (d[i][j],end=\" \")\n\tprint ()\n\n", "n,k = list(map(int, input().split(\" \")))\r\nx = list(map(int, input().split(\" \")))\r\na=[False for i in range(n*k)]\r\nfor i in range(k):\r\n a[x[i]-1]=True\r\nj=0\r\nfor i in range(k):\r\n print(x[i],end=\" \")\r\n k=0\r\n while k<n-1:\r\n if a[j]==False:\r\n print(j+1,end=\" \")\r\n a[j]=True\r\n k+=1\r\n j+=1\r\n print()\r\n", "n, k = map(int, input().split())\ntargets = list(map(int, input().split()))\ntaken = set(targets)\nalls = n * k\nfor i in range(len(targets)):\n print(targets[i], end=\" \")\n j = 0\n while j in range(n - 1):\n if alls not in taken:\n print(alls, end=\" \")\n alls -= 1\n j += 1\n else:\n alls -= 1\n print()\n", "a = input().split(' ')\nn = int(a[0])\nk = int(a[1])\na = input().split(' ')\nb = []\nfor i in range(k):\n a[i] = int(a[i])-1\n b.append(a[i])\nb.sort()\nd = {}\ncounter = 0\nfor i in range(k):\n d[i] = [a[i]]\n count = 0\n while count < n-1:\n if counter not in b:\n d[i].append(counter)\n count = count + 1\n counter = counter + 1\n else:\n counter = counter + 1\n\nfor i in range(k):\n for j in d[i]:\n print(j+1,end = ' ')\n print()\n", "n, m = map(int, input().split())\r\nl = [int(i) for i in range(1, n * m + 1)]\r\np = [int(i) for i in input().split()]\r\nfor i in range(m):\r\n j = 0\r\n print(p[i],end = \" \")\r\n while j < n - 1:\r\n if not (l[0] in p):\r\n print(l[0], end = \" \")\r\n j += 1\r\n l.pop(0)\r\n print()\r\n\r\n", "#For fast I/O\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\nHomura = [int(i) for i in input().split()]\r\nn = Homura[0]\r\nk = Homura[1]\r\nl = [int(i) for i in input().split()]\r\n\r\netc = [int(i) for i in range(1,n*k+1)]\r\nfor i in l:\r\n\tetc.remove(i)\r\n\r\nfor i in range(k):\r\n\tl_i = [l[i]]\r\n\tfor j in range(n-1):\r\n\t\tl_i.append(etc[i*(n-1)+j])\r\n\tl_i = [str(Madoka) for Madoka in l_i]\r\n\tprint(' '.join(l_i))\r\n", "N, K = map(int, input().strip().split())\r\nA = list(map(lambda a: int(a) - 1, input().strip().split()))\r\nselected = [False for _ in range(N * K)]\r\nfor i in range(len(A)):\r\n selected[A[i]] = True\r\n\r\n\r\nfor i in range(K):\r\n segs = [A[i] + 1]\r\n \r\n for j in range(1, N):\r\n for ii in range(len(selected)):\r\n if not selected[ii]:\r\n selected[ii] = True\r\n segs += [(ii + 1)]\r\n break\r\n print(*segs)\r\n", "def main():\n\tn,k= [int(i) for i in input().split()]\n\ts= list(range(1,n*k+1))\n\tarr=[int(i) for i in input().split()]\n\tplist=[]\n\tfor i in arr:\n\t\ts.remove(i)\n\tfor i in arr:\n\t\tplist.append([i]+s[:n-1])\n\t\ts[:]=s[n-1:]\n\tfor i in plist:\n\t\tprint(*i)\n\treturn 0 \n\nif __name__ == '__main__':\n\tmain()\n", "import sys\nf = sys.stdin\n#f = open(\"input.txt\", \"r\")\nn, k = map(int, f.readline().strip().split())\na = [int(i) for i in f.readline().strip().split()]\nnum = [True] * n*k\nfor i in a:\n num[i-1] = False\nfor i in a:\n print(i, end=\" \")\n cnt = 1\n for j in range(1, n*k+1):\n if cnt < n:\n if num[j-1]:\n num[j-1] = False\n print(j, end=\" \")\n cnt += 1\n else:\n break\n print()", "import math\r\nimport sys\r\nimport collections\r\n\r\n# imgur.com/Pkt7iIf.png\r\n\r\ndef getdict(n):\r\n d = {}\r\n if type(n) is list:\r\n for i in n:\r\n if i in d:\r\n d[i] += 1\r\n else:\r\n d[i] = 1\r\n else:\r\n for i in range(n):\r\n t = ii()\r\n if t in d:\r\n d[t] += 1\r\n else:\r\n d[t] = 1\r\n return d\r\ndef cdiv(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\n\r\nn, k = mi()\r\na = li()\r\nsa = set(a)\r\nt = []\r\n\r\nfor i in range(1, n*k + 1):\r\n if i not in sa:\r\n t.append(i)\r\n\r\nfor i in range(k):\r\n print(a[i], end = ' ')\r\n for j in range(n - 1):\r\n print(t.pop(), end = ' ')\r\n print()", "n,k=[int (i) for i in input().split()]\r\nx=[int (i) for i in input().split()]\r\nz=[i+1 for i in range(n*k)]\r\ny=[[] for i in range(k)]\r\nfor i in range(k):\r\n y[i].append(x[i])\r\n z.remove(x[i])\r\nwhile len(z)>0:\r\n for i in range(k):\r\n y[i].append(z[0])\r\n z.remove(z[0])\r\nfor i in y:\r\n for j in i:\r\n print(j,end=\" \")\r\n print(\"\")\r\n", "n, k = map(int, input().split())\nnk = list(range(1, n * k + 1))\nv = list(map(int, input().split()))\nnk = [i for i in nk if i not in v]\nfor i in range(0, k):\n print(*([v[i]] + nk[i * (n - 1): (i + 1) * (n - 1)]))\n", "n,k=map(int,input().split())\r\na=[int(a) for a in input().split()]\r\nstart=1\r\nfor i in range(k):\r\n count=1\r\n print (a[i],end=' ')\r\n while (start<=(n*k)):\r\n if (start not in a):\r\n print (start,end=' ')\r\n count+=1\r\n if count==n:\r\n start+=1\r\n break\r\n start+=1\r\n print ()\r\n\r\n", "X, Segments = list(map(int, input().split())), list(map(int, input().split()))\r\nPickedSegments = [False for i in range(X[0] * X[1])]\r\nfor i in range(X[1]):\r\n PickedSegments[Segments[i] - 1] = True\r\nj = 0\r\nfor i in range(X[1]):\r\n print(Segments[i], end=\" \")\r\n for k in range(X[0] - 1):\r\n while PickedSegments[j]:\r\n j += 1\r\n PickedSegments[j] = True\r\n print(j + 1, end=\" \")\r\n print()\r\n# UB_CodeForces\r\n# Don't give up on anything you are doing\r\n# location: in front of sb that i don't like\r\n", "n,k=map(int,input().split())\r\narr=list(map(int,input().split()))\r\nif n==1:\r\n for i in arr:\r\n print(i)\r\nelse: \r\n c=1\r\n for i in range(k):\r\n print(arr[i],end=\" \")\r\n con=1\r\n x=0\r\n while(con):\r\n if c not in arr:\r\n print(c,end=\" \")\r\n x=x+1\r\n c=c+1\r\n if x==n-1:\r\n print()\r\n break\r\n \r\n \r\n", "n, k = map(int, input().split())\r\narr = list(map(int, input().split()))\r\n\r\nlst = [i for i in range(1, n*k+1) if i not in arr]\r\nfor num in arr:\r\n ans = [num]\r\n cases = n -1\r\n\r\n while cases:\r\n ans.append(lst.pop())\r\n cases -= 1\r\n\r\n print(*ans)\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n,k=map(int,input().split())\r\nz=list(map(int,input().split()))\r\nx=[int(i) for i in range(1,n*k+1) if int(i) not in z]\r\na=0\r\nfor i in range(k):\r\n print(z[i],end=' ')\r\n for j in range(a,a+n-1):\r\n print(x[j],end=' ')\r\n a=a+n-1 \r\n print() \r\n", "def solve(arr,n,k):\n numbers = []\n res = []\n for i in range(1,n*k+1):\n if i not in arr:\n numbers.append(i)\n i = 0\n for v in arr:\n print(v,*numbers[i:i+n-1])\n i+=n-1\n\n\n \n\ndef main() :\n n,k = list(map(int, input().split(' ')))\n arr = list(map(int, input().split(' ')))\n solve(arr,n,k)\nmain()\n", "n, k = map(int, input().split())\na = [int(i) for i in input().split()]\n\ngets = [list() for i in range(k)]\nused = [False] * (n * k)\n\nfor i in range(k):\n gets[i].append(a[i])\n used[a[i] - 1] = True\n\nptr1 = 0\nusedptr = 0\nfor i in range(k):\n while len(gets[i]) < n:\n if not used[usedptr]:\n gets[i].append(usedptr + 1)\n used[usedptr] = True\n usedptr += 1\n\nfor i in gets:\n print(*i)\n", "n, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\ni = 1\r\nfor j in range(k):\r\n t=[a[j]]\r\n while len(t) != n:\r\n if i in a:\r\n i += 1\r\n else:\r\n t.append(i)\r\n i += 1\r\n print(' '.join(str(t[m]) for m in range(n)))", "n , k = map(int , input().split())\r\n\r\nr = lambda : list(map(int, input().split()))\r\narr = r()\r\n\r\nnum = 1\r\n\r\nfor i in arr:\r\n print(i , end = \" \")\r\n lim = n-1\r\n while lim:\r\n if num not in arr:\r\n print(num , end= \" \")\r\n\r\n lim -= 1\r\n num+=1\r\n\r\n\r\n print()\r\n\r\n\r\n", "n,k = [int(x) for x in input().split()]\r\na = [int(x) for x in input().split()]\r\ns = [False] * (n*k+1)\r\nfor ai in a:\r\n s[ai]=True\r\n\r\nfor kid in range(k):\r\n curN = 1\r\n print(a[kid],end=\" \")\r\n for num in range(n-1):\r\n while s[curN]: curN+=1\r\n s[curN] = True\r\n print(curN,end=\" \")\r\n print(\"\")\r\n \r\n \r\n \r\n\r\n\r\n\r\n", "n,k = map(int,input().split())\ntotalList = []\nfor i in range(1,n+1):\n totalList.append(i)\nans = []\nidxList = [int(ch) for ch in input().split()]\nfor i in range(k):\n ans.append([idxList[i]])\n\nfor i in range(k):\n for j in range(1,n*k+1):\n if len(ans[i]) == n:\n break\n if j not in idxList:\n ans[i].append(j)\n idxList.append(j)\nfor item in ans:\n for num in item:\n print(num,end=' ')\n print()\n \n", "in1 = [int(i) for i in input().split()]\nn, k = in1[0], in1[1]\n\nsegments = input()\n\na = [int(x) for x in segments.split()]\n\nr = [[0 for i in range(n)] for j in range(k)]\n\nindexes = [i+1 for i in range(n * k)]\n\nfiltered = list(filter(lambda x: x not in a, indexes))\n\nfor i in range(k):\n r[i] = filtered[i*(n-1):i*(n-1) + n - 1]\n r[i].append(a[i])\n\nfor i in range(k):\n print(*r[i])\n\n\t \t \t\t \t \t \t \t\t \t\t \t\t\t", "## int(input())\r\n## map(int ,input().split())\r\n## int(i) for i in input().split()\r\nn , k = map(int ,input().split())\r\na = [int(i) for i in input().split()]\r\nrs = [[i] for i in a]\r\npos = 0\r\nfor i in range(n*k):\r\n if i + 1 in a:\r\n continue\r\n rs[pos].append(i+1)\r\n pos+=1\r\n if pos >=k: pos = 0\r\nprint('\\n'.join(' '.join(str(x) for x in l) for l in rs))", "n, k = map(int, input().split())\r\na, b = list(map(int, input().split())), []\r\nfor x in range(1, n * k + 1):\r\n if x not in a: b.append(x)\r\nfor i in range(k):\r\n print(a[i], end = \" \")\r\n for j in range(n - 1): print(b[(n - 1) * i + j], end = \" \")\r\n print()", "from collections import deque\r\nn, k = [int(j) for j in input().split()]\r\narr = [0] + [int(j) for j in input().split()]\r\n\r\ndp = [[] for _ in range(k + 1)]\r\n# print(dp)\r\nobj = {}\r\nfor i in range(1, len(arr)):\r\n dp[i].append(arr[i])\r\n obj[arr[i]] = True\r\n\r\nleft = [i for i in range(1, n*k + 1) if i not in obj]\r\nd = deque(left)\r\n# print(d)\r\n# print(dp)\r\nfor i in range(1, len(dp)):\r\n while len(dp[i]) < n:\r\n dp[i].append(d.popleft())\r\n\r\nfor el in dp[1:]:\r\n print(*el)\r\n\r\n", "arr1=[]\narr2=[]\nx=str(input(\"\"))\narr1=x.split()\nfor z in range(0,2):\n z1=arr1[z]\n arr2.append(int(z1))\narr3=[]\narr4=[]\nx=str(input(\"\"))\narr3=x.split()\nfor z in range(0,arr2[1]):\n z1=arr3[z]\n arr4.append(int(z1))\ncomp=[]\nfor i in range(1,(arr2[0]*arr2[1])+1):\n comp.append(i)\narr5=[]\nfor j in range(0,arr2[0]*arr2[1]):\n if(j<arr2[1]):\n arr5.append(arr4[j])\n comp.remove(arr4[j])\n else:\n arr5.append(comp[j-arr2[1]])\nfor m in range(0,arr2[1]):\n for s in range(0,arr2[0]):\n print((arr5[m:arr2[0]*arr2[1]:arr2[1]])[s],end=\" \")\n print(\"\\n\")\n \t \t\t\t\t\t \t\t \t \t \t\t", "n,k=map(int, input().split())\r\n\r\nl1=list(map(int, input().split()))\r\n\r\nl2=[0 for i in range(0, n*k)]\r\n\r\nfor i in l1:\r\n l2[i-1]=1\r\n\r\nch=0\r\nfor i in range(0,k):\r\n print(l1[i],end=\" \")\r\n j=0\r\n while j<n-1:\r\n if l2[ch]==0:\r\n print(ch+1,end=\" \")\r\n ch=ch+1\r\n j=j+1\r\n else:\r\n ch=ch+1\r\n print()", "n,k = map(int,input().split())\r\nl = list(map(int,input().split()))\r\nl.append(\"fake\")\r\nidx=0\r\nans=[l[0]]\r\ns=set(l)\r\n\r\nfor i in range(1,n*k+1):\r\n\tif i not in s:\r\n\t\tans.append(i)\r\n\tif len(ans)==n:\r\n\t\tprint(*ans)\r\n\t\tidx+=1\r\n\t\tans=[l[idx]]", "n,k=map(int,input().split());l=list(map(int,input().split()))\r\na=[x for x in range(1,n*k+1) if x not in l]\r\nfor x in range(k):print(l[x],*a[x*(n-1):(x+1)*(n-1)])", "# Time complexity: O(N*K) => Linear time complexity\r\n# Space complexity: O(K) => Constant complexity\r\ndef solve(n, k, a):\r\n b = sorted(a)\r\n a_idx = 0\r\n k_idx = 0\r\n for i in range(1, n*k+1):\r\n if i != b[a_idx][0]:\r\n if len(a[k_idx]) == n:\r\n k_idx += 1\r\n a[k_idx].append(i)\r\n elif a_idx < len(a) -1:\r\n a_idx += 1\r\n return a\r\n\r\ndef print_res(a):\r\n for e in a:\r\n print(' '.join([str(x) for x in e]))\r\n\r\nn, k = [int(x) for x in input().split()]\r\na = [[int(x)] for x in input().split()]\r\nprint_res(solve(n, k, a))", "n,k=map(int,input().split())\r\nl1=list(range(1,n*k+1))\r\nl2=list(map(int,input().split()))\r\nd1={}\r\nfor item in l2:\r\n d1[item]=1\r\nx=0\r\nfor i in range(1,k+1):\r\n z=1\r\n print(l2[i-1],end=\" \")\r\n while z<n:\r\n if l1[x] not in l2:\r\n print(l1[x],end=\" \")\r\n z+=1\r\n x+=1\r\n print(\"\")\r\n ", "a, q = map(int, input().split())\r\n*s, = map(int, input().split())\r\nw = [i for i in range(1, a * q + 1)]\r\nfor i in s:\r\n print(i, end = ' ')\r\n w.remove(i)\r\n d = 1\r\n j = 0\r\n while j < len(w):\r\n if d == a:\r\n break\r\n if w[j] not in s:\r\n print(w[j], end = ' ')\r\n w.remove(w[j])\r\n d += 1\r\n else:\r\n j += 1\r\n print()\r\n", "#!/usr/bin/env python\r\nfrom __future__ import division, print_function\r\nimport math\r\nimport os\r\nimport sys\r\nfrom fractions import *\r\nfrom sys import stdin,stdout\r\nfrom io import BytesIO, IOBase\r\nfrom itertools import accumulate\r\nfrom collections import deque\r\n#sys.setrecursionlimit(10**5)\r\n\r\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") # for fast input\r\n\r\ndef out(var): sys.stdout.write(str(var)) # for fast output, always take string\r\n\r\ndef lis(): return list(map(int, inp().split()))\r\n\r\ndef stringlis(): return list(map(str, inp().split()))\r\n\r\ndef sep(): return map(int, inp().split())\r\n\r\ndef strsep(): return map(str, inp().split())\r\n\r\ndef fsep(): return map(float, inp().split())\r\n\r\ndef inpu(): return int(inp())\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#sys.setrecursionlimit(10**6)\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\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\n#-------------------------------------------------\r\ndef binarySearchCount(arr, n, key):\r\n left = 0\r\n right = n - 1\r\n\r\n count = 0\r\n\r\n while (left <= right):\r\n mid = int((right + left) / 2)\r\n\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\r\n # If key is smaller, ignore right half\r\n else:\r\n right = mid - 1\r\n return count\r\n#------------------------------reverse string(pallindrome)\r\ndef reverse1(string):\r\n pp=\"\"\r\n for i in string[::-1]:\r\n pp+=i\r\n if pp==string:\r\n return True\r\n return False\r\n#--------------------------------reverse list(paindrome)\r\ndef reverse2(list1):\r\n l=[]\r\n for i in list1[::-1]:\r\n l.append(i)\r\n if l==list1:\r\n return True\r\n return False\r\ndef mex(list1):\r\n #list1 = sorted(list1)\r\n p = max(list1)+1\r\n for i in range(len(list1)):\r\n if list1[i]!=i:\r\n p = i\r\n break\r\n return p\r\ndef sumofdigits(n):\r\n n = str(n)\r\n s1=0\r\n for i in n:\r\n s1+=int(i)\r\n return s1\r\ndef perfect_square(n):\r\n s = math.sqrt(n)\r\n if s==int(s):\r\n return True\r\n return False\r\n\r\n#-----------------------------roman\r\ndef roman_number(x):\r\n if x>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\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#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\ndef countrhombi2(h,w):\r\n return ((h*h)//4) * ((w*w)//4)\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\ndef binpowmodulus(a,b,m):\r\n a %= m\r\n res = 1\r\n while (b > 0):\r\n if (b & 1):\r\n res = res * a % m\r\n a = a * a % m\r\n b >>= 1\r\n return res\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#-------------------prime\r\ndef prime(x):\r\n if x==1:\r\n return False\r\n else:\r\n for i in range(2,int(math.sqrt(x))+1):\r\n if(x%i==0):\r\n return False\r\n else:\r\n return True\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\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\nres = set()\r\ndef solve(p, l,a,b):\r\n if p > n or l > 10:\r\n return\r\n if p > 0:\r\n res.add(p)\r\n solve(p * 10 + a, l + 1,a,b)\r\n solve(p * 10 + b, l + 1,a,b)\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#def mapu(): return map(int,input().split())\r\n#endregion------------------------------\r\n\"\"\"\r\ndef main():\r\n x,y,n = sep()\r\n\r\n c = (Fraction(x,y).limit_denominator(n))\r\n # print(type(c))\r\n # print(c)\r\n c = str(c)\r\n if \"/\" in c:\r\n print(c)\r\n else:\r\n print(c+\"/\"+\"1\")\r\n\r\nif __name__ == '__main__':\r\n main()\r\n\"\"\"\r\n\"\"\"\r\nif __name__ == '__main__':\r\n a,b = sep()\r\n print(countRhombi(a,b))\r\n\"\"\"\r\n\"\"\"\r\ndef main():\r\n m = inpu()\r\n l=[0]*5\r\n for _ in range(m):\r\n a,b = sep()\r\n l[a - 1] += 1\r\n l[b - 1] += 1\r\n #print(l)\r\n if l.count(2) == 5:\r\n print('FAIL')\r\n else:\r\n print('WIN')\r\nif __name__ == '__main__':\r\n main()\r\n\"\"\"\r\ndef main():\r\n n,k = sep()\r\n a = lis()\r\n ll=[]\r\n for i in range(k):\r\n ans=[]\r\n ans.append(a[i])\r\n for i in range(1,n*k+1):\r\n if i not in a and i not in ll:\r\n ans.append(i)\r\n ll.append(i)\r\n if len(ans)==n:\r\n break\r\n print(*ans)\r\nif __name__ == '__main__':\r\n main()\r\n", "if __name__ == '__main__':\r\n n, k = map(int, input().split())\r\n l = list(map(int, input().split()))\r\n s = set(l)\r\n val = [str(x) for x in range(1, n * k + 1) if x not in s]\r\n di = {k: v for k, v in enumerate(l)}\r\n for i in range(0, k):\r\n print(\" \".join(val[i * (n-1): (i + 1) * (n-1)]) + f\" {di[i]}\")", "n, k = [int(i) for i in input().split()]\nnk = n*k\nls_ = [int(i) for i in input().split()]\nmarks_ = [False]*(nk+1)\nc = 1\n# print(ls_)\n\nfor i in ls_:\n marks_[i] = True\n\nfor i in range(k):\n print(ls_[i], end=' ')\n for j in range(1, n):\n while(marks_[c] == True):\n c+=1\n if(j != n-1):\n print(c, end=' ')\n else:\n print(c, end='')\n marks_[c] = True\n if(i != k-1):\n print()\n \t \t \t\t\t \t \t\t \t \t \t\t", "a=list(map(int,input().split(' ')))\r\ns=[]\r\ns1=[]\r\nfor i in range(1,(a[0]*a[1]+1)):\r\n s.append(i)\r\ns1=list(map(int,input().split(' '))) \r\ng=list(set(s)-set(s1))\r\nx=0\r\nfor i in range(a[1]):\r\n print(s1[i],end=' ')\r\n for j in range(a[0]-1):\r\n print(g[x],end=' ')\r\n x+=1\r\n print()", "\r\nimport math\r\nfrom math import gcd,floor,sqrt,log\r\ndef iin(): return int(input())\r\ndef sin(): return input().strip()\r\ndef listin(): return list(map(int,input().strip().split()))\r\ndef liststr(): return list(map(str,input().strip().split()))\r\ndef ceill(x): return int(x) if(x==int(x)) else int(x)+1\r\ndef ceilldiv(x,d): return x//d if(x%d==0) else x//d+1\r\ndef LCM(a,b): return (a*b)//gcd(a,b)\r\n\r\n\r\ndef solve():\r\n n,k = listin()\r\n a = listin()\r\n z = [i for i in range(1,n*k+1) if i not in a]\r\n temp = 0\r\n for j in range(k):\r\n print(a[j],end = \" \")\r\n for i in range(temp,n+temp-1):\r\n print(z[i],end = ' ')\r\n temp += n-1\r\n print()\r\n \r\nt = 1 \r\n# t = int(input()) \r\nfor hula in range(t):\r\n\tsolve()\r\n", "n,k=[int(e) for e in input().split()]\nl=[int(e) for e in input().split()]\nf=list(range(1,n*k+1))\n\n\nfor i in l:\n f.remove(i)\nfor i in range(0,k):\n print(l[i], end=' ')\n for j in range(0,n-1):\n print(f[0],end=' ')\n f.remove(f[0])\n\n print(' ')\n \n", "n,k=map(int,input().split())\r\na=list(map(int,input().split()))\r\nl=[]\r\nfor i in range(n*k):\r\n\tif i+1 not in a:\r\n\t\tl.append(i+1)\r\nj=0\r\nfor i in a:\r\n\tprint(i, end=\" \")\r\n\tprint(*(z for z in l[j:j+n-1]))\r\n\tj=j+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\t\r\n\r\n\r\n\r\n\t\r\n\r\n\t\t\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n,k=map(int, input().split())\r\nli=list(map(int, input().split()))\r\ni=1;\r\nfor z in li:\r\n print(z,end=\" \")\r\n l=1\r\n while l<n:\r\n if i in li:\r\n i+=1\r\n else:\r\n print(i,end=\" \")\r\n l+=1\r\n i+=1\r\n print()", "n,k=list(map(int,input().split()))\r\na=list(map(int,input().split()))\r\nj=1\r\nfor i in range(k):\r\n l=[a[i]]\r\n while len(l)!=n:\r\n if j not in a:\r\n l.append(j)\r\n j+=1\r\n print(*l)\r\n", "import sys, io, os\r\nimport math\r\nimport bisect\r\nimport heapq\r\nimport string\r\nfrom collections import defaultdict,Counter,deque\r\ninput = sys.stdin.readline\r\n \r\ndef I():\r\n return input()\r\n \r\ndef II():\r\n return int(input())\r\n \r\ndef MII():\r\n return map(int, input().split())\r\n \r\ndef LI():\r\n return list(input().split())\r\n \r\ndef LII():\r\n return list(map(int, input().split()))\r\n \r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n \r\ndef LGMI():\r\n return list(map(lambda x: int(x) - 1, input().split()))\r\n \r\ndef WRITE(out):\r\n return print('\\n'.join(map(str, out)))\r\n \r\ndef WS(out):\r\n return print(' '.join(map(str, out)))\r\n \r\ndef WNS(out):\r\n return print(''.join(map(str, out)))\r\n\r\n'''\r\nn - majority element\r\n'''\r\n\r\ndef solve():\r\n n, k = MII()\r\n oranges = [i for i in range(n*k+1)]\r\n oranges[0] = -1\r\n\r\n splits = [[] for _ in range(k)]\r\n\r\n for i,num in enumerate(LII()):\r\n oranges[num] = -1 #selected -> remove\r\n splits[i].append(num)\r\n \r\n # convert 1-index to 0-index\r\n i = 0\r\n splits_idx = 0\r\n while i < len(oranges):\r\n if oranges[i] != -1:\r\n splits[splits_idx % k].append(oranges[i])\r\n splits_idx += 1\r\n i += 1\r\n\r\n for oranges in splits:\r\n WS(oranges)\r\n\r\nsolve()", "n,k=map(int,input().split())\r\ns=set()\r\nfor i in range((n*k)+1):\r\n s.add(i)\r\ns.pop()\r\nli=list(map(int,input().split()))\r\nfor i in range(k):\r\n s.remove(li[i])\r\nfor i in range(k):\r\n print(li[i],end=' ')\r\n for j in range(n-1):\r\n print(s.pop(),end=' ')\r\n print()\r\n", "\r\nrow = input()\r\nn = int(row.split()[0])\r\nk = int(row.split()[1])\r\n\r\nrow1 = input()\r\nselected = [x for x in row1.split()]\r\nfor i in range(0, len(selected)):\r\n selected[i] = int(selected[i])\r\n\r\nnotselected = [x for x in range(1, n*k+1) if x not in selected]\r\nidx = 0\r\n\r\n\r\nfor i in range(k):\r\n print(selected[i], end = \" \")\r\n for j in range(n -1):\r\n print(notselected[idx], end = \" \")\r\n idx = idx +1\r\n print(\"\\n\")\r\n\r\n", "n, k = (int(x) for x in input().split())\r\na = [int(x) for x in input().split()]\r\ns = set(range(1, n * k + 1))\r\nfor ai in a:\r\n s.remove(ai)\r\nfor ai in a:\r\n print(ai, end='')\r\n for i in range(n - 1):\r\n print(' ' + str(s.pop()), end='')\r\n print()", "def main():\n [n, k] = [int(_) for _ in input().split()]\n likes = [int(_) for _ in input().split()]\n not_likes = [i for i in range(1, n * k + 1) if i not in likes]\n children = {}\n\n for i in range(k):\n left = i * (n - 1)\n right = left + n - 1\n children[i] = [likes[i]] + not_likes[left:right]\n\n for segments in children.values():\n print(' '.join([str(x) for x in segments]))\n\n\nif __name__ == '__main__':\n main()\n", "n , k = map(int,input().split())\r\nseg = n*k\r\nreq_lis=[]\r\nleft_lis=[]\r\na = []\r\nx = list(map(int,input().split()))\r\nfor i in x:\r\n req_lis.append(i)\r\nfor i in range(1,seg+1):\r\n if i not in x:\r\n left_lis.append(i)\r\norder = req_lis+left_lis\r\n\r\nif n == 1 or k == 1:\r\n print(*order)\r\nelse:\r\n for j in range(k):\r\n for l in range(j,len(order),k):\r\n a.append(order[l])\r\n print(*a)\r\n a.clear()", "n, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\ni = 1\r\nfor j in range(k):\r\n temp = [a[j]]\r\n while len(temp) != n:\r\n if i in a:\r\n i += 1\r\n else:\r\n temp.append(i)\r\n i += 1\r\n print(' '.join(str(temp[m]) for m in range(n)))\r\n \r\n \r\n", "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nvals = set(range(1, N * K + 1))\n\nanswer = [[] for k in range(K)]\nfor k in range(K):\n answer[k].append(A[k])\n vals.remove(A[k])\n\nk = 0\nwhile len(vals) > 0:\n answer[k].append(vals.pop())\n k = (k + 1) % K\n\nfor k in range(K):\n print(\" \".join([str(x) for x in answer[k]]))\n", "inp=list(map(int,input().split()))\r\nn,k=inp\r\narr=[]\r\nfor i in range(k+1):\r\n arr.append([])\r\nfrom collections import Counter\r\na=list(map(int,input().split()))\r\nfor i in range(len(a)):\r\n arr[i+1].append(a[i])\r\nc=Counter(a)\r\nj=1\r\nfor i in range(1,n*k+1):\r\n if c[i]!=0:\r\n continue\r\n if len(arr[j])==n:\r\n j+=1\r\n if j==len(arr):\r\n break\r\n arr[j].append(i)\r\n c[i]+=1\r\nfor item in arr:\r\n for k in item:\r\n print (k,end=\" \")\r\n print (' ')", "n, k = [int(x) for x in input().split()]\n\nlikes = [int(x) for x in input().split()]\n\noranges = [ True ] * (n * k)\n\nfor i in likes:\n oranges[i - 1] = False\n\noranges_cnt = 0\n\nfor l in likes:\n print(l, end=\" \")\n for _ in range(n - 1):\n while not oranges[oranges_cnt]:\n oranges_cnt += 1\n print(oranges_cnt + 1, end=\" \")\n oranges_cnt += 1\n print()\n\n", "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############ ---- Input Functions ---- ############\r\n\r\ndef Dividing_Orange():\r\n n,k = invr() #k children, each gets n pieces\r\n total_num_pieces = n*k\r\n\r\n all_available_pieces_indices = [(i+1) for i in range(n*k)]\r\n\r\n desired_piece_list = inlt() \r\n\r\n for desired_piece in desired_piece_list:\r\n all_available_pieces_indices.remove(desired_piece)\r\n\r\n outputStr = ''\r\n\r\n current_piece_index = 0\r\n\r\n for child in range(k):\r\n for piece in range(n):\r\n if piece == 0:\r\n outputStr += str(desired_piece_list[child]) + ' ' \r\n else:\r\n outputStr += str(all_available_pieces_indices[current_piece_index]) + ' ' \r\n current_piece_index += 1\r\n \r\n outputStr += '\\n'\r\n \r\n outputStr = outputStr.strip()\r\n print(outputStr)\r\n return\r\n\r\nDividing_Orange()", "def main():\r\n [n, k] = list(map(int, input().split()))\r\n pos = list(map(int, input().split()))\r\n\r\n s = set(pos)\r\n for i in range(1, n*k + 1):\r\n s.add(i)\r\n\r\n sol = [[] for _ in range(k)]\r\n for i in range(k):\r\n sol[i].append(pos[i])\r\n s.remove(pos[i])\r\n\r\n for i in range(k):\r\n for _ in range(n-1):\r\n sol[i].append(s.pop())\r\n\r\n for row in sol:\r\n for col in row:\r\n print(col, end = ' ')\r\n print()\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n\r\n\r\n", "iarr = list(map(int,input().split()))\nn = iarr[0]\nk = iarr[1]\narr = list(map(int,input().split()))\nflagar = [0 for i in range(n*k+1)]\nfor i in arr:\n\tflagar[i]=1\n#print(arr)\nfor i in range(k):\n\tarr[i] = [arr[i]]\n#print(arr)\ncount=1\nind=0\nfor i in range(1,n*k+1):\n\t#print(i,flagar[i],count,ind,arr[ind])\n\tif count<n:\n\t\tif flagar[i]==0:\n\t\t\tarr[ind].append(i)\n\t\t\tcount+=1\n\telse:\n\t\tcount=1\n\t\tind+=1\n\t\tif count<n:\n\t\t\tif flagar[i]==0:\n\t\t\t\tarr[ind].append(i)\n\t\t\t\tcount+=1\n\n#print(flagar)\n#print(arr)\nfor i in range(k):\n\tfor j in arr[i]:\n\t\tprint(j,end=\" \")\n\tprint()", "n, k = map(int, input().split())\r\na = list(map(int, input().split()))\r\nresult = 1\r\nfor i in range(k):\r\n\tprint(a[i], end = ' ')\r\n\tcounter = 0\r\n\twhile counter!=n-1:\r\n\t\tif result in a:\r\n\t\t\tresult+=1\r\n\t\telse:\r\n\t\t\tprint(result, end = ' ')\r\n\t\t\tcounter+=1\r\n\t\t\tresult+=1\r\n\tprint('')", "(n, k) = map(int, input().split(' '))\na = list(input().split(' '))\ns = set(a)\n\no = []\n\nfor i in range(k):\n o.append([a[i]])\n\nfor i in range(n * k):\n num = str(i + 1)\n j = 0\n if num not in s:\n while len(o[j]) == n:\n j += 1\n o[j].append(num)\n\nfor x in o:\n print(' '.join(x))\n", "def read_int():\r\n return int(input())\r\n\r\n\r\ndef read_ints():\r\n return list(map(int, input().split()))\r\n\r\n\r\ndef print_nums(nums):\r\n print(\" \".join(map(str, nums)))\r\n\r\n\r\nn, k = read_ints()\r\nseg = read_ints()\r\nvis = set(seg)\r\nstep = 1\r\n\r\nfor i in range(k):\r\n # handle child i\r\n ans = [seg[i]]\r\n while len(ans) < n:\r\n if step not in vis:\r\n ans.append(step)\r\n step += 1\r\n print_nums(ans)\r\n", "n,k = input().split()\nn = int(n)\nk = int(k)\nlist1 = [int(n) for n in input().split()]\nlist2 = [0] * (n*k + 1)\n\nfor item in list1:\n list2[item] = 1\n \nfor z in range(k):\n outstring = str(list1[z])\n count = 1\n for j in range(1, n*k + 1):\n if count == n:\n break\n if list2[j] == 0:\n outstring = outstring + \" \" + str(j)\n list2[j] = 1\n count = count + 1\n print(outstring)\n \t\t\t \t\t\t \t\t\t \t \t \t", "n,m=map(int,input().split())\r\na=list(map(int,input().split()))\r\no=[]\r\nfor i in range(n*m):o.append(0)\r\nfor i in range(m):o[a[i]-1]=i+1\r\nfor i in range(m):\r\n\tfor j in range(n-1):\r\n\t\tfor k in range(n*m):\r\n\t\t\tif(o[k]==0):\r\n\t\t\t\tprint(k+1,end=' ')\r\n\t\t\t\to[k]=i+1\r\n\t\t\t\tbreak\r\n\tprint(a[i],end='\\n')\t\r\n", "##l = [int(item) for item in input().split()]\r\ndef children_to_slices(n, k, l):\r\n kid_to_slice = [[]] * (k+1)\r\n remaining = set([i for i in range(1, (n*k)+1)])\r\n\r\n # Give eah kid what he wants\r\n for item in l:\r\n kid_to_slice[item[0]] = kid_to_slice[item[0]] + [item[1]]\r\n remaining.remove(item[1])\r\n\r\n # fill each kid's inventory\r\n for i in range(1, k+1):\r\n while len(kid_to_slice[i]) < n:\r\n kid_to_slice[i] = kid_to_slice[i] + [remaining.pop()]\r\n\r\n return kid_to_slice\r\n\r\nfirst_line = input().split()\r\nn = int(first_line[0])\r\nk = int(first_line[1])\r\nl = []\r\nassignments = [int(item) for item in input().split()]\r\nfor i in range(len(assignments)):\r\n l.append((i+1, assignments[i]))\r\n\r\nm = children_to_slices(n, k, l)\r\nfor i in range(1, k+1):\r\n output = \"\"\r\n for item in m[i]:\r\n output += str(item) + \" \"\r\n print(output)\r\n", "n,k=map(int,input().split())\r\nb=[0 for i in range(n*k)]\r\na=list(map(int,input().split()))\r\nfor i in range(k):\r\n b[a[i]-1]=i+1\r\ncount=0\r\nc=1\r\nfor i in range(n*k):\r\n if b[i]==0:\r\n count+=1\r\n b[i]=c\r\n if count==n-1:\r\n count=0\r\n c+=1\r\nfor i in range(k):\r\n for j in range(n*k):\r\n if b[j]==i+1:\r\n print(j+1,end=' ')\r\n print('')", "def divide_orange(n, k, preferences):\r\n orange_segments = list(range(1, n*k+1))\r\n result = [[] for _ in range(k)]\r\n\r\n # Assign preferred segments to each child\r\n for i in range(k):\r\n result[i].append(preferences[i])\r\n orange_segments.remove(preferences[i])\r\n\r\n # Fill the remaining segments randomly for each child\r\n for i in range(k):\r\n while len(result[i]) < n:\r\n result[i].append(orange_segments.pop())\r\n\r\n # Flatten the result list and return as space-separated integers\r\n return \" \".join(str(segment) for sublist in result for segment in sublist)\r\n\r\n# Input\r\nn, k = map(int, input().split())\r\npreferences = list(map(int, input().split()))\r\n\r\n# Output\r\nprint(divide_orange(n, k, preferences))\r\n" ]
{"inputs": ["2 2\n4 1", "3 1\n2", "5 5\n25 24 23 22 21", "1 30\n8 22 13 25 10 30 12 27 6 4 7 2 20 16 26 14 15 17 23 3 24 9 5 11 29 1 19 28 21 18", "30 1\n29", "10 10\n13 39 6 75 84 94 96 21 85 71", "10 15\n106 109 94 50 3 143 147 10 89 145 29 28 87 126 110", "15 10\n126 111 12 6 28 47 51 116 53 35", "30 30\n455 723 796 90 7 881 40 736 147 718 560 619 468 363 161 767 282 19 111 369 443 850 871 242 713 789 208 435 135 411", "1 1\n1", "2 1\n1", "1 2\n2 1", "1 3\n2 3 1", "2 3\n3 2 1", "3 3\n6 7 8", "3 1\n3", "3 2\n5 4", "12 13\n149 22 133 146 151 64 45 88 77 126 92 134 143", "30 29\n427 740 444 787 193 268 19 767 46 276 245 468 661 348 402 62 665 425 398 503 89 455 200 772 355 442 863 416 164", "29 30\n173 601 360 751 194 411 708 598 236 812 855 647 100 106 59 38 822 196 529 417 606 159 384 389 300 172 544 726 702 799", "29 29\n669 371 637 18 176 724 137 757 407 420 658 737 188 408 185 416 425 293 178 557 8 104 139 819 268 403 255 63 793", "28 29\n771 736 590 366 135 633 68 789 193 459 137 370 216 692 730 712 537 356 752 757 796 541 804 27 431 162 196 630 684", "29 29\n669 371 637 18 176 724 137 757 407 420 658 737 188 408 185 416 425 293 178 557 8 104 139 819 268 403 255 63 793", "27 3\n12 77 80", "3 27\n77 9 32 56 7 65 58 24 64 19 49 62 47 44 28 79 76 71 21 4 18 23 51 53 12 6 20", "10 30\n165 86 241 45 144 43 95 250 28 240 42 15 295 211 48 99 199 156 206 109 100 194 229 224 57 10 220 79 44 203", "30 10\n71 146 274 157 190 85 32 152 25 278", "7 1\n5", "6 1\n5"], "outputs": ["2 4 \n1 3 ", "3 2 1 ", "2 3 1 25 4 \n7 6 8 5 24 \n10 12 9 23 11 \n13 15 14 16 22 \n19 21 20 17 18 ", "8 \n22 \n13 \n25 \n10 \n30 \n12 \n27 \n6 \n4 \n7 \n2 \n20 \n16 \n26 \n14 \n15 \n17 \n23 \n3 \n24 \n9 \n5 \n11 \n29 \n1 \n19 \n28 \n21 \n18 ", "8 20 17 12 5 26 13 2 19 22 28 16 10 4 6 11 3 25 1 27 15 9 30 24 21 18 14 23 29 7 ", "9 3 1 13 5 7 4 2 10 8 \n17 12 19 11 39 14 15 18 16 20 \n22 27 6 24 25 30 26 28 23 29 \n36 33 75 34 38 31 35 40 37 32 \n43 44 49 42 46 48 47 45 84 41 \n51 94 52 56 57 54 50 55 53 58 \n64 60 62 61 66 59 63 96 67 65 \n72 69 76 77 70 78 73 21 74 68 \n81 85 87 88 80 83 89 86 79 82 \n93 91 100 99 98 71 90 95 92 97 ", "9 4 1 106 6 7 5 2 11 8 \n17 13 19 12 109 14 15 18 16 20 \n21 26 94 23 24 31 25 27 22 30 \n37 34 50 35 39 32 36 40 38 33 \n43 44 49 42 46 48 47 45 3 41 \n52 143 53 57 58 55 51 56 54 59 \n65 61 63 62 67 60 64 147 68 66 \n72 70 75 76 71 77 73 10 74 69 \n80 89 84 85 79 82 86 83 78 81 \n92 90 98 97 96 145 88 93 91 95 \n100 104 105 103 102 108 99 101 29 107 \n111 114 112 116 119 118 28 113 117 115 \n128 120 122 125 129 127 87 124 123 121 \n133 136 130 134 132 131 135 126 137 138 \n142 141 144 148 146 149 110 140...", "9 13 1 14 5 16 15 2 10 8 126 3 11 4 7 \n111 22 21 26 20 30 17 23 18 19 24 31 27 25 29 \n43 40 41 39 42 12 45 44 34 37 32 36 38 33 46 \n59 6 57 56 58 49 62 54 50 52 63 61 48 55 60 \n70 67 71 75 69 77 72 65 68 73 76 74 28 64 66 \n80 89 86 79 87 91 81 78 88 83 85 82 90 84 47 \n95 93 51 99 104 98 103 101 100 102 97 96 94 92 105 \n120 115 113 118 109 119 110 116 114 106 121 117 108 107 112 \n135 133 128 125 123 131 129 122 124 53 134 132 130 127 136 \n148 139 141 143 146 144 147 138 137 145 142 149 140 150 35 \n...", "9 22 18 13 5 28 14 2 21 24 30 17 11 4 6 12 3 27 1 29 16 10 31 26 23 20 15 25 455 8 \n723 52 49 60 45 48 34 59 58 44 32 57 61 56 51 33 42 37 41 38 47 53 36 50 54 55 46 39 43 35 \n89 71 796 74 78 70 88 67 84 85 63 83 82 62 72 79 81 80 73 91 69 66 65 87 77 75 64 68 86 76 \n115 90 102 121 104 106 109 98 112 120 119 105 103 97 113 93 100 118 107 96 117 92 94 116 95 101 110 108 114 99 \n136 133 148 123 144 139 149 142 7 140 138 127 150 129 122 130 143 126 134 152 132 145 131 146 125 151 137 128 124 141 \n154 177...", "1 ", "2 1 ", "2 \n1 ", "2 \n3 \n1 ", "4 3 \n2 5 \n1 6 ", "2 6 1 \n7 4 3 \n5 9 8 ", "2 3 1 ", "2 5 1 \n4 6 3 ", "8 11 1 10 5 6 4 2 9 7 149 3 \n14 13 19 12 17 16 22 20 21 23 15 18 \n133 28 34 32 31 25 30 33 24 29 26 27 \n35 42 38 40 43 46 39 41 44 146 36 37 \n56 51 48 49 50 54 53 151 57 52 47 55 \n61 58 65 68 67 59 62 66 69 63 64 60 \n80 70 75 74 76 81 45 72 78 73 79 71 \n94 85 88 83 90 87 86 89 93 82 84 91 \n99 104 98 96 103 105 102 97 77 95 101 100 \n116 109 107 111 115 113 126 108 112 110 114 106 \n127 121 125 118 120 128 123 92 119 122 117 124 \n139 132 136 130 131 140 141 134 137 138 135 129 \n150 142 144 155 154...", "8 21 17 12 5 27 13 2 20 23 29 16 10 4 6 11 3 26 1 28 15 9 30 25 22 18 14 24 427 7 \n740 51 48 59 43 47 33 58 57 42 31 56 60 55 50 32 40 36 39 37 45 52 35 49 53 54 44 38 41 34 \n90 71 444 74 78 70 88 67 84 85 63 83 82 61 72 79 81 80 73 91 69 66 65 87 77 75 64 68 86 76 \n114 787 102 120 104 106 109 98 111 119 118 105 103 97 112 93 100 117 107 96 116 92 94 115 95 101 110 108 113 99 \n134 132 145 122 142 137 146 140 193 138 136 126 147 128 121 129 141 125 133 149 131 143 130 144 124 148 135 127 123 139 \n151 1...", "8 20 17 12 5 26 13 2 19 22 28 16 10 4 6 11 3 25 1 27 15 9 7 24 21 18 14 23 173 \n47 36 37 35 45 51 49 41 31 33 29 32 46 57 52 48 54 34 55 53 56 30 601 44 43 39 40 42 50 \n77 79 84 86 64 72 75 60 76 78 81 73 80 58 82 69 70 67 83 65 68 62 360 71 61 63 85 66 74 \n90 107 751 110 105 93 98 96 95 97 116 91 109 102 115 87 99 104 114 88 92 113 94 111 101 89 103 112 108 \n140 127 144 134 118 125 141 137 119 133 128 139 124 121 130 126 120 142 136 122 132 117 194 131 129 143 138 123 135 \n147 168 163 154 174 160 146...", "9 22 19 13 5 28 14 2 21 24 30 17 11 4 6 12 3 27 1 29 16 10 7 26 23 20 15 25 669 \n48 38 39 37 46 52 50 42 33 35 31 34 47 58 53 49 55 36 56 54 57 32 371 45 44 40 41 43 51 \n78 80 85 87 65 73 76 60 77 79 82 74 81 59 83 70 71 68 84 66 69 62 637 72 61 64 86 67 75 \n91 107 18 110 106 94 99 97 96 98 116 92 109 102 115 88 100 105 114 89 93 113 95 111 101 90 103 112 108 \n142 127 146 134 118 125 143 138 119 133 128 141 124 121 130 126 120 144 136 122 132 117 176 131 129 145 140 123 135 \n149 169 164 156 173 161 14...", "8 20 17 12 5 26 13 2 19 22 771 16 10 4 6 11 3 25 1 28 15 9 7 24 21 18 14 23 \n34 55 49 41 54 45 33 37 35 53 29 40 30 32 43 31 36 51 736 44 39 46 38 50 48 52 47 42 \n77 65 78 73 63 56 72 590 76 62 74 57 83 69 58 80 60 79 66 59 64 82 67 70 81 61 71 75 \n107 104 92 94 106 109 84 88 86 99 98 105 366 93 103 101 89 87 95 90 100 85 91 102 97 108 110 96 \n124 125 113 123 119 120 121 134 127 132 117 129 116 130 138 111 118 131 122 139 128 114 112 126 115 136 133 135 \n141 633 142 153 160 152 149 156 166 158 161 144...", "9 22 19 13 5 28 14 2 21 24 30 17 11 4 6 12 3 27 1 29 16 10 7 26 23 20 15 25 669 \n48 38 39 37 46 52 50 42 33 35 31 34 47 58 53 49 55 36 56 54 57 32 371 45 44 40 41 43 51 \n78 80 85 87 65 73 76 60 77 79 82 74 81 59 83 70 71 68 84 66 69 62 637 72 61 64 86 67 75 \n91 107 18 110 106 94 99 97 96 98 116 92 109 102 115 88 100 105 114 89 93 113 95 111 101 90 103 112 108 \n142 127 146 134 118 125 143 138 119 133 128 141 124 121 130 126 120 144 136 122 132 117 176 131 129 145 140 123 135 \n149 169 164 156 173 161 14...", "8 21 18 13 5 27 14 2 20 23 12 17 10 4 6 11 3 26 1 24 16 9 7 25 22 19 15 \n43 32 46 48 51 37 41 49 77 30 40 28 34 38 44 35 31 45 52 50 47 29 36 53 42 39 33 \n62 61 78 63 81 55 70 79 67 73 58 69 59 64 80 54 56 57 68 72 65 60 71 66 74 75 76 ", "2 77 1 \n9 5 3 \n8 10 32 \n13 56 11 \n15 7 14 \n65 17 16 \n22 58 25 \n24 26 27 \n29 64 30 \n31 33 19 \n35 34 49 \n62 37 36 \n47 38 39 \n44 40 41 \n42 43 28 \n46 45 79 \n48 50 76 \n71 54 52 \n57 21 55 \n60 4 59 \n61 18 63 \n66 23 67 \n68 51 69 \n72 70 53 \n12 73 74 \n75 6 78 \n81 20 80 ", "8 3 1 165 5 6 4 2 9 7 \n17 12 19 11 86 13 14 18 16 20 \n21 26 241 23 24 30 25 27 22 29 \n36 33 45 34 38 31 35 39 37 32 \n46 47 53 41 50 52 51 49 144 40 \n55 43 56 61 62 59 54 60 58 63 \n69 65 67 66 71 64 68 95 72 70 \n76 74 80 81 75 82 77 250 78 73 \n85 28 90 91 84 88 92 89 83 87 \n97 94 104 103 102 240 93 98 96 101 \n106 111 112 110 108 114 105 107 42 113 \n115 118 116 120 123 122 15 117 121 119 \n131 124 126 129 132 130 295 128 127 125 \n136 139 133 137 135 134 138 211 140 141 \n146 145 147 149 148 150 4...", "8 20 17 12 5 27 13 2 19 22 29 16 10 4 6 11 3 26 1 28 15 9 30 24 21 18 14 23 71 7 \n146 51 48 59 44 47 34 58 57 43 31 56 60 55 50 33 41 37 40 38 46 52 36 49 53 54 45 39 42 35 \n90 70 274 74 78 69 89 66 84 86 62 83 82 61 72 79 81 80 73 91 68 65 64 88 77 75 63 67 87 76 \n114 157 102 120 104 106 109 98 111 119 118 105 103 97 112 93 100 117 107 96 116 92 94 115 95 101 110 108 113 99 \n134 132 145 122 142 137 147 140 190 138 136 126 148 128 121 129 141 125 133 150 131 143 130 144 124 149 135 127 123 139 \n153 17...", "2 3 1 5 6 7 4 ", "2 3 1 5 6 4 "]}
UNKNOWN
PYTHON3
CODEFORCES
151
e34659897384fdf431133167ef516793
Dungeons and Candies
During the loading of the game "Dungeons and Candies" you are required to get descriptions of *k* levels from the server. Each description is a map of an *n*<=×<=*m* checkered rectangular field. Some cells of the field contain candies (each cell has at most one candy). An empty cell is denoted as "." on the map, but if a cell has a candy, it is denoted as a letter of the English alphabet. A level may contain identical candies, in this case the letters in the corresponding cells of the map will be the same. When you transmit information via a network, you want to minimize traffic — the total size of the transferred data. The levels can be transmitted in any order. There are two ways to transmit the current level *A*: 1. You can transmit the whole level *A*. Then you need to transmit *n*·*m* bytes via the network. 1. You can transmit the difference between level *A* and some previously transmitted level *B* (if it exists); this operation requires to transmit *d**A*,<=*B*·*w* bytes, where *d**A*,<=*B* is the number of cells of the field that are different for *A* and *B*, and *w* is a constant. Note, that you should compare only the corresponding cells of levels *A* and *B* to calculate *d**A*,<=*B*. You cannot transform the maps of levels, i.e. rotate or shift them relatively to each other. Your task is to find a way to transfer all the *k* levels and minimize the traffic. The first line contains four integers *n*,<=*m*,<=*k*,<=*w* (1<=≤<=*n*,<=*m*<=≤<=10; 1<=≤<=*k*,<=*w*<=≤<=1000). Then follows the description of *k* levels. Each level is described by *n* lines, each line contains *m* characters. Each character is either a letter of the English alphabet or a dot ("."). Please note that the case of the letters matters. In the first line print the required minimum number of transferred bytes. Then print *k* pairs of integers *x*1,<=*y*1,<=*x*2,<=*y*2,<=...,<=*x**k*,<=*y**k*, describing the way to transfer levels. Pair *x**i*, *y**i* means that level *x**i* needs to be transferred by way *y**i*. If *y**i* equals 0, that means that the level must be transferred using the first way, otherwise *y**i* must be equal to the number of a previously transferred level. It means that you will transfer the difference between levels *y**i* and *x**i* to transfer level *x**i*. Print the pairs in the order of transferring levels. The levels are numbered 1 through *k* in the order they follow in the input. If there are multiple optimal solutions, you can print any of them. Sample Input 2 3 3 2 A.A ... A.a ..C X.Y ... 1 1 4 1 A . B . 1 3 5 2 ABA BBB BBA BAB ABB Sample Output 14 1 0 2 1 3 1 3 1 0 2 0 4 2 3 0 11 1 0 3 1 2 3 4 2 5 1
[ "def put():\r\n return map(int, input().split())\r\ndef diff(x,y):\r\n ans = 0\r\n for i in range(n*m):\r\n if s[x][i]!= s[y][i]:\r\n ans+=1\r\n return ans\r\ndef find(i):\r\n if i==p[i]:\r\n return i\r\n p[i] = find(p[i])\r\n return p[i]\r\ndef union(i,j):\r\n if rank[i]>rank[j]:\r\n i,j = j,i\r\n elif rank[i]==rank[j]:\r\n rank[j]+=1\r\n p[i]= j\r\ndef dfs(i,p):\r\n if i!=0:\r\n print(i,p)\r\n for j in tree[i]:\r\n if j!=p:\r\n dfs(j,i)\r\n\r\nn,m,k,w = put()\r\ns = ['']*k \r\nfor i in range(k):\r\n for j in range(n):\r\n s[i]+=input()\r\nedge = []\r\nk+=1\r\nrank = [0]*(k)\r\np = list(range(k))\r\ncost = 0\r\ntree = [[] for i in range(k)]\r\n\r\nfor i in range(k):\r\n for j in range(i+1,k):\r\n if i==0:\r\n z=n*m\r\n else:\r\n z = diff(i-1,j-1)*w\r\n edge.append((z,i,j))\r\n\r\nedge.sort()\r\nfor z,i,j in edge:\r\n u = find(i)\r\n v = find(j)\r\n if u!=v:\r\n union(u,v)\r\n cost+= z\r\n tree[i].append(j)\r\n tree[j].append(i)\r\n\r\nprint(cost)\r\ndfs(0,-1)\r\n", "import heapq\n\ntotal_bytes = 0\nmessages_sent = []\n\n\ndef send_message(messages, weight, start_ind):\n global total_bytes\n global messages_sent\n\n num_messages = len(messages)\n num_rows = len(messages[1])\n num_cols = len(messages[1][0])\n\n sent = [False] * num_messages\n\n # Send the first message\n total_bytes += num_rows * num_cols\n mst = [\"1 0\"]\n sent[start_ind] = True\n\n queue = []\n start_message = messages[start_ind]\n max_bytes = num_rows * num_cols\n\n for curr_ind in range(1, num_messages):\n curr_message = messages[curr_ind]\n diff = 0\n\n if curr_ind != start_ind:\n for i in range(num_rows):\n for j in range(num_cols):\n if curr_message[i][j] != start_message[i][j]:\n diff += 1\n\n if max_bytes > diff * weight:\n heapq.heappush(queue, (diff * weight, (start_ind, curr_ind)))\n else:\n heapq.heappush(queue, (max_bytes, (0, curr_ind)))\n\n while queue:\n curr_bytes, (prev_ind, curr_ind) = heapq.heappop(queue)\n\n if sent[curr_ind]:\n continue\n\n mst.append(f\"{curr_ind} {prev_ind}\")\n sent[curr_ind] = True\n total_bytes += curr_bytes\n\n curr_message = messages[curr_ind]\n\n for next_ind in range(1, num_messages):\n if next_ind != curr_ind and not sent[next_ind]:\n next_message = messages[next_ind]\n diff = 0\n\n for i in range(num_rows):\n for j in range(num_cols):\n if curr_message[i][j] != next_message[i][j]:\n diff += 1\n\n if max_bytes > diff * weight:\n heapq.heappush(queue, (diff * weight, (curr_ind, next_ind)))\n else:\n heapq.heappush(queue, (max_bytes, (0, next_ind)))\n\n return mst\n\n\ndef main():\n global total_bytes\n global messages_sent\n\n num_rows, num_cols, num_messages, weight = map(int, input().split())\n messages = [[]]\n\n for _ in range(num_messages):\n message = [input() for _ in range(num_rows)]\n messages.append(message)\n\n result = send_message(messages, weight, 1)\n print(total_bytes)\n\n for line in result:\n print(line)\n\n\nif __name__ == \"__main__\":\n main()\n \t \t\t\t\t\t\t\t \t\t \t\t\t\t\t \t \t" ]
{"inputs": ["1 1 4 1\nA\n.\nB\n.", "1 3 5 2\nABA\nBBB\nBBA\nBAB\nABB", "2 2 5 1\n..\nBA\n.A\nB.\n..\nA.\nAB\n.B\n..\n..", "3 3 10 2\nBA.\n..A\n.BB\nB..\n..B\n.AA\nB..\nAB.\n..A\nBAB\n.A.\n.B.\n..B\nA..\n...\n...\n.B.\nBA.\n..B\n.AB\n.B.\nB.A\n.A.\n.BA\n..B\n...\n.A.\n.AA\n..A\n.B.", "3 1 5 1\nB\nA\nB\nA\nA\nB\nA\nA\nA\nA\nA\nA\nA\nA\nA", "3 2 10 1\nAB\nBA\nAB\nAA\nAA\nBA\nAA\nAA\nAB\nAB\nAB\nBA\nBA\nAB\nAA\nBB\nAB\nBA\nBB\nBB\nBA\nAA\nAA\nAB\nAB\nAB\nBA\nBB\nAB\nAA", "2 3 10 2\nABB\nABA\nAAB\nBAB\nAAA\nBBA\nBBB\nBAA\nBBB\nABB\nABA\nBBA\nBBB\nAAB\nABA\nABB\nBBA\nBAB\nBBB\nBBB", "1 1 1 1\n."], "outputs": ["3\n1 0\n2 0\n4 2\n3 0", "11\n1 0\n3 1\n2 3\n4 2\n5 1", "12\n1 0\n2 1\n3 1\n5 3\n4 5", "67\n1 0\n10 1\n2 1\n3 2\n4 1\n7 4\n9 7\n5 9\n6 9\n8 4", "5\n1 0\n2 1\n3 2\n4 3\n5 3", "16\n1 0\n3 1\n8 3\n2 3\n4 2\n9 4\n6 4\n7 6\n10 6\n5 10", "38\n1 0\n5 1\n7 5\n4 7\n9 4\n10 5\n6 1\n3 6\n8 1\n2 0", "1\n1 0"]}
UNKNOWN
PYTHON3
CODEFORCES
2
e34b47ed73a79f95085318930434821b
Special Olympics
A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine. Let us remind you that a ring is a region located between two concentric circles with radii *r* and *R* (*r*<=&lt;<=*R*). These radii are called internal and external, respectively. Concentric circles are circles with centers located at the same point. Soon a white canvas, which can be considered as an infinite Cartesian plane, had two perfect rings, painted with solid black paint. As Sasha is very impulsive, the rings could have different radii and sizes, they intersect and overlap with each other in any way. We know only one thing for sure: the centers of the pair of rings are not the same. When Sasha got tired and fell into a deep sleep, a girl called Ilona came into the room and wanted to cut a circle for the sake of good memories. To make the circle beautiful, she decided to cut along the contour. We'll consider a contour to be a continuous closed line through which there is transition from one color to another (see notes for clarification). If the contour takes the form of a circle, then the result will be cutting out a circle, which Iona wants. But the girl's inquisitive mathematical mind does not rest: how many ways are there to cut a circle out of the canvas? The input contains two lines. Each line has four space-separated integers *x**i*, *y**i*, *r**i*, *R**i*, that describe the *i*-th ring; *x**i* and *y**i* are coordinates of the ring's center, *r**i* and *R**i* are the internal and external radii of the ring correspondingly (<=-<=100<=≤<=*x**i*,<=*y**i*<=≤<=100; 1<=≤<=*r**i*<=&lt;<=*R**i*<=≤<=100). It is guaranteed that the centers of the rings do not coinside. A single integer — the number of ways to cut out a circle from the canvas. Sample Input 60 60 45 55 80 80 8 32 60 60 45 55 80 60 15 25 50 50 35 45 90 50 35 45 Sample Output 140
[ "def okay(xc, yc, rc, xr, yr, rr, Rr):\n d = ((xc-xr) ** 2 + (yc-yr) ** 2) ** 0.5\n if d + rc <= rr:\n return True\n if d >= rc + Rr:\n return True\n if d + Rr <= rc:\n return True\n return False\n\nx1, y1, r1, R1 = map(float, input().split())\nx2, y2, r2, R2 = map(float, input().split())\nans = 0\nif okay(x2, y2, r2, x1, y1, r1, R1):\n ans += 1\nif okay(x2, y2, R2, x1, y1, r1, R1):\n ans += 1\nif okay(x1, y1, r1, x2, y2, r2, R2):\n ans += 1\nif okay(x1, y1, R1, x2, y2, r2, R2):\n ans += 1\nprint (ans)", "def is_intersect(r1, r2, R, x1, y1, x2, y2):\r\n d = (x1 - x2)**2 + (y1 - y2)**2\r\n return d >= (r1 + R)**2 or r1 < r2 and d <= (r2 - r1)**2 or R < r1 and d <= (r1 - R)**2\r\n\r\nx1, y1, r1, R1 = map(int, input().split())\r\nx2, y2, r2, R2 = map(int, input().split())\r\n\r\nres1 = is_intersect(r1, r2, R2, x1, y1, x2, y2)\r\nres2 = is_intersect(R1, r2, R2, x1, y1, x2, y2)\r\nres3 = is_intersect(r2, r1, R1, x2, y2, x1, y1)\r\nres4 = is_intersect(R2, r1, R1, x2, y2, x1, y1)\r\n\r\nprint(res1 + res2 + res3 + res4)\r\n", "from math import sqrt\n\ndef dist(x1,y1,x2,y2):\n\treturn sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1))\n\ndef circleInCircle(x1,y1,r1,x2,y2,r2):\n\tcenterDist = dist(x1,y1,x2,y2)\n\treturn centerDist + r1 <= r2\n\ndef circleOutsideCircle(x1,y1,r1,x2,y2,r2):\n\tcenterDist = dist(x1,y1,x2,y2)\n\n\tif(abs(centerDist + r1) >= r2 and abs(centerDist - r1) >= r2):\n\t\treturn True\n\treturn False\n\n\n# print(circleOutsideCircle(60,60,55 ))\n\n\n\nx1,y1,r1,R1 = [int(i) for i in input().split(\" \")]\nx2,y2,r2,R2 = [int(i) for i in input().split(\" \")]\n\ncount = 0\n\nif circleInCircle(x2,y2,r2 , x1,y1,r1): #circle in inner circle\n\tcount+=1\n\t# print(1)\nif circleInCircle(x2,y2,R2 , x1,y1,r1): #circle in inner circle\n\tcount+=1\n\t# print(2)\n\n\nif circleInCircle(x1,y1,r1 , x2,y2,r2): #circle in inner circle\n\tcount+=1\n\t# print(3)\nif circleInCircle(x1,y1,R1 , x2,y2,r2): #circle in inner circle\n\tcount+=1\n\t# print(4)\n\n\nif circleOutsideCircle(x2,y2,r2 , x1,y1,R1): #circle in outer circle\n\tcount+=1\n\t# print(5)\nif circleOutsideCircle(x2,y2,R2 , x1,y1,R1): #circle in outer circle\n\tcount+=1\n\t# print(6)\n\nif circleOutsideCircle(x1,y1,r1 , x2,y2,R2): #circle in outer circle\n\tcount+=1\n\t# print(7)\nif circleOutsideCircle(x1,y1,R1 , x2,y2,R2): #circle in outer circle\n\tcount+=1\n\t# print(8)\n\n\nprint(count)\n \t \t \t \t \t \t \t \t", "def check(ds,x,r,R):\r\n #x disjoint with R: |d|>=R+x\r\n #R inside x: |d|+R<=x\r\n #x inside r: |d|+x<=r\r\n if (R+x)**2<=ds: return 1\r\n if x>=R and (x-R)**2>=ds: return 1\r\n if r>=x and (r-x)**2>=ds: return 1\r\n return 0\r\n\r\nx1,y1,r1,R1=map(int,input().split())\r\nx2,y2,r2,R2=map(int,input().split())\r\nds = (x1-x2)**2+(y1-y2)**2\r\nans = 0\r\nans += check(ds,r1,r2,R2)\r\nans += check(ds,R1,r2,R2)\r\nans += check(ds,r2,r1,R1)\r\nans += check(ds,R2,r1,R1)\r\nprint(ans)\r\n", "\r\ndef col(d, r, r1, R1):\r\n if r<=r1 and (r1-r)*(r1-r)>=d:\r\n return True\r\n if r >= R1 and (r-R1)*(r-R1)>=d:\r\n return True\r\n if (R1+r)*(R1+r)<=d:\r\n return True\r\n return False\r\n\r\nx1,y1,r1,R1 = map(int, input().split())\r\nx2,y2,r2,R2 = map(int, input().split())\r\nd = ((x1-x2)**2 + (y1-y2)**2)\r\nans = 0\r\nans += col(d, r1, r2, R2)\r\nans += col(d, R1, r2, R2)\r\nans += col(d, r2, r1, R1)\r\nans += col(d, R2, r1, R1)\r\nprint(ans)", "import collections\r\nimport heapq\r\nimport sys\r\nimport math\r\nimport itertools\r\nimport bisect\r\nfrom io import BytesIO, IOBase\r\nimport os\r\n######################################################################################\r\n#--------------------------------------funs here-------------------------------------#\r\n######################################################################################\r\ndef values(): return tuple(map(int, sys.stdin.readline().split()))\r\ndef inlsts(): return [int(i) for i in sys.stdin.readline().split()]\r\ndef inp(): return int(sys.stdin.readline())\r\ndef instr(): return sys.stdin.readline().strip()\r\ndef words(): return [i for i in sys.stdin.readline().strip().split()]\r\ndef chars(): return [i for i in sys.stdin.readline().strip()]\r\n######################################################################################\r\n#--------------------------------------code here-------------------------------------#\r\n######################################################################################\r\ndef check(x1,y1,r1,x2,y2,r2,R2):\r\n d=((x1-x2)**2+(y1-y2)**2)**(0.5)\r\n if r1+R2 <=d:return True\r\n if d+r1<=r2 or d+R2<=r1 :return True\r\n \r\ndef solve():\r\n x1,y1,r1,R1=values()\r\n x2,y2,r2,R2=values()\r\n ans=0\r\n if check( x1,y1,r1,x2,y2,r2,R2):ans+=1\r\n if check( x1,y1,R1,x2,y2,r2,R2):ans+=1\r\n # if check( x1,y1,R1,x2,y2,r2):ans+=1\r\n # if check( x1,y1,R1,x2,y2,R2):ans+=1\r\n\r\n # if check( x2,y2,r2,x1,y1,r1):ans+=1 #1\r\n # if check( x2,y2,R2,x1,y1,r1):ans+=1\r\n if check( x2,y2,r2,x1,y1,r1,R1):ans+=1 #2\r\n if check( x2,y2,R2,x1,y1,r1,R1):ans+=1\r\n \r\n\r\n \r\n\r\n print(ans)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n # for i in range(inp()):\r\n solve()\r\n", "((x,y,r,R), (u,v,w,W))=[map(int, input().split()) for _ in range(2)]\nd = (x-u) ** 2 + (y - v) ** 2\n\ndef t(a,b,c):\n if c <= a and (a-c)**2 >= d:\n return 1\n if c >= b and (c-b)**2 >= d:\n return 1\n if (b+c) ** 2 <= d:\n return 1\n return 0\nprint(t(r,R,w) + t(r,R,W) + t(w,W,r) + t(w,W,R))\n \t\t \t \t \t \t\t\t \t\t \t \t\t" ]
{"inputs": ["60 60 45 55\n80 80 8 32", "60 60 45 55\n80 60 15 25", "50 50 35 45\n90 50 35 45", "0 0 50 70\n1 0 60 80", "0 0 1 2\n10 0 2 20", "31 13 22 95\n48 63 21 98", "31 40 37 76\n48 65 66 98", "-65 -81 37 76\n48 65 66 98", "41 -14 37 76\n48 65 66 98", "41 -14 16 100\n48 17 37 66", "-75 -9 20 40\n25 55 99 100", "-45 6 20 40\n35 6 99 100", "-3 84 20 40\n76 96 96 100", "10 -91 20 40\n70 -91 79 100", "-64 -47 20 40\n-5 -37 79 100", "-63 97 20 40\n-34 97 11 48", "-67 47 20 40\n-38 47 11 49", "-100 -91 20 40\n-71 -91 11 68", "45 -76 20 40\n69 -69 15 65", "12 -43 20 40\n41 -43 11 97", "10 71 20 40\n39 78 10 49", "56 44 20 40\n83 44 12 13", "-20 78 20 40\n8 85 10 11", "65 -9 20 40\n94 -9 10 49", "-84 -59 20 40\n-74 -59 29 30", "33 -37 20 40\n42 -37 28 29", "-25 10 20 40\n4 17 10 69", "13 32 20 40\n42 32 10 69", "-12 -1 20 40\n-3 -1 28 31", "48 30 20 40\n77 37 10 99", "47 -50 20 40\n56 -46 28 30", "-26 -65 20 40\n52 -65 98 100", "-46 36 20 40\n14 36 80 100", "19 96 20 40\n77 96 78 99", "-42 -44 20 40\n-32 -44 30 48", "83 -23 20 40\n93 -23 30 50", "-100 -97 20 40\n-90 -97 30 100", "65 16 20 40\n74 16 29 48", "-66 78 20 40\n-62 81 25 45", "-11 63 20 40\n-2 63 29 31", "91 -59 20 40\n100 -59 29 100", "39 90 20 40\n47 90 28 31", "-100 40 20 40\n-81 40 1 38", "24 -24 20 40\n43 -24 1 21", "-8 35 20 40\n11 35 1 19", "-52 -94 20 40\n-33 -94 1 39", "61 2 20 40\n67 10 10 30", "49 -67 20 40\n57 -67 12 28", "65 17 20 40\n84 17 1 58", "-16 -18 20 40\n3 -18 1 59", "24 -16 20 40\n33 -16 11 31", "-83 96 20 40\n-64 96 1 98", "-10 89 20 40\n-2 89 12 29", "-40 -69 20 40\n60 -69 80 100", "-70 66 20 40\n8 66 58 98", "-11 -97 20 40\n67 -97 58 100", "-60 60 20 40\n0 60 40 100", "0 73 20 40\n59 73 39 100", "28 -91 20 40\n58 -91 10 49", "75 72 20 40\n99 90 10 50", "-84 74 20 40\n-54 74 10 63", "35 -6 20 40\n59 12 10 70", "67 41 20 40\n97 41 10 98", "-27 -68 20 40\n2 -68 9 48", "50 13 20 40\n78 13 8 12", "-73 36 20 40\n-44 36 9 10", "70 92 20 40\n99 92 9 49", "37 -80 20 40\n66 -80 9 66", "8 -95 20 40\n36 -95 8 68", "-9 77 20 40\n20 77 9 100", "-37 20 20 40\n41 31 99 100", "-36 28 20 40\n24 28 99 100", "-77 -16 20 40\n-18 -6 99 100", "-65 24 20 40\n-6 24 99 100", "-55 23 20 40\n-46 23 31 48", "-37 18 20 40\n-30 18 33 47", "-45 -93 20 40\n-36 -93 31 99", "-97 -29 20 40\n-39 -19 99 100", "14 18 20 40\n23 22 30 49", "-90 -38 20 40\n-81 -38 30 49", "52 -4 20 40\n61 -4 30 31", "-54 46 20 40\n-45 50 30 98", "74 -34 20 40\n82 -30 30 31", "23 -61 20 40\n41 -55 1 37", "57 -86 20 40\n75 -86 1 22", "-38 43 20 40\n-20 49 1 20", "-19 10 20 40\n-2 10 2 37", "64 58 20 40\n74 58 7 30", "53 49 20 40\n62 49 10 29", "53 80 20 40\n70 80 2 3", "73 -41 20 40\n91 -35 1 49", "-8 -34 20 40\n9 -34 2 57", "51 -40 20 40\n60 -40 9 31", "-29 87 20 40\n-11 93 1 94", "-64 3 20 40\n-55 7 6 30", "24 36 20 40\n41 39 1 2", "-56 -64 20 40\n44 2 96 100", "-59 -17 20 40\n21 -17 59 100", "-43 -3 20 40\n57 -3 79 80", "20 57 20 40\n99 69 58 100", "36 82 20 40\n96 82 38 100", "-55 37 20 40\n4 47 38 100", "-58 -4 20 40\n42 91 99 100", "28 51 20 40\n67 51 1 58", "-79 -62 20 40\n-41 -62 2 58", "-19 -10 20 40\n20 -10 1 19", "-95 -64 20 40\n-56 -64 1 78", "-17 -7 20 40\n22 -7 1 79", "-45 86 20 40\n-6 86 1 99", "-71 -23 20 40\n-32 -23 1 18", "-20 11 20 40\n80 11 60 100", "-27 97 20 40\n51 97 38 98", "-47 -84 20 40\n52 -64 61 81", "-81 99 20 40\n-3 99 38 99", "-54 25 20 40\n6 25 20 100", "-22 40 20 40\n36 40 18 100", "-71 15 20 40\n29 90 85 100", "31 -13 20 40\n69 -5 1 56", "-46 55 20 40\n-17 55 7 11", "-35 25 20 40\n-6 32 7 10", "27 -98 20 40\n65 -98 1 58", "-100 -19 20 40\n-62 -19 1 18", "48 66 20 40\n78 66 9 10", "-37 -22 20 40\n-8 -22 8 9", "-42 41 20 40\n-4 49 1 78", "-2 -27 20 40\n35 -27 1 77", "-28 -36 20 40\n10 -28 1 100", "-17 31 20 40\n21 39 1 14", "1 44 20 40\n39 44 1 2", "21 -99 20 40\n58 -97 1 2", "-86 -97 20 40\n14 -31 79 100", "-33 42 20 40\n47 42 39 100", "-79 45 20 40\n21 45 57 80", "-99 -66 20 40\n-20 -54 39 100", "39 -44 20 40\n99 -44 17 100", "10 86 20 40\n69 96 19 100", "-72 -4 20 40\n28 93 99 100", "-81 -55 20 40\n19 20 83 85", "-65 -34 20 40\n35 66 99 100", "-91 -46 10 50\n-73 -40 30 31"], "outputs": ["1", "4", "0", "2", "2", "0", "0", "4", "0", "1", "0", "0", "0", "1", "1", "0", "0", "0", "1", "1", "0", "1", "1", "0", "1", "1", "0", "1", "1", "1", "1", "1", "2", "2", "1", "2", "2", "1", "2", "2", "2", "2", "1", "2", "2", "1", "2", "2", "1", "2", "2", "2", "2", "0", "0", "0", "1", "1", "0", "0", "0", "1", "1", "0", "1", "1", "0", "0", "1", "1", "1", "2", "2", "4", "1", "2", "2", "4", "1", "2", "2", "2", "2", "1", "2", "2", "1", "2", "2", "4", "1", "2", "2", "2", "2", "4", "0", "0", "1", "0", "1", "1", "1", "0", "0", "1", "0", "1", "1", "1", "1", "1", "2", "1", "2", "2", "2", "0", "1", "1", "0", "1", "2", "2", "0", "1", "1", "1", "2", "2", "1", "1", "2", "1", "2", "2", "2", "4", "4", "2"]}
UNKNOWN
PYTHON3
CODEFORCES
7
e3545ed51cba0620cc82f0844cfe967d
Fifa and Fafa
Fifa and Fafa are sharing a flat. Fifa loves video games and wants to download a new soccer game. Unfortunately, Fafa heavily uses the internet which consumes the quota. Fifa can access the internet through his Wi-Fi access point. This access point can be accessed within a range of *r* meters (this range can be chosen by Fifa) from its position. Fifa must put the access point inside the flat which has a circular shape of radius *R*. Fifa wants to minimize the area that is not covered by the access point inside the flat without letting Fafa or anyone outside the flat to get access to the internet. The world is represented as an infinite 2D plane. The flat is centered at (*x*1,<=*y*1) and has radius *R* and Fafa's laptop is located at (*x*2,<=*y*2), not necessarily inside the flat. Find the position and the radius chosen by Fifa for his access point which minimizes the uncovered area. The single line of the input contains 5 space-separated integers *R*,<=*x*1,<=*y*1,<=*x*2,<=*y*2 (1<=≤<=*R*<=≤<=105, |*x*1|,<=|*y*1|,<=|*x*2|,<=|*y*2|<=≤<=105). Print three space-separated numbers *x**ap*,<=*y**ap*,<=*r* where (*x**ap*,<=*y**ap*) is the position which Fifa chose for the access point and *r* is the radius of its range. Your answer will be considered correct if the radius does not differ from optimal more than 10<=-<=6 absolutely or relatively, and also the radius you printed can be changed by no more than 10<=-<=6 (absolutely or relatively) in such a way that all points outside the flat and Fafa's laptop position are outside circle of the access point range. Sample Input 5 3 3 1 1 10 5 5 5 15 Sample Output 3.7677669529663684 3.7677669529663684 3.914213562373095 5.0 5.0 10.0
[ "import math\r\n\r\nR, x1, y1, x2, y2 = map(int, input().split(' '))\r\ndistance = math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))\r\nif distance >= R:\r\n print(x1, y1, R, sep=' ')\r\nelif x1 == x2 and y1 == y2:\r\n r = R / 2\r\n x = x1 + R / 2\r\n y = y1\r\n print(x, y, r, sep=' ')\r\nelse:\r\n r = (R + distance) / 2\r\n x = (x1 * (R + distance) - x2 * (R - distance)) / (2 * distance)\r\n y = (y1 * (R + distance) - y2 * (R - distance)) / (2 * distance)\r\n print(x, y, r, sep=' ')\r\n ", "r, xc, yc, xf, yf = [int(i) for i in input().split()]\r\nt = ((xf - xc) ** 2 + (yf - yc) ** 2) ** 0.5\r\nif t >= r:\r\n print(xc, yc, r)\r\n exit()\r\nelif xc == xf:\r\n if yf > yc:\r\n print(xc, (yc - r + yf) / 2, (t + r) / 2)\r\n else:\r\n print(xc, (yc + r + yf) / 2, (t + r) / 2)\r\n \r\n exit()\r\n\r\nk = (yc - yf) / (xc - xf)\r\nb = yf - k * xf\r\n\r\na, B, c = (k ** 2 + 1), (2 * b * k - 2 * xc - 2 * k * yc), b ** 2 - 2 * b * yc - r ** 2 + xc ** 2 + yc ** 2\r\nd = (B ** 2 - 4 * a * c) ** 0.5\r\nx1, x2 = (-B + d) / (2 * a), (-B - d) / (2 * a)\r\n\r\nif xf > xc:\r\n x = min(x1, x2)\r\nelse:\r\n x = max(x1, x2)\r\n\r\ny = k * x + b\r\nx = (x + xf) / 2\r\ny = (y + yf) / 2\r\n\r\nprint(x, y, (t + r) / 2)", "r,x,y,u,v=map(int,input().split())\r\nu-=x;v-=y\r\nd=(u*u+v*v)**.5\r\nif d<r:\r\n r=(r+d)/2\r\n if d:\r\n k=r/d-1;x-=u*k;y-=v*k\r\n else:y+=r\r\nprint(x,y,r)\r\n", "from math import *\r\nr,x1,y1,x2,y2=list(map(int,input().split()))\r\nif (x2-x1)**2+(y2-y1)**2>=r**2:\r\n\tval=r\r\n\tprint(x1,y1,val)\r\nelse:\r\n\trad=(r+sqrt(pow(x2-x1,2)+pow(y2-y1,2)))/2\r\n\tdist=sqrt((pow(x2-x1,2)+pow(y2-y1,2)))\r\n\tm=rad-dist\r\n\tif dist!=0:\r\n\t\tx=((m+dist)*x1-(m)*x2)/dist\r\n\t\ty=((m+dist)*y1-(m)*y2)/dist\r\n\telse:\r\n\t\tx=x1+r/2\r\n\t\ty=y1\r\n\t\trad=0.5*r\r\n\tprint(x,y,rad)", "from math import dist, sin, cos, atan2\r\n\r\nR, x1, y1, x2, y2 = map(float, input().split())\r\n\r\nans = (-1,)\r\n\r\n# Check if Fafa is inside the flat\r\nif dist((x1, y1), (x2, y2)) <= R:\r\n a = atan2(x1-x2,y1-y2)\r\n x3, y3 = x1 + R * sin(a), y1 + R * cos(a)\r\n mx, my = (x2 + x3) / 2, (y2 + y3) / 2\r\n r = dist((x2,y2), (x3,y3)) / 2\r\n ans = (mx, my, r)\r\n# Otherwise we can take the whole flat\r\nelse:\r\n ans = (x1, y1, R)\r\nprint(*map(round, ans, [9]*3))", "import math\r\nroom_r, room_x, room_y, fx, fy = list(map(int, input().split()))\r\n\r\nmidx = 0\r\nmidy = 0\r\nmid = 0\r\n\r\nif (room_x == fx and room_y == fy):\r\n print(room_x + (room_r)/2, room_y, room_r/2)\r\n exit(0)\r\n\r\n\r\nd = math.dist([room_x, room_y], [fx, fy])\r\n\r\nif d >= room_r:\r\n print(room_x, room_y, room_r)\r\n exit(0)\r\nelse:\r\n m = (d + room_r)/2\r\n midx = fx - m * (fx - room_x)/d\r\n midy = fy - m * (fy - room_y)/d\r\n mid = m\r\n\r\n\r\n\r\n\r\nprint(midx,midy,mid)\r\n", "r, x, y, u, v = map(int, input().split())\r\nu -= x\r\nv -= y\r\nd = (u*u+v*v)**.5\r\nif d < r:\r\n r = (r+d)/2\r\n if d:\r\n k = r/d-1\r\n x -= u*k\r\n y -= v*k\r\n else:\r\n y += r\r\nprint(x, y, r)\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\nr, x1, y1, x2, y2 = map(int, input().split())\r\n\r\na = ((x2-x1)**2 + (y2-y1)**2)**0.5\r\nif a >= r:\r\n print(x1, y1, r)\r\nelse:\r\n q = (a+r)/2\r\n if a == 0:\r\n u = x2 + q\r\n v = y2\r\n else:\r\n u = x2 + (x1-x2)/a*q\r\n v = y2 + (y1-y2)/a*q\r\n print(u, v, q)\r\n" ]
{"inputs": ["5 3 3 1 1", "10 5 5 5 15", "5 0 0 0 7", "10 0 0 0 0", "100000 100000 100000 10000 10000", "100000 -100000 100000 -10000 100000", "1 0 0 0 -1", "100000 83094 84316 63590 53480", "1 0 0 0 0", "1 0 0 -2 -2", "10 0 0 4 0", "82 1928 -30264 2004 -30294", "75 -66998 89495 -66988 89506", "11 9899 34570 9895 34565", "21 7298 -45672 7278 -45677", "31 84194 -71735 84170 -71758", "436 25094 -66597 25383 -66277", "390 -98011 78480 -98362 78671", "631 -21115 -1762 -21122 -1629", "872 55782 51671 54965 51668", "519 -92641 -28571 -92540 -28203", "3412 23894 22453 26265 25460", "3671 -99211 -3610 -99825 -1547", "3930 -76494 -83852 -78181 -81125", "4189 -24915 61224 -28221 65024", "8318 -2198 35161 3849 29911", "15096 -12439 58180 -10099 50671", "70343 64457 3256 83082 -17207", "66440 -58647 -76987 2151 -40758", "62537 18249 96951 -3656 54754", "88209 95145 42027 21960 26111", "100000 -100000 -100000 -100000 -100000", "100000 100000 100000 100000 100000", "2 0 0 0 1", "1 1 0 1 0", "2 3 3 3 3", "1 1 1 1 1", "10 1 1 1 1", "10 5 5 5 10", "5 0 0 0 0"], "outputs": ["3.7677669529663684 3.7677669529663684 3.914213562373095", "5.0 5.0 10.0", "0 0 5", "5.0 0.0 5.0", "100000 100000 100000", "-105000.0 100000.0 95000.0", "0.0 0.0 1.0", "100069.69149822203 111154.72144376408 68243.2515742123", "0.5 0.0 0.5", "0 0 1", "-3.0 0.0 7.0", "1927.8636359254158 -30263.946172075823 81.85339643163098", "-67018.22522977486 89472.75224724766 44.933034373659254", "9900.435822761548 34571.794778451935 8.701562118716424", "7298.186496251526 -45671.95337593712 20.80776406404415", "84194 -71735 31", "25092.386577687754 -66598.78648837341 433.5927874489312", "-98011 78480 390", "-21101.91768814977 -2010.563925154407 382.0920415665416", "55809.49706065544 51671.100968398976 844.502753968685", "-92659.18165738975 -28637.246038806206 450.30421903092184", "23894 22453 3412", "-98994.40770099283 -4337.736014416596 2911.7161725229744", "-76303.71953677801 -84159.58436467478 3568.316718555632", "-24915 61224 4189", "-2315.0277877457083 35262.60342081445 8163.0201360632545", "-13514.641370727473 61631.70557811649 11480.578066612283", "50095.092392996106 19035.206193939368 49006.464709026186", "-58647 -76987 66440", "21702.922094423477 103604.5106422455 55040.41533091097", "101649.61478542663 43441.59928844504 81552.34132964142", "-50000.0 -100000.0 50000.0", "150000.0 100000.0 50000.0", "0.0 -0.5 1.5", "1.5 0.0 0.5", "4.0 3.0 1.0", "1.5 1.0 0.5", "6.0 1.0 5.0", "5.0 2.5 7.5", "2.5 0.0 2.5"]}
UNKNOWN
PYTHON3
CODEFORCES
8
e359e5399b15238079e2f37af9c7990d
Petya and File System
Recently, on a programming lesson little Petya showed how quickly he can create files and folders on the computer. But he got soon fed up with this activity, and he decided to do a much more useful thing. He decided to calculate what folder contains most subfolders (including nested folders, nested folders of nested folders, and so on) and what folder contains most files (including the files in the subfolders). More formally, the subfolders of the folder are all its directly nested folders and the subfolders of these nested folders. The given folder is not considered the subfolder of itself. A file is regarded as lying in a folder, if and only if it either lies directly in this folder, or lies in some subfolder of the folder. For a better understanding of how to count subfolders and files for calculating the answer, see notes and answers to the samples. You are given a few files that Petya has managed to create. The path to each file looks as follows: *diskName*:\*folder*1\*folder*2\...\ *folder**n*\*fileName* - *diskName* is single capital letter from the set {C,D,E,F,G}.- *folder*1, ..., *folder**n* are folder names. Each folder name is nonempty sequence of lowercase Latin letters and digits from 0 to 9. (*n*<=≥<=1)- *fileName* is a file name in the form of *name*.*extension*, where the *name* and the *extension* are nonempty sequences of lowercase Latin letters and digits from 0 to 9. It is also known that there is no file whose path looks like *diskName*:\*fileName*. That is, each file is stored in some folder, but there are no files directly in the root. Also let us assume that the disk root is not a folder. Help Petya to find the largest number of subfolders, which can be in some folder, and the largest number of files that can be in some folder, counting all its subfolders. Each line of input data contains the description of one file path. The length of each line does not exceed 100, and overall there are no more than 100 lines. It is guaranteed, that all the paths are correct and meet the above rules. It is also guaranteed, that there are no two completely equal lines. That is, each file is described exactly once. There is at least one line in the input data. Print two space-separated numbers. The first one is the maximal number of possible subfolders in a folder (including nested folders, nested folders of nested folders, and so on). The second one is the maximal number of files in a folder (including nested files in subfolders). Note that the disks are not regarded as folders. Sample Input C:\folder1\file1.txtC:\folder1\folder2\folder3\file1.txt C:\folder1\folder2\folder4\file1.txt D:\folder1\file1.txt C:\file\file\file\file\file.txt C:\file\file\file\file2\file.txt Sample Output 0 13 24 2
[ "from collections import *\nfrom sys import *\n\ntxt = stdin.readlines()\nfor i in range(len(txt)):\n txt[i] = txt[i][:-1].replace(':\\\\', ':').split('\\\\')\nfile = Counter([s[0] for s in txt])\nfolder = defaultdict(set)\nfor i in txt:\n for j in range(2, len(i)):\n folder[i[0]].add('\\\\'.join(i[1:j]))\nprint(max([len(i) for i in folder.values()]+[0]), max(file.values()))\n \t\t \t\t \t \t \t \t\t \t\t \t\n \t\t\t \t \t \t \t \t \t \t\t\t", "s = []\r\nfiles = {}\r\nfolders = {}\r\n\r\nfor _ in range(101):\r\n try: a = input()\r\n except EOFError : break\r\n s.append(a)\r\n b = a.split(\"\\\\\")\r\n for i in range(2 ,len(b)):\r\n path = tuple(b[:i])\r\n if(path not in files):\r\n files[path] = 0\r\n folders[path] = set()\r\n files[path] += 1\r\n for j in range(i + 1 ,len(b)):\r\n path2 = tuple(b[:j])\r\n folders[path].add(path2)\r\n\r\nprint(f'{max([len(x) for x in folders.values()])} {max(files.values())}')\r\n\r\n\r\n", "import sys\r\n\r\ndef main():\r\n path_set = set()\r\n is_created = {}\r\n storage = {}\r\n freq_folders = {}\r\n folder_recorded = {}\r\n\r\n for path in sys.stdin:\r\n path = path.strip()\r\n if path in path_set:\r\n continue\r\n\r\n path_set.add(path)\r\n\r\n if path not in is_created:\r\n is_created[path] = True\r\n\r\n disk, dir = path.split(\":\", 1)[0], path.split(\":\", 1)[1]\r\n dir = dir.lstrip(\"\\\\\")\r\n\r\n root = \"\"\r\n inserted_file = 0\r\n length = len(dir)\r\n\r\n if disk not in storage:\r\n storage[disk] = {}\r\n freq_folders[disk] = {}\r\n folder_recorded[disk] = {}\r\n\r\n for i in range(length):\r\n root += dir[i]\r\n\r\n if dir[i] == \"\\\\\":\r\n current_folder = root + \"\\\\\"\r\n current_root = freq_folders[disk]\r\n current_root_record = folder_recorded[disk]\r\n\r\n if root not in storage[disk]:\r\n current_root[root] = 0\r\n storage[disk][root] = 0\r\n\r\n storage[disk][root] += 1\r\n\r\n for j in range(i + 1, length):\r\n current_folder += dir[j]\r\n\r\n if dir[j] == \"\\\\\" and current_folder not in current_root_record:\r\n current_root[root] += 1\r\n current_root_record[current_folder] = True\r\n\r\n break\r\n\r\n max_files = 0\r\n max_folders = 0\r\n\r\n for p in storage.values():\r\n for freq in p.values():\r\n max_files = max(max_files, freq)\r\n\r\n for freq_disk in freq_folders.values():\r\n for freq in freq_disk.values():\r\n max_folders = max(max_folders, freq)\r\n\r\n print(max_folders, max_files)\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "import sys\r\nfiles,folder_subfolder = {},{}\r\npaths = sys.stdin.readlines()\r\nfor line in paths:\r\n path = line.split('\\\\')\r\n path_length = len(path)\r\n headOFpath = path[0] + path[1]; interim = headOFpath\r\n if headOFpath not in folder_subfolder:\r\n # To collect the folder and the files\r\n folder_subfolder[headOFpath] = []\r\n files[headOFpath] = []\r\n for i in range(2,path_length):\r\n if i+1 == path_length:\r\n # appends the file, with the whole path, to the head of the path\r\n files[headOFpath].append(interim+path[i])\r\n else:\r\n interim+=path[i]\r\n # appends every increment of the path\r\n folder_subfolder[headOFpath].append(interim)\r\nmyfiles,myfolders = 0,0\r\nfor f in folder_subfolder:\r\n # the sets ensure that a duplicate path doesn't occur\r\n # the length contains the folders and subfolders\r\n myfiles = max(len(set(files[f])),myfiles)\r\n myfolders = max(len(set(folder_subfolder[f])),myfolders)\r\nprint (myfolders,myfiles)\r\n\r\n", "\r\nimport sys\r\n\r\ndic = {}\r\nmp = {}\r\n\r\nx = {}\r\n#n = int(input())\r\n#for i in range(n):\r\nfor si in sys.stdin:\r\n #si = input()\r\n si = si.strip()\r\n ar = si.split('\\\\')\r\n s=\"\"\r\n if ar[0] not in dic:\r\n dic[ar[0]]={};\r\n #print(ar)\r\n #print(dic)\r\n if ar[1] not in dic[ar[0]]:\r\n dic[ar[0]][ar[1]]=[0,0]\r\n s = ar[0]+ar[1]\r\n #print(dic[ar[0]][ar[1]])\r\n for i in range(2,len(ar)-1):\r\n if s+ar[i] not in mp:\r\n mp[s+ar[i]] = 1\r\n \r\n dic[ar[0]][ar[1]][0]+=1\r\n #print(s)\r\n s+=ar[i]\r\n #print(s+ar[len(ar)-1])\r\n if s+ar[len(ar)-1] not in mp:\r\n s+=ar[len(ar)-1]\r\n mp[s]=1\r\n dic[ar[0]][ar[1]][1]+=1\r\n\r\nma = [-1,0]\r\n#print(dic)\r\nfor x in dic:\r\n for y in dic[x]:\r\n if ma[0]<dic[x][y][0]:\r\n ma = dic[x][y]\r\n else:\r\n if ma[0]==dic[x][y][0]:\r\n if ma[1]<dic[x][y][1]:\r\n ma = dic[x][y]\r\nprint(*ma)\r\n \r\n \r\n\r\n \r\n", "import sys\r\nfrom array import array # noqa: F401\r\nfrom collections import defaultdict\r\n\r\n\r\ndef input():\r\n return sys.stdin.buffer.readline().decode('utf-8')\r\n\r\n\r\ncnt1 = defaultdict(set)\r\ncnt2 = defaultdict(int)\r\n\r\nfor line in sys.stdin:\r\n path = line.rstrip().split('\\\\')\r\n key = tuple(path[:2])\r\n for i in range(3, len(path)):\r\n cnt1[key].add(tuple(path[2:i]))\r\n cnt2[key] += 1\r\n\r\nans1 = max((len(s) for s in cnt1.values()), default=0)\r\nans2 = max(cnt2.values(), default=0)\r\nprint(ans1, ans2)\r\n", "#################\r\n# July 21st 2019.\r\n#################\r\n\r\n#############################################################################\r\n# Directory class definition.\r\nclass Directory:\r\n # Method to get recursive sub-directory count.\r\n def getSubDirCount(self):\r\n return self.subdirCount;\r\n # Method to get recursive file count.\r\n def getFileCount(self):\r\n return self.fileCount;\r\n # Method to add new sub-directory.\r\n def addSubDir(self,name):\r\n self.subdirs[name] = Directory(name)\r\n # Method to add new file.\r\n def addFile(self,name):\r\n self.files[name] = name\r\n # Method to calculate sub-folders.\r\n def calculateSubDirs(self):\r\n count,keys = 0,list(self.subdirs.keys())\r\n for key in keys:\r\n count+=self.subdirs[key].getSubDirCount()\r\n self.subdirCount = count + len(keys)\r\n def __init__(self,name):\r\n # Recursive counts of folders and files.\r\n self.subdirCount,self.fileCount = 0,0\r\n # For Storing files and sub-directries.\r\n self.subdirs,self.files = {},{}\r\n # For Storing name of this director.\r\n self.name = name\r\n#############################################################################\r\n# Method to perform Tree Insertion.\r\ndef insertIntoTree(directory,path):\r\n # Increasing file Count.\r\n directory.fileCount+=1;\r\n # Extracting name from queue.\r\n name = path.pop(0)\r\n # Defining Base-Case i.e File is reached.\r\n if len(path) == 0:\r\n directory.addFile(name); return\r\n # Defining Inductive-Case.\r\n else:\r\n # A New Directory is required.\r\n if not name in directory.subdirs:\r\n directory.addSubDir(name)\r\n # Navigating to directory.\r\n insertIntoTree(directory.subdirs[name],path)\r\n # Updating recursive sub-drectory and file counts.\r\n directory.calculateSubDirs();\r\n#############################################################################\r\n# Collecting paths from codeforces and performing insertion.\r\nfrom sys import stdin\r\nfileTree = Directory('root')\r\nfor path in stdin:\r\n insertIntoTree(fileTree,path.split('\\\\'))\r\n# Determining Maximal folders and file counts.\r\nmaxFolders,maxFiles = -1,-1\r\nfor drive in list(fileTree.subdirs.keys()):\r\n for directories in list(fileTree.subdirs[drive].subdirs.keys()):\r\n a = fileTree.subdirs[drive].subdirs[directories].getSubDirCount()\r\n b = fileTree.subdirs[drive].subdirs[directories].getFileCount()\r\n maxFolders = max(maxFolders,a)\r\n maxFiles = max(maxFiles,b)\r\nprint(str(maxFolders)+\" \"+str(maxFiles))\r\n#############################################################################\r\n\r\n ########################################\r\n # Programming-Credits atifcppprogrammer.\r\n ########################################\r\n", "import sys\r\n\r\nsys.setrecursionlimit(int(1e4)) \r\n\r\nclass TrieVertex:\r\n\tdef __init__(self, folder):\r\n\t\tself.child = dict()\r\n\t\tself.files = set()\r\n\t\tself.folder = folder\r\n\r\ndef add(v, path, k):\r\n\tif k==len(path)-1:\r\n\t\tv.files.add(path[k])\r\n\t\treturn \r\n\tif path[k] not in v.child:\r\n\t\tv.child[path[k]] = TrieVertex(path[k])\r\n\tadd(v.child[path[k]], path, k+1)\r\n\r\ndef dfs(v, cntSubs, cntFiles, cur):\r\n\ts = str(cur) + '-' + v.folder\r\n\tcntSubs[s] = 0\r\n\tcntFiles[s] = len(v.files)\r\n\tfor subFolder in v.child:\r\n\t\tsubs, files = dfs(v.child[subFolder], cntSubs, cntFiles, cur+1)\r\n\t\tcntSubs[s] += subs \r\n\t\tcntFiles[s] += files\r\n\treturn cntSubs[s]+1, cntFiles[s]\r\n\r\nroots = dict()\r\nfor line in sys.stdin:\r\n\tpath = line.split('\\\\')\r\n\tif path[0] in roots:\r\n\t\tadd(roots[path[0]], path, 1)\r\n\telse:\r\n\t\tv = TrieVertex(path[0])\r\n\t\tadd(v, path, 1)\r\n\t\troots[path[0]] = v\r\n\r\nans = [0 for _ in range(2)] \r\nfor disk in roots:\r\n\tcntSubs, cntFiles = dict(), dict()\r\n\tsubs, files = dfs(roots[disk], cntSubs, cntFiles, 0)\r\n\tfor folder in cntSubs:\r\n\t\tif folder[len(folder)-1] == ':': continue\r\n\t\tans[0] = max(ans[0], cntSubs[folder])\r\n\tfor folder in cntFiles:\r\n\t\tif folder[len(folder)-1] == ':': continue\r\n\t\tans[1] = max(ans[1], cntFiles[folder])\r\n\r\nprint(ans[0], ans[1])", "is_file = dict()\r\nedges = dict()\r\nused = dict()\r\ndirs_count = dict()\r\nfiles_count = dict()\r\n\r\ndef dfs(key):\r\n dirs_count[key] = 1 - is_file.get(key, 0)\r\n files_count[key] = is_file.get(key, 0)\r\n used.setdefault(key, 1)\r\n for v in edges[key]:\r\n if used.get(v, 0) == 0:\r\n dfs(v)\r\n dirs_count[key] += dirs_count[v]\r\n files_count[key] += files_count[v]\r\n\r\nwhile True:\r\n try:\r\n text = input()\r\n except:\r\n break\r\n\r\n splited = text.split('\\\\')\r\n n = len(splited)\r\n for i in range(2, n):\r\n t1 = '\\\\'.join(splited[0:i])\r\n t2 = '\\\\'.join(splited[0:(i + 1)])\r\n edges.setdefault(t1, list())\r\n edges.setdefault(t2, list())\r\n edges[t1].append(t2)\r\n edges[t2].append(t1)\r\n \r\n is_file.setdefault(text, 1)\r\n\r\nfor key in edges:\r\n if used.get(key, 0) == 0:\r\n dfs(key)\r\n\r\nmax_dirs = 0\r\nmax_files = 0\r\n\r\nfor key, value in dirs_count.items():\r\n max_dirs = max(max_dirs, value - 1)\r\n\r\nfor key, value in files_count.items():\r\n max_files = max(max_files, value)\r\n\r\nprint(max_dirs, max_files)\r\n" ]
{"inputs": ["C:\\folder1\\file1.txt", "C:\\folder1\\folder2\\folder3\\file1.txt\nC:\\folder1\\folder2\\folder4\\file1.txt\nD:\\folder1\\file1.txt", "C:\\file\\file\\file\\file\\file.txt\nC:\\file\\file\\file\\file2\\file.txt", "C:\\file\\file.txt\nD:\\file\\file.txt\nE:\\file\\file.txt\nF:\\file\\file.txt\nG:\\file\\file.txt", "C:\\a\\b\\c\\d\\d.txt\nC:\\a\\b\\c\\e\\f.txt", "C:\\z\\z.txt\nD:\\1\\1.txt\nD:\\1\\2.txt", "D:\\0000\\1.txt\nE:\\00000\\1.txt", "C:\\a\\b\\c\\d.txt\nC:\\a\\e\\c\\d.txt", "C:\\test1\\test2\\test3\\test.txt\nC:\\test1\\test3\\test3\\test4\\test.txt\nC:\\test1\\test2\\test3\\test2.txt\nD:\\test1\\test2\\test.txt\nD:\\test1\\test3\\test4.txt", "C:\\test1\\test2\\test.txt\nC:\\test1\\test2\\test2.txt"], "outputs": ["0 1", "3 2", "4 2", "0 1", "4 2", "0 2", "0 1", "4 2", "5 3", "1 2"]}
UNKNOWN
PYTHON3
CODEFORCES
9
e35b59696236a1f3116b78369f8d714a
Petya and Catacombs
A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs. Catacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute *i*, he makes a note in his logbook with number *t**i*: - If Petya has visited this room before, he writes down the minute he was in this room last time; - Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute *i*. Initially, Petya was in one of the rooms at minute 0, he didn't write down number *t*0. At some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook? The first line contains a single integer *n* (1<=≤<=*n*<=≤<=2·105) — then number of notes in Petya's logbook. The second line contains *n* non-negative integers *t*1,<=*t*2,<=...,<=*t**n* (0<=≤<=*t**i*<=&lt;<=*i*) — notes in the logbook. In the only line print a single integer — the minimum possible number of rooms in Paris catacombs. Sample Input 2 0 0 5 0 1 0 1 3 Sample Output 2 3
[ "n = int(input())\ntmp = list(map(int, input().split()))\n\nt = [0] * (n + 1)\nfor x in tmp:\n t[x] = 1\n\ncount = 1\nfor i in range(n):\n if not t[i]:\n count += 1\n\nprint(count)\n", "# _\r\n#####################################################################################################################\r\n\r\nprint(int(input()) + 1 - len(set(input().split())))\r\n", "n = int(input())\r\nx = list(map(int,input().split()))\r\n#memset(x,-1,sizeof(x))\r\n#x[0] = 1\r\n#ans = 1\r\n#mp = {}\r\n#for i in range(n):\r\n#mp[i]++\r\n# jami bala code korta para.\r\n#jami thaka ash vala code kora. bujha jaita hay.\r\n#implement korta para nai :(\r\ns = set(x)\r\nass = n-len(s)+1\r\nprint(ass)\r\n\r\n\r\n'''#include <bits/stdc++.h>\r\nusing namespace std;\r\nusing ll = long long;\r\n\r\nconst int sz = 3e5 + 10;\r\nconst int mod = 1e9 + 7;\r\n\r\nint ar[sz], n, ans, nxt;\r\n\r\nmap < int, int > mp;\r\n\r\nint main() {\r\n #ifdef CLown1331\r\n freopen( \"in.txt\",\"r\",stdin );\r\n #endif /// CLown1331\r\n while( cin >> n ) {\r\n memset( ar, -1, sizeof ar );\r\n ar[0] = 1;\r\n ans = 1;\r\n mp.clear();\r\n for( int i=1,x; i<=n; i++ ) {\r\n cin >> x;\r\n mp[x]++;\r\n }\r\n for( const auto &x: mp ) ans += max( 0, x.second - 1 );\r\n cout << ans << \"\\n\";\r\n cerr << \"-----\\n\";\r\n }\r\n return 0;\r\n}'''\r\n", "n=int(input())\r\nt=list(map(int,input().split()))\r\nprint(n+1-len(set(t)))", "n = int( input() )\r\na = list( map( int, input().split() ) )\r\n\r\nmemo = {}\r\nans = 1\r\n\r\nfor i in a:\r\n\tif i not in memo:\r\n\t\tmemo[i] = 1\r\n\telse:\r\n\t\tans += 1\r\n\t\t\r\nprint( ans )", "n=int(input())\r\nD={}\r\ntime=[int(i) for i in input().split()]\r\nfor i in time:\r\n if i not in D:\r\n D[i]=1\r\nprint(n-len(D)+1)", "input()\nrooms = set([0])\ni = 0\nfor a in input().split():\n a = int(a)\n try:\n rooms.remove(a)\n except Exception as e:\n pass\n i += 1\n rooms.add(i)\nprint(len(rooms))\n", "n = int(input())\r\nt = list(map(int, input().split()))\r\n\r\nrt = set()\r\nr = 1\r\nrt.add(0)\r\n\r\nfor i in range(1,n):\r\n if t[i] in rt:\r\n r += 1\r\n else:\r\n rt.add(t[i])\r\nprint(r,end='')", "n = int(input())\r\nt = list(map(int, input().split()))\r\n\r\na = [0] * (n+1)\r\ncounter = 1\r\na[0] = 1\r\n\r\nfor i in range(n):\r\n if (a[t[i]] <= counter and a[t[i]] != 0):\r\n a[i+1] = counter\r\n a[t[i]] = 0\r\n else:\r\n counter += 1\r\n a[i+1] = counter\r\n\r\nprint (counter)", "n = int(input())\r\nt = [int(x) for x in input().split()]\r\nans = 0\r\nistime = [0] * (2 * 10 ** 5 + 13)\r\nistime[0] = 1\r\nfor i in range(n):\r\n if istime[t[i]] > 0:\r\n istime[t[i]] -= 1\r\n else:\r\n ans += 1\r\n istime[i + 1] += 1\r\nprint(ans + 1)", "n=int(input())\r\nl=list(map(int,input().split()))\r\nctr=1\r\ns=len(set(l))\r\nprint(len(l)-s+1)\r\n\r\n", "t=int(input())\r\nd1={}\r\nl1=[int(i) for i in input().split()]\r\nfor i in l1:\r\n d1[i]=d1.get(i, 0)+1\r\nans=1\r\nfor i in d1:\r\n ans+=max(0, d1[i]-1)\r\nprint(ans)", "n = int(input())\nv = []\nv = [int(_) for _ in input().split()]\n\nrez = 1\ndict = {}\nfor i in v:\n if dict.get(i) != None:\n rez += 1\n dict[i] = 1\n\nprint(rez)", "n = int(input())\r\ndata = [int(i) for i in input().split()]\r\nbook = [0] * n\r\nans = 1\r\nfor i in range(n):\r\n if book[data[n - i - 1]] == 0:\r\n book[data[n - i - 1]] = 1\r\n else:\r\n ans += 1\r\nprint(str(ans))\r\n", "# -*- coding: utf-8 -*-\r\n\r\nimport math\r\nimport collections\r\nimport bisect\r\nimport heapq\r\nimport time\r\nimport random\r\nimport itertools\r\nimport sys\r\n\r\n\"\"\"\r\ncreated by shhuan at 2017/11/12 23:57\r\n\r\n\"\"\"\r\n\r\nN = int(input())\r\n\r\nT = [int(x) for x in input().split()]\r\n\r\n\r\n# time:room\r\nE = collections.defaultdict(int)\r\nE[0] = 1\r\n\r\n# room: time\r\nlast = collections.defaultdict(int)\r\nlast[1] = 0\r\n\r\nroomNo = 1\r\nfor i in range(N):\r\n t = T[i]\r\n ct = i+1\r\n if t in E:\r\n room = E[t]\r\n if last[room] == t:\r\n last[room] = ct\r\n E[ct] = room\r\n else:\r\n roomNo += 1\r\n E[ct] = roomNo\r\n last[roomNo] = ct\r\n else:\r\n roomNo += 1\r\n E[ct] = roomNo\r\n last[roomNo] = ct\r\n\r\nprint(roomNo)\r\n\r\n\r\n", "print(int(input()) + 1 - len(set(map(int, input().split()))))", "n = int(input())\na = set()\na.add(0)\nt = 0\nfor r in input().split():\n t += 1\n x = int(r)\n if x in a:\n a.remove(x)\n a.add(t)\n else:\n a.add(t)\nprint(len(a))\n", "def solve(xs):\n\trooms = [1]\n\tnew = 2\n\tlast_visited = { 1:0 }\n\tfor i, x in enumerate(xs):\n\t\tref = rooms[x]\n\t\tif last_visited[ref] == x:\n\t\t\trooms.append(ref)\n\t\t\tlast_visited[ref] = i + 1\n\t\telse:\n\t\t\trooms.append(new)\n\t\t\tlast_visited[new] = i + 1\n\t\t\tnew += 1\n\treturn new - 1\n\nn = int(input())\nxs = list(map(int, input().split()))[:n]\nprint(solve(xs))", "\r\nn = int(input())\r\nlst = list(map(int,input().split()))\r\ns = set(lst)\r\nprint(n - len(s) +1)\r\n", "n = int(input())\na = [int(i) for i in input().split()]\n\n# a = [0, 1, 0, 1, 3]\n\nd = {0: 0} # minute -> room\ncr = 0\ntotal = 0\ntime = 0\n\nfor e in a:\n time += 1\n if e in d and d[e] == cr:\n d[time] = cr\n del d[e]\n\n elif e not in d:\n total += 1\n cr = total\n d[time] = cr\n\n elif e in d and d[e] != cr:\n cr = d[e]\n d[time] = cr\n del d[e]\n\nprint(total + 1)", "n=int(input())\r\nk=[int(i) for i in input().split()]\r\nw=1\r\na=[0 for i in range(n+1)]\r\nfor i in k:\r\n if(a[i]==0):a[i]=1\r\n else:w+=1\r\nprint(w)", "n=int(input())\nar=list(map(int,input().split()))\ns=set()\ns.add(1)\ni=2\nmx=0\nfor x in ar[1:]:\n mx=max(mx,len(s))\n if x in s:\n s.remove(x)\n s.add(i)\n else:\n s.add(i)\n i+=1\nprint(max(len(s),mx))", "n = int(input())\r\nvis = [0 for i in range(n + 1)]\r\nline = input().split()\r\nfor i in range(n):\r\n vis[int(line[i])] = 1\r\n continue\r\nans = 0\r\nfor i in range(n + 1):\r\n if vis[i] == 0:\r\n ans += 1\r\n continue\r\n continue\r\nprint(ans)\r\n", "def main():\n n, pool, res = int(input()), {0}, 1\n for i, t in enumerate(map(int, input().split()), 1):\n if t in pool:\n pool.remove(t)\n else:\n res += 1\n pool.add(i)\n print(res)\n\n\nif __name__ == '__main__':\n main()\n", "am = int(input())\r\narr = list(map(int,input().split()))\r\nwas = [False]*am\r\nt = 0\r\nfor i in range(am):\r\n if arr[i] == 0:\r\n t+=1\r\n was[i] = True\r\n continue\r\n if was[arr[i]-1]:\r\n was[arr[i]-1] = False\r\n was[i] = True\r\n else:\r\n was[i] = True\r\n t+=1\r\nprint(t)\r\n", "# _\r\n#####################################################################################################################\r\n\r\nclass Petya_sNotes(object):\r\n def __init__(self, nVisits, notesContent):\r\n self.nVisits = nVisits\r\n self.notesContent = notesContent\r\n\r\n def min_nRoomsVisited(self):\r\n min_nRooms = 1\r\n recordOfLatestMinutes = {0}\r\n for iMinute in range(self.nVisits):\r\n note = int(self.notesContent[iMinute])\r\n if note not in recordOfLatestMinutes:\r\n min_nRooms += 1\r\n else:\r\n recordOfLatestMinutes.remove(note)\r\n recordOfLatestMinutes.add(iMinute + 1)\r\n\r\n return min_nRooms\r\n\r\n\r\nprint(Petya_sNotes(int(input()), input().split()).min_nRoomsVisited())\r\n", "n = int( input() )\nt = list( map( int, input().split() ) )\ns = [ False ] * ( n + 1 )\n\ns[ 0 ] = True\nrooms = 1\n\nfor idx, i in enumerate( t ):\n if s[ i ]:\n s[ i ] = False\n else:\n rooms += 1\n s[ idx + 1 ] = True\n\nprint( rooms )\n", "n = int(input())\r\na = [0] + list(map(int, input().split()))\r\nvis = [False] * len(a)\r\nans = 1\r\nfor x in a[1:]:\r\n if not vis[x]:\r\n vis[x] = True\r\n else:\r\n ans += 1\r\nprint(ans)\r\n", "y=int (input())\r\nx=list(map(int,input().split()))\r\n\r\nprint(y+1-len(set(x)))", "n = int(input())\nkat = [int(s) for s in input().split()]\nacc = 1\nkom = set()\nfor t, k in enumerate(kat):\n if k in kom:\n acc += 1\n else:\n kom.add(k)\n\nprint(acc)\n", "n=int(input())\r\narray=[]\r\narray=list(map(int, input().split()))\r\n\r\nlast={}\r\nlast[1]=0\r\nvmax=1\r\nval=[]\r\nval.append(1)\r\n\r\nfor i in range(0,n):\r\n if last[val[array[i]]]==array[i]:\r\n val.append(val[array[i]])\r\n last[val[array[i]]]=i+1\r\n else:\r\n vmax=vmax+1\r\n val.append(vmax)\r\n last[vmax]=i+1\r\n\r\nprint(vmax)\r\n\r\n\r\n", "n = int(input())\na = list(map(int, input().split()))\nlast = [[] for i in range(n + 1)]\nlast[0] = [0]\nrooms = 1\nfor i, x in enumerate(a):\n #print(x, last[x])\n if len(last[x]) == 0:\n last[i + 1] = [rooms]\n rooms += 1\n else:\n last[i + 1].append(last[x][-1])\n last[x].pop()\nprint(rooms)\n", "n = int(input())\r\na = list(map(int, input().split()))\r\nb = [0] * (n + 1)\r\nres = 1\r\nb[1] = 1\r\nfor i in range(2, n + 1) :\r\n if b[a[i - 1]] == 0 :\r\n b[i] = 1\r\n res += 1\r\n else :\r\n b[i] = 1\r\n b[a[i - 1]] = 0\r\nprint(res)\r\n", "N = int(input())\r\ntexts = [0] * N\r\ntexts = input().split()\r\n\r\nends=set()\r\n#print(ends)\r\n\r\nends.add(0)\r\n#print(ends)\r\n\r\nfor i in range(N):\r\n if int(texts[i]) in ends:\r\n ends.remove(int(texts[i]))\r\n #print('-'+texts[i],end=' ')\r\n ends.add(i+1)\r\n #print(ends)\r\n\r\nprint(len(ends))\r\n\r\n", "was = [0 for i in range(5 * 10 ** 5)]\n\nn = int(input())\na = list(map(int, input().split()))\nwas[0] = 1\n\nfor i, x in enumerate(a, start=1):\n if was[x] > 0:\n was[x] -= 1\n was[i] += 1\n else:\n was[i] += 1\n\nprint(sum(was))\n", "import sys\nimport io, os\ninput = sys.stdin.buffer.readline\n\nn = int(input())\nT = list(map(int, input().split()))\n\nchild = [[] for _ in range(n+1)]\nfor i, t in enumerate(T):\n child[t].append(i+1)\n#print(child)\nans = 0\nfor i in range(1, n+1):\n if not child[i]:\n ans += 1\nprint(ans)\n", "from sys import stdin\r\ninput=lambda : stdin.readline().strip()\r\nfrom math import ceil,sqrt,factorial,gcd\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nprint(n+1-len(set(l)))", "n=int(input())\na=list(map(int,input().split()))\n\nprint(1+len(a)-len(set(a)))\n\n", "n = int(input())\r\na = list(map(int,input().split()))\r\nuseds = [0 for i in range(200017)]\r\nuseds[0] = 1\r\nans = 1\r\nfor i in range(n):\r\n if useds[a[i]] > 0:\r\n useds[a[i]] -= 1\r\n else:\r\n ans += 1\r\n useds[i + 1] += 1\r\nprint(ans)", "n = int(input())\na = [int(i) for i in input().split()]\nb = [0 for i in a]\ns=1\nfor i in a:\n\tif b[i]==1:\n\t\ts+=1\n\telse:\n\t\tb[i]+=1\nprint(s)", "import sys\r\n\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\ntail = [0 for i in range(n+1)]\r\nans = 1\r\nfor i in range(1, len(arr)+1):\r\n\tx = arr[i-1]\r\n\tif tail[x]:\r\n\t\tans += 1\r\n\telse:\r\n\t\ttail[x] = 1\r\n\r\nprint(ans)", "n = int(input())\na = [int(x) for x in input().split()]\ntime = 0\nroot = {0}\nfor t in a:\n time += 1\n if t in root:\n root.remove(t)\n root.add(time)\nprint(len(root))\n", "n = int(input())\r\na = list(map(int, input().split()))\r\ndi = {0 : 0}\r\nk = 1\r\nq = 1\r\nfor i in a:\r\n if i in di:\r\n del di[i]\r\n else:\r\n q += 1\r\n di[k] = i\r\n k += 1\r\nprint(q)", "from collections import Counter\r\nfrom collections import defaultdict\r\nimport math\r\nimport random\r\nimport heapq as hq\r\nfrom math import sqrt\r\nimport sys\r\n\r\n\r\ndef input():\r\n return sys.stdin.readline().strip()\r\n\r\n\r\ndef iinput():\r\n return int(input())\r\n\r\n\r\ndef tinput():\r\n return input().split()\r\n\r\n\r\ndef rinput():\r\n return map(int, tinput())\r\n\r\n\r\ndef rlinput():\r\n return list(rinput())\r\n\r\n\r\nmod = int(1e9)+7\r\n\r\n\r\ndef solve(adj, colors, n):\r\n pass\r\n\r\n\r\nif __name__ == \"__main__\":\r\n n = iinput()\r\n a = rlinput()\r\n d = dict()\r\n ans = 1\r\n for i in a:\r\n if i in d:\r\n ans += 1\r\n d[i] = 0\r\n print(ans)\r\n", "import sys\r\nreadline=sys.stdin.readline\r\n\r\nN=int(readline())\r\nT=list(map(int,readline().split()))\r\nans=N+1-len(set(T))\r\nprint(ans)", "n = int(input())\r\ns = set()\r\nfor v in input().split():\r\n s.add(v)\r\n\r\nprint(n-len(s)+1)", "def read_ints():\r\n return map(int, input().split())\r\n \r\n \r\ndef read_int():\r\n return int(input())\r\n \r\n \r\ndef solve():\r\n n = read_int()\r\n t = list(read_ints())\r\n \r\n last = dict()\r\n last[0] = 0\r\n \r\n for time, old_time in enumerate(t):\r\n if old_time in last:\r\n index = last[old_time]\r\n del last[old_time]\r\n else:\r\n index = len(last)\r\n \r\n last[time + 1] = index\r\n \r\n print(len(last))\r\n \r\n \r\nif __name__ == '__main__':\r\n solve()", "n = int(input())\r\nt = list(map(int, input().split()))\r\nvis = [False] * n\r\nc = 1\r\nfor i in t:\r\n\tif not vis[i]:\r\n\t\tvis[i] = True\r\n\telse:\r\n\t\tc += 1\r\nprint (c)\r\n", "n = int(input())\r\ntl = [0] + list(map(int,input().split())) #2e5\r\nll = list(range(n+1)) #0-n\r\ncnt = 1\r\nfor m,t in enumerate(tl):\r\n if ll[t] > t:\r\n ll[m] = m\r\n cnt += 1\r\n else:\r\n ll[t] = m\r\nprint(cnt)\r\n\r\n", "n = int(input())\r\narr = list(map(int, input().split()))\r\ncount = 1\r\np = set()\r\np.add(0)\r\nfor i in range(n):\r\n if arr[i] in p:\r\n p.remove(arr[i])\r\n \r\n else:\r\n count += 1\r\n p.add(i + 1)\r\nprint(count)", "n = int(input())\r\nti = list(map(int,input().split()))\r\ntemp = [0] * (n+2)\r\nans = n\r\nfor i in range(n,0,-1):\r\n if temp[ti[i-1]] < temp[i]+1:\r\n if temp[ti[i-1]] == 0:\r\n ans -= 1\r\n temp[ti[i-1]] = temp[i] + 1\r\nprint(ans+1)\r\n", "n=int(input())\r\na=input().split()\r\nans=n+1-len(set(a))\r\nprint(ans)", "n = int(input())\r\nt = list(map(int, input().split()))\r\ntcopy = t[::-1]\r\ntbool = [False] * len(t)\r\nans = 0\r\nfor i in range(len(t)):\r\n if not tbool[len(t) - i - 1]:\r\n \r\n ans += 1\r\n j = len(t) - i - 1\r\n while not tbool[j]:\r\n tbool[j] = True\r\n j = t[j] - 1\r\n if j < 0:\r\n break\r\n \r\n \r\n tbool[len(t) - i - 1] = True\r\nprint(ans)\r\n ", "# _\r\n#####################################################################################################################\r\n\r\nclass Petya_sNotes(object):\r\n def __init__(self, nVisits, notesContent):\r\n self.nVisits = nVisits\r\n self.notesContent = notesContent\r\n\r\n def min_nRoomsVisited(self):\r\n return self.nVisits + 1 - len(set(self.notesContent))\r\n\r\n\r\nprint(Petya_sNotes(int(input()), input().split()).min_nRoomsVisited())\r\n", "n = int(input())\r\narr = list(map(int, input().split()))\r\nvis = [0] * (n+1)\r\nres = 1\r\nfor i in range(n):\r\n\tif vis[arr[i]] > 0:\r\n\t\tres += 1\r\n\tvis[arr[i]] = 1\r\nprint(res)\r\n", "n=int(input())\r\ndict={}\r\narr=list(map(int,input().split()))\r\nroom=0\r\ntime=1\r\nfor i in arr:\r\n if(i in dict and dict[i]!=-1):\r\n dict[time] = dict[i]\r\n dict[i]=-1\r\n else:\r\n room+=1\r\n dict[time]=room\r\n time+=1\r\nprint(room)\r\n ", "i = int(input())\nctc = [0] + list(map(int, input().split()))\nnm = 1\nptor = {0:1}\nfor i in range(1, len(ctc)):\n if ctc[i] in ptor.keys():\n ptor[i] = ptor[ctc[i]]\n del(ptor[ctc[i]])\n else:\n nm+=1\n ptor[i] = nm\nprint(nm)\n", "_ = input()\r\nt = [int(s) for s in input().split()]\r\n\r\np = [False] * len(t)\r\n\r\nfor i, _ in enumerate(t):\r\n r = t[i] - 1\r\n if r >= 0:\r\n p[r] = True\r\n\r\nprint(p.count(False))\r\n", "import sys\r\nsys.setrecursionlimit(10**6);\r\n\r\n# sys.stdin = open('input.txt', 'r')\r\n# sys.stdout = open('output.txt', 'w')\r\n\r\n\r\n\r\nn=int(input())+1;\r\na=[-1]+list(map(int,input().split(\" \")));\r\ni=1;c=0;s=set();\r\nwhile(i<n):\r\n if(a[i] in s):\r\n s.remove(a[i]);\r\n else:c+=1;\r\n s.add(i);i+=1;\r\nprint(c);\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\nb = [-1]\r\nc = [-1] * (n + 1)\r\n\r\nc[0] = 1\r\n\r\ncnt = 1\r\n\r\nfor i in a:\r\n if (cnt == 1) or b[c[i]] != i:\r\n b.append(cnt)\r\n c[cnt] = len(b) - 1\r\n cnt += 1\r\n else:\r\n b[c[i]] = cnt\r\n c[cnt] = c[i]\r\n cnt += 1\r\n\r\nprint(len(b) - 1)\r\n\r\n\r\n\r\n\r\n\r\n", "def solve(n, arr):\n distinct_set = set()\n for i in range(n):\n distinct_set.add(arr[i])\n print(1 + n - len(distinct_set))\n\nn = int(input())\narr = list(map(int, input().split()))\nsolve(n, arr)\n\t \t\t\t \t \t\t\t\t\t\t\t \t\t\t\t\t \t\t \t\t", "n = int(input())\r\ninputs = input().split(\" \")\r\nparsed = list(set(inputs))\r\nprint(n-len(parsed)+1)\r\n \r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\np = [-1 for i in range(n+1)]\r\nans = 1\r\nfor i in range(n):\r\n if p[a[i]] == -1:\r\n p[a[i]] = i\r\n else:\r\n ans += 1\r\nprint(ans)", "n = int(input())\r\nA = list(map(int, input().split()))\r\nD = {}\r\nfor i in range (n):\r\n D[A[i]] = D.get ( A[i], -1 ) + 1\r\na = sum(D.values())+1\r\nprint(a)", "# _\r\n#####################################################################################################################\r\n\r\nmin_nRooms = 1\r\nrecordOfLatestMinutes = {0}\r\nnVisits, notesContent = int(input()), input().split()\r\nfor iMinute in range(nVisits):\r\n note = int(notesContent[iMinute])\r\n if note not in recordOfLatestMinutes:\r\n min_nRooms += 1\r\n else:\r\n recordOfLatestMinutes.remove(note)\r\n recordOfLatestMinutes.add(iMinute + 1)\r\n\r\n\r\nprint(min_nRooms)", "y=int (input())\r\nx=list(map(int,input().split()))\r\n\r\nprint(len(x)+1-len(set(x)))", "n=int(input())\r\nlst=input().split()\r\n\r\nd={}\r\nfor i in lst:\r\n if i not in d:\r\n d[i]=1\r\n else:\r\n d[i]+=1\r\n\r\ncnt = 0\r\nfor item in d:\r\n cnt+=max(0, d[item]-1)\r\n\r\nprint(cnt+1)\r\n", "n = int(input())\r\ntime = list(map(int,input().split()))\r\npos = {}\r\nlas_pos = {}\r\npos[0] = 1\r\nlas_pos[1] = 0\r\nrooms = 1\r\nfor i in range (n):\r\n if las_pos[pos[time[i]]] == time[i]:\r\n las_pos[pos[time[i]]] = i+1\r\n pos[i+1]=pos[time[i]]\r\n else:\r\n rooms+=1\r\n pos[i+1]=rooms\r\n las_pos[rooms] = i+1\r\nprint(rooms)\r\n\r\n\r\n", "n = int(input())\r\nt = list(map(int, input().split()))\r\nvisited = [True] * n\r\nfor time in t: visited[time] = False\r\nprint(sum(visited) + 1)", "n=int(input())\r\na=list(map(int,input().split()))\r\nans=0\r\ntimes=set()\r\ncurtime=0\r\nfor i in a:\r\n curtime+=1\r\n if i in times:\r\n times.remove(i)\r\n times.add(curtime)\r\n else:\r\n ans+=1\r\n times.add(curtime)\r\nprint(ans)", "n = int(input())\r\ndata = list(map(int, input().split()))\r\nd = [False] * (n + 4)\r\nd[0] = True\r\nres = 1\r\nfor i in range(n):\r\n #print(d)\r\n if d[data[i]]:\r\n d[data[i]] = False\r\n d[i + 1] = True\r\n else:\r\n d[i + 1] = True\r\n res += 1\r\n#print(d)\r\nprint(res)", "n = int(input())\narr = list(map(int,input().split()))\ns = set()\nk = [0]*(n+1)\nl = [0]*(n+1)\nmp = dict()\nmp2 = dict()\nmp[0],mp2[0] = 0,0\nfor i in range(n):\n\ttp = i+1\n\tif mp[mp2[arr[i]]] == arr[i]:\n\t\tmp2[tp] = mp2[arr[i]] \n\t\tmp[mp2[tp]] = tp\n\telse:\n\t\tmp[tp] = tp\n\t\tmp2[tp] = tp\nprint(len(mp))\n", "n = int(input())\n\nt = [0]+[int(i) for i in input().split()]\n\ncc = []\nccc = {}\n\nc = 0\nfor i in range(len(t)):\n if t[i] >= i:\n c += 1\n cc.append(c)\n ccc[c] = i\n elif t[i] != ccc[cc[t[i]]]:\n c += 1\n cc.append(c)\n ccc[c] = i\n else:\n cc.append(cc[t[i]])\n ccc[cc[t[i]]] = i\n\nprint(c)\n", "n = int(input())\r\na = list(map(int, input().split()))\r\ntime = [-1] * (n + 1)\r\ntime[0] = 1\r\ncount = 1\r\nfor i in range(n):\r\n cur_time = i + 1\r\n if time[a[i]] != -1:\r\n time[a[i]], time[cur_time] = -1, time[a[i]]\r\n else:\r\n count += 1\r\n time[cur_time] = count\r\nprint(count)", "n = int(input())\r\nlast = set()\r\nlast.add(0)\r\ncnt = 1\r\ni = 1\r\nfor k in input().split():\r\n\tk = int(k)\r\n\tif k in last:\r\n\t\tlast.remove(k)\r\n\telse:\r\n\t\tcnt+=1\r\n\tlast.add(i)\r\n\ti+=1\r\nprint(cnt)\r\n", "from sys import stdin, stdout\r\n\r\nn=int(stdin.readline())\r\na=[int(x) for x in stdin.readline().split()]\r\nl=len(a)\r\nb=len(set(a))\r\nprint(l-b+1)", "n = int(input())\r\na = list(map(int, input().split()))\r\nt = set()\r\nc = 0\r\nfor i in range(n-1,-1,-1):\r\n if i not in t:\r\n c+=1\r\n t |= {a[i]-1}\r\nprint(c)", "print(int(input())+1-len(set(input().split())))", "n = int(input())\r\nl = input().split()\r\nprint(len(l) - len(set(l)) + 1)\r\n\r\n", "g = input()\r\ns = input().split()\r\nprint(1 + len(s) - len(set(s)))", "def catacombs(lst):\r\n used = [False] * 200005\r\n result = 0\r\n used[0] = True\r\n for i in range(len(lst)):\r\n if not used[lst[i]]:\r\n used[lst[i]] = True\r\n else:\r\n result += 1\r\n return result\r\n\r\n\r\nn = int(input())\r\nb = [int(j) for j in input().split()]\r\nprint(catacombs(b))\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\ny=set()\r\ny.add(0)\r\nflag=0\r\nfor i in range(len(a)):\r\n if ({a[i]}<= y):\r\n y.discard(a[i])\r\n y.add(i+1)\r\n else:\r\n flag+=1\r\n y.add(i+1)\r\nprint(flag+1)\r\n", "n = int(input())\r\ninp = list(map(int, input().split()))\r\narr = [0]\r\ncount = 1\r\ntime = 1\r\ndict = {0: 0}\r\n\r\nfor i in inp:\r\n\r\n if dict[arr[i]] != i:\r\n dict[count] = time\r\n arr.append(count)\r\n count += 1\r\n\r\n else:\r\n dict[arr[i]] = time\r\n arr.append(arr[i])\r\n\r\n time += 1\r\n\r\nprint(count)", "from collections import Counter\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nj=Counter(l)\r\nres=1\r\nfor i in range(n):\r\n if i in j:\r\n res+=j[i]-1\r\nprint(res)", "n = int(input())\r\nlist1 = list(map(int, input().split()))\r\ntime = [0] * (n + 1)\r\ntime[0] = 1\r\nans = 1\r\nfor i in range(n):\r\n if time[list1[i]] == 1:\r\n time[i + 1] = 1\r\n time[list1[i]] = 0\r\n else:\r\n ans += 1\r\n time[i + 1] = 1\r\nprint(ans)", "from sys import stdin, stdout\r\nfrom math import factorial\r\n\r\nn = int(stdin.readline())\r\nvalues = list(map(int, stdin.readline().split()))\r\nused = set()\r\n\r\nfor i in range(1, n + 1):\r\n v = values[i - 1]\r\n \r\n if v in used:\r\n used.discard(v)\r\n used.add(i)\r\n else:\r\n used.add(i)\r\n\r\nstdout.write(str(len(used)))", "n = int(input())\na = list(map(int, input().split()))\n\nlast = [-1]*(n+2)\nlast[1] = 0\n\nhod = [-1]*(n+1)\nhod[0] = 1\nk = 1 # Hod\no = 1 # Otvet\n\nfor i in a:\n if i == last[hod[i]]:\n last[hod[i]] = k\n hod[k] = hod[i]\n else:\n o += 1\n last[o] = k\n hod[k] = o\n\n k += 1\n\nprint(o)", "print(int(input()) + 1 - len(set(input().split())))\r\n", "n = int(input())\nt = list(map(int, input().split(' ')))\n\na = [0]\nh = 1\ncur_t = 1\n\nd = {0:0}\n\nfor ti in t:\n if d[a[ti]] != ti:\n a.append(h)\n d[h] = cur_t\n h += 1\n else:\n d[a[ti]] = cur_t\n a.append(a[ti])\n cur_t += 1\n\nprint (h)\n", "def main():\r\n\r\n n = int(input())\r\n\r\n a = [0]\r\n a += list(map(int, input().split()))\r\n\r\n p = [0] * 200001\r\n p[1] = 0\r\n k = [-1] * 200001\r\n k[0] = 1\r\n\r\n ans = 1\r\n\r\n cnt = 1\r\n\r\n for i in range(1, n + 1):\r\n if (i == 1):\r\n if (a[i] == 1):\r\n cnt += 1\r\n k[i] = cnt\r\n p[cnt] = i\r\n ans += 1\r\n else:\r\n k[i] = k[a[a[i]]]\r\n p[k[i]] = i\r\n\r\n elif (p[k[a[i]]] != a[i]):\r\n cnt += 1\r\n k[i] = cnt\r\n p[cnt] = i\r\n ans += 1\r\n else:\r\n k[i] = k[a[i]]\r\n p[k[i]] = i\r\n\r\n print(ans)\r\n\r\nmain()\r\n \r\n", "def count_min_rooms(timestamps):\r\n\treturn len(timestamps) + 1 - len(set(timestamps))\r\n\r\nnum_stamps = int(input())\r\ntimestamps = [int(x) for x in input().split()]\r\n\t\t\r\nprint(count_min_rooms(timestamps))\r\n", "n=int(input())\r\nlog=[int(x) for x in input().split()]\r\nlog.sort()\r\nnr=1\r\nfor i in range(n-1):\r\n if log[i]==log[i+1]:\r\n nr+=1\r\nprint(nr)", "n=int(input())\ns=list(map(int,input().split()))\n\nprint(1+len(s)-len(set(s)))", "n=int(input())\r\nl=list(map(int,input().split()))\r\nx=len(set(l))\r\nprint(n+1-x)", "n=int(input())\r\nl=list(map(int,input().split()))\r\nw=set(l)\r\nprint(n-len(w)+1)\r\n", "\r\ndef getMinimum (arr, n):\r\n times = [None for i in range(0, n+1)]\r\n rooms = [None for i in range(0, n+1)]\r\n currentRoom = 0\r\n times[0] = currentRoom\r\n rooms[currentRoom] = 0\r\n t = 1\r\n total = 1\r\n currentRoom += 1\r\n for i in range(0, n):\r\n # print('Times', times)\r\n # print('Rooms', rooms)\r\n if arr[i] >= t:\r\n t += 1\r\n else:\r\n if times[arr[i]] != None:\r\n curRoom = times[arr[i]]\r\n lastTime = rooms[curRoom]\r\n if arr[i] != lastTime:\r\n total += 1\r\n rooms[currentRoom] = t\r\n times[t] = currentRoom\r\n currentRoom += 1\r\n else:\r\n rooms[curRoom] = t\r\n times[t] = curRoom\r\n else:\r\n rooms[currentRoom] = t\r\n times[t] = currentRoom\r\n currentRoom += 1\r\n total += 1\r\n t += 1\r\n \r\n return total\r\n \r\nn = int(input())\r\narr = list(map(int, input().split()))\r\n\r\nprint(getMinimum(arr, n))\r\n", "n = int(input())\r\nt = list(map(int,input().split()))\r\nrooms = 0\r\nminute = 1\r\nlasttime = {0:0}\r\nfor i in range(n):\r\n if t[i] in lasttime.keys():\r\n a = lasttime.pop(t[i])\r\n lasttime[minute] = a\r\n else:\r\n rooms += 1\r\n lasttime[minute] = rooms\r\n minute += 1\r\nprint(rooms+1)\r\n\r\n", "n = int(input())\r\na = [int(i) for i in input().split()]\r\nvisited = {0: 1}\r\nfor i in range(n):\r\n r = visited.pop(a[i], None)\r\n visited[i+1] = 1\r\nprint(len(visited.keys()))", "def solver():\r\n n = int(input())\r\n arr = [int(x) for x in input().split()]\r\n cnt = 0\r\n arr.sort()\r\n for i in range(1,len(arr)):\r\n if arr[i] == arr[i-1]:\r\n cnt+=1\r\n print(cnt+1)\r\n\r\nsolver()\r\n", "n=int(input().strip())\na=list(map(int,input().strip().split()))\nt=[-1]*(n+1)\nt[0]=1\nans=1\nnew=1\nfor i in range(0,n):\n\tx=a[i]\n\tif t[x]!=-1:\n\t\tt[i+1]=t[x]\n\t\tt[x]=-1\n\telse:\n\t\tans=ans+1\n\t\tt[i+1]=ans\nprint(ans)", "import math\r\nimport sys\r\nfrom collections import defaultdict\r\nfrom collections import Counter\r\nimport bisect\r\ninput = iter(sys.stdin.buffer.read().decode().splitlines()).__next__\r\nilele = lambda: map(int,input().split())\r\nalele = lambda: list(map(int, input().split()))\r\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\r\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\r\nINF = 10 ** 18\r\nMOD = 10 ** 9 + 7\r\n\r\nN, =ilele()\r\nA = alele()\r\nC = Counter(A)\r\ntot = 1\r\nfor i in C.values():\r\n tot += max(0,i-1)\r\nprint(tot)", "n = int(input())\r\nt = list(map(int, input().split()))\r\nr = {0:1} # time visited : room num\r\nm = 1\r\nfor time in range(1, n+1):\r\n x = t[time-1] # number written down\r\n if x in r:\r\n r[time] = r.pop(x) \r\n else:\r\n m += 1\r\n r[time] = m\r\nprint(m)\r\n \r\n \r\n \r\n \r\n ", "n = int(input())\r\ns = {0}\r\nj = 0\r\nfor i in list(map(int, input().split())):\r\n j+=1\r\n if i in s:\r\n s.discard(i)\r\n s.add(j)\r\n else: s.add(j)\r\nprint(len(s))\r\n", "import fractions\r\nimport math\r\nn=int(input())\r\n#a,b=map(int,input().split(' ')) \r\n#n=list(map(int,input().split(' ')))\r\nt=list(map(int,input().split(' ')))\r\na=set(t)\r\nprint(n+1-len(a))\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\nd = [0]*(n+1)\r\nw = list(map(int, input().split()))\r\nc = 1\r\nfor i in range(n-1, -1, -1):\r\n x = i+1\r\n if d[x] == 0:\r\n while x >= 0 and d[x] == 0:\r\n d[x] = c\r\n x = w[x-1]\r\n c += 1\r\nprint(c-1)\r\n", "n = int(input())\r\ntmp = list(map(int, input().split()))\r\n\r\nt = [0] * (n + 1)\r\nfor x in tmp:\r\n t[x] = 1\r\n\r\ncount = 1\r\nfor i in range(n):\r\n if not t[i]:\r\n count += 1\r\n\r\nprint(count)", "n = int(input())\r\n*t, = map(int, input().split())\r\nk = {}\r\nfor i in t:\r\n if i not in k.keys():\r\n k[i] = 0\r\n k[i] += 1\r\ncnt = 0\r\nfor i in k:\r\n cnt += max(0, k[i] - 1)\r\nprint(cnt + 1)\r\n", "n = int(input())\narr = [int(x) for x in input().split()]\n\nse = set()\n\nse.add(0)\n\nfor i, ti in enumerate(arr, 1):\n if ti in se:\n se.remove(ti)\n se.add(i)\n else:\n se.add(i)\n\nprint(len(se))\n", "c = int(input())\r\na = list(map(int, input().split()))\r\nres = 0\r\nb = []\r\nfor i in range(len(a)):\r\n b.append(False)\r\nfor i in range(len(a)):\r\n k = len(a) - i - 1 \r\n m = 0\r\n while b[k] == False:\r\n b[k] = True\r\n k = a[k] - 1\r\n m = 1\r\n if (k == -1):\r\n break \r\n if m == 1:\r\n res = res + 1\r\nprint(res)", "n = int(input())\r\nt = [int(x) for x in input().split()]\r\n\r\nvisited = [False] * n\r\n\r\ncount = 0\r\n\r\nfor i in range(n-1, -1, -1):\r\n if visited[i]:\r\n continue\r\n\r\n curr_index = i\r\n while(True):\r\n\r\n visited[curr_index] = True\r\n\r\n if t[curr_index] == 0:\r\n count += 1\r\n\r\n break\r\n\r\n if visited[t[curr_index] - 1]:\r\n count += 1\r\n break\r\n\r\n curr_index = t[curr_index] - 1\r\n\r\nprint(count)\r\n", "k = int(input())\r\n\r\narr = list(map(int, input().split()))\r\ndp = [1]\r\nused = [False]\r\n\r\nfor i in range(1, k+1):\r\n prev = arr[i-1]\r\n \r\n dp.append(dp[i-1] + used[prev])\r\n used[prev] = 1\r\n \r\n used.append(0)\r\n\r\nprint(dp[-1])\r\n\r\n\r\n" ]
{"inputs": ["2\n0 0", "5\n0 1 0 1 3", "7\n0 1 0 0 0 0 0", "100\n0 0 0 0 0 0 1 4 4 0 2 2 4 1 7 1 11 0 8 4 12 12 3 0 3 2 2 4 3 9 1 5 4 6 9 14 6 2 4 18 7 7 19 11 20 13 17 16 0 34 2 6 12 27 9 4 29 22 4 20 20 17 17 20 37 53 17 3 3 15 1 46 11 24 31 6 12 6 11 18 13 1 5 0 19 10 24 41 16 41 18 52 46 39 16 30 18 23 53 13", "100\n0 0 0 0 1 2 0 0 3 3 2 2 6 4 1 6 2 9 8 0 2 0 2 2 0 0 10 0 4 20 4 11 3 9 0 3 8 2 6 3 13 2 1 23 20 20 16 7 1 37 6 1 25 25 14 30 6 23 18 3 2 16 0 4 37 9 4 6 2 14 15 11 16 35 36 7 32 26 8 1 0 37 35 38 27 3 16 8 3 7 7 25 13 13 30 11 5 28 0 12", "1\n0", "14\n0 0 1 1 2 2 3 3 4 4 5 5 6 6", "2\n0 1"], "outputs": ["2", "3", "6", "66", "71", "1", "8", "1"]}
UNKNOWN
PYTHON3
CODEFORCES
111
e35e610ac148cf150660bb1f42980765
Boys and Girls
There are *n* boys and *m* girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to *n*<=+<=*m*. Then the number of integers *i* (1<=≤<=*i*<=&lt;<=*n*<=+<=*m*) such that positions with indexes *i* and *i*<=+<=1 contain children of different genders (position *i* has a girl and position *i*<=+<=1 has a boy or vice versa) must be as large as possible. Help the children and tell them how to form the line. The single line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100), separated by a space. Print a line of *n*<=+<=*m* characters. Print on the *i*-th position of the line character "B", if the *i*-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal *n* and the number of characters "G" should equal *m*. If there are multiple optimal solutions, print any of them. Sample Input 3 3 4 2 Sample Output GBGBGB BGBGBB
[ "f = open('input.txt', 'r')\r\nline = f.readline()\r\nn, m = map(int, line.split())\r\nf.close()\r\n\r\nans = ''\r\ncur = 'B' if n > m else 'G'\r\n\r\nwhile n and m:\r\n ans += cur\r\n if cur == 'B':\r\n n -= 1\r\n cur = 'G'\r\n else:\r\n m -= 1\r\n cur = 'B'\r\n\r\nwhile n:\r\n ans += 'B'\r\n n -= 1\r\n\r\nwhile m:\r\n ans += 'G'\r\n m -= 1\r\n\r\nf = open('output.txt', 'w')\r\nf.write(ans)", "f = open('input.txt', 'r')\nl = f.readline().split()\nn = int(l[0])\nm = int(l[1])\n\nif n == m:\n result = [\"BG\"] * n\n outputs = ''.join(result)\n out = open('output.txt', 'w')\n out.write(outputs)\nelif n > m:\n diff = n - m\n result = [\"BG\"] * m\n result += [\"B\"] * diff\n outputs = ''.join(result)\n out = open('output.txt', 'w')\n out.write(outputs)\nelse:\n diff = m - n\n result = [\"GB\"] * n\n result += [\"G\"] * diff\n outputs = ''.join(result)\n out = open('output.txt', 'w')\n out.write(outputs)\n", "a = open('input.txt', 'r')\nb = open('output.txt', 'w')\nx, y = map(int, a.readline().split())\nif x >= y:\n b.write('BG' * y + 'B' * (x-y))\nelse:\n b.write('GB' * x + 'G' * (y-x)) \t\t\n \t \t \t\t \t \t\t\t \t\t\t\t\t\t\t \t \t \t \t", "INPUT = open('input.txt', 'r')\r\nOUTPUT = open('output.txt', 'w')\r\nn, m = map(int, INPUT.read().split())\r\n\r\nif n>m:\r\n OUTPUT.write(m*\"BG\"+(n-m)*\"B\")\r\nelse:\r\n OUTPUT.write(n*\"GB\"+(m-n)*\"G\")\r\n", "def main():\n #elems = list(map(int, input().split(' ')))\n with open('input.txt', 'r') as f:\n n_b, n_g = list(map(int, f.readline().rstrip('\\n').split(' ')))\n\n start = 'B'\n if n_g > n_b:\n start = 'G'\n output = [start]\n total = 1\n\n while total < n_b + n_g:\n prev = output[-1]\n if prev == 'B':\n if n_g > 0:\n output.append('G')\n n_g -= 1\n continue\n else:\n output.append('B')\n n_b -= 1\n continue\n if prev == 'G':\n if n_b > 0:\n output.append('B')\n n_b -= 1\n continue\n else:\n output.append('G')\n n_g -= 1\n continue\n\n with open('output.txt', 'w') as f2:\n f2.write(''.join(output) + '\\n')\n\n\nif __name__ == \"__main__\":\n main()\n", "n,m = map(int,open('input.txt').read().split())\n\nif( n >= m ):\n s = \"BG\"*(m)\n n = n-m\n s = s+'B'*n\nelse:\n s = \"GB\"*(n)\n m = m - n\n s = s + \"G\"*m\nf = open(\"output.txt\",'w')\nf.write(s)\n\t \t\t\t\t\t \t \t \t\t \t \t \t\t\t", "my_file = open(\"input.txt\", \"r\")\noutputFile = open(\"output.txt\", \"w\")\nb,g = map(int,my_file.readline().split())\nif b > g:\n while g > 0:\n outputFile.write('BG')\n b -= 1\n g -= 1\n while b > 0:\n outputFile.write('B')\n b -= 1\nelse:\n while b > 0:\n outputFile.write('GB')\n b -= 1\n g -= 1\n while g > 0:\n outputFile.write('G')\n g -= 1\n\t\t \t\t \t\t \t \t \t", "ip = open(\"input.txt\",\"r\")\r\nop = open('output.txt','w')\r\nn,m = map(int,ip.readline().split())\r\nif n>=m:\r\n\tres = 'BG'*m+'B'*(n-m)\r\nelse:\r\n\tres = 'GB'*n+'G'*(m-n)\t\r\nop.write(res)", "inp = open(\"input.txt\", \"r\")\noutp = open(\"output.txt\", \"w\")\n\nfor x in inp:\n b, g = x.split()\n g = int(g)\n b = int(b)\n\nif b > g:\n outp.write('BG' * g + 'B'*(b-g))\nelif g > b:\n outp.write('GB'*b + 'G' * (g-b))\nelse:\n outp.write('GB' * b)\n \t\t \t \t \t\t\t\t \t \t \t \t\t", "x = open(\"input.txt\", \"r\")\ny = open(\"output.txt\", \"w\")\nn, m = map(int, x.readline().split())\ny.write([\"BG\" * m + \"B\" * (n - m), \"GB\" * n + \"G\" * (m - n)][n < m])\n\t \t \t \t \t \t \t \t\t \t \t \t\t\t\t", "a = open(\"input.txt\",\"r\")\nn, m = a.readline().split()\na.close()\nn = int(n)\nm = int(m)\nc = \"\"\nif n > m:\n d = n-m\nelif n < m:\n d = m-n\nif n>m:\n for i in range(n-d):\n c += \"BG\"\nelif n<m:\n for i in range(m-d):\n c += \"GB\"\nif n>m:\n for i in range(d):\n c += 'B'\nelif n<m:\n for i in range(d):\n c += 'G'\nif n == m:\n for i in range(n):\n c += \"BG\"\nprint(c)\noutput = open(\"output.txt\", \"w\")\noutput.write(c)\noutput.close\n \t \t \t\t \t\t \t \t \t\t \t\t\t\t\t\t\t \t", "# n,m=map(int,input().split())\r\nimport sys\r\nsys.stdin = open('input.txt','r')\r\nsys.stdout = open('output.txt','w')\r\nn,m = map(int, sys.stdin.readline().strip().split())\r\nio=\"BG\"\r\nip=\"GB\"\r\nif n==m:\r\n\ts=ip*n\r\n\tprint(s)\r\nelif n>m:\r\n\ts=io*m\r\n\ts+=\"B\"*(n-m)\r\n\tprint(s)\r\nelse:\r\n\ts=ip*n+\"G\"*(m-n)\r\n\tprint(s)", "import os.path\r\nimport sys\r\nif os.path.exists('input.txt'):\r\n sys.stdin = open('input.txt', 'r')\r\n sys.stdout = open('output.txt', 'w')\r\nn,m=[int(x) for x in input().split(' ')]\r\nx=min(n,m)\r\n#print(x)\r\nif n<m:\r\n ans=x*\"GB\"\r\nelse:\r\n ans=x*'BG'\r\nn=n-x\r\nm=m-x\r\n#print(n,m)\r\nif n!=0:\r\n ans+=n*'B'\r\nif m!=0:\r\n ans+=m*'G'\r\nprint((ans))", "f=open(\"input.txt\",'r');g=open(\"output.txt\",'w')\r\nn,m=map(int,f.readline().split())\r\ng.write(['BG'*m+'B'*(n-m),'GB'*n+'G'*(m-n)][n<m])", "f1 = open(\"input.txt\", \"r\")\r\nf2 = open(\"output.txt\", \"w\")\r\nb,g=map(int,f1.read().split())\r\ns=''\r\nfor i in range(min(g,b)):\r\n s+='GB'\r\nif(b>g):\r\n s='B'+s\r\n b-=1+g\r\n for i in range(b):\r\n s+='B'\r\nelse:\r\n g-=b\r\n for i in range(g):\r\n s+='G'\r\nf2.write(s)\r\n\r\n", "with open('input.txt', 'r') as rf:\n n, m = map(int, rf.readline().split(' '))\nif n >= m:\n result = ['BG' for _ in range(m)]\n for i in range(m, n):\n result.append('B')\nelse:\n result = ['GB' for _ in range(n)]\n for i in range(n, m):\n result.append('G')\nwith open('output.txt','w') as rf:\n for i in range(len(result)):\n rf.write(result[i])\n\t \t\t\t\t\t \t\t \t\t\t\t \t \t\t", "import math as m\r\nfrom collections import defaultdict,deque\r\nfrom bisect import bisect_left as b_l\r\nfrom bisect import bisect_right as b_r\r\nimport sys\r\n\r\nsys.stdin=open(\"input.txt\")\r\nsys.stdout=open(\"output.txt\",'w')\r\n\r\nb,g=map(int,input().split())\r\nif(b>g):\r\n ans=\"BG\"*g\r\n print(ans+\"B\"*(b-g))\r\nelse:\r\n ans=\"GB\"*b\r\n print(ans+\"G\"*(g-b))", "inputFile=open(\"input.txt\",'r')\noutputFile=open(\"output.txt\",'w')\n\n\nn,m=list(map(int,inputFile.readline().split()))\nans=\"\"\nif n>m:\n\tfor i in range(m):\n\t\tans+=\"BG\"\n\tfor i in range(abs(m-n)):\n\t\tans+=\"B\"\nelse:\n\tfor i in range(n):\n\t\tans+=\"GB\"\n\tfor i in range(abs(m-n)):\n\t\tans+=\"G\"\noutputFile.write(ans)", "input = open(\"input.txt\", \"r\")\nx = str(input.readline())\nxsplit = x.split()\nn = int(xsplit[0])\nm = int(xsplit[1])\nans = \"\"\nif n == m:\n rsnt = \"\"\n for i in range(0, n):\n rsnt = rsnt + \"G\"\n rsnt = rsnt + \"B\"\n ans = rsnt\nelif n > m:\n r = n - m\n rsnt = \"\"\n for i in range(0,m):\n rsnt = rsnt + \"B\"\n rsnt = rsnt + \"G\"\n rsnt = rsnt + r * \"B\"\n ans = rsnt\nelse:\n r = m - n\n rsnt = \"\"\n for i in range(0, n):\n rsnt = rsnt + \"G\"\n rsnt = rsnt + \"B\"\n rsnt = rsnt + r * \"G\"\n ans = rsnt\n\noutput = open(\"output.txt\", \"w\")\noutput.write(ans)\n\t \t \t \t \t \t \t\t\t \t \t", "f = open(\"input.txt\", \"r\")\ng = open(\"output.txt\", \"w\")\n\nt = f.readline().split(\" \")\n\nt1 = int(t[0])\nt2 = int(t[1])\n\nif t1 > t2:\n l1 = [\"B\" for i in range(t1)]\n l2 = [\"G\" for i in range(t2)]\n res = [a + b for a, b in zip(l1, l2)]\n ans = \"\".join(res)\n ans += \"\".join([\"B\" for i in range(abs(t1 - t2))])\nelse:\n l1 = [\"G\" for i in range(t1)]\n l2 = [\"B\" for i in range(t2)]\n res = [a + b for a, b in zip(l1, l2)]\n ans = \"\".join(res)\n ans += \"\".join([\"G\" for i in range(abs(t2 - t1))])\n\ng.write(ans)\n", "import sys\r\nfrom os import path\r\ndef get_int():\r\n if path.exists(\"input.txt\"):\r\n sys.stdin = open(\"input.txt\", \"r\")\r\n sys.stdout = open(\"output.txt\", \"w\")\r\n a = map(int, sys.stdin.readline().split())\r\n return a\r\nn,m = get_int()\r\nx,y = n,m\r\na = []\r\nfor i in range(n + m):\r\n if (i + int(y > x)) % 2 == 0 and n > 0:\r\n n -= 1\r\n a.append(\"B\")\r\n elif (i + int(y > x)) % 2 == 1 and m > 0:\r\n m -= 1\r\n a.append(\"G\")\r\n else:\r\n a.append(\"B\" if n > 0 else \"G\")\r\nsys.stdout.write(\"\".join(a))", "import fileinput\nfin = open(\"input.txt\", \"r\")\nfout = open(\"output.txt\", \"w\")\nlines = fin.readlines()\nn, m = lines[0].split()\nn = int(n)\nm = int(m)\ns = ''\nif n < m:\n for i in range(n):\n s += 'GB'\n m -= 1\n while m > 0:\n s += 'G'\n m -= 1\nelse:\n for i in range(m):\n s += 'BG'\n n -= 1\n while n > 0:\n s += 'B'\n n -= 1\nfout.write(s)\nfin.close()\nfout.close()\n \t\t \t\t\t\t\t\t \t\t \t \t\t\t\t \t\t\t \t", "with open(\"input.txt\", \"r\") as fp:\r\n n, m = map(int, fp.readline().split())\r\n out = open(\"output.txt\", \"w\")\r\n b, g = 'B', 'G'\r\n if n > m:\r\n m, n = n, m\r\n b, g = g, b\r\n out.write((g+b)*n + g*(m-n))\r\n out.close()", "import sys\r\n\r\ndef solve(b,g):\r\n mi = min(b,g)\r\n s = \"BG\" if b >= g else \"GB\"\r\n return s*mi + s[0]*abs(b-g)\r\n\r\nsys.stdin = open('input.txt', 'r')\r\nsys.stdout = open('output.txt', 'w')\r\n\r\ninputStr = sys.stdin.readline().strip()\r\nboys, girls = map(int, inputStr.split())\r\n\r\noutputStr = solve(boys, girls)\r\nsys.stdout.write(outputStr)", "with open('input.txt', 'r') as f:\r\n n, m = map(int, f.readline().split())\r\n\r\n t = ''\r\n r = ''\r\n\r\n if n >= m:\r\n t = 'BG'\r\n else:\r\n t = 'GB'\r\n\r\n r += min(n,m) * t + t[0] * abs(n-m)\r\n\r\n with open('output.txt', 'w') as fo:\r\n fo.write(r)", "'''input\r\n3 3\r\n'''\r\nimport sys\r\nfrom math import *\r\nfrom copy import *\r\nfrom bisect import *\r\nfrom collections import *\r\nfrom itertools import *\r\nfrom functools import *\r\nfrom heapq import *\r\nfrom array import array\r\nsys.stdin = open('input.txt', 'r') \r\nsys.stdout = open('output.txt', 'w')\r\nINF = 2147483647\r\nINF64 = 9223372036854775807\r\ninput = sys.stdin.readline\r\ndef getstr(): return input().rstrip('\\r\\n')\r\ndef getint(): return int(input().strip())\r\ndef getints(): return list(map(int, input().strip().split()))\r\ndef impossible(): print(-1),exit(0)\r\n\r\ndef solve():\r\n\ta,b = getints()\r\n\tturn = True\r\n\tif a>b: turn = False\r\n\twhile a or b:\r\n\t\tif a==0:\r\n\t\t\tprint(\"G\",end='')\r\n\t\t\tb-=1\r\n\t\t\tcontinue\r\n\t\tif b==0:\r\n\t\t\tprint(\"B\",end='')\r\n\t\t\ta-=1\r\n\t\t\tcontinue\r\n\t\tif turn:\r\n\t\t\tprint(\"G\",end='')\r\n\t\t\tturn = not turn\r\n\t\t\tb-=1\r\n\t\telse:\r\n\t\t\tprint(\"B\",end='')\r\n\t\t\tturn = not turn\r\n\t\t\ta-=1\r\n\tprint()\r\n\r\nif __name__==\"__main__\":\r\n\tt = 1\r\n\tfor i in range(t):\r\n\t\tsolve()", "taco = open(\"input.txt\",\"r\")\nk = taco.readline()\ntaco.close()\nn,m = k.split()\nn = int(n)\nm = int(m)\nif n == m:\n i = 0\n s = str()\n while i < n:\n s += \"BG\"\n i += 1\nelif n > m:\n s = str()\n i = 0\n while i < m:\n s += \"BG\"\n i += 1\n while i < n:\n s += \"B\"\n i += 1\nelse:\n s = str()\n i = 0\n while i < n:\n s += \"GB\"\n i += 1\n while i < m:\n s += \"G\"\n i += 1\nburrito = open(\"output.txt\",\"w\")\nburrito.write(s)\nburrito.close()\n \t \t \t \t \t\t \t \t", "import sys\r\nsys.stdin=open(\"input.txt\",\"r\")\r\nsys.stdout=open(\"output.txt\",\"w\")\r\nn,m=map(int,input().split())\r\nif m>n:\r\n print('GB'*n +'G'*(m-n))\r\nelse:\r\n print('BG'*m+'B'*(n-m))", "with open('input.txt', 'r') as input_file:\r\n content = input_file.read().strip().split('\\n')\r\n\r\n #print(content)\r\n\r\n for line in content:\r\n boys, girls = map(int, line.split())\r\n\r\nfileForOutput = open('output.txt','w')\r\nanswer = ''\r\nif boys>=girls :\r\n answer += \"BG\"*girls + \"B\"*(boys-girls)\r\nelse :\r\n answer += \"GB\"*boys + \"G\"*(girls-boys)\r\n\r\nfileForOutput.write(answer)\r\n", "with open('input.txt') as f:\n question = f.read()\nn, m = map(int, question.split())\nwith open('output.txt', 'w') as f:\n if n > m:\n f.write('BG' * m + 'B' * (n - m))\n elif n < m:\n f.write('GB' * n + 'G' * (m - n))\n else:\n f.write('GB' * n)\n\t \t\t \t \t \t\t\t \t \t\t \t\t\t \t", "with open('input.txt') as f:\n n, m = map(int, f.read().split())\n \noutput = ''\nif n > m:\n substr = 'BG'\nelse:\n substr = 'GB'\nfor i in range(min(n, m)):\n output += substr\n \nwith open('output.txt', 'w') as f:\n if n > m:\n f.write(output+'B'*(n-m))\n else:\n f.write(output+'G'*(m-n))\n\n", "fh1=open('input.txt','r')\r\nx=fh1.read()\r\nb,g=x.split(' ')\r\nb,g=int(b),int(g)\r\nfh1.close()\r\nfh2=open('output.txt','w')\r\nif b==g:\r\n for i in range(g):fh2.write('BG')\r\nelif b>g:\r\n for i in range(g):fh2.write('BG')\r\n for i in range(b-g):fh2.write('B')\r\nelse:\r\n for i in range(b):fh2.write('GB')\r\n for i in range(g-b):fh2.write('G')\r\nfh2.close()\r\n", "r=open(\"input.txt\",\"r\")\nw=open(\"output.txt\",\"w\")\nn,m=map(int,r.readline().split())\nans=\"\"\nif n>=m:\n while n>0 or m>0:\n if n>0:\n ans+='B'\n n-=1\n if m>0:\n ans+='G'\n m-=1\nelse:\n while n>0 or m>0:\n if m>0:\n ans+='G'\n m-=1\n if n>0:\n ans+='B'\n n-=1\n \nw.write(ans)\n\t \t\t\t \t \t \t\t \t \t\t\t\t\t\t \t \t \t", "import sys\r\nsys.stdin = open('input.txt', 'r')\r\nsys.stdout = open('output.txt', 'w')\r\n\r\nn, m = map(int, input().split())\r\n\r\nx = min(n, m)\r\nn, m = n - x, m - x\r\n\r\nif n == 0:\r\n print('G' * m + 'BG' * x)\r\nelse:\r\n print('BG' * x + 'B' * n)\r\n", "\r\ninputs=open(\"input.txt\", \"r\")\r\noutputs=open(\"output.txt\",\"w\")\r\n\r\n\r\nn,m=map(int,inputs.readline().split())\r\n\r\nif(n>=m):\r\n for i in range(m):\r\n outputs.write(\"BG\")\r\n outputs.write(\"B\"*(n-m))\r\n\r\nelse:\r\n for i in range(n):\r\n outputs.write(\"GB\")\r\n outputs.write(\"G\"*(m-n))\r\n\r\ninputs.close()\r\noutputs.close()", "read_file = open(\"input.txt\", 'r')\r\nwrite_file = open(\"output.txt\", 'w')\r\n\r\nb, g = map(int, read_file.readline().split())\r\ns = \"\"\r\ns += ('G'*(g-b) if g > b else 'B'*(b-g))\r\nif g >= b:\r\n s += (\"BG\"*(b))\r\nelse:\r\n s += (\"GB\"*(g))\r\n\r\nwrite_file.write(s)\r\n", "import sys\nsys.stdin = open(\"input.txt\",\"r\")\nsys.stdout = open(\"output.txt\",\"w\")\na,b = input().split()\na,b = int(a),int(b)\nif a==b:\n for i in range(a):\n print(\"GB\",end=\"\")\nif a>b:\n d=a-b\n for i in range(d):\n print(\"B\",end=\"\")\n for i in range(b):\n print(\"GB\",end=\"\")\nif a<b:\n d=b-a\n for i in range(a):\n print(\"GB\",end=\"\")\n for i in range(d):\n print(\"G\",end=\"\")\n\t\t\t\t\t \t\t \t \t\t\t\t\t \t\t \t \t", "'''\r\nn,m=map(int,input().split())\r\nif n>m:\r\n print(\"BG\"*m+\"B\"*(n-m))\r\nelse:\r\n print(\"GB\"*n+\"G\"*(m-n))\r\n'''\r\n\r\nf=open('input.txt','r')\r\nn,m=map(int,f.readline().split())\r\n\r\ng=open('output.txt','w')\r\nif n>m:\r\n g.write('BG'*m+'B'*(n-m))\r\nelse:\r\n g.write('GB'*n+'G'*(m-n))\r\n", "with open(\"input.txt\") as fh:\n first_line = fh.readline()\n n,m = map(int, first_line.split())\noutfile = open(\"output.txt\", \"w\")\nb = 0\ng = 0\nif n >= m:\n while b < n:\n outfile.write(\"B\")\n if g < m:\n outfile.write(\"G\")\n g += 1\n b += 1\nelse:\n while g < m:\n outfile.write(\"G\")\n if b < n:\n outfile.write(\"B\")\n b += 1\n g += 1\noutfile.close()\n \n\t \t \t\t \t \t\t \t\t\t\t \t \t\t", "f=open('input.txt','r')\r\nf1=open('output.txt','w')\r\nfor i in f:\r\n\tt=''\r\n\tn,m=map(int,i.split())\r\n\tif n>=m:t='B'*(n-m)+'GB'*m\r\n\telse:t='G'*(m-n)+'BG'*n\r\n\tf1.write(t)\r\nf.close();f1.close()", "f = open(\"input.txt\", \"r\")\r\nfo = open(\"output.txt\", \"w\")\r\n#print(f.readlines())\r\nfor line in f.readlines():\r\n #print(line)\r\n n, m = map(int, line.rstrip().split())\r\n if n>=m:\r\n s = \"BG\"*m + \"B\"*(n-m)+\"\\n\"\r\n else:\r\n s = \"GB\"*n + \"G\"*(m-n)+\"\\n\"\r\n #print(s)\r\n fo.write(s)\r\nf.close()\r\nfo.close()\r\n", "file = open(\"input.txt\", \"r\")\ntext = [line.rstrip() for line in file]\nfile.close()\n\nx = text[0].split()\nn = int(x[0])\nm = int(x[1])\n\nboys = [\"B\" for i in range(n)]\ngirls = [\"G\" for i in range(m)]\n\noutput = []\nfor b, g in zip(boys, girls):\n if len(boys) > len(girls):\n output.append(b)\n output.append(g)\n else:\n output.append(g)\n output.append(b)\n\nif len(boys) > len(girls):\n size = len(boys) - len(girls)\n output += boys[-size:]\n\nif len(girls) > len(boys):\n size = len(girls) - len(boys)\n output += girls[-size:]\n\nfile = open(\"output.txt\", \"w\")\nfile.write(\"\".join(output))\nfile.close()\n \t \t\t\t\t \t \t\t \t \t \t \t\t\t\t\t", "input_txt = open(\"input.txt\", \"r\")\n\nn, m = map(int, input_txt.readline().split())\nif n >= m:\n\tres = 'BG' * m+'B' * (n-m)\nelse:\n\tres = 'GB' * n+'G' * (m-n)\t\n\noutput_txt = open('output.txt', 'w')\noutput_txt.write(res)\ninput_txt.close()\noutput_txt.close()\n \t \t\t\t\t\t\t\t \t \t\t\t\t\t\t\t \t\t \t\t\t\t", "def readLine(file):\r\n f = open(file, \"r\")\r\n line = f.readline()\r\n f.close()\r\n return line\r\n\r\ndef writeLine(file, line):\r\n f = open(file, \"w\")\r\n f.writelines(line)\r\n f.close()\r\n\r\ndef solve(n, m):\r\n s = ''\r\n if n > m:\r\n s = list((n+m)*'B')\r\n \r\n for i in range(m):\r\n s[2*(i+1)-1] = 'G'\r\n else:\r\n s = list((n+m)*'G')\r\n \r\n for i in range(n):\r\n s[2*(i+1)-1] = 'B'\r\n \r\n return ''.join(s)\r\n\r\nif __name__ == \"__main__\":\r\n n, m = map(int, readLine(\"input.txt\").split(\" \"))\r\n writeLine(\"output.txt\", solve(n, m))", "with open('input.txt','r') as file:\r\n n,m = map(int,file.read().split())\r\nif (n>=m):\r\n with open('output.txt','w') as file:\r\n file.write('BG'*(m)+'B'*(n-m))\r\nelse:\r\n with open('output.txt','w') as file:\r\n file.write('GB'*(n)+'G'*(m-n))", "with open(\"input.txt\", \"r\") as file:\r\n data = [i.rstrip(\"\\n\") for i in file.readlines()]\r\nwith open(\"output.txt\", \"w\") as file:\r\n b, g = [int(i) for i in data[0].split()]\r\n ans = \"\"\r\n if (b > g):\r\n ans += 'B'\r\n b -= 1\r\n mi = min(b, g)\r\n ans += 'GB' * mi\r\n ans += 'G' * (g - mi)\r\n ans += 'B' * (b - mi)\r\n file.write(ans + '\\n')\r\n", "f = open(\"input.txt\", 'r')\r\npeople = list(map(int, f.read().split()))\r\nf.close()\r\nboys = people[0]\r\ngirls = people[1]\r\n \r\nunit = 'BG'\r\nunit_2 = 'GB'\r\n \r\nanswer = ''\r\nboy = 'B'\r\ngirl = 'G'\r\n \r\nif boys == girls:\r\n for i in range(boys):\r\n answer += unit\r\nelif boys > girls:\r\n for i in range(girls):\r\n answer += unit\r\n for i in range(boys-girls):\r\n answer += boy\r\nelif girls > boys:\r\n for i in range(boys):\r\n answer += unit_2\r\n for i in range(girls-boys):\r\n answer += girl\r\nfw = open(\"output.txt\", \"w\")\r\nfw.write(answer)", "with open(\"input.txt\", \"r\") as file:\r\n n, m = [int(e) for e in file.readline().strip().split()]\r\nif n >= m:\r\n _maxc = n\r\n _minc = m\r\n _max = \"B\"\r\n _min = \"G\"\r\nelse:\r\n _maxc = m\r\n _minc = n\r\n _max = \"G\"\r\n _min = \"B\"\r\nres = \"\"\r\nfor i in range(_minc*2):\r\n if i % 2:\r\n res += _min\r\n else:\r\n res += _max\r\nfor i in range(_maxc-_minc):\r\n res += _max\r\nwith open(\"output.txt\", \"w\") as file:\r\n file.write(str(res))\r\n", "f=open('input.txt', 'r')\r\no=open(\"output.txt\",'w')\r\nb,g=map(int,f.readline().split())\r\nif b==g:\r\n ans=\"BG\"*b\r\nelif b>g:\r\n ans=\"BG\"*g+\"B\"*(b-g)\r\nelse:\r\n ans=\"GB\"*b+\"G\"*(g-b)\r\no.write(ans)", "f=open(\"input.txt\", \"r\")\r\ng=open(\"output.txt\", \"w\")\r\nn,m=map(int,f.readline().split())\r\nif n==m :\r\n g.write(\"GB\"*n)\r\nelif n>m :\r\n g.write((\"BG\"*m)+(\"B\"*(n-m)))\r\nelif m>n :\r\n g.write((\"GB\"*n)+(\"G\"*(m- n)))", "input=open(\"input.txt\",'r')\r\noutput=open(\"output.txt\",'w')\r\n\r\na,b=map(int,input.readline().split())\r\noutput.write(['BG'*b+'B'*(a-b),'GB'*a+'G'*(b-a)][a<b]) ", "f = open(\"input.txt\", 'r') \r\nn, m = map(int, f.readline().split()) \r\nans = '' \r\nif n>m : \r\n for i in range(n+m): \r\n if i<2*m : \r\n if i%2==0 : ans += 'B' \r\n else : ans += 'G' \r\n else : ans += 'B' \r\nelse : \r\n for i in range(n+m): \r\n if i<2*n : \r\n if i%2==0 : ans += 'G' \r\n else : ans += 'B' \r\n else : ans += 'G' \r\no = open('output.txt', 'w') \r\no.write(ans)", "def main():\r\n f = open('input.txt','r')\r\n o = open('output.txt','w')\r\n b,g = map(int,f.readline().split())\r\n ans=\"\"\r\n if b>=g:\r\n i,j,k=0,0,0\r\n while(True):\r\n if i<b and j<g:\r\n ans+=\"BG\"\r\n i+=1\r\n j+=1\r\n elif i<b and j>=g:\r\n ans+=\"B\"\r\n i+=1\r\n else:\r\n break\r\n elif g>=b:\r\n i,j,k=0,0,0\r\n while(True):\r\n if i<b and j<g:\r\n ans+=\"GB\"\r\n i+=1\r\n j+=1\r\n elif i>=b and j<g:\r\n ans+=\"G\"\r\n j+=1\r\n else:\r\n break\r\n\r\n o.write(ans)\r\n o.close()\r\nif __name__ == '__main__':\r\n main()\r\n", "inputFile = open(\"input.txt\", \"r\")\noutputFile = open(\"output.txt\", \"w\")\n\ninputLines = inputFile.readlines()\n\nGirls, Boys = map(int, inputLines[0].split())\nAnswer = \" \"\nif Boys == Girls:\n Answer = \"GB\" * Girls\n print(Answer, file = outputFile) \nif Boys > Girls:\n Answer = \"GB\" * Girls\n Answer = Answer + (\"G\" * (Boys-Girls))\n print(Answer, file = outputFile)\nif Girls > Boys:\n Answer = \"BG\" * Boys\n Answer = Answer + (\"B\" * (Girls-Boys))\n print(Answer, file = outputFile)\n\ninputFile.close()\noutputFile.close()\n\n#General format from MSI\n \t\t \t\t\t \t \t \t\t\t\t\t\t \t\t\t\t \t\t\t\t", "f = open(\"input.txt\", 'r')\r\ng = open(\"output.txt\", 'w')\r\n\r\nn, m = map(int, f.readline().split())\r\nif n < m:\r\n g.write('GB' * n + 'G' * (m - n))\r\nelse:\r\n g.write('BG' * m + 'B' * (n - m))", "Fi=open('input.txt','r')\r\nFo=open('output.txt','w')\r\nn,m=map(int,Fi.readline().split())\r\nS=''\r\nNb=m+n\r\nif n>m:\r\n for i in range(Nb):\r\n if i%2==0 or m==0:\r\n S+='B'\r\n else:\r\n S+='G'\r\n m-=1\r\nelse:\r\n for i in range(Nb):\r\n if i%2==0 or n==0:\r\n S+='G'\r\n else:\r\n S+='B'\r\n n-=1\r\nFo.write(S)\r\nFi.close()\r\nFo.close()", "n = open('input.txt', 'r')\nm = open('output.txt', 'w')\nx, y = map(int, n.readline().split())\n\nif x >= y:\n m.write('BG' * y + 'B' * (x-y))\nelse:\n m.write('GB' * x + 'G' * (y-x)) \n\t \t \t\t \t \t \t\t \t \t", "file=open(\"input.txt\",'r');c=open(\"output.txt\",'w')\na,b=map(int,file.readline().split())\nc.write(['BG'*b+'B'*(a-b),'GB'*a+'G'*(b-a)][a<b])\n#https://codeforces.com/contest/253/status/A, siddartha19 81809690\n\t\t\t\t\t \t \t \t\t \t \t\t\t\t\t \t \t \t\t", "#E / seating chart GB\niput=open('input.txt','r') #reading input\nouput=open('output.txt','w') #writing output\nfor i in iput:\n n,m=i.split() \n n=int(n) #boys\n m=int(m) #girls\nif n==m: #boys equal amount of girls\n ouput.write('GB'*n) \nelif m>n: #more girls than boys\n ouput.write('GB'*n+'G'*(m-n)) #m-n gives difference\nelse: #more boys than girls\n ouput.write('BG'*m+'B'*(n-m)) #n-m gives difference\n\t \t\t\t \t \t \t\t\t \t \t \t\t \t \t", "\ninput_file = open('input.txt', 'r')\noutput_file = open('output.txt', 'w')\nBoy,Girl = map(int,input_file.readline().split())\n\n\noutputer = ''\n\nif Boy >= Girl:\n outputer = ('BG' * Girl) + 'B' * (Boy - Girl)\n\n\nif Girl > Boy:\n outputer = ('GB' * Boy) + 'G' * (Girl - Boy)\n\n\n\noutput_file.write(outputer)\n\t \t \t \t\t \t\t \t \t\t \t\t \t\t \t\t", "\r\nfile1=open(\"input.txt\",'r')\r\n \r\n \r\nn,m=map(int, file1.readline().split())\r\nfile1.close()\r\n \r\nfile2=open(\"output.txt\",'w')\r\n \r\nif n>m:\r\n s=('BG'*m)+('B'*(n-m))\r\n file2.write(s)\r\nelse:\r\n s=('GB'*n)+('G'*(m-n))\r\n file2.write(s)\r\n \r\nfile2.close()", "inp = open('input.txt', 'r')\nout = open('output.txt', 'w')\nn, m = [int(x) for x in inp.readline().split()]\ninp.close()\ns = ''\nif n > m:\n s += 'BG' * m\n s += 'B' * (n - m)\nelse:\n s += 'GB' * n\n s += 'G' * (m - n)\nprint(s, file = out)\nout.close()\n \n \t \t\t\t\t\t \t \t \t\t\t\t \t\t \t\t", "f = open(\"input.txt\",'r')\r\ng = open(\"output.txt\",'w')\r\nn, m = map(int, f.readline().split())\r\nstart = \"\"\r\nend = \"\"\r\nrow = \"\"\r\nif n > m:\r\n start = \"B\"\r\n end = \"G\"\r\nelse:\r\n start = \"G\"\r\n end = \"B\"\r\ni, j = 0, 0\r\nwhile i < n and j < m:\r\n row += start\r\n row += end\r\n i += 1\r\n j += 1\r\nwhile i < n:\r\n row += \"B\"\r\n i += 1\r\nwhile j < m:\r\n row += \"G\"\r\n j += 1\r\ng.write(row)", "Fi = open('input.txt', 'r')\r\nFo = open('output.txt', 'w')\r\nB, G = Fi.read().split()\r\nB = int(B)\r\nG = int(G)\r\n\r\nif B > G:\r\n Fo.write('BG'*G + 'B'*(B-G))\r\nelse:\r\n Fo.write('GB'*B + 'G'*(G-B))\r\n", "fin = open(\"input.txt\", \"r\")\r\nfout = open(\"output.txt\", \"w\")\r\n \r\nnboys, ngirls = map(int, fin.readline().strip().split())\r\n \r\n \r\nif nboys >= ngirls:\r\n s = \"BG\" * ngirls + \"B\" * (nboys - ngirls)\r\nelse:\r\n s = \"GB\" * nboys + \"G\" * (ngirls - nboys)\r\n \r\nfout.write(s)", "with open('input.txt', 'r') as fi:\r\n b, g = list(map(int, fi.readline().strip().split()))\r\nd = min(b, g)\r\nresult = 'BG' * d\r\nb -= d\r\ng -= d\r\nif b > 0:\r\n result += 'B' * b\r\nelse:\r\n result = 'G' * g + result\r\nwith open('output.txt', 'w') as fo:\r\n fo.write(result)", "import sys\r\nsys.stdin = open('input.txt', 'r') \r\nsys.stdout = open('output.txt', 'w')\r\nn, m = map(int, input().split())\r\nif n>=m: print(\"BG\"*m + \"B\"*(n-m))\r\nelif m>n: print(\"GB\"*n + \"G\"*(m-n))", "import string\r\n\r\nalph = string.ascii_lowercase\r\n\r\ndef check(a, b):\r\n for i in range(len(a)):\r\n if a[i] >= b[i]:\r\n return 0\r\n\r\n return 1\r\n\r\n\r\ndef main():\r\n with open(\"input.txt\", \"r\") as fin:\r\n f = fin.readlines()\r\n n, m = list(map(int, f[0].split()))\r\n ans = ''\r\n cnt1, cnt2 = m, n\r\n if n >= m:\r\n prev = 'B'\r\n else:\r\n prev = 'G'\r\n for i in range(n+m):\r\n if prev == 'G' and cnt1 > 0:\r\n ans += prev\r\n prev = 'B'\r\n cnt1 -= 1\r\n elif prev == 'G':\r\n prev = 'B'\r\n ans += prev\r\n cnt2 -= 1\r\n elif prev == 'B' and cnt2 > 0:\r\n ans += prev\r\n prev = 'G'\r\n cnt2 -= 1\r\n elif prev == 'B':\r\n prev = 'G'\r\n ans += prev\r\n cnt1 -= 1\r\n with open('output.txt', 'w') as fout:\r\n fout.write(ans)\r\n\r\nif __name__ == \"__main__\":\r\n main()", "import sys\r\n#input=sys.stdin.readline\r\nsys.stdout = open('output.txt','w')\r\nsys.stdin = open('input.txt','r')\r\n\r\n\r\nT = 1#int(input())\r\nwhile(T>0):\r\n T-=1\r\n n,m = map(int,input().split())\r\n ans = \"\"\r\n if(n>m):\r\n ans+=\"BG\"*(m)\r\n ans+=\"B\"*(n-m)\r\n else:\r\n ans+=\"GB\"*(n)\r\n ans+=\"G\"*(m-n)\r\n print(ans)", "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\n\r\nf=open(\"input.txt\",'r');g=open(\"output.txt\",'w')\r\nn,m=map(int,f.readline().split())\r\n\r\n \r\ndef solve():\r\n \r\n if n > m :\r\n g.write((\"BG\"*m)+\"B\"*(n-m))\r\n else :\r\n g.write((\"GB\"*n)+\"G\"*(m-n))\r\n \r\n \r\n \r\n \r\n\r\n# for _ in range(int(input())):\r\nsolve ()", "boys, girls = 0, 0\r\nwith open(\"input.txt\") as f:\r\n for line in f:\r\n boys, girls = map(int, line.split())\r\n\r\nqueue_length = boys + girls\r\ncommon_pattern = \"BG\" if boys >= girls else \"GB\"\r\nadditional_pattern = \"B\" if boys >= girls else \"G\"\r\nmin_length = min(boys, girls)\r\nans = \"\"\r\n\r\nfor _ in range(min_length): ans += common_pattern\r\nfor _ in range(queue_length - min_length * 2): ans += additional_pattern\r\n\r\nwith open(\"output.txt\", \"w\") as f:\r\n f.write(ans)", "a=open(\"input.txt\",'r')\nb=open(\"output.txt\",'w')\nx,y=map(int,a.readline().split())\nb.write(['BG'*y+'B'*(x-y),'GB'*x+'G'*(y-x)][x<y])\n \t\t \t \t\t\t \t \t\t\t \t \t\t\t \t \t", "with open(\"input.txt\") as f:\r\n s = f.readline()\r\n n = int(s.split(\" \")[0])\r\n m = int(s.split(\" \")[1])\r\n if m > n:\r\n ans = \"GB\" * n + \"G\" * (m - n)\r\n else:\r\n ans = \"BG\" * m + \"B\" * (n - m)\r\n f.close()\r\n with open(\"output.txt\", mode=\"w\") as f:\r\n f.write(ans)\r\n", "f = open(\"input.txt\")\r\nans = ''\r\nc = 1\r\na, b = map(int, f.read().split())\r\nif a > b:\r\n for i in range(b * 2):\r\n if c % 2 == 0:\r\n ans += \"G\"\r\n\r\n else:\r\n ans += \"B\"\r\n c += 1\r\n\r\n ans += \"B\"*((a + b) - len(ans))\r\n\r\nelse:\r\n for i in range(a * 2):\r\n if c % 2 == 0:\r\n ans += 'B'\r\n\r\n else:\r\n ans += \"G\"\r\n c += 1\r\n\r\n ans += \"G\" * ((a + b) - len(ans))\r\n\r\nf2 = open(\"output.txt\", \"w\")\r\nf2.write(ans)\r\n", "out = open('output.txt', 'w')\nwith open('input.txt', 'r') as f:\n b, g = map(int, f.readlines()[0].strip().split(' '))\n if b < g:\n out.write(('GB'*b) + ('G' * (g-b)) + '\\n')\n else:\n out.write(('BG'*g) + ('B' * (b-g)) + '\\n')\n", "with open('input.txt', 'r') as i:\n num = list(int(num) for num in i.read().split())[:2]\nb = num[0]\ng= num[1]\nbool = 0\nwith open('output.txt', 'w') as o:\n for i in range(g + b):\n if (g>=b or bool ==1):\n if(g>0):\n print(\"G\",file=o,end=\"\")\n g-=1\n if(b>0):\n print(\"B\",file=o,end=\"\")\n b-=1\n bool=1\n print(file=o)\n\n \t\t \t \t\t\t\t \t\t\t\t \t\t\t \t", "i = open(\"input.txt\", 'r')\r\no = open(\"output.txt\", 'w')\r\n\r\nn, m = map(int, i.readline().split())\r\nif n < m:\r\n o.write('GB' * n + 'G' * (m - n))\r\nelse:\r\n o.write('BG' * m + 'B' * (n - m))\r\n", "f=open(\"input.txt\",\"r\")\r\nfor j in f:\r\n x=list(map(int,j.split()))\r\nn=x[0]\r\nm=x[1]\r\nk=\"\"\r\nif(m==0):\r\n k=\"B\"*n\r\nelif(n==0):\r\n k=(\"G\"*m)\r\nelse:\r\n if(n>m):\r\n k=(\"BG\"*(m))\r\n k=k+(\"B\"*(n-m))\r\n else:\r\n k=(\"GB\"*(n))\r\n if(m!=n): \r\n k=k+(\"G\"*(m-n))\r\nwith open(\"output.txt\",\"w\") as f1:\r\n f1.write(k)\r\n\r\n", "f=open(\"input.txt\",'r');g=open(\"output.txt\",'w')\r\na, b =map(int,f.readline().split())\r\nres = ''\r\np = 'GB' if a < b else 'BG'\r\nres = p * min(a,b)\r\nres = res+('B'*abs(a-b)) if a > b else res + ('G'*abs(a-b))\r\ng.write(res)", "with open(\"input.txt\") as fh:\n content = fh.read()\n content = content.split()\n n = int(content[0])\n m = int(content[-1])\n\n\n\n if n > m:\n #print(n, \" is the number of boys\")\n #print(\"there are more boys than girls\")\n boys_left = n - m\n #print(boys_left)\n pairs = m\n\n eta = ((\"BG\")*pairs+(\"B\")*boys_left)\n\n else:\n #print(m, \" is the number of girls\")\n #print(\"there are more girls than boys\")\n girls_left = m - n\n #print(girls_left)\n pairs = n\n\n eta = (((\"GB\")*pairs)+(\"G\")*girls_left)\n \n #print(pairs, \" is the number of pairs\")\n\nwith open(\"output.txt\",\"w\") as g:\n g.write(eta)\n \n \n\t \t \t \t\t \t\t\t \t \t\t \t \t \t", "f=open(\"input.txt\",'r')\ng=open(\"output.txt\",'w')\nn,s=map(int,f.readline().split())\nt=min(n,s)\ng.write(['GB','BG'][t==s]*t+'G'*(s-t)+'B'*(n-t))\n \t\t \t \t \t \t \t\t \t\t \t \t \t \t", "a = open(\"input.txt\",'r')\r\n# print(a)\r\nar = a.read()\r\nar = ar.split(' ')\r\nn = int(ar[0])\r\nm = int(ar[1])\r\nif n>m:\r\n\ts = m*\"BG\"+(n-m)*'B'\r\n\tf = open(\"output.txt\", 'w')\r\n\tf.write(s)\r\n\tf.close()\r\n\t# print(s)\r\nelif m>=n:\r\n\ts = n*\"GB\"+(m-n)*'G'\r\n\tf = open(\"output.txt\", 'w')\r\n\tf.write(s)\r\n\tf.close()\r\n\t# print(s)", "import sys\nsys.stdin=open(\"input.txt\",\"r\")\nsys.stdout=open(\"output.txt\",\"w\")\nn,m=map(int,input().split())\na='GBBG'[n>m::2]\nprint(a*min(n,m)+a[0]*(max(n,m)-min(n,m)))\n\n \t\t \t\t\t \t \t\t\t\t \t \t", "with open(\"input.txt\", \"r\") as g:\n boys, girls = g.readline().split()\n boys = int(boys)\n girls = int(girls)\nif boys >= girls:\n diff = int(boys - girls)\n with open(\"output.txt\", \"w\") as h:\n h. write(\"BG\" * girls + \"B\" * diff)\nelse:\n diff = int(girls - boys)\n with open(\"output.txt\", \"w\") as h:\n h. write(\"GB\" * boys + \"G\" * diff)\n\t \t\t \t\t\t \t\t\t\t\t\t\t \t \t\t \t\t\t", "In=open(\"input.txt\",\"r\")\r\nOut=open(\"output.txt\",\"w\")\r\nn,m=In.readline().split()\r\nn=int(n)\r\nm=int(m)\r\ni=min(n,m)\r\nres=''\r\nif n<m:\r\n res+='GB'*n+'G'*(m-n)\r\nelse:\r\n res+='BG'*m+'B'*(n-m)\r\nprint(res,file=Out)\r\nIn.close()\r\nOut.close()", "iin=lambda: map(int,input().split())\r\nii=lambda: int(input())\r\nil=lambda: list(map(int,input().split()))\r\n\r\n\r\nf = open(\"input.txt\")\r\nn, m = map(int, f.read().split())\r\na=\"\"\r\nif(n>m):\r\n t=m\r\n while(t):\r\n t-=1\r\n a+=\"BG\"\r\n a+=\"B\"*(n-m)\r\nelse:\r\n t=n\r\n while(t):\r\n t-=1\r\n a+=\"GB\"\r\n a+=\"G\"*(m-n)\r\n\r\nf = open(\"output.txt\", 'w')\r\nf.write(a)\r\nf.close()", "f = open('input.txt', 'r')\r\nn, m = map(int, f.readline().split())\r\nf = open('output.txt', 'w')\r\nif n > m:\r\n print(('BG'*n)[:m*2]+'B'*(n-m), file=f)\r\nelse:\r\n print(('GB'*m)[:n*2] + 'G'*(m-n), file=f)", "\"\"\"\r\ndef main():\r\n f = open('input.txt','r')\r\n o = open('output.txt','w')\r\n b,g = map(int,f.readline().split())\r\n ans=\"\"\r\n if b>=g:\r\n i,j,k=0,0,0\r\n while(True):\r\n if i<b and j<g:\r\n ans+=\"BG\"\r\n i+=1\r\n j+=1\r\n elif i<b and j>=g:\r\n ans+=\"B\"\r\n i+=1\r\n else:\r\n break\r\n elif g>=b:\r\n i,j,k=0,0,0\r\n while(True):\r\n if i<b and j<g:\r\n ans+=\"GB\"\r\n i+=1\r\n j+=1\r\n elif i>=b and j<g:\r\n ans+=\"G\"\r\n j+=1\r\n else:\r\n break\r\n\r\n o.write(ans)\r\n o.close()\r\nif __name__ == '__main__':\r\n main()\r\n\"\"\"\r\nimport sys\r\ndef main():\r\n sys.stdin = open(\"input.txt\")\r\n sys.stdout = open(\"output.txt\", 'w')\r\n b, g = map(int, input().split())\r\n ans = \"\"\r\n if b >= g:\r\n i, j, k = 0, 0, 0\r\n while (True):\r\n if i < b and j < g:\r\n ans += \"BG\"\r\n i += 1\r\n j += 1\r\n elif i < b and j >= g:\r\n ans += \"B\"\r\n i += 1\r\n else:\r\n break\r\n elif g >= b:\r\n i, j, k = 0, 0, 0\r\n while (True):\r\n if i < b and j < g:\r\n ans += \"GB\"\r\n i += 1\r\n j += 1\r\n elif i >= b and j < g:\r\n ans += \"G\"\r\n j += 1\r\n else:\r\n break\r\n print(ans)\r\nif __name__ == '__main__':\r\n main()\r\n", "input_file = open('input.txt', 'r')\ninput = input_file.readlines()\ninput_file.close() \n\ninput_file = open('input.txt', 'r')\ninput_list = input_file.readlines()\nb, g = map(int, input_list[0].split())\n\nnum_students = b + g\noutput_str = ''\n\n\nif(b > g):\n while(g != 0):\n output_str += 'BG'\n b -= 1\n g -= 1\n for i in range(b):\n output_str += 'B'\nelif(g > b):\n while(b != 0):\n output_str += 'GB'\n b -= 1\n g -= 1\n for i in range(g):\n output_str += 'G'\nelse:\n while(b != 0):\n output_str += 'BG'\n b -= 1\n\n\noutput_file = open('output.txt', 'w')\noutput_file.write(output_str)\noutput_file.close()\n\t\t \t \t \t\t \t \t\t \t \t\t\t\t\t\t", "fin = open(\"input.txt\", \"r\")\nfout = open(\"output.txt\", \"w\")\nn, m = map(int, fin.readline().split())\ni=0\ns=''\nif(n>m):\n while(i<m):\n s+='BG'\n i+=1\n s+='B'*(n-m)\nelse:\n while(i<n):\n s+='GB'\n i+=1\n s+='G'*(m-n)\nfout.write(s)\n\t\t \t\t \t \t\t \t \t\t \t\t \t \t", "import sys\r\nfrom os import path\r\n\r\nFILE = True # if needed change it while submitting\r\n\r\nif FILE:\r\n\tsys.stdin = open('input.txt', 'r')\r\n\tsys.stdout = open('output.txt', 'w')\r\n\r\ndef get_int():\r\n\treturn int(sys.stdin.readline())\r\n\r\ndef get_string():\r\n\treturn sys.stdin.readline().strip()\r\nn,m=map(int,get_string().split())\r\nif(n==m):\r\n sys.stdout.write('BG'*n)\r\nelif(n>m):\r\n sys.stdout.write('BG'*m+'B'*(n-m))\r\nelse:\r\n sys.stdout.write('GB'*n+'G'*(m-n))", "#文字列入力はするな!!\r\n#carpe diem\r\n\r\n'''\r\n ██╗ ██╗ ███╗ ███╗ ██╗ ████████╗\r\n ██║ ██║ ████╗ ████║ ██║ ╚══██╔══╝\r\n═════════██╠════════██╠═══██╔████╔██╠═══██╠══════██╠══════════\r\n ██║ ██║ ██║╚██╔╝██║ ██║ ██║\r\n ███████╗ ██║ ██║ ╚═╝ ██║ ██║ ██║\r\n ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\r\n'''\r\n\r\n#文字列入力はするな!!\r\n#carpe diem\r\n#Skip the contest if A,B or C is bitwise problem \r\n#Special cases like n=1\r\n#don't get stuck on one approach \r\n# import sys\r\n# input = lambda: sys.stdin.readline().rstrip()\r\nip = open(\"input.txt\",\"r\")\r\nop = open('output.txt','w')\r\nn,m = map(int,ip.readline().split())\r\nif n>=m:\r\n\tres = 'BG'*m+'B'*(n-m)\r\nelse:\r\n\tres = 'GB'*n+'G'*(m-n)\t\r\nop.write(res)\r\n \r\n\r\n\r\n\r\n\r\n#Skip the contest if A,B or C is bitwise problem \r\n#Special cases like n=1\r\n#don't get stuck on one approach \r\n \r\n\r\n#carpe diem\r\n" ]
{"inputs": ["3 3", "4 2", "5 5", "6 4", "100 1", "76 48", "100 90", "90 100", "1 98", "1 100", "56 98", "89 89", "18 94", "84 27", "1 1", "1 2", "2 1", "1 34", "46 2", "99 3", "10 100", "100 100", "1 4"], "outputs": ["GBGBGB", "BGBGBB", "GBGBGBGBGB", "BGBGBGBGBB", "BGBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "BGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "BGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBBBBBBBBBB", "GBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGGGGGGGGGG", "GBGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG", "GBGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG", "GBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG", "GBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGB", "GBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG", "BGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "GB", "GBG", "BGB", "GBGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG", "BGBGBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "BGBGBGBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "GBGBGBGBGBGBGBGBGBGBGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG", "GBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGBGB", "GBGGG"]}
UNKNOWN
PYTHON3
CODEFORCES
92
e38c20558f898049bdd9d53ea518eea9
Permutation Game
*n* children are standing in a circle and playing a game. Children's numbers in clockwise order form a permutation *a*1,<=*a*2,<=...,<=*a**n* of length *n*. It is an integer sequence such that each integer from 1 to *n* appears exactly once in it. The game consists of *m* steps. On each step the current leader with index *i* counts out *a**i* people in clockwise order, starting from the next person. The last one to be pointed at by the leader becomes the new leader. You are given numbers *l*1,<=*l*2,<=...,<=*l**m* — indices of leaders in the beginning of each step. Child with number *l*1 is the first leader in the game. Write a program which will restore a possible permutation *a*1,<=*a*2,<=...,<=*a**n*. If there are multiple solutions then print any of them. If there is no solution then print -1. The first line contains two integer numbers *n*, *m* (1<=≤<=*n*,<=*m*<=≤<=100). The second line contains *m* integer numbers *l*1,<=*l*2,<=...,<=*l**m* (1<=≤<=*l**i*<=≤<=*n*) — indices of leaders in the beginning of each step. Print such permutation of *n* numbers *a*1,<=*a*2,<=...,<=*a**n* that leaders in the game will be exactly *l*1,<=*l*2,<=...,<=*l**m* if all the rules are followed. If there are multiple solutions print any of them. If there is no permutation which satisfies all described conditions print -1. Sample Input 4 5 2 3 1 4 4 3 3 3 1 2 Sample Output 3 1 2 4 -1
[ "n,m=map(int,input().split())\r\nl=[]\r\nl=list(map(int,input().split()))\r\na=[-1]*(n+1)\r\ns=set()\r\nsorry = False\r\nfor i in range(1,n+1):\r\n s.add(i)\r\nfor i in range(m-1):\r\n temp = (l[i+1] + n - l[i])%n\r\n if(temp == 0):\r\n temp = n\r\n #print(temp)\r\n if(a[l[i]] == -1 and temp in s):\r\n a[l[i]] = temp\r\n s.remove(temp)\r\n\r\n elif(a[l[i]] == temp):\r\n continue\r\n else:\r\n sorry=True\r\n break\r\n\r\nif(sorry):\r\n print(-1)\r\nelse:\r\n ss = list(s)\r\n x=0\r\n for i in range(1,len(a)):\r\n if(a[i] == -1):\r\n a[i] = ss[x]\r\n x+=1\r\n print(a[i],\"\",end='')\r\n", "n,m=map(int,input().split())\r\nls=list(map(int,input().split()))\r\nz={}\r\nfor i in range(m-1):\r\n if ls[i] not in z:\r\n if ls[i+1]<ls[i]:\r\n z[ls[i]]=(ls[i+1]+n-ls[i])%(n+1)\r\n elif ls[i+1]==ls[i]:\r\n z[ls[i]] = n\r\n else:\r\n z[ls[i]] = (ls[i + 1] - ls[i]) % (n + 1)\r\n\r\n else:\r\n if ls[i + 1] < ls[i]:\r\n x=(ls[i+1]+n-ls[i])%(n+1)\r\n elif ls[i+1]==ls[i]:\r\n x = n\r\n else:\r\n x=(ls[i + 1] - ls[i]) % (n + 1)\r\n if z[ls[i]]!=x:\r\n print(-1)\r\n exit()\r\nif len(set(z.values()))!=len(z.values()):\r\n print(-1)\r\n exit()\r\nc=list(range(1,n+1))\r\nfor i in z.values():\r\n if i in c:\r\n c.remove(i)\r\nfor i in range(1,n+1):\r\n if i in z:\r\n print(z[i],end=\" \")\r\n else:\r\n print(c.pop(0),end=\" \")", "#!/usr/bin/env python3\n\n[n, m] = map(int, input().strip().split())\nlis = list(map(int, input().strip().split()))\n\ndef solve():\n\tres = [0 for _ in range(n)]\n\tused = [False for _ in range(n)]\n\tfor l0, l1 in zip(lis, lis[1:]):\n\t\tal0 = n - (l0 - l1) % n\n\t\tif (res[l0 - 1] != 0 and res[l0 - 1] != al0) or (res[l0 - 1] == 0 and used[al0 -1]):\n\t\t\treturn [-1]\n\t\tres[l0 - 1] = al0\n\t\tused[al0 - 1] = True\n\ti0s = [i for i, a in enumerate(res) if a == 0]\n\tnot_used = list(set(range(1, n + 1)) - set(res))\n\tfor i, a in zip(i0s, not_used):\n\t\tres[i] = a\n\treturn res\n\nres = solve()\nprint (' '.join(map(str, res)))\n", "n, m = map(int, input().split())\na = list(map(int, input().split()))\nans = [0] * (n + 1)\nfor i in range(m - 1):\n\tpot = (a[i + 1] - a[i] + n) % n\n\tif pot == 0: pot = n\n\tif ans[a[i]] == 0 or ans[a[i]] == pot: ans[a[i]] = pot\n\telse:\n\t\tprint(-1)\n\t\texit(0)\nused = [False] * (n + 1)\nfor i in ans:\n\tused[i] = True\nfor i in range(1, n + 1):\n\tif ans[i] == 0:\n\t\tfor j in range(1, n + 1):\n\t\t\tif not used[j]:\n\t\t\t\tused[j] = True\n\t\t\t\tans[i] = j\n\t\t\t\tbreak\nprint(' '.join(map(str, ans[1:])) if all(used[1:]) else -1)\n", "def calc(a,b,n):\n\tif(b<=a):\n\t\treturn n-a+b\n\telse:\n\t\treturn b-a\n\ninp=input().split()\nn=int(inp[0])\nm=int(inp[1])\nseq=[]\ninp=input().split()\nfor val in inp:\n\tseq.append(int(val))\nindices={}\nflag=0\nfor i in range(len(seq)-1):\n\thop=calc(seq[i],seq[i+1],n)\n\tif((seq[i] in indices) and indices[seq[i]]!=hop):\n\t\tprint(\"-1\")\n\t\tflag=1\n\t\tbreak\n\tindices[seq[i]]=hop\nl=[]\nfor i in range(n+1):\n\tl.append(1)\nflag2=0\nif(flag==0):\n\tfor i in range(1,n+1):\n\t\ttry:\n\t\t\tval=indices[i]\n\t\texcept:\n\t\t\tcontinue\n\t\tif(l[val]==1):\n\t\t\tl[val]=0\n\t\telse:\n\t\t\tprint(\"-1\")\n\t\t\tflag2=1\n\t\t\tbreak\n\tif(flag2==0):\n\t\tfor i in range(1,n+1):\n\t\t\ttry:\n\t\t\t\tprint(indices[i],end=\" \")\n\t\t\texcept:\n\t\t\t\tj=1\n\t\t\t\twhile(l[j]==0):\n\t\t\t\t\tj+=1\n\t\t\t\tprint(j,end=\" \")\n\t\t\t\tl[j]=0\n\t\tprint()", "n,m = map(int,input().split())\r\nl =list(map(int,input().split()))\r\nmark={}\r\na=[-1]*(n)\r\nfor i in range(m-1):\r\n temp=l[i+1]-l[i]\r\n if l[i+1]-l[i] <=0:\r\n temp+=n\r\n if a[l[i]-1]==temp:\r\n continue\r\n if a[l[i]-1]==-1:\r\n a[l[i]-1]+=temp+1\r\n if a[l[i]-1] not in mark:\r\n mark[a[l[i]-1]]=1\r\n else:\r\n print('-1')\r\n break\r\n else:\r\n print('-1')\r\n break \r\nelse: \r\n fill=[]\r\n for i in range(1,n+1):\r\n if i not in mark:\r\n fill.append(i)\r\n c=0\r\n for i in range(n):\r\n if c>=n:\r\n print('-1')\r\n break\r\n if a[i]==-1:\r\n a[i]=fill[c]\r\n c+=1\r\n print(*a)\r\n", "def f(a,b,c):\r\n\tif (a-b+c)%c==0:\r\n\t\treturn c\r\n\telse:\r\n\t\treturn (a-b+c)%c\r\nn,m=list(map(int,input().split()))\r\nl=list(map(int,input().split()))\r\na=[0 for i in range(n)]\r\nfor i in range(m-1):\r\n\tif a[l[i]-1]==0 or a[l[i]-1]==f(l[i+1],l[i],n):\r\n\t\ta[l[i]-1]=f(l[i+1],l[i],n)\r\n\telse:\r\n\t\tprint(-1)\r\n\t\texit(0)\r\np=[i+1 for i in range(n)]\r\ns=list(set(p)-set([i for i in a if i!=0]))\r\nif len(s)!=a.count(0):\r\n\tprint(-1)\r\n\texit(0)\r\nelse:\r\n\tfor i in range(n):\r\n\t\tif a[i]==0:\r\n\t\t\ta[i]=s[-1]\r\n\t\t\ts.pop()\r\nfor i in a:\r\n\tprint(i,end=' ')", "\n\n\nn, m = map(int, input().split())\n\nL = [int(x) - 1 for x in input().split()]\n\nA = [-1 for _ in range(n)]\n\nN = set(range(n))\n\ngood = True\n\nx = L[0]\nfor q in L[1:]:\n dist = (q + n - x) % n\n if A[x] == -1:\n if dist in N:\n A[x] = dist\n N.remove(dist)\n else:\n good = False\n else:\n if A[x] != dist:\n good = False\n x = q\n\nfor i in range(len(A)):\n if A[i] == -1:\n A[i] = N.pop()\n\nif good:\n print(' '.join(map(lambda x: str(n if x == 0 else x), A)))\nelse:\n print(-1)\n", "f = lambda: map(int, input().split())\r\nn, m = f()\r\np = list(f())\r\nt = [0] * n\r\nfor x, y in zip(p, p[1:]):\r\n q = (y - x) % n\r\n if q == 0: q = n\r\n if 0 < t[x - 1] != q:\r\n print(-1)\r\n exit()\r\n t[x - 1] = q\r\np = set(t)\r\np.discard(0)\r\nif len(p) + t.count(0) < n:\r\n print(-1)\r\n exit()\r\ns = set(range(1, n + 1)).difference(p)\r\nfor q in t: print(q if q else s.pop())", "n,m = map(int, input().split())\nl = list(map(int, input().split()))\na = [-1]*(n + 1)\ns = [True] + [False]*n\nfor i in range(m - 1):\n curr = l[i + 1] - l[i]\n if curr <= 0:\n curr += n\n if a[l[i]] == curr:\n continue\n if s[curr] or a[l[i]] != -1:\n print(\"-1\")\n exit()\n s[curr] = True\n a[l[i]] = curr\n\nfor i,x in enumerate(a[1:]):\n if x == -1:\n for j in range(len(s)):\n if s[j] == False:\n s[j] = True\n a[i + 1] = j\n break\nprint(\" \".join(str(x) for x in a[1:]))\n", "def main():\r\n n,m = map(int,input().split())\r\n l = list(map(int,input().split()))\r\n for i in range(m):\r\n l[i] -= 1\r\n\r\n a = [-1 for i in range(n)]\r\n\r\n now = l[0]\r\n for i in range(1,m):\r\n if a[now] == -1:\r\n for j in range(1,n+1):\r\n if (now + j)%n == l[i]:\r\n a[now] = j\r\n break\r\n\r\n now = (now+a[now])%n\r\n if now != l[i]:\r\n print(-1)\r\n return\r\n\r\n ct = [0 for i in range(n+1)]\r\n for i in range(n):\r\n if a[i]>0:\r\n ct[a[i]] += 1\r\n if ct[a[i]] > 1:\r\n print(-1)\r\n return\r\n\r\n idx = 1\r\n for i in range(n):\r\n while idx <= n and ct[idx] != 0:\r\n idx += 1\r\n\r\n if a[i] == -1:\r\n if idx > n:\r\n print(-1)\r\n return\r\n a[i] = idx\r\n ct[idx] += 1\r\n\r\n print(' '.join(map(str,a)))\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "R=lambda:map(int,input().split())\nn,m=R()\nl=list(R())\na=[None]*n\nc =set(range(1, n + 1))\nfor i in range(m-1):\n j=l[i]-1\n d=l[i+1]-l[i]\n if d<=0:\n d+=n\n if a[j]!=d:\n if a[j] or d not in c:\n print(-1)\n exit()\n a[j]=d\n c.remove(d)\nfor i in range(n):\n if a[i] is None:\n a[i]=c.pop()\nprint(*a)\n\t\t \t\t \t\t \t \t \t\t\t \t \t\t\t\t", "import sys, math\r\ninput=sys.stdin.readline\r\nINF=int(1e9)+7\r\n\r\n\r\ndef solve():\r\n n,m=map(int,input().split())\r\n data=list(map(int,input().split()))\r\n result=[0]*(n+1)\r\n for i in range(1,m):\r\n now=(data[i]-data[i-1])%n\r\n if now==0: now=n\r\n if result[data[i-1]]:\r\n if result[data[i-1]]!=now:\r\n print(-1)\r\n return\r\n else:\r\n result[data[i-1]]=now\r\n left=[0]*(n+1)\r\n for i in range(1,n+1):\r\n if result[i]!=0:\r\n left[result[i]]+=1\r\n a=[]\r\n for i in range(1,n+1):\r\n if left[i]>1:\r\n print(-1)\r\n return\r\n elif left[i]==0:\r\n a.append(i)\r\n for i in range(1,n+1):\r\n if result[i]==0:\r\n result[i]=a.pop()\r\n print(*result[1:],sep=' ')\r\n \r\n \r\nt=1\r\nwhile t:\r\n t-=1\r\n solve()\r\n", "n, m = [int(x) for x in input().split()]\r\nl = [int(x) for x in input().split()]\r\na = [-1]*(n+1)\r\nt = True\r\nd1 = set()\r\nd = {}\r\nfor x in range(len(l)-1):\r\n if(l[x+1]-l[x] == 0):\r\n if(a[l[x]]!=-1 and a[l[x]]!=n):\r\n t = False\r\n d1.add(n)\r\n if(n in d):\r\n if( d[n]!=l[x] ):\r\n t = False\r\n else:\r\n d[n]=l[x]\r\n a[l[x]] = n\r\n \r\n else:\r\n if(l[x+1]-l[x] < 0):\r\n if(a[l[x]]!=-1 and a[l[x]]!=n + l[x+1]-l[x]):\r\n t = False\r\n if(n + l[x+1]-l[x] in d):\r\n if( d[n + l[x+1]-l[x]]!=l[x] ):\r\n t = False\r\n else:\r\n d[n + l[x+1]-l[x]]=l[x]\r\n d1.add(n + l[x+1]-l[x])\r\n a[l[x]] = n + l[x+1]-l[x]\r\n else:\r\n if(a[l[x]]!=-1 and a[l[x]]!=l[x+1]-l[x]):\r\n t = False\r\n if(l[x+1]-l[x] in d):\r\n if(d[l[x+1]-l[x]] != l[x]):\r\n t = False\r\n else:\r\n d[l[x+1]-l[x]]=l[x]\r\n d1.add(l[x+1]-l[x])\r\n a[l[x]] = l[x+1]-l[x]\r\nif(t == False):\r\n print(-1)\r\nelse:\r\n p = set([x for x in range(1,n+1)])\r\n p -=d1\r\n # t = 0\r\n for x in range(1,n+1):\r\n if(a[x]==-1):\r\n print(p.pop(),end=' ')\r\n # t+=1\r\n continue\r\n print(a[x],end=' ')\r\n \r\n # print(a[x],end=' ')\r\n", "n, m = map(int, input().split())\r\nl = list(map(int, input().split()))\r\n\r\ndata = [0] * n\r\ng = set(range(1, n + 1))\r\nfor i in range(m - 1):\r\n j, d = l[i] - 1, l[i + 1] - l[i]\r\n if d <= 0:\r\n d += n\r\n if data[j] != d:\r\n if data[j] or d not in g:\r\n print(-1)\r\n exit(0)\r\n data[j] = d\r\n g.remove(d)\r\nfor i in range(n):\r\n if not data[i]:\r\n data[i] = g.pop()\r\nprint(*data)\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn, m = map(int, input().split())\r\nw = list(map(int, input().split()))\r\nd = [0]*n\r\ns = dict()\r\nfor i in range(m-1):\r\n x = (w[i+1] - w[i] + n) % n\r\n if x == 0:\r\n x = n\r\n if d[w[i]-1] == 0:\r\n d[w[i]-1] = x\r\n if x not in s:\r\n s[x] = 1\r\n else:\r\n print(-1)\r\n exit()\r\n elif d[w[i]-1] != x:\r\n print(-1)\r\n exit()\r\n\r\nc = 1\r\nfor i in range(n):\r\n if d[i] == 0:\r\n while c in s:\r\n c += 1\r\n d[i] = c\r\n c += 1\r\nprint(' '.join(map(str, d)))", "n, m = map(int,input().split())\r\nlm = list(map(int,input().split()))\r\n\r\nimpossible = False\r\nan = [-1]*(n+1)\r\nf = [False]*(n+1)\r\nfor k in range(m-1):\r\n if an[lm[k]] < 0:\r\n for i in range(1,n+1):\r\n if f[i]:\r\n continue\r\n x = lm[k]+i\r\n if x > n:\r\n x -= n\r\n if lm[k+1] != x:\r\n continue\r\n an[lm[k]] = i\r\n f[i] = True\r\n break\r\n if an[lm[k]] < 0:\r\n impossible = True\r\n break\r\n else:\r\n x = lm[k]+an[lm[k]]\r\n if x > n:\r\n x -= n\r\n if lm[k+1] != x:\r\n impossible = True\r\n break\r\n\r\nif impossible:\r\n print(-1)\r\nelse:\r\n for i in range(1,n+1):\r\n if an[i] > 0:\r\n continue\r\n for j in range(1,n+1):\r\n if f[j]:\r\n continue\r\n an[i] = j\r\n f[j] = True\r\n break\r\n print(*an[1:])", "n, m = map(int, input().split())\r\na = list(map(int, input().split()))\r\nans = [0] * (n + 1)\r\nfor i in range(m - 1):\r\n\tpot = (a[i + 1] - a[i] + n) % n\r\n\tif pot == 0: pot = n\r\n\tif ans[a[i]] == 0 or ans[a[i]] == pot: ans[a[i]] = pot\r\n\telse:\r\n\t\tprint(-1)\r\n\t\texit(0)\r\nused = [False] * (n + 1)\r\nfor i in ans:\r\n\tused[i] = True\r\nfor i in range(1, n + 1):\r\n\tif ans[i] == 0:\r\n\t\tfor j in range(1, n + 1):\r\n\t\t\tif not used[j]:\r\n\t\t\t\tused[j] = True\r\n\t\t\t\tans[i] = j\r\n\t\t\t\tbreak\r\nprint(' '.join(map(str, ans[1:])) if all(used[1:]) else -1)", "n, m = map(int, input().split())\r\na = list(map(int, input().split()))\r\nused = [0]*(n+1)\r\nans = [0]*(n+1)\r\n \r\nfor x, y in zip(a, a[1:]):\r\n z = (y - x) % n or n\r\n if ans[x] == 0 and used[z] or ans[x] != 0 and ans[x] != z:\r\n print(-1)\r\n exit()\r\n used[z] = 1\r\n ans[x] = z\r\n \r\ni = 1\r\nfor j in range(1, n+1):\r\n if ans[j] == 0:\r\n while used[i]:\r\n i += 1\r\n ans[j] = i\r\n i += 1\r\n \r\nprint(*ans[1:])" ]
{"inputs": ["4 5\n2 3 1 4 4", "3 3\n3 1 2", "1 100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "6 8\n2 5 4 2 5 4 2 5", "100 1\n6", "10 5\n7 7 9 9 3", "10 20\n10 1 5 7 1 2 5 3 6 3 9 4 3 4 9 6 8 4 9 6", "20 15\n11 19 1 8 17 12 3 1 8 17 12 3 1 8 17", "100 100\n96 73 23 74 35 44 75 13 62 50 76 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63 29 45 24 63", "100 100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91", "20 20\n1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11", "20 5\n1 20 2 19 3", "19 19\n1 19 2 18 3 17 4 16 5 15 6 14 7 13 8 12 9 11 10", "100 100\n1 99 2 98 3 97 4 96 5 95 6 94 7 93 8 92 9 91 10 90 11 89 12 88 13 87 14 86 15 85 16 84 17 83 18 82 19 81 20 80 21 79 22 78 23 77 24 76 25 75 26 74 27 73 28 72 29 71 30 70 31 69 32 68 33 67 34 66 35 65 36 64 37 63 38 62 39 61 40 60 41 59 42 58 43 57 44 56 45 55 46 54 47 53 48 52 49 51 50 50", "51 18\n8 32 24 19 1 29 49 24 39 33 5 37 37 26 17 28 2 19", "5 5\n1 2 5 2 4", "6 6\n1 2 1 1 3 6", "4 4\n4 3 4 2", "3 3\n2 2 3", "4 6\n1 1 2 4 4 4", "9 4\n8 2 8 3", "4 6\n2 3 1 4 4 1", "2 3\n1 1 2", "5 7\n4 3 4 3 3 4 5", "2 9\n1 1 1 1 2 1 1 1 1", "4 4\n2 4 4 4", "3 3\n1 1 3", "2 5\n1 2 2 1 1", "4 4\n1 4 1 3", "3 4\n1 3 1 1", "4 4\n1 4 1 1", "66 67\n19 9 60 40 19 48 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5 58 5", "3 3\n3 3 2", "27 28\n8 18 27 24 20 8 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23", "4 3\n1 1 2", "4 4\n2 4 2 3", "2 3\n2 2 1", "2 2\n2 2", "3 4\n2 3 3 1", "5 6\n1 4 4 2 1 4", "4 3\n2 3 4", "2 3\n1 2 1", "10 4\n5 6 5 7", "3 3\n1 1 2", "4 5\n1 4 1 3 2", "6 5\n1 2 4 1 3"], "outputs": ["3 1 2 4 ", "-1", "1 ", "1 3 2 4 5 6 ", "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ", "-1", "-1", "7 1 18 3 4 5 6 9 10 12 8 11 13 14 16 17 15 19 2 20 ", "1 2 3 4 5 6 7 8 10 11 12 13 49 14 15 17 18 19 20 21 22 23 51 39 24 25 27 28 16 29 30 32 33 34 9 35 36 37 40 41 42 43 44 31 79 45 46 47 48 26 52 53 54 55 56 57 58 59 60 62 63 88 66 64 65 67 68 69 70 71 72 73 50 61 38 87 74 75 76 78 80 81 82 83 84 85 86 89 90 91 92 93 94 95 96 77 97 98 99 100 ", "-1", "19 17 15 13 11 9 7 5 3 1 20 18 16 14 12 10 8 6 4 2 ", "19 17 1 3 5 6 7 8 9 10 11 12 13 14 15 16 18 20 4 2 ", "-1", "98 96 94 92 90 88 86 84 82 80 78 76 74 72 70 68 66 64 62 60 58 56 54 52 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 100 99 97 95 93 91 89 87 85 83 81 79 77 75 73 71 69 67 65 63 61 59 57 55 53 51 49 47 45 43 41 39 37 35 33 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1 ", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "1 2 3 4 ", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "1 2 ", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1"]}
UNKNOWN
PYTHON3
CODEFORCES
19
e38dfdf946eae11efa5d9a21f3f4c2e0
Unsorting Array
Little Petya likes arrays of integers a lot. Recently his mother has presented him one such array consisting of *n* elements. Petya is now wondering whether he can swap any two distinct integers in the array so that the array got unsorted. Please note that Petya can not swap equal integers even if they are in distinct positions in the array. Also note that Petya must swap some two integers even if the original array meets all requirements. Array *a* (the array elements are indexed from 1) consisting of *n* elements is called sorted if it meets at least one of the following two conditions: 1. *a*1<=≤<=*a*2<=≤<=...<=≤<=*a**n*; 1. *a*1<=≥<=*a*2<=≥<=...<=≥<=*a**n*. Help Petya find the two required positions to swap or else say that they do not exist. The first line contains a single integer *n* (1<=≤<=*n*<=≤<=105). The second line contains *n* non-negative space-separated integers *a*1,<=*a*2,<=...,<=*a**n* — the elements of the array that Petya's mother presented him. All integers in the input do not exceed 109. If there is a pair of positions that make the array unsorted if swapped, then print the numbers of these positions separated by a space. If there are several pairs of positions, print any of them. If such pair does not exist, print -1. The positions in the array are numbered with integers from 1 to *n*. Sample Input 1 1 2 1 2 4 1 2 3 4 3 1 1 1 Sample Output -1 -1 1 2 -1
[ "n=int(input())\r\na=list(map(int,input().split()))\r\nb,c=sorted(a),sorted(a,reverse=True)\r\nfor i in range(n-1):\r\n if a[i]!=a[i+1]:\r\n a[i],a[i+1]=a[i+1],a[i]\r\n if a==b or a==c:\r\n a[i],a[i+1]=a[i+1],a[i]\r\n else:\r\n print(i+1,i+2)\r\n exit()\r\nprint(-1)\r\n", "n=int(input())\r\na=[int(i) for i in input().split()]\r\nb=len(set(a))\r\nc=sorted(a,reverse=True)\r\nif n==1 or n==2 or b==1:\r\n print(\"-1\")\r\nelif n==3:\r\n if b==2:\r\n if a[0]==a[2]:\r\n print(\"-1\")\r\n elif a[0]==a[1]:\r\n print(\"2 3\")\r\n else:\r\n print(\"1 2\")\r\n elif a[1]!=max(a[0],a[1],a[2]):\r\n print(a.index(c[0])+1,\"2\")\r\n else:\r\n print(a.index(c[2])+1,\"2\")\r\nelif n==4:\r\n if b==2:\r\n if a[0]==a[3]:\r\n if a[0]==a[1] or a[0]==a[2]:\r\n print(\"2 3\")\r\n else:\r\n print(\"1 2\")\r\n elif a[0]==a[1]:\r\n if a[0]==a[2]:\r\n print(\"4 3\")\r\n else:\r\n print(\"2 3\")\r\n elif a[0]==a[2]:\r\n print(\"1 2\")\r\n elif a[1]==a[2]:\r\n print(\"1 2\")\r\n elif a[1]==a[3]:\r\n print(\"1 2\")\r\n else:\r\n print(\"2 3\")\r\n elif b==3:\r\n if c[0]==c[1]:\r\n if a.index(c[3])!=2:\r\n print(a.index(c[3])+1,\"3\")\r\n elif a.index(c[3])!=1:\r\n print(a.index(c[3])+1,\"2\")\r\n else:\r\n if a.index(c[0])!=2:\r\n print(a.index(c[0])+1,\"3\")\r\n elif a.index(c[0])!=1:\r\n print(a.index(c[0])+1,\"2\")\r\n elif b==4:\r\n if a.index(c[0])!=2:\r\n print(a.index(c[0])+1,\"3\")\r\n elif a.index(c[0])!=1:\r\n print(a.index(c[0])+1,\"2\")\r\nelif n>4:\r\n i=0\r\n while(a[i]==a[0]):\r\n i+=1\r\n if i>3:\r\n print(i+1,\"2\")\r\n else:\r\n d=list(a)\r\n for i in range (n-4):\r\n a.pop()\r\n c=sorted(a,reverse=True)\r\n b=len(set(c))\r\n if b==2:\r\n if a[0]==a[3]:\r\n if a[0]==a[1] or a[0]==a[2]:\r\n print(\"2 3\")\r\n else:\r\n print(\"1 2\")\r\n elif a[0]==a[1]:\r\n if a[0]==a[2]:\r\n print(\"4 3\")\r\n else:\r\n print(\"2 3\")\r\n elif a[0]==a[2]:\r\n print(\"1 2\")\r\n elif a[1]==a[2]:\r\n print(\"1 2\")\r\n elif a[1]==a[3]:\r\n print(\"1 2\")\r\n else:\r\n print(\"2 3\")\r\n elif b==3:\r\n if c[0]==c[1]:\r\n if a.index(c[3])!=2:\r\n print(a.index(c[3])+1,\"3\")\r\n elif a.index(c[3])!=1:\r\n print(a.index(c[3])+1,\"2\")\r\n else:\r\n if a.index(c[0])!=2:\r\n print(a.index(c[0])+1,\"3\")\r\n elif a.index(c[0])!=1:\r\n print(a.index(c[0])+1,\"2\")\r\n elif b==4:\r\n if a.index(c[0])!=2:\r\n print(a.index(c[0])+1,\"3\")\r\n elif a.index(c[0])!=1:\r\n print(a.index(c[0])+1,\"2\")", "n = int(input())\narr = list(map(int, input().split()))\na, b = -1, -1\nfor i in range(1, n):\n\tif arr[i-1] == arr[i]:\n\t\tcontinue\n\tarr[i-1], arr[i] = arr[i], arr[i-1]\n\tup, down = True, True\n\tfor j in range(1, n):\n\t\tif arr[j-1] < arr[j]:\n\t\t\tdown = False\n\t\tif arr[j-1] > arr[j]:\n\t\t\tup = False\n\tif not up and not down:\n\t\ta, b = i-1, i\n\t\tbreak\n\tarr[i-1], arr[i] = arr[i], arr[i-1]\nif a == -1:\n\tprint(-1)\nelse:\n\tprint('%d %d' % (a+1, b+1))\n", "import sys\ninput = sys.stdin.readline\n############\nn = int(input())\n\nnn = input()\n\nnums = [int(x) for x in nn.split(' ')]\nsortedNums = sorted(nums)\ndef checkUnsorted(nums, correctSort): # at most this take O(n) time. Probably less\n if nums != correctSort and nums[::-1] != correctSort:\n return True\n return False\ndef swapVals(nums, i, x):\n num = nums[:]\n temp = num[i]\n num[i] = num[x]\n num[x] = temp\n return num\n\n\n\ndef question():\n length = len(nums)\n diff = 0\n mp = {}\n first = nums[0]\n for i in range(len(nums) - 1):\n if nums[i] not in mp:\n mp[nums[i]] = 1\n diff += 1\n if nums[i] != nums[i+1]:\n temp = swapVals(nums, i, i+1)\n if checkUnsorted(temp, sortedNums):\n return i, i+1\n \n return 0,0\n \n \n\ni, x = question()\n\nif i != x:\n print(f\"{i+1 } {x+1}\")\nelse:\n print(-1)\n \n\n\n\n", "n = int(input())\n\nt = list(map(int, input().split()))\n\nif n < 3 or (n == 3 and t[0] == t[2]) or all(i == t[0] for i in t): print(-1)\n\nelse:\n\n i = 1\n\n while t[i] == t[i - 1]: i += 1\n\n if i > 1: print('2 ' + str(i + 1))\n\n elif t[0] < t[1]:\n\n if t[1] <= t[2]: print('1 2')\n\n elif t[0] == t[2]:\n\n if t[0] == t[3]: print('2 3')\n\n else: print('3 4')\n\n else: print('1 3')\n\n else:\n\n if t[1] >= t[2]: print('1 2')\n\n elif t[0] == t[2]:\n\n if t[0] == t[3]: print('2 3')\n\n else: print('3 4')\n\n else: print('1 3')\n\n\n\n# Made By Mostafa_Khaled", "n = int(input())\r\narr = list(map(int, input().split()))\r\na, b = -1, -1\r\nfor i in range(1, n):\r\n\tif arr[i-1] == arr[i]:\r\n\t\tcontinue\r\n\tarr[i-1], arr[i] = arr[i], arr[i-1]\r\n\tup, down = True, True\r\n\tfor j in range(1, n):\r\n\t\tif arr[j-1] < arr[j]:\r\n\t\t\tdown = False\r\n\t\tif arr[j-1] > arr[j]:\r\n\t\t\tup = False\r\n\tif not up and not down:\r\n\t\ta, b = i-1, i\r\n\t\tbreak\r\n\tarr[i-1], arr[i] = arr[i], arr[i-1]\r\nprint(-1 if a == -1 else str(a+1)+' '+str(b+1))\r\n" ]
{"inputs": ["1\n1", "2\n1 2", "4\n1 2 3 4", "3\n1 1 1", "3\n1 2 2", "5\n1 1 1 1 2", "6\n1 2 3 3 2 1", "7\n6 5 4 3 2 1 0", "10\n1 2 1 2 1 2 1 2 1 2", "11\n1 1 1 1 1 2 2 2 2 2 1", "3\n1 2 1", "4\n562617869 961148050 596819899 951133776", "4\n562617869 596819899 951133776 961148050", "4\n961148050 951133776 596819899 562617869", "4\n596819899 562617869 951133776 961148050", "4\n562617869 596819899 951133776 0", "4\n951133776 961148050 596819899 562617869", "4\n961148050 951133776 596819899 0", "4\n562617869 562617869 562617869 562617869", "4\n961148050 961148050 562617869 961148050", "4\n562617869 961148050 961148050 961148050", "4\n961148050 961148050 961148050 562617869", "4\n961148050 562617869 961148050 961148050", "4\n562617869 961148050 961148050 961148050", "4\n562617869 961148050 562617869 562617869", "4\n562617869 562617869 562617869 961148050", "4\n961148050 562617869 562617869 562617869", "4\n961148050 562617869 961148050 961148050", "4\n961148050 961148050 562617869 961148050", "4\n562617869 562617869 961148050 562617869", "4\n562617869 961148050 562617869 562617869", "3\n2 1 3", "4\n2 1 3 4", "3\n2 1 2", "5\n1 1 2 1 1", "3\n1 3 1", "3\n1 3 2", "3\n3 2 3"], "outputs": ["-1", "-1", "1 2", "-1", "1 2", "2 5", "1 2", "1 2", "1 2", "1 6", "-1", "1 2", "1 2", "1 2", "1 3", "1 2", "1 3", "1 2", "-1", "2 3", "1 2", "2 4", "2 3", "1 2", "2 3", "2 4", "1 2", "2 3", "2 3", "2 3", "2 3", "1 3", "1 3", "-1", "2 3", "-1", "1 2", "-1"]}
UNKNOWN
PYTHON3
CODEFORCES
6
e39c2b784af5d5aba5d400fe46821f40
Voting for Photos
After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: the photo which gets most likes wins. If multiple photoes get most likes, the winner is the photo that gets this number first. Help guys determine the winner photo by the records of likes. The first line of the input contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the total likes to the published photoes. The second line contains *n* positive integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=1<=000<=000), where *a**i* is the identifier of the photo which got the *i*-th like. Print the identifier of the photo which won the elections. Sample Input 5 1 3 2 2 1 9 100 200 300 200 100 300 300 100 200 Sample Output 2 300
[ "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sun Mar 13 19:40:03 2016\r\n\r\n@author: Kostya S.\r\n\"\"\"\r\nfrom functools import cmp_to_key\r\nn = int(input())\r\nd = {}\r\na = [int(i) for i in input().split()]\r\nfor i,e in enumerate(a):\r\n d[e] = (i+1,1,e) if d.get(e) == None else (i+1,d[e][1] + 1,e)\r\nt1 = sorted(list(d.values()),key = lambda x: x[1])\r\nt2 = list(filter(lambda x: x[1] == t1[-1][1],t1))\r\nt2 = sorted(t2,key = lambda x: x[0])\r\nprint(t2[0][-1])", "n = int(input())\nphotos = {}\nbest_photo = 0\nmax_likes = 0\nq = list(map(int, input().split()))\nfor id in q:\n try:\n photos[id] += 1\n except KeyError:\n photos[id] = 1\n if photos[id] > max_likes:\n best_photo = id\n max_likes = photos[id]\nprint(best_photo)\n", "l=int(input())\narr=list(map(int,input().split()))\nhash={}\nmxm=0\nmax_sum=0\nfor i in arr:\n\tif i not in hash.keys():\n\t\thash[i]=1\n\telse:\n\t\thash[i]+=1\n\t\n\tif hash[i]>max_sum:\n\t\tmxm=i\n\t\tmax_sum=hash[i]\n\t\t\nprint(mxm)\n", "#!/usr/bin/python3\n\ndef solve(photo_ids):\n\tfreq = dict()\n\twinner_id = None\n\twinner_freq = None\n\n\tfor photo_id in photo_ids:\n\t\tif photo_id not in freq:\n\t\t\tfreq[photo_id] = 0\n\n\t\tfreq[photo_id] += 1\n\t\tif winner_freq is None or freq[photo_id] > winner_freq:\n\t\t\twinner_freq = freq[photo_id]\n\t\t\twinner_id = photo_id\n\n\treturn winner_id\n\n\ndef main():\n\tn = int(input())\n\tphoto_ids = [int(i) for i in input().split()]\n\n\tprint(solve(photo_ids))\n\n\n# def test():\n# \timport random\n# \tn = 1000\n# \tids = [random.randrange(1, 1000000) for i in range(n)]\n\n# \tprint(solve(ids))\n\nif __name__ == '__main__':\n\tmain()\n\t# test()\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nd={}\r\nans=a[0]\r\ncount=1\r\nfor i in range(n):\r\n\tif a[i] not in d:\r\n\t\td[a[i]]=1\r\n\telse:\r\n\t\td[a[i]]+=1\r\n\r\n\t\tif a[i]==ans:\r\n\t\t\tcount+=1\r\n\t\telif d[a[i]]>count:\r\n\t\t\tans=a[i]\r\n\t\t\tcount=d[a[i]]\r\nprint(ans)", "likes = input()\r\n\r\nphotos = input()\r\nphotos = photos.split()\r\n\r\n\r\ndef main(photos, likes):\r\n count = {}\r\n new_count = {}\r\n for i in photos:\r\n if i in count:\r\n count[i] += 1\r\n else:\r\n count[i] = 1\r\n value = max(count.values())\r\n for i in photos:\r\n if i in new_count:\r\n new_count[i] += 1\r\n else:\r\n new_count[i] = 1\r\n if new_count[i] == value:\r\n return i\r\n\r\n\r\nprint(main(photos, likes))", "from collections import deque, defaultdict, Counter\r\nfrom itertools import product, groupby, permutations, combinations\r\nfrom math import gcd, floor, inf, log2, sqrt, log10\r\nfrom bisect import bisect_right, bisect_left\r\nfrom statistics import mode\r\nnum = int(input())\r\narr = list(map(int, input().split()))\r\n\r\ncom_num = Counter(arr).most_common(1)[0][1]\r\n\r\nfreq = defaultdict(int)\r\n\r\nfor num in arr:\r\n freq[num] += 1\r\n if freq[num] == com_num:\r\n print(num)\r\n break\r\n\r\n\r\n\r\n\r\n", "# A. Voting for Photos\r\n\r\narr = []\r\nn=int(input())\r\nlike=list(map(int,input().split()))\r\niden=dict.fromkeys(like,0)\r\nmax=0\r\nmaxind=0\r\nfor item in like:\r\n iden[item]+=1;\r\n if iden[item]>max:\r\n max=iden[item]\r\n maxind=item\r\nprint(maxind)\r\n", "n = input()\r\na = list(map(int, input().split()))\r\nd = {}\r\nmx = 0\r\nans = -1\r\nfor x in a:\r\n d[x] = d.get(x, 0) + 1\r\n if(d[x] > mx):\r\n mx = d[x]\r\n ans = x\r\nprint(ans)", "n = int(input())\r\n\r\na = list(map(int, input().split()))\r\n\r\na1 = [0]* (1000001)\r\np = 0\r\nm = 0\r\n\r\nfor i in range(n):\r\n \r\n a1[a[i]] += 1\r\n # print(a[i], a1[a[i]])\r\n if a1[a[i]] > m:\r\n m = a1[a[i]]\r\n p = a[i]\r\nprint(p)", "\r\nnum_inp=lambda: int(input())\r\narr_inp=lambda: list(map(int,input().split()))\r\nsp_inp=lambda: map(int,input().split())\r\nstr_inp=lambda:input()\r\nn = int(input())\r\nA = [0] * 1000001\r\nidx = 1\r\nfor i in list(map(int, input().split())):\r\n A[i] += 1\r\n if A[i] > A[idx]:\r\n idx = i\r\nprint(idx)", "n=int(input())\r\na=list(map(int,input().split()))\r\nlikes=dict()\r\ntimes=dict()\r\nfor i in range(len(a)):\r\n if a[i] not in likes:\r\n likes[a[i]] = 1\r\n times[a[i]] = i\r\n else:\r\n likes[a[i]] = likes[a[i]]+1\r\n times[a[i]] = i\r\n \r\nmx=0\r\nlike=[]\r\nfor i in likes:\r\n if likes[i] > mx:\r\n mx = likes[i] \r\nfor i in likes:\r\n if likes[i] == mx:\r\n like=like+[i]\r\nif len(like) == 1:\r\n print(like[0])\r\nelse:\r\n slovar={}\r\n mn=10000\r\n max_like=0\r\n for i in range(len(like)):\r\n slovar[like[i]] = times[like[i]]\r\n for i in slovar:\r\n if slovar[i] < mn:\r\n mn = slovar[i]\r\n max_like=i\r\n\r\n print(max_like)\r\n \r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nma=0\r\nd={}\r\nindx=-1\r\nfor i in range(n) :\r\n v=d.get(l[i],0)+1\r\n if ma<v :\r\n ma=v\r\n indx=l[i]\r\n d[l[i]]=v\r\nprint(indx)\r\n\r\n \r\n \r\n \r\n", "n = int(input())\r\na = input().split()\r\n\r\nif len(a) == n:\r\n ids = {}\r\n max = 0\r\n for el in a:\r\n if ids.get(el) == None:\r\n ids[el] = 1\r\n else:\r\n ids[el] = 1 + ids.get(el)\r\n if ids.get(el) > max:\r\n max = ids.get(el)\r\n answer=el\r\n print(answer)\r\n", "n = int(input())\ndata = [int(i) for i in input().split()]\ndct = {}\nkeys = []\nmx = 0\nret = 0\nfor box in data:\n if box in keys:\n dct[box] += 1 \n else:\n dct[box] = 1\n keys.append(box)\n if dct[box] > mx:\n mx = dct[box]\n ret = box\nprint(ret)\n\n", "from collections import Counter\r\ni=int(input())\r\nl=list(map(int,input().split()))\r\nc=Counter(l)\r\nt=max(c.values())\r\nm={}\r\nfor x in l:\r\n if x not in m: m[x]=0\r\n m[x]+=1\r\n if m[x]==t:print(x);exit()\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\ncnt = [0]*(10**6+100)\r\n\r\nfor ai in a:\r\n cnt[ai] += 1\r\n\r\nM = max(cnt)\r\ncnt = [0]*(10**6+100)\r\n\r\nfor ai in a:\r\n cnt[ai] += 1\r\n \r\n if cnt[ai]==M:\r\n print(ai)\r\n exit()", "def main():\n n = int(input())\n our = [[0, 0] for i in range(1000001)]\n ask = list(map(int, input().split()))\n for i in range(len(ask)):\n e = ask[i]\n our[e][0] -= 1\n our[e][1] = i\n print(our.index(min(our)))\n \nmain()", "n = int(input())\r\nids = list(map(int,input().split()))\r\nd = {}\r\nfor i in range (0,n):\r\n if (d.get(ids[i])==None):\r\n d[ids[i]] = (0,i)\r\n else:\r\n d[ids[i]] = (d[ids[i]][0]+1,i)\r\n \r\nmax = ids[0]\r\nfor i in range (0,n):\r\n if (d[ids[i]][0]>d[max][0]):\r\n max = ids[i]\r\n else:\r\n if (d[ids[i]][0]==d[max][0]):\r\n if (d[ids[i]][1]<d[max][1]):\r\n max = ids[i]\r\n\r\nprint (max)\r\n", "n=int(input())\r\ns=[int(z) for z in input().split()]\r\nD={}\r\nM=s[0]\r\nMc=1\r\nfor i in s:\r\n\tif i in D:\r\n\t\tD[i]+=1\r\n\t\tif i==M:\r\n\t\t\tMc+=1\r\n\t\telif D[i]>Mc:\r\n\t\t\tM=i\r\n\t\t\tMc=D[i]\r\n\telse:\r\n\t\tD[i]=1\r\nprint(M)", "#!/usr/bin/env python3\r\n\r\nfrom collections import Counter\r\n\r\nn = int(input())\r\na = Counter()\r\nresult = None\r\n\r\nfor v in map(int, input().split()):\r\n\ta[v] += 1\r\n\tif result is None or a[v] > a[result]:\r\n\t\tresult = v\r\n\r\nprint(result)\r\n", "from collections import *\r\nn=int(input())\r\nc=Counter()\r\na,b=0,0\r\nfor x in map(int,input().split()): c[x]+=1; a,b=(c[x],x) if a<c[x] else (a,b)\r\nprint(b)\r\n", "n = int(input())\r\na = list(map(int, input().split(\" \")))\r\n\r\nd = dict()\r\n\r\nfor i, x in enumerate(a):\r\n if not x in d:\r\n d.setdefault(x, (1, i))\r\n else:\r\n d[x] = (d[x][0]+1, i)\r\n\r\nkeyRes = -1\r\nres = (-1, -1)\r\n\r\nfor key, val in d.items():\r\n if val[0] > res[0] or val[0] == res[0] and val[1] < res[1]:\r\n res = val\r\n keyRes = key\r\n\r\nprint(keyRes)\r\n", "#!/usr/bin/python3\n\nfrom collections import Counter\n\nn = int(input())\n\nmax = -1\nmax_photo_id = -1\n\nphoto_likes = Counter()\n\nids_str = input().split()\n\nfor i in range(n):\n\n photo_id = int(ids_str[i])\n photo_likes[photo_id] += 1\n\n if photo_likes[photo_id] > max:\n max = photo_likes[photo_id]\n max_photo_id = photo_id\n\nprint(max_photo_id) \n", "#d\nn = int(input())\nu = list(map(int, input(). split()))\nb = [0]*1000001\npemenang = -1\nfoto = 0\n\nfor i in range (len(u)):\n b[u[i]] += 1\n if b[u[i]] > pemenang:\n pemenang = b[u[i]]\n foto = u[i]\n\nprint (foto)\n \t\t\t \t \t\t \t \t\t\t \t\t \t\t\t\t \t\t\t", "n = int(input())\r\nvotes = list(map(int, input().split(\" \")))\r\n\r\nchecked = []\r\npopular = []\r\nvote_count = {}\r\n\r\nfor v in votes:\r\n if v not in checked:\r\n checked.append(v)\r\n vote_count[v] = votes.count(v)\r\n# print(vote_count)\r\n\r\nmxval = -1\r\nmx = -1\r\nfor key in vote_count.keys():\r\n # print(\"key\",key,\" \",\"vote\",vote_count[key])\r\n # print(\"max\",mx)\r\n if vote_count[key] > mxval:\r\n mxval = vote_count[key]\r\n mx = key\r\n# print(\"maxval: \", mxval)\r\n# print(\"maxkey: \", mx)\r\n\r\npopular.append(mx)\r\n\r\n# Check for other equal votes.\r\nfor key in vote_count.keys():\r\n if key != mx and vote_count[key] == vote_count[mx]:\r\n popular.append(key)\r\n# print(popular)\r\n\r\n# Find who's last.\r\nlast = -1\r\noccured = []\r\nif len(popular) == 1: print(popular[0])\r\nelse:\r\n j = n-1\r\n while j >=0:\r\n if votes[j] in popular and votes[j] not in occured:\r\n occured.append(votes[j])\r\n j -= 1\r\n print(occured[-1])", "n = int(input())\r\nd1,a,d2 = {},[],{}\r\nl = list(map(int,input().split()))\r\nfor i in l:\r\n\tif i in d1:\r\n\t\td1[i]+=1\r\n\telse:\r\n\t\td1[i]=1\r\nfor i in d1:\r\n\ta.append(d1[i])\r\nm = max(a)\r\nfor i in l:\r\n\tif i in d2:\r\n\t\td2[i]+=1\r\n\telse:\r\n\t\td2[i]=1\r\n\tif d2[i]==m:\r\n\t\tprint(i)\r\n\t\tbreak", "n = int(input())\na = map(int, input().split())\nlikes = {}\nfor i, like in enumerate(a):\n if not like in likes:\n likes[like] = [1, i]\n else:\n likes[like][0] += 1\n likes[like][1] = i\nlikes = list(likes.items())\nprint(max(likes, \n key = lambda x: (x[1][0], -x[1][1]))[0])\n", "n = int(input())\r\nper = 0\r\nind = 0\r\nA = dict()\r\ns = input().split()\r\nfor i in s:\r\n if i not in A:\r\n A[i] = 1\r\n if per == 0:\r\n per = 1\r\n ind = i\r\n else:\r\n \r\n A[i] += 1\r\n if A[i] > per:\r\n \r\n ind = i\r\n per = A[i]\r\nprint(ind)", "__author__ = 'nadik'\nimport sys\n\n\n#with open(\"test.in\", 'r') as input:\n# n = int(input.readline())\n# a = [int(x) for x in input.readline().split()]\nn = int(input())\na = [int(i) for i in input().split()]\n\nd = {}\nfor i in range(0, n):\n if a[i] not in d:\n d[a[i]] = (0, -1)\n likes, time_of_last_like = d[a[i]]\n d[a[i]] = (likes + 1, i)\n\nwinner, winner_score, winner_time = 0, -1, n\nfor k, v in d.items():\n likes, time_of_last_like = v\n if likes > winner_score:\n winner = k\n winner_score = likes\n winner_time = time_of_last_like\n elif likes == winner_score:\n if time_of_last_like < winner_time:\n winner = k\n winner_time = time_of_last_like\n\nprint(winner)\n", "n=int(input())\r\na=list(map(int,input().split()))\r\n\r\nmax_count=0\r\nans=0\r\nfor i in range(n):\r\n if a[:i+1].count(a[i]) > max_count:\r\n\r\n max_count=a[:i+1].count(a[i])\r\n ans=a[i]\r\n\r\nprint(ans)", "from collections import defaultdict\n\ndef solve():\n n = int(input())\n A = [int(x) for x in input().split()]\n D = defaultdict(int)\n M, argmax = 0, None\n for a in A:\n D[a] += 1\n if M < D[a]:\n M = D[a]\n argmax = a\n return argmax\n\nprint(solve())\n", "n = [int (i) for i in input().split()][0]\r\na = [int (i) for i in input().split()]\r\nmydic = {}\r\nmax = 0\r\nmaxind = 0\r\nfor i in range(n):\r\n mydic[a[i]] = mydic.get(a[i], 0) + 1\r\n if mydic[a[i]] > max:\r\n max = mydic[a[i]]\r\n maxind = a[i]\r\nprint (maxind)", "n = int(input())\r\nA = [0] * 1000001\r\nidx = 1\r\na = list(map(int, input().split()))\r\nfor i in a:\r\n A[i] += 1\r\n if A[i] > A[idx]:\r\n idx = i\r\nprint(idx)\r\n", "input()\r\ns, p, k = {}, '', 0\r\nfor q in input().split():\r\n s[q] = s.get(q, 0) + 1\r\n if s[q] > k: p, k = q, k + 1\r\nprint(p)", "n=int(input())\r\na=[int(x) for x in input().split()]\r\nhp={}\r\nfor i in a:\r\n if i in hp:\r\n hp[i]+=1\r\n else:\r\n hp[i]=1\r\nans=0\r\nb=[]\r\na.reverse()\r\nfor i in hp:\r\n if hp[i]>ans:\r\n ans=hp[i]\r\nfor i in hp:\r\n if hp[i]==ans:\r\n b.append(i)\r\nind=-1\r\nfor i in b:\r\n t=a.index(i)\r\n if t>ind:\r\n ind=t\r\n ss=i\r\nprint(ss)\r\n ", "import collections\r\nn=int(input())\r\ns=[int(i) for i in input().split()]\r\nd=collections.Counter()\r\ng=0\r\nh=0\r\nfor i in s:\r\n d[i]+=1\r\n p=d.most_common(1)[0][1]\r\n y=d.most_common(1)[0][0]\r\n if p>g:\r\n h=y\r\n g=p\r\nprint(h)", "n = int(input())\na = list(map(int, input().split()))\np = {}\nfor i in range(n):\n\tif a[i] in p:\n\t\tp[a[i]] += 1\n\telse:\n\t\tp[a[i]] = 1\nb = max(p[i] for i in p)\nfor i in p:\n\tp[i] = 0\nfor i in a:\n\tp[i] += 1\n\tif p[i] == b:\n\t\tprint(i)\n\t\texit(0)", "def Voting(n,lis):\r\n if n==1:\r\n return lis[0]\r\n dic = {}\r\n val = -999999999999999999999\r\n ans = 0\r\n for i in lis:\r\n if i in dic:\r\n dic[i]+=1\r\n if dic[i]>val:\r\n ans=i\r\n val = dic[i]\r\n else:\r\n dic[i]=1\r\n if dic[i]>val:\r\n ans=i\r\n val = dic[i]\r\n\r\n return ans\r\n\r\nn = int(input())\r\nlis = list(map(int, input().split()))\r\nprint(Voting(n,lis))", "n = int(input())\r\na = [0] * (10 ** 6 + 1)\r\nbest = 0\r\nfor i in map(int, input().split(' ')):\r\n a[i] += 1\r\n if a[i] > a[best]:\r\n best = i\r\nprint(best)\r\n", "n = eval(input())\r\narr = {}\r\nmax = 0\r\nmass = input().split()\r\nfor k in mass:\r\n if k in arr:\r\n arr[k] += 1\r\n else:\r\n arr[k] = 1\r\n if max < arr[k] :\r\n max = arr[k]\r\n liker = k\r\n\r\nprint(liker)", "from collections import defaultdict\r\n\r\n_ = input()\r\nlst = list(map(int, input().split()))\r\ndc = defaultdict(int)\r\nmaxVotes = 0\r\nfor x in lst:\r\n dc[x] += 1\r\n if dc[x] > maxVotes:\r\n wins = x\r\n maxVotes = dc[x]\r\nprint(wins)\r\n", "n = int(input(''))\r\nlst = list(map(int, input().split()))\r\ndic = {}\r\nmostlikes = 0\r\nnewlist = []\r\n\r\nfor item in lst:\r\n if item not in dic:\r\n dic[item] = 1\r\n else:\r\n dic[item] = dic[item] + 1\r\n\r\nfor item in dic:\r\n if dic[item] > mostlikes:\r\n mostlikes = dic[item]\r\n\r\nfor item in dic:\r\n if dic[item] == mostlikes:\r\n newlist.append(item)\r\n\r\nfor y in range(len(newlist)):\r\n for i in range(mostlikes-1):\r\n lst.remove(newlist[y])\r\n\r\nfor item in lst:\r\n if item in newlist:\r\n print(item)\r\n break\r\n \r\n\r\n", "from collections import Counter\r\n\r\nn = int(input())\r\n\r\narr = list(map(int,input().split()))\r\n\r\nx = Counter(arr)\r\n\r\ny = max(x.values())\r\n\r\nd = {}\r\nfor i in arr:\r\n if i in d:\r\n d[i] += 1 \r\n else:\r\n d[i] = 1\r\n\r\n if d.get(i,0)==y:\r\n print(i)\r\n break\r\n \r\n\r\n \r\n\r\n \r\n\r\n\r\n\r\n", "n = int(input())\ndic = {}\nar = input().split(' ')\nar = [int(i) for i in ar]\nfor i in range(n):\n\ttry:\n\t\tdic[ar[i]][0]+=1\n\t\tdic[ar[i]][1]=i\n\texcept:\n\t\tdic[ar[i]] = [1,i]\nkeys = []\nmaxi = 0\nfor i in dic:\n\tif dic[i][0]>maxi:\n\t\tmaxi = dic[i][0]\n\t\tkeys = [i]\n\telif dic[i][0] == maxi:\n\t\tkeys.append(i)\n\nmini = 9999999\nid_num = 0\nfor i in keys:\n\tif dic[i][1]<mini:\n\t\tid_num = i\n\t\tmini = dic[i][1]\nprint(id_num)", "n = int(input())\r\nA = input().split()\r\nmax = 0\r\nmax_i = A[0]\r\nLikes = dict()\r\nfor a in A:\r\n if a not in Likes:\r\n Likes[a] = 1\r\n else:\r\n Likes[a] += 1\r\n if Likes.get(a) > max:\r\n max = Likes.get(a)\r\n max_i = int(a)\r\nprint(max_i)", "n = int(input())\r\narr = list(map(int,input().split()))\r\ncnt = 0\r\nval = -1\r\nd = {}\r\nfor i in arr:\r\n if i in d:\r\n d[i]+=1\r\n else:\r\n d[i] = 1\r\n if d[i]>cnt:\r\n cnt = d[i]\r\n val = i\r\nprint(val)", "n = int(input())\r\na = {}\r\narr = input().split(\" \")\r\n\r\nlikes = [int(x) for x in arr]\r\n\r\nmaximum = 0\r\nmaximum_el = 0\r\n\r\nfor i in likes:\r\n if a.get(i):\r\n a[i] += 1\r\n if a[i] > maximum:\r\n maximum = a[i]\r\n maximum_el = i\r\n else:\r\n a[i] = 1\r\n if a[i] > maximum:\r\n maximum = a[i]\r\n maximum_el = i\r\n\r\n\r\nprint(maximum_el)", "n = int(input(\"\"))\r\na = input().split()\r\nd = {0: 0}\r\nrez = 0\r\n#print(a)\r\nfor i in range(n):\r\n a[i] = int(a[i]);\r\n try:\r\n d[a[i]] += 1\r\n except KeyError:\r\n d[a[i]] = 1;\r\n if (d[a[i]] > d[rez]):\r\n rez = a[i];\r\nprint(rez);\r\n", "def main():\r\n n = int(input())\r\n arr = [int(x) for x in input().split()]\r\n d = [0] * (10 ** 6 + 1)\r\n for x in arr:\r\n d[x] += 1\r\n \r\n m = max(d)\r\n \r\n d = [0] * (10 ** 6 + 1) \r\n for x in arr:\r\n d[x] += 1\r\n if d[x] == m:\r\n print(x)\r\n return \r\n \r\n \r\n\r\n\r\nmain()", "from collections import Counter\r\n\r\nn = int(input())\r\na = [int(i) for i in input().split()]\r\nc = Counter(a)\r\nk = c.most_common(1)[0][1]\r\nli = []\r\nfor i, j in c.most_common():\r\n if j == k:\r\n li.append(i)\r\n else:\r\n break\r\na.reverse()\r\nprint(max(li, key=lambda i: a.index(i)))\r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\ns=[0]*(1000002)\r\nans=(0,0)\r\nfor i in range(n):\r\n s[l[i]]+=1\r\n if ans[1]<s[l[i]]:\r\n ans=(l[i],s[l[i]])\r\nprint(ans[0])", "n = int(input())\r\nl = list(map(int, input().split()))\r\n\r\nh = {}\r\nmaxlike=-1\r\nfirst=0\r\n\r\nfor x in l:\r\n h[x] = h.get(x, 0) + 1\r\n if h[x] > maxlike:\r\n maxlike = h[x]\r\n first = x\r\n\r\nprint(first)\r\n", "def main():\n n = int(input())\n l, m = [0] * 1000001, 0\n for a in map(int, input().split()):\n x = l[a] + 1\n l[a] = x\n if m < x:\n m, res = x, a\n print(res)\n\n\nif __name__ == '__main__':\n main()\n", "n = int(input())\na = list(map(int, input().split()))\ncount = {}\nfor x in a:\n count[x] = count.get(x, 0) + 1\ncandidates = [key for key in count if count[key] == max(count.values())]\nfor x in a[::-1]:\n if x in candidates:\n if len(candidates) == 1:\n print(x)\n break\n else:\n candidates.remove(x)", "n = int(input())\r\nlike = list(map(int , input().split()))\r\nid = 0\r\nA = [0] * 1000005\r\nfor i in range(n) :\r\n A[like[i]] += 1\r\n if A[like[i]] > A[id] :\r\n id = like[i]\r\nprint(id)", "n=int(input())\r\nx=list(map(int,input().split()))\r\ndi={}\r\nfor z in x:\r\n if z in di.keys():\r\n di[z]=di[z]+1\r\n else:\r\n di[z]=1\r\nkm = di[max(di, key=di.get)]\r\nwinners=[]\r\nfor z in di.keys():\r\n if di[z]==km:\r\n winners.append(z)\r\ni=n-1\r\nwhile(len(winners)>1):\r\n if x[i] in winners:\r\n winners.remove(x[i])\r\n i-=1\r\nprint(winners[0])", "r=m=-1\r\nd={}\r\nfor x in map(int,[*open(0)][1].split()):\r\n d[x]=d.get(x,0)+1\r\n if d[x]>m:m=d[x];r=x\r\nprint(r)", "a,b=int(input()),list(map(int,input().split()));maxValue,mex=0,0;dt=dict.fromkeys(set(b),0)\r\nfor i in range(a):\r\n dt[b[i]]+=1\r\n if dt[b[i]]>maxValue:maxValue,mex=dt[b[i]],b[i]\r\nprint(mex)", "n = int(input())\r\na = list(map(int, input().split()))\r\nd = {}\r\nkeymax = 0\r\nvaluemax = 0\r\nfor i in a:\r\n v = d.get(i, None)\r\n if v != None:\r\n d[i] = d[i] + 1\r\n else:\r\n d[i] = 1\r\n if d[i] > valuemax:\r\n valuemax = d[i]\r\n keymax = i\r\nprint(keymax)\r\n", "from collections import defaultdict\r\nfrom operator import itemgetter\r\n\r\npics = defaultdict(lambda: (0, float('inf')))\r\ninput()\r\nfor i, v in enumerate(map(int, input().split())):\r\n pics[v] = (pics[v][0] + 1, -i)\r\n\r\nprint(max(pics.items(), key=itemgetter(1))[0])\r\n", "n = int(input())\r\na = list(map(int,input().split()))\r\nl = [0] * (max(a) + 1)\r\nt = [0] * (max(a) + 1)\r\nfor i in range(n):\r\n l[a[i]] += 1\r\n t[a[i]] = i\r\nm = max(l)\r\nm1 = 100000000000000000000000\r\nj = 0\r\nfor i in range(len(l)):\r\n if l[i] == m:\r\n if t[i] < m1:\r\n m1 = t[i]\r\n j = i\r\nprint(j)\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\nlikes = dict()\r\nm = [-1, 0]\r\n\r\nfor num in a:\r\n if num in likes:\r\n likes[num]+=1\r\n else:\r\n likes[num]=1\r\n mnlocal = max(likes, key = lambda q: likes[q])\r\n mlocal = likes[mnlocal]\r\n if (mlocal > m[1]):\r\n m = [mnlocal, mlocal]\r\n\r\nprint(m[0])\r\n", "n=input()\r\na,b=[0]*11**6,0\r\nfor x in map(int,input().split()): a[x]+=1; b=x if a[b]<a[x] else b\r\nprint(b)", "n = int(input())\r\na = input()\r\nlst = a.split(' ')\r\ndic = {}\r\nfor i in lst:\r\n if i not in dic:\r\n dic[i] = 1\r\n else:\r\n dic[i] += 1\r\n_max = 0\r\nfor p in dic:\r\n _max = max(_max,dic[p])\r\n\r\nnewdic = {}\r\nfor p in dic:\r\n if dic[p] == _max:\r\n newdic.setdefault(p,dic[p])\r\n\r\ni = n-1\r\nwhile len(newdic)>1:\r\n if(lst[i] in newdic):\r\n del newdic[lst[i]]\r\n i -= 1\r\n\r\nfor i in newdic:\r\n print(i)\r\n ", "n = int(input())\r\nl = list(map(int ,input().split())) \r\nmx = 0 \r\nfor i in set(l) : \r\n mx = max(mx , l.count(i))\r\nd = {}\r\nwinner = None\r\nfor i in l : \r\n d.setdefault(i , 0 )\r\n d[i] += 1\r\n if d[i] == mx : \r\n winner = i \r\n break \r\nprint(winner)", "n = int(input())\r\nnums = [int(j) for j in input().split()]\r\nref = 1000000 * [0]\r\nwinner, max = 0, 0\r\nfor j in range(n):\r\n ref[nums[j] - 1] += 1\r\n if ref[nums[j] - 1] > max:\r\n winner, max = nums[j], ref[nums[j] - 1]\r\nprint(winner)\r\n", "likes_num = int(input())\r\nlikes = dict() #{photo_id: [total_likes, last_like_time]}\r\ntime = 0\r\nfor i in input().split():\r\n if i in likes:\r\n likes[i][0] += 1\r\n likes[i][1] = time\r\n else:\r\n likes[i] = [1, time]\r\n time += 1\r\nmax_likes = 0\r\nfor key, value in likes.items():\r\n if value[0]>max_likes:\r\n max_likes = value[0]\r\n res = key\r\n elif value[0]==max_likes and likes[res][1]>value[1]:\r\n res = key\r\nprint(res)\r\n", "n = int(input())\r\ndaf = list(map(int, input().split()))\r\ndaf = daf[::-1]\r\nhas = dict()\r\n\r\nfor x in daf:\r\n if x in has.keys():\r\n has[x] += 1\r\n else:\r\n has[x] = 1\r\n\r\ny = max(has.values())\r\n\r\nans = 0\r\nfor x in has.keys():\r\n if has[x] == y:\r\n ans = x\r\n\r\nprint(ans)\r\n\r\n", "n = input()\r\narr, arr1, ptr = list(map(int,input().split())), [0] * 1000001, 0\r\nfor i in arr:\r\n arr1[i] += 1\r\n if arr1[ptr] < arr1[i]:\r\n ptr = i\r\nprint(ptr)", "n = int(input())\nm = list(map(int, input().split()))\nb = {}\nfor i in range(n):\n s = m[i]\n if s in b:\n b[s][1] = i\n b[s][0] += 1\n else:\n b[s] = [1, i]\ntop = max(b[k][0] for k in b)\nf = sorted([n for n in b if b[n][0] == top], key = lambda k: b[k][1])\nprint(f[0])\n", "n=int(input())\r\ns=input().split()\r\n\r\nd=dict()\r\n\r\nfor i in range(len(s)):\r\n\t\tkey=s[i]\r\n\t\td[key]=s.count(key)\r\n\r\nmax_count=max(d.values())\r\n\r\n\r\nl=[]\r\n\r\nfor i in (range(len(s)-1,-1,-1)):\r\n\tkey=s[i]\r\n\tif s.count(key)==max_count and key not in l:\r\n\t\tl.append(s[i])\r\n\t\t\r\n\t\t\t\t\r\nprint(l[len(l)-1])\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nK=max(map(a.count,a))\r\ni=0\r\nwhile True:\r\n if a.count(a[i])<K:\r\n C=a.count(a[i])\r\n n-=C\r\n Val=a[i]\r\n for k in range(C):\r\n a.remove(Val)\r\n \r\n else:\r\n i+=1\r\n if i==n:\r\n break\r\nMinI=1000001\r\nID=-1\r\nA=list(set(a))\r\nfor i in range(len(A)):\r\n j=n-1\r\n while j>=0 and a[j]!=A[i]:\r\n j-=1\r\n if j<MinI:\r\n MinI=j\r\n ID=A[i]\r\nprint(ID)", "#Here u can check fast your code!\r\nx = int(input())\r\nlines_string = input()\r\nlines_string = lines_string.split()\r\nlst_tags = []\r\nlst_counts = []\r\nk = 1\r\nfor i in range(x):\r\n\tif lines_string[i] not in lst_tags:\r\n\t\tlst_tags.append(lines_string[i])\r\n\t\tlines_string[i]=(lines_string[i], 1)\r\n\t\tlst_counts.append(1)\r\n\telse:\r\n\t\tfor j in range(len(lst_counts)):\r\n\t\t\tif lst_tags[j]==lines_string[i]:\r\n\t\t\t\tlines_string[i]=(lines_string[i], lst_counts[j]+1)\r\n\t\t\t\tlst_counts[j]+=1\r\n\t\t\t\tbreak\r\np = lines_string[0][0]\r\nfor i in range(x):\r\n\tif lines_string[i][1]>k:\r\n\t\tk=lines_string[i][1]\r\n\t\tp = lines_string[i][0]\r\nprint(p)", "n = int(input())\na = map(int, input().split())\nlikes = {}\nfor i, like in enumerate(a):\n if not like in likes:\n likes[like] = [1, i]\n else:\n likes[like][0] += 1\n likes[like][1] = i\nlikes = list(likes.items())\nlikes.sort(key=lambda x: x[1][0]*10000-x[1][1])\nprint(likes[-1][0])\n", "n = int(input())\r\nlikes = [ x for x in (input().split(' ')) ]\r\n\r\nnum_likes = {}\r\nmax_likes = -1\r\nmax_photo = likes[0]\r\n\r\nfor p_num in likes:\r\n if (p_num in num_likes):\r\n num_likes[p_num] = num_likes[p_num]+1\r\n if (max_likes < num_likes[p_num]):\r\n max_likes = num_likes[p_num]\r\n max_photo = p_num\r\n else:\r\n num_likes[p_num] = 0\r\n \r\nprint(max_photo)", "n = int(input())\r\na = list(map(int,input().split()))\r\nk = 0\r\npas = 0\r\na = a[::-1]\r\nfor i in set(a):\r\n s = a.count(i)\r\n if s > k:\r\n pas = i\r\n k = s\r\n elif s==k:\r\n if a.index(i) > a.index(pas):\r\n pas = i\r\n k = a.count(i)\r\nprint(pas) \r\n ", "n = int(input())\r\na = input().split(' ')\r\nb = [[], []]\r\ntmp = 0\r\nmx = 0\r\n# for i in range(1000):\r\n# print(i+1, end=' '),\r\nfor i in range(n):\r\n cnt = 0\r\n for j in range(len(b[0])):\r\n # if b[1][mx] < b[1][j]:\r\n # mx = j\r\n if b[0][j] == int(a[i]):\r\n cnt = 1\r\n tmp = j\r\n\r\n if cnt == 0:\r\n b[0].append(int(a[i]))\r\n b[1].append(int(1))\r\n else:\r\n b[1][tmp] += 1\r\n if b[1][mx] < b[1][tmp]:\r\n mx = tmp\r\n\r\nprint(b[0][mx])\r\n\r\n\r\n", "n=int(input())\nlargest=0\nvotes=list(map(int,input().split()))\nnumberofvotes=[0]*1000000\nfor x in range(n):\n numberofvotes[votes[x]-1]+=1\n if numberofvotes[votes[x]-1]>largest:\n largest=numberofvotes[votes[x]-1]\n winner=votes[x]\nprint(winner)", "import string\r\n\r\ndef is_palindrome(s):\r\n for i in range(len(s) // 2):\r\n k = len(s) - 1 - i\r\n if s[i] != s[k]:\r\n return False\r\n return True\r\n\r\n\r\n\r\n\r\n\r\n\r\n#\r\n\r\ndef main_function():\r\n n = int(input())\r\n max_photos = 0\r\n who_reached_first = 0\r\n likes = [int(i) for i in input().split(\" \")]\r\n maxi = max(likes) + 1\r\n photos = [0 for i in range(maxi)]\r\n for i in likes:\r\n photos[i] += 1\r\n if photos[i] > max_photos:\r\n max_photos = photos[i]\r\n who_reached_first = i\r\n print(who_reached_first)\r\n\r\n\r\nmain_function()", "n = int(input())\r\na = list(map(int, input().split()))\r\nb = [[], []]\r\nmaxl = -1\r\nfor i in range(len(a)):\r\n photo = a[i]\r\n if b[0].count(photo) == 0:\r\n b[0].append(photo)\r\n b[1].append(0)\r\n nom = b[0].index(photo)\r\n nom = b[0].index(photo)\r\n b[1][nom] += 1\r\n maxmom = max(b[1])\r\n if maxl < maxmom:\r\n maxl = maxmom\r\n mesto = b[1].index(maxmom)\r\n ans = b[0][mesto]\r\nprint(ans)", "n = int(input())\r\ndata = list(map(int, input().split()))\r\nmemo = {}\r\n\r\nfor i in range(n):\r\n if data[i] in memo:\r\n memo[data[i]] = (memo[data[i]][0] + 1, i)\r\n else:\r\n memo[data[i]] = (1, i)\r\n\r\nprint(sorted(memo, key=lambda x: (-memo[x][0], memo[x][1]))[0])", "n = int(input())\r\nmx = -1\r\nans = -1\r\ncnt = [0] * (10**6 + 1)\r\nfor id in map(int, input().split()):\r\n cnt[id] += 1\r\n if cnt[id] > mx:\r\n mx = cnt[id]\r\n ans = id\r\nprint(ans)", "N = int(input())\nlikes, D, mx, ans = list(map(int, input().split())), {}, 0, -1\nfor num in likes:\n D[num] = D.get(num, 0) + 1\n if D[num] > mx:\n mx = D[num]\n ans = num\nprint(ans)", "n=int(input())\r\nk=list(map(int,input().split()))\r\nd=dict.fromkeys(k,0)\r\nmx=0\r\nmj=0\r\nfor i in k:\r\n d[i]+=1\r\n if d[i]>mx:\r\n mx=d[i]\r\n mj=i\r\nprint(mj)", "n = int(input())\r\na = [*map(int, input().split())]\r\na.reverse()\r\nd = {}\r\nfor i in range(n):\r\n\td[a[i]] = d.get(a[i], 0) + 1\r\nm = max(d.values())\r\nb = []\r\nfor i in d.keys():\r\n\tif d[i] == m:\r\n\t\tb.append(a.index(i))\r\nb.sort()\r\nprint(a[b[-1]])\r\n\r\n", "'''input\n9\n100 200 300 200 100 300 300 100 200\n'''\nn = int(input())\na = list(map(int, input().split()))\nm = max([a.count(i) for i in set(a)])\nd = {}\nfor x in a:\n\tif x in d:\n\t\td[x] += 1\n\telse:\n\t\td[x] = 1\n\tif max(d.values()) == m:\n\t\tprint(x)\n\t\tbreak", "from collections import Counter\n\nn, a = int(input()), (int(i) for i in input().split())\nres, cnt = 0, Counter()\nfor i in a:\n cnt[i] += 1\n if cnt[i] > cnt[res]:\n res = i\nprint(res)\n", "# n, k = map(int, input().split())\nn = int(input())\n\nv = [int(i) for i in input().split()]\n\nmapa = {}\n\nma = 0\nres = -1\nfor i in v:\n if i not in mapa:\n mapa[i] = 0\n mapa[i] += 1\n if mapa[i] > ma:\n ma = mapa[i]\n res = i\nprint(res)\n", "from collections import Counter\nn=int(input())\nc=Counter()\nx=[]\nfor i,l in enumerate(map(int,input().split())):\n c[l]+=1; x+=[(c[l],-i,l)]\nprint(max(x)[2])\n \t \t\t \t\t \t\t \t \t\t\t \t\t \t \t \t\t", "n = int(input())\r\ndata = map(int, input().split())\r\nd = {}\r\nrec = 0\r\nres = 0\r\nfor v in data:\r\n vv = d.get(v, 0)+1\r\n d[v] = vv\r\n if vv > rec:\r\n rec = vv\r\n res = v\r\nprint(res)\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\nans = -1\r\nd = {}\r\nfor ind in a:\r\n if d.get(ind) != None:\r\n d[ind] += 1\r\n else:\r\n d[ind] = 0\r\n if (ans == -1 or d[ind] > d[ans]):\r\n ans = ind\r\n\r\nprint(ans)\r\n ", "from functools import reduce\n \na=int(input())\nb=list(map(lambda m:int(m),input().split(' ')))\n\nm=max([len(list(filter(lambda m:m==i,b))) for i in b]) #количество вхождений\n\nv={a:0 for a in b}\n\nfor i in b:\n v[i]+=1\n if v[i]== m:\n print(i)\n exit(0)\n", "import collections\n\n\ndef main():\n likes_count = int(input())\n likes = input().split()\n\n id2like_count = collections.defaultdict(int)\n winner_id = None\n\n for liked_id in likes:\n id2like_count[liked_id] += 1\n if (\n liked_id != winner_id and\n id2like_count[liked_id] > id2like_count[winner_id]\n ):\n winner_id = liked_id\n print(winner_id)\n\nif __name__ == '__main__':\n main()\n", "import math , itertools , fractions , random\r\nfrom collections import Counter as cc\r\nsi = lambda : input() ; I = lambda : int(input()); ar = lambda : list(map(int , input().split())); al = lambda : map(int , input().split()); als = lambda : map(str , input().split());ars = lambda : list(map(str , input().split()))\r\n'''\r\n⠀⠀⠀⠀⠀⠀⠀⢀⣤⣴⣶⣶⣶⣶⣶⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⢀⣾⠟⠛⢿⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⢸⣿⣄⣀⣼⣿⣿⣿⣿⣿⣿⣿⠀⢀⣀⣀⣀⡀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠉⣿⣿⣿⣿⣿⠀⢸⣿⣿⣿⣿⣦⠀\r\n⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⢸⣿⣿⣿⣿⣿⡇\r\n⢰⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠿⠋⠀⣼⣿⣿⣿⣿⣿⡇\r\n⢸⣿⣿⣿⣿⣿⡿⠉⢀⣠⣤⣤⣤⣤⣤⣤⣤⣴⣾⣿⣿⣿⣿⣿⣿⡇\r\n'''\r\nn = I()\r\narr = ar() ; freq = [0]*(1000006) ; x = -999 ; y = 0 \r\nfor i in range(n) : \r\n freq[arr[i]]+=1\r\n if freq[arr[i]] > x : \r\n x = freq[arr[i]]\r\n y = arr[i]\r\nprint(y)\r\n'''\r\n⢸⣿⣿⣿⣿⣿⡇⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀\r\n⠘⣿⣿⣿⣿⣿⡇⠀⣿⣿⣿⣿⣿⠛⠛⠛⠛⠛⠛⠛⠛⠛⠋⠁⠀⠀\r\n⠀⠈⠛⠻⠿⠿⠇⠀⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⣿⡇⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣧⣀⣀⣿⠇⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠘⢿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀\r\n'''", "import collections\n\ninput()\ncounter = collections.Counter()\nmost = 0\nfor a in input().split():\n a = int(a)\n counter[a] += 1\n if counter[a] > most:\n most = counter[a]\n photo = a\nprint(photo)\n", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\nlikes = {}\r\nfor x in a:\r\n if x not in likes:\r\n likes[x] = 1\r\n else:\r\n likes[x] += 1\r\n\r\nmax_elem = max(likes.values())\r\n\r\nlikes.clear()\r\nlikes = {}\r\nfor x in a:\r\n if x not in likes:\r\n likes[x] = 1\r\n else:\r\n likes[x] += 1\r\n if likes[x] == max_elem:\r\n print(x)\r\n break\r\n", "n=int(input())\r\na=[int(x) for x in input().split()]\r\ndict1={}\r\nfor i in a:\r\n if i in dict1:\r\n dict1[i]+=1\r\n else:\r\n dict1[i]=1\r\nlst,res=[],0\r\nfor i in dict1:\r\n lst.append([i,dict1[i]])\r\n res=max(res,dict1[i])\r\nans=[]\r\nfor i in lst:\r\n if i[1]==res:\r\n ans.append(i[0])\r\nif len(ans)==1:\r\n print(ans[0])\r\nelse:\r\n for i in range(n-1,-1,-1):\r\n if a[i] in ans:\r\n ans.remove(a[i])\r\n if len(ans)==1:\r\n break\r\n print(ans[0])", "n = int(input())\r\ns = [i for i in input().split()]\r\na = {s[i]:0 for i in range(n)}\r\nb = a.copy()\r\nc = 0\r\nfor i in range(n):\r\n\ta[s[i]]+=1\r\nmaxi = max(a[i] for i in a)\r\n\r\nfor i in range(n):\r\n\tif a[s[i]]==maxi:\r\n\t\tif b[s[i]]==maxi-1:\r\n\t\t\tc = s[i]\r\n\t\t\tbreak\r\n\t\telse:\r\n\t\t\tb[s[i]]+=1\r\nprint(c)", "import math\r\nfrom collections import deque\r\n\r\n\r\nalfabet = {'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\nrasp=''\r\n#c=int(input())\r\nfor i in range(0,1):\r\n #n,m=map(int,input().split())\r\n n=int(input())\r\n #print(n,m)\r\n #stringul=input()\r\n \r\n lista=list(map(int,input().split()))\r\n #lista.sort()\r\n #primul=str(lista[0])\r\n \r\n \r\n dictionar={}\r\n maximul=0\r\n element=-1\r\n for i in range(0,n):\r\n if lista[i] not in dictionar:\r\n dictionar[lista[i]]=1\r\n else:\r\n dictionar[lista[i]]=dictionar[lista[i]]+1\r\n \r\n if dictionar[lista[i]]>maximul:\r\n maximul=dictionar[lista[i]]\r\n element=lista[i]\r\n \r\n# print(dictionar)\r\n \r\n print(element)\r\n#print(rasp) ", "I=input\r\nL=list\r\nC=L.count\r\nD=L.index\r\nI()\r\na=L(map(int,I().split()))[::-1]\r\nr=a[0]\r\nfor x in set(a):\r\n\tif C(a,x)>C(a,r)or C(a,x)==C(a,r) and D(a,x)>D(a,r):r=x\r\nprint(r)", "def solve():\r\n n = int(input())\r\n a = list(map(int, input().split()))\r\n\r\n if n == 1 or n == 2:\r\n print(a[0]); return\r\n\r\n max_l = 0\r\n likes = set(a)\r\n last_index = 10 ** 3\r\n\r\n for i in likes:\r\n if a.count(i) == max_l:\r\n for j in range(len(a) - 1, -1, -1):\r\n if a[j] == i:\r\n index = j\r\n break\r\n if index < last_index:\r\n last_index = index\r\n winner = i\r\n elif a.count(i) > max_l:\r\n winner = i\r\n for j in range(len(a) - 1, -1, -1):\r\n if a[j] == i:\r\n index = j\r\n break\r\n last_index = index\r\n max_l = a.count(i)\r\n\r\n print(winner)\r\n\r\nsolve()", "a = int(input())\nb = list(map(int,input().split()))\nd = []\ne = []\nc = 0\nfor x in b:\n\tif b.count(x) > c:\n\t\tc = b.count(x)\nfor x in b:\n\tif b.count(x) == c:\n\t\td.append(x)\nfor x in range(len(d)):\n\ta = 0\n\tif d.count(d[a]) != 1:\n\t\td.pop(d.index(d[a]))\n\telse:\n\t\ta += 1\nprint(d[0])", "count = int(input())\r\narray = input().split()\r\nmax_likes = 0\r\nwin_number = 0\r\nlikes = []\r\nfor i in range(count):\r\n if array[i] not in likes:\r\n likes.append(array[i])\r\n likes.append(1)\r\n if array[i] in likes:\r\n likes[likes.index(array[i]) + 1] += 1\r\n if likes[likes.index(array[i]) + 1] > max_likes:\r\n max_likes = likes[likes.index(array[i]) + 1]\r\n win_number = array[i]\r\nprint(win_number)", "n = int(input())\r\nd = dict()\r\ns = input().split()\r\nm = 0\r\na = -1\r\nfor i in s:\r\n if i in d:\r\n d[i] += 1\r\n if m < d[i]:\r\n m = d[i]\r\n a = i\r\n else:\r\n d[i] = 1\r\n if m < d[i]:\r\n m = d[i]\r\n a = i \r\nprint(a)", "n = int(input())\na = list(map(int, input().split(' ')))\n\nc = {}\nfor i in range(n):\n if a[i] not in c:\n c[a[i]] = [0, 0, a[i]]\n c[a[i]][0] -= 1\n c[a[i]][1] = i\n\nprint(sorted(c.values())[0][-1])\n", "from collections import defaultdict\n\nn = int(input())\nlike_ids = list(map(int, input().split()))\n\nlikes_by_id = defaultdict(int)\nlast_like_position = dict()\n\nfor pos, id in enumerate(like_ids):\n likes_by_id[id] += 1\n last_like_position[id] = pos\n\nmax_likes = max(likes_by_id.values())\n\nbest_photos = list(filter(lambda id: likes_by_id[id] == max_likes, likes_by_id.keys()))\n\nfastest_position = min([last_like_position[id] for id in best_photos])\nfor id in best_photos:\n if last_like_position[id] == fastest_position:\n print(id)\n break\nelse:\n raise ValueError()\n", "n = int(input())\r\n\r\narr = list(map(int, input().split()))\r\n\r\nlikes = [0] * 1000000\r\n\r\nfor i in arr:\r\n likes[i - 1] += 1\r\n\r\nl = max(likes)\r\ncand = set()\r\n\r\nfor i in range(1000000):\r\n if likes[i] == l:\r\n cand.add(i + 1)\r\n\r\nfor i in range(n - 1, -1, -1):\r\n if len(cand) == 1:\r\n break\r\n if arr[i] in cand:\r\n cand.remove(arr[i])\r\n\r\nprint(*cand)\r\n", "from collections import Counter\nn=int(input())\naa = list(map(int,input().split()))\nc = Counter()\nbest = 0\nlead = 1\nfor a in aa:\n c[a]+=1\n if c[a]>best:\n best = c[a]\n lead = a\n\nprint(lead)\n\n\n\n", "from collections import Counter\r\nn, v, vc, c = int(input()), 0, 0, Counter()\r\nfor x in map(int, input().split()):\r\n c[x] += 1\r\n if c[x] > vc:\r\n v, vc = x, c[x]\r\nprint(v)", "from collections import Counter\r\nn=int(input())\r\na=[int(i) for i in input().split(' ')]\r\nc=Counter()\r\nmx=-1\r\nmxid=-1\r\nfor i in range(n):\r\n c[a[i]]+=1\r\n if c[a[i]]>mx:\r\n mx=c[a[i]]\r\n mxid=a[i]\r\nprint(mxid)", "a = [0] * (10**3 + 1)\r\nn = int(input())\r\na = [int(i) for i in input().split()]\r\nm = max([a.count(i) for i in a])\r\nb = {}\r\nfor i in a:\r\n\tb[i] = 0\r\nfor i in a:\r\n\tb[i] += 1\r\n\tfor key, val in b.items():\r\n\t\tif val == m:\r\n\t\t\tprint(key)\r\n\t\t\texit()", "def mp(): return map(int,input().split())\r\ndef lt(): return list(map(int,input().split()))\r\ndef pt(x): print(x)\r\ndef ip(): return input()\r\ndef it(): return int(input())\r\ndef sl(x): return [t for t in x]\r\ndef spl(x): return x.split()\r\ndef aj(liste, item): liste.append(item)\r\ndef bin(x): return \"{0:b}\".format(x)\r\n\r\nn = it()\r\nL = lt()\r\nE = []\r\nfor i in set(L):\r\n E.append([i,L.count(i)])\r\nE.sort(key = lambda x: x[1], reverse = True)\r\nR = [E[0][0]]\r\nindex = 1\r\nwhile index < len(E) and E[index][1] == E[0][1]:\r\n R.append(E[index][0])\r\n index += 1\r\nL = L[::-1]\r\nR.sort(key = lambda x: L.index(x), reverse = True)\r\nprint(R[0])", "n = int(input())\r\nlikes = input().split()\r\n\r\nphotos = dict()\r\nbest = int(likes[0])\r\n\r\nfor like in likes:\r\n like = int(like)\r\n if like not in photos:\r\n photos[like] = 0\r\n photos[like] += 1\r\n if photos[best] < photos[like]:\r\n best = like\r\n\r\nprint(best)\r\n", "\"\"\"\nhttps://codeforces.com/problemset/problem/637/A\n\"\"\"\ntests = int(input())\nlikes = [int(x) for x in input().split()]\ndico = dict()\n\n\nfor i, l in enumerate(likes):\n a, b = dico.get(l, (0, 0))\n a += 1\n b = i\n dico[l] = (a, b)\n\nmaxi = 0\nfor k, (a, b) in dico.items():\n if a > maxi:\n maxi = a\n\nres = []\nfor k, (a, b) in dico.items():\n if a == maxi:\n res.append((b, k))\n\nprint(sorted(res)[0][1])\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nl,h=list(set(a)),0\r\nf=max(l)*[0]\r\nfor i in range(n):\r\n f[a[i]-1]+=1\r\n if f[a[i]-1]>h:\r\n h=f[a[i]-1]\r\nf=None\r\nf=max(l)*[0]\r\nfor i in range(n):\r\n f[a[i]-1]+=1\r\n if f[a[i]-1]==h:\r\n print(a[i])\r\n break\r\n \r\n\r\n\r\n\r\n\r\n", "kek = int(input())\r\na = [int(i) for i in input().split()]\r\nz = dict()\r\nz[10**10] = 0\r\nq = 10**10\r\nfor i in a:\r\n if not i in z:\r\n z[i] = 0\r\n z[i] += 1\r\n if z[i] > z[q]:\r\n q = i\r\nprint(q)\r\n", "n, d, k, m = int(input()), {}, None, 0\r\nfor i in input().split():\r\n\tif i in d:\r\n\t\td[i] += 1\r\n\telse:\r\n\t\td[i] = 1\r\n\tif d[i] > m:\r\n\t\tm = d[i]\r\n\t\tk = i\r\nprint(k)\r\n", "def photos(likes_sum, likes):\r\n d = {}\r\n max_value = 0\r\n last_like = 0\r\n for like in likes:\r\n if like in d:\r\n d[like] += 1\r\n else:\r\n d[like] = 1\r\n if d[like] > max_value:\r\n max_value = d[like]\r\n last_like = like\r\n return last_like\r\n\r\n\r\nif __name__ == \"__main__\":\r\n count_likes = int(input())\r\n likes = [int(a) for a in input().split()]\r\n print(photos(count_likes, likes))\r\n" ]
{"inputs": ["5\n1 3 2 2 1", "9\n100 200 300 200 100 300 300 100 200", "1\n5", "1\n1000000", "5\n1 3 4 2 2", "10\n2 1 2 3 1 5 8 7 4 8", "7\n1 1 2 2 2 3 3", "12\n2 3 1 2 3 3 3 2 1 1 2 1", "15\n7 6 8 4 9 8 7 3 4 6 7 5 4 2 8", "15\n100 200 300 500 300 400 600 300 100 200 400 300 600 200 100", "10\n677171 677171 677171 677171 672280 677171 677171 672280 672280 677171", "15\n137419 137419 531977 438949 137419 438949 438949 137419 438949 531977 531977 531977 438949 438949 438949", "20\n474463 517819 640039 640039 640039 640039 474463 474463 474463 640039 640039 474463 474463 425567 474463 517819 640039 474463 517819 517819", "40\n119631 119631 772776 119631 658661 119631 108862 524470 125132 700668 69196 844949 154577 108862 108862 108862 597344 940938 989698 108862 154577 69196 125132 687080 940938 125132 69196 69196 125132 566152 953083 406319 380068 119631 154577 125132 413984 69196 154577 154577", "5\n1 1 1000000 1000000 1000000", "5\n1000000 1 1 1000000 1", "10\n1 1 1000000 1000000 1000000 1 1000000 1 1 1000000", "8\n1000000 1000000 1 1 1 1000000 1000000 1", "1\n1", "2\n1 1", "2\n1000000 1", "2\n1 1000000", "2\n1000000 1000000", "3\n1 1 1", "3\n1 1 2", "3\n1 2 1", "3\n2 1 1", "4\n1 1000000 1000000 1"], "outputs": ["2", "300", "5", "1000000", "2", "2", "2", "3", "7", "300", "677171", "438949", "474463", "108862", "1000000", "1", "1", "1000000", "1", "1", "1000000", "1", "1000000", "1", "1", "1", "1", "1000000"]}
UNKNOWN
PYTHON3
CODEFORCES
119
e3abacc6abe0ee07cdb442dc8ff735e4
Is This a Zebra?
A camera you have accidentally left in a desert has taken an interesting photo. The photo has a resolution of *n* pixels width, and each column of this photo is all white or all black. Thus, we can represent the photo as a sequence of *n* zeros and ones, where 0 means that the corresponding column is all white, and 1 means that the corresponding column is black. You think that this photo can contain a zebra. In this case the whole photo should consist of several (possibly, only one) alternating black and white stripes of equal width. For example, the photo [0,<=0,<=0,<=1,<=1,<=1,<=0,<=0,<=0] can be a photo of zebra, while the photo [0,<=0,<=0,<=1,<=1,<=1,<=1] can not, because the width of the black stripe is 3, while the width of the white stripe is 4. Can the given photo be a photo of zebra or not? The first line contains a single integer *n* (1<=≤<=*n*<=≤<=100<=000) — the width of the photo. The second line contains a sequence of integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=1) — the description of the photo. If *a**i* is zero, the *i*-th column is all black. If *a**i* is one, then the *i*-th column is all white. If the photo can be a photo of zebra, print "YES" (without quotes). Otherwise, print "NO". You can print each letter in any case (upper or lower). Sample Input 9 0 0 0 1 1 1 0 0 0 7 0 0 0 1 1 1 1 5 1 1 1 1 1 8 1 1 1 0 0 0 1 1 9 1 1 0 1 1 0 1 1 0 Sample Output YES NO YES NO NO
[ "n = int(input())\r\na = input().split()\r\nnow = -1\r\nwhite = 0\r\nblack = 0\r\nfor i in range(n):\r\n if(int(a[i]) == 0):\r\n if(white > 0):\r\n if(now == -1):\r\n now = white\r\n elif(now != white):\r\n print(\"NO\")\r\n exit(0)\r\n \r\n white = 0\r\n black += 1\r\n else:\r\n if(black > 0):\r\n if(now == -1):\r\n now = black\r\n elif(now != black):\r\n print(\"NO\")\r\n exit(0)\r\n black = 0\r\n white += 1\r\n\r\nif(white > 0):\r\n if(now == -1):\r\n now = white\r\n elif(now != white):\r\n print(\"NO\")\r\n exit(0)\r\n\r\nif(black > 0):\r\n if(now == -1):\r\n now = black\r\n elif(now != black):\r\n print(\"NO\")\r\n exit(0)\r\n \r\nprint(\"YES\")", "def main():\r\n n = int(input())\r\n photo = [int(x) for x in (input().split())]\r\n color = dict()\r\n cnt = 0\r\n for i in range(n):\r\n if i == 0:\r\n cnt += 1\r\n continue\r\n if photo[i] == photo[i - 1]:\r\n cnt += 1\r\n if photo[i] != photo[i - 1]:\r\n color[cnt] = 1\r\n cnt = 1\r\n if i == n - 1:\r\n color[cnt] = 1\r\n if len(color) <= 1:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\nmain()", "import sys\n\ninput()\ndata = list(map(lambda x: int(x), input().split(\" \")))\n\nlength = 0\nfor i in data:\n if i == data[0]:\n length += 1\n else:\n break\ncur_char = data[0]\ncounter = 0\nfor c in data:\n if c == cur_char:\n counter += 1\n else:\n if counter != length:\n print(\"NO\")\n sys.exit(0)\n else:\n counter = 1\n cur_char = c\nif counter != length:\n print(\"NO\")\nelse:\n print(\"YES\")\n", "# python3\r\n\r\n\r\n\r\nn = input()\r\na = list(map(int, input().split()))\r\nlen=0\r\n\r\nn=int(n)\r\n\r\nlen=0\r\n\r\nfor i in range (1,n):\r\n sc = a[i]-a[i-1]\r\n if(sc>0):\r\n len=i\r\n break\r\n if(sc<0):\r\n len=i\r\n break\r\nfl=1;\r\nif(len==0): \r\n len=n\r\nr=n%len\r\nif(r==0):\r\n lol=1\r\nelse:\r\n print(\"NO\")\r\n exit(0)\r\nfor i in range (1,n):\r\n sc = a[i]-a[i-1]\r\n if(sc>0):\r\n tmp = (i)%len\r\n if(tmp>0):\r\n fl=0\r\n if(tmp<0):\r\n fl=0\r\n if(sc<0):\r\n tmp = (i)%len\r\n if(tmp>0):\r\n fl=0\r\n if(tmp<0):\r\n fl=0\r\n if(sc==0):\r\n tmp = (i)%len\r\n if(tmp==0):\r\n fl=0\r\nif(fl==0):\r\n print (\"NO\")\r\nelse:\r\n print(\"YES\")", "# LUOGU_RID: 105567814\nn = int(input())\r\nla = -1\r\ncnt = 0\r\nflg = True\r\nlac = -1\r\ns = input().split()\r\nfor i in range(n):\r\n x = int(s[i])\r\n if (x == lac):\r\n cnt += 1\r\n else:\r\n if (la != -1 and la != cnt):\r\n flg = False\r\n break\r\n else:\r\n if (cnt != 0):\r\n la = cnt\r\n cnt = 1\r\n lac = x\r\n# print(la, cnt, flg)\r\nif (flg == False or (la != -1 and la != cnt)):\r\n print('NO')\r\nelse:\r\n print('YES')", "n = int(input())\r\nline = list(map(int, input().split()))\r\nans = [1]\r\nprev = line[0]\r\nk = 1\r\nfor i in range(1, n):\r\n if line[i] == prev:\r\n ans[-1] += 1\r\n else:\r\n k += 1\r\n prev = line[i]\r\n ans.append(1)\r\nif [ans[0]] * k != ans:\r\n print('NO')\r\nelse:\r\n print('YES')\r\n", "'''\r\nBeezMinh\r\n09:14 UTC+7\r\n20/07/2023\r\n'''\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nl = []\r\nsz = 1\r\nfor i in range(1, n):\r\n if a[i] == a[i - 1]:\r\n sz += 1\r\n else:\r\n l.append(sz)\r\n sz = 1\r\nl.append(sz)\r\nl = sorted(l)\r\nif l[0] == l[-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = int(input())\r\na = [int(i) for i in input().split()]\r\n\r\nS = set()\r\ninterval = 1 # interval size\r\n\r\nfor i in range(1, n):\r\n if a[i] != a[i - 1]:\r\n S.add(interval)\r\n interval = 0\r\n interval= interval + 1\r\nS.add(interval)\r\n\r\nif len(S) != 1:\r\n print(\"NO\\n\")\r\nelse:\r\n print(\"YES\\n\")\r\n", "n = int(input())\r\nl = list(map(int, input().split()))\r\ns = ''\r\nfor i in range(n):\r\n\ts += str(l[i])\r\nj = 0\r\nwhile j != n and l[j] == l[0]:\r\n\tj += 1\r\nans = ''\r\nblocks = n // j\r\ncurr = l[0]\r\nfor i in range(blocks):\r\n\tans += j * str(curr)\r\n\tcurr ^= 1\r\nif ans == s:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "n=int(input())\na=list(map(int,input().split()))\nk=0\nb=a[0]\nans=0\nfor i in a:\n\tif i==b:\n\t\tans+=1\n\telse:\n\t\tbreak\nif n%ans!=0:\n\tprint(\"NO\")\nelse:\n\tresult=0\n\ti=0\n\tcurr=a[0]\n\twhile(i<n):\n\t\tj=0\n\t\twhile(j<ans):\n\t\t\tif a[i+j]!=curr:\n\t\t\t\tresult=-1\n\t\t\t\tbreak\n\t\t\tj+=1\n\t\tif result==-1:\n\t\t\tbreak\n\n\t\ti+=ans\n\t\tcurr=1-curr\n\tif result==-1:\n\t\tprint(\"NO\")\n\telse :\n\t\tprint(\"YES\")\n", "x = int(input())\r\narr = [int(x) for x in input().split()]\r\n\r\nd = {}\r\ncnt = 0\r\nfor i in range(x):\r\n if arr[i] == 0:\r\n cnt += 1\r\n else:\r\n if cnt > 0:\r\n d[cnt] = 1\r\n cnt = 0\r\nif cnt > 0:\r\n d[cnt] = 1\r\n\r\ncnt = 0\r\nfor i in range(x):\r\n if arr[i] == 1:\r\n cnt += 1\r\n else:\r\n if cnt > 0:\r\n d[cnt] = 1\r\n cnt = 0\r\nif cnt > 0:\r\n d[cnt] = 1\r\n\r\nif len(d.keys()) == 1:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = int(input())\na = list(map(int, input().split()))\npv = 0\nl = 0\n\nb = -1\nok = 1\nfor i in range(n):\n\tif i == 0:\n\t\tpv = a[i]\n\t\tl += 1\n\telse:\n\t\tif a[i] == pv:\n\t\t\tl+=1\n\t\telse:\n\t\t\tif b == -1:\n\t\t\t\tb = l;\n\t\t\telif b != l:\n\t\t\t\tok = 0\n\t\t\tl = 1\n\t\t\tpv = a[i]\n\nif b == -1:\n\tb = l\nelif b != l:\n\tok = 0\n\nif ok == 1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "input()\r\nl, ll = list(map(int, input().split())), []\r\nx, y = l[0], 1\r\nfor i in range(1, len(l)):\r\n\tif l[i] == x:\r\n\t\ty += 1\r\n\telse:\r\n\t\tll.append(y)\r\n\t\tx = l[i]\r\n\t\ty = 1\r\nprint('YES' if len(set(ll + [y])) == 1 else 'NO')", "# my_string = raw_input()\nimport sys\nn = int(input())\n# print \"Enter n numbers :\"\n# a = []\n# for i in range(n):\n# x = int(input())\n# a.append(x)\n\nstr_arr = input().split(' ')\na = [int(num) for num in str_arr]\nzero = True\nsmallest = n\nlen = 0\nif(a[0] == 0):\n zero = True\nelse:\n zero = False\nfor i in range(n):\n if(zero == True):\n if(a[i] == 0):\n len += 1\n else:\n smallest = min(smallest, len)\n len = 1\n zero = False\n else:\n if(a[i] == 1):\n len += 1\n else:\n smallest = min(smallest, len)\n len = 1\n zero = True\n if(i == n - 1):\n smallest = min(smallest, len)\n\n# print(\"smallest = \" + str(smallest))\nzero = True\nif(a[0] == 0):\n zero = True\nelse:\n zero = False\nlen = 0\nfor i in range(n):\n if(zero == True):\n if(a[i] == 0):\n len += 1\n else:\n if(len != smallest):\n print(\"NO\")\n sys.exit()\n len = 1\n zero = False\n else:\n if(a[i] == 1):\n len += 1\n else:\n if(len != smallest):\n print(\"NO\")\n sys.exit()\n len = 1\n zero = True\n if(i == n - 1):\n if(len != smallest):\n print(\"NO\")\n sys.exit()\n\nprint(\"YES\")\n# M = int(raw_input(\"Enter M :\"))\n# m = [0 for i in range(M + 10)]\n# m[0] = 1\n# for i in range(n):\n# for j in range(a[i], M, -1):\n# m[j] |= m[j - a[i]]\n#\n# print m\n", "n = int(input())\r\na = list(map(int, input().split()))\r\nstripe = -1\r\ncur_stripe = 1\r\nfor i in range(1, len(a)):\r\n if a[i] == a[i - 1]:\r\n cur_stripe += 1\r\n else:\r\n if stripe == -1:\r\n stripe = cur_stripe\r\n cur_stripe = 1\r\n else:\r\n if cur_stripe != stripe:\r\n print(\"NO\")\r\n break\r\n else:\r\n cur_stripe = 1\r\nelse:\r\n if stripe == -1:\r\n print(\"YES\")\r\n else:\r\n if cur_stripe != stripe:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n", "n = int(input())\r\na = list(map(int,input().split()))\r\nlst = []\r\nsz = 1\r\nfor i in range(1, n):\r\n if a[i] == a[i-1]:\r\n sz += 1\r\n else:\r\n lst.append(sz)\r\n sz = 1\r\nlst.append(sz)\r\nlst.sort()\r\nif lst[0] == lst[len(lst)-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = map(int,input().split())\r\na = [int(i) for i in input().split()]\r\n \r\no=a[0];\r\nk=0;\r\noldk=-1;\r\nw=1;\r\n\r\nfor i in range(0,len(a)) :\r\n if o==a[i] :\r\n k+=1;\r\n if o!=a[i] :\r\n if oldk==-1 :\r\n oldk=k;\r\n if oldk!=k :\r\n w=0;\r\n k=1;\r\n o=a[i];\r\n\r\nif oldk==-1 :\r\n oldk=k;\r\n \r\nif k!=oldk :\r\n w=0;\r\n \r\nif w==1 :\r\n print(\"YES\");\r\nif w==0 :\r\n print(\"NO\");", "n = list(map(int, input().split(' ')))[0]\nmessage1 = list(map(int, input().split(' ')))\n\ncorrect = True\nif n == 0:\n print(\"YES\")\nelse: \n counter = 0\n ff = message1[0]\n i = 0\n while i < n and message1[i] == ff:\n i += 1\n counter += 1\n while i != n:\n ss = message1[i]\n curcounter = 0\n while i < n and message1[i] == ss:\n i += 1\n curcounter += 1\n if curcounter != counter:\n correct = False\n if correct:\n print(\"YES\")\n else:\n print(\"NO\")\n \n ", "n = int(input())\r\nl = input().split()\r\nfor i in range(0,len(l)):\r\n l[i] = int(l[i])\r\nk = 0\r\nlast = l[0]\r\nkabul = -1\r\nister = 1\r\nfor i in range(0,len(l)):\r\n if last != l[i] :\r\n if kabul == -1:\r\n kabul = k\r\n if kabul != k:\r\n ister = 0\r\n break\r\n k = 1\r\n last = l[i]\r\n else :\r\n k+=1\r\n if kabul != -1 and k > kabul:\r\n ister = 0\r\n break;\r\nif k < kabul :\r\n ister = 0\r\nif ister == 1:\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n", "n = input()\r\nline = [int(x) for x in input().split()]\r\n\r\ncurrent = line[0]\r\ncurrent_size = 1\r\nline_size = -1\r\n\r\nfor i in line[1:]:\r\n if i == current:\r\n current_size = current_size + 1\r\n if current_size > line_size != -1:\r\n print(\"NO\")\r\n exit(0)\r\n if i != current:\r\n if current_size != line_size and line_size!= -1:\r\n print(\"NO\")\r\n exit(0)\r\n line_size = current_size\r\n current = i\r\n current_size = 1\r\n\r\nif current_size != line_size and line_size!= -1:\r\n print(\"NO\")\r\n exit(0)\r\nprint(\"YES\")", "n = int(input())\r\na = list(map(int,input().split()))\r\nz = set()\r\no = set()\r\ni=0\r\nwhile i<n:\r\n\tcount=0\r\n\twhile i<n and a[i]==1:\r\n\t\tcount+=1\r\n\t\ti=i+1\r\n\t#print(count)\r\n\tif count!=0:\r\n\t\to.add(count)\r\n\tcount=0\r\n\twhile i<n and a[i]==0:\r\n\t\tcount=count+1\r\n\t\ti=i+1\r\n\t#print(count)\r\n\tif count!=0:\r\n\t\tz.add(count)\r\nz = list(z)\r\no = list(o)\r\n#print(z,\" \",o)\r\nif len(z)==1 and len(o)==1 and z[0]==o[0]:\r\n\tprint('YES')\r\nelif (len(z)==0 and len(o)==1) or (len(o)==0 and len(z)==1):\r\n\tprint('YES')\r\nelse :\r\n\tprint('NO')", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\nlen = -1\r\nlastColor = -1\r\ncurLen = 0\r\na.append(-1)\r\n\r\n\r\nfor i in a:\r\n if i != lastColor:\r\n if len != -1:\r\n if curLen != len:\r\n print(\"NO\")\r\n exit(0)\r\n else:\r\n if lastColor != -1:\r\n len = curLen\r\n lastColor = i\r\n curLen = 1\r\n else:\r\n curLen += 1\r\n\r\nprint(\"YES\")\r\n", "import sys\r\n\r\nn = sys.stdin.readline()\r\narray = sys.stdin.readline().split()\r\n\r\nfirst = True\r\ntemp = 0\r\nwidth = 0\r\nlast = array[0]\r\n\r\nfor num in array:\r\n if last != num:\r\n if first:\r\n width = temp\r\n elif temp != width:\r\n print(\"NO\")\r\n sys.exit(0)\r\n\t\t\r\n last = num\r\n temp = 1\r\n first = False\r\n else:\r\n temp += 1\r\n\r\nif not first and temp != width:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "\r\nn = int(input())\r\narr = input().split()\r\nfor i in range(0,n) :\r\n arr[i] = int(arr[i])\r\narr.append(1-arr[-1])\r\nans = True\r\nl = 0\r\nr = 1\r\nw = 0\r\nwhile l<n :\r\n if arr[r]!=arr[r-1] :\r\n if r-l!=w and w!=0 :\r\n ans = False\r\n break\r\n w = r - l\r\n l = r\r\n r+= 1\r\nif ans :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n", "#!/usr/bin/python3\nn =int(input())\narr = list(map(int, input().split()))\nx=1\nU=-1\na=arr[0]\narr.append(42)\nfor i in range(n):\n b=arr[i+1]\n if(b!=a):\n if(U==-1):U=x\n elif(U!=x):U=-2\n a=b\n x=1\n else:\n x=x+1\nif(U==-2):print(\"NO\")\nelse: print(\"YES\")\n", "# -*- coding: utf-8 -*-\r\n\r\nn = int(input())\r\npix, num = [int(i) for i in input().split()], []\r\n\r\nsig = -1\r\nfor p in pix:\r\n if p == sig:\r\n num[-1] += 1\r\n else:\r\n num.append(1)\r\n sig = p\r\n \r\nprint(\"YES\" if len(set(num)) == 1 else \"NO\")\r\n", "x = int(input())\r\nm = list(map(int,input().split()))\r\nwh = 0\r\nbl = 0\r\nl = []\r\nif m[0] == 1:\r\n\t\twh += 1\r\nelse:\r\n\tbl += 1\r\nfor i in range(1, x):\r\n\tif m[i] != m[i - 1]:\r\n\t\tif m[i - 1] == 1:\r\n\t\t\tl += [wh]\r\n\t\t\twh = 0\r\n\t\telse:\r\n\t\t\tl += [bl]\r\n\t\t\tbl = 0\r\n\tif m[i] == 1:\r\n\t\tbl = 0\r\n\t\twh += 1\r\n\telse:\r\n\t\twh = 0\r\n\t\tbl += 1\r\nif bl > 0:\r\n\tl += [bl]\r\nelse:\r\n\tl += [wh]\r\nb = 1\r\nfor i in range(1, len(l)):\r\n\tif l[i - 1] != l[i]:\r\n\t\tb = 0\r\n\t\tprint('NO')\r\n\t\tbreak\r\nif b == 1:\r\n\tprint('YES')", "n = int(input());\r\ns = map(int, input().split());\r\ni = 0;\r\nk = 0;\r\nt = 0;\r\nx = 0;\r\nc = 0;\r\nans = 1;\r\nfor i in list(s):\r\n p = int(i);\r\n if (c == 0):\r\n if (k == 0):\r\n t = p;\r\n if (t == p):\r\n k += 1\r\n else:\r\n t = p;\r\n x = 0;\r\n c = 1;\r\n if (t == p):\r\n x += 1\r\n else:\r\n t = p;\r\n if (x != k):\r\n ans = 0;\r\n x = 1;\r\nif (x != k):\r\n ans = 0;\r\nif (ans == 1):\r\n print('YES')\r\nelse:\r\n print('NO')", "n=int(input())\r\nf=True\r\nprev=0\r\ncurr=1\r\nst=input()\r\n# print(st);\r\ntem= st.split();\r\n# print(tem)\r\nch=tem[0]\r\nfor i in range(1,n):\r\n y=tem[i]\r\n if y==ch:\r\n curr=curr+1\r\n else:\r\n if prev==0:\r\n prev=curr\r\n ch=y\r\n curr=1\r\n elif prev==curr:\r\n ch=y\r\n curr=1\r\n else:\r\n f=False\r\nif prev!=0 and prev!=curr:\r\n f=False\r\nif f:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n ", "n = int(input())\r\na = list(map(int, input().split()));\r\ncnt = 0;\r\nlast = 0\r\nfor i in range(n):\r\n if i > 0 and a[i] != a[i-1]:\r\n if last>0 and last != cnt :\r\n print(\"NO\")\r\n exit(0)\r\n last = cnt\r\n cnt = 0\r\n cnt = cnt+1\r\nif last > 0 and cnt != last:\r\n print(\"NO\")\r\n exit(0)\r\nelse :\r\n print(\"YES\")", "from itertools import groupby\r\nn = int(input())\r\nmas = ''.join([i for i in input().split()])\r\nzebra = []\r\nzebra = [len(list(j)) for i, j in groupby(mas)]\r\na = [len(list(j)) for i, j in groupby(zebra)]\r\n\r\n\r\nif len(a)==1:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = int(input())\nl = list(map(int, input().split()))\ncount = 0\ntemp = 0\npre = -1\nans = \"YES\"\nfor i in l:\n\tif i == pre:\n\t\ttemp = temp + 1\n\telse:\n\t\tif pre == -1:\n\t\t\tpre = i\n\t\t\ttemp = temp + 1\n\t\telif count == 0:\n\t\t\tcount = temp\n\t\t\tpre = i\n\t\t\ttemp = 1\n\t\telif count == temp:\n\t\t\tpre = i\n\t\t\ttemp = 1\n\t\telse:\n\t\t\tans = \"NO\"\t\n\nif count!=0 and temp != count:\n\tans = \"NO\"\t\nprint(ans)\t\n", "n = int(input().split()[0]);\r\na = list(map(int,input().split()))\r\n\r\npad = 0;\r\nfor i in range(0,n):\r\n if(a[i]==a[0]):\r\n pad = pad+1\r\n else:\r\n break\r\nstatus = True\r\n\r\nif (n % pad != 0):\r\n status = False;\r\n\r\nfor i in range(pad,n):\r\n if(a[i] == a[i-pad]):\r\n status = False\r\n break\r\n\r\nif(status):\r\n print('YES')\r\nelse:\r\n print('NO')", "def main():\r\n\tn = int(input())\r\n\tarr = list(map(int, input().split(' ')))\r\n\tcnt = 0\r\n\tfor i in range(0, n):\r\n\t\tif arr[i] == arr[0]:\r\n\t\t\tcnt = cnt+1\r\n\t\telse:\r\n\t\t\tbreak\r\n\tId = cnt;\r\n\ttemp = 0;\r\n\tflag = 0;\r\n\tfor i in range(cnt, n):\r\n\t\tif arr[i] == arr[Id]:\r\n\t\t\ttemp = temp+1\r\n\t\telif temp == cnt:\r\n\t\t\ttemp = 1;\r\n\t\t\tId = i;\r\n\t\telse:\r\n\t\t\tflag = 1\r\n\t\t\tbreak\r\n\tif temp > 0 and temp != cnt:\r\n\t\tflag = 1\r\n\tif flag == 1:\r\n\t\tprint('NO')\r\n\telse:\r\n\t\tprint('YES')\r\nif __name__ == '__main__':\r\n\tmain()", "import sys\r\n\r\nn = int(input())\r\nar = input().split()\r\nz=int(0)\r\no=int(0)\r\nlast=\"0\"\r\nv=list()\r\n\r\nif ar[0]==\"0\":\r\n\tz = z+1\r\nelse:\r\n\to = o+1\r\n\tlast=\"1\";\r\n\r\nfor y in range(1, len(ar)):\r\n\tx = ar[y]\r\n\tif x==last:\r\n\t\tif last==\"0\":\r\n\t\t\tz = z+1\r\n\t\telse:\r\n\t\t\to = o+1\r\n\telse:\r\n\t\tif last==\"0\":\r\n\t\t\tlast=\"1\"\r\n\t\t\tv.append(z)\r\n\t\t\tz=0\r\n\t\t\to=1\r\n\t\telse:\r\n\t\t\tlast=\"0\"\r\n\t\t\tv.append(o)\r\n\t\t\to=0\r\n\t\t\tz=1\r\n\r\nif z==0:\r\n\tv.append(o)\r\nelse:\r\n\tv.append(z)\r\n\r\nif len(set(v))==1:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\ncom = []\r\ncnt = 0\r\no1 = False\r\nif a[0] == 1:\r\n o1 = True\r\nfor i in a:\r\n if i == o1:\r\n cnt += 1\r\n else:\r\n com.append(cnt)\r\n cnt = 1\r\n o1 = i\r\ncom.append(cnt)\r\n \r\nfor i in com:\r\n if i != com[0]:\r\n print(\"NO\")\r\n exit()\r\nprint(\"YES\")\r\n", "from sys import stdin\r\n \r\nn = int(input())\r\ns = str(input())\r\ni = 0\r\nj = 1\r\nk = int(0)\r\nc = 'a'\r\nkk = int(-1)\r\nbad = 0\r\nwhile j<=n:\r\n\tif (c!=s[i]):\r\n\t\tc=s[i]\r\n\t\tif (k!=kk):\r\n\t\t\tif (kk!=-1):\r\n\t\t\t\tbad=1\r\n\t\tif (kk==-1):\r\n\t\t\tif (i>1):\r\n\t\t\t\tkk=k\r\n\t\tk=0\r\n\tk=k+1\t\r\n\ti=i+2\r\n\tj=j+1\r\nif (k!=kk):\r\n\tif (kk!=-1):\r\n\t\tbad=1\r\nif (bad==1):\r\n\tprint(\"NO\")\r\nif (bad==0):\r\n\tprint(\"YES\")", "'''input\n9\n0 0 0 1 1 1 0 0 0\n\n'''\n\ns = set()\nn = int(input())\nvec = list(map(int, input().split()))\ni = 0\nwhile i < n:\n\tcnt = 0\n\tv = vec[i]\n\twhile i < n and vec[i] == v:\n\t\tcnt += 1\n\t\ti += 1\n\ts.add(cnt)\n\nif len(s) == 1:\n\tprint('YES')\nelse:\n\tprint('NO')", "n = int(input())\r\na = list(map(int, input().split()))\r\ncnt = 0\r\ns = set()\r\npr = a[0]\r\nfor i in a:\r\n if i == pr:\r\n cnt += 1\r\n else :\r\n s.add(cnt)\r\n cnt = 1;\r\n pr = i\r\ns.add(cnt)\r\nif len(s)==1:\r\n print(\"Yes\")\r\nelse :\r\n print(\"No\")", "n=int(input())\r\n\r\nl =input()\r\n\r\nl = [int(i) for i in l.split()] + [-1]\r\ns = set()\r\nt = 0\r\nfor i in range(len(l)-1):\r\n if l[i]==l[i+1]:t+=1\r\n else:\r\n t+=1\r\n s.add(t)\r\n if i==len(l)-2:\r\n t=1\r\n else:t=0\r\nif len(s)==1:print(\"YES\")\r\nelse:print(\"NO\")\r\n", "from itertools import groupby\ninput()\nprint(['YES', 'NO'][len(set(len(list(g)) for k, g in groupby(input().split()))) > 1])\n", "n = int(input())\r\na = list(map(int, input().split()))\r\nans = \"YES\"\r\nstripe, ctr, temp = -1, 1, -1\r\nfor x in a:\r\n if stripe == -1:\r\n stripe = x\r\n else:\r\n if x == stripe:\r\n ctr += 1\r\n else:\r\n if temp != -1 and ctr != temp:\r\n ans = \"NO\"\r\n break\r\n temp = ctr\r\n ctr = 1\r\n stripe = x\r\nif temp != -1 and ctr != temp:\r\n ans = \"NO\"\r\nprint(ans)", "maxN = 10**5 + 5\r\nH = []\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nw = 0\r\nb = 0\r\nfor i in range(n):\r\n if (a[i] == 1):\r\n if (w):\r\n H.append(w)\r\n w = 0\r\n b += 1\r\n else:\r\n if (b):\r\n H.append(b)\r\n b = 0\r\n w += 1\r\nif (w):\r\n H.append(w)\r\nif (b):\r\n H.append(b)\r\nf = 0\r\nfor i in range(len(H)):\r\n if (H[i] != H[0]):\r\n f = 1\r\nif (f == 1):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n", "from itertools import groupby\r\nn=int(input())\r\nw=[int(k) for k in input().split()]\r\nw=[len(list(k[1])) for k in groupby(w)]\r\nif len(set(w))==1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = int(input())\r\na = list(map(int, input().split()))\r\nans = \"NO\"\r\nfor i in range(1, n+1):\r\n\tif n%i == 0:\r\n\t\tflag = True\r\n\t\tfor j in range(0, n//i):\r\n\t\t\tif j > 0 and a[j*i] == a[(j-1)*i]:\r\n\t\t\t\tflag = False\r\n\t\t\tfor k in range(j*i, j*i+i):\r\n\t\t\t\tif a[k] != a[j*i]:\r\n\t\t\t\t\tflag = False\r\n\t\tif flag:\r\n\t\t\tans = \"YES\"\r\nprint(ans)", "n = int(input())\r\na = list(map(int, input().split()))\r\nc = [1]\r\nfor i in range(1, n):\r\n if a[i] == a[i-1]:\r\n c[-1] += 1\r\n else :\r\n c.append(1)\r\nans = \"Yes\"\r\nfor i in range(1, len(c)):\r\n if c[i] != c[i-1]:\r\n ans = \"No\"\r\n break\r\nprint(ans)", "t=int(input())\r\na=[int(i) for i in input().split()]\r\nc=0\r\nd=0\r\nb=[]\r\nfor i in a:\r\n if i==0:\r\n if d!=0:\r\n b.append(d)\r\n d=0\r\n c+=1\r\n else:\r\n if c!=0:\r\n b.append(c)\r\n c=0\r\n d+=1\r\nif c!=0:\r\n b.append(c)\r\nif d!=0:\r\n b.append(d)\r\nb.sort()\r\nif b[0]!=b[len(b)-1]:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "s = 1\r\nf = 0\r\nn = int(input())\r\na = list(map(int, input().split()))\r\na.append(1 - a[n - 1])\r\nn += 1\r\nfor i in range(1, n):\r\n if a[i] == a[i - 1]:\r\n s += 1\r\n else:\r\n if f == 0:\r\n f = s\r\n else:\r\n if s != f:\r\n print(\"NO\")\r\n exit()\r\n s = 1\r\nprint(\"YES\")", "def solve():\r\n n = int(input())\r\n p = [int(x) for x in (input().split())]\r\n c = dict()\r\n cnt = 0\r\n for i in range(n):\r\n if i == 0:\r\n cnt += 1\r\n continue\r\n if p[i] == p[i - 1]:\r\n cnt += 1\r\n if p[i] != p[i - 1]:\r\n c[cnt] = 1\r\n cnt = 1\r\n if i == n - 1:\r\n c[cnt] = 1\r\n if len(c) < 2:\r\n print('YES')\r\n else:\r\n print('NO')\r\n \r\nsolve()", "import sys\r\nn = int(input())\r\nL = [int(el) for el in input().split()]\r\na = set()\r\nk = 1\r\nfor i in range(1, len(L)):\r\n if L[i] == L[i - 1]:\r\n k += 1\r\n else:\r\n a.add(k)\r\n k = 1\r\n if len(a) > 1:\r\n print('NO')\r\n sys.exit()\r\na.add(k)\r\nif len(a) > 1:\r\n print('NO')\r\nelse:\r\n print('YES')\r\n \r\n \r\n", "n=int(input())\r\narr=list(map(int,input().split()))\r\ncolor=[0]\r\nfor i in range(1,len(arr)):\r\n if arr[i]==arr[i-1]:\r\n color.append(color[i-1]+1)\r\n else:\r\n color.append(0)\r\nmaxx=max(color)\r\ncount=color.count(max(color))\r\nif count*(maxx+1)==n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "numms = list()\r\nnum = input()\r\nnum_array = [int(i) for i in input().split()]\r\n\r\nlast = num_array[0]\r\nt = 0\r\nlastt = 0\r\nfor i in num_array:\r\n\tif (i == last):\r\n\t\tt = t+1\r\n\t\tlast = i\r\n\telse:\r\n\t\tnumms.append(int(t))\r\n\t\tlast = i\r\n\t\tt = 1\r\nnumms.append(int(t))\r\n\t\t\r\ni = 1\r\nchecker = None\r\nwhile i < len(numms):\r\n\tif (numms[i] != numms[i-1]):\r\n\t\tprint(\"No\")\r\n\t\traise SystemExit\r\n\ti = i+1\r\n\r\nprint(\"Yes\")", "len = int(input())\r\nline = input().split(' ')\r\n\r\ncnt = 1\r\ni = 1\r\n\r\nwhile i < len:\r\n\tif line[i] != line[i - 1]:\r\n\t\tcnt = cnt + 1\r\n\ti = i + 1\r\n\r\nneed_len = len // cnt\r\n\r\nif need_len * cnt != len:\r\n\tprint(\"NO\")\r\nelse:\r\n\ti = 0\r\n\twhile i < len:\r\n\t\tsize = 0\r\n\t\tif int(line[i]) == 1:\r\n\t\t\twhile i < len and int(line[i]) == 1:\r\n\t\t\t\ti = i + 1\r\n\t\t\t\tsize = size + 1\r\n\t\telse:\r\n\t\t\twhile i < len and int(line[i]) == 0:\r\n\t\t\t\ti = i + 1\r\n\t\t\t\tsize = size + 1\r\n\t\tif size != need_len:\r\n\t\t\tprint(\"NO\")\r\n\t\t\ti = len + 100\r\n\tif i - 10 < len:\r\n\t\tprint(\"YES\")\t\r\n\t", "n = int(input())\r\na = [int(item) for item in input().split()]\r\ns = set()\r\nam = 1\r\nfor i in range(1, n):\r\n if a[i] == a[i-1]:\r\n am = am+1\r\n else:\r\n s.add(am)\r\n am = 1\r\ns.add(am)\r\nif(len(s) == 1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def main():\r\n n = int(input())\r\n data = input().split()\r\n current_char = '1'\r\n count = 0\r\n counters = set()\r\n while data:\r\n char = data.pop()\r\n if char == current_char:\r\n count += 1\r\n else:\r\n current_char = char\r\n if count != 0:\r\n counters.add(count)\r\n count = 1\r\n if count != 0:\r\n counters.add(count)\r\n print(\"YES\" if len(counters) == 1 else \"NO\")\r\n\r\n\r\nmain()\r\n", "def zebra(n, photo): \r\n\r\n colour=photo[0]\r\n width=False\r\n current_width=1\r\n \r\n for index in range(1, n):\r\n\r\n if photo[index]==colour:\r\n current_width+=1\r\n\r\n ## if current_width > width\r\n\r\n else:\r\n\r\n if width==False:\r\n width=current_width\r\n current_width=1\r\n colour=photo[index]\r\n\r\n else:\r\n if width!=current_width:\r\n return False\r\n\r\n current_width=1\r\n colour=photo[index]\r\n\r\n if current_width != width and width!=False:\r\n return False\r\n\r\n return True\r\n\r\nwhile True:\r\n N=int(input())\r\n\r\n PHOTO=input().split()\r\n\r\n if zebra(N, PHOTO):\r\n print('YES')\r\n\r\n else:\r\n print('NO')\r\n\r\n break\r\n", "n = int(input())\r\nstripes = [int(x) for x in input().split()] + [-1]\r\nln = 1\r\nwhile ln < n and stripes[ln] == stripes[ln - 1]:\r\n ln += 1\r\ncur = ln\r\nflag = True\r\nfor i in range(ln, n + 1):\r\n if stripes[i] != stripes[i - 1]:\r\n if cur != ln:\r\n flag = False\r\n break\r\n cur = 0\r\n cur += 1\r\nif flag:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = int(input())\r\na = [int(i) for i in input().split()]\r\n\r\nd = 0\r\ni = 0\r\nok = True\r\nwhile i < n:\r\n if not ok:\r\n break\r\n j = i\r\n while j < n and a[j] == a[i]:\r\n j+=1\r\n if d==0: d = j-i\r\n else :\r\n if d != j-i:\r\n print(\"No\")\r\n ok = False\r\n i = j\r\nif ok:\r\n print(\"Yes\")", "n = int(input())\r\nl = input().split()\r\nwidth = 1\r\nzebra = 0\r\ni = 0\r\ncnt = set()\r\nwhile i < n:\r\n j = i\r\n while j < n and l[j] == l[i]:\r\n j += 1\r\n cnt.add(j - i)\r\n i = j\r\n\r\nif len(cnt) == 1:\r\n print('YES')\r\nelse:\r\n print('NO')", "arri = lambda: [int(s) for s in input().split()]\r\nn = int(input())\r\na = arri()\r\nlast = a[0]\r\nfixed = -1\r\nl = 0\r\nf = True\r\nfor i in a:\r\n if last == i:\r\n l += 1\r\n else:\r\n if fixed == -1:\r\n fixed = l\r\n elif l != fixed:\r\n f = False\r\n break\r\n l = 1\r\n last = i\r\n #print(l, i, fixed, f)\r\nif l != fixed and fixed != -1:\r\n f = False\r\nprint(\"Yes\" if f else \"No\")", "n=input()\r\nn=int(n);\r\na = list(map(int, input().split()))\r\npre=-1;\r\ncnt=-1;\r\nq=-1;\r\nflag=0;\r\nscnt=0\r\ncnt1=0;\r\ncnt0=0;\r\nfor i in a:\r\n\tif i==0:\r\n\t\tcnt0+=1\r\n\telse:\r\n\t\tcnt1+=1\r\n\tif i==pre:\r\n\t\tq=q+1\r\n\telse:\r\n\t\tif cnt==-1:\r\n\t\t\tcnt=q\r\n\t\telse:\r\n\t\t\tif(cnt!=q):\r\n\t\t\t\tflag=1\r\n\t\t\t\tbreak\r\n\t\tpre=i\r\n\t\tq=1\r\n\tscnt+=1\r\n\tif scnt==n:\r\n\t\tif(cnt!=q):\r\n\t\t\tflag=1\r\ns=1\r\nif cnt0==n or cnt1==n:\r\n\tprint(\"YES\")\r\n\ts=0\t\t\r\n\r\nif flag==1 and s==1:\r\n\tprint(\"NO\")\r\nelif flag==0 and s==1:\r\n\tprint(\"YES\")\r\n\t\t", "\r\nz = input()\r\nc = list(map(int, input().split()))\r\nif len(set(c))!=1:\r\n\tif c[0]==0:\r\n\t\tt= 1\r\n\telse:\r\n\t\tt =0\r\n\td=c.index(t)\r\n\ts = list()\r\n\tt = not t\r\n\tfor i in range(0,len(c),d):\r\n\t\ts+=[int(t)]*d\r\n\t\tt = not t\r\n\tif s == c:\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")", "n = int(input())\r\ndigits = list(map(int, input().split()))\r\n\r\nlength = 0\r\nxd = True\r\nfor i in range(len(digits)):\r\n if digits[i] == digits[0]:\r\n length += 1\r\n else:\r\n break\r\nelse:\r\n print(\"YES\")\r\n xd = False\r\n\r\nif xd:\r\n if n % length != 0:\r\n print(\"NO\")\r\n else:\r\n d = digits[length]\r\n for i in range(length, n, length):\r\n if digits[i: i+length] != [d]*length:\r\n print(\"NO\")\r\n break\r\n\r\n d = 1 - d\r\n else:\r\n print(\"YES\")", "n = int(input())\r\nx = list(map(int, input().split()))\r\nd = None\r\ns = 1\r\nc = x[0]\r\nfor i in range(1, n):\r\n if x[i] == c:\r\n s += 1\r\n else:\r\n if d is None:\r\n d = s\r\n else:\r\n if (s != d):\r\n print(\"NO\")\r\n break\r\n s = 1\r\n c = x[i]\r\nelse:\r\n if (d is None) or (s == d):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "N=int(input())\r\narr=list(map(int, input().split(' ')[:N]))\r\ni = 0\r\ncomp = 0\r\nwhile i < N and arr[i] == arr[0]:\r\n comp += 1\r\n i += 1\r\nflag = True\r\nwhile i < N:\r\n c2 = 0\r\n check = arr[i]\r\n while i < N and arr[i] == check:\r\n i += 1\r\n c2 += 1\r\n if comp != c2:\r\n flag = False\r\nif flag == True:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = int(input())\r\nx = list(map(int, input().split()))\r\nlastc = x[0];\r\nlast = 1;\r\nfirst = False;\r\ncount = 0;\r\nfor i in range(1,n):\r\n\tif lastc != x[i]:\r\n\t\tif not first:\r\n\t\t\tcount = last\r\n\t\t\tfirst = True\r\n\t\telse:\r\n\t\t\tif last != count:\r\n\t\t\t\tbreak\r\n\t\tlast = 0;\r\n\t\tlastc = x[i]\r\n\tlast+=1\r\nif last != count and count != 0:\r\n\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")", "n=int(input())\r\na=list(map(int,input().split()))\r\ni=0\r\nwhile a[i] == a[0]:\r\n \r\n i+=1\r\n if i==n:\r\n break\r\n\r\nb=[]\r\nb.append([a[0] for i in range(0,i)])\r\nb.append([(a[0] +1) % 2 for i in range(0,i)])\r\nc=[]\r\nfor i in range(n//i):\r\n c += b[i % 2]\r\nif c == a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = int(input())\r\nln = 0\r\nstart = 1\r\nlast = -1\r\ncheck = 1\r\nx = list(map(int, input().split()))\r\nfor i in range(n):\r\n num = x[i]\r\n if num != last:\r\n if ln == 0:\r\n ln = i + 1 - start\r\n else:\r\n if i + 1 - start != ln:\r\n check = 0\r\n start = i + 1\r\n last = num\r\nif ln != 0 and n + 1 - start != ln:\r\n check = 0\r\nif check == 0:\r\n print('NO')\r\nelse:\r\n print('YES')", "n = int(input())\r\n\r\nlst = [int(i) for i in input().split()]\r\n\r\ns = set()\r\n\r\nprev, n = lst[0], 1\r\n\r\nfor i in lst[1:]:\r\n if i == prev:\r\n n += 1\r\n else:\r\n s.add(n)\r\n n = 1\r\n prev = i\r\n\r\ns.add(n)\r\n\r\nif len(s) == 1:\r\n print('YES')\r\nelse:\r\n print('NO')", "# LUOGU_RID: 105665598\nn=int(input())\r\na=input()\r\na=a.split()\r\nx=1\r\nfor i in range(1,n):\r\n if a[i]!=a[i-1]:\r\n break\r\n else:\r\n x=x+1\r\nif n%x!=0:\r\n print('NO')\r\nelse:\r\n q=0\r\n for i in range(0,n,x):\r\n for j in range(x-1):\r\n if a[i+j]!=a[i+j+1]:\r\n q=1\r\n if i+x<n:\r\n if a[i]==a[i+x]:\r\n q=1\r\n if q==0:\r\n print('YES')\r\n else:\r\n print('NO')", "n = int(input())\r\narr = list(map(int, input().split()))\r\n\r\np=arr[0]\r\nz=0\r\nzz=0\r\nans=0\r\nfor i in range(n):\r\n if arr[i]==p:\r\n z=z+1\r\n else:\r\n break\r\nfor i in range(n):\r\n if arr[i]==p:\r\n zz=zz+1\r\n if zz>z:\r\n ans=1\r\n break\r\n elif (arr[i]!=p and zz==z):\r\n p=arr[i]\r\n zz=1\r\n elif (arr[i]!=p and zz!=z):\r\n \r\n ans=1\r\n break\r\n\r\nif ans==0 and zz<z:\r\n ans=1\r\nif ans==0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "#\r\n#\t$$$$$$$\\ $$\\ $$$$$$$\\\r\n#\t$$ __$$\\ \\__| $$ __$$\\\r\n#\t$$ | $$ | $$$$$$\\ $$$$$$\\ $$\\ $$$$$$$\\ $$ | $$ | $$$$$$\\ $$$$$$\\ $$$$$$$\\ $$$$$$\\\r\n#\t$$$$$$$\\ |$$ __$$\\ $$ __$$\\ $$ |$$ _____|$$$$$$$\\ | \\____$$\\ $$ __$$\\ $$ _____|\\____$$\\\r\n#\t$$ __$$\\ $$ / $$ |$$ | \\__|$$ |\\$$$$$$\\ $$ __$$\\ $$$$$$$ |$$ | \\__|$$ / $$$$$$$ |\r\n#\t$$ | $$ |$$ | $$ |$$ | $$ | \\____$$\\ $$ | $$ |$$ __$$ |$$ | $$ | $$ __$$ |\r\n#\t$$$$$$$ |\\$$$$$$ |$$ | $$ |$$$$$$$ |$$$$$$$ |\\$$$$$$$ |$$ | \\$$$$$$$\\\\$$$$$$$ |\r\n#\t\\_______/ \\______/ \\__| \\__|\\_______/ \\_______/ \\_______|\\__| \\_______|\\_______|\r\n#\r\n\r\nsol = set()\r\n\r\nn = int(input())\r\nv = [int(x) for x in input().split(' ')]\r\n\r\ncurr = v[0]\r\ncnt = 0\r\nfor i in range(n):\r\n if v[i] == curr:\r\n cnt += 1\r\n continue\r\n else:\r\n if curr == 0:\r\n curr = 1\r\n else:\r\n curr = 0\r\n\r\n sol.add(cnt)\r\n cnt = 1\r\nsol.add(cnt)\r\nif len(sol) == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = int(input())\r\narr = list(map(int, input().split()))\r\ni = 0\r\nlast = 0\r\nnow = 0\r\nln = -1\r\nflag = 0\r\nfor i in range(len(arr)):\r\n if arr[i] == arr[last]:\r\n now += 1\r\n else:\r\n if not (ln == -1 or ln == now):\r\n flag = 1\r\n break\r\n elif ln == -1:\r\n ln = now\r\n last = i\r\n now = 1\r\n else:\r\n last = i\r\n now = 1\r\n\r\n\r\nif not flag and (ln == -1 or ln == now):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=(int)(input())\r\na = [int(i) for i in input().split()]\r\nS=set()\r\np=1\r\nfor i in range(1,n):\r\n if a[i]!=a[i-1]: \r\n S.add(p)\r\n p=0\r\n p=p+1\r\nS.add(p)\r\nif len(S)!=1:\r\n print('NO\\n')\r\nelse:\r\n print('YES\\n')", "n = int(input())\r\narr = [int(i) for i in input().split(' ')]\r\nt = arr[0]\r\ntl = 1\r\nsl = -1\r\nfor i in range(1,len(arr)):\r\n if (arr[i]==arr[i-1]):\r\n tl+=1\r\n else:\r\n if (sl==-1):\r\n sl = tl\r\n tl = 1\r\n else:\r\n if (sl!=tl):\r\n print(\"NO\")\r\n exit()\r\n else:\r\n tl = 1\r\n \r\n\r\nif sl!=-1 and tl != sl:\r\n print (\"NO\")\r\nelse:\r\n print (\"YES\")\r\n", "n = int(input())\r\na = list(map(int,input().split()))\r\nl = 0\r\nr = 0\r\nw = -1\r\nwhile l < n:\r\n\twhile r < n and a[l] == a[r]:\r\n\t\tr += 1\r\n\tw = r - l\r\n\tbreak\r\nl = 0\r\nr = 0\r\nno = False\r\nwhile l < n:\r\n\twhile r < n and a[l] == a[r]:\r\n\t\tr += 1\r\n\tif r - l != w:\r\n\t\tno = True\r\n\t\tbreak\r\n\tl = r\r\n \r\nif no:\r\n\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")", "n = int(input())\r\n\r\nstr = input()\r\narray = str.split(' ')\r\n\r\ni = 0\r\nfirst_bit = int(array[i])\r\ni += 1\r\n\r\nfirst_len = 1\r\n\r\ncurrent_bit = 0\r\n\r\nwhile(i < n):\r\n current_bit = int(array[i])\r\n if(current_bit == first_bit):\r\n first_len += 1\r\n i += 1\r\n else:\r\n break\r\n\r\nfirst_bit = current_bit\r\n\r\nif i == n:\r\n print(\"YES\")\r\n exit(0)\r\n\r\ncurrent_len = 0\r\n\r\nwhile(i < n):\r\n current_bit = int(array[i])\r\n i += 1\r\n if(current_bit == first_bit):\r\n current_len += 1\r\n else:\r\n if(current_len != first_len):\r\n print(\"NO\")\r\n exit(0)\r\n current_len = 1\r\n first_bit = current_bit\r\n\r\nif(current_len != first_len):\r\n print(\"NO\")\r\n exit(0)\r\nprint(\"YES\")", "n=int(input())\r\nl=[int(i) for i in input().split()]\r\n#0->white 1->black \r\ngrps=[]\r\ni=0 \r\nwhile i<n:\r\n if l[i]==0:\r\n c=0 \r\n while i<n and l[i]==0:\r\n c+=1 \r\n i+=1 \r\n grps.append([0,c])\r\n else:\r\n c=0 \r\n while i<n and l[i]==1:\r\n c+=1 \r\n i+=1 \r\n grps.append([1,c])\r\nf=0 \r\nif l.count(1)==n or l.count(0)==n:\r\n print('YES')\r\n exit()\r\ng=[grps[i][1] for i in range(len(grps))]\r\nif len(set(g))==1:\r\n print('YES')\r\n exit()\r\nprint('NO')", "n = int(input())\r\na = list(map(int, input().split()))\r\ncnt = 0\r\ncnt1 = 0\r\ncnt2 = 0\r\np = -1\r\nflag = True\r\nfor i in range(n):\r\n if a[i] == 1:\r\n if p != 1:\r\n if cnt != cnt1 and cnt != 0:\r\n flag = False\r\n cnt = cnt1\r\n p = 1\r\n cnt1 = 0\r\n cnt1 += 1\r\n if a[i] == 0:\r\n if p != 0:\r\n if cnt != cnt1 and cnt != 0:\r\n flag = False\r\n cnt = cnt1\r\n cnt1 = 0\r\n p = 0\r\n cnt1 += 1\r\nif cnt != cnt1 and cnt != 0:\r\n flag = False\r\nif flag:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = int(input())\r\ns = input()\r\np = []\r\n\r\n\r\nfor i in s:\r\n if (i == '0' or i == '1'):\r\n p.append(int(i))\r\n\r\nk = int(0)\r\ncur = p[0]\r\n\r\nwhile (k < n and p[k] == cur):\r\n k += 1\r\n\r\npos = int(0)\r\nnum = int(0)\r\nfl = bool(0)\r\n\r\nwhile (pos < n):\r\n if (p[pos] != cur):\r\n if (num != k):\r\n fl = 1\r\n cur = (cur + 1) % 2\r\n num = 1\r\n pos += 1\r\n else:\r\n num += 1\r\n pos += 1\r\nif (num != k):\r\n fl = 1\r\nif (fl):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n", "n=int(input())\r\nb=[]\r\n#for i in range(1,n):\r\nline=input()\r\nc=0\r\nd=int(line.split()[0])\r\ne=-1\r\nans=1\r\nfor a in line.split():\r\n if (int(a)==d):\r\n c+=1\r\n else:\r\n if (e!=-1)and(e!=c):\r\n ans=0\r\n e=c\r\n c=1\r\n d=1-d\r\nif (e!=-1)and(e!=c):\r\n ans=0\r\nif (ans==1):\r\n print('YES')\r\nelse:\r\n print('NO')", "n = int(input())\r\na = [0] * n\r\nb = [0] * 100001\r\na = input().split()\r\nfor i in range(n):\r\n a[i] = int(a[i])\r\nk = 0\r\nl = 0\r\nif(a[0] == 1):\r\n k = 1\r\nfor i in range(n):\r\n if(a[i] == k):\r\n l = l + 1\r\n else:\r\n k = a[i]\r\n b[l] = 1\r\n l = 1\r\nb[l] = 1\r\nk = 0\r\nfor i in range(100001):\r\n k += b[i]\r\nif(k == 1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = int(input())\r\nz = map(int, input().split(' '))\r\n\r\nacc = 0\r\ncols = 1\r\nprev = next(z)\r\n\r\nfor cur in z:\r\n if cur == prev:\r\n cols += 1\r\n else:\r\n acc = 1\r\n break\r\n prev = cur\r\n\r\nif acc:\r\n prev = cur\r\n for cur in z:\r\n if cur == prev:\r\n acc += 1\r\n else:\r\n if acc != cols:\r\n break\r\n acc = 1\r\n prev = cur\r\nelse:\r\n acc = cols\r\n\r\nif acc == cols:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "q = int(input())\r\ncnt1 = 0\r\ncnt2 = 0\r\nflag = 0\r\na = list(map(int, input().split()))\r\nl = a[0]\r\nfor i in range(q):\r\n if (a[i] == 0):\r\n if ((l != a[i]) and (cnt1 != 0) and (cnt2 != 0)):\r\n if (cnt1 != cnt2):\r\n flag = 1\r\n cnt1 = 0\r\n cnt1 += 1\r\n else:\r\n if ((l != a[i]) and (cnt2 != 0) and (cnt1 != 0)):\r\n if (cnt1 != cnt2):\r\n flag = 1\r\n cnt2 = 0\r\n cnt2 += 1\r\n l = a[i]\r\nif ((cnt1 != cnt2) and (cnt1 != 0) and (cnt2 != 0)):\r\n flag = 1\r\nif (flag == 1):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "n = input()\na = input().split()\ntemp = a[0]\ncnt = 0\nans = -1\nflag = 1\nfor x in a:\n\tif x == temp:\n\t\tcnt += 1\n\telse:\n\t\tif ans == -1:\n\t\t\tans = cnt\n\t\telse:\n\t\t\tif cnt != ans:\n\t\t\t\tflag = 0\n\t\t\t\tbreak\n\t\tcnt = 1\n\t\ttemp = x\nif ans == -1:\n\tans = cnt\nelse:\n\tif cnt != ans:\n\t\tflag = 0\nif flag == 1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "n=int(input())\r\na=[]\r\nd = input().split()\r\nfor i in range(n):\r\n c =int(d[i])\r\n a+=[c]\r\nif(n==1):\r\n print(\"YES\")\r\n exit(0)\r\nlen = 1\r\nfor i in range(n-1):\r\n if a[i]==a[i+1]:\r\n len+=1\r\n else:\r\n break\r\nif(len == n-1 and (a[n-1]==a[n-2])):\r\n len+=1\r\nif(n%len):\r\n print(\"NO\")\r\n exit(0) \r\nk = a[0]\r\nfor i in range(n):\r\n if(i>0 and i%len ==0):\r\n k=1-k\r\n if(a[i]!=k):\r\n print(\"NO\")\r\n exit(0) \r\nprint(\"YES\")", "n = int(input())\r\na = list(map(int, input().split()))\r\nlast = -1\r\ncnt = 0\r\nfx = -1\r\nkek = 0\r\nfor i in range(0, n):\r\n cur = a[i]\r\n if last == -1:\r\n cnt = cnt + 1\r\n elif last == cur:\r\n cnt = cnt + 1\r\n else:\r\n if fx == -1:\r\n fx = cnt\r\n elif fx != cnt:\r\n kek = -1\r\n cnt = 1\r\n last = cur\r\nif fx == -1:\r\n fx = cnt\r\nelif fx != cnt:\r\n kek = -1\r\nif kek == -1:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "n = int(input())\r\ns = input().split() \r\na = list(map(int, s))\r\n\r\ni = 0\r\ncount = 0\r\nif (a[0] == 0):\r\n while (i<len(a) and a[i] == 0):\r\n i+=1\r\n count+=1\r\nelse:\r\n while (i<len(s) and a[i] == 1):\r\n i+=1\r\n count+=1\r\n \r\nwhile (i<len(a)):\r\n t = 0\r\n symbol = a[i]\r\n while (i<len(a) and a[i] == symbol):\r\n t+=1\r\n i+=1\r\n if (t!=count):\r\n print(\"NO\")\r\n exit(0)\r\n \r\nprint(\"YES\")", "n = int(input())\r\nsa = input().split(' ')\r\na = []\r\nflag = 1\r\nb = []\r\nm = 2\r\nb.append(0)\r\nfor i in range(n):\r\n\ta.append(int(sa[i]))\r\nfor i in range(1,n):\r\n\tif a[i] != a[i - 1]:\r\n\t\tb.append(i)\r\n\t\tm = m + 1\r\nb.append(n)\r\nfor i in range(m - 1):\r\n\tif b[i + 1] - b[i] != b[1] - b[0]:\r\n\t\tflag = 0\r\n#print(b)\r\nif flag:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "n = int(input())\na = list(map(int, input().split()))\nv = list()\nlast, cnt = a[0], 0\nfor i in range(n):\n\tif a[i] == last:\n\t\tcnt += 1\n\telse:\n\t\tv.append(cnt)\n\t\tcnt = 1\n\t\tlast = a[i]\nv.append(cnt)\n\nf = True\nfor e in v:\n\tif e != v[0]:\n\t\tf = False\n\nif (f):\n\tprint('YES')\nelse:\n\tprint('NO')\n", "\nn = int(input())\na = input().split()\nfor j in range(n):\n a[j] = int(a[j])\ni = 1\nlast = a[0]\ncount = 1;\nwhile (i < n and last == a[i]):\n\ti+=1\n\tcount+=1\nif (i < n):\n\tlast = a[i]\n\tbuf = 1\n\ti += 1\n\tflag = 1\n\twhile (i < n):\n\t\tif (last == a[i]):\n\t\t\tbuf += 1\n\t\telse:\n\t\t\tif (count != buf):\n\t\t\t\tflag = 0\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tlast = a[i]\n\t\t\t\tbuf = 1\n\t\ti += 1\n\tif ((count != buf) or (flag == 0)):\n\t\tprint(\"NO\")\n\telse:\t\n\t\tprint(\"YES\")\nelse:\n\tprint(\"YES\")" ]
{"inputs": ["9\n0 0 0 1 1 1 0 0 0", "7\n0 0 0 1 1 1 1", "5\n1 1 1 1 1", "8\n1 1 1 0 0 0 1 1", "9\n1 1 0 1 1 0 1 1 0", "1\n0", "1\n1", "2\n0 0", "2\n0 1", "2\n1 0", "2\n1 1", "3\n1 1 0", "7\n0 0 0 1 1 1 0", "3\n0 1 1", "3\n0 0 1", "6\n0 0 1 0 1 0", "4\n0 1 1 0", "5\n0 1 1 0 0", "4\n0 1 0 0", "5\n1 1 1 0 0", "10\n0 0 1 1 0 0 0 1 1 1", "5\n0 0 0 0 1", "14\n0 0 0 1 1 1 1 0 0 0 0 1 1 1", "4\n1 0 1 0", "5\n1 0 0 0 1", "6\n1 1 1 0 1 1", "7\n1 1 1 1 1 0 1", "8\n1 1 0 0 1 1 0 0", "9\n0 1 1 0 0 0 1 1 1", "10\n0 0 0 0 0 1 1 1 1 1", "11\n0 1 0 1 0 1 0 0 0 1 0", "20\n1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0", "50\n0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 1 1 1 1", "100\n1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1", "3\n0 0 0", "3\n0 1 0", "3\n1 0 0", "3\n1 0 1", "3\n1 1 1"], "outputs": ["YES", "NO", "YES", "NO", "NO", "YES", "YES", "YES", "YES", "YES", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "NO", "NO", "NO", "YES", "NO", "YES", "NO", "YES", "NO", "YES", "YES", "YES", "NO", "YES", "YES"]}
UNKNOWN
PYTHON3
CODEFORCES
91
e3b1fb30d6b7e49c9f8d4e32d68da69a
Little Pony and Summer Sun Celebration
Twilight Sparkle learnt that the evil Nightmare Moon would return during the upcoming Summer Sun Celebration after one thousand years of imprisonment on the moon. She tried to warn her mentor Princess Celestia, but the princess ignored her and sent her to Ponyville to check on the preparations for the celebration. Twilight Sparkle wanted to track the path of Nightmare Moon. Unfortunately, she didn't know the exact path. What she knew is the parity of the number of times that each place Nightmare Moon visited. Can you help Twilight Sparkle to restore any path that is consistent with this information? Ponyville can be represented as an undirected graph (vertices are places, edges are roads between places) without self-loops and multi-edges. The path can start and end at any place (also it can be empty). Each place can be visited multiple times. The path must not visit more than 4*n* places. The first line contains two integers *n* and *m* (2<=≤<=*n*<=≤<=105; 0<=≤<=*m*<=≤<=105) — the number of places and the number of roads in Ponyville. Each of the following *m* lines contains two integers *u**i*,<=*v**i* (1<=≤<=*u**i*,<=*v**i*<=≤<=*n*; *u**i*<=≠<=*v**i*), these integers describe a road between places *u**i* and *v**i*. The next line contains *n* integers: *x*1,<=*x*2,<=...,<=*x**n* (0<=≤<=*x**i*<=≤<=1) — the parity of the number of times that each place must be visited. If *x**i*<==<=0, then the *i*-th place must be visited even number of times, else it must be visited odd number of times. Output the number of visited places *k* in the first line (0<=≤<=*k*<=≤<=4*n*). Then output *k* integers — the numbers of places in the order of path. If *x**i*<==<=0, then the *i*-th place must appear in the path even number of times, else *i*-th place must appear in the path odd number of times. Note, that given road system has no self-loops, therefore any two neighbouring places in the path must be distinct. If there is no required path, output -1. If there multiple possible paths, you can output any of them. Sample Input 3 2 1 2 2 3 1 1 1 5 7 1 2 1 3 1 4 1 5 3 4 3 5 4 5 0 1 0 1 0 2 0 0 0 Sample Output 3 1 2 3 10 2 1 3 4 5 4 5 4 3 1 0
[ "\"\"\"\n\nCodeforces Contest 259 Div 1 Problem C\n\n\n\nAuthor : chaotic_iak\n\nLanguage: Python 3.3.4\n\n\"\"\"\n\n\n\ndef main():\n\n\n\n # Read N and M from problem statement.\n\n n,m = read()\n\n\n\n # Set up an adjacency list for each vertex.\n\n edges = [[] for _ in range(n+1)]\n\n for i in range(m):\n\n a,b = read()\n\n edges[a].append(b)\n\n edges[b].append(a)\n\n\n\n # Read the parity array. Pad with 0 at the front to make it 1-based like in problem.\n\n parity = [0] + read()\n\n\n\n # Find odd vertex with minimum index.\n\n mn = 0\n\n while mn < n+1 and not parity[mn]: mn += 1\n\n\n\n # If none, then no need to output anything.\n\n if mn == n+1:\n\n print(0)\n\n return\n\n\n\n # Create the visited array, stack for DFS, and list to store the resulting path.\n\n visited = [0] * (n+1)\n\n dfs_stack = [mn]\n\n dfs_path = []\n\n\n\n # Call one step of DFS as long as the stack is not empty. (See below.)\n\n while dfs_stack: dfs(dfs_stack, dfs_path, visited, edges, parity)\n\n\n\n # If the root is odd, remove the last element of the path.\n\n if parity[mn]:\n\n dfs_path.pop()\n\n parity[mn] = 0\n\n\n\n # If there's still an odd vertex, then we have two separate components with\n\n # odd vertices; we failed.\n\n if sum(parity):\n\n print(-1)\n\n\n\n # Otherwise, print the resulting path.\n\n else:\n\n print(len(dfs_path))\n\n print(\" \".join(map(str, dfs_path)))\n\n\n\ndef dfs(dfs_stack, dfs_path, visited, edges, parity):\n\n\n\n # Take top element of the stack. This is positive if it's a downward edge (away\n\n # from root) and negative if it's an upward edge (to root), and its absolute\n\n # value is the index of the destination vertex.\n\n v = dfs_stack.pop()\n\n\n\n # If a downward edge:\n\n if v > 0:\n\n\n\n # If target vertex has been visited, no need to visit it again. Pop the\n\n # top item of the stack (which is a return edge for this vertex, but unused).\n\n if visited[v]:\n\n dfs_stack.pop()\n\n return\n\n\n\n # Set current vertex as visited and append it to path. Toggle the parity.\n\n visited[v] = 1\n\n dfs_path.append(v)\n\n parity[v] = 1 - parity[v]\n\n\n\n # Add a pair of downward/upward edges for each neighbor of this vertex.\n\n for i in edges[v]:\n\n dfs_stack.append(-v)\n\n dfs_stack.append(i)\n\n\n\n # If an upward edge:\n\n else:\n\n\n\n # Set v as absolute value. Take the child just visited, u, which is stored as\n\n # the last element of final path. Append the current vertex v to final path\n\n # and toggle the parity of v.\n\n v = -v\n\n u = dfs_path[-1]\n\n dfs_path.append(v)\n\n parity[v] = 1 - parity[v]\n\n\n\n # If u is odd, visit u and return back to v one more time. This toggles the\n\n # parity of u but not v.\n\n if parity[u]:\n\n dfs_path.append(u)\n\n dfs_path.append(v)\n\n parity[u] = 1 - parity[u]\n\n parity[v] = 1 - parity[v]\n\n\n\n # If u is even, we don't need to do anything.\n\n else:\n\n pass\n\n\n\n################################### NON-SOLUTION STUFF BELOW\n\n\n\ndef read(mode=2):\n\n # 0: String\n\n # 1: List of strings\n\n # 2: List of integers\n\n inputs = input().strip()\n\n if mode == 0: return inputs\n\n if mode == 1: return inputs.split()\n\n if mode == 2: return list(map(int, inputs.split()))\n\n\n\ndef read_str(): return read(0)\n\ndef read_int(): return read(2)[0]\n\n\n\ndef write(s=\"\\n\"):\n\n if isinstance(s, list): s = \" \".join(map(str, s))\n\n s = str(s)\n\n print(s, end=\"\")\n\n\n\nmain()\n\n\n\n# Made By Mostafa_Khaled", "\"\"\"\r\nCodeforces Contest 259 Div 1 Problem C\r\n\r\nAuthor : chaotic_iak\r\nLanguage: Python 3.3.4\r\n\"\"\"\r\n\r\ndef main():\r\n n,m = read()\r\n edges = [[] for _ in range(n+1)]\r\n for i in range(m):\r\n a,b = read()\r\n edges[a].append(b)\r\n edges[b].append(a)\r\n parity = [0] + read()\r\n mn = 0\r\n while mn < n+1 and not parity[mn]: mn += 1\r\n if mn == n+1:\r\n print(0)\r\n return\r\n visited = [0] * (n+1)\r\n dfs_stack = [mn]\r\n dfs_path = []\r\n while dfs_stack: dfs(dfs_stack, dfs_path, visited, edges, parity)\r\n if parity[mn]:\r\n dfs_path.pop()\r\n parity[mn] = 0\r\n if sum(parity):\r\n print(-1)\r\n else:\r\n print(len(dfs_path))\r\n print(\" \".join(map(str, dfs_path)))\r\n\r\ndef dfs(dfs_stack, dfs_path, visited, edges, parity):\r\n v = dfs_stack.pop()\r\n if v > 0:\r\n if visited[v]:\r\n dfs_stack.pop()\r\n return\r\n visited[v] = 1\r\n dfs_path.append(v)\r\n parity[v] = 1 - parity[v]\r\n for i in edges[v]:\r\n dfs_stack.append(-v)\r\n dfs_stack.append(i)\r\n else:\r\n v = -v\r\n u = dfs_path[-1]\r\n dfs_path.append(v)\r\n if parity[u]:\r\n dfs_path.append(u)\r\n dfs_path.append(v)\r\n parity[u] = 1 - parity[u]\r\n else:\r\n parity[v] = 1 - parity[v]\r\n\r\n################################### NON-SOLUTION STUFF BELOW\r\n\r\ndef read(mode=2):\r\n # 0: String\r\n # 1: List of strings\r\n # 2: List of integers\r\n inputs = input().strip()\r\n if mode == 0: return inputs\r\n if mode == 1: return inputs.split()\r\n if mode == 2: return list(map(int, inputs.split()))\r\n\r\ndef read_str(): return read(0)\r\ndef read_int(): return read(2)[0]\r\n\r\ndef write(s=\"\\n\"):\r\n if isinstance(s, list): s = \" \".join(map(str, s))\r\n s = str(s)\r\n print(s, end=\"\")\r\n\r\nmain()" ]
{"inputs": ["3 2\n1 2\n2 3\n1 1 1", "5 7\n1 2\n1 3\n1 4\n1 5\n3 4\n3 5\n4 5\n0 1 0 1 0", "2 0\n0 0", "10 10\n2 1\n2 3\n4 2\n4 5\n3 6\n5 7\n8 4\n4 9\n5 10\n4 7\n0 0 1 0 1 1 1 0 1 0", "10 10\n2 1\n3 1\n4 1\n3 5\n6 2\n5 7\n1 8\n5 9\n10 5\n7 2\n1 0 0 0 1 1 1 0 0 1", "10 10\n1 2\n1 3\n3 4\n3 5\n6 1\n7 6\n8 7\n9 7\n10 1\n2 4\n0 1 0 1 1 0 0 1 1 0", "10 10\n1 2\n2 3\n3 4\n2 5\n3 6\n7 4\n8 7\n9 1\n7 10\n5 3\n1 0 0 1 1 0 0 1 1 1", "10 10\n1 2\n3 1\n4 2\n2 5\n6 2\n7 4\n4 8\n2 9\n10 4\n5 10\n0 0 1 0 1 1 1 1 0 0", "10 10\n1 2\n2 3\n4 1\n2 5\n3 6\n7 6\n8 1\n9 4\n1 10\n7 1\n0 1 1 0 1 1 1 1 1 1", "10 10\n1 2\n3 1\n4 3\n1 5\n6 5\n7 4\n8 7\n9 5\n10 4\n6 10\n1 0 0 1 1 0 0 1 0 0", "2 0\n0 1", "2 0\n1 0", "2 0\n1 1", "4 1\n3 4\n0 0 1 1", "4 2\n1 3\n2 4\n0 1 0 1", "3 1\n2 3\n0 1 1", "4 2\n1 2\n3 4\n0 0 0 1"], "outputs": ["3\n1 2 3", "10\n2 1 3 4 5 4 5 4 3 1 ", "0", "29\n2 1 2 1 2 3 6 3 2 3 2 4 5 7 5 10 5 10 5 4 5 4 8 4 8 4 9 4 2 ", "27\n2 1 3 5 7 5 9 5 9 5 10 5 3 1 4 1 4 1 8 1 8 1 2 1 2 6 2 ", "27\n1 2 4 3 5 3 4 2 4 2 1 6 7 8 7 9 7 6 7 6 1 6 1 10 1 10 1 ", "26\n2 3 4 7 8 7 10 7 4 7 4 3 6 3 6 3 5 3 2 3 2 1 2 1 9 1 ", "23\n1 2 4 7 4 8 4 10 5 10 4 2 6 2 9 2 9 2 1 2 1 3 1 ", "20\n2 3 6 7 6 3 6 3 2 5 2 1 4 9 4 1 8 1 10 1 ", "22\n2 1 2 1 3 4 7 8 7 4 10 6 5 9 5 9 5 6 10 4 3 1 ", "1\n2 ", "1\n1 ", "-1", "2\n4 3 ", "2\n4 2 ", "2\n3 2 ", "3\n3 4 3 "]}
UNKNOWN
PYTHON3
CODEFORCES
2
e3bcaa6255789a6043a882a7aa399d52
Vladik and flights
Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is to find the cheapest way to get to the olympiad. Vladik knows *n* airports. All the airports are located on a straight line. Each airport has unique id from 1 to *n*, Vladik's house is situated next to the airport with id *a*, and the place of the olympiad is situated next to the airport with id *b*. It is possible that Vladik's house and the place of the olympiad are located near the same airport. To get to the olympiad, Vladik can fly between any pair of airports any number of times, but he has to start his route at the airport *a* and finish it at the airport *b*. Each airport belongs to one of two companies. The cost of flight from the airport *i* to the airport *j* is zero if both airports belong to the same company, and |*i*<=-<=*j*| if they belong to different companies. Print the minimum cost Vladik has to pay to get to the olympiad. The first line contains three integers *n*, *a*, and *b* (1<=≤<=*n*<=≤<=105, 1<=≤<=*a*,<=*b*<=≤<=*n*) — the number of airports, the id of the airport from which Vladik starts his route and the id of the airport which he has to reach. The second line contains a string with length *n*, which consists only of characters 0 and 1. If the *i*-th character in this string is 0, then *i*-th airport belongs to first company, otherwise it belongs to the second. Print single integer — the minimum cost Vladik has to pay to get to the olympiad. Sample Input 4 1 4 1010 5 5 2 10110 Sample Output 10
[ "n,a,b = map(int, input().split())\r\n\r\nstring = input()\r\n\r\nif string[a - 1] == string[b - 1]:\r\n\tprint(0)\r\nelse:\r\n\tprint(1)\r\n", "def min_cost(a,b,l):\r\n return (l[a-1]!=l[b-1])+0\r\n\r\n\r\nn,a,b=map(int,input().split())\r\nl=input()\r\nprint(min_cost(a,b,l))\r\n", "n, a, b = map(int, input().split())\r\ns = list(input())\r\n\r\nif s[a - 1] == s[b - 1]:\r\n print(0)\r\nelse:\r\n print(1)", "(n, a, b) = map(int, input().split())\r\nt = input()\r\na -= 1\r\nb -= 1\r\nif t[a] == t[b]:\r\n print(0)\r\nelse:\r\n print(1)", "a,b,c=[int(x) for x in input().split()]\ns=input()\nif s[b-1] is s[c-1]:\n print(0)\nelse:\n print(1)\n", "n,a,b=input().split()\r\nn=int(n)\r\na=int(a)\r\nb=int(b)\r\nairport=input()\r\nif airport[a-1]==airport[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "n,a,b=list(map(int,input().split()))\r\ns=input()\r\nprint(0 if s[a-1]==s[b-1] else 1)\r\n ", "n,a,b = [int(x) for x in input().split()]\ns = input()\nif s[a-1] == s[b-1]:\n print(\"0\")\nelse:\n print(\"1\")\n \t\t \t\t \t\t\t\t\t \t\t\t\t \t \t \t \t\t", "airport_num, airport_start, airport_end = map(int, input().split())\r\nairport_possession = input()\r\n\r\ncompany_airport_start = 0\r\ncompany_airport_end = 0\r\n\r\nfor i in range(1, airport_num + 1):\r\n if i == airport_start:\r\n company_airport_start = int(airport_possession[i-1])\r\n if i == airport_end:\r\n company_airport_end = int(airport_possession[i-1])\r\n\r\nif company_airport_start != company_airport_end:\r\n print(1)\r\nelse:\r\n print(0)", "n, a, b=map(int, input().split())\r\ninp=input()\r\nif int(inp[a-1])-int(inp[b-1])<0:\r\n print(int(inp[b-1])-int(inp[a-1]))\r\nelse:\r\n print(int(inp[a-1])-int(inp[b-1]))", "n, a, b = map(int, input().split())\ncad = input()\nif cad[a-1] == cad[b-1]:\n print(0)\nelse:\n print(1)\n \t\t\t \t \t\t \t\t\t \t\t\t\t\t\t \t \t \t\t", "n,a,b=map(int,input().split())\r\ns=input()\r\na=a-1\r\nb=b-1\r\nif(s[a]==s[b]):\r\n print(0)\r\nelse:\r\n print(1)\r\n \r\n", "def main():\r\n n, a, b = map(int, input().split())\r\n s = input()\r\n\r\n if s[a - 1] != s[b - 1]:\r\n print(1)\r\n else:\r\n print(0)\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n,a,b=map(int,input().split())\r\ns=input()\r\nprint(int(s[a-1]) ^ int(s[b-1]))\r\n", "import sys\r\nimport math\r\nimport collections\r\nimport heapq\r\nimport decimal\r\ninput=sys.stdin.readline\r\nn,a,b=(int(i) for i in input().split())\r\nl=list(input())\r\nif(l[a-1]==l[b-1]):\r\n print(0)\r\nelse:\r\n print(1)", "n, a, b = [int(x) for x in input().split()]\r\na -= 1\r\nb -= 1\r\ns = list(input())\r\nif s[a] == s[b]:\r\n print(0)\r\nelse:\r\n print(1)", "(a, b, _), owners = sorted(map(int, input().split())), '_' + input()\r\n\r\nprint(int(owners[a] != owners[b]))", "n,a,b=map(int,input().split())\r\ns=input()\r\nif a==b:\r\n print(0)\r\nelse:\r\n if s[a-1]==s[b-1]:\r\n print(0)\r\n else:\r\n print(1)", "n, a, b = list(map(int, input().split()))\r\narr = input()\r\n\r\n\r\nif a == b or arr[a-1] == arr[b-1]:\r\n\tprint(0)\r\nelse:\r\n\tprint(1)\r\n", "n,a,b=map(int,input().split())\r\nairport=input()\r\nif airport[a-1]==airport[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "def get_input(pregunta):\r\n return list(map(int, input(pregunta).split(\" \")))\r\nline_1 = get_input(\"\") # PilasPilas\r\nline_2 = input()# Gusanos por pila\r\n\r\n#line_1 = [4,1,4]\r\n#line_2 = \"1010\"\r\n\r\naeropuertos = line_1[0]\r\nidA = line_1[1] - 1\r\nidB = line_1[2] - 1\r\n\r\nif line_2[idA] == line_2[idB]:\r\n print(0)\r\n\r\nelse:\r\n print(1)", "#!/usr/bin/env python3\r\n# -*- coding: utf-8 -*-\r\nn,a,b=map(int,input().split())\r\nd=[int(x) for x in input()]\r\nif d[a-1]==d[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "a, b, c = map(int, input().split())\r\nst = [int(x) for x in input()]\r\nb -= 1\r\nc -= 1\r\nres = 0\r\nif st[b] != st[c]:\r\n res = 1\r\nprint(res)", "n,a,b = map(int,input().split())\r\ns = input()\r\n# for i in range(len(n)):\r\nprint(abs((ord(s[a-1])-ord(s[b-1]))))", "n, a, b = map(int, input().split())\ns = input()\nA = [int(c) for c in s]\ndef solve(n,a,b,A):\n #print(a,b,A)\n if a == b:\n return 0\n if A[a-1] == A[b-1]:\n return 0\n return 1\n\nx = solve(n,a,b,A)\nprint(x)", "# https://codeforces.com/contest/743/problem/A\n\n# Problem\n# Big O:\n# Time complexity: O(n)\n# Space complexity: O(n)\n\n# Problem\n\n\ndef minimum_cost_between_airports(vladiks_house, olympiad, airports):\n return 1 if airports[vladiks_house] != airports[olympiad] else 0\n\n\n# Read input\nfirst_line = input().split()\n_, vladiks_house, olympiad = (int(i) for i in first_line)\n\nairports = list(input())\nprint(minimum_cost_between_airports(vladiks_house - 1, olympiad - 1, airports))\n", "\r\nimport math\r\nimport sys\r\nfrom collections import deque,OrderedDict,defaultdict\r\nimport heapq,re\r\nfrom collections import Counter\r\ndef inp(): return sys.stdin.readline().rstrip()\r\ndef mpp(): return map(int,inp().split())\r\ndef lis(): return list(mpp())\r\ndef yn(n):\r\n if n:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\ndef cd(s):\r\n return ord(s)-ord('a')+1\r\ndef fn(s,n,a,b):\r\n if s[a-1]==s[b-1]:\r\n return 0\r\n else:\r\n return 1\r\n\r\ndef main():\r\n n,a,b=mpp()\r\n s=inp()\r\n print(fn(s,n,a,b))\r\n\r\nif __name__==\"__main__\":\r\n main()", "n,ini,fim = [int(i) for i in input().split()]\r\nmapa = input()\r\n\r\nini-=1\r\nfim-=1\r\n\r\nif(mapa[ini] == mapa[fim]):\r\n print(0)\r\nelse:\r\n print(1)\r\n\r\n \r\n", "n, a, b = list(map(int, input().rstrip().split()))\ns = input()\nif s[a - 1] == s[b - 1]:\n print(0)\nelse:\n print(1)", "\nn,a,b = list(map(int,input().split()))\ns = input()\nif s[a-1] == s[b-1]:\n print(\"0\")\nelse:\n print(\"1\")", "n, a, b = map(int, input().split())\r\ns = input()\r\nprint(abs(int(s[a-1])-int(s[b-1])))\r\n", "\n\n# def firstThing(airport, index):\n# \tdelta_right = 1\n# \tfound_right = False\n# \tdelta_left = 1\n# \tfound_left = False\n\n# \twhile(index + delta_right < len(airport)):\n# \t\tif airport[index + delta_right] != airport[index]:\n# \t\t\tfound_right = True\n# \t\t\tbreak\n# \t\tdelta_right+=1\n\n# \tif not found_right:\n# \t\tdelta_right = 9999999999\n\n# \twhile(index - delta_left >= 0):\n# \t\tif airport[index - delta_left] != airport[index]:\n# \t\t\tfound_left = True\n# \t\t\tbreak\n# \t\tdelta_left+=1\n\n# \tif not found_left:\n# \t\tdelta_left = 9999999999\n\n# \treturn min(delta_right, delta_left)\n\n# def analyze(airport, start, end):\n# \tif airport[start] == airport[end]:\n# \t\treturn 0\n# \telse:\n# \t\treturn min(firstThing(airport, start), firstThing(airport, end))\n\nnums = [int(x) for x in input().split(\" \")]\nsize = nums[0]\nstart = nums[1]-1\nend = nums[2]-1\nairport = input()\n\n# print(analyze(input(), start, end))\n\nresult = 0 if airport[start] == airport[end] else 1\nprint(result)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "n, a, b = [int(i) for i in input().split()]\ns = input()\n\na, b = min(a, b), max(a, b)\ncompanya = s[a - 1]\ncompanyb = s[b - 1]\nif companya == companyb:\n print(0)\nelse:\n print(1)", "_, i, j = list(map(int, input().split()))\nairports = input()\nif airports[i-1] == airports[j-1]:\n print(0)\nelse:\n print(1)\n", "def vladik(s, a, b):\r\n if s[a - 1] == s[b - 1]:\r\n return 0\r\n return 1\r\n\r\n\r\nn, c, d = [int(i) for i in input().split()]\r\nt = input()\r\nprint(vladik(t, c, d))\r\n", "X = list(map(int, input().split()))\r\nS = input()\r\nprint(0 if S[X[1] - 1] == S[X[2] - 1] else 1)\r\n\r\n# Come together for getting better !!!!\r\n", "n, a, b = map(int, input().split())\r\ns = input()\r\n\r\na -= 1\r\nb -= 1\r\n\r\nprint((ord(s[a]) - ord('0')) ^ (ord(s[b]) - ord('0')))", "n, a, b = map(int, input().split())\r\na -= 1\r\nb -= 1\r\nports = list(input())\r\n\r\nif a == b or ports[a] == ports[b]:\r\n print(0)\r\nelse:\r\n print(1)\r\n", "ins = input().split()\r\na = int(ins[1]) - 1\r\nb = int(ins[2]) - 1\r\nins = input()\r\nif ins[a] == ins[b]:\r\n print(0)\r\nelse:\r\n print(1)\r\n", "n,a,b=map(int,input().split())\r\nx=input()\r\nprint(int(not(x[a-1]==x[b-1])))", "a = list(map(int, input().split()))\nb = input()\nif b[a[1] - 1] == b[a[2] - 1]:\n\tprint(0)\nelse:\n\tprint(1)", "# LUOGU_RID: 101648055\nn, a, b = map(int, input().split())\r\ns = input()\r\na -= 1\r\nb -= 1\r\nif a > b:\r\n a, b = b, a\r\nif s[a] == s[b]:\r\n exit(print(0))\r\nprint(1)", "inp1=[int(i) for i in input().split(\" \")]\r\ninp2=[int(i) for i in input()]\r\nif inp2[inp1[1]-1]==inp2[inp1[2]-1]:\r\n print(0)\r\nelse:\r\n print(1)\r\n", "from sys import stdin\n\nN, A, B = map(int, stdin.readline().rstrip().split())\ncompanies = [x == '1' for x in stdin.readline().rstrip()]\nif companies[A - 1] == companies[B - 1]:\n print(0)\nelse:\n print(1)", "n,a,b=map(int,input().split())\r\nS=input()\r\nma1=1000000000\r\nma2=1000000000\r\nif a>b :\r\n c=a\r\n a=b\r\n b=c\r\ng=0\r\nfor i in range(a-1,b) :\r\n if S[i]==S[b-1] :\r\n ma1=abs(i-a+1+g)\r\n break\r\n else :\r\n if a-1!=i :\r\n g=g-1\r\ng=0\r\nfor i in range(a-1,-1,-1) :\r\n if S[i]==S[b-1] :\r\n ma1=min(ma1,abs(i-a+1)+g)\r\n break\r\n else :\r\n if i!=a-1 :\r\n g=g-1\r\ng=0 \r\nfor i in range(b-1,n) :\r\n if S[i]==S[a-1] :\r\n ma2=abs(i-b+1+g)\r\n break\r\n else :\r\n if i!=b-1 :\r\n g=g-1\r\ng=0\r\nfor i in range(b-1,-1,-1) :\r\n if S[i]==S[a-1] :\r\n ma2=min(ma2,abs(i-b+1)+g)\r\n break\r\n else :\r\n if i!=b-1 :\r\n g=g-1\r\nprint(min(ma1,ma2))\r\n \r\n \r\n \r\n\r\n \r\n", "n,a,b=map(int,input().split())\r\ns=input()\r\nif s[a-1]==s[b-1]:print(0)\r\nelse:print(1)\r\n", "n, a, b = map(int, input().split())\r\nstring = input()\r\nprint (int(string[a - 1]) ^ int(string[b - 1]))\r\n", "## Vi el tutorial, mucho más facil de lo que pensaba, ver los codigos anteriores\r\nn, a, b = map(int, input().split())\r\n\r\nars = input()\r\nairports = int(ars, 2)\r\nhome_airport = ars[a-1]\r\ndest_airport = ars[b-1]\r\n#Si los aeropuertos son iguales el viaje es gratis\r\nif home_airport == dest_airport:\r\n print(0)\r\n#Si no nos movemos a un aeropuerto adjacente, pagamos uno y viajamos gratis a la olimpiada\r\nelse:\r\n print(1)\r\n\r\n\r\n\r\n", "n,a,b = map(int,input().split())\r\nl = input()\r\nprint(int(l[a-1]!=l[b-1]))", "n,a,b=map(int,input().split())\r\ns=input().strip()\r\nans=0\r\nif(s[a-1]==s[b-1]):\r\n print(0)\r\nelse:\r\n print(1)", "n,a,b = [int(x) for x in input().split()]\r\ns = input()\r\na-=1\r\nb-=1\r\nif s[a] == s[b]:\r\n print(0)\r\nelse:\r\n print(1)", "n,a,b=map(int,input().split())\ns=input()\nif(s[a-1]==s[b-1]):\n\tprint (0)\nelse:\n\tprint(1)", "n, a, b = input().split()\r\nairports = input()\r\nif(airports[int(a)-1] != airports[int(b)-1]):\r\n\tprint(1)\r\nelse:\r\n\tprint(0)", "n,a,b=map(int, input().split())\r\ns=input()\r\nif s[a-1] == s[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "nab = input().split(\" \")\r\nn,a,b = [int(x) for x in nab]\r\na -= 1\r\nb -= 1\r\nairports = input()\r\nif airports[a] == airports[b]:\r\n print(0)\r\nelse:\r\n print(1)\r\n \r\n", "n,a,b=map(int,input().split())\r\nl=input()\r\nif l[a-1]==l[b-1]:\r\n print(\"0\")\r\nelse:\r\n print(abs(int(l[a-1])-int(l[b-1])))\r\n", "import sys\r\n\r\n#print(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])\r\n\r\n\r\n\r\nno_airport, start_airport, dest_airport = map(int, input().split()) \r\n\r\nairport_string = input()\r\n\r\nif airport_string[start_airport-1] == airport_string[dest_airport-1]:\r\n print(0)\r\nelse:\r\n print(1)", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn, a, b = map(int, input().split())\r\ns = input()[:-1]\r\na, b = sorted([a, b])\r\nx = s[a-1]\r\ny = s[b-1]\r\nif x == y:\r\n print(0)\r\nelse:\r\n print(1)", "n,a,b=map(int,input().split())\r\ns=input()\r\na-=1\r\nb-=1\r\nprint(0 if s[a]==s[b] else 1)", "n,a,b=input().split()\r\ns=input()\r\ns=list(s)\r\na=int(a)\r\nb=int(b)\r\nif a==b:\r\n print(0)\r\nelse:\r\n a-=1\r\n b-=1\r\n if s[a]==s[b]:\r\n print(0)\r\n else:\r\n print(1)\r\n", "n, a, b = map(int, input().split())\r\ncompany = input()\r\na -= 1\r\nb -= 1\r\nres = 0\r\nif company[a] != company[b]:\r\n res = 1\r\nprint(res)", "n,a,b=map(int,input().split())\r\n\r\ns=input()\r\n\r\nif (s[a-1]==\"0\" and s[b-1]==\"0\") or (s[a-1]==\"1\" and s[b-1]==\"1\"):\r\n print(0)\r\nelse:\r\n print(1)", "\r\nif __name__ == '__main__':\r\n\tn, a, b = map(int, input().split())\r\n\ts = input()\r\n\ta, b = a-1, b-1\r\n\tif s[a] == s[b]:\r\n\t\tprint(0)\r\n\telse:\r\n\t\tprint(1)\r\n", "num_ports, start, finish = [int(i) for i in input().split(' ')]\n\nall_airports = [int(i) for i in input()]\n\nif all_airports[start - 1] == all_airports[finish - 1]:\n print(0)\nelse:\n if len(set(all_airports)) == 1:\n print(0)\n else:\n print(1)", "n, a, b = map(int, input().split())\r\ncomp = list(input())\r\n\r\nif(comp[a-1] == comp[b-1]):\r\n\tprint(\"0\")\r\nelse:\r\n\tprint(\"1\")", "#ROUNIAAUDI\r\nint1,int2,int3=map(int,input().split())\r\ny=input()\r\nprint(\"1\" if y[int2-1]!=y[int3-1] else \"0\")\r\n", "n, a, b = map(int, input().split())\r\ns = input()\r\n\r\n# Если аэропорты a и b принадлежат одной компании, то ответ равен 0.\r\n# Иначе найдется два соседних аэропорта, принадлежащие разным компаниям,\r\n# рассмотрим их. Долетим бесплатно до одного из этих аэропортов,\r\n# перелетим заплатив 1 в другой и из него бесплатно в b.\r\n# А значит, в таком случае ответ равен 1.\r\na -= 1\r\nb -= 1\r\nprint(0 if s[a] == s[b] else 1)", "n,a,b=map(int,input().split())\nF=input()\nif F[a-1]==F[b-1]:print(0)\nelse:print(1)\n\n\n\n", "def min_cost(a,b,l):\r\n if l[a - 1] == l[b - 1]:\r\n return 0\r\n return 1\r\n\r\n\r\nn,a,b=map(int,input().split())\r\nl=input()\r\nprint(min_cost(a,b,l))\r\n", "inp = input()\r\nk = input()\r\nn ,a, b = inp.split(\" \")\r\n\r\n\r\nif k[int(a)-1] == k[int(b)-1]:\r\n print(\"0\")\r\nelse:\r\n print(\"1\")", "a,b,c=map(int,input().split())\r\nd=input()\r\nif d[b-1]!=d[c-1]:\r\n print(1)\r\nelse: print(0)", "n,a,b=map(int,input().split());s=input();print(0if s[a-1]==s[b-1]else 1)", "\r\ndef vla_air(n,a,b,s):\r\n\tx=s[a-1]\r\n\ty=s[b-1]\r\n\tif x==y:\r\n\t\treturn 0\r\n\tif a==b:\r\n\t\treturn 0\r\n\tif a>b or a<b:\r\n\t\treturn 1\r\n\r\n\r\nn,a,b=list(map(int,input().strip().split()))\r\ns=str(input())\r\nprint(vla_air(n,a,b,s))", "n, a , b = map(int, input().split())\r\ns=input()\r\nw=int(s[a-1])\r\nx=int(s[b-1])\r\nprint(abs(w-x))\r\n", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nn, a, b = map(int, input().split())\r\ns = [0] + list(input().rstrip())\r\nans = s[a] ^ s[b] \r\nprint(ans)", "a,b,c = [int(x) for x in input().split()]\nb-=1\nc-=1\nx = None\ns = input()\nif b == c:\n print(0)\nelse:\n for i,d in enumerate(s):\n if x is not None:\n if i== b or i == c:\n if x == d:\n print(0)\n else:\n print(1)\n break\n elif i == b or i == c:\n x = d\n \n", "s=input().split()\r\nn=int(s[0])\r\na=int(s[1])-1\r\nb=int(s[2])-1\r\ns=input()\r\nif s[a]==s[b]:\r\n\tprint(0)\r\nelse:\r\n\tprint(1)", "w=input().split()\r\nn,a,b=int(w[0]),int(w[1]),int(w[2])\r\nv=input()\r\nco=[]\r\nfor i in range(len(v)):\r\n co.append(int(v[i]))\r\ntc=co[a-1]\r\ndc=co[b-1]\r\nif(tc==dc):\r\n print(\"0\")\r\nelse:\r\n print(\"1\")", "_,a,b=map(int,input().split())\r\nc=input()\r\nprint(int(not(c[a-1]==c[b-1])))", "import math\r\nfrom decimal import *\r\nimport random\r\nmod = int(1e9)+7\r\n\r\nn,a,b = map(int, input().split())\r\narr = list(input())\r\nif(arr[a-1]==arr[b-1]):\r\n print(0)\r\nelse:\r\n print(1)\r\n", "n,a,b=map(int,input().split(' '))\r\nidentity=list(input())\r\nprint(abs(int(identity[b-1])-int(identity[a-1])))\r\n", "a,b,c=map(int,input().split())\r\ns=input()\r\nif s[b-1]==s[c-1]:\r\n print(0)\r\nelse:\r\n print(1)", "n,a,b = map(int,input().split())\r\na-=1\r\nb-=1\r\ns = list(map(int,list(input())))\r\n#print(s)\r\nif s[a]==s[b]:\r\n print(0)\r\nelse:\r\n print(1)", "l = list(map(int, input().split()))\r\nx = list(input())\r\nif x[l[1]-1] == x[l[2]-1]:\r\n print(0)\r\nelse:\r\n print(1)\r\n", "from sys import stdin\r\n\r\nrd = stdin.readline\r\n\r\nn, a, b = map(int, rd().split())\r\ns = rd().strip()\r\n\r\na -= 1\r\nb -= 1\r\n\r\nif s[a] == s[b]: print(0)\r\nelse: print(1) \r\n", "n,a,b=map(int,input().split())\r\narr=input()\r\nv=0\r\nif arr[a-1]==arr[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "n, a, b = map(int, input().split())\r\ns = input()\r\na -= 1\r\nb -= 1\r\nif a>b:\r\n s = s[::-1]\r\n a = n-a-1\r\n b = n-b-1\r\nif s[a] == s[b]:\r\n print(\"0\")\r\nelse:\r\n count = 0\r\n for i in range(b, a-1, -1):\r\n if s[i]!=s[a]:\r\n count += 1\r\n break\r\n print(count)\r\n", "n,x,y=map(int,input().split())\r\nl=list(input())\r\nprint(abs(int(l[y-1])-int(l[x-1])))", "data = input()\r\ncompanys = input()\r\ndataSplit = data.split()\r\na = dataSplit[1]\r\nb = dataSplit[2]\r\ncantAirport = dataSplit[0]\r\ncompanyA = companys[int(a)-1]\r\ncompanyB = companys[int(b)-1]\r\n\r\nif (companyA == companyB):\r\n print('0')\r\nelse:\r\n print('1')\r\n", "n , a , b = map(int, input().split())\r\n\r\ns = ' ' + input()\r\n\r\nprint( int( s[ a ] != s[ b ] ) )", "n,a,b=map(int,input().split())\r\nx=input()\r\nif x[a-1]==x[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "n,a,b=map(int,input().split())\r\nch=input()\r\nif ch[a-1]==ch[b-1]:\r\n print(0)\r\nelse:\r\n print(1)\r\n", "# ---rgkbitw---\r\n# 7.10.2017\r\nn,a,b=map(int,input().split())\r\ns=input()\r\nprint(int(s[a-1])^int(s[b-1])) \r\n \r\n", "n, a, b = list(map(int, input().split()))\nsecondLine = input()\n\n#print(n, a, b, secondLine)\n\nairports = list(secondLine)\n\nif(airports[a-1] == airports[b-1]):\n\tprint(0)\nelse:\n\tprint(1)", "n,a,b=map(int,input().split())\r\ns=input()\r\nprint(chr(49-(s[a-1]==s[b-1])))", "n,a,b = map(int,input().split())\r\ni = input()\r\nair_a = i[a-1]\r\nair_b = i[b-1]\r\nif air_a == air_b:\r\n print (0)\r\nelse:\r\n print (1)", "n,a,b=map(int,input().split())\r\ns=input()\r\nif(s[a-1]==s[b-1]): #no need to change\r\n\tprint (0)\r\nelse: #u need to change from 0 to 1 or 1 to 0..for changing u go towards airport uptill there are same number as beginning..that too consecutive else u will make a chaneg and directly go to final position for free.\r\n\tprint(1)", "import sys\r\nimport string\r\nimport math\r\n\r\nline=input()\r\nn=int(line.split(\" \")[0])\r\na=int(line.split(\" \")[1])-1\r\nb=int(line.split(\" \")[2])-1\r\n\r\nbelong=input()\r\n\r\nif belong[a]==belong[b]:\r\n print(0)\r\n exit(0)\r\n\r\nprint(1)", "n,a,b = map(int,input().split())\r\nf = ' ' + input().strip()\r\nprint(1 if f[a] != f[b] else 0)", "import sys\n\nn, a, b = map(int, sys.stdin.readline().split())\ns = input()\n\na -= 1\nb -= 1\n\nsmall = min(a, b)\nbig = max(a, b)\n\nans = 0\nif s[small] != s[big]:\n ans = 1\n\nprint(ans)\n", "x = input().split()\ny = input()\nz = []\n\nfor i in y:\n z.append(i)\n \nif y[int(x[1])-1] == y[int(x[2])-1]:\n print('0')\nelif y[int(x[1])-1] != y[int(x[2])-1]:\n print('1')\n \t \t \t\t \t \t\t\t\t \t", "# Description of the problem can be found at http://codeforces.com/problemset/problem/743/A\r\n\r\nn, a, b = map(int, input().split())\r\nl_a = input()\r\n\r\nif l_a[b - 1] == l_a[a - 1]:\r\n print(0)\r\nelse:\r\n print(1)", "def get_input(pregunta):\r\n return list(map(int, input(pregunta).split(\" \")))\r\nline_1 = get_input(\"\") \r\nline_2 = input()\r\n\r\naeropuertos = line_1[0]\r\nidA = line_1[1] - 1\r\nidB = line_1[2] - 1\r\n\r\nif line_2[idA] == line_2[idB]:\r\n print(0)\r\nelse:\r\n print(1)", "n,i,j=list(map(lambda x:int(x),input().split()))\r\ns=input()\r\nif s[i-1]==s[j-1]:\r\n print(0)\r\nelse:\r\n print(1)", "n,a,b=map(int,(input().split(' ')))\r\nstring=list(map(int,(list(input()))))\r\nif string[a-1]==string[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "entrada = list(map(int,input().strip().split(\" \")))\r\naeropuerto = input()\r\n\r\nif aeropuerto[entrada[1]-1] == aeropuerto[entrada[2]-1]:\r\n\tprint(0)\r\n\r\nelse:\r\n\tprint(1)\r\n", "n, a, b = [int(x) for x in input().split()]\ns = input()\nprint(0 if s[a-1] == s[b-1] else 1)\n", "n,a,b=map(int,input().split())\r\ns=input()\r\nif(s[a-1]==s[b-1]):\r\n print(0)\r\nelse:\r\n print(1)\r\n ", "n,a,b = map(int,input().split())\r\na-=1\r\nb-=1\r\nl = list(input())\r\nif l[a]==l[b]:\r\n print(0)\r\n exit(0)\r\nprint(1)", "# https://codeforces.com/contest/743/problem/A\n\n# Problem\n# Big O:\n# Time complexity:\n# Space complexity:\n\n# Problem\n\n\ndef minimum_cost_between_airports(vladiks_house, olympiad, airports):\n return abs(airports[vladiks_house - 1] - airports[olympiad - 1])\n\n\n# Read input\nfirst_line = input().split()\n_, vladiks_house, olympiad = (int(i) for i in first_line)\n\nairports = [int(i) for i in input()]\nprint(minimum_cost_between_airports(vladiks_house, olympiad, airports))\n", "n,m,k=map(int,input().split())\r\np=input()\r\nif p[m-1] == p[k-1]:\r\n print(0)\r\nelse:\r\n print(1)", "a=input().split()\r\nn,a,b=int(a[0]),int(a[1]),int(a[2])\r\ns=input()\r\nsa=s[a-1]\r\nsb=s[b-1]\r\n\r\nif sa==sb or a==b:# a==b wale me doubt h\r\n print(\"0\")\r\nelif sa!=sb:\r\n print(1)", "n, a, b = map(int,input().split())\r\nm = input()\r\n\r\n \r\n\r\nprint([1,0][m[a-1]==m[b-1]])\r\n", "# Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is to find the cheapest way to get to the olympiad.\r\n\r\n# Vladik knows n airports. All the airports are located on a straight line. Each airport has unique id from 1 to n, Vladik's house is situated next to the airport with id a, and the place of the olympiad is situated next to the airport with id b. It is possible that Vladik's house and the place of the olympiad are located near the same airport.\r\n\r\n# To get to the olympiad, Vladik can fly between any pair of airports any number of times, but he has to start his route at the airport a and finish it at the airport b.\r\n\r\n# Each airport belongs to one of two companies. The cost of flight from the airport i to the airport j is zero if both airports belong to the same company, and |i - j| if they belong to different companies.\r\n\r\n# Print the minimum cost Vladik has to pay to get to the olympiad.\r\n\r\n# Input\r\n# The first line contains three integers n, a, and b (1 ≤ n ≤ 105, 1 ≤ a, b ≤ n) — the number of airports, the id of the airport from which Vladik starts his route and the id of the airport which he has to reach.\r\n\r\n# The second line contains a string with length n, which consists only of characters 0 and 1. If the i-th character in this string is 0, then i-th airport belongs to first company, otherwise it belongs to the second.\r\n\r\n# Output\r\n# Print single integer — the minimum cost Vladik has to pay to get to the olympiad.\r\n\r\n# Examples\r\n# inputCopy\r\n# 4 1 4\r\n# 1010\r\n# outputCopy\r\n# 1\r\n# inputCopy\r\n# 5 5 2\r\n# 10110\r\n# outputCopy\r\n# 0\r\n\r\n\r\ndef findCost(i, j, a):\r\n if a[i] == a[j]:\r\n return 0\r\n return 1\r\n\r\nli = list(map(int, input().split()))\r\na = input()\r\n\r\nprint(findCost(li[1]-1, li[2]-1, a))\r\n", "n, a, b = list(map(int, input().split()))\r\ns = input()\r\na -= 1 \r\nb-= 1\r\n\r\nif s[a]==s[b] or a == b:\r\n print(0)\r\nelse:\r\n print(1)\r\n", "n, a, b = [int(i) for i in input().split()]\nnum = list(input())\nif num[a - 1] != num[b - 1]:\n print(1)\nelse:\n print(0)\n \t\t \t \t\t\t\t \t \t\t \t\t \t \t \t \t", "def main():\r\n n,a,b=map(int,input().split())\r\n s=input()\r\n ind1=s[a-1]\r\n ind2=s[b-1]\r\n if ind1==ind2:\r\n print(0)\r\n else:\r\n print(1)\r\n\r\nmain()", "n,a,b = list(map(int, input().split()))\r\ns=input()\r\n#cnt=s[a+1:b].count('0')\r\nif(s[a-1]==s[b-1]):\r\n print(\"0\")\r\nelse:\r\n print(\"1\")", "a,b,c = map(int,input().split())\r\nstring = input()\r\nif string[b-1] != string[c-1]:\r\n\tprint(1)\r\nelse:\r\n\tprint(0)\r\n", "n,a,b = input().split()\r\ns = input()\r\na = int(a)\r\nb = int(b)\r\nprint(int(s[a-1])^int(s[b-1]))", "n, a, b = map(int, input().split())\r\nl = list(input())\r\nif l[a-1]==l[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "def inp():\r\n return map(int, input().split())\r\n\r\n\r\nn, a, b = inp()\r\ns = input()\r\nprint(0 if s[a - 1] == s[b - 1] else 1)\r\n", "nAirPorts, start,end = [int(i) for i in input().split(' ')]\r\n\r\nstart -= 1 \r\nend -= 1 \r\n\r\nl = input()\r\n\r\nif l[start] == l[end]:\r\n print(0)\r\n\r\nelse:\r\n #Buscamos el id mas cercano\r\n\r\n #Caso del menor\r\n menor = 0\r\n while menor != 0:\r\n for i in range(1,len(l)):\r\n if l[start] != l[start - i]:\r\n menor = i\r\n\r\n #Caso del mayor\r\n mayor = 0\r\n while menor != 0:\r\n for i in range(1,len(l)):\r\n if l[start] != l[start + i]:\r\n menor = i\r\n #Realizamos el print \r\n if menor >= mayor:\r\n print(mayor+1)\r\n else:\r\n print(menor+1)\r\n", "n,a,b = list(map(int, input().split()))\r\ns = input()\r\na-=1\r\nb-=1\r\n \r\nprint((ord(s[a])-58) ^ (ord(s[b])-58))", "n, a, b = list(map(int,input().split()))\r\n\r\nx = input()\r\n\r\ny = [0]*n\r\nfor i in range(n):\r\n y[i] = int(x[i])\r\n\r\nif (x[a-1]==x[b-1]):\r\n\tprint(\"0\")\r\nelse:\r\n\tprint(\"1\")", "#in the name of god\r\n#Mr_Rubick\r\nn,a,b=map(int,input().split())\r\ns=input()\r\nprint(1 if s[a-1]!=s[b-1] else 0)", "n,a,b = map(int,input().split())\r\ns = input()\r\na-=1\r\nb-=1\r\nif(s[a]=='0'):\r\n\tif(s[b]=='0'):\r\n\t\tprint(0)\r\n\telse:\r\n\t\tprint(1)\r\n\t\r\nelse:\r\n\tif(s[b]=='1'):\r\n\t\tprint(0)\r\n\telse:\r\n\t\tprint(1)", "n, a, b = map(int, input().split())\ns = input()\n\nmi = 10**9\no = -10**18\nz = -10**18\n\nif s[0] == '0':\n z = 0\nelse:\n o = 0\nfor i in range(1, n):\n if s[i] == '1':\n o = i\n mi = min(mi, i-z)\n elif s[i] == '0':\n z = i\n mi = min(mi, i-o)\n\nif s[a-1] == s[b-1]:\n mi = 0\nprint(mi)\n", "n,a,b=map(int,input().split())\r\nx=str(input())\r\nif x[a-1]==x[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "#t=int(input())\r\nn,a,b = map(int, input().strip().split(' '))\r\n#lst = list(map(int, input().strip().split(' ')))\r\ns=input()\r\ns=list(s)\r\nif s[a-1]==s[b-1]:\r\n print(0)\r\nelse:\r\n print(1)\r\n \r\n \r\n ", "class solve:\r\n def __init__(self):\r\n n,a,b=map(int,input().split())\r\n s=input()\r\n if s[a-1]==s[b-1]:\r\n print(0)\r\n else:\r\n print(1)\r\n \r\nobj=solve()", "n, a, b = map(int, input().split())\r\ns = input()\r\nprint(1 if s[a - 1] != s[b - 1] else 0)\r\n\r\n", "l=list(map(int,input().split()))\r\ns=input()\r\nif s[l[1]-1]==s[l[2]-1]:\r\n print(0)\r\nelse:\r\n print(1)", "n, a, b = map(int, input().split())\na -= 1\nb -= 1\ns = input()\nif s[a] == s[b]:\n print('0')\nelse:\n print('1')\n", "n,a,b=map(int,input().split())\r\ns=input()\r\nprint(0) if s[a-1]==s[b-1]else print(1)", "n, a, b = [int(x) for x in input().split()]\r\nairports = input()\r\n\r\n\r\n\r\ndef fun():\r\n if a == b:\r\n return 0\r\n if airports[a - 1] == airports[b - 1]:\r\n return 0\r\n return 1\r\nprint(fun())\r\n", "n,a,b=map(int,input().split())\r\ns=input()\r\nprint(int(s[a - 1] != s[b - 1]))\r\n", "n,a,b = map(int,input().split())\r\nair=input()\r\nx=air[a-1]\r\ny=air[b-1]\r\nif x==y:\r\n print(0)\r\nelse:\r\n print(1)\r\n", "n, a, b = map(int, input().split())\ns = input()\nif s[a - 1] == s[b - 1]:\n print(0)\nelse:\n print(1)", "n,a,b = map(int,input().split())\r\ns = input()\r\nif s[a-1] == s[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "nums = list(map(int, input().split()))\nowners = list(map(int, input()))\n\nif(owners[nums[1] - 1] is owners[nums[2] - 1]):\n print(\"0\")\nelse:\n print(\"1\")", "n,a,b = map(int,input().split())\r\ns = input()\r\nprint(1 if s[b-1]!=s[a-1] else 0)\r\n", "n,a,b=map(int,input().split())\r\ns=str(input())\r\nif s[a-1]==s[b-1]:\r\n print(0)\r\nelse:\r\n print(abs(int(s[a-1])-int(s[b-1])))", "n,a,b= map(int,input().split())\r\ns= input()\r\nfirst= min(a,b)\r\nsecond= max(a,b)\r\nif s[first-1]==s[second-1]:\r\n print(\"0\")\r\nelse:\r\n print(\"1\")\r\n ", "#t = int( input() )\r\nn , a , b = map(int,input().split(\" \"))\r\ns= input()\r\n\r\nif(s[a-1]==s[b-1]):\r\n\tprint(0)\r\nelse:\r\n\tprint(1)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t", "n,a,b=map(int,input().split())\r\nl=list(map(int,input()))\r\nif l[a-1]==l[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "def main_function():\r\n n, a, b = [int(i) for i in input().split(\" \")]\r\n s = input()\r\n starting_company = s[a - 1]\r\n ending_company = s[b - 1]\r\n if starting_company == ending_company:\r\n print(0)\r\n else:\r\n print(1)\r\n\r\nmain_function()", "n = [int(x) for x in input().split()]\r\nk = str(input())\r\n\r\nif k[n[1]-1] == k[n[2]-1]:\r\n print(0)\r\nelse:\r\n print(1)", "n, a, b = map(int, input().split())\na -= 1\nb -= 1\nL = input()\nif L[a] == L[b]:\n print(0)\n exit()\n\nif a == b:\n print(0)\n exit()\n\nprint(1)\n", "_, i, j = list(map(int, input().split()))\nairports = '0' + input()\nif airports[i] == airports[j]:\n print(0)\nelse:\n print(1)\n", "n, a, b = map(int, input().split())\r\nx = input()\r\nprint(0 if x[a - 1] == x[b - 1] else 1)", "n,a,b=map(int,input().split())\r\ns=input()\r\na-=1\r\nb-=1\r\nif s[a]==s[b]:\r\n print(0)\r\nelse:\r\n print(1) ", "n,a,b = map(int,input().split())\r\ns = input()\r\na -= 1\r\nb -= 1\r\n#start=0 ; end = b-a ; mid = index\r\nif a==b or s[a]==s[b]:\r\n print(0)\r\nelse:\r\n print(1)\r\n\r\n", "n, a, b = map(int, input().split())\r\ns = input()\r\na -= 1\r\nb -= 1\r\nif s[a] == s[b]:\r\n print(0)\r\nelse:\r\n print(1)\r\n", "n, a, b = map(int, input().split())\r\n\r\ncomp = input()\r\n\r\nif comp[a - 1] == comp[b - 1]:\r\n print(0)\r\nelse:\r\n print(1)\r\n\r\n", "n,a,b=(int (z) for z in input().split())\r\ns=input()\r\nif s[a-1]==s[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "a,b,c=map(int,input().split())\r\nz=input()\r\nprint((z[b-1]!=z[c-1])+0)", "import math\r\nn , a , b = map(int,input().split())\r\ns = input()\r\ncount = 0\r\nif s[a-1] == s[b-1]:\r\n print('0')\r\nelse:\r\n for i in range(a-1,b-1):\r\n if s[a-1] == s[b-1]:\r\n count += 1\r\n print(abs(s.find('a')-count))\r\n\r\n", "import sys\r\nimport math\r\nimport bisect\r\n\r\ndef solve(s, a, b):\r\n n = len(s)\r\n if s[a] == s[b]:\r\n return 0\r\n return 1\r\n\r\ndef main():\r\n n, a, b = map(int, input().split())\r\n a -= 1\r\n b -= 1\r\n s = input()\r\n ans = solve(s, a, b)\r\n print(ans)\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "a,b,c = map(int, input().split())\r\nnums = input()\r\nnums.split()\r\nif nums[b-1]==nums[c-1]:\r\n\tprint(0)\r\nelse:\r\n\tprint(1)\r\n", "n, a, b = map(int, input().split())\r\nairports = [int(x) for x in input().strip()]\r\n\r\nprint(0 if airports[a - 1] == airports[b - 1] else 1)\r\n", "import math\r\nfrom collections import Counter,defaultdict\r\nI =lambda:int(input())\r\nM =lambda:map(int,input().split())\r\nLI=lambda:list(map(int,input().split()))\r\nn,a,b=M()\r\ns=input()\r\nif s[a-1]==s[b-1]:\r\n print(0)\r\nelse:\r\n m=abs(b-a);c=-1;d=-1\r\n for i in range(len(s)):\r\n if s[i]==\"1\":c=i\r\n elif s[i]==\"0\":d=i\r\n if c>-1 and d>-1:\r\n m=min(m,abs(c-d))\r\n print(m)\r\n \r\n \r\n \r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n", "if __name__ == '__main__':\r\n\tn,a,b = map(int, input().split())\r\n\ts = input()\r\n\tf = a-1\r\n\tt = b-1\r\n\tif a >b:\r\n\t\tf,t=t,f\r\n\tif a == b or s[a-1] == s[b-1]:\r\n\t\tprint(0)\r\n\telse:\r\n\t\tprint(1)", "n , a , b=map(int,input().split())\r\ns=input()\r\nprint([1,0][s[a-1]==s[b-1]])", "import math\r\n\r\ninp = [int(a) for a in input().split(\" \")]\r\nget = list(input())\r\nstart = inp[1]-1\r\nend = inp[2]-1\r\nif get[start] == get[end]:\r\n print(\"0\")\r\nelse:\r\n print(\"1\")", "a,x,y=map(int,input().split())\r\nb=input()\r\nprint([1,0][b[x-1]==b[y-1]])\r\n", "# https://codeforces.com/contest/743/problem/A\n\n# Problem\n# Big O:\n# Time complexity:\n# Space complexity:\n\n# Problem\n\n\ndef minimum_cost_between_airports(vladiks_house, olympiad, airports):\n return abs(int(airports[vladiks_house - 1]) - int(airports[olympiad - 1]))\n\n\n# Read input\nfirst_line = input().split()\nn = int(first_line[0])\na = int(first_line[1])\nb = int(first_line[2])\n\nairports = list(input())\nprint(minimum_cost_between_airports(a, b, airports))\n", "n,a,b=list(map(int,input().split()))\r\np=list(input())\r\nif a==b:\r\n print(0)\r\nelse:\r\n if p[a-1]!=p[b-1]:\r\n print(1)\r\n else:\r\n print(0)", "n, a, b = map(int, input().split())\r\ns = ' ' + input()\r\nprint(1 if s[a] != s[b] else 0)", "n, a, b = map(int, input().split())\na-=1\nb-=1\n\nv = input()\nif v[a] == v[b]:\n print(0)\nelse:\n print(1)\n", "if __name__== '__main__':\r\n n, a, b= [int(x) for x in input().split()]\r\n airports= input()\r\n\r\n if((a== b) or (airports[a- 1]== airports[b- 1])):\r\n print(0)\r\n else:\r\n print(1)\r\n\r\n", "# https://codeforces.com/contest/743/problem/A\n\n# Problem\n# Big O:\n# Time complexity: O(n)\n# Space complexity: O(n)\n\n# Problem\n\n\ndef minimum_cost_between_airports(vladiks_house, olympiad, airports_companies):\n return 1 if airports_companies[vladiks_house] != airports_companies[olympiad] else 0\n\n\n# Read input\nfirst_line = input().split()\n_, vladiks_house, olympiad = (int(i) for i in first_line)\n\nairports_companies = list(input())\nprint(minimum_cost_between_airports(\n vladiks_house - 1, olympiad - 1, airports_companies))\n", "n,a,b = map(int,input().split())\r\n\r\ns = input()\r\n\r\nif s[a-1]!=s[b-1]:\r\n print(\"1\")\r\nelse:\r\n print(\"0\")\r\n", "sink, n, m = map(int, input().split())\r\na = [int(x) for x in input()]\r\n\r\nprint(abs(a[n-1] - a[m-1]))", "m,a,b = map(int,input().split())\r\nn = input()\r\nk,l,pp = [n[a-1],n[b-1],[]]\r\nif l == k:\r\n print('0')\r\nelse:\r\n print('1')", "def solve():\n n, a, b = map(int, input().rstrip().split())\n ls = input().rstrip()\n if ls[a-1] == ls[b-1]:\n print(0)\n else:\n print(1)\n\nif __name__ == '__main__':\n solve()\n", "n,a,b=map(int,input().split(\" \"))\r\ns=input()\r\nprint(0) if s[a-1]==s[b-1] else print(1)\r\n", "n,a,b = map(int, input().split())\r\nstring = input()\r\nif string[a-1] == string[b-1]:\r\n print(0)\r\nelse:\r\n print(1)\r\n", "def main():\n from sys import stdin, stdout\n lines = stdin.readlines()\n # lines will now contain all of the input's lines in a list\n # how to print: stdout.write(str(stuff)) (remember to add your own newlines)\n line = lines[0].split()\n n, a, b = tuple(map(int, line))\n airports = lines[1]\n stdout.write('0\\n' if airports[a-1] == airports[b-1] else '1\\n')\n\n\nif __name__ == '__main__':\n main()\n", "# A. Vladik and flights\r\n\r\nmasuk = input().split()\r\nn,a,b = masuk[0],masuk[1],masuk[2]\r\ncomp = list(input())\r\nif comp[int(a)-1] == comp[int(b)-1]:\r\n print(0)\r\nelse:\r\n print(1)\r\n", "\r\nn,start,end = list(map(int,input().split()))\r\nnums = input()\r\n# print(nums[start-1],nums[end-1])\r\nif nums[start-1]==nums[end-1]:\r\n print(0)\r\nelse:\r\n print(1)", "n,a,b=map(int,input().split())\r\narr=input().strip()\r\nif a==b:\r\n print(0)\r\nelif arr[a-1]==arr[b-1]:\r\n print(0)\r\nelse:\r\n print(1)", "list = [int(x) for x in input().split(' ')]\nairports = input()\nairports = [int(digit) for digit in airports]\n\nif(airports[list[1]-1] == airports [list[2]-1]):\n print('0')\nelse:\n print('1')\n\t\t\t\t\t \t \t \t \t \t\t\t\t\t \t\t\t", "n,a,b=[int(i) for i in input().split()]\r\ns=input()\r\nif(a==b or s[a-1]==s[b-1]):print(\"0\")\r\nelse: print(\"1\")\r\n", "_, a, b=map(int, input().split())\r\ns=input()\r\nprint(int(s[a-1])^int(s[b-1]))", "n,a,b=map(int,input().split())\r\ns=input()\r\n\r\ni=int(s[a-1])\r\nj=int(s[b-1])\r\nif (i-j==1 )or (i-j==-1):\r\n print(\"1\")\r\nelse:\r\n print(\"0\")\r\n", "from sys import stdin\n\nN, A, B = map(int, stdin.readline().split())\nbits = stdin.readline()\n\nprint(int(bits[A - 1] != bits[B - 1]))\n", "from sys import stdin,stdout\r\n\r\na,x,y=list(map(int,input().split()))\r\nlength=input()\r\nprint(0 if length[x-1]==length[y-1] else 1 )", "def compute(a,b,airports):\r\n if a == b or airports[a] == airports[b]:\r\n return 0\r\n if a > b:\r\n temp = b\r\n b = a\r\n a = temp\r\n return 1\r\nn,a,b = map(int, input().split())\r\nairports = input()\r\n\r\nprint (compute(a-1,b-1,airports))\r\n", "def main():\r\n n, a, b = list(map(int, input().split()))\r\n string = input()\r\n\r\n if n == 1:\r\n print(0)\r\n else:\r\n if string[a - 1] == string[b - 1]:\r\n print(0)\r\n else:\r\n print(1)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "i = str(input()).split()\na = str(input())\nprint(int(not(a[int(i[1]) - 1] == a[int(i[2]) - 1])))\n", "n, a, b = map(int, input().split())\r\ns = input()\r\nprint( 1- (s[a-1]==s[b-1]))", "import sys\nn, a, b = map(int, sys.stdin.readline().split())\ns = input().strip()\nif s[a-1] == s[b-1]:\n print(0)\nelse:\n print(1)\n", "n, a, b = map(int, input().split())\r\na, b = a - 1, b - 1\r\ns = input()\r\npa = s[a]\r\npb = s[b]\r\nif pa == pb:\r\n print(0)\r\nelse:\r\n print(1)", "first = input().split()\nfor i in range(0, 3):\n first[i] = int(first[i])\n\nroute = list(input())\nfor i in range(0, len(route)):\n route[i] = int(route[i])\n\npos = first[1]\ndest = first[2]\n\nprint(abs(route[pos-1] - route[dest-1]))\n\n\n\t \t\t\t\t \t\t\t \t\t \t \t \t\t \t \t \t", "n,a,b=[int(x) for x in input().split()]\r\ns=str(input())\r\n\r\nif s[a-1]==s[b-1]:\r\n print(0)\r\n \r\nelse:\r\n print(1)", "n,a,b=tuple(int(x) for x in input().split())\r\ncompany=input()\r\nif company[a-1]==company[b-1] :\r\n print(0)\r\nelse:\r\n print(1)\r\n\r\n", "n, a, b = map(int, input().split())\nbit_string = input()\n\nif bit_string[a-1] == bit_string[b-1]:\n print(0)\nelse:\n print(1)", "if __name__==\"__main__\":\r\n n,a,b=map(int,input().split())\r\n s=input()\r\n if s[a-1]==s[b-1]:\r\n print(0)\r\n else:\r\n print(1)", "s=[int(n)-1 for n in input().split()]\r\nz=[int(n) for n in input()]\r\nif z[s[1]]==z[s[2]]:\r\n print(0)\r\nelse:\r\n print(1)", "length, start, end = map(int,input().split())\ndata = input()\nif data[end - 1] == data[start -1] :\n print (\"0\")\nelse :\n print (\"1\")" ]
{"inputs": ["4 1 4\n1010", "5 5 2\n10110", "10 9 5\n1011111001", "7 3 7\n1110111", "1 1 1\n1", "10 3 3\n1001011011", "1 1 1\n0", "10 5 8\n1000001110", "10 1 10\n0000011111", "4 1 4\n0011", "10 3 7\n0000011111", "5 1 5\n11010", "6 1 6\n111000", "2 1 2\n01", "10 10 1\n0000011111", "6 1 6\n000111", "10 2 10\n0000011111", "8 1 8\n11110000", "6 1 5\n100000", "16 4 12\n0000000011111111", "6 1 5\n111000", "8 2 7\n11110000", "6 2 5\n111000", "9 9 1\n111000000", "2 2 1\n01", "5 2 5\n00001", "5 1 5\n10000", "6 1 6\n011111", "5 5 1\n11110", "2 1 2\n10", "4 2 4\n0001", "10 1 10\n1111100000", "8 4 5\n00001111", "4 4 1\n0111", "8 1 8\n00101001"], "outputs": ["1", "0", "1", "0", "0", "0", "0", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"]}
UNKNOWN
PYTHON3
CODEFORCES
201
e3ef0e1738a58490809dd66924789fd2
Eleven
Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly *n* characters. Her friend suggested that her name should only consist of uppercase and lowercase letters 'O'. More precisely, they suggested that the *i*-th letter of her name should be 'O' (uppercase) if *i* is a member of Fibonacci sequence, and 'o' (lowercase) otherwise. The letters in the name are numbered from 1 to *n*. Fibonacci sequence is the sequence *f* where - *f*1<==<=1, - *f*2<==<=1, - *f**n*<==<=*f**n*<=-<=2<=+<=*f**n*<=-<=1 (*n*<=&gt;<=2). As her friends are too young to know what Fibonacci sequence is, they asked you to help Eleven determine her new name. The first and only line of input contains an integer *n* (1<=≤<=*n*<=≤<=1000). Print Eleven's new name on the first and only line of output. Sample Input 8 15 Sample Output OOOoOooO OOOoOooOooooOoo
[ "s = \"\"\r\n\r\n\r\ndef fibo(i):\r\n if i == 1:\r\n return 0\r\n elif i == 2:\r\n return 0\r\n a = 0\r\n b = 1\r\n c = 0\r\n while c < i:\r\n c = a + b\r\n a = b\r\n b = c\r\n if c == i:\r\n return 0\r\n return 1\r\n\r\n\r\nfor i in range(1,int(input())+1):\r\n if fibo(i) == 0:\r\n s += \"O\"\r\n else:\r\n s += \"o\"\r\nprint(s)", "n = int(input())\r\nf1 = 1\r\nf2 = 1\r\nf = f1+f2\r\ns = 'O'\r\nidx = 2\r\nwhile idx <= n:\r\n if idx == f:\r\n s += 'O'\r\n f1 = f2\r\n f2 = f\r\n f = f1+f2\r\n else:\r\n s += 'o'\r\n idx += 1\r\n\r\nprint(s)\r\n", "n = int(input())\narr = [1, 2]\na = 1\nb = 2\nrez = ''\nfor i in range(n):\n a, b = b, a + b\n arr.append(b)\nfor i in range(1, n + 1):\n if i in arr:\n rez += 'O'\n else:\n rez += 'o'\nprint(rez)\n\n", "n=int(input())\r\nf=0\r\ns=1\r\nlst=[]\r\nwhile f<=(n+1):\r\n lst.append(f)\r\n f,s=s,f+s\r\nfor i in range(1,n+1):\r\n if i in lst:\r\n print('O',end='')\r\n else:\r\n print('o',end='')\r\nprint()\r\n \r\n", "n=int(input())\r\ndef f(n):\r\n if n==1 or n==2:\r\n return 1\r\n return f(n-1)+f(n-2)\r\ni=2\r\np=[]\r\nwhile f(i)<=n:\r\n p.append(f(i))\r\n i+=1\r\nx=''\r\nfor i in range(n):\r\n if i+1 in p:\r\n x+='O'\r\n else:\r\n x+='o'\r\nprint(x)\r\n", "def fibonacci(n):\r\n if n == 1 or n == 2:\r\n return 1\r\n else:\r\n return( fibonacci( n-1 ) + fibonacci( n-2) )\r\n\r\nn = int(input())\r\ni = 1\r\nc = 1\r\nFibo = []\r\nwhile c <= n:\r\n i += 1\r\n Fibo.append(c)\r\n c = fibonacci(i)\r\n# print(Fibo)\r\nFibo = set(Fibo)\r\nans = \"\"\r\nfor i in range(1, n+1):\r\n if i in Fibo:\r\n ans += \"O\"\r\n else:\r\n ans += \"o\"\r\n\r\nprint(ans)", "n = int(input())\r\nf=[1,1]\r\nwhile f[-1]<n:\r\n f.append(f[-1]+f[-2])\r\nfor i in range(n):\r\n if i+1 in f:\r\n print('O',end='')\r\n else:\r\n print('o',end='')", "# LUOGU_RID: 113788200\nprint('OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooo'[:int(input())])", "fib=[1,1]\r\nc=50\r\nwhile c>0:\r\n fib.append(fib[-1]+fib[-2])\r\n c=c-1\r\n#print(fib)\r\na=int(input())\r\nd=''\r\nfor i in range(1,a+1):\r\n if i in fib:\r\n d+='O'\r\n else:\r\n d+='o'\r\nprint(d)\r\n", "n = int(input())\r\nl= []\r\nl.append(1)\r\nc=0\r\na=1\r\nb=1\r\nwhile c<=n:\r\n c=a+b\r\n a=b\r\n b=c\r\n l.append(c)\r\nfor i in range(1,n+1):\r\n if i in l:\r\n print('O',end=\"\")\r\n else:\r\n print('o',end=\"\")", "n = int(input())\r\nfib = [1,1]\r\nres = ''\r\nfor i in range(16):\r\n fib.append(fib[i]+fib[i+1])\r\nfor i in range(n):\r\n if i+1 in fib:\r\n res += 'O'\r\n else:\r\n res += 'o'\r\nprint(res)\r\n\r\n", "a=int(input())\ni=0\ns=[0,1]\nwhile i in range(1000):\n q=s[i]+s[i+1]\n s.append(q)\n i+=1\ns1=''\nfor k in range(1,a+1):\n if s.count(k)==0:\n s1+='o'\n else:\n s1+='O'\nprint(s1)\n", "n = int(input())\nf1 = 1\nf2 = 2\ns = \"OO\"\nif n > 2:\n for i in range(3, n + 1):\n if i == f1 + f2:\n f1 = f2\n f2 = i\n s += 'O'\n else:\n s += 'o'\n print(s)\nelse:\n print(s[:n])\n", "# ===================================\n# (c) MidAndFeed aka ASilentVoice\n# ===================================\n# import math \n# import collections\n# ===================================\nfib = [0, 1, 1]\nn = int(input())\nfor i in range(n):\n fib.append(fib[i+2]+fib[i+1])\ns = \"\"\nfor i in range(n):\n s += \"O\" if i+1 in fib else \"o\"\nprint(s)\n", "n = int(input())\r\n\r\n\r\ndef fib(n):\r\n if n <= 2:\r\n return 1\r\n else:\r\n return fib(n - 2) + fib(n - 1)\r\n\r\n\r\nletters = ['o' for _ in range(n)]\r\n\r\na = 1\r\nwhile fib(a) <= n:\r\n letters[fib(a)-1] = 'O'\r\n a += 1\r\n\r\nprint(''.join(letters))\r\n", "arr=[0,1]\r\nn=int(input())\r\nwhile(arr[-1]<n):\r\n\tarr.append(arr[-1]+arr[-2])\r\ns=\"\"\r\nfor i in range(1,n+1):\r\n\tif(i in arr):\r\n\t\ts+='O'\r\n\telse:\r\n\t\ts+='o'\r\nprint(s)", "n=int(input())\r\nlist1=[]\r\nsum1=0\r\ns1=0\r\ni=1\r\nwhile i <= n :\r\n\tsum1=s1+i\r\n\ts1=i#tried all the variables,used i+=1 giving wrong answer\r\n\ti=sum1\r\n\tlist1.append(s1)\r\nfor i in range(n):\r\n\tif i+1 in list1:\r\n\t\tprint(\"O\",end=\"\")\r\n\telse:\r\n\t\tprint(\"o\",end=\"\")", "n = int(input())\r\ncur, next = 1, 1\r\nans = \"\"\r\nfor i in range(n):\r\n if i + 1 == cur:\r\n ans += 'O'\r\n cur, next = cur+next, cur\r\n else:\r\n ans += 'o'\r\nprint(ans)\r\n", "def checkFibo(n):\r\n c, a, b = 0, 1, 1\r\n if n == 1:\r\n return True\r\n else:\r\n while c<n:\r\n c = a+b\r\n b = a\r\n a = c\r\n if c == n:\r\n return True\r\n else:\r\n return False\r\n# print(checkFibo(13))\r\nn = int(input())\r\nres = ''\r\nfor i in range(1, n+1):\r\n res += 'O' if checkFibo(i) else 'o'\r\nprint(res)", "w=int(input())\r\na,b=0,1\r\nt,p,y=[],[],[]\r\nfor i in range(0,w):\r\n q= 'o'\r\n y.append(q)\r\nfor i in range(2,w):\r\n c = a + b\r\n a = b\r\n b = c\r\n if b>w:\r\n break\r\n t.append(b)\r\nrepl_char = 'O'\r\ntemp = list(y)\r\nfor idx in t:\r\n temp[idx-1] = repl_char\r\nr = ''.join(temp)\r\nif w==1:\r\n print('O')\r\nelif w==2:\r\n print('OO')\r\nelif w==3:\r\n print('OOO')\r\nelif w==4:\r\n print('OOOo')\r\nelif w==5:\r\n print('OOOoO')\r\nelse:\r\n print(r)\r\n", "from functools import lru_cache\r\nfrom itertools import count\r\n@lru_cache(None)\r\ndef f(n):\r\n if n<=2:\r\n return 1\r\n return f(n-1)+f(n-2)\r\n \r\nn=int(input())\r\nw=['o']*n\r\nfor i in count(1):\r\n try:\r\n w[f(i)-1]='O'\r\n except:\r\n break\r\nprint(''.join(w))\r\n", "a,b = 1,2\r\nr = \"\"\r\nfor i in range(1,int(input())+1):\r\n\tif i == a or i == b:\r\n\t\tr += \"O\"\r\n\t\ta,b = b,a+b\r\n\telse:\r\n\t r += \"o\"\r\nprint(r)", "a = int(input())\r\nb = \"o\" * a\r\nd = 0\r\nd1 = 0\r\nd2 = 1\r\nfor i in range(len(b)):\r\n if d <= len(b):\r\n b = b[:d-1] + \"O\" + \"o\" * (a-d)\r\n d = d1 + d2\r\n d1 = d2\r\n d2 = d\r\nif a <= 3:\r\n print(\"O\"*a)\r\nelse:\r\n print(b)", "FibArray = [0, 1] \ndef fibonacci(n): \n while len(FibArray) < n + 1: \n FibArray.append(0) \n \n if n <= 1: \n return n \n else: \n if FibArray[n - 1] == 0: \n FibArray[n - 1] = fibonacci(n - 1) \n \n if FibArray[n - 2] == 0: \n FibArray[n - 2] = fibonacci(n - 2) \n \n FibArray[n] = FibArray[n - 2] + FibArray[n - 1] \n return FibArray[n]\n\ndef main():\n _ = fibonacci(100)\n n = int(input())\n\n for i in range(1, n+1):\n if i in FibArray:\n print(\"O\", end=\"\")\n else:\n print(\"o\", end=\"\")\n\n print()\n\nif __name__ == \"__main__\":\n main()", "def fib(n,s):\r\n if n<=2:\r\n return 1\r\n s = fib(n-1,s)+fib(n-2,s)\r\n lst.append(s)\r\n return s\r\nlst = []\r\nfib(17,0)\r\nlst = set(lst)\r\nx = int(input())\r\ns = 'O'\r\nfor i in range(2,x+1):\r\n if i in lst:\r\n s+='O'\r\n else:\r\n s+='o'\r\nprint(s)", "def generateName(i,n):\r\n if(i == n+1 ):\r\n return\r\n if(i in fibs):\r\n print(\"O\",end=\"\")\r\n return generateName((i+1),n)\r\n print(\"o\",end=\"\")\r\n return generateName(i+1,n)\r\n\r\nfibs=[0]*1003\r\ndef generateFib(n):\r\n fibs[1]=fibs[2]=1\r\n \r\n for i in (range(3,n+1)):\r\n fibs[i]=fibs[i-1]+fibs[i-2]\r\n\r\n \r\ngenerateFib(1002)\r\nn=int(input())\r\ngenerateName(1,n)", "# def fib(n):\r\n# if(n<=1):\r\n# return 1 \r\n# return fib(n-1)+fib(n-2)\r\nn=int(input())\r\nl=[]\r\nfir=0 \r\nsec=1 \r\nans=\"\"\r\nfor i in range(1,n+1):\r\n if (fir+sec==i):\r\n ans+=\"O\"\r\n fir=sec \r\n sec=i\r\n else:\r\n ans+='o'\r\nprint(ans)", "\r\nfrom math import *\r\n\r\ndef isperfect(x):\r\n s = int(sqrt(x))\r\n return s*s == x\r\n\r\n\r\ndef is_fib(n):\r\n return isperfect(5*n*n + 4) or isperfect(5*n*n - 4)\r\n\r\n\r\nrem = \"\"\r\nn = int(input())\r\nfor i in range(1, n+1):\r\n if is_fib(i) == True:\r\n rem += \"O\"\r\n else:\r\n rem += \"o\"\r\nprint(rem)", "n = int(input())\r\ns = ''\r\nfor i in range(1, n + 1):\r\n a, b = (5 * i**2 - 4), (5 * i**2 + 4)\r\n a1, b1 = int(a**.5), int(b**.5)\r\n s += 'O' if a == a1**2 or b == b1**2 else 'o'\r\nprint(s)\r\n", "N = int(input())+1\r\nfib = set([1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987])\r\nname = [['o','O'][i in fib] for i in range(1,N)]\r\nprint(*name, sep='')", "now = 1\r\nprevious = 1\r\n\r\nn = int(input())\r\nname = \"O\"\r\n\r\nnext_fibonacci = 2\r\n\r\nfor i in range(2, n + 1):\r\n if i == next_fibonacci:\r\n new_previous = now\r\n now += previous\r\n previous = new_previous\r\n name += \"O\"\r\n next_fibonacci = now + previous\r\n else:\r\n name += \"o\"\r\n\r\nprint(name)\r\n", "n = int(input())\r\nname = ['o'] * n\r\n\r\nfib_1 = 1\r\nfib_2 = 1\r\nfib_s = 0\r\nwhile fib_s < n+1:\r\n name[fib_1 - 1] = \"O\"\r\n name[fib_2 - 1] = \"O\"\r\n\r\n fib_s = fib_1 + fib_2\r\n fib_1 = fib_2\r\n fib_2 = fib_s\r\nprint(*name, sep=\"\")\r\n", "import math\n\n\ndef check(n):\n sqrt = int(math.sqrt(n))\n if pow(sqrt, 2) == n:\n return True\n else:\n return False\n\n\ndef fib(n):\n a, b = 5 * int(pow(n, 2)) + 4, 5 * int(pow(n, 2)) - 4\n if check(a) or check(b):\n return True\n else:\n return False\n\n\nn = eval(input())\nfor i in range(1, n + 1):\n if fib(i):\n print(\"O\", sep='', end='')\n else:\n print(\"o\", sep='', end='')\n\n \t \t \t\t \t \t\t \t\t\t \t", "n = int(input())\r\ns = ''\r\n#斐波那契小于1000的项\r\nfib = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]\r\nfor i in range(1,n+1):\r\n if i not in fib:\r\n s += 'o'\r\n else:\r\n s+='O'\r\nprint(s)", "n=int(input())\r\nf=1\r\ns=1\r\nc=[]\r\nc.append(f)\r\na=[]\r\nfor i in range(n-1):\r\n\tt=f+s\r\n\tf=s\r\n\ts=t\r\n\tc.append(t)\r\nfor i in range(n):\r\n\tif i+1 in c:\r\n\t\ta.append('O')\r\n\telse:\r\n\t\ta.append('o')\r\nprint(\"\".join(a))", "nn=int(input())\r\nk=1\r\nz=1\r\ns=''\r\nfor i in range(1,nn+1):\r\n if i==z:\r\n z=k+z\r\n k=z-k\r\n s=s+\"O\"\r\n else:\r\n s=s+\"o\"\r\nprint(s) ", "n = int(input())\r\nli = [1]\r\na,b = 1,1\r\nfor _ in range(14):\r\n k = b\r\n b += a\r\n a = k\r\n li.append(b)\r\nres = 'o'*n\r\nfor i in li:\r\n if i <= n:\r\n res = res[:(i-1)] + 'O' + res[i:] \r\n else:\r\n break\r\nprint(res)", "n=int(input())\r\nz=\"\"\r\nlist1=[] \r\nfib1=1\r\nlist1.append(fib1)\r\nfib2=1\r\nlist1.append(fib2)\r\nfor i in range(2,n+1):\r\n fib3=fib1+fib2\r\n list1.append(fib3)\r\n fib1=fib2\r\n fib2=fib3\r\nfor i in range(1,n+1):\r\n if(i in list1):\r\n z=z+\"O\"\r\n else:\r\n z=z+\"o\"\r\nprint(z)\r\n \r\n ", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Jun 18 11:10:56 2021\r\n\r\n@author: nagan\r\n\"\"\"\r\n\r\nn = int(input())\r\nl = [0, 1]\r\nwhile l[-1] < n:\r\n l.append(l[-2] + l[-1])\r\nans = \"\"\r\nfor i in range(1, n + 1):\r\n if i in l:\r\n ans += \"O\"\r\n else:\r\n ans += \"o\"\r\nprint(ans)", "f = [1,2]\nfor i in range(17):\n f.append(f[-1]+f[-2])\nn = int(input())\nans = \"\"\nfor i in range(n):\n if i+1 in f:\n ans += \"O\"\n else:\n ans += \"o\"\nprint(ans)", "s = set()\r\ns.add(1)\r\nn = int(input())\r\nf1 = 1\r\nf2 = 1\r\nfor _ in range(n + 1):\r\n f1, f2 = f2, f2 + f1\r\n s.add(f2)\r\n if f2 > n:\r\n break\r\nw = ''\r\nfor i in range(n):\r\n if i + 1 in s:\r\n w += 'O'\r\n else:\r\n w += 'o'\r\nprint(w)\r\n", "n=int(input())\r\ns=set()\r\na,b=0,1\r\nresult=\"\"\r\nfor i in range(0,n):\r\n c=a+b\r\n s.add(c)\r\n a,b=b,c\r\n\"\"\"above code is for set \"\"\"\r\nfor i in range(1,n+1):\r\n if i in s:\r\n result+=\"O\"\r\n else:\r\n result+=\"o\"\r\nprint(result)\r\n\"\"\"actual code\"\"\"", "n = int(input())\r\n\r\ntemp = 1\r\nb = 1\r\nhold = 0\r\nans = [\"o\"]*n\r\n\r\nwhile temp <= n:\r\n ans[temp-1] = \"O\"\r\n hold = temp\r\n temp += b\r\n b = hold\r\n\r\nprint (\"\".join(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\r\n\r\n\r\n \r\n \r\n \r\n\r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n", "n = int(input())\r\nfirst = 1\r\nsecond = 1\r\nnum = second\r\nans = \"\"\r\nfor i in range(1, n+1):\r\n if i == num:\r\n ans += 'O'\r\n first = second\r\n second = num\r\n num = first + second\r\n else:\r\n ans += 'o'\r\nprint(ans)\r\n", "n = int(input())\r\nar = ['o'] * n\r\ni=j=k=1\r\nwhile i<=n:\r\n j,k = k,j+k\r\n if j<=n:ar[j-1] = 'O'\r\n else:break\r\n i+=1\r\nprint(*ar,sep=\"\")", "n=int(input())\r\nfeb=[1,1]\r\na=0\r\nb=1\r\nc=a+b\r\nwhile c<n:\r\n\ta=b\r\n\tb=c\r\n\tc=a+b\r\n\tfeb.append(c)\r\n\r\n\r\nfor i in range(1,n+1):\r\n\tif i in feb:\r\n\t\tprint(\"O\",end=\"\")\r\n\telse:\r\n\t\tprint(\"o\",end=\"\")", "n=int(input())\r\ns=n*['o']\r\ni,j=0,1\r\nwhile i+j<=n:\r\n i,j=j,i+j\r\n s[j-1]='O'\r\nprint(''.join(s))\r\n", "n = int(input())\r\ns = ['o' for _ in range(n)]\r\nf = [1,1]\r\n\r\nwhile True:\r\n\tf.append(f[-1]+f[-2])\r\n\tif f[-1] > n:\r\n\t\tbreak\r\n\r\nfor i in range(n):\r\n\tif i+1 in f:\r\n\t\ts[i] = 'O'\r\nprint(*s,sep='')", "a = int(input())\r\n\r\no = ''\r\nq = [1, 1]\r\nwhile q[-1]<a:\r\n q.append(q[-1]+q[-2])\r\n\r\nfor i in range(1, a+1):\r\n if i in q:\r\n o+='O'\r\n else:\r\n o+='o'\r\nprint(o)\r\n\r\n", "n = int(input())\r\n\r\nif n == 1:\r\n print('O')\r\nelif n == 2:\r\n print('OO')\r\nelse:\r\n fibo = [1,1]\r\n f1 = 1\r\n f2 = 1\r\n for i in range(2,1001):\r\n f2, f1 = f1 + f2, f2\r\n fibo.append(f2)\r\n if f2 > 1000:\r\n break\r\n for i in range(1,n+1):\r\n if i in fibo:\r\n print('O',end='')\r\n else:\r\n print('o',end='')\r\n print()", "\r\nn = int(input())\r\nl = [1]\r\n\r\na = b = 1\r\nr = ''\r\nwhile b < n:\r\n c = a + b\r\n l.append(c)\r\n a = b\r\n b = c\r\n \r\nfor i in range(1 , n + 1):\r\n if i in l:\r\n r += 'O'\r\n else:\r\n r += 'o'\r\n\r\nprint(r)", "n=int(input())\r\ns=\"\"\r\nfib=[0 for i in range(17)]\r\nfib[0]=0\r\nfib[1]=1\r\nfib[2]=1\r\n\r\ni=3\r\n\r\nwhile(fib[i-1]+fib[i-2]<1000):\r\n fib[i]=fib[i-1]+fib[i-2]\r\n i+=1\r\n \r\nfor i in range(1,n+1):\r\n if(i in fib):\r\n s+='O'\r\n else:\r\n s+='o'\r\nprint(s) ", "\r\n\r\nn=int(input())\r\ns=['o']*n\r\na=b=c=1\r\nwhile a<=n:\r\n s[a-1]='O'\r\n c=a\r\n a=b\r\n b=a+c\r\nprint(''.join(s))", "n = int(input())\nfib = [1, 1]\ns = ''\nfor i in range(1, n+1):\n fib.append(fib[i] + fib[i - 1])\nfor i in range(1, n+1):\n if i in fib:\n s += 'O'\n else:\n s += 'o'\nprint(s)", "a,b = 1,2\r\nfibs = {a,b}\r\nfor _ in range(1000):\r\n a,b = b,a+b\r\n fibs.add(b)\r\nn = int(input())\r\ns = ['o'] * n\r\nfor i in range(n):\r\n if i+1 in fibs:\r\n s[i] = 'O'\r\n\r\nprint(''.join(s))", "c=0\nn=int(input())\ns=['o' for i in range(n)]\ns[0]='O'\na=b=1\nd=10\n\nwhile True:\n c=a+b\n a=b\n b=c\n if c<=n:\n s[c-1]='O'\n else:\n break\n \nprint(*s,sep=\"\") \n", "def code8():\r\n n=int(input())\r\n a=1\r\n b=1\r\n c=2\r\n x=[1,1]\r\n while(c<=n):\r\n x.append(c)\r\n c=a+b\r\n a,b=b,c\r\n s=\"\"\r\n for i in range(1,n+1):\r\n if(i in x):\r\n s+=\"O\"\r\n else:\r\n s+=\"o\"\r\n print(s)\r\n \r\n \r\ncode8()\r\n", "n = int(input())\r\nc = ['o']*n\r\na = 1\r\nb = 1\r\nwhile a <= n:\r\n x = a\r\n c[a-1] = 'O'\r\n a = a + b\r\n b = x\r\n \r\nfor i in range (0,len(c)):\r\n print(c[i],end='')", "n = int(input())\r\n\r\nf = [1, 1]\r\nwhile(f[len(f) - 1] <= n):\r\n f.append(f[len(f) - 1] + f[len(f) - 2])\r\n\r\nf = f[:-1]\r\ns = ['o'] * n\r\nfor i in f:\r\n s[i - 1] = 'O'\r\n \r\nprint(''.join(s))", "n = int(input())\r\ndp = []\r\na,b = 1,1\r\nfor i in range(1000):\r\n x = a + b\r\n dp.append(a)\r\n\r\n a = b\r\n b = x\r\n\r\nfor i in range(1,n+1):\r\n if i in dp:\r\n print('O',end='')\r\n else:\r\n print('o',end='')", "# for testCase in range(int(input())):\n# n ,x = map(int ,input().split())\n# print(x*2)\nn = int(input())\nlast = cur = 1\nans = \"\"\nn += 1\nfor i in range(1 ,n):\n if i == cur:\n tmp = cur\n cur += last\n last = tmp\n ans += 'O'\n else:\n ans += 'o'\nprint(ans)\n", "# import sys\r\n# sys.stdin=open(\"input.in\",\"r\")\r\nn=int(input())\r\na,b=1,1\r\nfor i in range(1,n+1):\r\n\tif i==b:\r\n\t\ta,b=b,a+b\r\n\t\tprint(\"O\",end=\"\")\r\n\telse:\r\n\t\tprint(\"o\",end=\"\")", "import math\r\ndef checkpf(n):\r\n if int(math.sqrt(n)+0.5)**2==n:\r\n return True\r\n else:\r\n return False\r\n\r\n\r\ndef checkFibonacci(n):\r\n if checkpf(5*n**2 +4) or checkpf(5*n**2 -4):\r\n return True\r\n else:\r\n return False\r\n\r\nn=int(input())\r\ns=\"\"\r\n\r\nfor i in range(1,n+1):\r\n if checkFibonacci(i):\r\n s=s+\"O\"\r\n else:\r\n s=s+\"o\"\r\n\r\nprint(s)", "fib = [1, 1]\r\nfor i in range(20):\r\n fib.append(fib[-1]+fib[-2])\r\nd = {}\r\nfor i in fib: d[i] = True\r\nn = int(input())\r\nfor i in range(1, n+1):\r\n try:\r\n if d[i]==True: print('O', end='')\r\n except: print('o', end='')\r\nprint()\r\n", "n = int(input())\r\nf,g = 1,1\r\nfor i in range(1,n+1):\r\n if f == i:\r\n print('O',end='')\r\n f,g = g+f,f\r\n else:\r\n print('o',end='')", "from math import sqrt\r\n\r\nis_fib = lambda n: True if sqrt(5 * (n**2) - 4) % 1 == 0 or sqrt(5 * (n**2) + 4) % 1 == 0 else False\r\n\r\nn = int(input())\r\nfor i in range(1, n + 1):\r\n print('O', end = '') if is_fib(i) else print('o', end = '')", "import collections\r\nn = int(input())\r\ndp = [0, 1] + [0] * 50\r\nfor i in range(2, 52):\r\n dp[i] = dp[i - 1] + dp[i - 2]\r\nd = collections.Counter(dp)\r\nans = \"\"\r\nfor i in range(1, n + 1):\r\n if i in d:\r\n ans += \"O\"\r\n else:\r\n ans += 'o'\r\nprint(ans)\r\n\r\n\r\n", "n = int(input())\r\ns = ''\r\ndp = [-1]*1000\r\ndp[0] = 1\r\ndp[1] = 1\r\nfor i in range(2, 500):\r\n dp[i] = dp[i-1]+dp[i-2]\r\n if dp[i]>=n:\r\n break\r\n\r\nfor i in range(1, n+1):\r\n if i in dp:\r\n s+=\"O\"\r\n else:\r\n s+=\"o\"\r\nprint(s)", "\r\nn = int(input())\r\n\r\nfib = [0, 1]\r\nk = 1\r\nm = 1\r\n\r\nwhile fib[m] < n:\r\n\r\n l = fib[m] + fib[m - 1]\r\n fib.append(l)\r\n m += 1\r\n\r\nfor i in range(1, n+1):\r\n\r\n if i in fib:\r\n print(\"O\", end=\"\")\r\n else:\r\n print(\"o\", end=\"\")\r\n\r\n\r\n\r\n", "# return string where str[i] is 'O' if i is fibonachi number else str[i] is 'o'\r\ndef build_string(n: int) -> str:\r\n f1 = f2 = 1\r\n s = 'O'\r\n\r\n if n < 3:\r\n return 'O' * n\r\n\r\n for i in range(2, n+1):\r\n if i == f1+f2:\r\n s += 'O'\r\n new_f2 = f1+f2\r\n f1 = f2\r\n f2 = new_f2\r\n else:\r\n s += 'o'\r\n \r\n return s\r\n\r\nn = int(input())\r\n\r\nprint(build_string(n))\r\n", "nm = ['o'] * int(input())\r\n\r\nfa, fb = 0, 1\r\n\r\nwhile fb <= len(nm):\r\n nm[fb - 1] = 'O'\r\n fa, fb = fb, fa + fb\r\n\r\nprint (''.join(nm))\r\n", "n=int(input())\r\na,b=1,2\r\ns='O'\r\nfor i in range(2,n+1):\r\n if(b==i):\r\n a,b=b,a+b\r\n s=s+'O'\r\n else:\r\n s=s+'o'\r\nprint(s)", "f=[1,1]\r\ni=2\r\nfr=0\r\nwhile fr<=900:\r\n fr=f[i-2]+f[i-1]\r\n i+=1\r\n f.append(fr)\r\nn=int(input())\r\nfor i in range(1,n+1):\r\n if f.count(i)>0:\r\n print('O',end=\"\")\r\n else:\r\n print(\"o\",end=\"\")", "import sys\r\nfrom math import sqrt, floor, factorial\r\nfrom collections import deque, Counter\r\ninp = sys.stdin.readline\r\nread = lambda: list(map(int, inp().strip().split()))\r\ndef gcd(a, b):\r\n\tmini = min(a,b)\r\n\tmaxi = max(a,b)\r\n\twhile maxi % mini != 0:\r\n\t\tmaxi, mini = mini, maxi%mini\r\n\treturn(mini)\r\n\r\ndef solve():\r\n\tn = int(inp()); ans = \"\"\r\n\ta, b = 1, 1\r\n\tfor i in range(1, n+1):\r\n\t\tif b == i:ans+=\"O\"; t = b; b=a+b;a=t\r\n\t\telse:ans += \"o\"\r\n\tprint(ans)\r\n\r\nif __name__ == \"__main__\":\r\n\tsolve()", "import math\r\n# # for _ in range(int(input())):\r\n# # int(input())\r\n# # list(map(int,input().split()))\r\n\r\n# for _ in range(int(input())):\r\nn = int(input())\r\nf1=1\r\nf2= 2\r\nf3 = f1+f2\r\ns=\"OO\"\r\nif n == 1:\r\n print(\"O\")\r\nelif n == 2:\r\n print(\"OO\")\r\nelse:\r\n for i in range(3,n+1):\r\n if i == f3:\r\n s = s +\"O\"\r\n f1 = f2\r\n f2 = f3\r\n f3 = f1+f2\r\n else:\r\n s = s+\"o\"\r\n print(s)", "#print(\" \".join(map(str, r)))\r\nr = int(input())\r\nm = \"O\"\r\ns=[]\r\nif r == 1:\r\n print (\"O\")\r\nelif r == 2:\r\n print(\"OO\")\r\n\r\nelse:\r\n s.append(1)\r\n s.append(1)\r\n for i in range(2, r+1):\r\n a = s[i-1] + s[i-2]\r\n s.append(a)\r\n if i in s:\r\n m += \"O\"\r\n else:\r\n m += \"o\"\r\n print(m)\r\n\r\n\r\n\r\n\r\n", "n=int(input())\r\nf1=0\r\nf2=1\r\ns=[]\r\nfor i in range(n+1):\r\n sum=f1+f2\r\n s.append(sum)\r\n f1=f2\r\n f2=sum\r\nfor i in range(1,n+1):\r\n if i in s:\r\n print('O',end=\"\")\r\n else:\r\n print('o',end=\"\")", "n = int(input())\r\ns =\"\"\r\nl =[]\r\nfib=0\r\nf1,f2=1,1\r\nl.append(f1)\r\nl.append(f2)\r\nwhile(fib<=n):\r\n fib = f1+f2\r\n l.append(fib)\r\n f1=f2\r\n f2=fib\r\n \r\nfor i in range(1,n+1):\r\n if(i in l):\r\n s=s+'O'\r\n else:\r\n s=s+'o'\r\nprint(s)\r\n ", "from sys import stdin, stdout\r\nn=int(stdin.readline())\r\nf=[]\r\nf.append(0)\r\nf.append(1)\r\nfor i in range(2,18):\r\n f.append(f[i-1]+f[i-2])\r\ns=\"\"\r\nfor i in range(1,n+1):\r\n if(i in f):\r\n s+=\"O\"\r\n else:\r\n s+=\"o\"\r\nprint(s)\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n", "n=int(input())\r\na=[1,1]\r\nk=1\r\nwhile(k==1):\r\n if n<=a[-1]:\r\n k=0\r\n break \r\n a.append(a[-1]+a[-2])\r\ns=''\r\nfor i in range(1, n+1):\r\n if i in a:\r\n s+='O'\r\n else:\r\n s+='o'\r\nprint(s)", "fibonacci = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]\r\n\r\nn = int(input())\r\n\r\noutput = \"\"\r\n\r\nfor i in range(1, n + 1):\r\n \r\n if i in fibonacci:\r\n output += \"O\"\r\n else:\r\n output += \"o\"\r\n \r\nprint(output)", "n = int(input())\r\n\r\nlst = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]\r\n\r\nans = \"\"\r\nfor i in range(n):\r\n if i + 1 in lst:\r\n ans += \"O\"\r\n else:\r\n ans += \"o\"\r\n\r\nprint(ans)\r\n", "n=int(input())\r\na=0\r\nb=1\r\nc=[]\r\nfor i in range(n):\r\n c.append(a+b)\r\n a=b\r\n b=c[i]\r\nans=\"\"\r\nfor j in range(n):\r\n if j+1 in c:\r\n ans=ans+'O'\r\n else:\r\n ans=ans+'o'\r\nprint(ans)", "n = int(input())\r\nfib = [1, 1]\r\nfib_set = set()\r\nfib_set.add(1)\r\nwhile fib[-1] < n:\r\n fib.append(fib[-1] + fib[-2])\r\n fib_set.add(fib[-1])\r\ns = ''\r\nfor i in range(1, n + 1):\r\n if i in fib_set:\r\n s += 'O'\r\n else:\r\n s += 'o'\r\nprint(s)\r\n", "n=int(input())\r\nres=['o']*n\r\nfirst=1\r\nsecond=1\r\nwhile(second<=n):\r\n res[second-1]='O'\r\n t=first+second\r\n first=second\r\n second=t\r\nprint(''.join(res))", "n = int(input())\r\n\r\nfibList = [1,1]\r\n\r\nwhile fibList[len(fibList)-1] <= n:\r\n fibList.append(sum(fibList[-2:]))\r\n\r\ncurrent = 1\r\n\r\nstring = ''\r\n\r\nfor i in range(n):\r\n if i+1 == fibList[current]:\r\n string += 'O'\r\n current += 1\r\n else:\r\n string += 'o'\r\n\r\nprint(string)\r\n", "result=\"\"\r\nf1=1\r\nf2=1\r\nfor i in range(1,1+int(input())):\r\n if f2==i:\r\n result+=\"O\"\r\n f1,f2=f2,f1+f2\r\n else:\r\n result+=\"o\"\r\nprint(result)\r\n", "n=int(input())\r\nar=[1,1]\r\nwhile(ar[-1]<n):\r\n ar.append(ar[-1]+ar[-2])\r\nfor i in range(1,n+1):\r\n if i in ar:\r\n print(\"O\",end='')\r\n else:\r\n print(\"o\",end='')\r\n \r\n", "def fib(n):\r\n li = [0,1]\r\n a = 0\r\n b = 1 \r\n for i in range(n):\r\n a,b = b,a+b \r\n if b<=n:\r\n li.append(b)\r\n else:\r\n return li \r\n return li\r\n\r\nn = int(input())\r\nli1 = fib(n)\r\nfor i in range(1,n+1):\r\n if i in li1:\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")\r\n\r\n ", "n=int(input())\r\na=[1,1]\r\nl=[]\r\nfor i in range(2,16):\r\n x=a[i-2]+a[i-1]\r\n a.append(x)\r\nfor i in range(n):\r\n if (i+1) in a:\r\n l.append(\"O\")\r\n else:\r\n l.append(\"o\")\r\nfinal=\"\".join(l)\r\nprint(final) ", "# A. Eleven\n\ndef fib_numbers(n):\n if n == 0:\n return 0\n f = [0, 1]\n for i in range(2, n+1):\n f.append(f[i-1] + f[i-2])\n return f\n\n\nn = int(input())\nf_nums = fib_numbers(n+1)\noutput = ['O' if i in f_nums else 'o' for i in range(1, n+1)]\nprint(''.join(output))\n", "# print(\"Input n\")\nn = int(input())\n\nfiblist = [1, 1]\ncurrentfib = 1\noneback = 1\ntwoback = 1\n\nwhile currentfib < 2000:\n currentfib = oneback + twoback\n fiblist.append(currentfib)\n twoback = oneback\n oneback = currentfib\n\nanswer = ''\nfor i in range(1, n+1):\n if i in fiblist:\n answer += \"O\"\n else:\n answer += \"o\"\nprint(answer)\n \n \n \n", "def solve():\r\n\tls = ['O'] + ['o']*999\r\n\tf = s = 1\r\n\twhile s<=1000:\r\n\t\tt = s; s += f; f = t\r\n\t\tif s<= 1000: ls[s-1] = 'O'\r\n\tfor i in range(int(input())):\r\n\t\tprint(ls[i],end='')\r\nsolve()", "\r\nif __name__ == \"__main__\":\r\n t = int(input())\r\n lastfib=1\r\n nextfib=1\r\n for i in range(1,t+1):\r\n if(i==nextfib):\r\n print(\"O\",end='')\r\n t = nextfib + lastfib\r\n lastfib = nextfib\r\n nextfib=t\r\n else:\r\n print(\"o\",end='')\r\n\r\n\r\n", "n=int(input())\r\ns=['o']*(n)\r\na,b=0,1\r\nwhile b<=n:\r\n s[b-1]='O'\r\n a,b=b,a+b\r\nprint(''.join(s))", "n = int(input())\r\nans = ['o'] * n\r\nb = a = 1\r\nwhile b <= n:\r\n ans[b-1] = 'O'\r\n a, b = b, a+b\r\nprint(''.join(ans))", "def main(n):\r\n f = [1,1]\r\n mainstr = ''\r\n for i in range(2,n+1):\r\n num = f[i-2]+f[i-1]\r\n f.append(num)\r\n\r\n for num in range(1,n+1):\r\n if num in f:\r\n mainstr+='O'\r\n else:\r\n mainstr+='o'\r\n return mainstr\r\n\r\nprint(main(int(input())))", "n = int(input())\nf = [1, 1]\nfor i in range(n):\n l = len(f)\n f.append(f[l-2]+f[l-1])\nans = \"\"\nfor i in range(n):\n if f.count(i+1)!=0:\n ans+='O'\n else:\n ans+='o'\nprint(ans)", "a=[1,1]\r\nfor i in range(2,16):\r\n a.append(a[i-1]+a[i-2])\r\nn=int(input())\r\ns=''\r\nfor i in range(1,n+1):\r\n if i in a:\r\n s+='O'\r\n else:\r\n s+='o'\r\nprint(s)", "a=int(input())\r\nj=1\r\nc=[]\r\nfor i in range(a):\r\n if i==0:\r\n h=1\r\n c.append(h)\r\n else:\r\n if h+j<=a:\r\n c.append(j+h)\r\n j=c[i-1]\r\n h=c[i]\r\n else:\r\n break\r\nfor i in range(a):\r\n if (i+1) in c:\r\n print('O',end='')\r\n else:\r\n print('o',end='')", "n=int(input())\r\na=[1,1]\r\nwhile a[-1]<=n:\r\n\ta.append(a[-1]+a[-2])\r\nfor x in range(1,n+1):\r\n\tif x in a:print(\"O\",end=\"\")\r\n\telse:print(\"o\",end=\"\")", "l1=[1,1]\r\ns1=\"\"\r\nn=int(input())\r\nfor i in range (n):\r\n l1.append(l1[i]+l1[i+1])\r\n if(l1[i]+l1[i+1]>n):\r\n break\r\nfor i in range (n):\r\n if(i+1 not in l1):\r\n s1+=\"o\"\r\n else:\r\n s1+=\"O\"\r\nprint(s1)", "n = int(input())\r\n\r\nfib = []\r\nfib.append(1)\r\nfib.append(1)\r\nfor i in range(2, n + 1):\r\n if fib[i - 1] + fib[i - 2] > n:\r\n break\r\n fib.append(fib[i - 1] + fib[i - 2])\r\n\r\nname = [\"o\" for i in range(n)]\r\nfor i in range(len(fib)):\r\n name[fib[i] - 1] = \"O\"\r\n\r\nprint(*name, sep=\"\")\r\n", "def fib(n):\r\n a,b = 1,2\r\n fibo = []\r\n while(a<=n):\r\n fibo.append(a)\r\n a,b = b,a+b\r\n return fibo\r\n \r\nn = int(input())\r\nans = \"\"\r\nfor i in range(1,n+1):\r\n if i in fib(n):\r\n ans+='O'\r\n else:\r\n ans+='o'\r\nprint(ans)\r\n ", "# https://codeforces.com/problemset/problem/918/A\r\n\r\n\r\nn = int(input())\r\n\r\na, b = 1, 2\r\ns = set()\r\n\r\nwhile a <= n+1:\r\n s.add(a)\r\n a, b = b, a+b\r\n\r\n\r\nfor i in range(1, n+1):\r\n if i in s:\r\n print(\"O\", end='')\r\n else:\r\n print('o', end=\"\")\r\n\r\n\r\n\r\n", "if __name__ == \"__main__\":\r\n\tn = int(input())\r\n\tb, a = 1, 2\r\n\tres = []\r\n\tres.append(b); res.append(a)\r\n\r\n\twhile a < n and b < n:\r\n\t\tc = a + b\r\n\t\tb = a; a = c\r\n\t\tres.append(c)\r\n\r\n\tstring = \"\"\r\n\tfor i in range(1, n+1):\r\n\t\tif i in res:\r\n\t\t\tstring += 'O'\r\n\t\telse:\r\n\t\t\tstring += 'o'\r\n\r\n\tprint(string)\r\n\r\n", "def solve():\r\n need = [1, 1]\r\n \r\n while need[-1] <= 1000:\r\n need.append(need[-1] + need[-2])\r\n \r\n result = \"\"\r\n \r\n for i in range(1, int(input()) + 1):\r\n if i in need:\r\n result += 'O'\r\n else:\r\n result += 'o'\r\n \r\n print(result)\r\n \r\n \r\nif __name__ == \"__main__\":\r\n solve()\r\n ", "a = int(input())\r\ns = \"\"\r\nn = 2\r\nn2 = 1\r\nfor i in range(1,a+1):\r\n if i == 1 or i == 2:s+=\"O\"\r\n elif n + n2 == i:\r\n s+=\"O\"\r\n n2 = n\r\n n = i\r\n else:s+=\"o\"\r\nprint(s)", "a=int(input())\r\nfib=[1,1]\r\nfor i in range(1,1000):\r\n fib.append(fib[i]+fib[i-1])\r\nfib=set(fib)\r\nans=''\r\nfor i in range(1,a+1):\r\n ans+=('O' if i in fib else 'o')\r\nprint(ans)", "n=1005\r\nf3=0\r\nf1=0\r\nf2=1\r\nlist1=[]\r\n #print(\"0 1\",end=\" \")\r\nwhile (f3<=n):\r\n #print(f3,end=\" \")\r\n list1.append(f3)\r\n f1=f2\r\n f2=f3\r\n f3=f1+f2\r\neleven=int(input())\r\nfor i in range(1,eleven+1):\r\n if i in list1:\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")\r\nprint(\"\") \r\n\r\n\r\n", "n = int(input())\r\n\r\nf = [1, 2]\r\nfor _ in range(100):\r\n\tf.append(f[-1] + f[-2])\r\n\r\ns = ''\r\nfor i in range(1, n + 1):\r\n\tif i in f:\r\n\t\ts += 'O'\r\n\telse:\r\n\t\ts += 'o'\r\n\r\nprint(s)\r\n", "n=int(input())\r\nlastfib=1\r\nplastfib=0\r\nfor i in range(1,n+1):\r\n if i==lastfib+plastfib:\r\n plastfib=lastfib\r\n lastfib=i\r\n print('O',end='')\r\n else:\r\n print('o',end='')", "n = int(input())\r\nfib = [1, 1]\r\ns = \"\"\r\nnum = 0\r\n\r\nfor i in range(n):\r\n num = num + 1\r\n fib.append(fib[-1] + fib[-2])\r\n if num in fib:\r\n s = s + \"O\"\r\n else:\r\n s = s + \"o\"\r\n\r\nprint(s)", "n=int(input())\r\na=b=1\r\nch=\"\"\r\nfor i in range(n):\r\n if(i+1==b):\r\n ch=ch+'O'\r\n x=b\r\n b=b+a\r\n a=x\r\n else:\r\n ch=ch+'o'\r\nprint(ch)\r\n \r\n", "n = int(input())\r\n\r\nans = ['o'] * n\r\na = b = 1\r\n\r\nwhile b <= n:\r\n ans[b - 1] = 'O'\r\n a, b = b, a + b\r\n\r\nprint(*ans, sep='')", "n=int(input())\r\nf=[1,1]\r\nwhile f[-1]<=n:\r\n f.append(f[-1]+f[-2])\r\nf=f[:-1]\r\na=['o' for i in range(n)]\r\nfor i in f:\r\n a[i-1]='O'\r\nprint(*a,sep='')", "# Codeforces 918A - Eleven\n\ndef fib(n):\n a = 1\n b = 1\n ls = [a, b]\n\n while (a + b <= n):\n ls.append(a + b)\n a, b = b, a + b\n\n return ls\n\ndef bin_search(arr, num):\n low = 0\n high = len(arr) - 1\n\n while (low <= high):\n mid = int((low + high) / 2)\n\n if (arr[mid] == num):\n return mid\n elif (arr[mid] > num):\n high = mid - 1\n\n else:\n low = mid + 1\n\n return -1 # Value doesn't exist in array\n\nn = int(input(\"\"))\n\n# Generate the fibonacci sequence up until n\nfibls = fib(n)\n\nfor i in range(1, n + 1, 1):\n if bin_search(fibls, i) != -1:\n print('O', end='')\n\n else:\n print('o', end='')\n\nprint('')\n", "x = int(input())\r\nr = 0\r\ns = 1\r\nz = []\r\nz.append(0)\r\nwhile r<=x:\r\n\tt = r + s\r\n\tr = s\r\n\ts = t\r\n\tz.append(t)\r\nfor i in range(1,x+1):\r\n\tif i in z:\r\n\t\tprint(\"O\",end=\"\")\r\n\telse:\r\n\t\tprint(\"o\",end=\"\")", "n=int(input())\r\nfibo=1\r\na=1\r\nb=1\r\nname=['o']*n\r\nname[0]='O'\r\nwhile(1):\r\n fibo=a+b\r\n if(fibo>n):\r\n break\r\n name[fibo-1]='O'\r\n a=b\r\n b=fibo\r\n# print(name)\r\ns=''.join(name)\r\nprint(s)\r\n\r\n\r\n ", "n = int(input())\r\nb = 1\r\na = b\r\nfor i in range(1, n + 1):\r\n\tif i == a:\r\n\t\tprint('O', end = '')\r\n\t\tc = b\r\n\t\tb = a\r\n\t\ta += c\r\n\telse:\r\n\t\tprint('o', end = '')", "n=int(input())\r\ns=[\"o\"]*n\r\na=b=1\r\nwhile b<=n:\r\n s[b-1]=\"O\"\r\n aux=a\r\n a=b\r\n b+=aux\r\n #a,b=b,a+b\r\nprint(\"\".join(s))", "n = int(input())\r\nm = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]\r\nfor i in range(1, n+1):\r\n if i in m:\r\n print('O', end='')\r\n else:\r\n print('o', end='')", "def fibbonaci(n):\r\n v=[]\r\n n1=1\r\n n2=2\r\n while n1<=n:\r\n v.append(n1)\r\n temp=n2\r\n n2=n1+n2\r\n n1=temp\r\n return(v)\r\n\r\ndef namer(n):\r\n v=fibbonaci(n)\r\n restr=\"o\"*n\r\n for i in v:\r\n restr=restr[:i-1:]+\"O\"+restr[i::]\r\n return(restr)\r\na=int(input())\r\nprint(namer(a))", "n=int(input())\r\nnum=['o']*n\r\nnum[0]='O'\r\nm1=n1=1\r\nwhile m1+n1-1<n:\r\n num[m1+n1-1]='O'\r\n c=n1\r\n n1=m1+n1\r\n m1=c\r\nprint(*num,sep='')", "\r\nn=int(input())\r\n\r\n#fibonacci\r\ndef fib(n):\r\n\tglobal s\r\n\ts=[]\r\n\ta=1\r\n\tb=1\r\n\tfor i in range(n+1):\r\n\t\ts.append(a)\r\n\t\ta,b=b,a+b\r\n\t\t\r\nfib(n)\r\n\r\nfor i in range(1,n+1):\r\n\tif(i in s):\r\n\t\tprint(\"O\",end=\"\")\r\n\telse:\r\n\t\tprint(\"o\",end=\"\")\r\n", "N = int(input())\r\nstr1 = \"\"\r\nfor i in range(1,N+1):\r\n f3 = 0\r\n f1 = 1\r\n f2 = 1\r\n# 0 and 1 both are fibonacci numbers\r\n if (i == 0 or i == 1):\r\n str1+=\"O\"\r\n \r\n else:\r\n # generating the fibonacci numbers until the generated number is less than N\r\n while f3 < i:\r\n f3 = f1 + f2\r\n f2 = f1\r\n f1 = f3\r\n if f3 == i:\r\n str1+=\"O\"\r\n else:\r\n str1+=\"o\"\r\nprint(str1)", "import sys\r\ninput = sys.stdin.readline\r\nfrom math import comb\r\n\r\ndef prefixsum2D(arrf,m,n):\r\n # vertical prefixsum\r\n for j in range(n):\r\n for i in range(1, m):\r\n arrf[i][j] += arrf[i - 1][j]\r\n \r\n # horizontal prefixsum\r\n for i in range(m):\r\n for j in range(1, n):\r\n arrf[i][j] += arrf[i][j - 1]\r\n \r\n# def diagonalOrder(arr, n, m,answers):\r\n \r\n# ans = [[] for i in range(n + m - 1)]\r\n \r\n# for i in range(m):\r\n# for j in range(n):\r\n# ans[i + j].append(arr[j][i])\r\n# k = 0\r\n# for i in range(len(ans)):\r\n# for j in range(len(ans[i])):\r\n# k += 1\r\n# answers[k] = ans[i][j]\r\n# if k>= comb(2023,2):\r\n# break\r\n# if k >= comb(2023,2):\r\n# break\r\nROW = COL = 2023\r\n\r\ndef diagonalOrder(matrix,answers):\r\n p = 1\r\n # There will be ROW+COL-1 lines in the output\r\n for line in range(1, (ROW + COL)):\r\n # Get column index of the first element\r\n # in this line of output. The index is 0\r\n # for first ROW lines and line - ROW for\r\n # remaining lines\r\n start_col = max(0, line - ROW)\r\n \r\n # Get count of elements in this line.\r\n # The count of elements is equal to\r\n # minimum of line number, COL-start_col and ROW\r\n count = min(line, (COL - start_col), ROW)\r\n \r\n # Print elements of this line\r\n for j in range(0, count):\r\n answers[p] = (matrix[min(ROW, line) - j - 1][start_col + j])\r\n p += 1\r\n if p >= comb(2023,2):\r\n break\r\n if p>=comb(2023,2):\r\n break\r\narr = [1,1]\r\nfor i in range(2,9000):\r\n arr.append(arr[i-1]+arr[i-2])\r\narr = set(arr)\r\nt = 1 #int(input().strip())\r\nfor _ in range(t):\r\n n = int(input())\r\n ans = []\r\n for i in range(1,n+1):\r\n if i in arr:\r\n ans.append(\"O\")\r\n else:\r\n ans.append(\"o\")\r\n print(''.join(ans))", "print('OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooo'[:int(input())])", "n=int(input())\r\n\r\nterm = [0]*1001\r\ndef fib(n):\r\n if n <= 2:\r\n return 1\r\n if term[n] != 0:\r\n return term[n]\r\n else:\r\n term[n] = fib(n - 1) + fib(n - 2)\r\n return term[n]\r\nfibx=[]\r\ntemp=0\r\ni=0\r\nwhile(temp<n):\r\n i=i+1\r\n temp=fib(i)\r\n fibx.append(temp)\r\n\r\n\r\nans=[]\r\nfor i in range(1,n+1):\r\n if i in fibx:\r\n ans.append(\"O\")\r\n else:\r\n ans.append(\"o\")\r\nprint(''.join(ans))\r\n\r\n\r\n\r\n", "x=int(input())\r\na=['o' for i in range(x)]\r\nc=[0,1,1]\r\nn=1\r\nwhile c[n+1]<=x:\r\n\ta[c[n+1]-1]='O'\r\n\tc.append(0)\r\n\tn+=1\r\n\tc[n+1]=c[n]+c[n-1]\r\nprint(*a,sep=\"\")", "def fibonacci(max):\n a, b = 1, 2\n arr = []\n while a < max:\n arr.append(a)\n a, b = b, a + b\n return arr\n\nn = int(input())\nf = fibonacci(n+1)\nfor i in range(1,n+1):\n if i in f:\n print('O', end='')\n else:\n print('o', end='')\n", "n=int(input())\r\nfibbo=list()\r\nfibbo.append(1)\r\npoint=0\r\nflen=0\r\nf2=1\r\nname=\"\"\r\ni=1\r\nwhile i<=n:\r\n if i==fibbo[point]:\r\n name+=\"O\"\r\n point+=1\r\n else:\r\n name+=\"o\"\r\n\r\n x=fibbo[flen]\r\n if x<=n:\r\n f2+=x\r\n fibbo.append(f2)\r\n f2=x\r\n flen+=1\r\n i+=1\r\nprint(name)\r\n", "import sys\r\nimport math\r\nimport heapq\r\nimport string\r\nfrom collections import defaultdict,Counter,deque\r\n \r\ndef I():\r\n return input()\r\n \r\ndef II():\r\n return int(input())\r\n \r\ndef MII():\r\n return map(int, input().split())\r\n \r\ndef LI():\r\n return list(input().split())\r\n \r\ndef LII():\r\n return list(map(int, input().split()))\r\n \r\ndef GMI():\r\n return map(lambda x: int(x) - 1, input().split())\r\n \r\ndef LGMI():\r\n return list(map(lambda x: int(x) - 1, input().split()))\r\n \r\ndef WRITE(out):\r\n return print('\\n'.join(map(str, out)))\r\n \r\ndef WS(out):\r\n return print(' '.join(map(str, out)))\r\n \r\ndef WNS(out):\r\n return print(''.join(map(str, out)))\r\n\r\n'''\r\n T W TH F\r\n-1 +1 -1 +1\r\n\r\n1 2 \r\n3 4\r\n\r\nall f1 same = 1\r\n\r\n\r\ndict of numbers [1,n] -> [set number 1, set2, etc.]\r\n\r\n[]\r\n[1]\r\n[2]\r\n[1,2]\r\n[3]\r\n[1,3]\r\n[2,3]\r\n[1,2,3]\r\n\r\n'''\r\n\r\n# sys.stdin = open(\"backforth.in\", \"r\")\r\n# sys.stdout = open(\"backforth.out\", \"w\")\r\ninput = sys.stdin.readline\r\n\r\ndef solve():\r\n t = II()\r\n fib = [1,1]\r\n while fib[-1] < 2000:\r\n fib.append(fib[-1] + fib[-2])\r\n fib = set(fib)\r\n\r\n ans = []\r\n for i in range(1,t+1):\r\n if i in fib:\r\n ans.append('O')\r\n else:\r\n ans.append('o')\r\n WNS(ans)\r\n\r\nsolve()", "n = int(input())\r\n\r\nvis = []\r\na ,b = 1, 1\r\nfor i in range(55):\r\n vis.append(b)\r\n a,b = b,a+b\r\ns = \"\"\r\nfor i in range(n):\r\n if vis.count(i+1):\r\n s += 'O'\r\n else :\r\n s += 'o'\r\nprint(s)", "n=int(input())\r\na,b=0,1\r\nc=0\r\nl=[\"o\"]*n\r\nwhile(c<=n):\r\n c=a+b\r\n a,b=b,c\r\n if(c<=n):\r\n l[c-1]=\"O\"\r\n \r\nprint(\"\".join(l))\r\n", "a = [1, 2]\r\ni = 0\r\ns = ''\r\nwhile i < 1000:\r\n i = a[-1]+a[-2]\r\n a.append(i)\r\nfor i in range(1, int(input())+1):\r\n if i in a:\r\n s += \"O\"\r\n else:\r\n s += \"o\"\r\nprint(s)\r\n", "a=[1, 1]\r\nn=int(input())\r\nwhile a[-1]<=n:\r\n a.append(a[-1]+a[-2])\r\nfor i in range(1, n+1):\r\n if i in a: print('O', end='')\r\n else: print('o', end='')", "n = int(input())\nres = [\"o\"] * n\na, b = 1, 1\nwhile a <= n:\n res[a - 1] = \"O\"\n a, b = b, a + b\nres = \"\".join(res)\nprint(res)\n", "def fib(limit):\r\n a=[1,2]\r\n while a[-1]<=limit:\r\n a.append(a[-1]+a[-2])\r\n return a\r\n\r\nn=int(input())\r\nlst=fib(n)\r\ns=\"\"\r\npos=0\r\nfor i in range(1,n+1):\r\n if lst[pos]==i:\r\n pos+=1\r\n s+=\"O\"\r\n else:\r\n s+=\"o\"\r\nprint(s)", "n=int(input())\r\na,b,c=1,2,0\r\ns=\"\"\r\nfor i in range(1,n+1):\r\n if(i==b):\r\n s=s+\"O\"\r\n c=a+b \r\n a=b \r\n b=c\r\n elif(i==a):\r\n s+=\"O\"\r\n else:\r\n s+=\"o\"\r\nprint(s) \r\n \r\n", "rec = {}\r\ndef fibo(n):\r\n if n in rec.keys():\r\n return rec[n]\r\n if n <= 2:\r\n val = 1\r\n else:\r\n val = fibo(n-1) + fibo(n-2)\r\n rec[n] = val\r\n return val\r\nt= [fibo(item) for item in range(1,1000)]\r\n\r\n\r\na = int(input())\r\nl = [\"O\"]*a\r\nfor item in range(1,a+1):\r\n if item not in t:\r\n l[item-1] = \"o\"\r\nprint(\"\".join(l))", "n = int(input())\r\nfib = ''\r\nf1, f2, fn = 1, 1, 0 \r\ni = 1\r\n\r\nwhile len(fib) <= n:\r\n if i == 1:\r\n fib += 'O'\r\n elif i == 2:\r\n fib += 'O'\r\n else:\r\n fn = f1 + f2\r\n fib += 'O' + ('o' * (fn - 1))\r\n f1 = f2\r\n f2 = fn\r\n i += 1\r\nprint(fib[:n])\r\n \r\n \r\n", "n=int(input())\r\nt=[\"o\"]*(n+1)\r\na=1\r\nb=1\r\nwhile a<=n:\r\n t[a]='O'\r\n a,b=b,a+b\r\nprint(\"\".join(t[1:]))", "l=[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]\r\nx=[]\r\nn=int(input())\r\nfor i in range(1,n+1):\r\n if i in l:\r\n x.append('O')\r\n else:\r\n x.append('o')\r\nprint(''.join(x))", "def read():\r\n\treturn int(input())\r\n\r\nn = read()\r\n\r\nfib = [1, 1]\r\nisFIB = []\r\n\r\nfor i in range(0, 1001): isFIB.append(False)\r\n\r\nisFIB[1] = True\r\nwhile fib[len(fib) - 1] < 1000:\r\n\tfib.append(fib[len(fib) - 1] + fib[len(fib) - 2])\r\n\tif (fib[len(fib) - 1] <= 1000): isFIB[fib[len(fib) - 1]] = True\r\n\r\nans = ''\r\nfor i in range(1, n+1):\r\n\tif isFIB[i]: ans += 'O'\r\n\telse: ans += 'o'\r\n\r\nprint(ans)", "n = int(input())\r\nfor i in range(1, n + 1):\r\n print('O' if i in {1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987} else 'o', end='')\r\n", "def checkFib(n):\n\tif int((5*(n**2) + 4)**0.5) == (5*(n**2) + 4)**0.5 or int((5*(n**2) - 4)**0.5) == (5*(n**2) - 4)**0.5:\n\t\treturn True\n\treturn False\n\t\nn = int(input())\nans = \"\"\nfor i in range(1, n+1):\n\tif checkFib(i):\n\t\tans += \"O\"\n\telse:\n\t\tans += \"o\"\nprint(ans)\t\n", "def solve(t_id):\r\n n = int(input())\r\n f = [1, 1]\r\n while f[-1] + f[-2] <= n:\r\n f.append(f[-1] + f[-2])\r\n ans = ''\r\n for i in range(n):\r\n if (i + 1) in f:\r\n ans += 'O'\r\n else:\r\n ans += 'o'\r\n print(ans)\r\nt = 1\r\n#t = int(input())\r\nfor t_id in range(1, t + 1):\r\n solve(t_id)\r\n t -= 1", "a = int(input())\r\ns = [1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]\r\nfor i in range(1,a+1):\r\n if i in s:\r\n print('O',end='')\r\n else:\r\n print('o',end='')", "n = int(input())\r\na = [0]*20\r\nans =''\r\n\r\na[0]=a[1]=a[2]=1\r\nfor i in range(3, 20):\r\n a[i] = a[i-1]+a[i-2]\r\n\r\nb = [0]*(n+1)\r\nfor i in range(20):\r\n if a[i] <= n:\r\n b[a[i]]=1\r\n\r\nfor i in range(1, n+1):\r\n if b[i] == 1:\r\n ans += 'O'\r\n else:\r\n ans += 'o'\r\n\r\nprint(ans)\r\n \r\n \r\n", "print(''.join([('O' if i in [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987] else 'o') for i in range(1,int(input())+1)]))", "arr = []\r\narr.append(0)\r\narr.append(1)\r\nfor i in range(2,2000):\r\n arr.append(arr[i - 1] + arr[i - 2])\r\n\r\nn = int(input())\r\ns = ''\r\nfor i in range(1,n+1):\r\n if i in arr:\r\n s += 'O'\r\n else:\r\n s += 'o'\r\nprint(s)", "fibo=[]\r\na=0\r\nb=1\r\nfor i in range(16):\r\n\tc=a+b\r\n\ta=b\r\n\tb=c\r\n\tfibo.append(a)\r\nn=int(input())\r\nfor i in range(1,n+1):\r\n\tif i in fibo:\r\n\t\tprint(\"O\",end=\"\")\r\n\telse:\r\n\t\tprint(\"o\",end=\"\")", "n = int(input())\nans = ['o'] * n\nx, y = 1, 1\nwhile y <= n:\n ans[y - 1] = 'O'\n tmp = x + y\n x, y = y, tmp\n\nprint(''.join(ans))", "n=int(input())\r\nname=['o']*n\r\na=b=1\r\nwhile b<=n:\r\n name[b-1]='O';\r\n a,b=b,a+b\r\nprint(''.join(name))", "n = int(input())\r\nfibo = [0, 1]\r\nwhile fibo[-1] < n:\r\n fibo.append(fibo[-1]+fibo[-2])\r\nfibo = set(fibo)\r\nans = \"\"\r\nfor i in range(n):\r\n if i+1 in fibo:\r\n ans += \"O\"\r\n else:\r\n ans += \"o\"\r\nprint(ans)", "import math \r\ndef ps(x): \r\n s = int(math.sqrt(x)) \r\n return s*s == x \r\ndef fibo(c): \r\n return ps(5*c*c + 4) or ps(5*c*c - 4) \r\nn=int(input())\r\nfor i in range(1,n+1):\r\n if(fibo(i)):\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")", "n = int(input())\r\ns = []\r\nFib = [1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]\r\nfor i in range(1,n+1):\r\n if i in Fib:\r\n s.append('O')\r\n else:\r\n s.append('o')\r\n\r\notv=''\r\n\r\nfor i in range(len(s)):\r\n otv = otv + s[i]\r\n\r\nprint(otv)\r\n", "n = int(input())\no = ['o']*(n+1)\no[1] = 'O'\nh, t = 1, 1\nwhile h+t <= n:\n h = h + t\n h, t = t, h\n o[t] = 'O'\no.pop(0)\nprint(*o, sep='')\n", "n=int(input())\r\nL=[1,1]+[0]*(n-1)\r\nfor k in range(2,n+1):\r\n L[k]=L[k-1]+L[k-2]\r\nnombre=[[\"o\",\"O\"][k+1 in L] for k in range(n)]\r\nprint(\"\".join(nombre))", "n = int(input())\narr = ['o']*n\na,b = 0,1\nwhile a+b<=n:\n arr[a+b-1] = 'O'\n a,b = b,a+b\nprint(\"\".join(arr))\n", "import math\r\ndef isPerfectSquare(x):\r\n s = int(math.sqrt(x))\r\n return s * s == x\r\ndef isFibonacci(n):\r\n return isPerfectSquare(5 * n * n + 4) or isPerfectSquare(5 * n * n - 4)\r\nn=int(input())\r\nfor i in range(n):\r\n if (isFibonacci(i+1) == True):\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")\r\n", "n = int(input())\r\ni = 1\r\nd = 1\r\nout = ''\r\nfor j in range(1,n+1):\r\n if j==d:\r\n out+='O'\r\n d = d+i\r\n i = d-i\r\n else:\r\n out+='o'\r\nprint(out)", "fib = [1,1]\r\nn = int(input())\r\nwhile fib[-1] < n:\r\n fib.append(fib[-1] + fib[-2])\r\nnewname = []\r\nfor i in range(n):\r\n if i+1 in fib:\r\n newname.append(\"O\")\r\n else:\r\n newname.append(\"o\")\r\nprint(*newname,sep=\"\")", "def main():\n fibonacci = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]\n n = int(input())\n s = ['o'] * n\n\n i = 0\n while fibonacci[i] <= n:\n s[fibonacci[i] - 1] = 'O'\n i += 1\n\n print(''.join(s))\n\n\nif __name__ == '__main__':\n main()\n", "from math import sqrt\r\n\r\n\r\ndef is_fibonacci(n):\r\n phi = 0.5 + 0.5 * sqrt(5.0)\r\n a = phi * n\r\n return n == 0 or abs(round(a) - a) < 1.0 / n\r\n\r\n\r\ndef new_name(number):\r\n name = list()\r\n for i in range(1, number + 1):\r\n if is_fibonacci(i):\r\n name.append('O')\r\n else:\r\n name.append('o')\r\n return ''.join(name)\r\n\r\n\r\nm = int(input())\r\nprint(new_name(m))\r\n", "n = int(input())\r\na , b = 1 , 1\r\nfor i in range(1 , n + 1):\r\n if i == b:\r\n print(\"O\" , end = \"\")\r\n a , b = b , a + b\r\n else:\r\n print(\"o\" , end = \"\")\r\n", "n = int(input())\r\nlast = 1\r\nf = [1, 1]\r\ni = 2\r\nnn = 0\r\nwhile nn < n:\r\n nn = f[i-1]+f[i-2]\r\n f.append(nn)\r\n i += 1\r\nprint(\"\".join(map(str, ['O' if j in f else 'o' for j in range(1, n+1)])))\r\n", "x = 0\r\ny = 1\r\ni = int(input())\r\nfor u in range(i):\r\n u += 1\r\n if u == x + y:\r\n print('O',end = '')\r\n x = y\r\n y = u\r\n else:\r\n print('o', end = '')", "n=int(input())\r\nfib_terms = [0, 1] \r\nwhile fib_terms[-1] <= n:fib_terms.append(fib_terms[-1] + fib_terms[-2])\r\nfor i in range(1,n+1) :\r\n if i in fib_terms:print(\"O\",end=\"\")\r\n else:print(\"o\",end=\"\")\r\n", "def fibonacci(n):\r\n fib=[1,1]\r\n for i in range(2,n):\r\n next_term=fib[i-1] + fib[i-2]\r\n fib.append(next_term)\r\n \r\n return fib\r\n\r\nfib_list=fibonacci(20)\r\n\r\nn=int(input())\r\ns=''\r\nfor i in range(1,n+1):\r\n if i in fib_list:\r\n s+='O'\r\n else:\r\n s+='o'\r\n\r\nprint(s)", "n = int(input())\r\nfib = [1,1]\r\na = 2\r\nb = \"\"\r\nwhile a <= n:\r\n fib.append(a)\r\n a = fib[-1] + fib[-2]\r\nfor i in range(1,n + 1):\r\n if i in fib:\r\n b += \"O\"\r\n else:\r\n b += \"o\"\r\nprint(b)\r\n", "f = [1, 2]\r\nfor i in range(30):\r\n f.append(f[-1] + f[-2])\r\no = \"\"\r\nn = int(input())\r\nfor i in range(1, n+1):\r\n if i in f:\r\n o += \"O\"\r\n continue\r\n o += \"o\"\r\nprint(o)", "import math\r\ndef isperfectsquare(m):\r\n a = int(math.sqrt(m))\r\n return a*a == m\r\n\r\ndef isfib(n):\r\n return isperfectsquare(5*n*n - 4) or isperfectsquare(5*n*n + 4)\r\n\r\nn = int(input())\r\nname = []\r\nfor i in range(1, n+1):\r\n if isfib(i):\r\n name.append('O')\r\n else:\r\n name.append('o')\r\nprint(''.join(name))", "n=int(input())\r\nx=0\r\ny=1\r\nresult=\"\"\r\nfor i in range(1,n+1):\r\n if((x+y)==i):\r\n result+=\"O\"\r\n x=y\r\n y=i\r\n else:\r\n result+=\"o\"\r\nprint(result)", "n = int(input())\r\narray = [1,1]\r\nwhile array[-1] < n:\r\n array.append(array[-1] + array[-2])\r\n#print(array)\r\nidx = 1\r\nfor i in range(1, n + 1):\r\n if i == array[idx]:\r\n print('O',end = '')\r\n idx += 1\r\n else:\r\n print('o', end = '')", "n = int(input())\r\nlis = ['o']*n\r\nfib =[1,1]\r\nf1 = 1\r\nf2 = 1\r\nfor i in range(n):\r\n f3 = f1 + f2\r\n if f3 > n:\r\n break\r\n fib.append(f3)\r\n f1 = f2\r\n f2 = f3\r\nfor i in fib:\r\n lis[i - 1] = 'O'\r\nans = \"\".join(lis)\r\nprint(ans)", "\r\nn = int(input())\r\nl = [1 , 1]\r\nn1 = 0\r\nwhile n1 < n:\r\n\tl.append(l[-1] + l[-2])\r\n\tn1 = l[-1]\r\nst = ''\r\nfor i in range(1,n+1):\r\n\tif i in l:\r\n\t\tst += 'O'\r\n\telse:\r\n\t\tst += 'o'\r\n\r\nprint(st)", "n = int(input())\r\nres = ''\r\nf = []\r\n\r\nfor i in range(1, n+1):\r\n if i == 1 or i == 2:\r\n res += 'O'\r\n f.append(i)\r\n elif f[-1] + f[-2] == i:\r\n res += 'O'\r\n f.append(i)\r\n else:\r\n res += 'o'\r\n\r\n\r\nprint(res)", "# cf 918 A 800\nn = int(input())\n\nO = ['o'] * n\nf1 = 1\nf2 = 1\nO[0] = 'O'\nwhile True:\n fn = f2 + f1\n if fn > n:\n break\n O[fn - 1] = 'O'\n f1 = f2\n f2 = fn\n\nprint(\"\".join(O))\n\n \n", "def fibo(n):\r\n r = [1, 1]\r\n while r[-1] <= n:\r\n r.append(r[-1] + r[-2])\r\n return set(r)\r\n\r\nn = int(input())\r\nfi = fibo(n)\r\nprint(\"\".join('O' if x in fi else 'o' for x in range(1,n+1)))", "\r\nn = int(input())\r\n\r\na = [1, 2]\r\n\r\nf1 = 1\r\nf2 = 2\r\n\r\ns = ''\r\n\r\nfor i in range(2, n):\r\n\r\n\ta.append(f1 + f2)\r\n\tf1 = f2\r\n\tf2 = a[i]\r\n\r\n\r\nfor i in range(1, n + 1):\r\n\r\n\tif i in a:\r\n\r\n\t\ts += 'O'\r\n\r\n\telse:\r\n\r\n\t\ts += 'o'\r\n\r\nprint(s)\r\n\r\n\r\n", "def fibo(x):\r\n if x<=2:\r\n return x\r\n else:\r\n return fibo(x-1)+fibo(x-2)\r\n\r\n#drivre code\r\nstr1=\"\"\r\nn=(int(input()))\r\nfor j in range(1,n+1):\r\n for i in range(1,n+1):\r\n f=fibo(i)\r\n if f==j:\r\n str1+='O'\r\n break\r\n elif f>j:\r\n str1+='o'\r\n break\r\nprint(str1)\r\n", "N = int(input())+1\r\nfib = set([1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987])\r\nprint(''.join([['o','O'][i in fib] for i in range(1,N)]))", "L = [1, 1]\r\nfor i in range(15):\r\n L += [L[i]+L[i+1]]\r\nn = int(input())\r\nfor i in range(n):\r\n if i+1 in L:\r\n print('O', end='')\r\n else:\r\n print('o', end='')\r\n", "n = int(input())\r\na = [1, 1]\r\nprint('O', end=\"\")\r\nfor i in range(2, n + 1):\r\n a.append(a[i - 2] + a[i - 1])\r\n print('O' if i in a else 'o', end=\"\")", "def ii():\r\n return int(input())\r\ndef ss():\r\n return [x for x in input()]\r\ndef si():\r\n return [int(x) for x in input().split()]\r\ndef mi():\r\n return map(int, input().split())\r\n\r\ns = [\"o\" for _ in range(ii())]\r\na, b = 1, 1\r\nwhile b <= len(s):\r\n s[b - 1] = \"O\"\r\n a, b = b, a + b\r\nprint(\"\".join(s))", "n=int(input())\na=['o']*n\nf1=1\nf2=2\na[f1-1]='O'\nwhile(f2<=n):\n a[f2-1]='O'\n t=f1+f2\n f1=f2\n f2=t\nprint(''.join(a))\n", "n=int(input())\r\nfib=[None]*1000\r\nfib[0]=0\r\nfib[1]=1\r\nfor i in range(2,1000):\r\n fib[i]=fib[i-1]+fib[i-2]\r\n \r\nres=''\r\nfor i in range(1,n+1):\r\n if i in fib:\r\n res+='O'\r\n else:\r\n res+='o'\r\nprint(res)", "n = int(input())\r\nfib = [1,1]\r\n\r\ni = 2\r\n\r\nwhile (fib[i-1] < n):\r\n\r\n fib.append(fib[i-2] + fib[i-1])\r\n i += 1\r\n\r\nname = \"\"\r\n\r\nfor i in range(1, n+1):\r\n\r\n if (i in fib):\r\n\r\n name += \"O\"\r\n\r\n else:\r\n\r\n name += \"o\"\r\n\r\nprint(name)", "from sys import stdin, stdout\r\n \r\nintn = lambda : int(stdin.readline())\r\nstrs = lambda : stdin.readline()[:-1]\r\nlstr = lambda : list(stdin.readline()[:-1])\r\nmint = lambda : map(int, stdin.readline().split())\r\nlint = lambda : list(map(int, stdin.readline().split()))\r\nout = lambda x: stdout.write(str(x)+\"\\n\")\r\nout_ = lambda x: stdout.write(str(x)+\" \")\r\n\r\ndef main():\r\n n = intn()\r\n if n == 1:\r\n out('O')\r\n else:\r\n s = ['o' for _ in range(n)]\r\n f1 = 0\r\n f2 = 1\r\n f = 1\r\n while f<=n:\r\n s[f-1] = 'O'\r\n f = f1 + f2\r\n f1 = f2\r\n f2 = f\r\n \r\n print(*s, sep='')\r\n\r\nif __name__ == \"__main__\":\r\n main()", "\r\nn = int(input())\r\ns = \"\"\r\nmylist = []\r\na, b = 0, 1\r\nwhile a<=n:\r\n mylist.append(a)\r\n a, b = b, a+b\r\n#print(mylist)\r\nfor i in range(1,n+1):\r\n if mylist.count(i):\r\n s += 'O'\r\n else:\r\n s += 'o'\r\nprint(s) \r\n", "fib = [1, 1]\nwhile True:\n next = fib[-1] + fib[-2]\n if next > 1000:\n break\n fib.append(next)\nn = int(input())\nans = ['o'] * n\nfor idx in fib:\n if idx > n:\n break\n ans[idx - 1] = 'O'\nprint(''.join(ans))", "\r\ndef fibo(n):\r\n a, b = 1, 1\r\n d = []\r\n e = ''\r\n while a <= n:\r\n d.append(a)\r\n a, b = b, b + a\r\n\r\n for i in range(1, n+1):\r\n if i in d:\r\n e += 'O'\r\n else:\r\n e += 'o'\r\n return e\r\n\r\nn = int(input())\r\nprint(fibo(n))", "n=int(input())\r\nl=[]\r\nl.append(1)\r\nl.append(1)\r\nfor i in range(2,16):\r\n l.append(l[i-1]+l[i-2])\r\nfor i in range(1,n+1):\r\n if i in l:\r\n print(\"O\",end='')\r\n else:\r\n print(\"o\",end='')\r\n", "n1 = int(input())\r\n\r\nlist1 = []\r\n\r\nlist1 = [1,1]\r\n \r\nb1 = False\r\ntemp = 2\r\nwhile b1==False:\r\n if temp>n1:\r\n break\r\n list1.append(temp)\r\n temp = list1[-1]+list1[-2]\r\n\r\nstr1 = \"\"\r\nfor i in range(n1):\r\n if i+1 in list1:\r\n str1+=\"O\"\r\n else:\r\n str1+=\"o\"\r\nprint(str1)\r\n ", "n = int(input())\r\nn1, n2 = 0, 1\r\nfib = []\r\n\r\nanswer = ''\r\n\r\nfor i in range(n):\r\n current = n1 + n2\r\n n1 = n2\r\n n2 = current\r\n fib.append(n2)\r\n\r\nfor i in range(1, n+1):\r\n if i in fib:\r\n answer += 'O'\r\n else:\r\n answer += 'o'\r\n\r\nprint(answer)\r\n", "a=[1,2]\nwhile a[-1]<=1000:\n a.append(a[-1]+a[-2])\nn=int(input())\nfor i in range(1,n+1):\n if i in a:\n print(\"O\",end='')\n else:\n print(\"o\",end='')\n\n\t \t \t \t\t\t \t\t \t \t\t \t\t \t \t", "n=int(input())\r\nn0=1\r\nn1=2\r\nans=\"\"\r\nfor i in range(1,n+1):\r\n if n0==i or n1==i:\r\n ans+=\"O\"\r\n elif n1+n0==i:\r\n ans+=\"O\"\r\n temp=n1\r\n n1=n1+n0\r\n n0=temp\r\n else:\r\n ans+=\"o\"\r\nprint(ans)\r\n \r\n \r\n", "# import sys\r\n# sys.stdin=open(\"input.in\",'r')\r\n# sys.stdout=open(\"outp.out\",'w')\r\ndef fibonacci(n):\r\n\ta=[0,1]\r\n\tc=0\r\n\ti=1\r\n\twhile(c<=n):\r\n\t\tc=a[i-1]+a[i]\r\n\t\ti+=1\r\n\t\ta.append(c)\r\n\treturn a\t\r\n\r\nn=int(input())\r\nl=fibonacci(n)\r\nfor i in range(1,n+1):\r\n\tif i in l:\r\n\t\tprint('O',end='')\r\n\telse:\r\n\t\tprint('o',end='')\t", "n = int(input())\r\n\r\nlst = ['o']*n\r\ni,j,sum = 0,1,0\r\n\r\nwhile sum<n:\r\n sum = i+j\r\n \r\n if sum>n:\r\n break\r\n \r\n lst[sum-1]='O'\r\n\r\n i=j\r\n j=sum\r\n\r\nst = ''.join(lst)\r\nprint(st)", "l=[1,1]\r\ni=2\r\na=1;b=1\r\nwhile(len(l)<=18):\r\n s=a+b\r\n l.append(s)\r\n a=b;b=s\r\nn=int(input())\r\nans=[]\r\nfor i in range(1,n+1):\r\n if i in l:\r\n ans.append('O')\r\n else:\r\n ans.append('o')\r\nprint(''.join([a for a in ans]))", "n=int(input())\r\ns=1\r\nf=1\r\nd=\"\"\r\nfor i in range(1,n+1):\r\n while s<i:\r\n h=f\r\n f+=s\r\n s=h\r\n if s==i:\r\n d+=\"O\"\r\n else:\r\n d+=\"o\"\r\nprint(d)\r\n", "n = int(input())\r\n\r\ns = ['o'] * n\r\n\r\nfs = [1, 2]\r\nwhile fs[-1] < n:\r\n fs += [fs[-1] + fs[-2]]\r\nfor f in fs:\r\n if f <= n:\r\n s[f - 1] = 'O'\r\n\r\nprint(\"\".join(s)) ", "n = int(input())\r\na = 1\r\nb = 1\r\nc = [1, 1]\r\nwhile a < n and b < n:\r\n a = a+b\r\n c.append(a)\r\n b = a+b\r\n c.append(b)\r\nd = []\r\nfor i in range(1, n+1):\r\n if i in c:\r\n d.append('O')\r\n else:\r\n d.append('o')\r\nprint(''.join(d))", "# H - Eleven\n\nimport string\n\n\nclass Ejercicio:\n\n def handle(self, num):\n result = ''\n fibonacci = self.get_fibonacci(int(num))\n for i in range(1, int(num)+1):\n if i in fibonacci:\n result += 'O'\n else:\n result += 'o'\n return result\n\n def get_fibonacci(self, n):\n a = 1\n b = 1\n result = [a]\n while a <= n:\n aux = a + b\n result.append(aux)\n b = a\n a = aux\n return result\n\nif __name__ == '__main__':\n n = input()\n use_case = Ejercicio()\n result = use_case.handle(num=n)\n print(result)\n\t \t\t\t\t\t\t \t\t\t\t \t \t\t \t\t\t \t\t \t\t", "m = int(input())\r\nn = 16\r\na = 0\r\nb = 1\r\nf=[1]\r\nfor i in range(n-1):\r\n\tc=a+b\r\n\ta=b\r\n\tb=c\r\n\tf.append(c)\r\n\r\nfor i in range(1,m+1):\r\n\tif i in f:\r\n\t\tprint('O',end='')\r\n\telse:\r\n\t\tprint('o',end='')", "fibonacci = [1, 1]\nwhile fibonacci[-1] + fibonacci[-2] < 1000:\n fibonacci.append(fibonacci[-1] + fibonacci[-2])\nfibonacci = set(fibonacci)\n\n\nn = int(input())\n\nnew_name = \"\"\nfor i in range(1, n + 1):\n if i in fibonacci:\n new_name += \"O\"\n else:\n new_name += \"o\"\nprint(new_name)\n", "n = int(input())\r\nans = \"\"\r\na,b = 1,1\r\nfor i in range(n):\r\n if i == b-1:\r\n a,b = b,a + b\r\n ans += 'O'\r\n else:\r\n ans += 'o'\r\nprint(ans)\r\n", "n = int(input())\r\nname = ['o']*n\r\nfibonacci = [1, 1]\r\nwhile fibonacci[-1] <= n:\r\n name[fibonacci[-1]-1] = 'O'\r\n fibonacci.append(fibonacci[-1] + fibonacci[-2])\r\n\r\n\r\nprint(''.join(name))\r\n", "n = int(input())\r\np = []\r\nl = [0,1]\r\na = 0\r\nb = 1\r\ni = 0\r\nwhile i<n:\r\n\tc = a+b\r\n\ta = b\r\n\tb = c\r\n\tl.append(c)\r\n\ti += 1\r\nfor i in range(1,n+1):\r\n\tp.append(i) \r\nst = \"\"\t\r\nfor j in range(len(p)):\r\n\tif p[j] in l:\r\n\t\tst += \"O\"\r\n\telif p[j] not in l:\r\n\t\tst += \"o\"\r\nprint(st)\t\t", "n=int(input())\r\n\r\nfib_terms = [0, 1] \r\nwhile fib_terms[-1] <= n:\r\n fib_terms.append(fib_terms[-1] + fib_terms[-2])\r\n\r\n \r\nfor i in range(1,n+1) :\r\n # L = [fib(k) for k in range(i+2)]\r\n if i in fib_terms:\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")", "'''input\n15\n'''\n\nn = int(input())\n\nf1 = 1\nf2 = 1\n\nl = [f1, f2]\n\nfor i in range(n):\n\tf3 = f1 + f2\n\tl.append(f3)\n\n\tf1, f2 = f2, f3\n\nres = ''\n\nfor i in range(n):\n\tif i+1 in l:\n\t\tres += 'O'\n\telse:\n\t\tres += 'o'\nprint(res)\n\n", "z = int(input())\r\na = [1,1]\r\ns = ''\r\nfor i in range(2,z+1):\r\n a.append(a[i-2]+a[i-1])\r\nfor i in range(1,z+1):\r\n if i in a:\r\n s=s+'O'\r\n else:\r\n s=s+'o'\r\nprint(s)", "def fib(n):\r\n if n==1 or n==0:\r\n return 1\r\n return fib(n-1)+fib(n-2)\r\nl=[]\r\nfor i in range(1,16):\r\n l.append(fib(i))\r\nn=int(input())+1\r\nfor i in range(1,n):\r\n if i in l:\r\n print('O',end=\"\")\r\n else:\r\n print('o',end=\"\")\r\n", "l=[0,1] \r\nfor i in range(2,1001):\r\n\tif l[i-1]>=1000:\r\n\t\tbreak\r\n\tl.append(l[i-1]+l[i-2])\r\nn=int(input())\r\nfor i in range(1,n+1):\r\n\tif i in l:\r\n\t\tprint('O',end='')\r\n\telse:\r\n\t\tprint('o',end='')", "import sys\r\n\r\ndef input():\r\n return sys.stdin.readline().strip()\r\n\r\ndef input_l():\r\n return map(int, input().split())\r\n\r\ndef input_t():\r\n return list(input_l())\r\n\r\ndef main():\r\n print('OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooo'[:int(input())])\r\n\r\nmain()", "l=[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]\r\nrs=\"\"\r\nfor i in range(1,int(input())+1):\r\n if i in l:\r\n rs=rs+\"O\"\r\n else:\r\n rs=rs+\"o\"\r\nprint(rs)", "f1 = 1\r\nf2 = 1\r\ns = set([1])\r\nfn = f1+f2\r\nwhile(fn<=1000):\r\n\ts.add(fn)\r\n\tf1 = f2\r\n\tf2 = fn\r\n\tfn = f2+f1\r\nn = int(input())\r\na = \"\"\r\nfor i in range(1,n+1):\r\n\tif i in s:\r\n\t\ta += \"O\"\r\n\telse:\r\n\t\ta+= \"o\"\r\nprint(a)", "x = 1\r\nz = 1\r\ny = int(input())\r\nprint('O', end='')\r\nfor i in range(2, y+1):\r\n if i == x+z:\r\n print(\"O\", end=\"\")\r\n if x < z:\r\n x = i\r\n else:\r\n z = i\r\n else:\r\n print(\"o\", end=\"\")\r\n", "def fibonacci(n):\n if n == 1 or n == 2:\n return 1\n return fibonacci(n - 1) + fibonacci(n - 2)\n\ntmp = 1\ncurrFib = 0\nfibs = {}\nn = int(input())\n\nwhile(currFib <= n):\n currFib = fibonacci(tmp)\n fibs[currFib] = True\n tmp += 1\n\nfor i in range(1, n + 1):\n if fibs.get(i, False):\n print('O', end='')\n else:\n print('o', end='')\n\nprint()\n\t \t \t\t \t \t\t\t \t\t\t \t\t\t \t\t \t\t", "n=int(input())\r\na=0\r\nb=1\r\n#print(\"O\",end=\"\")\r\nfor i in range(1,n+1):\r\n c=a+b\r\n if(c==i):\r\n a=b\r\n b=c\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")\r\n \r\n", "n = int(input())\r\nf1 = 1\r\nf2 = 1\r\nfib = [0]*(n+1)\r\nwhile f2<=n:\r\n fib[f2] = 1\r\n temp = f1\r\n f1 = f2\r\n f2 += temp\r\n# print(fib) \r\nres = ''\r\nfor i in range(1,n+1):\r\n if fib[i]==1:\r\n res += 'O'\r\n else:\r\n res += 'o'\r\nprint(res)\r\n\r\n ", "a = (1,2,3,5,8,13,21,34,55,89,144,233,377,610,987)\nn = int(input())\nfor i in range(1, n + 1):\n\tif i in a:\n\t\tprint('O', end='')\n\telse:\n\t\tprint('o', end='')", "n=int(input())\r\nfib=[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]\r\nfor i in range(n):\r\n if fib.count(i+1)!=0:\r\n print(\"O\",sep=\"\",end=\"\")\r\n else:\r\n print(\"o\",sep=\"\",end=\"\")\r\n", "n = int(input(''))\r\nfib = [1]\r\nf1, f2 = 1, 1\r\nk = 0\r\nfor i in range(2, n+1):\r\n sum = f1 + f2\r\n f1 = f2\r\n f2 = sum\r\n fib.append(sum)\r\n\r\nfor i in range(1, n + 1):\r\n if i == fib[k]:\r\n print('O', end=\"\")\r\n k += 1\r\n else:\r\n print('o', end=\"\")\r\n\r\n\r\n\r\n", "a = int(input())\r\nS = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]\r\nfor i in range(1,a+1):\r\n if(S.count(i)!=0):\r\n print(\"O\",end='')\r\n else:\r\n print(\"o\",end='')\r\n", "n = int(input())\r\n\r\nfib = [1, 1]\r\na = 2\r\nwhile a <= n:\r\n fib.append(a)\r\n a = fib[-1] + fib[-2]\r\nres = ''\r\nfor i in range(1, n + 1):\r\n if i in fib:\r\n res += 'O'\r\n else:\r\n res += 'o'\r\nprint(res)\r\n", "n = int(input())\r\ni = 1\r\nm = 1\r\nk = 0\r\na = [1]\r\nwhile k<=986:\r\n k=m+i\r\n m = i\r\n i = k\r\n a.append(k)\r\nfor i in range (1,n+1):\r\n if i in a:\r\n print('O',end = '')\r\n else:\r\n print ('o',end = '')", "a = [1,1]\r\nfor i in range(2,1010,1):\r\n a.append(a[i-1]+a[i-2])\r\nn = int(input())\r\nfor i in range(0,n):\r\n if(i+1 in a):\r\n print('O',end = '')\r\n else:\r\n print('o',end = '')\r\n", "import math\r\nn = int(input())\r\n\r\ndef check_fib(num):\r\n return math.ceil(math.sqrt(5*(num**2) + 4)) == math.floor(math.sqrt(5*(num**2) + 4)) or math.ceil(math.sqrt(5*(num**2) - 4)) == math.floor(math.sqrt(5*(num**2) - 4))\r\ns = \"\"\r\nfor i in range(n):\r\n if check_fib(i+1):\r\n s += \"O\"\r\n else:\r\n s += \"o\"\r\nprint(s)", "#Eleven\r\nn=int(input())\r\nfib=[]\r\nf1=1\r\nf2=1\r\nfib.append(0)\r\nfib.append(1)\r\nfib.append(1)\r\nfn=0\r\nwhile fn<=n:\r\n fn=f1+f2\r\n fib.append(fn)\r\n f1=f2\r\n f2=fn\r\nout=\"\"\r\n#print(out)\r\nfor i in range(1,n+1):\r\n if i in fib:\r\n out=out+'O'\r\n # print(1,i,out)\r\n\r\n else:\r\n out=out+'o'\r\n #print(2,i,out)\r\n\r\nprint(str(out))\r\n ", "fib = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]\r\n\r\nn = int (input())\r\n\r\nfor i in range (1,n+1):\r\n if i in fib:\r\n print (\"O\",end=\"\")\r\n else:\r\n print (\"o\",end=\"\")", "f = []\r\n\r\ndef fibo(n):\r\n a = 0\r\n b = 1\r\n if n==1:\r\n\r\n return b\r\n else:\r\n for i in range(2, n):\r\n c = a+b\r\n a = b\r\n b = c\r\n return b\r\n\r\nfor i in range(1,1001):\r\n f.append(fibo(i))\r\n\r\nx = int(input())\r\nfor i in range(1,x+1):\r\n if i in f:\r\n print('O', end=\"\")\r\n else:\r\n print('o', end=\"\")", "n=int(input());k=['o']*n;a=b=1\r\nwhile b<=n:k[b-1]='O';a,b=b,a+b\r\nprint(*k,sep=\"\")", "a = 0\nb = 1\nN = int(input())\nname = [\"o\"] * N\n\nwhile True:\n c = a + b\n a, b = b, c\n\n if c > N:\n break\n name[c - 1] = \"O\"\nprint(\"\".join(name))\n", "l = [0,1,1]\r\nfor i in range(999):\r\n l.append(l[-1]+l[-2])\r\nn = int(input())\r\nout = \"\"\r\nfor i in range(1,n+1):\r\n if i in l:\r\n out += 'O'\r\n else:\r\n out += 'o'\r\nprint(out)", "n=int(input())\r\ns=['o']*n\r\na=1\r\nb=1\r\nwhile a<=n:\r\n s[a-1]='O'\r\n a,b = b,a+b\r\nprint(''.join(s))", "n=int(input())\r\nfor i in range (n):\r\n if i==0 or i==1 or i==2 or i==4 or i==7 or i==12 or i==20 or i==33 or i==54 or i==88 or i==143 or i==232 or i==376 or i==609 or i==986:\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")\r\n", "n = int(input())\r\n\r\n# 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987\r\n\r\nfor i in range(1, n+1):\r\n if i in [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]:\r\n print(\"O\", end=\"\")\r\n else:\r\n print(\"o\", end=\"\")\r\n", "n = int(input())\r\na = 1\r\nb = 1\r\nresult = 'O'\r\nfor i in range(2, n+1):\r\n if i == a + b:\r\n result += 'O'\r\n x = b\r\n b += a\r\n a = x\r\n else:\r\n result += 'o'\r\nprint(result)\r\n", "n=int(input())\r\na=0\r\nb=1\r\nname=[]\r\nfor i in range(n):\r\n if(i+1==a+b):\r\n a=b\r\n b=i+1\r\n name.append(\"O\")\r\n else:\r\n name.append(\"o\")\r\nne=''.join(name)\r\nprint(ne)", "from math import *\r\n\r\ndef isPerfectSquare(n):\r\n sq = int(sqrt(n))\r\n return sq*sq == n\r\n\r\ndef isFibonacciMember(n):\r\n return isPerfectSquare(5*n*n+4) or isPerfectSquare(5*n*n-4)\r\n\r\nn = int(input())\r\nres = str()\r\nfor i in range(1,n+1):\r\n if isFibonacciMember(i):\r\n res+='O'\r\n else:\r\n res+='o'\r\nprint(res)", "n=int(input())\r\na=[0]*(n+1)\r\nf1=0\r\nf2=1\r\nk=0\r\nwhile(k<n+1):\r\n a[k]=1\r\n f1=f2\r\n f2=k\r\n k=f1+f2\r\ns=''\r\nfor i in range(1,n+1):\r\n if(a[i]==0):\r\n s+='o'\r\n else:\r\n s+='O'\r\nprint(s)\r\n", "l=[1,1]\r\nn=int(input())\r\nwhile l[-1]<=n:\r\n l.append(l[-1]+l[-2])\r\np=['O' if i in l else 'o' for i in range(1,n+1)]\r\nprint(\"\".join(p))", "n = int(input())\r\nf1 = 1\r\nf2 = 1\r\nfor i in range(1, 1 + n):\r\n if i == f1 or i == f2:\r\n if f1 < f2:\r\n f1 += max(f1, f2)\r\n else:\r\n f2 += max(f1, f2)\r\n print('O', end='')\r\n else:\r\n print('o', end='')", "ar=[0]*1000\r\nar[0]=0\r\nar[1]=1\r\nar[2]=1\r\nfor i in range(3,1000):\r\n ar[i]=ar[i-1]+ar[i-2]\r\n#print(ar)\r\nn=int(input())\r\ns=''\r\nfor i in range(n):\r\n if (i+1) in ar:\r\n s+='O'\r\n else:\r\n s+='o'\r\nprint(s)\r\n\r\n \r\n ", "\r\na=b=1\r\nfor i in range(int(input())):\r\n if b==i+1:a,b=(b,a+b);print('O',end='')\r\n else:print('o',end='')", "def isFibanocci(n):\r\n f1 = 0\r\n f2 = 1\r\n f3 = f1 + f1\r\n while (f3 < n):\r\n f1 = f2\r\n f2 = f3\r\n f3 = f1 + f2\r\n if f3 == n:\r\n return True\r\n else:\r\n return False\r\nn = int(input())\r\nfor i in range(1, n+1):\r\n if isFibanocci(i):\r\n print(\"O\", end=\"\")\r\n else:\r\n print(\"o\",end=\"\")", "# import sys\r\n# sys.stdin=open(\"input.in\",\"r\")\r\n# sys.stdout=open(\"output.out\",\"w\")\r\nn=int(input())\r\nA=[]\r\nA.append(0)\r\nA.append(1)\r\nfor i in range(2,18):\r\n\tA.append(A[i-2]+A[i-1])\r\nfor i in range(1,n+1):\r\n\tFLAG=1\r\n\tfor j in range(len(A)):\r\n\t\tif i==A[j]:\r\n\t\t\tFLAG=0\r\n\t\t\tbreak\r\n\tif FLAG==1:\r\n\t\tprint(\"o\",end='')\r\n\telse:\r\n\t\tprint(\"O\",end='') ", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[2]:\n\n\nn = int(input())\nl1 = []\nl2 = []\ns = \"\"\n\nn1 = 0\nn2 = 1\nfor i in range(n):\n n3 = n1 + n2\n l1.append(n3)\n n1 = n2\n n2 = n3\n\nfor m in range(1,n+1):\n if m in l1:\n l2.append('O')\n else:\n l2.append('o')\n\nprint(s.join(l2))\n\n", "a, b = 1, 1\r\nk = int(input())\r\nn = 1\r\nwhile n <= k:\r\n\tif n == b:\r\n\t\tprint(\"O\", end = \"\")\r\n\t\ta, b = b, a + b\r\n\telse:\r\n\t\tprint(\"o\", end = \"\")\r\n\tn = n + 1\r\n", "from math import *\r\n#s=['toc','c++','c','cse',\"lol\",'c','c++']\r\n#s.append(\"hi\")\r\n#s.insert(2,\"ki\")\r\n#s.remove(\"toc\")\r\n#s.sort()\r\n#s.reverse()\r\n#s.pop()\r\n#s2=s.copy()\r\n#k=s.index('c')\r\n#k=s.count('cse')\r\n#k=list(range(1,n))\r\n#print(n[2])\r\n#print(s2)\r\nn=int(input())\r\na=2\r\nb=1\r\nprint(\"O\",end='')\r\nfor i in range(2,n+1):\r\n\tif i==a:\r\n\t\tprint('O',end='')\r\n\t\tc=a\r\n\t\ta=a+b\r\n\t\tb=c\r\n\telse:\r\n\t\tprint('o',end='')\r\n\ti+=1\r\n'''\r\na={1,2,3,4,5}\r\nb=set([4,5,6,7,8])\r\na.add(6)\r\nif 4 in a:\r\n\tprint('false')\r\nprint(a)\r\nprint(a|b)\r\nprint(a&b)\r\nprint(a-b)\r\n'''\r\n", "n = int(input())\r\nans = [0 for i in range(n)]\r\na = 1\r\nb = 1\r\nans[0]=1\r\nwhile a+b<=n:\r\n ans[a+b-1]=1\r\n a, b = b, a+b\r\nfor i in range(n):\r\n if ans[i]:\r\n print(\"O\", end=\"\")\r\n else:\r\n print(\"o\", end=\"\")\r\n", "#!/usr/bin/env python\r\n\r\nimport math\r\nimport sys\r\nimport itertools\r\nimport fractions\r\n\r\nif __name__ == '__main__':\r\n wtf = sys.stdin.read()\r\n wtf = wtf.strip().split('\\n')\r\n n = int(wtf[0])\r\n fibs = [0,1]\r\n for i in range(2,1001):\r\n fibs.append(fibs[i-1]+fibs[i-2])\r\n if fibs[i] > 1000:\r\n break\r\n ans = ''\r\n for i in range(1, n+1):\r\n if i in fibs:\r\n ans += 'O'\r\n else:\r\n ans += 'o'\r\n print(ans)\r\n", "n = int(input())\r\nl = [1, 1]\r\nb = ''\r\nfor i in range(2, n + 1):\r\n l.append(l[i - 2] + l[i - 1])\r\nfor j in range(1, n + 1):\r\n if j in l:\r\n b += 'O'\r\n else:\r\n b += 'o'\r\nprint(b)", "for i in range(1,int(input())+1):\r\n if ((5*i*i-4)**0.5).is_integer() or ((5*i*i+4)**0.5).is_integer():print('O',end='')\r\n else:print('o',end='')", "def FibonnaciList(num):\r\n lst, a, b = [], 0, 1\r\n for i in range(num):\r\n a, b = b, a + b\r\n lst.append(b)\r\n return lst\r\n\r\n\r\nn = int(input())\r\nfib = FibonnaciList(15)\r\n\r\nfor i in range(1, n+1):\r\n if i in fib:\r\n print('O', end='')\r\n else:\r\n print('o', end='')\r\n", "n=int(input())\r\nfib=[1,1]\r\nfor i in range(2,18):\r\n fib.append(fib[i-1]+fib[i-2])\r\nfor i in range(n):\r\n if i+1 in fib:\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")\r\nprint()", "n=int(input())\r\nn1,n2=0,0\r\ns=\"\"\r\n\r\nf=[1,1]\r\nwhile f[-1]<n:\r\n f.append(sum(f[-2:]))\r\n\r\nfor i in range(n):\r\n if i+1 in f:\r\n s+=\"O\"\r\n else:\r\n s+=\"o\"\r\nprint(s)", "n1,n2 = 0,1\r\nx = int(input())\r\ni = 0\r\nsum = 0\r\nlst = [0]\r\n#print(n1,n2,end=' ')\r\nwhile i < x:\r\n sum = n1 + n2\r\n n1 = n2\r\n n2 = sum\r\n i = i + 1\r\n lst.append(sum)\r\n if i in lst:\r\n print('O',end='')\r\n else:\r\n print('o',end='')\r\n #print(sum,end=' ')\r\n #if i == sum:\r\n #print(\"O\",end='')\r\n #else:\r\n #print(\"o\",end='')\r\n#print(lst)\r\n#j = 1\r\n#k = 1\r\n#while j <= x:\r\n #if j in lst:\r\n #print(j,lst[j],end=' ')\r\n #print(\"O\",end='')\r\n #pass\r\n #else:\r\n #print(\"o\",end='')\r\n #print(j, lst[k], end=' ')\r\n\r\n #j = j + 1\r\n #k = k + 1\r\n", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nn = int(input())\r\nans = [\"o\"] * n\r\nans[0] = \"O\"\r\nu, v = 1, 1\r\nwhile u + v <= n:\r\n u, v = v, u + v\r\n ans[v - 1] = \"O\"\r\nsys.stdout.write(\"\".join(ans))", "n = int(input())\r\nli = [0,1]\r\na = 0\r\nb = 1\r\ns = 0\r\nname = ''\r\nwhile s<n:\r\n s = a+b\r\n a = b\r\n b = s\r\n li.append(s)\r\nfor i in range(1,n+1):\r\n if i in li:\r\n name +='O'\r\n else:\r\n name+='o'\r\nprint(name)\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n", "n=int(input())\r\ns=['o']*2000\r\na,b=1,1\r\nwhile a<1000:\r\n s[a]='O'\r\n a,b=b,a+b\r\nprint(''.join(s[1:n+1]))", "fib = [1,1]\r\ni = 0\r\nt = 1\r\ncount = 0\r\nwhile count < 20:\r\n fib.append(fib[i]+fib[t])\r\n i += 1\r\n t += 1\r\n count += 1\r\nn = int(input())\r\nname = []\r\nfor i in range(1,n+1):\r\n if i in fib:\r\n name.append('O')\r\n else:\r\n name.append('o')\r\nprint(''.join(name))\r\n\r\n", "n=int(input())\r\n\r\ndef fib(n):\r\n s1=1\r\n s2=1\r\n s=0\r\n l=[1]\r\n while s<n:\r\n s=s1+s2\r\n s1=s2\r\n s2=s\r\n l.append(s)\r\n return l\r\n\r\nl=fib(n)\r\nch=\"\"\r\nfor i in range(1,n+1):\r\n if i in l:\r\n ch+=\"O\"\r\n else:\r\n ch+=\"o\"\r\nprint(ch)", "n = int(input())\r\nq = 'o' * n ###\r\nw = ''\r\nfib = [1, 1]\r\nfor j in range(1, n):\r\n fib.append(fib[-2] + fib[-1])\r\n \r\nfor i in range(1, n + 1):\r\n if i in fib:\r\n w += 'O'\r\n else:\r\n w += 'o'\r\nprint(w)", "n=int(input())\r\ns=['o']*n\r\na=b=1\r\nwhile b<=n:\r\n s[b-1]='O';a,b=b,a+b\r\nprint(''.join(s))", "n = int(input())\r\ns = [\"o\"] * n\r\nf1 = 1\r\nf2 = 1\r\nwhile f2 <= n:\r\n s[f2-1] = \"O\"\r\n f1, f2 = f2, f1+f2\r\nprint(\"\".join(s))\r\n\r\n", "n = int(input())\r\nlist_o = []\r\nres = ''\r\nfib = [1,1]\r\n\r\n\r\n\r\nfor i in range(1,n+1):\r\n\r\n fib_num = 0\r\n fib_num = fib[len(fib)-2] + fib[len(fib)-1]\r\n fib.append(fib_num)\r\n\r\n if i in fib:\r\n list_o.append('O')\r\n else:\r\n list_o.append('o')\r\n\r\nfor o in list_o:\r\n res = res + o\r\n\r\nprint(res)\r\n \r\n", "import sys\r\nfrom functools import lru_cache\r\n\r\ninput = sys.stdin.readline\r\n\r\n\r\n@lru_cache()\r\ndef get_fibo(n):\r\n if n < 2:\r\n return n\r\n else:\r\n return get_fibo(n - 1) + get_fibo(n - 2)\r\n\r\n\r\nfibos = []\r\nfor i in range(1, 1000):\r\n tmp = get_fibo(i)\r\n if tmp > 1000:\r\n break\r\n fibos.append(tmp)\r\n\r\nn = int(input())\r\nprint(\"\".join(['O' if (i + 1) in fibos else 'o' for i in range(n)]))", "n=int(input())\r\nk=1\r\nm=[1,1]\r\nwhile k<=n:\r\n f=m[-1]+m[-2]\r\n m.append(f)\r\n k=k+1\r\ns=\"\"\r\na=1\r\nwhile a<=n:\r\n if a in m:\r\n s=s+\"O\"\r\n else:\r\n s=s+\"o\"\r\n a=a+1\r\nprint(s)", "q=int(input())\r\na=1\r\ns=1\r\nl=''\r\nfor w in range(1,q+1):\r\n if w==s:\r\n a,s=s,a+s\r\n l+='O'\r\n else:\r\n l+='o'\r\nprint(l)", "dp=[1]*16\r\nfor i in range(2,16):\r\n dp[i]=dp[i-1]+dp[i-2]\r\nn=int(input())\r\nlst=['O']*n \r\nfor i in range(n):\r\n if i+1 not in dp:\r\n lst[i]='o'\r\nprint(''.join(lst))", "a=[1,1]\r\n\r\ndef f():\r\n global a\r\n while a[-1]<=1000:\r\n a.append(a[-1]+a[-2])\r\n\r\nf()\r\nn=int(input())\r\nfor i in range(n):\r\n if i+1 in a:\r\n print('O',end='')\r\n else:\r\n print('o',end='')", "t=[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]\r\nn=int(input())\r\ns='o'*n\r\nl=list(s)\r\nfor i in range(len(s)):\r\n if (i+1) in t:\r\n l[i]=\"O\"\r\nprint(\"\".join(l))", "import sys\r\n\r\nrd = sys.stdin.readline\r\n\r\nn = int(rd())\r\n\r\nfib1 = 1\r\nfib2 = 1\r\n\r\nfor i in range(1, n + 1):\r\n\r\n if i == fib1:\r\n\r\n print('O', end = '')\r\n fib1, fib2 = fib1 + fib2, fib1\r\n\r\n else: print('o', end = '')\r\n\r\n\r\n\r\n\r\n", "x = int(input())\r\nseq = [1,1]\r\nname = \"\"\r\n\r\nfor i in range (x-1):\r\n seq.append(seq[i]+seq[i+1])\r\n\r\nfor i in range(1,x+1):\r\n if i in seq:\r\n name += \"O\"\r\n else:\r\n name += \"o\"\r\n\r\n\r\nprint (name)", "n = int(input())\r\nfib = [1,1]\r\nstring = [\"o\"]*n\r\nif n < 6:\r\n if n < 4:\r\n print(\"O\"*n)\r\n elif n == 4:\r\n print(\"O\"*3 + \"o\")\r\n elif n == 5:\r\n print(\"O\"*3 + \"o\" + \"O\")\r\n \r\nif n > 6: \r\n newf = lambda i : fib[i - 1] + fib[i - 2]\r\n \r\n for i in range(2,n):\r\n fib.append(newf(i))\r\n \r\n i = 0\r\n while fib[i] <= n:\r\n string[fib[i] - 1] = \"O\"\r\n i += 1\r\n print(\"\".join(string))", "n = int(input())\nl = [1, 1]\nb = ''\nfor i in range(2, n + 1):\n l.append(l[i - 2] + l[i - 1])\nfor j in range(1, n + 1):\n if j in l:\n b += 'O'\n else:\n b += 'o'\nprint(b)\n# when we bsozem a list for example in line 2 (l), we must put 'O' and 'o'\n# eeeeeeeeeeeeeeee diden ma zadachara chitari mezanm\n# yod bgiren\n# hahahhahahhahahhahahha\n# hahahahhahahhahahhahah\n# eeeeee basay khap kadm hh!!\n", "n=int(input())\r\na=0 \r\nl=[]\r\nb=1\r\nc=0\r\nwhile c<=n:\r\n\tc=a+b\r\n\tl.append(c)\r\n\ta=b\r\n\tb=c\r\nfor i in range(1,n+1):\r\n\tif i in l:\r\n\t\tprint(\"O\",end='')\r\n\telse:\r\n\t\tprint(\"o\",end='')\r\n", "n=int(input())\r\nn1=1\r\nn2=2\r\nn3=n2+n1\r\nfor i in range(1,n+1):\r\n if i==1:\r\n print('O',end=\"\")\r\n elif i==2:\r\n print('O',end=\"\")\r\n elif(i==n3):\r\n print('O',end=\"\")\r\n n1=n2\r\n n2=n3\r\n n3=n2+n1\r\n else:\r\n print('o',end=\"\")\r\n \r\n", "def fibonacci(n):\r\n\tif n<2:\r\n\t\treturn [1]\r\n\tans = [1,1]\r\n\ti = 0\r\n\twhile i<n:\r\n\t\ti = ans[-2] + ans[-1]\r\n\t\tans.append(i)\r\n\treturn ans\r\n\r\n\r\nn = int(input())\r\n\r\ntest = fibonacci(n)\r\nans = \"\"\r\nfor i in range(1,n+1):\r\n\tif i in test:\r\n\t\tans += \"O\"\r\n\telse:\r\n\t\tans += \"o\"\r\n\r\nprint(ans)", "n, s1, s2 = int(input()), 1, 1\r\ns = 'o' * n\r\nwhile s2 <= n: s, s1, s2 = s[0:s2 - 1] + 'O' + s[s2:n], s2, s2 + s1\r\nprint(s)", "n = int(input())\r\na, b = 1, 1\r\nfor i in range(1, n+1):\r\n if i == a or i == b or i == a+b:\r\n a, b = a+b, a\r\n print('O', end='')\r\n else:\r\n print('o', end='')\r\nprint()", "x=int(input())\r\nl=[1,1]\r\nk=1\r\nfor i in range(1,x+1):\r\n l=l+[l[k]+l[k-1]]\r\n k=k+1\r\n if i in l:\r\n print('O',end='')\r\n else:\r\n print('o',end='')\r\n", "n = int(input())\r\nfib = [1, 1]\r\nwhile fib[-1] < 1001:\r\n fib.append(fib[-1] + fib[-2])\r\nres = \"\"\r\nfor i in range(1, n+1):\r\n if i in fib:\r\n res += \"O\"\r\n else:\r\n res += \"o\"\r\nprint(res)\r\n", "n = int(input())\n\nf = [1, 1]\nwhile True:\n x = f[-1] + f[-2]\n if x > n: break\n f.append(x)\n\nans = ['o' for _ in range(n)]\nfor i in range(1, n+1):\n if i in f: ans[i-1] = 'O'\nprint(''.join(ans))\n", "n=int(input())\r\nl=[1,]\r\na=1\r\nb=1\r\nfor i in range(1,n+1):\r\n\ta,b=b,a+b\r\n\tif b > n:\r\n\t\tbreak\r\n\tl.append(b)\r\ns=\"\"\r\nfor i in range(1,n+1):\r\n\tif i in l:\r\n\t\ts=s+\"O\"\r\n\telse:\r\n\t\ts=s+\"o\"\r\nprint(s)", "import sys\r\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\r\ndef get_ls(): return list(map(int, sys.stdin.readline().strip().split()))\r\n\r\ndef main():\r\n \r\n n = int(input())\r\n a = 0\r\n b = 1\r\n st = set()\r\n st.add(b)\r\n while a < n:\r\n a, b = a+b, a\r\n st.add(a)\r\n \r\n for i in range(1, n+1):\r\n if i in st:\r\n print(\"O\", end='')\r\n else: print(\"o\", end='')\r\n print()\r\n \r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n ", "n=int(input())\nfib=[1,1]\nwhile fib[-1]<=1000:\n fib.append(fib[-1]+fib[-2])\nans=\"\"\nfor i in range(n):\n if fib.count(i+1):\n ans+=\"O\"\n else:\n ans+=\"o\"\nprint(ans)\n", "def main():\r\n c = int(input())\r\n data = [0,1]\r\n while data[-1]<c:\r\n data.append(data[-1]+data[-2])\r\n s = \"\"\r\n for i in range(0,c):\r\n if i+1 in data:\r\n s+=\"O\"\r\n else:\r\n s+=\"o\"\r\n print(s)\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n=int(input())\r\ndp=[0]*(n+100)\r\ndp[0]=1\r\ndp[1]=1\r\nres='O'\r\nfor i in range(2,n+100):\r\n dp[i]=dp[i-1]+dp[i-2]\r\nfor i in range(2,n+1):\r\n if i in dp:\r\n res+='O'\r\n else:\r\n res+='o'\r\nprint(res)", "nameLenght = int(input())\r\nfNumbs = [0]\r\nfNum = 0\r\n\r\nlast = 0\r\nnow = 1\r\ni = 1\r\nwhile fNum <= 1000:\r\n fNumbs.append(last+now)\r\n last = now\r\n now = fNumbs[i]\r\n fNum = now\r\n i += 1\r\n\r\nname = \"\"\r\nfor i in range(1,nameLenght+1):\r\n if i in fNumbs:\r\n name += \"O\"\r\n else:\r\n name += \"o\"\r\n\r\nprint(name)", "FibArray = [1, 2]\r\n\r\ndef fibonacci(n):\r\n if n < 0:\r\n print(\"Incorrect input\")\r\n\r\n elif n < len(FibArray):\r\n return FibArray[n]\r\n else:\r\n FibArray.append(fibonacci(n - 1) + fibonacci(n - 2))\r\n return FibArray[n]\r\n\r\nfibonacci(20)\r\n\r\nn = int(input())\r\nans = ''\r\nfor i in range(1,n+1):\r\n\tif i in FibArray:\r\n\t\tans += 'O'\r\n\telse:\r\n\t\tans += 'o'\r\n\t\t\r\nprint(ans)\r\n\r\n", "def getfib(n):\r\n f1=0\r\n f2=1\r\n f3=f1+f2\r\n l=[]\r\n l.append(f1)\r\n l.append(f2)\r\n while f1<n:\r\n l.append(f3)\r\n f1=f2\r\n f2=f3\r\n f3=f1+f2\r\n del l[len(l)-1]\r\n return l\r\nn=int(input())\r\nl=getfib(n)\r\ns=\"\"\r\nfor i in range(1,n+1):\r\n if i in l:\r\n s=s+\"O\"\r\n else:\r\n s=s+\"o\"\r\nprint(s)\r\n", "n=int(input())\r\nz=['o']*n\r\nfibs=[1,1]\r\nfor i in range(2,n+1):\r\n fibs+=fibs[i-1]+fibs[i-2],\r\nj=1\r\nk=1\r\nwhile(j!=n+1):\r\n if j>fibs[k]:\r\n k+=1\r\n if j==fibs[k]:\r\n z[j-1]='O'\r\n k+=1\r\n j+=1\r\n\r\nprint(''.join(z))", "x = int(input())\r\nfirst, second, third = 1, 2, 3\r\nfor i in range(x):\r\n if i > third:\r\n first = second\r\n second = third\r\n third = first + second\r\n print('O' if i == first-1 or i == second-1 or i == third-1 else 'o', end=\"\")\r\n", "n = int(input())\r\n\r\nfibonacciBelow1000 = (1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987)\r\n\r\ntempNameArray = [''] * n\r\n\r\nfor i in range(1, n + 1):\r\n if i in fibonacciBelow1000:\r\n tempNameArray[i-1] = 'O'\r\n else:\r\n tempNameArray[i-1] = 'o'\r\n\r\nnewName = ''.join(tempNameArray)\r\n\r\nprint(newName)", "#import sys\r\n#sys.stdin = open(\"input.in\",\"r\")\r\n#sys.stdout = open(\"test.out\",\"w\")\r\nn = int(input())\r\na=1\r\nb=1\r\nfor i in range(1,n+1):\r\n\tif i==a:\r\n\t\tprint('O', end = '')\r\n\t\tm= b\r\n\t\tb=a\r\n\t\ta+=m\r\n\telse:\r\n\t\tprint('o', end = '')", "n=int(input())\r\nf=1\r\ns=2\r\nc=3\r\nl=[1,2]\r\nwhile(c<=1002):\r\n\tc=f+s\r\n\tl.append(c)\r\n\tf=s\r\n\ts=c\r\nans=''\r\nfor i in range(1,n+1):\r\n\tif i in l:\r\n\t\tans+='O'\r\n\telse:\r\n\t\tans+='o'\r\nprint(ans)", "a=int(input())\r\nq=1\r\nw=1\r\nh=''\r\nfor s in range(1,a+1):\r\n if w==s:\r\n h+='O'\r\n q,w=w,q+w\r\n else:\r\n h+='o'\r\nprint(h)", "n=int(input())\r\np=[\"o\"]*n\r\na=0\r\nb=1\r\nwhile a+b<=n:\r\n p[a+b-1]=\"O\"\r\n b=a+b\r\n a=b-a\r\nprint(*p,sep=\"\")", "# cook your dish here\r\nn=int(input())\r\na=1\r\nb=1\r\nc=[]\r\nfor i in range(1,n+1):\r\n d=a+b\r\n c.append(d)\r\n if(i==1 or i in c):\r\n print(\"O\",end='')\r\n else:\r\n print(\"o\",end='')\r\n a=b\r\n b=d", "def potter_out():\r\n s=\"\";l=[]\r\n for i in range(1,int(input())+1):\r\n if i==1 or i==2 or i==sum(l[0:2]):\r\n l.insert(0,i);s+=\"o\".upper()\r\n else:\r\n s+=\"o\".lower()\r\n return s\r\nprint(potter_out())", "def fibb2(n):\n a = 0\n b = 1\n ans = []\n\n for i in range(n):\n c = a+b\n a = b\n b = c\n\n ans.append(c)\n\n return ans\n\n\nn = int(input())\n\nans = fibb2(n)\nfor i in range(1, n+1):\n if i in ans:\n print('O', end='')\n else:\n print('o', end='')\n", "f = [1, 2]\r\ndef fib():\r\n for i in range(13):\r\n f.append(f[-1]+f[-2])\r\n \r\nfib()\r\n# print(f)\r\n\r\nn = int(input())\r\nans = \"\"\r\nfor i in range(1,1002):\r\n if i in f:\r\n ans += 'O'\r\n else:\r\n ans += 'o'\r\nprint(ans[:n])\r\n\r\n", "n=int(input())\r\na=[1, 1]\r\ni=2\r\nwhile a[-1]<=n:\r\n a.append(a[i-2]+a[i-1])\r\n i+=1\r\nb=[]\r\nfor i in range(1, n+1):\r\n if i in a:\r\n b.append('O')\r\n else:\r\n b.append('o')\r\nb=''.join(b)\r\nprint(b)", "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\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 I(): return int(sys.stdin.readline())\ndef LS(): return sys.stdin.readline().split()\ndef S(): return input()\n\ndef main():\n n=I()\n\n l=[0]*1010\n a=1\n b=1\n l[a]=1\n\n while True:\n a+=b\n if a>1000:\n break\n l[a]=1\n c=a\n a=b\n b=c\n\n ans=''\n for x in l[1:n+1]:\n if x==1:\n ans+='O'\n else:\n ans+='o'\n\n return ans\n\n# main()\nprint(main())\n", "n=eval(input())\r\na=0\r\nb=1\r\nnums=[]\r\nfor i in range(1,n+1):\r\n c=a+b\r\n a=b\r\n b=c\r\n nums.append(c)\r\n if c>=n:\r\n break\r\n\r\n\r\n\r\n\r\nfor i in range(1,n+1):\r\n if i in nums:\r\n print(\"O\",end='')\r\n else:\r\n print(\"o\",end='')\r\n \r\n", "n=int(input())\r\ns=['o']*n\r\na,b=1,2\r\nwhile a<=n:\r\n\ts[a-1]='o'.upper()\r\n\ta,b=b,a+b\r\nprint(''.join(s))", "a=int(input())\r\nb=[\"o\"]*(a+1)\r\nd=[int(1)]*22\r\nfor i in range(2,len(d)):\r\n d[i]=d[i-1]+d[i-2]\r\nfor j in range(1,len(b)):\r\n\tif d.count(j)!=0:\r\n\t\tb[j]=\"O\"\r\nb.remove(b[0])\r\nprint(\"\".join(b))", "import sys\r\nimport math\r\nimport bisect\r\n\r\ndef main():\r\n F = [1, 1]\r\n while F[-1] < 1000:\r\n F.append(F[-2] + F[-1])\r\n n = int(input())\r\n A = ['o'] * n\r\n for i in range(n):\r\n if i + 1 in F:\r\n A[i] = 'O'\r\n print(''.join(A))\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n=int(input())\r\nl=[1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]\r\nfor i in range(1,n+1):\r\n\tif i in l:\r\n\t\tprint('O',end='')\r\n\telse:\r\n\t\tprint('o',end='')", "a=[1,1]\r\na+=[0 for i in range(30)]\r\nfor i in range(2,32):\r\n a[i]=a[i-1]+a[i-2]\r\n\r\nn=int(input())\r\nfor i in range(1,n+1):\r\n if i in a:\r\n print('O',end='')\r\n else:\r\n print('o',end='')\r\n \r\n\r\n", "n=int(input())\r\nS=['o']*(n)\r\na,b=0,1\r\nwhile b<=n:\r\n S[b-1]='O'\r\n a,b=b,a+b\r\nprint(''.join(S))", "def fibbonaci(x: int) -> str:\r\n fib = [0, 1]\r\n while fib[-1] <= x:\r\n fib.append(fib[-1] + fib[-2])\r\n \r\n ans = \"\".join(['O' if i in fib else 'o' for i in range(1, x+1)])\r\n return ans\r\n\r\nif __name__ == \"__main__\":\r\n print(fibbonaci(int(input())))", "n=int(input())\r\na=[1,1]\r\nz=\"o\"*n\r\nc=1\r\nwhile c<=n:\r\n\tc=a[len(a)-1]+a[len(a)-2]\r\n\ta.append(c)\r\nfor i in range(n+1):\r\n\tif i in a:\r\n\t\tz=z[:i-1]+\"O\"+z[i:]\r\nprint(z)\t \t", "#-------------Program--------------\r\n#----Kuzlyaev-Nikita-Codeforces----\r\n#-------------Training-------------\r\n#----------------------------------\r\n\r\nn=int(input())\r\narr=[0]*n\r\na=1;b=1\r\nwhile a<=n:\r\n arr[a-1]=1\r\n a,b=b,b+a\r\nfor i in range(n):\r\n if arr[i]==1:\r\n print('O',end='')\r\n else:\r\n print('o',end='')", "x=int(input())\r\ny=[1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]\r\nr=''\r\nfor i in range(x):\r\n if (i+1) in y:\r\n r+='O'\r\n else:\r\n r+='o'\r\nprint(r)\r\n ", "n = int(input())\r\nfib =[]\r\nx = 1\r\ny = 1\r\nwhile(y<=n):\r\n fib.append(y)\r\n x,y = y,x+y\r\nfor i in range(1,n+1):\r\n if i in fib:\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")", "n = int(input())\nres = ''\nfor i in range(1, n + 1):\n if (5*i**2+4)**0.5 % 1 == 0 or (5*i**2-4)**0.5 % 1 == 0:\n res = res + 'O'\n else:\n res = res + 'o'\nprint(res)\n", "n=int(input())\np=[\"o\"]*n\na=0\nb=1\nwhile a+b<=n:\n p[a+b-1]=\"O\"\n b=a+b\n a=b-a\nprint(*p,sep=\"\")\n", "N = int(input())\na = [False] * 1001\na[1]= True\na[2]= True \nfirst = 1\nsecond = 1\nwhile(first < 1001):\n first,second = first + second , first \n a[second] = True\nans = ''\nfor i in range(1,N+1):\n if a[i]:\n ans+= \"O\"\n else:\n ans += \"o\"\nprint(ans)\n", "s = [0]\r\nw = set()\r\nn = int(1)\r\nfib = int(0)\r\nwhile (fib <= 1000):\r\n if n > 2:\r\n fib = s[n - 1] + s[n - 2]\r\n else:\r\n fib = 1\r\n n += 1\r\n s.append(fib)\r\nfor i in range(len(s)):\r\n w.add(s[i])\r\nq = int(input())\r\nb = \"\"\r\nfor i in range(1, q + 1, 1):\r\n if i in w:\r\n b += \"O\"\r\n else:\r\n b += \"o\"\r\nprint(b)", "n = int(input())\r\n\r\nfib = [1, 1]\r\ncount = 0\r\nres = \"\"\r\n\r\nfib.append(fib[-1] + fib[-2])\r\nfib.remove(fib[0])\r\n\r\nfor i in range(n):\r\n fib.append(fib[-1] + fib[-2])\r\n if fib[count] - 1 == i:\r\n res += \"O\"\r\n count += 1\r\n else:\r\n res += \"o\"\r\n\r\nprint(res)\r\n", "fibos = []\r\n\r\ndef fibo(n):\r\n\tif n == 1 or n == 2:\r\n\t\treturn 1\r\n\telse:\r\n\t\treturn fibo(n-1) + fibo(n-2)\r\n\r\ndef build_fibos():\r\n\ti = 1\r\n\twhile (fibo(i) <= 1000):\r\n\t\tfibos.append(fibo(i))\r\n\t\ti += 1\r\n\r\nbuild_fibos()\r\n\r\nn = int(input())\r\nans = \"\"\r\n\r\nfor i in range(0,n):\r\n\tif i+1 in fibos:\r\n\t\tans += \"O\"\r\n\telse:\r\n\t\tans += 'o'\r\n\r\nprint(ans)", "# import sys\n# sys.stdin=open('input.in','r')\n# sys.stdout=open('output.out','w')\nn=int(input())\nx1=1\nx2=2\nk=0\nfor x in range(1,n+1):\n\tif x==1 or x==2:\n\t\tprint('O',end='')\n\telse:\n\t\tk=x1+x2\n\t\tif k==x:\n\t\t\tprint('O',end='')\n\t\t\tx1=x2\n\t\t\tx2=k\n\t\telse:\n\t\t\tprint('o',end='')\n#OOOoOooOooooOoo", "n = int(input())\ni = 2\nf = [1, 1]\nwhile i <= n:\n f.append(f[i - 2] + f[i - 1])\n i += 1\nfor i in range(1, n + 1):\n if i in f:\n print('O', end='')\n else:\n print('o', end='')\n", "n = int(input())\nf1 = 1\nf2 = 1\nfor i in range(1, 1+n):\n if i == f1 or i == f2:\n if f1 < f2:\n f1 += max(f1, f2)\n else:\n f2 += max(f1, f2)\n print('O', end='')\n else:\n print('o', end='')", "x=int(input())\r\na=1\r\nb=1\r\np=[1]\r\nfor n in range(16):\r\n c=a+b\r\n p.append(c)\r\n a=b\r\n b=c\r\n\r\ns=\"\"\r\nfor n in range(1,x+1):\r\n if n in p:\r\n s=s+\"O\"\r\n else:\r\n s=s+\"o\"\r\nprint(s) \r\n", "def fib(i,d={1:1,2:1}):\r\n if i in d:\r\n return d[i]\r\n d[i] = fib(i-1) + fib(i-2)\r\n return d[i]\r\nfor i in range(int(input())):\r\n x=1\r\n while True:\r\n if i<0:\r\n print('o',end='')\r\n break\r\n if i == 0:\r\n print('O',end='')\r\n break\r\n i-=fib(x)\r\n x+=1", "n = int(input())\r\ns = ''\r\nfi = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]\r\nfor i in range(n):\r\n s += ['o','O'][i+1 in fi]\r\nprint(s)", "n = int(input())\r\nn1, n2 = 0, 1\r\nfib = [0]\r\nfor i in range(n + 1):\r\n n3 = n1 + n2\r\n fib.append(n3)\r\n n2 = n1\r\n n1 = n3\r\nname = \"\"\r\nfor i in range(1, n + 1):\r\n if i in fib:\r\n name += \"O\"\r\n else:\r\n name += \"o\"\r\nprint(name)", "f1 = 1\r\nf2 = 1\r\nfeb = [f1,f2]\r\nfor i in range(2,16):\r\n feb.append(feb[i-1]+feb[i-2])\r\n\r\nn = int(input())\r\nres = ''\r\nfor i in range(1,n+1):\r\n if i in feb:\r\n res += 'O'\r\n else:\r\n res += 'o'\r\nprint(res)", "li=[1,1]\r\nfor i in range (2, 16):\r\n li.append(li[i-1]+li[i-2])\r\nn=int(input())\r\nfor i in range(1 ,n+1):\r\n if(i in li):\r\n print (\"O\" , end=\"\")\r\n else :\r\n print (\"o\" , end=\"\")\r\n\r\n ", "li1=[]\r\nf1,f2=0,1\r\nwhile f2<=1000:\r\n li1.append(f2)\r\n f1,f2= f2, f1+f2\r\n \r\n \r\na= int(input())\r\nou=['o']*a\r\nfor i in range(a):\r\n if (i+1) in li1:\r\n ou[i]='O'\r\n \r\nout= ''.join(i for i in ou)\r\nprint(out)", "n = int(input())\r\n\r\nfib = [0, 1]\r\n\r\nwhile fib[-1] < n:\r\n fib.append(fib[-1] + fib[-2])\r\ns = ''\r\nfor i in range(1, n+1):\r\n if i in fib:\r\n s += 'O'\r\n else:\r\n s += 'o'\r\nprint(s)", "\r\np = int(input())\r\nl =['o' for i in range(p)]\r\n\r\nf=s=1\r\nwhile f<=p:\r\n l[f-1]='O'\r\n temp = f\r\n f=f+s\r\n s=temp\r\n\r\nprint(\"\".join(l))", "n = int(input())\n\nans = ['o' for i in range(n)]\nf1, f2, f3 = 1, 1, 2\nwhile f1 <= n:\n ans[f1-1] = 'O'\n f1, f2, f3 = f2, f3, f2+f3\n\nprint(''.join(ans))\n", "n = int(input())\r\na = 1\r\nb = 1\r\nd = []\r\nr = []\r\nfor i in range(n):\r\n\td.append(b)\r\n\ta,b= b,a+b\r\n\r\ns = [i for i in range(1,n+1)]\r\n\r\nfor i in range(n):\r\n\tif s[i] in d:\r\n\t\tr.append(\"O\")\r\n\telse:\r\n\t\tr.append(\"o\")\r\n\r\nprint(\"\".join(r))", "def fib(n):\r\n if(n==1 or n==2):\r\n return 1\r\n else:\r\n return fib(n-1)+fib(n-2)\r\n \r\nn=int(input())\r\nlist=[]\r\nfor i in range(1,18):\r\n list.append(fib(i))\r\nfor i in range(1,n+1):\r\n if i in list:\r\n print('O',end=\"\")\r\n else:\r\n print('o',end=\"\")", "import sys\r\n\r\ndef fibs(n):\r\n a, b = 1, 1\r\n out = set()\r\n while b <= n:\r\n out.add(b)\r\n a, b = b, a + b\r\n return out\r\n\r\ndef main():\r\n n = int(sys.stdin.read().strip())\r\n s = n*['o']\r\n for i in fibs(n):\r\n s[i-1] = 'O'\r\n return s\r\n \r\nprint(*main(), sep='')\r\n", "n=int(input())\r\na,b=1,1\r\nj=[1]\r\nwhile b<=n:\r\n\tj.append(a+b)\r\n\tk=a+b\r\n\ta=b\r\n\tb=k\r\nfor i in range(1,n+1):\r\n\tif i in j:\r\n\t\tprint(\"O\",end=\"\")\r\n\telse:\r\n\t\tprint(\"o\",end=\"\")\r\nprint(\"\")", "n=int(input())\r\nname=['o']*n\r\nfibo=[1,1]\r\nfor i in range(2,n+1):\r\n fibo+=fibo[i-1]+fibo[i-2], \r\na=1\r\nb=1\r\nwhile(a!=n+1):\r\n if a>fibo[b]:\r\n b+=1\r\n if a==fibo[b]:\r\n name[a-1]='O'\r\n b+=1\r\n a+=1\r\n \r\nprint(''.join(name)) \r\n \r\n \r\n", "l=[1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]\r\nn=int(input())\r\ns=\"\"\r\nfor i in range(1,n+1):\r\n if i in l:\r\n s+=\"O\"\r\n else:\r\n s+=\"o\"\r\nprint(s)\r\n ", "fib=[0]*100\r\nfib[0]=1\r\nfib[1]=1\r\nfor i in range(2,100):\r\n\tfib[i]=fib[i-1]+fib[i-2]\r\n\tif fib[i]>1000:\r\n\t\tbreak\r\nn=int(input())\r\nfor i in range(1,n+1):\r\n\tif i in fib:\r\n\t\tprint(\"O\",end=\"\")\r\n\telse:\r\n\t\tprint(\"o\",end=\"\")", "k = int(input())\r\nstr = ''\r\nfor i in range(k):\r\n str += \"o\"\r\na, b = 1,1\r\nwhile a <= k:\r\n str = str[:a-1] +\"O\"+str[a:]\r\n a, b = a+b, a\r\nprint(str)", "n=int(input())\r\nl=[1]\r\na=1\r\np1=0\r\np2=0\r\nfor i in range(n):\r\n p2=p1\r\n p1=a\r\n a=p1+p2\r\n l.append(a)\r\nk=len(l)\r\ndef check(x):\r\n for i in range(k):\r\n if x==l[i]:\r\n return True\r\n return False\r\np=[]\r\nfor i in range(n):\r\n if check(i+1):\r\n p.append('O')\r\n else:\r\n p.append('o')\r\nf=''\r\nfor i in range(n):\r\n f+=p[i]\r\n \r\nprint(f)\r\n ", "n = int(input())\r\n\r\na = ['o']*n\r\nl = [0]*19\r\nl[0],l[1] = 1,1\r\ni = 2\r\nwhile(i<=18):\r\n l[i] = l[i-1] + l[i-2]\r\n i+=1\r\n#print(l)\r\n#print\r\nfor i in range(n):\r\n if i+1 in l:\r\n #print('true')\r\n a[i] = 'O'\r\n\r\nprint(''.join(a))", "n = int(input())\r\nfib = [1, 1]\r\nc = 2\r\ni = 1\r\nt = [0] * (n + 1)\r\nt[1] = 1\r\nwhile c <= n:\r\n t[c] = 1\r\n fib.append(c)\r\n c = fib[i] + fib[ i + 1]\r\n i += 1\r\nfor i in range(1, n + 1):\r\n if t[i] == 1: print(\"O\", end = \"\")\r\n else: print(\"o\", end = \"\")", "q=lambda:map(int,input().split())\r\nqi=lambda:int(input())\r\nqs=lambda:input().split()\r\nn=qi()\r\ndef fibonacci(max):\r\n a, b = 1, 1\r\n while a <= max:\r\n yield a\r\n a, b = b, a+b\r\n\r\nprint(*['O' if i in [x for x in fibonacci(n)] else 'o' for i in range(1,n+1)],sep='')", "n=int(input())\r\na=['o' for i in range(n+1)]\r\nx=0;y=1\r\nwhile(x<=n):\r\n a[x]='O'\r\n x,y=y,x+y\r\nprint(\"\".join(a)[1:])\r\n", "def fib(n):\n x=0;y=1\n s=0\n lst=[]\n while(s<=n+1):\n s=x+y\n lst.append(s)\n x=y\n y=s\n n-=1\n return lst\nval=True\nn=int(input())\nlst=fib(n)\nstr=\"\"\nfor i in range(1,n+1):\n for j in range(len(lst)):\n if(i==lst[j]):\n val=False\n break\n \n if(val==False):\n str+=\"O\"\n else:\n str+=\"o\"\n val=True\nprint(str)\n\n", "n = int(input())\r\n\r\nmsk = [False for i in range(n+1)]\r\na = 1\r\nb = 1\r\nmsk[a] = True\r\nmsk[b] = True\r\nwhile True:\r\n tmp = b\r\n b = a + b\r\n a = tmp\r\n if b > n: \r\n break \r\n msk[b] = True\r\n\r\nres = ['o' for i in range(n)]\r\nfor i in range(n):\r\n if msk[i+1] is True:\r\n res[i] = 'O'\r\nprint(''.join(res))", "l={1,2,3,5,8,13,21,34,55,89,144,233,377,610,987}\r\nn=int(input())\r\nfor i in range(n):\r\n if i+1 in l:\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")", "#****************************************************\r\n#***************Shariar Hasan************************\r\n#**************CSE CU Batch 18***********************\r\n#****************************************************\r\nimport math\r\nimport re\r\nimport random\r\ndef isInFib(n):\r\n check1 = 5*n*n + 4\r\n check2 = 5*n*n - 4\r\n root_check1 = int(math.sqrt(check1))\r\n root_check2 = int(math.sqrt(check2))\r\n if(root_check1**2 == check1 or root_check2**2 == check2):\r\n return True\r\n else:\r\n return False\r\n \r\n \r\ndef solve():\r\n #for i in range(int(input())):\r\n for i in range(1):\r\n n = int(input())\r\n name = [\"O\" if(isInFib(x+1)) else \"o\" for x in range(n)]\r\n print(\"\".join(name))\r\n # s = input()\r\n\r\n\r\n\r\n\r\n\r\nsolve()", "l=[1,2]\r\n\r\nfor i in range(2,15):\r\n s = l[i-2]+l[i-1]\r\n l.append(s)\r\n\r\nrep=''\r\nn = int(input())\r\nfor i in range(1,n+1):\r\n if i in l:\r\n rep+='O'\r\n else:\r\n rep+='o'\r\n\r\nprint(rep)\r\n ", "n = int(input())\r\nres = ''\r\na, b = 1, 1\r\nfor i in range(1, n + 1):\r\n if i == b:\r\n res += 'O'\r\n a, b = b, a + b\r\n else:\r\n res += 'o'\r\nprint(res)\r\n", "n = int(input())\r\ndp = [0] * (n + 1)\r\ndp[0] = 1\r\ndp[1] = 1\r\nfor i in range(2, n + 1):\r\n dp[i] = dp[i - 1] + dp[i - 2]\r\nfor i in range(1, n + 1):\r\n for j in range(n + 1):\r\n if i == dp[j]:\r\n print('O', end=\"\")\r\n break\r\n elif dp[j] > i:\r\n print('o', end=\"\")\r\n break", "fibonacci = [1]\ndigits = int(input())\nnumber = 1\nnunber = 1\nwhile number <= digits:\n number = nunber + number\n nunber = number - nunber\n fibonacci.append(number)\nfor i in range(1,digits+1):\n if i in fibonacci:\n print('O',end = '')\n else:\n print('o',end = '')\n \n", "n = int(input())\r\ns = ['o']*n\r\na, b = 1, 1\r\nwhile(b <= n):\r\n s[b - 1] = 'O'\r\n a, b = b, a + b\r\nprint(''.join(s))\r\n ", "\"\"\"\r\n██╗ ██████╗ ██╗ ██████╗ ██████╗ ██╗ █████╗\r\n██║██╔═══██╗██║ ╚════██╗██╔═████╗███║██╔══██╗\r\n██║██║ ██║██║ █████╔╝██║██╔██║╚██║╚██████║\r\n██║██║ ██║██║ ██╔═══╝ ████╔╝██║ ██║ ╚═══██║\r\n██║╚██████╔╝██║ ███████╗╚██████╔╝ ██║ █████╔╝\r\n╚═╝ ╚═════╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚════╝\r\n\"\"\" \r\n__author__ = \"Dilshod\"\r\nn = int(input())\r\nfibonacci = [1, 1]\r\nf1 = 1\r\nf2 = 1\r\nname = [\"o\"] * n\r\nwhile fibonacci[-1] < n:\r\n\ta = f2\r\n\tf2 = f1 + f2\r\n\tf1 = a\r\n\tfibonacci += [f2]\r\nfor i in fibonacci:\r\n\tif i <= n:\r\n\t\tname[i - 1] = \"O\"\r\nprint(* name, sep = \"\")\r\n", "n=int(input())\r\ns=0\r\nl=[1]\r\na=1\r\nb=1\r\np=['o']*n\r\nwhile(s<=n):\r\n s=a+b\r\n if(s<=n):\r\n l.append(s)\r\n a=b\r\n b=s\r\nfor i in range(n):\r\n if i+1 in l:\r\n p[i]='O'\r\nprint(''.join(map(str,p)))\r\n", "def fib(n):\r\n if(n==1 or n==2):\r\n return 1\r\n else:\r\n return fib(n-1) + fib(n-2)\r\n\r\nb = [False] * 1000\r\n\r\nn = int(input())\r\n\r\nfor i in range(1,17):\r\n b[fib(i)-1] = True\r\n\r\nfor i in range(n):\r\n if(b[i]):\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")\r\nprint(\"\")\r\n\r\n", "dp = [1 for i in range(20)]\r\nfor i in range(18):\r\n dp[i] = dp[i - 1] + dp[i - 2]\r\nfor i in range(1, int(input()) + 1):\r\n if i in dp:\r\n print('O', end='')\r\n else:\r\n print('o', end='')", "def fib(n):\r\n a = [1,2]\r\n \r\n for i in range(2,n):\r\n a.append(a[i-1] + a[i-2])\r\n\r\n return a\r\n\r\nn = int(input())\r\n\r\ns = \"\"\r\n\r\nfor i in range(1,n+1):\r\n if i in fib(n):\r\n s += \"O\"\r\n else:\r\n s += \"o\"\r\n\r\nprint(s)\r\n", "n = int(input())\r\nname = []\r\nfor _ in range(n):\r\n name.append(\"o\")\r\nch1 = 1\r\nch2 = 1\r\nwhile True:\r\n if ch2>n:\r\n break;\r\n name[ch2-1]=\"O\"\r\n ch1, ch2 =ch2, ch1+ch2\r\nprint(\"\".join(name))", "n = int(input())\n\n# python program to check if x is a perfect square \nimport math \n \n# A utility function that returns true if x is perfect square \ndef isPerfectSquare(x): \n s = int(math.sqrt(x)) \n return s*s == x \n \n# Returns true if n is a Fibinacci Number, else false \ndef isFibonacci(n): \n \n # n is Fibinacci if one of 5*n*n + 4 or 5*n*n - 4 or both \n # is a perferct square \n return isPerfectSquare(5*n*n + 4) or isPerfectSquare(5*n*n - 4) \n \nname = ''\n\nfor i in range(1,n+1):\n\tif isFibonacci(i):\n\t\tname += 'O'\n\telse:\n\t\tname += 'o'\n\nprint(name)\n\n", "n=int(input())\r\nl=[1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610,987]\r\ni=1\r\nwhile(i<=n):\r\n if i in l:\r\n print(\"O\",end='')\r\n else:\r\n print(\"o\",end='')\r\n i+=1 \r\n ", "f = [1, 1]\r\nfor j in range(60):\r\n f.append(f[-1] + f[-2])\r\nn = int(input())\r\nfor i in range(n):\r\n if (i+1) in f:\r\n print('O', end='')\r\n else:\r\n print('o', end='')\r\n", "n=int(input())\r\ns=['o']*n\r\na=b=c=1\r\nwhile (a<=n):\r\n\ts[a-1]='O'\r\n\tc=a\r\n\ta=b\r\n\tb=a+c\r\nprint(''.join(s))", "a=[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]\r\nn=int(input())\r\nm=\"\"\r\nfor i in range(1,n+1):\r\n if i in a:\r\n m=m+\"O\"\r\n else:\r\n m=m+\"o\"\r\nprint(m)\r\n", "a= int(input())\r\nfibo=[]\r\nfibo.append(int(1))\r\nfibo.append(int(1))\r\n\r\ni=1\r\n\r\nwhile fibo[i]<a:\r\n j= fibo[i-1] + fibo[i]\r\n fibo.append(j)\r\n i=i+1\r\n\r\nans=''\r\n\r\nfor i in range(1,a+1):\r\n if i in fibo:\r\n ans=ans+\"O\"\r\n else:\r\n ans= ans+'o'\r\n\r\nprint(ans)", "namelen = int(input())\r\n\r\na = [0]*(namelen+2)\r\na[1] = 1\r\na[2] = 1\r\nfor i in range(2,namelen+1):\r\n a[i] = a[i-1] + a[i-2]\r\n\r\nif namelen==1:\r\n name = 'O'\r\nelif namelen==2:\r\n name = 'OO'\r\nelse:\r\n name = 'OOO'\r\n\r\nfor i in range(4,namelen+1):\r\n if(i in a):\r\n name +='O'\r\n else:\r\n name +='o'\r\nprint(name)", "n=int(input());\r\nk=['o']*n\r\na=b=1\r\nwhile b<=n:\r\n k[b-1]='O'\r\n a,b=b,a+b\r\nprint(*k,sep=\"\")\r\n", "import math\r\n\r\ndef isPerfectSquare(x):\r\n s = int(math.sqrt(x))\r\n return s*s == x\r\n\r\ndef isFibonacci(n):\r\n return isPerfectSquare(5*n*n + 4) or isPerfectSquare(5*n*n - 4)\r\n\r\nn = int(input())\r\nfor i in range(1, n+1):\r\n if isFibonacci(i):\r\n print(\"O\", end=\"\")\r\n else:\r\n print(\"o\", end=\"\")", "length = int(input())\r\n\r\nname = \"\"\r\ncounter1 = 1\r\ncounter2 = 1\r\ncounter3 = counter1 + counter2\r\nfibonacci = [1,1,3]\r\n\r\nfor i in range(1,length + 1):\r\n if i in fibonacci:\r\n name += \"O\"\r\n else:\r\n name += \"o\"\r\n counter1 = counter2\r\n counter2 = counter3\r\n counter3 = counter1 + counter2\r\n fibonacci.append(counter1)\r\n fibonacci.append(counter2)\r\n fibonacci.append(counter3)\r\n\r\nprint(name)", "def fib_numbers(n):\r\n fib_set = set()\r\n a = 1\r\n b = 1\r\n while b <= n:\r\n fib_set.add(b)\r\n b = b + a\r\n a = b - a\r\n return fib_set\r\n\r\ndef generate_name(n):\r\n char_array = []\r\n fib_set = fib_numbers(n)\r\n for i in range(n):\r\n if (i + 1) in fib_set:\r\n char_array.append('O')\r\n else:\r\n char_array.append('o')\r\n return ''.join(char_array)\r\n \r\nn = int(input())\r\nprint(generate_name(n))", "n = int(input())\r\nif n == 1:\r\n print(\"O\")\r\nelse:\r\n ans = \"OO\"\r\n m1, m2 = 1, 2\r\n for i in range(3, n + 1):\r\n if i == m1 + m2:\r\n m1 = m2\r\n m2 = i\r\n ans += \"O\"\r\n else:\r\n ans += \"o\"\r\n print(ans)\r\n \r\n", "n = int(input())\r\nl = []\r\nl1 = []\r\nfor i in range(1, n+1):\r\n if i <= 3:\r\n l1.append(i)\r\n l.append('O')\r\n else:\r\n if i == l1[-1] + l1[-2]:\r\n l1.append(i)\r\n l.append('O')\r\n else:\r\n l.append('o')\r\nprint(''.join(l))", "n = int(input())\r\n\r\na = 1\r\nb = 1\r\n\r\nname = []\r\n\r\nfor i in range(n):\r\n if i+1 > b:\r\n (a, b) = (b, a + b)\r\n name.append(\"O\" if (i+1 == b) else \"o\")\r\n\r\nprint(\"\".join(name))\r\n", "n = int(input())\r\ns = ['o' for i in range(n)]\r\nfibb = [1, 1]\r\ns[0] = 'O'\r\nfor i in range(n):\r\n x = fibb[-2] + fibb[-1]\r\n if x > n:\r\n break\r\n fibb.append(x)\r\n s[x - 1] = 'O'\r\nfor i in s:\r\n print(i, end='')\r\n", "def isfebu(x):\r\n z=False\r\n i=3\r\n f1=1\r\n f2=1\r\n while (f2<=x):\r\n f3=f1+f2\r\n f1=f2\r\n f2=f3\r\n i+=1\r\n if (f1==x):\r\n z=True\r\n return (z)\r\nx=int(input())\r\nq=''\r\nfor i in range(1,x+1):\r\n if (isfebu(i)):\r\n q+='O'\r\n else:\r\n q+='o'\r\nprint(q)\r\n\r\n", "n = int(input())\r\ns = ''\r\nc = [1]\r\na = b = 1 \r\nd = a+b\r\nwhile d<=n:\r\n\td = a+b\r\n\tc.append(d)\r\n\ta=b\r\n\tb=d\r\nfor i in range(n):\r\n\tif i+1 in c:\r\n\t\ts+='O'\r\n\telse:\r\n\t\ts+='o'\r\nprint(s)\r\n", "n = int(input())\na = 'o'*n\nf1,f2 = 1,1\nwhile True:\n a = a[:f2-1:] + 'O' + a[f2::]\n f1,f2 = f2, f1+f2\n \n if f2>n:\n break\nprint(a)\n\n", "l=[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]\r\nn=int(input())\r\nr=''\r\nfor i in range(n):\r\n if((i+1) in l):\r\n r=r+'O'\r\n else:\r\n r=r+'o'\r\nprint(r)\r\n", "a = [1, 1]\r\nn = int(input())\r\nwhile a[len(a) - 1] < n:\r\n a.append(a[len(a) - 1] + a[len(a) - 2])\r\nfor i in range(1, n + 1):\r\n if i in a:\r\n print('O', end='')\r\n else:\r\n print('o', end='')", "n = int(input())\r\n\r\nlist = [1, 1]\r\n\r\nfor i in range(2, 20):\r\n list.append(list[i - 1] + list[i - 2])\r\n#print(list)\r\ns = \"\"\r\nfor i in range(n):\r\n if i + 1 not in list:\r\n s += 'o'\r\n else:\r\n s += 'O'\r\nprint(s)\r\n", "n = int(input())\r\nfib = [1,1]\r\ntemp = fib[0] + fib [1]\r\ni = 2 \r\nwhile(temp<=n):\r\n fib.append(temp)\r\n temp = fib[i] + fib [i-1]\r\n i += 1 \r\nop = \"\"\r\nfor i in range(n):\r\n if i+1 in fib:\r\n op += 'O'\r\n else:\r\n op += 'o'\r\nprint(op)\r\n\r\n ", "def eleven(n):\r\n fab = [0,1]\r\n name = \"\"\r\n a , b, s = fab[0], fab[1], 0\r\n for i in range(n):\r\n s = a + b\r\n a = b\r\n b = s\r\n fab.append(s)\r\n\r\n \r\n for i in range(1, n+1):\r\n if i in fab:\r\n name += \"O\"\r\n else:\r\n name+=\"o\"\r\n \r\n return name\r\n\r\nn = int(input())\r\nprint(eleven(n))", "n=int(input())\r\na=[1,1]\r\nst=''\r\nwhile a[-1]<n:\r\n a.append(a[-1]+a[-2])\r\nfor i in range(1,n+1):\r\n if i in a:\r\n st+='O'\r\n else:\r\n st+='o'\r\nprint(st)\r\n", "x=int(input())\r\nfibo=[1,1]\r\nS=\"O\"\r\nfor i in range(0,x):\r\n\r\n fibo.append(fibo[-1]+fibo[-2])\r\n\r\nfor j in range(2,x+1):\r\n if j in fibo:\r\n S=S+'O'\r\n else:\r\n S=S+'o'\r\n\r\nprint(S)", "from math import sqrt\r\nfib= lambda n: True if sqrt(5*(n**2)-4)%1==0 or sqrt(5*(n**2)+4)%1 == 0 else False\r\nn=int(input())\r\nh=''\r\nfor i in range(1,n+1):\r\n if fib(i):\r\n h+=\"O\"\r\n else:\r\n h+='o'\r\nprint(h)", "a = b = 1\r\nfor i in range(int(input())):\r\n if b == i + 1:\r\n a, b = (b, a + b)\r\n print('O', end='')\r\n else:\r\n print('o', end='')\r\n", "n=int(input())\r\n\r\nf1=0\r\nf2=1\r\ncount=0\r\nl=[]\r\nif n==1:\r\n l.append(n)\r\nelse:\r\n l.append(f1)\r\n while count<n:\r\n f=f1+f2\r\n l.append(f)\r\n f1=f2\r\n f2=f\r\n count+=1\r\n\r\n# print(l)\r\n\r\nfor i in range(1,n+1):\r\n if i in l:\r\n print('O',end=\"\")\r\n else:\r\n print('o',end=\"\")\r\n ", "a=int(input())\r\nb=1\r\nc=2\r\nx=[]\r\ns=\"\"\r\nwhile(b<=a):\r\n d=b+c\r\n x. append(b)\r\n b=c\r\n c=d\r\nfor i in range(1,a+1):\r\n if i in x:\r\n s=s+'O'\r\n else:\r\n s=s+'o'\r\nprint(s)\r\n \r\n ", "n=int(input())\r\na=[1,2]\r\nx=1\r\nwhile a[x]<=1000:\r\n a.append(a[x]+a[x-1])\r\n x+=1\r\nfor x in range(n):\r\n if (x+1) in a:\r\n print('O',end='')\r\n else:\r\n print('o',end='')\r\n \r\n", "def int_lst_input():\n return [int(val) for val in input().split()]\n\n\ndef int_input():\n return int(input())\n\n\ndef print_lst(lst):\n print(' '.join([str(val) for val in lst]))\n\n\ndef solve():\n n = int_input()\n\n result = []\n fibs = set()\n a, b = 1, 1\n for _ in range(n):\n fibs.add(b)\n a, b = b, a + b\n\n for i in range(1, n + 1):\n # do something\n if i in fibs:\n result.append('O')\n else:\n result.append('o')\n\n print(''.join(result))\n\n\nif __name__ == '__main__':\n solve()\n", "l = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]\r\nn = int(input())\r\nfor i in range(1,n+1) :\r\n if i in l :\r\n print('O',end = '')\r\n else :\r\n print('o',end = '')\r\n", "import math\r\ndef sqcheck(m):\r\n n=int(math.sqrt(m))\r\n if n*n==m:\r\n return True\r\n else:\r\n return False\r\ndef checkFibo(a):\r\n if sqcheck(5*a*a-4)==True :\r\n return True\r\n elif sqcheck(5*a*a+4)==True:\r\n return True\r\n else:\r\n return False\r\nnum=int(input())\r\ni=1\r\nwhile i<=num:\r\n if checkFibo(i)==True:\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")\r\n i=i+1", "import sys\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\nFibArray = [1, 1]\r\n\r\n\r\ndef fibonacci(n):\r\n for i in range(2, n+1):\r\n if n <= len(FibArray):\r\n continue\r\n else:\r\n temp_fib = FibArray[i - 1] + FibArray[i - 2]\r\n FibArray.append(temp_fib)\r\n return FibArray\r\n\r\n\r\nn = inp()\r\nli = ['o']*n\r\nif n >= 3:\r\n li[0] = 'O'\r\n li[1] = 'O'\r\n li[2] = 'O'\r\n a = 3\r\nelif n >= 2:\r\n li[0] = 'O'\r\n li[1] = 'O'\r\n a = 2\r\nelif n >= 1:\r\n li[0] = 'O'\r\n a = 1\r\nfib = fibonacci(n)\r\nfor i in range(a, n):\r\n if i+1 in fib:\r\n #print(i)\r\n li[i] = 'O'\r\nprint(\"\".join(li))\r\n", "#In the name of GOD!\nn = int(input())\na = b = 1\nfor i in range(1, n + 1):\n\tif i == a:\n\t\tprint('O', end = '')\n\t\tc = b\n\t\tb = a\n\t\ta += c\n\telse:\n\t\tprint('o', end = '')\n", "# Το σίδερο όσο το χτυπάς τόσο γίνεται ατσάλι\r\n\r\n\"\"\"\r\n1. Read carefully, understand the problem & its output.\r\n2. Think about the solution using pen & paper.\r\n3. Code the solution.\r\n4. Test with edge cases: 0 len, empty str, identical elements.\r\n5. Debug if needed and iterate process.\r\n\"\"\"\r\n\r\nn = int(input())\r\n\r\n_set = set()\r\n\r\na, b = 1, 1\r\n\r\nwhile a <= n:\r\n _set.add(a)\r\n a, b = b, a+b\r\n\r\nname = ''\r\n\r\nfor i in range(n):\r\n if i+1 in _set:\r\n name += 'O'\r\n else:\r\n name += 'o'\r\n\r\nprint(name)\r\n", "b = [False for _ in range(1001)]\r\nb[1] = True\r\nn1 = 1\r\nn2 = 1\r\nwhile True:\r\n n1, n2 = n2, n1+n2\r\n try:\r\n b[n2] = True\r\n except IndexError:\r\n break\r\n\r\nn = int(input())\r\nfor i in range(1, n+1):\r\n print('O' if b[i] else 'o', end='')\r\n\r\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\r\n/////////////////////////////////////////\r\n// //\r\n// Coded by brownfox2k6 //\r\n// //\r\n/////////////////////////////////////////\r\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"", "l=[1,1,2]\r\na,b,c=1,1,2\r\nfor i in range(1,1000):\r\n\ta,b,c=b,a+b,b+c\r\n\tl.append(c)\r\nn=int(input())\r\nfor i in range(1,n+1):\r\n\tif i in l:\r\n\t\tprint('O', end='')\r\n\telse:\r\n\t\tprint('o', end='')", "# I make this just for fun because i'm done\r\n# Aimi Haraguni >> Konomi Suzuki >> Yui >> Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi. .. dude? \r\n# problems that involves any kind of persistent data structures are the best of the best, are not them?\r\n\r\nimport random\r\nN=20\r\nar, br = [0]*1001, [0]*52\r\nbr[0], br[1], ar[1] = 1, 1, 1\r\nfor i in range(2, N, 1):\r\n\tbr[i]=br[i-1]+br[i-2]\r\n\tif(br[i] <= 1000):\r\n\t\tar[br[i]]=ar[br[i]]+1\r\n\r\nn=int(input())\r\nfor i in range(1, n+1, 1):\r\n\tif(ar[i]!=0):\r\n\t\tprint(\"O\", end='')\r\n\telse:\r\n\t\tprint(\"o\", end='')\r\n", "n = int(input())\nf1 = 0\nf2 = 1\nanswer = \"\"\nhold = []\nf3 = f1 + f2\nwhile f3 < n:\n f3 = f1 + f2\n hold.append(f3)\n f1 = f2\n f2 = f3\nif n == 1:\n print(\"O\")\nelse:\n for i in range(1, n + 1):\n if hold.count(i) > 0:\n answer = answer + \"O\"\n else:\n answer = answer + \"o\"\n print(answer)", "l=[1,1]\r\nfor z in range(15):\r\n l.append(l[-1]+l[-2])\r\nn=int(input())\r\ns=\"\"\r\nfor y in range(1,n+1):\r\n if y not in l:\r\n s+=\"o\"\r\n else :\r\n s+=\"O\"\r\nprint(s)", "n=int(input())\r\nl=[1]\r\nch=\"\" \r\nf1=1\r\nf2=1 \r\nfor i in range(1,n+1):\r\n f3=f2+f1\r\n f1=f2\r\n f2=f3\r\n l.append(f3)\r\n if i in l:\r\n ch+=\"O\"\r\n else:\r\n ch+='o'\r\nprint(ch)", "a=0\r\nb=1\r\nc=1\r\narr=[c]\r\nn=input()\r\nn=int(n)\r\ns=\"\"\r\nwhile c<=n:\r\n c=a+b\r\n a=b\r\n b=c\r\n arr.append(c)\r\n\r\nfor i in range(1,n+1):\r\n if i in arr:\r\n s+=\"O\"\r\n else:\r\n s+=\"o\"\r\n\r\nprint(s)", "n = int(input())\r\nv = [1,1]\r\nz =[]\r\na,b = 1,1\r\nfor i in range(n):\r\n\ta,b=b,a+b\r\n\tv.append(b)\r\nfor j in range(1,n+1):\r\n\tif j in v:\r\n\t\tz.append(\"O\")\r\n\telse:\r\n\t\tz.append(\"o\")\r\nprint(\"\".join(z))", "n = int(input())\r\n\r\nif n < 4:\r\n print(\"O\"*n)\r\n\r\nelse:\r\n i = n\r\n fibs = set()\r\n x = 0\r\n y = 1\r\n while i:\r\n x, y = y, y+x\r\n fibs.add(y)\r\n if y > n:\r\n break\r\n i -= 1\r\n ans = \"\"\r\n for i in range(1, n+1):\r\n if i in fibs:\r\n ans += \"O\"\r\n else:\r\n ans += \"o\"\r\n print(ans)\r\n\r\n\r\n\r\n", "n= int(input())\r\nf0=0\r\nf1=1\r\nfn=0\r\nl1=[]\r\nstr=\"\"\r\nwhile(fn<=n):\r\n fn=f0+f1\r\n f0=f1\r\n f1=fn\r\n l1.append(fn)\r\nfor i in range(1,n+1):\r\n if i in l1:\r\n str=str + \"O\"\r\n else:\r\n str=str + \"o\"\r\n\r\nprint(str)", "ans = []\r\nn = int(input())\r\na = 0\r\nb = 1\r\nlst = []\r\nfor i in range(1, n+1):\r\n c = a + b\r\n a = b\r\n b = c\r\n lst.append(c)\r\n if (i in lst):\r\n ans.append(\"O\")\r\n else:\r\n ans.append(\"o\")\r\nprint(\"\".join(ans))", "p=int(input())\r\na=['o']*p\r\nfi=[1,1]\r\nfor i in range(2,p+1):\r\n fi+=fi[i-1]+fi[i-2],\r\n\r\nb=1\r\nc=1\r\nwhile(b!=p+1):\r\n if b>fi[c]:\r\n c+=1\r\n if b==fi[c]:\r\n a[b-1]='O'\r\n c+=1\r\n b+=1\r\n\r\nprint(''.join(a))", "n = int(input())\nfibonacci = [1, 1]\ni = 2\nwhile fibonacci[i-1] < 1001:\n\tfibonacci.append(fibonacci[i-1] + fibonacci[i-2])\n\ti += 1\nfibonacci = [x-1 for x in fibonacci]\nfor i in range(n):\n\tif(i in fibonacci):\n\t\tprint(\"O\", end='')\n\telse:\n\t\tprint(\"o\", end='')\n", "n = int(input())\r\na = 1\r\nf = [1, 1]\r\nans = ''\r\nfor i in range(n):\r\n f.append(f[i] + f[i+1])\r\n if i+1 in f:\r\n ans += 'O'\r\n else:\r\n ans += 'o'\r\nprint(ans)", "import sys\r\ninput = sys.stdin.readline\r\nins = lambda: input().rstrip()\r\nini = lambda: int(input().rstrip())\r\ninm = lambda: map(int, input().rstrip().split())\r\ninl = lambda: list(map(int, input().split()))\r\nout = lambda x, s='\\n': print(s.join(map(str, x)))\r\n\r\nn = ini()\r\nans = [\"o\"] * n\r\na = b = 1\r\nwhile b <= n:\r\n ans[b-1] = ans[b-1].upper()\r\n a, b = b, a + b\r\nout(ans, \"\")", "s=[]\r\nn=int(input())\r\nx=y=1\r\nfor i in range(n):\r\n\ts.append(\"o\")\r\nwhile(y<=n):\r\n\ts[y-1]=\"O\"\r\n\ttmp=y\r\n\ty=x+y\r\n\tx=tmp\r\nprint(*s,sep=\"\")", "import sys\r\nimport math\r\n\r\n#to read string\r\nget_string = lambda: sys.stdin.readline().strip()\r\n#to read list of integers\r\nget_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\r\n#to read non spaced string and elements are integers to list of int\r\nget_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))\r\n#to read non spaced string and elements are character to list of character\r\nget_charList_from_str = lambda: list(sys.stdin.readline().strip())\r\n#to read integers\r\nget_int = lambda: int(sys.stdin.readline().strip())\r\n#to print faster\r\npt = lambda x: sys.stdout.write(str(x))\r\n\r\n#--------------------------------WhiteHat010--------------------------------------#\r\nn = get_int()\r\nname = list('o'*n)\r\nx = y = 1\r\nwhile y<=n:\r\n name[y-1] = 'O'\r\n x,y = y,y+x\r\nprint(''.join(name)) \r\n", "n = int(input())\r\nfib = [0,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]\r\ns=''\r\nfor i in range(1,n+1):\r\n\tif i in fib:\r\n\t\ts+='O'\r\n\telse:\r\n\t\ts+='o'\r\nprint(s)", "n = int(input())\r\nlist = [1, 2]\r\ns = ['o' for i in range(0, n)]\r\nf1 = list[0]\r\nf2 = list[1]\r\nwhile f2 + f1 <= 1000:\r\n f = f2 + f1\r\n list.append(f)\r\n f1 = f2\r\n f2 = f\r\nfor item in list:\r\n if item <= n:\r\n s[item - 1] = 'O'\r\nfor item in s:\r\n print(item, end='')", "n=int(input())\r\nls=[]\r\na,b=0,1\r\ni=0\r\ns1=\"\"\r\nwhile(True):\r\n\tif i==0:\r\n\t\tls.append(0)\r\n\telif i==1:\r\n\t\tls.append(1)\r\n\telse:\r\n\t\tresult=ls[i-2]+ls[i-1]\r\n\t\tif result<=n:\r\n\t\t\tls.append(result)\r\n\t\telse:\r\n\t\t\tbreak\r\n\ti+=1\r\nfor j in range(1,n+1):\r\n\tif j in ls:\r\n\t\ts1+='O'\r\n\telse:\r\n\t\ts1+='o'\r\nprint(s1)", "def fib(num):\r\n\ta=[0, 1]\r\n\tfirst=0\r\n\tsecond=1\r\n\tfor _ in range(num):\r\n\t\ttemp=first\r\n\t\tfirst=second\r\n\t\tsecond+=temp\r\n\t\ta.append(second)\r\n\treturn a\r\n\r\nn=int(input())\r\nname=\"\"\r\nfor i in range(1, n+1):\r\n\tp=False\r\n\tfor j in fib(n):\r\n\t\tif i==j:\r\n\t\t\tname+='O';p=True\r\n\t\t\tbreak\r\n\tif not p:\r\n\t\tname+='o'\r\nprint(name)", "t=int(input())\r\nsum1=0\r\nsum2=1\r\nfor i in range(1,t+1):\r\n\tif(i==sum1+sum2):\r\n\t\tsum= sum1+sum2\r\n\t\tprint('O',end='')\r\n\t\tsum1=sum2\r\n\t\tsum2=sum\r\n\telse:print('o',end='')", "N = int(input())\nfibo = [0]*1001\nfibo[0] = 1\nfibo[1] = 2\nfor i in range(2,1001):\n fibo[i]=fibo[i-1]+fibo[i-2]\nres = []\nfor i in range(N):\n if i+1 in fibo: res.append('O')\n else: res.append('o')\nprint(''.join(res))\n\n\n", "n = int(input())\r\ncs = ['o'] * n\r\nf1 = f2 = 1\r\ncs [0] = 'O'\r\nwhile f1 <= n:\r\n cs[f1 - 1] = 'O'\r\n f1, f2 = f1 + f2, f1\r\nprint(''.join(cs))\r\n", "n=int(input())\r\nx=[\"o\" for i in range(n+1)]\r\nj=1\r\nk=1\r\nwhile j<=n and k<=n:\r\n x[j]='O'\r\n x[k]='O'\r\n k,j=j,j+k\r\nx[k]='O'\r\nx.pop(0)\r\nprint(*x,sep='')\r\n \r\n \r\n \r\n ", "n=int(input())\r\nl=[1,1]\r\na=1\r\nb=1\r\nfor i in range(n):\r\n\ta,b=b,a+b\r\n\tl.append(b)\r\nfor i in range(1,n+1):\r\n\tif i not in l:\r\n\t\tprint('o',end='')\r\n\telse:\r\n\t\tprint('O',end='')", "import math\r\ns=int(input())\r\nu=''\r\nfor i in range(1,s+1):\r\n a=5*pow(i,2)+4\r\n b=5*pow(i,2)-4\r\n A=math.sqrt(a)\r\n B=math.sqrt(b)\r\n AA=int(A)\r\n BB=int(B)\r\n if pow(AA,2)==a or pow(BB,2)==b:\r\n u+='O'\r\n else:\r\n u+='o'\r\nprint(u)\r\n", "def frameName(no_of_chars):\n if no_of_chars < 2:\n return 'O' * no_of_chars\n name = ['O'] + ['O'] + ['o'] * (no_of_chars - 2)\n f1, f2 = 1, 1\n \n \n while f1 + f2 <= no_of_chars:\n f3 = f1 + f2\n name[f3 - 1] = 'O'\n f2, f1 = f3, f2\n\n return ''.join(name)\n\n\nno_of_chars = int(input())\n\nprint(frameName(no_of_chars))", "f = []\r\ndef k(n):\r\n global f\r\n f = [0, 1]\r\n for i in range(2, n+1):\r\n f.append(f[i-1] + f[i-2])\r\n return\r\nk(1000) \r\nn = int(input())\r\np = \"\"\r\nfor i in range(1,n+1):\r\n if i in f:\r\n p+=\"O\"\r\n else:\r\n p+=\"o\"\r\nprint(p)\r\n", "def fibo(x):\n listt = [] \n listt.append(1)\n listt.append(1) \n temp = 1 \n temp2 = 1\n i = 2 \n while(i <= x) :\n listt.append(temp + temp2)\n temp = listt[i] \n temp2 = listt[i-1]\n i += 1\n \n return listt \n\n\n\nn = int(input())\n\n# for i in fibo(n):\n# print(i , end = ' ')\n# print()\n# print()\n\nj , k = 1 , 1 \nfl = fibo(n)\nwhile(j <= n ):\n if(fl[k] == j ):\n print(\"O\" , end ='')\n k += 1\n else:\n print('o' , end = '')\n j += 1\n\n\n\n\n\n\n\n", "n = int(input())\r\n\r\nlst = [1, 1]\r\nfor i in range (1001):\r\n l = len(lst)\r\n lst.append(lst[l-1] + lst[l-2])\r\n\r\nstr = \"\"\r\nfor i in range (1, n+1):\r\n if i in lst:\r\n str = str + \"O\"\r\n else:\r\n str += \"o\" \r\n\r\nprint(str)", "# cook your dish here \r\n\r\ntry :\r\n n= int(input()) \r\n next_num = 0 \r\n first = 2\r\n second = 3 \r\n count = 2\r\n new_name = \"OO\" \r\n if(n == 1):\r\n new_name = \"O\"\r\n elif(n ==2):\r\n new_name =\"OO\" \r\n else:\r\n while True :\r\n next_num = first + second \r\n first = second \r\n second = next_num\r\n count += 1 \r\n new_name = new_name + \"O\" \r\n for each in range (first + 1 , second) : \r\n if(count < n):\r\n new_name = new_name + \"o\" \r\n count+=1 \r\n \r\n if(count == n):\r\n break\r\n print(new_name) \r\n \r\nexcept:\r\n pass\r\n\r\n\r\n", "n=int(input())\r\nl=[]\r\na=0\r\nb=1\r\nwhile b<=n:\r\n l.append(b)\r\n c=a+b\r\n a=b\r\n b=c\r\nl.pop(0)\r\ny=[]\r\nfor i in range(0,n-len(l)):\r\n y.append('o')\r\nfor i in range(0,len(l)):\r\n y.insert(l[i]-1,'O')\r\nprint(''.join(y)) \r\n ", "lst=[1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]\r\ns=\"\"\r\nfor i in range(int(input())):\r\n if i+1 in lst:\r\n s+=\"O\"\r\n else:\r\n s+=\"o\"\r\nprint(s)", "n=int(input())\r\nn1=1\r\nn2=1\r\na=[1,1]\r\nfor i in range(n):\r\n temp=n1+n2\r\n n1=n2 \r\n n2=temp\r\n if temp<=n:\r\n a.append(temp)\r\n else:\r\n break \r\n#print(a)\r\ns=\"\"\r\nfor i in range(1,n+1):\r\n if i in a:\r\n s+='O'\r\n else:\r\n s+='o'\r\nprint(s)", "n = int(input())\r\nf = [1, 1]\r\nwhile f[-1] < n:\r\n f.append(f[-1] + f[- 2])\r\nname = ''\r\nfor i in range(1,n+1):\r\n name += 'O' if i in f else 'o'\r\nprint(name)", "def fibonacci():\n f = [1, 1]\n for i in range(2, 1001):\n f.append(f[i-1] + f[i-2])\n return f\n\n \ndef solve(n):\n s = ''\n f = set(fibonacci())\n for i in range(1, n+1):\n s += 'O' if i in f else 'o'\n return s\n\n\ndef main():\n n = int(input())\n print(solve(n))\n\n\nmain()\n", "l=[1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]\r\nn=int(input())\r\ns=\"\"\r\nfor i in range(1,n+1):\r\n if i in l:\r\n s +=\"O\"\r\n else:\r\n s +=\"o\"\r\nprint(s)\r\n", "\r\ndef fib(n,d):\r\n if n in d:\r\n return d[n]\r\n else :\r\n ans = fib(n-2,d)+fib(n-1,d)\r\n d[n] = ans\r\n return ans\r\ndic = {1:1,2:1}\r\n(fib(17,dic))\r\narr = []\r\nfor i in range(1,len(dic)+1):\r\n arr.append(dic[i])\r\nres ='' \r\nfor i in range(1,int(input())+1):\r\n if i in arr:\r\n res += 'O'\r\n else:\r\n res += 'o'\r\nprint(res) \r\n ", "n=int(input())\r\ndef fib(n):\r\n if n in [1,2]:\r\n return 1\r\n else :\r\n return fib(n-1)+fib(n-2)\r\nl= [fib(i) for i in range(1,17)]\r\ns=''\r\nfor i in range(1,n+1):\r\n if i in l:\r\n s+='O'\r\n else:\r\n s+='o'\r\nprint(s) ", "n=int(input())\r\nl=['o']*n\r\na=1\r\nb=1\r\nl[0]='O'\r\nwhile(b<=n):\r\n l[b-1]='O'\r\n a,b=b,a+b\r\nprint(''.join(l))", "f = [1,2]\r\na = int(input())\r\nb = ''\r\nwhile f[-1]<a:\r\n f.append(f[-1]+f[-2])\r\nfor i in range(a):\r\n if f.count(i+1) == 0:\r\n b += 'o'\r\n else:\r\n b += 'O'\r\nprint(b)", "n = int(input())\r\nf = [0, 1, 2, 3, 5, 8, 13, 21, 34, 55,\r\n 89, 144, 233, 377, 610, 987, 1597]\r\nansw = ''\r\nfor i in range(n):\r\n if i+1 in f:\r\n answ += 'O'\r\n else:\r\n answ += 'o'\r\nprint(answ)", "n = int(input())\r\n\r\na = ['o' for i in range(n)]\r\n\r\nfn1 = fn2 = 0\r\nfn = 1\r\n\r\nwhile fn < n + 1:\r\n a[fn - 1] = 'O'\r\n fn2 = fn1\r\n fn1 = fn\r\n fn = fn1 + fn2\r\n\r\nprint(''.join(a))", "fb=[1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987]\nn=int(input())\nfor i in range(1,n):\n if i in fb:\n print('O',end='')\n else:\n print('o',end='')\nif n in fb:\n print('O')\nelse:\n print('o')", "n=int(input())\r\nf1=0\r\nf2=1\r\nf3=1\r\nls=[]\r\nwhile(True):\r\n f3=f1+f2\r\n if(f3>n):\r\n break\r\n ls.append(f3)\r\n f1=f2\r\n f2=f3\r\nfor i in range(1,n+1):\r\n if(i in ls):\r\n print(\"O\",end=\"\")\r\n else:\r\n print(\"o\",end=\"\")", "n=int(input())\r\na=1\r\nb=1\r\nl=[1,1]\r\ns=''\r\nfor i in range(998):\r\n temp=a+b\r\n a=b\r\n b=temp\r\n l.append(temp)\r\nfor i in range(n):\r\n if(i+1) in l:\r\n s+='O'\r\n else:\r\n s+='o'\r\nprint(s)", "l = []\r\ndef fib(n):\r\n global l\r\n a,b = 1,1\r\n s = 0\r\n l = [1,1]\r\n while s<n:\r\n s = a + b\r\n l.append(s)\r\n a = b\r\n b = s\r\n \r\nif __name__ == '__main__':\r\n n = int(input())\r\n fib(n)\r\n for i in range(1,n+1):\r\n if i in l:\r\n print('O',end=\"\")\r\n else:\r\n print('o',end = \"\")", "n=int(input())\r\nl=[]\r\nm=0\r\np=[1,1]\r\ndef d(i):\r\n z=p[i-3]+p[i-2]\r\n p.append(z)\r\n return(z)\r\ns=\"\"\r\nfor i in range(3,1000):\r\n m=d(i)\r\nfor i in range(1,n+1):\r\n if(i in p):\r\n s=s+'O'\r\n else:\r\n s=s+'o'\r\nprint(s)", "m=int(input())\r\nz=[1,1]\r\nc=0\r\na=1\r\nb=1\r\nfor x in range(m):\r\n\tc=a+b\r\n\ta,b=b,c\r\n\tz.append(c)\r\n\tif c>=m:\r\n\t\tbreak\r\nfor x in range(1,m+1):\r\n\tif x in z:\r\n\t\tprint('O',end='')\r\n\telse:\r\n\t\tprint('o',end='')", "n = int(input())\nF = [0]*(n+5)\nF[0] = 1\nF[1] = 1\nfor i in range(2, n+5):\n F[i] = F[i-1]+F[i-2]\nF = set(F)\nres = []\nfor i in range(1, n+1):\n if i in F:\n res.append('O')\n else:\n res.append('o')\nprint(''.join(res))\n" ]
{"inputs": ["8", "15", "85", "381", "805", "1000", "1", "2", "3", "5", "17", "49", "256", "512", "933", "61", "781", "999"], "outputs": ["OOOoOooO", "OOOoOooOooooOoo", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooo", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooo", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...", "O", "OO", "OOO", "OOOoO", "OOOoOooOooooOoooo", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooo", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooo", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooo", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...", "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo..."]}
UNKNOWN
PYTHON3
CODEFORCES
455
e3fe082fc38571aabd3b4f88454d51ea
Choosing The Commander
As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires. Vova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and he wants to choose the person who will be respected by warriors. Each warrior is represented by his personality — an integer number *p**i*. Each commander has two characteristics — his personality *p**j* and leadership *l**j* (both are integer numbers). Warrior *i* respects commander *j* only if ( is the bitwise excluding OR of *x* and *y*). Initially Vova's army is empty. There are three different types of events that can happen with the army: - 1 *p**i* — one warrior with personality *p**i* joins Vova's army; - 2 *p**i* — one warrior with personality *p**i* leaves Vova's army; - 3 *p**i* *l**i* — Vova tries to hire a commander with personality *p**i* and leadership *l**i*. For each event of the third type Vova wants to know how many warriors (counting only those who joined the army and haven't left yet) respect the commander he tries to hire. The first line contains one integer *q* (1<=≤<=*q*<=≤<=100000) — the number of events. Then *q* lines follow. Each line describes the event: - 1 *p**i* (1<=≤<=*p**i*<=≤<=108) — one warrior with personality *p**i* joins Vova's army; - 2 *p**i* (1<=≤<=*p**i*<=≤<=108) — one warrior with personality *p**i* leaves Vova's army (it is guaranteed that there is at least one such warrior in Vova's army by this moment); - 3 *p**i* *l**i* (1<=≤<=*p**i*,<=*l**i*<=≤<=108) — Vova tries to hire a commander with personality *p**i* and leadership *l**i*. There is at least one event of this type. For each event of the third type print one integer — the number of warriors who respect the commander Vova tries to hire in the event. Sample Input 5 1 3 1 4 3 6 3 2 4 3 6 3 Sample Output 1 0
[ "import sys\r\nfrom collections import defaultdict\r\n\r\nclass Node:\r\n\tdef __init__(self, val):\r\n\t\tself.val = val\r\n\t\tself.left = None\r\n\t\tself.right = None\r\n\r\nq = int(sys.stdin.readline())\r\nroot = Node(0)\r\n# def search(node, bit, )\r\n\r\nfor _ in range(q):\r\n\tl = list(map(int, sys.stdin.readline().split()))\r\n\tif l[0] == 1:\r\n\t\t# add\r\n\t\tbit = 28\r\n\t\tcur = root\r\n\t\tnum = l[1]\r\n\t\t# print(num,'num')\r\n\t\twhile bit >= 0:\r\n\t\t\tif ((1<<bit)&num) == (1<<bit):\r\n\t\t\t\tif cur.right is None:\r\n\t\t\t\t\tcur.right = Node(1)\r\n\t\t\t\t\t# print(bit,'bit right')\r\n\t\t\t\telse:\r\n\t\t\t\t\tcur.right.val += 1\r\n\t\t\t\t\t# print(bit,'bit add right')\r\n\t\t\t\tcur = cur.right\r\n\t\t\telse:\r\n\t\t\t\tif cur.left is None:\r\n\t\t\t\t\tcur.left = Node(1)\r\n\t\t\t\t\t# print(bit,'bit left', cur.left.val)\r\n\t\t\t\telse:\r\n\t\t\t\t\tcur.left.val += 1\r\n\t\t\t\t\t# print(bit,'bit add left', cur.left.val)\r\n\t\t\t\tcur = cur.left\r\n\t\t\tbit -= 1\r\n\tif l[0] == 2:\r\n\t\tnum = l[1]\r\n\t\tbit, cur = 28, root\r\n\t\t# print(num,'num')\r\n\t\twhile bit >= 0:\r\n\t\t\tif((1<<bit)&num) == (1<<bit):\r\n\t\t\t\tcur.right.val -= 1\r\n\t\t\t\tcur = cur.right\r\n\t\t\telse:\r\n\t\t\t\tcur.left.val -= 1\r\n\t\t\t\tcur = cur.left\r\n\t\t\tbit -= 1\r\n\t\t# remove\r\n\tif l[0] == 3:\r\n\t\t# print\r\n\t\tres, cur, bit = 0, root, 28\r\n\t\t# print(res, cur, bit)\r\n\t\twhile bit >= 0:\r\n\t\t\tnum = (1<<bit)\r\n\t\t\t# print(bit,'bit')\r\n\t\t\tif (num&l[2]) and (num&l[1]):\r\n\t\t\t\t# print(\"A\")\r\n\t\t\t\tif cur.right is not None:\r\n\t\t\t\t\tres += cur.right.val\r\n\t\t\t\tif cur.left is None:\r\n\t\t\t\t\tbreak\r\n\t\t\t\tcur = cur.left\r\n\t\t\t\tbit -= 1\r\n\t\t\t\tcontinue\r\n\t\t\tif (num&l[2]) and not (num&l[1]):\r\n\t\t\t\t# print(\"B\")\r\n\t\t\t\tif cur.left is not None:\r\n\t\t\t\t\tres += cur.left.val\r\n\t\t\t\tif cur.right is None:\r\n\t\t\t\t\tbreak\r\n\t\t\t\tcur = cur.right\r\n\t\t\t\tbit -= 1\r\n\t\t\t\tcontinue\r\n\t\t\tif not (num&l[2]) and (num&l[1]):\r\n\t\t\t\t# print(\"C\")\r\n\t\t\t\tif cur.right is None:\r\n\t\t\t\t\tbreak\r\n\t\t\t\tcur = cur.right\r\n\t\t\t\tbit -= 1\r\n\t\t\t\tcontinue\r\n\t\t\tif not (num&l[2]) and not (num&l[1]):\r\n\t\t\t\t# print(\"D\")\r\n\t\t\t\tif cur.left is None:\r\n\t\t\t\t\tbreak\r\n\t\t\t\tcur = cur.left\r\n\t\t\t\tbit -= 1\r\n\t\t\t\tcontinue\r\n\t\tprint(res)\r\n\r\n", "import sys\r\nreadline=sys.stdin.readline\r\n\r\nclass Node:\r\n def __init__(self):\r\n self.children=[None]*2\r\n self.cnt=0\r\n\r\n def __getitem__(self,i):\r\n return self.children[i]\r\n\r\n def __setitem__(self,i,x):\r\n self.children[i]=x\r\n\r\nclass Binary_Trie:\r\n def __init__(self,bit,default=False):\r\n self.bit=bit\r\n self.default=default\r\n self.root=Node()\r\n\r\n def Append(self,x):\r\n node=self.root\r\n node.cnt+=1\r\n for i in range(self.bit-1,-1,-1):\r\n xx=x>>i&1\r\n if node.children[xx]==None:\r\n node.children[xx]=Node()\r\n node=node.children[xx]\r\n node.cnt+=1\r\n\r\n def Remove(self,x):\r\n node=self.root\r\n node.cnt-=1\r\n for i in range(self.bit-1,-1,-1):\r\n xx=x>>i&1\r\n node=node.children[xx]\r\n node.cnt-=1\r\n if node.cnt<0:\r\n raise KeyError(x)\r\n\r\n def Discard(self,x):\r\n node=self.root\r\n for i in range(self.bit-1,-1,-1):\r\n xx=x>>i&1\r\n if node.children[xx]==None:\r\n return False\r\n node=node.children[xx]\r\n if node.cnt==0:\r\n return False\r\n node=self.root\r\n node.cnt-=1\r\n for i in range(self.bit-1,-1,-1):\r\n xx=x>>i&1\r\n node=node.children[xx]\r\n node.cnt-=1\r\n return True\r\n\r\n def Count(self,x,l,r):\r\n if l>=r:\r\n return 0\r\n cnt=0\r\n if l:\r\n node=self.root\r\n for i in range(self.bit-1,-1,-1):\r\n xx=x>>i&1\r\n ll=l>>i&1\r\n if ll:\r\n if node.children[xx]!=None:\r\n cnt-=node.children[xx].cnt\r\n node=node.children[xx^ll]\r\n if node==None:\r\n break\r\n if r==1<<self.bit:\r\n cnt+=self.root.cnt\r\n else:\r\n node=self.root\r\n for i in range(self.bit-1,-1,-1):\r\n xx=x>>i&1\r\n rr=r>>i&1\r\n if rr:\r\n if node.children[xx]!=None:\r\n cnt+=node.children[xx].cnt\r\n node=node.children[xx^rr]\r\n if node==None:\r\n break\r\n return cnt\r\n\r\n def Kth_Min_Element(self,k,x):\r\n node=self.root\r\n if node.cnt<=k:\r\n return None\r\n key=0\r\n for i in range(self.bit-1,-1,-1):\r\n xx=x>>i&1\r\n if node.children[xx]==None:\r\n node=node.children[xx^1]\r\n key|=(xx^1)<<i\r\n else:\r\n if node.children[xx].cnt>k:\r\n node=node.children[xx]\r\n key|=xx<<i\r\n else:\r\n k-=node.children[xx].cnt\r\n node=node.children[xx^1]\r\n key|=(xx^1)<<i\r\n return key\r\n\r\n def Kth_Max_Element(self,k,x):\r\n node=self.root\r\n if node.cnt<=k:\r\n return None\r\n key=0\r\n for i in range(self.bit-1,-1,-1):\r\n xx=x>>i&1\r\n if node.children[xx^1]!=None:\r\n if node.children[xx^1].cnt>k:\r\n node=node.children[xx^1]\r\n key|=(xx^1)<<i\r\n else:\r\n k-=node.children[xx^1].cnt\r\n node=node.children[xx]\r\n key|=xx<<i\r\n else:\r\n node=node.children[xx]\r\n key|=xx<<i\r\n return key\r\n\r\n def __getitem__(self,x):\r\n node=self.root\r\n for i in range(self.bit-1,-1,-1):\r\n xx=x>>i&1\r\n if node.children[xx]==None:\r\n if self.default:\r\n node.children[xx]=Node()\r\n node=node.children[xx]\r\n else:\r\n return None\r\n else:\r\n node=node.children[xx]\r\n return node\r\n\r\n def __len__(self):\r\n return self.root.cnt\r\n\r\nN=int(readline())\r\nBT=Binary_Trie(28)\r\nfor _ in range(N):\r\n data=map(int,readline().split())\r\n q=next(data)\r\n if q==1:\r\n p=next(data)\r\n BT.Append(p)\r\n elif q==2:\r\n p=next(data)\r\n BT.Discard(p)\r\n else:\r\n p,l=data\r\n ans=BT.Count(p,0,l)\r\n print(ans)", "import sys\r\ninput = sys.stdin.buffer.readline\r\n\r\ndef binary_trie(l):\r\n G0, G1, cnt = [-1], [-1], [0]\r\n return G0, G1, cnt, l\r\n\r\ndef insert(x):\r\n j = 0\r\n for i in range(l, -1, -1):\r\n cnt[j] += 1\r\n if x & pow2[i]:\r\n if G1[j] == -1:\r\n G0.append(-1)\r\n G1.append(-1)\r\n cnt.append(0)\r\n G1[j] = len(cnt) - 1\r\n j = G1[j]\r\n else:\r\n if G0[j] == -1:\r\n G0.append(-1)\r\n G1.append(-1)\r\n cnt.append(0)\r\n G0[j] = len(cnt) - 1\r\n j = G0[j]\r\n cnt[j] += 1\r\n return\r\n\r\ndef erase(x):\r\n j = 0\r\n for i in range(l, -1, -1):\r\n cnt[j] -= 1\r\n if x & pow2[i]:\r\n j = G1[j]\r\n else:\r\n j = G0[j]\r\n cnt[j] -= 1\r\n return\r\n\r\ndef xor_and_count_min(x, k):\r\n j = 0\r\n ans = 0\r\n for i in range(l, -1, -1):\r\n if not x & pow2[i]:\r\n if k & pow2[i]:\r\n if G0[j] ^ -1:\r\n ans += cnt[G0[j]]\r\n j = G1[j]\r\n else:\r\n j = G0[j]\r\n else:\r\n if k & pow2[i]:\r\n if G1[j] ^ -1:\r\n ans += cnt[G1[j]]\r\n j = G0[j]\r\n else:\r\n j = G1[j]\r\n return ans\r\n\r\nq = int(input())\r\npow2 = [1]\r\nfor _ in range(31):\r\n pow2.append(2 * pow2[-1])\r\nG0, G1, cnt, l = binary_trie(31)\r\nans = []\r\nfor _ in range(q):\r\n t = list(map(int, input().split()))\r\n p = t[1]\r\n if t[0] == 1:\r\n insert(p)\r\n elif t[0] == 2:\r\n erase(p)\r\n else:\r\n li = t[2]\r\n ans0 = xor_and_count_min(p, li)\r\n ans.append(ans0)\r\nsys.stdout.write(\"\\n\".join(map(str, ans)))", "from collections import *\r\nfrom functools import *\r\nfrom itertools import *\r\nfrom operator import *\r\nfrom bisect import *\r\nfrom heapq import *\r\nimport math\r\nimport re\r\nimport os\r\nimport io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\ndef I():\r\n return input().decode('utf-8').strip()\r\n \r\ndef II(base=10):\r\n return int(input(),base)\r\n \r\ndef MII():\r\n return map(int, input().split())\r\n \r\ndef LI():\r\n return list(input().split())\r\n \r\ndef LII():\r\n return list(map(int, input().split()))\r\n\r\nL = 28\r\nA = [defaultdict(int) for _ in range(L)]\r\nfor _ in range(II()):\r\n B = LII()\r\n if B[0]==1:\r\n p = B[1]\r\n for i in range(L):\r\n A[i][p>>i]+=1\r\n elif B[0]==2:\r\n p = B[1]\r\n for i in range(L):\r\n A[i][p>>i]-=1\r\n else:\r\n p,h = B[1],B[2]\r\n res = 0\r\n for i in range(L):\r\n if h&1:\r\n res += A[i][p^h^1]\r\n h >>= 1\r\n p >>= 1\r\n print(res)\r\n \r\n " ]
{"inputs": ["5\n1 3\n1 4\n3 6 3\n2 4\n3 6 3"], "outputs": ["1\n0"]}
UNKNOWN
PYTHON3
CODEFORCES
4
e40684cda255dcda1121368f0af3e27d
Periodic RMQ Problem
You are given an array *a* consisting of positive integers and *q* queries to this array. There are two types of queries: - 1 *l* *r* *x* — for each index *i* such that *l*<=≤<=*i*<=≤<=*r* set *a**i*<==<=*x*. - 2 *l* *r* — find the minimum among such *a**i* that *l*<=≤<=*i*<=≤<=*r*. We decided that this problem is too easy. So the array *a* is given in a compressed form: there is an array *b* consisting of *n* elements and a number *k* in the input, and before all queries *a* is equal to the concatenation of *k* arrays *b* (so the size of *a* is *n*·*k*). The first line contains two integers *n* and *k* (1<=≤<=*n*<=≤<=105, 1<=≤<=*k*<=≤<=104). The second line contains *n* integers — elements of the array *b* (1<=≤<=*b**i*<=≤<=109). The third line contains one integer *q* (1<=≤<=*q*<=≤<=105). Then *q* lines follow, each representing a query. Each query is given either as 1 *l* *r* *x* — set all elements in the segment from *l* till *r* (including borders) to *x* (1<=≤<=*l*<=≤<=*r*<=≤<=*n*·*k*, 1<=≤<=*x*<=≤<=109) or as 2 *l* *r* — find the minimum among all elements in the segment from *l* till *r* (1<=≤<=*l*<=≤<=*r*<=≤<=*n*·*k*). For each query of type 2 print the answer to this query — the minimum on the corresponding segment. Sample Input 3 1 1 2 3 3 2 1 3 1 1 2 4 2 1 3 3 2 1 2 3 5 2 4 4 1 4 4 5 2 4 4 1 1 6 1 2 6 6 Sample Output 1 3 1 5 1
[ "import sys\r\nimport random\r\n\r\ninput = sys.stdin.readline\r\nrd = random.randint(10 ** 9, 2 * 10 ** 9)\r\n\r\n\r\nclass SegmentTree():\r\n def __init__(self, init, unitX, f):\r\n self.f = f # (X, X) -> X\r\n self.unitX = unitX\r\n self.f = f\r\n if type(init) == int:\r\n self.n = init\r\n self.n = 1 << (self.n - 1).bit_length()\r\n self.X = [unitX] * (self.n * 2)\r\n else:\r\n self.n = len(init)\r\n self.n = 1 << (self.n - 1).bit_length()\r\n # len(init)が2の累乗ではない時UnitXで埋める\r\n self.X = [unitX] * self.n + init + [unitX] * (self.n - len(init))\r\n # 配列のindex1まで埋める\r\n for i in range(self.n - 1, 0, -1):\r\n self.X[i] = self.f(self.X[i * 2], self.X[i * 2 | 1])\r\n\r\n def update(self, i, x):\r\n \"\"\"0-indexedのi番目の値をxで置換\"\"\"\r\n # 最下段に移動\r\n i += self.n\r\n self.X[i] = x\r\n # 上向に更新\r\n i >>= 1\r\n while i:\r\n self.X[i] = self.f(self.X[i * 2], self.X[i * 2 | 1])\r\n i >>= 1\r\n\r\n def getvalue(self, i):\r\n \"\"\"元の配列のindexの値を見る\"\"\"\r\n return self.X[i + self.n]\r\n\r\n def getrange(self, l, r):\r\n \"\"\"区間[l, r)でのfを行った値\"\"\"\r\n l += self.n\r\n r += self.n\r\n al = self.unitX\r\n ar = self.unitX\r\n while l < r:\r\n # 左端が右子ノードであれば\r\n if l & 1:\r\n al = self.f(al, self.X[l])\r\n l += 1\r\n # 右端が右子ノードであれば\r\n if r & 1:\r\n r -= 1\r\n ar = self.f(self.X[r], ar)\r\n l >>= 1\r\n r >>= 1\r\n return self.f(al, ar)\r\n\r\n\r\nn, k = list(map(int, input().split()))\r\na = list(map(int, input().split()))\r\nq = int(input())\r\nqueries = [list(map(int, input().split())) for _ in range(q)]\r\nmin_tree = SegmentTree(a, 10 ** 9, min)\r\np = []\r\nfor qq in queries:\r\n p.append(qq[1] - 1)\r\n p.append(qq[2] - 1)\r\np.sort()\r\ncur = 0\r\npre = -1\r\nnew = []\r\nd = dict()\r\nfor i in range(len(p)):\r\n if p[i] == pre:\r\n continue\r\n if p[i] - pre > 1:\r\n if p[i] - pre > n:\r\n mi = min_tree.getrange(0, n)\r\n elif pre % n < p[i] % n:\r\n mi = min_tree.getrange(pre % n + 1, p[i] % n)\r\n else:\r\n mi = min(min_tree.getrange(pre % n + 1, n), min_tree.getrange(0, p[i] % n))\r\n new.append(mi)\r\n cur += 1\r\n new.append(a[p[i] % n])\r\n d[p[i]] = cur\r\n cur += 1\r\n pre = p[i]\r\n\r\n\r\ndef push_lazy(node, left, right):\r\n if lazy[node] != 0:\r\n tree[node] = lazy[node]\r\n if left != right:\r\n lazy[node * 2] = lazy[node]\r\n lazy[node * 2 + 1] = lazy[node]\r\n lazy[node] = 0\r\n\r\n\r\ndef update(node, left, right, l, r, val):\r\n push_lazy(node, left, right)\r\n if r < left or l > right:\r\n return\r\n if l <= left and r >= right:\r\n lazy[node] = val\r\n push_lazy(node, left, right)\r\n return\r\n mid = (left + right) // 2\r\n update(node * 2, left, mid, l, r, val)\r\n update(node * 2 + 1, mid + 1, right, l, r, val)\r\n tree[node] = min(tree[node * 2], tree[node * 2 + 1])\r\n\r\n\r\ndef query(node, left, right, l, r):\r\n push_lazy(node, left, right)\r\n if r < left or l > right:\r\n return 10**18\r\n if l <= left and r >= right:\r\n return tree[node]\r\n mid = (left + right) // 2\r\n sum_left = query(node * 2, left, mid, l, r)\r\n sum_right = query(node * 2 + 1, mid + 1, right, l, r)\r\n return min(sum_left, sum_right)\r\n\r\n\r\ntree = [10 ** 18] * (4 * len(new))\r\nlazy = [0] * (4 * len(new))\r\nfor i in range(len(new)):\r\n update(1, 0, len(new) - 1, i, i, new[i])\r\nfor qq in queries:\r\n if qq[0] == 1:\r\n l, r = qq[1] - 1, qq[2] - 1\r\n update(1, 0, len(new) - 1, d[l], d[r], qq[3])\r\n else:\r\n l, r = qq[1] - 1, qq[2] - 1\r\n print(query(1, 0, len(new) - 1, d[l], d[r]))\r\n\r\n" ]
{"inputs": ["3 1\n1 2 3\n3\n2 1 3\n1 1 2 4\n2 1 3", "3 2\n1 2 3\n5\n2 4 4\n1 4 4 5\n2 4 4\n1 1 6 1\n2 6 6", "10 10\n10 8 10 9 2 2 4 6 10 1\n10\n1 17 87 5\n2 31 94\n1 5 56 8\n1 56 90 10\n1 25 93 6\n1 11 32 4\n2 20 49\n1 46 87 8\n2 14 48\n2 40 48", "10 10\n4 2 3 8 1 2 1 7 5 4\n10\n2 63 87\n2 2 48\n2 5 62\n2 33 85\n2 30 100\n2 38 94\n2 7 81\n2 13 16\n2 26 36\n2 64 96"], "outputs": ["1\n3", "1\n5\n1", "1\n4\n4\n6", "1\n1\n1\n1\n1\n1\n1\n1\n1\n1"]}
UNKNOWN
PYTHON3
CODEFORCES
1
e40c630afd73a6f1182ef69cbf40aad2
Infinite Inversions
There is an infinite sequence consisting of all positive integers in the increasing order: *p*<==<={1,<=2,<=3,<=...}. We performed *n* swap operations with this sequence. A *swap*(*a*,<=*b*) is an operation of swapping the elements of the sequence on positions *a* and *b*. Your task is to find the number of inversions in the resulting sequence, i.e. the number of such index pairs (*i*,<=*j*), that *i*<=&lt;<=*j* and *p**i*<=&gt;<=*p**j*. The first line contains a single integer *n* (1<=≤<=*n*<=≤<=105) — the number of swap operations applied to the sequence. Each of the next *n* lines contains two integers *a**i* and *b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=109, *a**i*<=≠<=*b**i*) — the arguments of the swap operation. Print a single integer — the number of inversions in the resulting sequence. Sample Input 2 4 2 1 4 3 1 6 3 4 2 5 Sample Output 4 15
[ "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\ndef get_sum(i):\r\n s = 0\r\n while i > 0:\r\n s += tree[i]\r\n i -= i & -i\r\n return s\r\n\r\ndef add(i, x):\r\n while i < len(tree):\r\n tree[i] += x\r\n i += i & -i\r\n\r\nn = int(input())\r\nab = [tuple(map(int, input().split())) for _ in range(n)]\r\ns = [0]\r\nfor a, b in ab:\r\n s.append(a)\r\n s.append(b)\r\ns = list(set(sorted(s)))\r\ns.sort()\r\nd = dict()\r\nl = len(s)\r\nfor i in range(l):\r\n d[s[i]] = i\r\nx = [i for i in range(l)]\r\nfor a, b in ab:\r\n u, v = d[a], d[b]\r\n x[u], x[v] = x[v], x[u]\r\ntree = [0] * (l + 5)\r\nans = 0\r\nfor i in x[::-1][:-1]:\r\n ans += get_sum(i)\r\n add(i, 1)\r\nfor i in range(1, l):\r\n j = x[i]\r\n ans += abs(s[i] - s[j])\r\n ans -= abs(i - j)\r\nprint(ans)", "import sys\r\ninput = sys.stdin.readline\r\ndef fg():\r\n return int(input())\r\ndef fgh():\r\n return [int(xx) for xx in input().split()]\r\ndef sd():\r\n print('YES')\r\ndef df():\r\n print('NO')\r\ndef s(l, r):\r\n return p(r) - p(l)\r\ndef p(i):\r\n ans = 0\r\n while i:\r\n ans += R[i]\r\n i -= F[i]\r\n return ans\r\ndef pl(i, x):\r\n global R\r\n global m\r\n while i <= m + 1:\r\n R[i] += x\r\n i += F[i]\r\nF = []\r\nfor i in range(2 * 10 ** 5 + 3):\r\n F.append(i & (-i))\r\nn = fg()\r\nc = []\r\nfor i in range(n):\r\n a, b = fgh()\r\n c.append((a, b))\r\na = []\r\nd = {}\r\nfor i in range(n):\r\n if c[i][0] not in d:\r\n d[c[i][0]] = len(a)\r\n a.append(c[i][0])\r\n if c[i][1] not in d:\r\n d[c[i][1]] = len(a)\r\n a.append(c[i][1])\r\na = sorted(a)\r\nm = len(a)\r\nfor i in range(m):\r\n d[a[i]] = i\r\nb = a[:]\r\nfor i in range(n):\r\n b[d[c[i][0]]], b[d[c[i][1]]] = b[d[c[i][1]]], b[d[c[i][0]]]\r\n d[c[i][0]], d[c[i][1]] = d[c[i][1]], d[c[i][0]]\r\na = sorted(a)\r\nm = len(a)\r\ne = {}\r\nc = []\r\nfor i in range(m):\r\n e[a[i]] = i\r\nfor i in range(m):\r\n c.append(e[b[i]])\r\nQ = [0] * (m + 2)\r\npr = [0]\r\nQ[c[0]] = 1\r\nans = 0\r\nfor i in range(m + 1):\r\n pr.append(pr[-1] + Q[i])\r\nR = [0] * (m + 2)\r\nfor i in range(1, m + 2):\r\n R[i] = pr[i] - pr[i - F[i]]\r\nfor i in range(m - 1):\r\n k = p(m + 1) - p(i + 1)\r\n ans += (a[i + 1] - a[i] - 1) * k\r\n pl(c[i + 1] + 1, 1)\r\n\r\nQ = [0] * (m + 2)\r\npr = [0]\r\nQ[c[-1]] = 1\r\nfor i in range(m + 1):\r\n pr.append(pr[-1] + Q[i])\r\nR = [0] * (m + 2)\r\nfor i in range(1, m + 2):\r\n R[i] = pr[i] - pr[i - F[i]]\r\nfor i in range(m - 2, -1, -1):\r\n k = p(i + 1)\r\n ans += (a[i + 1] - a[i] - 1) * k\r\n pl(c[i] + 1, 1)\r\nQ = [0] * (m + 2)\r\npr = [0]\r\nQ[c[-1]] = 1\r\nfor i in range(m + 1):\r\n pr.append(pr[-1] + Q[i])\r\nR = [0] * (m + 2)\r\nfor i in range(1, m + 2):\r\n R[i] = pr[i] - pr[i - F[i]]\r\nfor i in range(m - 2, -1, -1):\r\n k = p(c[i] + 1)\r\n ans += k\r\n pl(c[i] + 1, 1)\r\nprint(ans)\r\n" ]
{"inputs": ["2\n4 2\n1 4", "3\n1 6\n3 4\n2 5", "1\n1000000000 1", "5\n2 5\n6 3\n4 6\n5 4\n2 5", "4\n2 5\n4 3\n1 4\n6 2", "3\n1 3\n4 6\n5 2", "5\n1 1000000000\n2 999999999\n3 999999998\n4 999999997\n5 999999996", "30\n1 200000\n2 199999\n3 199998\n4 199997\n5 199996\n200001 399996\n200002 399997\n200003 399998\n200004 399999\n200005 400000\n400001 599998\n400002 599999\n400003 600000\n400004 599996\n400005 599995\n600001 800000\n600002 799999\n600003 799998\n600004 799997\n600005 799996\n600001 799998\n600002 799999\n600003 800000\n600004 799996\n600005 799997\n800001 999998\n800002 999997\n800003 999999\n800004 999996\n800005 1000000"], "outputs": ["4", "15", "1999999997", "5", "8", "7", "9999999945", "7999746"]}
UNKNOWN
PYTHON3
CODEFORCES
2
e421645e9eb603b650a8ddacc45396f5
Jamie and Interesting Graph
Jamie has recently found undirected weighted graphs with the following properties very interesting: - The graph is connected and contains exactly *n* vertices and *m* edges. - All edge weights are integers and are in range [1,<=109] inclusive. - The length of shortest path from 1 to *n* is a prime number. - The sum of edges' weights in the minimum spanning tree (MST) of the graph is a prime number. - The graph contains no loops or multi-edges. If you are not familiar with some terms from the statement you can find definitions of them in notes section. Help Jamie construct any graph with given number of vertices and edges that is interesting! First line of input contains 2 integers *n*, *m*  — the required number of vertices and edges. In the first line output 2 integers *sp*, *mstw* (1<=≤<=*sp*,<=*mstw*<=≤<=1014) — the length of the shortest path and the sum of edges' weights in the minimum spanning tree. In the next *m* lines output the edges of the graph. In each line output 3 integers *u*, *v*, *w* (1<=≤<=*u*,<=*v*<=≤<=*n*,<=1<=≤<=*w*<=≤<=109) describing the edge connecting *u* and *v* and having weight *w*. Sample Input 4 4 5 4 Sample Output 7 7 1 2 3 2 3 2 3 4 2 2 4 4 7 13 1 2 2 1 3 4 1 4 3 4 5 4
[ "def doit(n, m):\r\n if (n == 2):\r\n print(2, 2)\r\n print(1, 2, 2)\r\n return\r\n sp = 2\r\n mstw = 100003\r\n print(sp, mstw)\r\n print(1, n, sp)\r\n print(2, n, mstw - n + 3 - sp)\r\n for i in range(3, n):\r\n print(i, n, 1)\r\n for i in range(2, n):\r\n for j in range(1, i):\r\n if (m == n - 1):\r\n return\r\n print(i, j, mstw)\r\n m -= 1\r\n\r\nn, m = input().split()\r\ndoit(int(n), int(m))\r\n", "n, m = list(map(int, input().strip().split()))\r\nprime = 100003\r\n\r\nif n == 2:\r\n print(2, 2)\r\n print(1, 2, 2)\r\nelse:\r\n print(2, prime)\r\n print(1, n, 2)\r\n remaining = prime - 2\r\n for i in range(2, n-1):\r\n print(1, i, 1)\r\n remaining -= 1\r\n print(1, n-1, remaining)\r\n remaining_arc = m - (n - 1)\r\n while remaining_arc:\r\n for i in range(2, n):\r\n for j in range(i+1, n+1):\r\n print(i, j, prime+2)\r\n remaining_arc -= 1\r\n if not remaining_arc:\r\n break\r\n if not remaining_arc:\r\n break\r\n\r\n", "INF = 1000000\nerast = [1] * INF\nerast[1] = 0\n\nprimes = []\nfor i in range(2, INF):\n if erast[i] == 1:\n for j in range(i * 2, INF, i):\n erast[j] = 0\n primes.append(i)\n# print(primes)\nlastp = primes[-1]\nn, m = map(int, input().split())\nedges = set()\nprint(lastp, lastp)\nfor i in range(n - 2):\n print(i + 1, i + 2, 1)\n edges.add((i, i + 1))\n edges.add((i + 1, i))\n\nprint(n - 1, n, lastp - n + 2)\nedges.add((n - 1, n))\nedges.add((n, n - 1))\n\nm -= n - 1\nfor i in range(0, n):\n for j in range(0, n):\n if i == j: continue\n if m == 0: break\n if not (i, j) in edges:\n m -= 1\n print(i + 1, j + 1, INF)\n edges.add((i, j))\n edges.add((j, i))\n\n\n", "from math import sqrt\r\ndef check(number):\r\n\tflag = 1\r\n\tlimit = int(sqrt(number))\r\n\r\n\tif number == 0:\r\n\t\treturn 0\r\n\tfor i in range(2,limit+1):\r\n\r\n\t\tif number%i != 0:\r\n\t\t\tcontinue\r\n\t\telse:\r\n\t\t\tflag = 0\r\n\t\t\tbreak\r\n\treturn flag\r\n\r\ndef nextprime(number):\r\n\tfor i in range(number+1, number+10**6):\r\n\t\tif check(i):\r\n\r\n\t\t\treturn i\r\n\r\n\r\nn, m = map(int, input().split(' '))\r\n\r\n\r\nans = []\r\nrem = 0\r\nl = []\r\nif n == 2:\r\n\tprint(2,2)\r\n\tprint(1,2,2)\r\nelse:\r\n\r\n\tfor i in range(n-2):\r\n\t\tl.append([i+1, i+2, 1])\r\n\t\trem += 1\r\n\tf = nextprime(rem)\r\n\r\n\tl.append([n-1, n, f-rem])\r\n\tprint(f, f)\r\n\tfor i in l:\r\n\t\tprint(*i)\r\n\tnode = 1\r\n\tnextnode = node+2\r\n\tfor i in range(m-n+1):\r\n\t\tif nextnode > n:\r\n\t\t\tnode += 1\r\n\t\t\tnextnode = node+2\r\n\t\tprint(node, nextnode, f+100)\r\n\t\tnextnode += 1\r\n\r\n\r\n\r\n\r\n", "n,m=map(int,input().split())\r\n\r\nif(n==2):\r\n print(3,3)\r\n print(1,2,3)\r\nelse:\r\n ini=1\r\n print(3,100003)\r\n \r\n print(1,n,3)\r\n \r\n for i in range(2,n-1):\r\n print(1,i,1)\r\n print(1,n-1,10**5-(n-3))\r\n count=n-1\r\n ini=2\r\n \r\n \r\n \r\n while(count<m):\r\n for i in range(ini+1,n+1):\r\n \r\n count+=1\r\n print(ini,i,10000000)\r\n if(count>=m):\r\n break\r\n ini+=1\r\n \r\n", "n,m=map(int,input().split())\r\no=[]\r\nr=2\r\nfor i in range(2,n-1):\r\n o.append('1 %i 1'%i)\r\n r+=1\r\no.append('1 %i 2'%n)\r\nif n>2:\r\n o.append('1 %i %i'%(n-1,100019-(n-1)))\r\n r+=100019-(n-1)\r\nm-=n-1\r\nfor i in range(2,n+1):\r\n if m<=0:break\r\n for j in range(i+1,n+1):\r\n if m<=0:break\r\n o.append('%i %i 100020'%(i,j))\r\n m-=1\r\nprint('2 %i'%r)\r\nprint('\\n'.join(o))", "from collections import deque\n\n\ndef solve():\n\tn,m = map(int,input().split())\n\tlprime = 100003\n\tprint(lprime,lprime)\n\tprint(1,2,lprime-n+2)\n\tfor i in range(2,n):\n\t\tprint(i,i+1,1)\n\tm-=n-1\n\tl,h = 1,3\n\twhile m:\n\t\tprint(l,h,int(1e9))\n\t\th+=1\n\t\tif h>n:\n\t\t\tl+=1\n\t\t\th=l+2\n\t\tm-=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\nt = 1\n#t = int(input())\n\nfor i in range(t):\n\tsolve()", "def solve(n, m):\r\n out = '%d %d\\n' % (prime, prime)\r\n for i in range(1, n-1):\r\n out += '%d %d %d\\n' % (i, i+1, 1)\r\n out += '%d %d %d\\n' % (n-1, n, prime-n+2)\r\n m -= n-1\r\n for i in range(1, n-1):\r\n for j in range(i+2, n+1):\r\n if m == 0:\r\n return out\r\n else:\r\n m -= 1\r\n out += '%d %d %d\\n' % (i, j, maximum)\r\n return out\r\n\r\n\r\nprime = 100003\r\nmaximum = 1000000000\r\n\r\nif __name__ == '__main__':\r\n n, m = map(int, input().split())\r\n print(solve(n, m))", "n,m = list(map(int,input().split()))\r\nprint(2 *10**5-1,2 * 10**5 - 1)\r\nfor i in range(1, n - 1):\r\n print(i, i + 1, 1)\r\nprint(n - 1, n, 2 * 10 ** 5 -1 - (n-2))\r\nimport sys\r\nif (m>=n):\r\n k = n\r\n j = 1\r\n for i in range(1,n):\r\n for j in range(i+2,n + 1):\r\n print(i,j, 2 * 10**5)\r\n k +=1\r\n if k >m:\r\n sys.exit()\r\n \r\n", "n, m = map(int, input().split())\r\n\r\np = 999983\r\n\r\nprint(p, p)\r\n\r\nans = list()\r\n\r\n\r\ndef to_ans(*arr):\r\n return ' '.join(map(str, arr))\r\n\r\n\r\nif n == 2:\r\n print(1, 2, p)\r\n exit()\r\n\r\nans.append(to_ans(1, 2, 2))\r\n\r\nfor i in range(2, n - 1):\r\n ans.append(to_ans(i, i + 1, 1))\r\n\r\nans.append(to_ans(n - 1, n, p - (n - 1)))\r\n\r\nx = n - 1\r\n\r\nif x == m:\r\n print('\\n'.join(ans))\r\n exit()\r\n\r\nfor i in range(1, n - 1):\r\n for j in range(i + 2, n + 1):\r\n ans.append(to_ans(i, j, 10 ** 8))\r\n x += 1\r\n\r\n if x == m:\r\n print('\\n'.join(ans))\r\n exit()\r\n", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\nread = lambda: map(int, input().split())\n\n\ndef generate_first_prime(lower, upper):\n if upper < lower:\n return -1\n if lower is 2:\n return 2\n lower = lower + 1 if lower & 1 is 0 else lower\n for num in range(lower, upper + 1, 2):\n for i in range(2, num):\n if (num % i) is 0:\n break\n else:\n return num\n return -1\n\n\ndef main():\n n, m = read()\n p = generate_first_prime(n, 2 * n - 2)\n print(2, p)\n n1 = 2 * (n - 1) - p\n n2 = p - (n - 1)\n index = 2\n for _ in range(n1):\n print(1, index, 1)\n index += 1\n for _ in range(n2):\n print(1, index, 2)\n index += 1\n remain = m - (n - 1)\n i = 2\n j = 3\n while remain:\n print(i, j, 999)\n j += 1\n if j > n:\n i += 1\n j = i + 1\n remain -= 1\n \n\nmain()\n", "n,m = map(int,input().split())\r\nprime = 100003\r\nfirst = prime-n+2\r\ntotal = prime\r\nm = m-n+1\r\nsol = []\r\nsol.append((1,2,first))\r\nfor i in range(2,n):\r\n\tsol.append((i,i+1,1))\r\nprint(\"{} {}\".format(prime,prime))\r\nfor i in sol:\r\n\tprint(\"{} {} {}\".format(i[0],i[1],i[2]))\r\nprime+=1\r\nfor k in range(2,n):\r\n\tfor i in range(1,n):\r\n\t\tfor j in range(i+k,n+1):\r\n\t\t\tif(m>0):\r\n\t\t\t\tprint(\"{} {} {}\".format(i,j,prime))\r\n\t\t\t\tprime += 1\r\n\t\t\t\tm -= 1\r\n\t\t\telse:\r\n\t\t\t\texit(0)", "n, m = map(int, input().split())\ngr = { u:[] for u in range(1, n + 1)}\n\nfor p in range(n + 3, 1000000):\n isprime = True\n for k in range(2, p):\n if p % k == 0:\n isprime = False\n break\n elif p < k * k:\n break\n if isprime:\n c = p - n + 2\n break\n\nfor u in range(1, n - 1):\n gr[u].append((u + 1, 1))\nif 1 < n:\n gr[n - 1].append((n, c))\n\ncnt = n - 1\nu = 1\nv = 2\nwhile cnt < m:\n if v == n:\n u += 1\n v = u + 2\n else:\n v += 1\n gr[u].append((v, 1000000000))\n cnt += 1\n\nprint('%d %d' % (p, p))\nfor u in gr.keys():\n for (v, c) in gr[u]:\n print('%d %d %d' % (u, v, c))\n", "n, m = list(map(int, input().split()))\r\nprint(100003, 100003)\r\nprint(1, 2, 100005 - n)\r\nfor i in range(1, n-1):\r\n print(i+1, i+2, 1)\r\n\r\nl = 1\r\nh = 3\r\nfor i in range(m - n + 1):\r\n print(l, h, 10**9)\r\n h += 1\r\n if (h > n):\r\n l += 1\r\n h = l + 2", "pr, inf = 100003, 1000000000\r\nn, m = [int(i) for i in input().split()]\r\ncr, crs = 0, 0\r\nprint(pr, pr)\r\nfor i in range(1, n):\r\n if cr == n - 2:\r\n print(i, i + 1, pr - crs)\r\n else:\r\n print(i, i + 1, 1)\r\n crs += 1\r\n cr += 1\r\nfor i in range(1, n + 1):\r\n if cr == m:\r\n break\r\n for j in range(i + 2, n + 1):\r\n print(i, j, inf)\r\n cr += 1\r\n if cr == m:\r\n break\r\n \r\n", " ###### ### ####### ####### ## # ##### ### ##### \r\n # # # # # # # # # # # # # ### \r\n # # # # # # # # # # # # # ### \r\n ###### ######### # # # # # # ######### # \r\n ###### ######### # # # # # # ######### # \r\n # # # # # # # # # # #### # # # \r\n # # # # # # # ## # # # # # \r\n ###### # # ####### ####### # # ##### # # # # \r\n\r\n# from __future__ import print_function # for PyPy2\r\nfrom collections import Counter, OrderedDict\r\nfrom itertools import permutations as perm\r\nfrom fractions import Fraction\r\nfrom collections import deque\r\nfrom sys import stdin\r\nfrom bisect import *\r\nfrom heapq import *\r\nfrom math import *\r\n\r\ng = lambda : stdin.readline().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\nmod = int(1e9)+7\r\ninf = float(\"inf\") \r\n\r\nn, m = gil()\r\n\r\nN = int(1e6)\r\np = [1]*(N+1)\r\n\r\nfor i in range(2, 1001):\r\n if p[i]:\r\n for j in range(i+i, N+1, i):\r\n p[j] = 0\r\n\r\ne = []\r\ncst = 0\r\nfor i in range(n, N+1):\r\n if p[i]:\r\n cst = i\r\n break\r\n\r\n\r\nfor i in range(2, n):\r\n e.append((i-1, i, 1))\r\n\r\ne.append((n-1, n, cst-n+2))\r\n\r\nm -= n-1\r\n\r\nfor i in range(1, n+1):\r\n if m == 0:break\r\n for j in range(i+2, n+1):\r\n if m == 0:break\r\n e.append((i, j, cst+1))\r\n m -= 1\r\n\r\nprint(cst, cst)\r\nfor r in e:\r\n print(*r)\r\n", "n,m = map(int,input().split())\na = [0 for i in range(2*n)]\nfor i in range(2,2*n):\n if a[i] == 0:\n if i >= n:\n break\n j = 1\n while i*j < 2*n:\n a[i*j] = 1\n j += 1\nprint(2,i)\nprint(1,n,2)\nif n - 2 == 1:\n print(1,2,1)\nelif n-2 > 1:\n print(1,2,i-n+1)\n for j in range(n-3):\n print(j+2,j+3,1)\ntime = 0\nt = []\nfor j in range(1,n-1):\n for k in range(j+2,n+1):\n if (j-k)**2 > 1 and not (j == 1 and k == n):\n t.append([j,k])\n time += 1\n if time > 10**5:\n break\nt.append([n-1,n])\nfor j in range(m-n+1):\n print(t[j][0],t[j][1],10**9)\n ", "n, m = map(int, input().split())\np = int(1e5+3)\nmaxw = int(1e9)\nprint('{} {}'.format(p, p))\nprint('{} {} {}'.format(1, 2, p-n+2))\nfor i in range(2, n):\n print('{} {} {}'.format(i, i+1, 1))\n\nif m > n-1:\n count = 0\n for i in range(1, n+1):\n if count >= m-n+1:\n break\n for j in range(i+2, n+1):\n print('{} {} {}'.format(i, j, maxw))\n count += 1\n if count >= m-n+1:\n break\n \n\n", "from sys import exit\r\n\r\nn, m = [int(i) for i in input().split()]\r\ninf = 10 ** 9\r\npr = 10 ** 8 + 7\r\nprint(pr, pr)\r\nch = 0\r\nfor i in range(n - 2):\r\n ch += 1\r\n print(i + 1, i + 2, 1)\r\nprint(n - 1, n, pr - n + 2)\r\nch += 1\r\nfor i in range(1, n):\r\n for j in range(i + 2, n + 1):\r\n if ch < m:\r\n print(i, j, inf)\r\n ch += 1\r\n else:\r\n exit(0)", "def addEdge(res,m):\r\n if len(res)>=m:\r\n return\r\n for i in range(1,n):\r\n for j in range(i+2,n+1):\r\n res.append([i,j,1000000000])\r\n if len(res)>=m:\r\n return\r\n\r\nn, m = map(int, input().split())\r\n\r\nres = []\r\nprev = 1\r\nfor i in range(2,n+1):\r\n res.append([prev,i,1])\r\n prev = i\r\nres[0][2] += 100003 - len(res)\r\naddEdge(res,m)\r\nprint(100003,100003)\r\nfor i in res:\r\n print(*i)", "n, m = map(int, input().split())\r\np = 524287\r\nprint(2, (p if m > 1 else 2))\r\nfor i in range(2, n + 1):\r\n w = 1\r\n if i == 2:\r\n w = p - n + 1\r\n if i == n:\r\n w = 2\r\n print(1, i, w)\r\n\r\nif m >= n:\r\n current = 2\r\n next = current + 1\r\n for i in range(0, m - n + 1):\r\n print(current, next, p)\r\n next += 1\r\n if next > n:\r\n current += 1\r\n next = current + 1", "n, m = map(int, input().split())\r\np = int(7e5+1)\r\nprint(p, p)\r\nfor i in range(n-2):\r\n print(i+1, i+2, 1)\r\nprint(n-1, n, p-n+2)\r\nm -= (n-1)\r\nfor i in range(n):\r\n for j in range(i+2, n):\r\n if m == 0:\r\n exit()\r\n m -= 1\r\n print(i+1, j+1, int(1e8))\r\n", "n,m = map(int, input().split())\r\n\r\ng = [[] for i in range(n)]\r\nedges =[]\r\nfor i in range(n-1):\r\n edges.append([i, i+1, 1])\r\n \r\n \r\ndef prime(k):\r\n if k == 1:\r\n return False\r\n import math\r\n for i in range(2, int(math.sqrt(k)) + 1):\r\n if k % i == 0:\r\n return False\r\n return True\r\n\r\np = n-1\r\nwhile not prime(p):\r\n p += 1\r\nleft = p - (n-1)\r\ncur = 0\r\nwhile left > 0:\r\n edges[cur][2] += 1 \r\n cur += 1\r\n cur %= (n-1)\r\n left -=1\r\nmw = edges[0][2] + 1\r\nleft = m - (n-1)\r\nfor i in range(n):\r\n if left == 0: break\r\n for j in range(i + 2, n):\r\n edges.append([i, j, mw*(j-i)])\r\n left -= 1\r\n if left == 0:\r\n break\r\n if left == 0:\r\n break\r\nprint(p, p)\r\nfor e in edges:\r\n print(' '.join([str(i) for i in [e[0]+1, e[1]+1, e[2]]]))" ]
{"inputs": ["4 4", "5 4", "2 1", "10 19", "9 18", "92 280", "89 3439", "926 31057", "753 98686", "9724 31045", "8732 93395", "80297 83088", "86549 98929", "87 109", "95 3582", "96 557", "85 3106", "98 367", "77 2344", "84 286", "100 4665", "94 350", "100 4309", "88 666", "93 4075", "100 342", "84 3482", "943 51645", "808 63768", "898 1882", "662 76813", "681 13806", "991 92176", "745 4986", "954 94880", "965 5451", "943 95302", "879 8524", "953 98192", "806 1771", "790 97497", "9492 36483", "5839 48668", "9029 15632", "5127 53185", "7044 33010", "9637 98924", "7837 45130", "9603 99398", "9204 11722", "6996 90227", "9897 21204", "9051 92600", "9880 13424", "9811 89446", "90498 92256", "99840 99968", "92340 92571", "99019 99681", "93750 94653", "99831 99956", "95373 95859", "95519 99837", "94183 94638", "84935 98326", "94995 95821", "88804 99911", "93394 94036", "97796 99885", "3 2", "3 3", "4 3", "4 5", "4 6", "100000 100000", "50000 100000", "1415 100000", "13 17", "19 31"], "outputs": ["100003 100003\n1 2 100001\n2 3 1\n3 4 1\n1 3 1000000000", "100003 100003\n1 2 100000\n2 3 1\n3 4 1\n4 5 1", "100003 100003\n1 2 100003", "100003 100003\n1 2 99995\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n1 3 1000000000\n1 4 1000000000\n1 5 1000000000\n1 6 1000000000\n1 7 1000000000\n1 8 1000000000\n1 9 1000000000\n1 10 1000000000\n2 4 1000000000\n2 5 1000000000", "100003 100003\n1 2 99996\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n1 3 1000000000\n1 4 1000000000\n1 5 1000000000\n1 6 1000000000\n1 7 1000000000\n1 8 1000000000\n1 9 1000000000\n2 4 1000000000\n2 5 1000000000\n2 6 1000000000", "100003 100003\n1 2 99913\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99916\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99079\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99252\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 90281\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 91273\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 19708\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 13456\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99918\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99910\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99909\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99920\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99907\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99928\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99921\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99905\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99911\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99905\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99917\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99912\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99905\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99921\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99062\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99197\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99107\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99343\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99324\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99014\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99260\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99051\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99040\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99062\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99126\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99052\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99199\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99215\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 90513\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 94166\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 90976\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 94878\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 92961\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 90368\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 92168\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 90402\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 90801\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 93009\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 90108\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 90954\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 90125\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 90194\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 9507\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 ...", "100003 100003\n1 2 165\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 1...", "100003 100003\n1 2 7665\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 ...", "100003 100003\n1 2 986\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 1...", "100003 100003\n1 2 6255\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 ...", "100003 100003\n1 2 174\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 1...", "100003 100003\n1 2 4632\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 ...", "100003 100003\n1 2 4486\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 ...", "100003 100003\n1 2 5822\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 ...", "100003 100003\n1 2 15070\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 5010\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 ...", "100003 100003\n1 2 11201\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 6611\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 ...", "100003 100003\n1 2 2209\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 ...", "100003 100003\n1 2 100002\n2 3 1", "100003 100003\n1 2 100002\n2 3 1\n1 3 1000000000", "100003 100003\n1 2 100001\n2 3 1\n3 4 1", "100003 100003\n1 2 100001\n2 3 1\n3 4 1\n1 3 1000000000\n1 4 1000000000", "100003 100003\n1 2 100001\n2 3 1\n3 4 1\n1 3 1000000000\n1 4 1000000000\n2 4 1000000000", "100003 100003\n1 2 5\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58 1\n...", "100003 100003\n1 2 50005\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 98590\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n19 20 1\n20 21 1\n21 22 1\n22 23 1\n23 24 1\n24 25 1\n25 26 1\n26 27 1\n27 28 1\n28 29 1\n29 30 1\n30 31 1\n31 32 1\n32 33 1\n33 34 1\n34 35 1\n35 36 1\n36 37 1\n37 38 1\n38 39 1\n39 40 1\n40 41 1\n41 42 1\n42 43 1\n43 44 1\n44 45 1\n45 46 1\n46 47 1\n47 48 1\n48 49 1\n49 50 1\n50 51 1\n51 52 1\n52 53 1\n53 54 1\n54 55 1\n55 56 1\n56 57 1\n57 58...", "100003 100003\n1 2 99992\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n1 3 1000000000\n1 4 1000000000\n1 5 1000000000\n1 6 1000000000\n1 7 1000000000", "100003 100003\n1 2 99986\n2 3 1\n3 4 1\n4 5 1\n5 6 1\n6 7 1\n7 8 1\n8 9 1\n9 10 1\n10 11 1\n11 12 1\n12 13 1\n13 14 1\n14 15 1\n15 16 1\n16 17 1\n17 18 1\n18 19 1\n1 3 1000000000\n1 4 1000000000\n1 5 1000000000\n1 6 1000000000\n1 7 1000000000\n1 8 1000000000\n1 9 1000000000\n1 10 1000000000\n1 11 1000000000\n1 12 1000000000\n1 13 1000000000\n1 14 1000000000\n1 15 1000000000"]}
UNKNOWN
PYTHON3
CODEFORCES
23
e45b65b89c65f1b5c76b0d160106837e
Little Girl and Maximum XOR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers *l* and *r*. Let's consider the values of for all pairs of integers *a* and *b* (*l*<=≤<=*a*<=≤<=*b*<=≤<=*r*). Your task is to find the maximum value among all considered ones. Expression means applying bitwise excluding or operation to integers *x* and *y*. The given operation exists in all modern programming languages, for example, in languages *C*++ and *Java* it is represented as "^", in *Pascal* — as "xor". The single line contains space-separated integers *l* and *r* (1<=≤<=*l*<=≤<=*r*<=≤<=1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier. In a single line print a single integer — the maximum value of for all pairs of integers *a*, *b* (*l*<=≤<=*a*<=≤<=*b*<=≤<=*r*). Sample Input 1 2 8 16 1 1 Sample Output 3 31 0
[ "a,b=map(int,input().split())\r\na=a^b\r\ndef setb(a):\r\n for i in range(63,-1,-1):\r\n if(a&(1<<i)):\r\n return i+1\r\n return 0\r\nz=setb(a)\r\nprint((2**z)-1)\r\n", "x=1000000007\nfor _ in range(1):\n l,r=map(int,input().split())\n lb=str(bin(l))[2:]\n rb=str(bin(r))[2:]\n s=\"1\"*len(rb)\n if l==r:\n print(0)\n elif(len(lb)==len(rb)):\n c=0\n for i in range(len(rb)):\n if lb[i]!=rb[i]:\n break\n c+=1\n s=\"1\"*(len(rb)-c)\n print(int(s,2))\n else:\n print(int(s,2))\n \t \t\t\t \t\t\t\t \t\t \t\t \t \t\t\t", "import sys\r\nfrom bisect import bisect_left,bisect_right\r\nfrom collections import defaultdict as dd\r\nfrom collections import deque\r\nfrom functools import cache\r\nfrom heapq import heappop,heappush,heapify\r\nfrom itertools import permutations, accumulate\r\nfrom math import lcm,gcd,sqrt,ceil,comb\r\ntoBin=lambda x:bin(x).replace(\"0b\",\"\")\r\ninf=float(\"inf\");DIRS=[[1,0],[-1,0],[0,1],[0,-1]];CHARS=\"abcdefghijklmnopqrstuvwxyz\"\r\nMOD=10**9+7;N=300010;fac=[1]*N;invfac=[1]*N #Fill out N to calculate combinations\r\nfor i in range(2,N):fac[i]=fac[i-1]*i%MOD\r\ninvfac[N-1]=pow(fac[N-1],MOD-2,MOD)\r\nfor i in range(N-1)[::-1]:invfac[i]=invfac[i+1]*(i+1)%MOD\r\ndef c(i,j):return 0 if i<j else fac[i]*invfac[j]*invfac[i-j]\r\ninput=sys.stdin.readline\r\n\r\ndef solve():\r\n \"\"\"\r\n 1011101 -> 1001\r\n 0110101\r\n\r\n 1 1 1\r\n 1 0 1\r\n\r\n MSB just has to be XOR'd\r\n the lower bounded numbers cannot go from 1 to 0, bc that dips below the LB. Can only\r\n go from 0 to 1 if it doesn't go above the upper bound.\r\n Higher bounds can go either direction. as long as it doesnt go outside the boundaries.\r\n Compare bit by bit?\r\n 1111\r\n Case 1: If MSB has 1 for upper number and 0 for lower number, it can be all 1s.\r\n Case 2: If MSB are both 1s:\r\n 1 10 01\r\n 1 10 10\r\n 1&1:upper bound number can go from 1 to 0 If previously there was a 1-0.\r\n 1 10 1100\r\n 1 01 1000\r\n 0&0:lower bound number can go from 0 to 1 if previous there was a 1-0.\r\n 1 10 0\r\n 1 01 0\r\n Maybe..if there even is a 1-0 pair, then everything can be 1s after...\r\n 1101\r\n 1011\r\n \"\"\"\r\n l,r=map(int,input().split())\r\n lb=toBin(l);rb=toBin(r)\r\n i=0;res=\"\"\r\n while i<len(rb):\r\n if (lb[i]==\"0\" and rb[i]==\"1\") or len(rb)>len(lb):break\r\n if lb[i]==rb[i]:res+=\"0\"\r\n i+=1\r\n if i<len(rb):\r\n res+=\"1\"*(len(rb)-i)\r\n print(int(res,2))\r\n\r\n\r\n\r\nif __name__==\"__main__\":\r\n solve()", "def f(l,r):\r\n x=1\r\n if r-l<=1:\r\n return l^r\r\n while x<r:\r\n x*=2\r\n if x==r and r-1>=l:\r\n return x^(x-1)\r\n else:\r\n x=x//2\r\n if x>l:\r\n return x^(x-1)\r\n else:\r\n return f(l-x,r-x)\r\nl,r=map(int,input().split())\r\nprint(f(l,r))\r\n", "def solve(a, b):\r\n if a == b:\r\n return 0\r\n else:\r\n return 1 + 2 * solve(a // 2, b // 2)\r\n\r\n\r\nif __name__ == '__main__':\r\n print(solve(*map(int, input().split())))\r\n", "s,r=map(int,input().split())\nprint(2**(s^r).bit_length()-1)\n \t\t\t\t \t\t\t\t \t \t", "def solve(l, r):\n lb, rb = bin(l)[2:], bin(r)[2:]\n\n ln = max(len(lb), len(rb))\n lb, rb = lb.zfill(ln), rb.zfill(ln)\n\n for i in range(ln):\n if lb[i] != rb[i]:\n return (1 << (ln - i)) - 1\n return 0\n\n\nprint(solve(*map(int, input().split())))\n\n \t\t\t \t\t \t\t \t \t \t \t \t \t \t\t\t\t", "l, r = map(int, input().split())\r\nprint(2**(l^r).bit_length()-1)", "l, r = map(int, input().split())\r\n\r\n#ans = 0\r\n#i1 = j1 = 0\r\n#for i in range(l, r + 1):\r\n# for j in range(i, r + 1):\r\n# if ans < (i ^ j):\r\n# ans = (i ^ j)\r\n# i1 = i\r\n# j1 = j\r\n#print(bin(i1)[2:], i1)\r\n#print(bin(j1)[2:], j1)\r\n#print(ans)\r\n\r\nr_b = list(bin(r)[2:])\r\nl_b = list(bin(l)[2:])\r\nlt = ['0' for _ in range(len(r_b) - len(l_b))]\r\nl_b = lt + l_b\r\n#print(r_b)\r\n#print(l_b)\r\n\r\nyes = 0\r\nfor i in range(len(l_b)):\r\n if r_b[i] == '1' and l_b[i] == '1':\r\n if yes:\r\n l_b[i] = '0'\r\n else:\r\n r_b[i] = '0'\r\n if int(\"\".join(r_b), 2) < l:\r\n r_b[i] = '1'\r\n elif r_b[i] == '0' and l_b[i] == '0':\r\n l_b[i] = '1'\r\n if int(\"\".join(l_b), 2) > r:\r\n l_b[i] = '0'\r\n else:\r\n yes = 1\r\n#print(l_b)\r\na = int(\"\".join(l_b), 2)\r\nb = int(\"\".join(r_b), 2)\r\nprint(a ^ b)", "l,r=map(int,input().split())\r\nx=l^r;p=1\r\nwhile p<=x:p*=2\r\nprint(p-1)", "l, r = map(int, input().split())\n\n\na = l ^ r\nb = 1\n\nwhile b <= a:\n b <<= 1;\n\nprint(b - 1)\n\t\t \t \t\t\t\t\t \t \t \t \t \t\t \t", "import math\r\nfrom collections import Counter, deque, defaultdict\r\nfrom sys import stdout\r\nimport time\r\nfrom math import factorial, log, gcd\r\nimport sys\r\nfrom decimal import Decimal\r\nimport heapq\r\nimport itertools\r\nimport bisect\r\n\r\n\r\ndef S():\r\n return sys.stdin.readline().split()\r\n\r\n\r\ndef I():\r\n return [int(i) for i in sys.stdin.readline().split()]\r\n\r\n\r\ndef II():\r\n return int(sys.stdin.readline())\r\n\r\n\r\ndef IS():\r\n return sys.stdin.readline().replace('\\n', '')\r\n\r\n\r\ndef main():\r\n a, b = I()\r\n a = bin(a)[2:]\r\n b = bin(b)[2:]\r\n a = (len(b) - len(a)) * '0' + a\r\n for i in range(len(a)):\r\n if a[i] != b[i]:\r\n print(2 ** (len(a) - i) - 1)\r\n return\r\n print(0)\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n # for _ in range(II()):\r\n # main()\r\n main()", "l, r = map(int, input().split())\n\n\nbitLength = (l ^ r).bit_length()\nlarge = 2 ** bitLength\nif l != r:\n print(large - 1)\nelse:\n print(0)\n\n", "def main():\n\tl, r = [int(x) for x in input().split()]\n\tn = 60\n\twhile (1<<n > r):\n\t\tn-=1\n\twhile n>=0 and ((l>>n)&1 == (r>>n)&1):\n\t\tn-=1\n\tprint((1<<n+1)-1)\n\nif __name__ == '__main__':\n\tmain()", "import math\r\nfrom collections import Counter, deque, defaultdict\r\nfrom sys import stdout\r\nimport time\r\nfrom math import factorial, log, gcd\r\nimport sys\r\nfrom decimal import Decimal\r\nimport heapq\r\nimport itertools\r\nimport bisect\r\n\r\n\r\ndef S():\r\n return sys.stdin.readline().split()\r\n\r\n\r\ndef I():\r\n return [int(i) for i in sys.stdin.readline().split()]\r\n\r\n\r\ndef II():\r\n return int(sys.stdin.readline())\r\n\r\n\r\ndef IS():\r\n return sys.stdin.readline().replace('\\n', '')\r\n\r\n\r\ndef main():\r\n a, b = I()\r\n if a == b:\r\n print(0)\r\n else:\r\n print(2 ** (len(bin(a ^ b)) - 2) - 1)\r\n\r\n\r\nif __name__ == '__main__':\r\n # for _ in range(II()):\r\n # main()\r\n main()", "import math\r\nN, M = map(int, input().split())\r\n\r\nans = 0\r\n\r\nlimit = int(math.log2(M))\r\n\r\nfor bit in range(limit, -1, -1):\r\n a = (N & (1 << bit))\r\n b = (M & (1 << bit))\r\n if a == b:\r\n if a == 0:\r\n small = (1 << bit) + N\r\n if small <= M:\r\n ans += (1 << bit)\r\n else:\r\n big = M - (1 << bit)\r\n if big >= N:\r\n ans += (1 << bit)\r\n else:\r\n ans += (1 << bit)\r\nprint(ans)", "import sys, threading\nimport math\nfrom os import path\nfrom collections import deque, defaultdict, Counter\nfrom bisect import *\nfrom string import ascii_lowercase\nfrom functools import cmp_to_key\nfrom random import randint\nimport heapq\n \n \ndef readInts():\n x = list(map(int, (sys.stdin.readline().rstrip().split())))\n return x[0] if len(x) == 1 else x\n \n \ndef readList(type=int):\n x = sys.stdin.readline()\n x = list(map(type, x.rstrip('\\n\\r').split()))\n return x\n \n \ndef readStr():\n x = sys.stdin.readline().rstrip('\\r\\n')\n return x\n \n \nwrite = sys.stdout.write\nread = sys.stdin.readline\n \n \nMAXN = 1123456\n\n\nclass mydict:\n def __init__(self, func=lambda: 0):\n self.random = randint(0, 1 << 32)\n self.default = func\n self.dict = {}\n \n def __getitem__(self, key):\n mykey = self.random ^ key\n if mykey not in self.dict:\n self.dict[mykey] = self.default()\n return self.dict[mykey]\n \n def get(self, key, default):\n mykey = self.random ^ key\n if mykey not in self.dict:\n return default\n return self.dict[mykey]\n \n def __setitem__(self, key, item):\n mykey = self.random ^ key\n self.dict[mykey] = item\n \n def getkeys(self):\n return [self.random ^ i for i in self.dict]\n \n def __str__(self):\n return f'{[(self.random ^ i, self.dict[i]) for i in self.dict]}'\n\n \ndef lcm(a, b):\n return (a*b)//(math.gcd(a,b))\n \n \ndef mod(n):\n return n%(1000000007) \n\n\ndef solve(t):\n # print(f'Case #{t}: ', end = '')\n l, r = readInts()\n bitl = [0 for _ in range(64)]\n bitr = bitl.copy()\n k = 0\n lc = l\n rc = r\n while lc > 0:\n\n if lc&1:\n bitl[k] = 1\n \n lc >>= 1\n k += 1\n\n k = 0\n while rc > 0:\n\n if rc&1:\n bitr[k] = 1\n \n rc >>= 1\n k += 1\n\n curl = l\n curr = r\n for i in range(63, -1, -1):\n if bitl[i] == bitr[i]:\n if bitl[i] == 0:\n # print(i, curl+(1<<i), r, curl)\n if curl + (1<<i) <= r:\n curl += 1<<i\n\n elif curr + (1<<i) <= r:\n curr += 1<<i\n\n elif bitl[i] == 1:\n if curr - (1<<i) >= l:\n curr -= 1<<i\n\n elif curl - (1<<i) >= l:\n curl -= 1<<i\n\n # print(bitl[:6])\n # print(bitr[:6])\n # print(curl, curr)\n\n print(curl^curr)\n\n\ndef main():\n t = 1\n if path.exists(\"/Users/arijitbhaumik/Library/Application Support/Sublime Text/Packages/User/input.txt\"):\n sys.stdin = open(\"/Users/arijitbhaumik/Library/Application Support/Sublime Text/Packages/User/input.txt\", 'r')\n sys.stdout = open(\"/Users/arijitbhaumik/Library/Application Support/Sublime Text/Packages/User/output.txt\", 'w')\n # sys.setrecursionlimit(100000) \n # t = readInts()\n for i in range(t):\n solve(i+1)\n \n \nif __name__ == '__main__':\n main() ", "import sys\r\nfrom collections import *\r\nfrom itertools import *\r\nfrom math import *\r\nfrom array import *\r\nfrom functools import lru_cache\r\nimport heapq\r\nimport bisect\r\nimport random\r\nimport io, os\r\nfrom bisect import *\r\n\r\nif sys.hexversion == 50924784:\r\n sys.stdin = open('cfinput.txt')\r\n\r\n# input = sys.stdin.readline\r\n# input_int = sys.stdin.buffer.readline\r\n# RI = lambda: map(int, input_int().split())\r\n# RS = lambda: input().strip().split()\r\n# RILST = lambda: list(RI())\r\n\r\n# RI = lambda: map(int, sys.stdin.buffer.readline().split())\r\n# RS = lambda: sys.stdin.readline().strip().split()\r\n# RILST = lambda: list(RI())\r\n\r\n# input = sys.stdin.buffer.readline\r\n# RI = lambda: map(int, input().split())\r\n# RS = lambda: map(bytes.decode, input().strip().split())\r\n# RILST = lambda: list(RI())\r\n\r\nRI = lambda: map(int, sys.stdin.buffer.readline().split())\r\nRS = lambda: map(bytes.decode, sys.stdin.buffer.readline().strip().split())\r\nRILST = lambda: list(RI())\r\n\r\nMOD = 10 ** 9 + 7\r\n\"\"\"https://codeforces.com/problemset/problem/276/D\r\n\r\n输入 L 和 R (1≤L≤R≤1e18)。\r\n输出区间 [L,R] 内任意两个数的异或的最大值。\r\n\r\n思考题:如果还要求异或不超过某个 limit 呢?\r\n\r\n输入 1 2\r\n输出 3\r\n\r\n输入 8 16\r\n输出 31\r\n\r\n输入 1 1\r\n输出 0\r\nhttps://codeforces.com/contest/276/submission/118793107\r\n\r\n如果 L 和 R 的二进制长度不一样,例如 L=2,R=9,那么我们可以用 7^8 得到最大的异或和 15。\r\n\r\n推广,如果 L 和 R 的二进制长度一样,那么我们可以从高到低找到第一个二进制不同的位置,转换到长度不一样的情况。\r\n\r\n总之,答案为 (1 << bit_length(L ^ R)) - 1。\r\n\r\n思考题代码 https://github.com/EndlessCheng/codeforces-go/blob/master/copypasta/bits.go#L632\r\n\"\"\"\r\n\r\n\r\n# \t ms\r\ndef solve(l, r):\r\n print((1 << (l ^ r).bit_length()) - 1)\r\n\r\n\r\nif __name__ == '__main__':\r\n l, r = RI()\r\n\r\n solve(l, r)\r\n", "l, r = map(int,input().split(\" \"))\r\nx = l ^ r\r\npow = 1\r\nwhile(pow <= x) :\r\n pow *= 2\r\n \r\nprint(pow - 1)", "import sys\ninput = sys.stdin.readline\n\n\ndef mp(): return map(int, input().split())\n\n\nx, y = mp()\na = format(x, '0b')\nb = format(y, '0b')\nif x == y:\n print(0)\n exit()\nprint((1 << len(format(x ^ y, '0b')))-1)\n", "import time\r\nimport sys\r\nimport math\r\nimport heapq as hp\r\n#hp.heapify hp.heappush hp.heappop\r\n\r\nfrom collections import deque\r\n#appendleft append pop popleft\r\n\r\n#BITWISE: and:& or:| not:~ XOR:^ \r\ninput=sys.stdin.readline\r\nm=1000000007\r\ndef inp():\r\n return int(input())\r\ndef minp():\r\n return map(int,input().split())\r\ndef strinp():\r\n S=input().rstrip()\r\n return S\r\ndef lst():\r\n return list(map(int,input().split()))\r\n\r\ndef primelist(n):\r\n history = [True] * n\r\n p = []\r\n for i in range(2, n):\r\n if history[i]:\r\n p.append(i)\r\n for j in range(i * i, n, i):\r\n history[j] = False\r\n return p\r\n \r\n#------------------------------------#\r\n\r\nl,r=minp()\r\nif l==r:\r\n print(0)\r\nelse:\r\n xor=l^r\r\n xor=bin(xor)[2:]\r\n print(2**len(xor)-1)", "l,r=map(int,input().split())\r\nif l==r:\r\n print(0)\r\nelse:\r\n x=l^r\r\n k=0\r\n mask=1\r\n while x>0:\r\n if mask&x==1:\r\n msb=k\r\n k+=1\r\n x=x>>1\r\n val=1<<(msb+1)\r\n print(val-1)\r\n\r\n", "import sys\r\n\r\n# sys.stdin = open('./../input.txt', 'r')\r\n\r\nI = lambda: int(input())\r\nMI = lambda: map(int, input().split())\r\nLI = lambda: list(map(int, input().split()))\r\nB = 2\r\n\r\nl, r = MI()\r\n\r\nif l == r:\r\n exit(print(0))\r\nfor i in range(60, -1, -1):\r\n if l >> i != r >> i:\r\n exit(print((1 << i + 1) - 1))\r\n", "inp = input().split()\nl = int(inp[0])\nr = int(inp[1])\n\n\ndef highest(x):\n if x == 0:\n return 0\n else:\n return 2**(len(bin(x))-2)-1\n\ndef xanyxor(l,r):\n x = l^r\n return highest(x)\n\nprint(xanyxor(l,r))\n \t \t\t \t \t \t\t\t\t \t \t\t\t", "l, r = map(lambda k: bin(int(k))[2:], input().split())\r\n\r\nl = l.zfill(len(r))\r\n# print(l, r)\r\n\r\nfor i in range(len(r)):\r\n if l[i] != r[i]:\r\n print(2**(len(r) - i) - 1)\r\n exit(0)\r\nprint(0)\r\n", "[l,r]=list(map(int,input().split()))\r\nli,ri=l,r\r\na,b=[],[]\r\nwhile(l):\r\n a.append(l%2)\r\n l=l//2\r\nwhile(r):\r\n b.append(r%2)\r\n r=r//2\r\nx,y=len(a),len(b)\r\n# print(a,b)\r\nif li==ri:\r\n print(0)\r\nelif x!=y:\r\n print(2**(max(x,y))-1)\r\nelse:\r\n while(a[-1]==b[-1]):\r\n a.pop(-1)\r\n b.pop(-1)\r\n print(2**(len(a))-1)", "from collections import Counter, deque\r\nfrom functools import lru_cache\r\n# from itertools import combinations\r\nimport bisect\r\nimport heapq\r\nfrom itertools import permutations, product\r\nimport math\r\nfrom operator import le\r\nfrom re import S, T\r\nimport sys\r\nfrom turtle import left, right\r\nfrom types import GeneratorType\r\n\r\n# sys.stdin = open('grey.in', 'r')\r\n# sys.setrecursionlimit(5 * 10**5)\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\nresult = []\r\n\r\n\r\ninput = sys.stdin.readline\r\n\r\nLOG = 18\r\n\r\narray = [1, 2, 3, 4, 5, 6, 7, 8]\r\n\r\n\r\n\r\ndef genSparseTable(array):\r\n \r\n sparseTable = [[float('inf') for i in range(LOG)] for x in range(len(array))]\r\n\r\n\r\n for i in range(len(array)):\r\n sparseTable[i][0] = array[i]\r\n\r\n\r\n\r\n for i in range(1, LOG):\r\n j = 0\r\n while((j + (1 << i) - 1) < len(array)):\r\n sparseTable[j][i] = max(sparseTable[j][i - 1], sparseTable[j + (1 << (i - 1))][i - 1])\r\n j += 1\r\n\r\n return sparseTable\r\n\r\ndef query(l, r, sparseTable):\r\n length = (r - l) + 1\r\n idx = int(math.log(length, 2))\r\n return max(sparseTable[l][idx], sparseTable[r - (1 << idx) + 1][idx])\r\n\r\n\r\n\r\n\r\n\r\ndef calc(numOne, numTwo):\r\n \r\n currentSum = 0\r\n for i in range(32):\r\n firstBit, secondBit = min(1, numOne & (1 << i)), min(1, numTwo & (1 << i))\r\n \r\n currentSum += (firstBit ^ secondBit)\r\n\r\n return currentSum \r\n\r\n\r\n# counter = Counter()\r\n# for i in range(0, 119000):\r\n# counter[calc(i, i + 1)] += 1\r\n\r\n\r\n# print(counter)\r\n\r\n\r\n\r\n \r\ninput = sys.stdin.readline\r\n \r\n# def 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# t = int(input())\r\n# result = []\r\n# for _ in range(t):\r\n# a, b = map(int, input().split())\r\n\r\n\r\n# def solve():\r\n# state = False\r\n# count = 0\r\n \r\n# currentMin = float('inf')\r\n# for z in range(0, b + 5):\r\n# currentB = b + z\r\n# count = 0\r\n# for i in range(32):\r\n# firstBit, secondBit = a & (1 << i), currentB & (1 << i)\r\n\r\n# if secondBit and not firstBit:\r\n# state = True\r\n# continue\r\n\r\n# if firstBit and not secondBit:\r\n# count += (2**i)\r\n# currentMin = min(currentMin, count + 1 + z if state else count + z) \r\n# return min(currentMin, b - a)\r\n\r\n# print(solve()) \r\n\r\n# # print(result)\r\n\r\n\r\n\r\nclass SegmentTree2D:\r\n\r\n \r\n def __init__(self, row, col, inMatrix):\r\n self.rows = row\r\n self.cols = col\r\n self.inMatrix = inMatrix\r\n self.matrix = [[0 for z in range(col + 1)] for i in range(row + 1)]\r\n self.genTable()\r\n\r\n\r\n \r\n\r\n def genTable(self):\r\n self.matrix[0][0] = 0\r\n\r\n\r\n for row in range(self.rows):\r\n currentSum = 0\r\n for col in range(self.cols):\r\n currentSum += self.inMatrix[row][col]\r\n above = self.matrix[row][col + 1]\r\n self.matrix[row + 1][col + 1] = currentSum + above\r\n\r\n \r\n\r\n\r\n def sumRegion(self, rowOne, colOne, rowTwo, colTwo):\r\n rowOne += 1\r\n rowTwo += 1\r\n colOne += 1\r\n colTwo += 1\r\n\r\n bottomRight, above = self.matrix[rowTwo][colTwo], self.matrix[rowOne - 1][colTwo]\r\n left, topLeft = self.matrix[rowTwo][colOne - 1], self.matrix[rowOne - 1][colOne - 1]\r\n return bottomRight - above - left + topLeft\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\ndef power(a, b, mod):\r\n if not b:\r\n return 1\r\n\r\n temp = power(a, b // 2, mod)\r\n result = temp * temp if b % 2 == 0 else temp * temp * a\r\n result %= mod\r\n return result \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nleft, right = map(int, input().split())\r\n\r\n\r\n\r\ndef solve():\r\n if left == right:\r\n return 0\r\n\r\n if left == right - 1:\r\n return left ^ right\r\n\r\n\r\n mostSignificantBit = None\r\n for i in reversed(range(65)):\r\n firstBit, secondBit = min(left & (1 << i), 1), min(right & (1 << i), 1)\r\n if firstBit != secondBit:\r\n mostSignificantBit = i\r\n break\r\n\r\n ans = 0\r\n\r\n\r\n # print(mostSignificantBit)\r\n\r\n for i in range(mostSignificantBit + 1):\r\n ans ^= (1 << i)\r\n\r\n\r\n return ans \r\n \r\n\r\nprint(solve()) \r\n\r\n\r\n\r\n", "l, r = map(int, input().split())\r\np = l ^ r\r\nx = 1\r\nwhile x <= p:\r\n x = x << 1\r\nprint(x - 1)", "import sys\r\ninput = sys.stdin.readline\r\n\r\nl, r = map(int, input().split())\r\n\r\nbinl = bin(l)[2:]\r\nbinr = bin(r)[2:]\r\n\r\nx = len(binr) - len(binl)\r\nif x >= 1:\r\n print(2**len(binr) - 1)\r\nelse:\r\n i = 0\r\n while i < len(binr) and binl[i] == binr[i]:\r\n i += 1\r\n if i == len(binr):\r\n print(0)\r\n else:\r\n print(2**(len(binr) - i) - 1)", "l,r=map(int, input().split())\r\nx=len(bin(r)[2:])\r\nans=[0 for _ in range(x)]\r\nm=-1\r\na=bin(l)[2:]\r\nb=bin(r)[2:]\r\na='0'*(len(b)-len(a))+a\r\nfor i in range(x):\r\n if (a[i]=='1' and b[i]=='0') or (a[i]=='0' and b[i]=='1'):\r\n m=i \r\n break \r\n# print(m)\r\nif m==-1:\r\n print(0)\r\nelse:\r\n print(2**(x-m) -1) \r\n\r\n ", "L,R=list(map(int,input().split()))\r\nprint((1<<(L^R).bit_length())-1)", "import sys\ninput = lambda: sys.stdin.readline().rstrip()\nfrom collections import deque,defaultdict,Counter\nfrom itertools import permutations,combinations\nfrom bisect import *\nfrom heapq import *\nfrom math import ceil,gcd,lcm,floor,comb\nalph = 'abcdefghijklmnopqrstuvwxyz'\n#pow(x,mod-2,mod)\n\nL,R = map(int,input().split())\nans = 0\nfor i in range(61,-1,-1):\n if (2**i)&R==(2**i) and (2**i)&L==0:\n for j in range(i,-1,-1):ans+=2**j\n break\n\nprint(ans)", "def bitarr(n):\r\n a = []\r\n while n:\r\n r = n % 2\r\n a.append(r)\r\n n //= 2\r\n return a\r\n\r\ndef solve(r, l):\r\n if len(r) == len(l):\r\n while len(r) > 1 and r[-1] == l[-1]:\r\n r.pop()\r\n l.pop()\r\n if len(r) == 1: return r[0] ^ l[0]\r\n return 2 ** len(r) - 1\r\n\r\nl, r = map(int, input().split())\r\nprint(solve(bitarr(r), bitarr(l)))\r\n", "n,m=list(map(int,input().split()))\r\nans=\"\"\r\nc=0\r\nr=0\r\nx=n\r\ny=m\r\nwhile n>0 or m>0:\r\n if (n&1)!=(m&1):\r\n c=0\r\n ans=\"1\"+ans\r\n else:\r\n c+=1\r\n ans=\"1\"+ans\r\n n=n>>1\r\n m=m>>1\r\n r+=1\r\nans=ans[c::]\r\nn=x>>(r-c)\r\nm=y>>(r-c)\r\nwhile n>0:\r\n ans=str((n&1)^(m&1))+ans\r\n n=n>>1\r\n m=m>>1\r\n\r\nwhile m>0:\r\n ans=str((n&1)^(m&1))+ans\r\n n=n>>1\r\n m=m>>1\r\n\r\nprint(int(ans,2))\r\n \r\n", "\r\na,b=map(int,input().split())\r\nif a==b:print(0)\r\nelse:\r\n pos = 0\r\n i=0\r\n while a or b:\r\n i+=1\r\n if (a&1==0 and b&1) or (b&1==0 and a&1):\r\n pos = i\r\n a=a>>1\r\n b=b>>1\r\n print((1<<pos)-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\nfor _ in range(int(input())):\r\n a,b=map(int,input().split())\r\n if a==1:print(0)\r\n else:\r\n need = (a-1)//2\r\n ans = 0\r\n if b>=need:\r\n ans+=(2*need*(b//need))\r\n if a>2:\r\n ans+=(2*(b%need))\r\n else:\r\n ans+=b\r\n print(ans)\r\n''' \r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\n\r\ndef f(a, b):\r\n i, j = g(a), g(b)\r\n if j > i:\r\n return 2**j-1\r\n elif j == i == 0:\r\n return 0\r\n else:\r\n return f(a-2**(j-1), b-2**(j-1))\r\n\r\n\r\ndef g(a):\r\n c = 0\r\n while a:\r\n c += 1\r\n a //= 2\r\n return c\r\n\r\n\r\nl, r = map(int, input().split())\r\nprint(f(l, r))", "def toBinary(n):\n b = \"\"\n while n > 0:\n b += str(n % 2)\n n = n//2\n return b[::-1]\n\n\na, b = map(int, input().split())\nl = len(toBinary(a ^ b))\nres = 0\nk = 1\nfor i in range(l):\n res += k\n k = k << 1\nprint(res)\n\n \t\t \t\t \t \t\t \t\t \t\t \t \t", "import sys\r\ninput = sys.stdin.readline\r\nl, r = map(int, input().split())\r\nhb = -1\r\nfor i in range(60, -1, -1):\r\n if (1 << i) & l != (1 << i) & r:\r\n hb = i\r\n break\r\nprint(2 ** (i + 1) - 1 if hb >= 0 else 0)", "from sys import stdin\r\ninput = stdin.readline\r\n\r\nl, r = [int(x) for x in input().split()]\r\n\r\nprint(2**(l^r).bit_length()-1)", "a, b = list(map(int, input().split(' ')))\r\nmax_ = b\r\ncur_b = bin(max_)[2:]\r\ncur_a = bin(a)[2:]\r\n\r\nif a == b:\r\n print(0)\r\n exit()\r\n\r\nelse:\r\n start = len(cur_b)-1\r\n if len(cur_b) == len(cur_a):\r\n while b & (1<<start) == a & (1<<start):\r\n if max_&(1<<start) == 0:\r\n start -= 1\r\n continue\r\n max_ ^= (1<<start)\r\n start -= 1\r\n \r\n for i in range(start, -1, -1):\r\n max_ |= (1<<i)\r\n \r\nprint(max_)", "import sys\ninput = lambda: sys.stdin.readline().rstrip('\\n\\r')\n\n__input_tests__ = False\nfrom collections import Counter, defaultdict, deque\nfrom itertools import accumulate\nfrom bisect import bisect_left, bisect_right\n\ndef solve():\n l, r = map(int, input().split())\n bl, br = bin(l)[2:], bin(r)[2:]\n lbl, lbr = len(bl), len(br)\n xbl, xbr = '0' * (max(lbl, lbr) - lbl) + bl, '0' * (max(lbl, lbr) - lbr) + br\n start = False\n c = 0\n for i, j in zip(xbl, xbr):\n if start or i != j:\n start = True\n c += 1\n return int('0' + '1' * c, 2)\n\n\nfor _ in range(int(input()) if __input_tests__ else 1):\n val = solve()\n print(val)\n", "import math \nl,r=map(int,input().split())\nif(l==r):\n print(\"0\")\nelse:\n for bit in range(int(math.log(r,2)+1),-1,-1):\n if((l>>bit)&1)!=((r>>bit)&1):\n print(2**(bit+1)-1) \n break\n\n \t \t\t\t \t\t\t \t\t\t \t \t \t\t\t", "l,r=map(int,input().split())\r\ncount=63\r\nwhile count>=0:\r\n if l&(1<<count) != r&(1<<count):\r\n break\r\n count-=1\r\n \r\ns=\"0\"\r\nfor i in range(count+1):\r\n s+=\"1\"\r\n \r\nprint(int(s,2))", "import sys\r\ndef input() : return sys.stdin.readline().strip()\r\ndef getints() : return map(int,sys.stdin.readline().strip().split())\r\n\r\nl,r = getints()\r\nt = bin(l^r)\r\nprint(0 if l == r else (1<<(len(t)-t.index('1')))-1)", "l, r = map(int, input().split())\nif l == r:\n print(0)\nelse:\n l = bin(l)[2:]\n r = bin(r)[2:]\n l = (max(len(r), len(l)) - len(l)) * '0' + l\n r = (max(len(r), len(l)) - len(r)) * '0' + r\n s = 0\n for p in range(len(l)):\n if l[p] != r[p]:\n s = p\n break\n a = l[:s] + '0' + '1' * (len(l) - s - 1)\n b = l[:s] + '1' + '0' * (len(l) - s - 1)\n print(int(a, 2) ^ int(b, 2))\n", "l,r=map(int,input().split())\r\nprint(2**(l^r).bit_length()-1)\r\n", "l,r = list(map(int, input().split()))\r\nlbin = str(bin(l))[2:]\r\nrbin = str(bin(r))[2:]\r\nlbin = \"0\"*(len(rbin) - len(lbin)) + lbin\r\n# print(lbin, rbin)\r\nans = \"\"\r\ncanAdd = False\r\nfor i in range(len(lbin)):\r\n if canAdd == True:\r\n ans += '1'\r\n elif lbin[i] == '1' and rbin[i] == '1':\r\n ans += '0'\r\n elif lbin[i] == '0' and rbin[i] == '0':\r\n ans += '0'\r\n elif lbin[i] == '0' and rbin[i] == '1':\r\n canAdd = True\r\n ans += '1'\r\n# print(lbin, rbin)\r\n# print(ans)\r\nprint(int(ans, 2))", "l,r=tuple(map(int,input().split(\" \")))\r\nx=l^r\r\npow=1\r\nwhile(pow<=x) :\r\n pow*=2\r\n \r\nprint(pow-1)", "left, right = list(map(int, input().split()))\r\n\r\nbin1 = list(bin(left)[2:])\r\nbin2 = list(bin(right)[2:])\r\n\r\nbin1.reverse()\r\nbin2.reverse()\r\n\r\nlength2 = len(bin1) - 1\r\nlength1 = len(bin2) - 1\r\nans = \"\"\r\n\r\nif length1 != length2:\r\n print(2 ** (length1 + 1) - 1)\r\n\r\nelse:\r\n\r\n while length1 >= 0 and bin1[length1] == bin2[length1]:\r\n \r\n length1 -= 1\r\n \r\n print(2 ** (length1 + 1) - 1)", "l, r = map(int, input().split())\r\nprint(2**(l ^ r).bit_length() - 1)\r\n", "# https://codeforces.com/problemset/problem/276/D\r\na, b = map(int, input().split())\r\n\r\nc = a ^ b\r\nif c == 0:\r\n print(0)\r\nelse:\r\n l = len('{:b}'.format(c))\r\n print((1 << l) - 1)\r\n", "l,r = map(int,input().split())\r\ni=1<<60\r\nwhile i&l == i&r and i!=0:\r\n i=i>>1\r\nans=i\r\nwhile i>0:\r\n i=i>>1\r\n ans+=i\r\nprint(ans) ", "l,r=map(int,input().split())\r\nprint((1<<(l^r).bit_length())-1)", "l,r = map(int,input().split())\r\nprint(2**(l^r).bit_length() - 1)\r\n" ]
{"inputs": ["1 2", "8 16", "1 1", "506 677", "33 910", "36 94", "10000000000 20000000000", "79242383109441603 533369389165030783", "797162752288318119 908416915938410706", "230148668013473494 573330407369354716", "668869743157683834 805679503731305624", "32473107276976561 588384394540535099", "632668612680440378 864824360766754908", "658472316271074503 728242833853270665", "289218059048863941 314351197831808685", "54248140375568203 718189790306910368", "330134158459714054 457118108955760856", "190442232278841373 980738846929096255", "203359308073091683 455893840817516371", "200851182089362664 449305852839820160", "731792654005832175 789527173439457653", "231465750142682282 276038074124518614", "462451489958473150 957447393463701191", "68666076639301243 247574109010873331", "491113582000560303 858928223424873439", "454452550141901489 843034681327343036", "43543567767276698 769776048133345296", "214985598536531449 956713939905291713", "56445001476501414 706930175458589379", "666033930784103123 883523065811761270", "501827377176522663 590153819613032662", "140216419613864821 362678730465999561", "23811264031960242 520940113721281721", "43249439481689805 431488136320817289", "198909890748296613 528950282310167050", "190620774979376809 899159649449168622", "18565852953382418 697862904569985066", "277046860122752192 828379515775613732", "25785331761502790 119852560236585580", "363313173638414449 500957528623228245", "549330032897152846 715374717344043295", "47456305370335136 388462406071482688", "125051194948742221 235911208585118006", "780993382943360354 889872865454335075", "815449097320007662 942453891178865528", "765369978472937483 796958953973862258", "259703440079833303 857510033561081530", "181513087965617551 301910258955864271", "28591024119784617 732203343197854927", "215365547805299155 861595308221385098", "1 1000000000000000000", "1000000000000 999999999999999999", "1 1", "9999999999998 9999999999999", "9999999999900 9999999999901", "9999999999900 9999999999902", "9999999999900 9999999999903", "1 3", "5000000 5900000", "8589934592 8989934592", "1 288230376151711743"], "outputs": ["3", "31", "0", "1023", "1023", "127", "34359738367", "576460752303423487", "576460752303423487", "576460752303423487", "288230376151711743", "1152921504606846975", "576460752303423487", "288230376151711743", "36028797018963967", "1152921504606846975", "288230376151711743", "1152921504606846975", "576460752303423487", "576460752303423487", "72057594037927935", "72057594037927935", "1152921504606846975", "288230376151711743", "1152921504606846975", "1152921504606846975", "1152921504606846975", "1152921504606846975", "1152921504606846975", "576460752303423487", "1152921504606846975", "576460752303423487", "576460752303423487", "576460752303423487", "576460752303423487", "1152921504606846975", "1152921504606846975", "1152921504606846975", "144115188075855871", "288230376151711743", "1152921504606846975", "576460752303423487", "288230376151711743", "576460752303423487", "576460752303423487", "144115188075855871", "1152921504606846975", "576460752303423487", "1152921504606846975", "1152921504606846975", "1152921504606846975", "1152921504606846975", "0", "1", "1", "3", "3", "3", "2097151", "536870911", "288230376151711743"]}
UNKNOWN
PYTHON3
CODEFORCES
54
e473417d063d5db8ecc735c3ecdaf67d
Alyona and the Tree
Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on. The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call vertex *v* sad if there is a vertex *u* in subtree of vertex *v* such that *dist*(*v*,<=*u*)<=&gt;<=*a**u*, where *a**u* is the number written on vertex *u*, *dist*(*v*,<=*u*) is the sum of the numbers written on the edges on the path from *v* to *u*. Leaves of a tree are vertices connected to a single vertex by a single edge, but the root of a tree is a leaf if and only if the tree consists of a single vertex — root. Thus Alyona decided to remove some of tree leaves until there will be no any sad vertex left in the tree. What is the minimum number of leaves Alyona needs to remove? In the first line of the input integer *n* (1<=≤<=*n*<=≤<=105) is given — the number of vertices in the tree. In the second line the sequence of *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) is given, where *a**i* is the number written on vertex *i*. The next *n*<=-<=1 lines describe tree edges: *i**th* of them consists of two integers *p**i* and *c**i* (1<=≤<=*p**i*<=≤<=*n*, <=-<=109<=≤<=*c**i*<=≤<=109), meaning that there is an edge connecting vertices *i*<=+<=1 and *p**i* with number *c**i* written on it. Print the only integer — the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. Sample Input 9 88 22 83 14 95 91 98 53 11 3 24 7 -8 1 67 1 64 9 65 5 12 6 -80 3 8 Sample Output 5
[ "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\nw = list(map(int, input().split()))\r\nd = [[] for i in range(n)]\r\nfor i in range(n-1):\r\n a, b = map(int, input().split())\r\n d[i+1].append((a-1, b))\r\n d[a-1].append((i+1, b))\r\n\r\nx = [0]*n\r\nq = [(0, 0, -1, 0)]\r\nwhile q:\r\n a, b, c, e = q.pop()\r\n if a == 0:\r\n q.append((1, b, c, e))\r\n for i, j in d[b]:\r\n if i != c:\r\n q.append((0, i, b, max(0, e + j)))\r\n else:\r\n if e > w[b]:\r\n x[b] = 1\r\nq = [(0, -1)]\r\nc = 0\r\nwhile q:\r\n a, b = q.pop()\r\n if x[a] == 0:\r\n c += 1\r\n for i, j in d[a]:\r\n if i != b:\r\n q.append((i, a))\r\nprint(n-c)\r\n", "n = int(input())\na = list(map(int, input().split()))\n\ntree = [[] for _ in range(n)]\nfor i in range(n - 1):\n p, c = map(int, input().split())\n tree[p - 1].append((i + 1, c))\n\nstack = [0]\nmaxDist = [0 for _ in range(n)]\nwhile len(stack) != 0:\n current = stack.pop()\n for child, edge in tree[current]:\n maxDist[child] = max(maxDist[current] + edge, 0)\n stack.append(child)\n\nstack = [(0, False)]\nnodesToRemove = 0\nwhile len(stack) != 0:\n current, remove = stack.pop()\n if remove:\n nodesToRemove += 1\n\n for child, edge in tree[current]:\n if maxDist[child] > a[child]:\n stack.append((child, True))\n else:\n stack.append((child, remove))\n\nprint(nodesToRemove)\n", "from collections import deque\nn = int(input())\nval = [int(x) for x in input().split()]\ndist = [0] * (n+1)\ng = [[]for i in range(n+1)]\n\nfor i in range(2, n+1):\n a, b = map(int, input().split())\n g[a].append((i,b))\n\nr = 0\nretira = [False]*(n+1)\npilha = deque([1])\nwhile pilha:\n v = pilha.pop()\n if retira[v]:\n r += 1\n for u, d in g[v]:\n dist[u] = max(d, dist[v]+d)\n if dist[u] > val[u-1]:\n retira[u] = True\n else:\n retira[u] = retira[v]\n pilha.append(u)\nprint(r)\n \t\t\t \t \t \t \t \t \t \t \t \t", " ###### ### ####### ####### ## # ##### ### ##### \r\n # # # # # # # # # # # # # ### \r\n # # # # # # # # # # # # # ### \r\n ###### ######### # # # # # # ######### # \r\n ###### ######### # # # # # # ######### # \r\n # # # # # # # # # # #### # # # \r\n # # # # # # # ## # # # # # \r\n ###### # # ####### ####### # # ##### # # # # \r\n \r\nfrom __future__ import print_function # for PyPy2\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 sys import stdin\r\n# from bisect import *\r\nfrom heapq import *\r\nfrom math import *\r\n \r\ng = lambda : stdin.readline().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 = [0] + gil()\r\nadj = [[] for _ in range(n+1)]\r\n\r\nfor i in range(2, n+1):\r\n p, w = gil()\r\n adj[p].append((i, w))\r\n\r\nst = [(1, 0, 0)]\r\nans = 0\r\n\r\nwhile st:\r\n p, sm, dmin = st.pop()\r\n if p!= 1 and sm - dmin > a[p]:continue\r\n # print(p, 'is a good node', sm, dmin)\r\n ans += 1\r\n for c, w in adj[p]:\r\n st.append((c, sm+w, min(dmin, sm+w)))\r\n\r\nprint(n - ans)", "from collections import deque\n\nn = int(input())\nvalues = []\nvalues.append(0)\nnumbers = list(map(int, input().split()))\n\nfor number in numbers:\n values.append(number)\n\nbiggest = [0] * (n + 1)\nx = [[]for _ in range(n + 1)]\n\nfor i in range(2, n + 1):\n a, b = map(int, input().split())\n x[a].append((i,b))\n\nstack = deque([1])\nwhile stack:\n y = stack.pop()\n for u, d in x[y]:\n biggest[u] = max(d, biggest[y] + d)\n stack.append(u)\n\nans = 0\noff = [False] * (n + 1)\nstack = deque([1])\nwhile stack:\n y = stack.pop()\n if off[y]:\n ans += 1\n for u, d in x[y]:\n biggest[u] = max(d, biggest[y] + d)\n if biggest[u] > values[u]:\n off[u] = True\n else:\n off[u] = off[y]\n stack.append(u)\n\nprint(ans)\n \t\t \t \t \t \t\t\t \t\t\t\t \t\t\t \t\t", "from collections import defaultdict, deque\r\nfrom math import inf\r\nfrom sys import stdin, stdout\r\n\r\nn = int(stdin.readline().strip())\r\narr = list(map(int, stdin.readline().split()))\r\n\r\ntree = defaultdict(list)\r\n\r\nfor i in range(n - 1):\r\n node, v = map(int, stdin.readline().split())\r\n tree[node - 1].append((i + 1, v))\r\n\r\nqueue = deque([(0, -inf, False)])\r\nanswer = 0\r\nwhile queue:\r\n node, dist, remove = queue.popleft()\r\n\r\n if remove:\r\n answer += 1\r\n elif dist > arr[node]:\r\n answer += 1\r\n remove = True\r\n\r\n for (nei, cost) in tree[node]:\r\n queue.append((nei, max(dist + cost, cost), remove))\r\n\r\nprint(answer)\r\n", "import sys\n\n\ndef subtree_count():\n stack = [0]\n while len(stack):\n v = stack[-1]\n\n size = 1\n for u, _ in edge[v]:\n if u in subtree:\n size += subtree[u]\n else:\n stack.append(u)\n\n if stack[-1] == v:\n stack.pop()\n subtree[v] = size\n\n\ndef remove_bfs():\n queue = [(0, 0)]\n\n removed = 0\n\n while len(queue):\n v, s = queue.pop()\n\n if s > vertex[v]:\n removed += subtree[v]\n else:\n for u, c in edge[v]:\n queue.append((u, max(s + c, 0)))\n\n return removed\n\nsys.setrecursionlimit(1000001)\nn = int(input())\n\nvertex = list(map(int, input().split()))\nedge = {}\nsubtree = {}\n\nfor i in range(n):\n edge[i] = []\n\nfor i in range(n - 1):\n p, c = map(int, input().split())\n edge[p - 1] += [(i + 1, c)]\n\nsubtree_count()\nprint(remove_bfs())\n", "import sys\r\ninput=sys.stdin.readline\r\nn=int(input())\r\na=list(map(int,input().split()))\r\ng=[[] for i in range(n)]\r\nfor i in range(n-1):\r\n p,c=map(int,input().split())\r\n p-=1\r\n g[p].append([i+1,c])\r\ncnt=0\r\nq=[[0,0]]\r\nwhile q:\r\n v,dist=q.pop()\r\n if dist>a[v]:\r\n continue\r\n cnt+=1\r\n for to,c in g[v]:\r\n q.append([to,max(0,dist+c)])\r\nprint(n-cnt)", "from collections import deque\n\nn = int(input())\nval = [0] + [int(i) for i in input().split(' ')]\nhighest_dist = [0]*(n+1)\ng = [[]for i in range(n+1)]\n\nfor i in range(2,n+1):\n a,b = map(int, input().split(' '))\n g[a].append((i,b))\npilha = deque([1])\nwhile pilha:\n v = pilha.pop()\n for u,d in g[v]:\n highest_dist[u] = max(d,highest_dist[v]+d)\n pilha.append(u)\n\nres = 0\nretira = [False]*(n+1)\npilha = deque([1])\nwhile pilha:\n v = pilha.pop()\n if retira[v]:\n res += 1\n for u,d in g[v]:\n highest_dist[u] = max(d,highest_dist[v]+d)\n if highest_dist[u] > val[u]:\n retira[u]=True\n else:\n retira[u] = retira[v]\n pilha.append(u)\nprint(res)\n\n\n\n\n\t\t \t \t\t \t\t\t \t \t \t \t\t\t\t \t", "from collections import defaultdict, deque\r\n\r\n\r\nn = int(input())\r\n\r\nnums = list(map(int, input().split()))\r\n\r\ntree = defaultdict(list)\r\nfor node in range(n-1):\r\n node2, c = map(int, input().split())\r\n node += 2\r\n tree[node].append((node2, c))\r\n tree[node2].append((node, c))\r\n\r\nvisited = set()\r\nans = 0\r\nq = deque([(1, 0, False)])\r\nvisited.add(1)\r\n\r\nwhile q:\r\n for _ in range(len(q)):\r\n cur, cost, remove = q.popleft()\r\n\r\n if remove:\r\n ans += 1\r\n \r\n elif cost > nums[cur-1]:\r\n # print(cur)\r\n remove = True\r\n ans += 1\r\n \r\n for neig, c in tree[cur]:\r\n if neig not in visited:\r\n q.append((neig, max(cost + c, c), remove))\r\n visited.add(neig)\r\n\r\nprint(ans)", "import collections\nimport dataclasses\nimport typing\n\n\[email protected](repr=False)\nclass Node:\n nid: int\n value: int\n children: typing.List['Node']\n parent: typing.Union['Node', None]\n parent_distant: int\n\n # node_num: int\n\n def __repr__(self):\n return f'Node({self.nid + 1}, v={self.value}, d={self.parent_distant})'\n\n\ndef solve():\n n = int(input())\n nodes: typing.List[Node] = [None] * n\n for nid, val_str in enumerate(input().split()):\n nodes[nid] = Node(nid, int(val_str), [], None, 0)\n\n for child_node in nodes[1:]:\n parent_index, edge_val = [int(x) for x in input().split()]\n\n parent_node = nodes[parent_index - 1]\n child_node.parent = parent_node\n child_node.parent_distant = edge_val\n parent_node.children.append(child_node)\n\n root = get_root(nodes[0])\n print(eliminate_unhappy(root))\n\n\ndef get_root(node: Node):\n while node.parent:\n node = node.parent\n return node\n\n\ndef eliminate_unhappy(root: Node):\n stack = [(root, 0)] # tuple of node and distance from root\n total_elim_node_num = 0\n while stack:\n node, distance = stack.pop()\n for child in node.children:\n child_dis = distance + child.parent_distant\n if child_dis > child.value:\n total_elim_node_num += get_node_num(child)\n else:\n stack.append((child, max(0, child_dis)))\n return total_elim_node_num\n\n\ndef get_node_num(node: Node):\n q = collections.deque()\n q.append(node)\n num = 0\n while len(q):\n next_node = q.popleft()\n num += 1\n if next_node.children:\n for child in next_node.children:\n q.append(child)\n return num\n\n\nif __name__ == '__main__':\n solve()\n\n\t \t \t\t \t\t \t\t \t \t\t \t \t", "n = int(input())\na = list(map(int, input().split()))\ne = []\n\nfor i in range(n):\n e.append([])\n\nfor i in range(1, n):\n x, y = map(int, input().split())\n e[x-1].append([i, y])\n\nb = [0] * n\nc = [0] * n\nd = [(10**18)] * n\nl = 0\nr = 1\ncnt = 0\nwhile l < r:\n v = b[l]\n if c[l] - a[v] > d[l]:\n l += 1\n continue\n cnt += 1\n for x in e[v]:\n c[r] = c[l] + x[1]\n d[r] = min(d[l], c[l])\n b[r] = x[0]\n r += 1\n l += 1\n\nprint(n - cnt)\n\t\t\t \t \t\t \t \t\t \t\t \t \t \t\t \t", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\ndef bfs(s):\r\n q = [s]\r\n dp, mi = [0] * (n + 1), [0] * (n + 1)\r\n ng = [0] * (n + 1)\r\n for k in range(n):\r\n i = q[k]\r\n for j, c in G[i]:\r\n dp[j] = dp[i] + c\r\n mi[j] = min(mi[i], dp[i])\r\n ng[j] = ng[i]\r\n if dp[j] - mi[j] > a[j]:\r\n ng[j] = 1\r\n q.append(j)\r\n return sum(ng)\r\n\r\nn = int(input())\r\na = [0] + list(map(int, input().split()))\r\nG = [[] for _ in range(n + 1)]\r\nfor i in range(2, n + 1):\r\n p, c = map(int, input().split())\r\n G[p].append((i, c))\r\nans = bfs(1)\r\nprint(ans)", "#Código - Vídeo Tutorial 3\nfrom collections import deque\nn = int(input())\nval = [0] \ninp = list(map(int,input().strip().split()))[:n]\nfor i in range(len(inp)):\n val.append(inp[i])\n\nmaiordist = [0] * (n+1)\ng = [[] for _ in range(n+1)]\n\nfor i in range(2,n+1):\n a,b = map(int,input().split(\" \"))\n g[a].append((i,b))\n\npilha = deque([1])\n\nwhile pilha:\n v = pilha.pop()\n for u,d in g[v]:\n maiordist[u] = max(d,maiordist[v]+d)\n pilha.append(u)\n\nresp = 0\nretira = [False] * (n+1)\npilha = deque([1])\n\nwhile pilha:\n v = pilha.pop()\n if retira[v]:\n resp += 1\n for u, d in g[v]:\n maiordist[u] = max(d,maiordist[v]+d)\n if maiordist[u] > val[u]:\n retira[u] = True\n else:\n retira[u] = retira[v]\n pilha.append(u)\n\nprint(resp)\n\t \t\t\t \t \t\t\t\t \t \t\t\t\t", "\r\nread = lambda: map(int, input().split())\r\nn = int(input())\r\na = [0] + list(read())\r\ng = [list() for i in range(n + 1)]\r\nfor i in range(2, n + 1):\r\n p, c = read()\r\n g[i].append((p, c))\r\n g[p].append((i, c))\r\nwas = [0] * (n + 1)\r\nst = [(1, 0, 0)]\r\nwhile st:\r\n v, mind, dist = st.pop()\r\n was[v] = 1\r\n for u, c in g[v]:\r\n if not was[u]:\r\n if dist + c - min(dist + c, mind) <= a[u]:\r\n st.append((u, min(mind, dist + c), dist + c))\r\n\r\nans = n - was.count(1)\r\nprint(ans)", "from sys import stdin\nfrom collections import deque\n\n\ndef readint():\n return int(stdin.readline())\n\n\ndef readints():\n return [int(i) for i in stdin.readline().split()]\n\n\ndef main():\n n = readint()\n a = [0] + readints()\n \n max_dist = [0] * (n + 1) \n g = [[] for _ in range(n + 1)]\n for i in range(2, n + 1):\n u, d = readints()\n\n g[u].append((i, d))\n\n st = deque([1])\n retira = [False] * (n + 1)\n\n ans = 0\n while st:\n u = st.pop()\n\n if retira[u]:\n ans += 1\n\n for v, d in g[u]:\n max_dist[v] = max(d, max_dist[u] + d)\n\n if max_dist[v] > a[v]:\n retira[v] = True\n else:\n retira[v] = retira[u]\n\n st.append(v)\n\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n\n", "n = int(input())\n \nA = list(map(int, input().split()))\n \nmaxDist = [0] * n\n \nG = [[] for _ in range(n)]\n \nfor v in range(1, n):\n u, d = tuple(map(int, input().split()))\n u -= 1\n G[v].append((u, d))\n G[u].append((v, d))\n \n \nseen = [False] * n\nseen[0] = True\nq = [0]\nto_remove = []\n \nwhile q:\n v = q.pop();\n for u, dist in G[v]:\n if not seen[u]:\n seen[u] = True\n maxDist[u] = max(dist, maxDist[v] + dist)\n if maxDist[u] > A[u]:\n to_remove.append(u)\n else:\n q.append(u)\n \ncount = 0\nwhile to_remove:\n v = to_remove.pop()\n count += 1\n for u, _ in G[v]:\n if not seen[u]:\n seen[u] = True\n to_remove.append(u)\n \nprint(count)\n \t \t \t\t \t \t \t \t \t \t\t\t \t\t", "n = int(input())\na = [[] for _ in range(n+2)]\np = list(map(int, input().split()))\n\np.insert(0, 0)\n\nfor i in range(n-1):\n x, y = map(int, input().split())\n a[x].append((i+2, y))\n\nc = 0\naux = [(1, 0)]\n\nwhile aux:\n node, dist = aux.pop()\n\n if dist > p[node]: continue\n\n c += 1\n\n for x, y in a[node]:\n aux.append((x, max(0, dist+y)))\n\nprint(n-c)\n \t\t\t \t\t\t \t\t\t\t \t \t\t \t \t", "# @author Nayara Souza\n# UFCG - Universidade Federal de Campina Grande\n# AA - Basico\n \nfrom collections import deque\n\nn = int(input())\nl = list(map(int, input().split()))\n\nd = [0]*(n+1)\nx = [0]\n\nfor i in l:\n x.append(i)\n\nm = [[]for i in range(n+1)]\n \nfor i in range(2, n+1):\n a, b = map(int, input().split())\n m[a].append((i,b))\n \ns = 0\nr = [False]*(n+1)\np = deque([1])\n\nwhile(p):\n v = p.pop()\n if(r[v]):\n s += 1\n for i,j in m[v]:\n d[i] = max(j,d[v]+j)\n if(d[i] > x[i]):\n r[i] = True\n else:\n r[i] = r[v]\n p.append(i)\n \nprint(s)\n \t \t\t \t\t\t\t \t \t\t\t\t\t\t\t\t\t \t \t\t\t", "import sys\r\n\r\n\r\ndef input():\r\n return sys.stdin.readline()[:-1]\r\n\r\n\r\nnn = int(input())\r\na = [0] + list(map(int, input().split()))\r\nE = [[] for _ in range(nn + 1)]\r\nfor i in range(nn - 1):\r\n p, c = map(int, input().split())\r\n E[i + 2] += [(p, c)]\r\n E[p] += [(i + 2, c)]\r\n\r\nans = 0\r\nch = [(1, 0, 0)]\r\nwhile ch:\r\n nom, pre, l = ch.pop()\r\n if l > a[nom]: continue\r\n ans += 1\r\n for x, c in E[nom]:\r\n if x != pre: ch += [(x, nom, max(l + c, c))]\r\nprint(nn - ans)\r\n\r\n\r\n\r\n", "from collections import deque\n\nn = int(input())\nval = [0]\nval.extend(map(int, input().split()))\nmaiordist = [0] * (n+1)\ng = [[] for _ in range(n+1)]\n\nfor i in range(2, n+1):\n a, b = map(int, input().split())\n g[a].append((i, b))\n\np= deque([1])\nwhile p:\n v = p.pop()\n for u, d in g[v]:\n maiordist[u] = max(d, maiordist[v]+d)\n p.append(u)\n\nr= 0\nretira = [False]*(n+1)\np= deque([1])\nwhile p:\n v = p.pop()\n if retira[v]:\n r+= 1\n for u, d in g[v]:\n maiordist[u] = max(d, maiordist[v]+d)\n if maiordist[u] > val[u]:\n retira[u] = True\n else:\n retira[u] = retira[v]\n p.append(u)\nprint(r)\n\t\t\t\t \t \t \t \t\t\t \t\t\t \t\t\t\t\t \t", "from sys import stdin\r\ninput=lambda : stdin.readline().strip()\r\nfrom math import ceil,sqrt,factorial,gcd\r\nfrom collections import deque\r\ndef dfs(x):\r\n\tstack=[x]\r\n\twhile stack:\r\n\t\tx=stack.pop()\r\n\t\tfor i in graph[x]:\r\n\t\t\tgraph[i].remove(x)\r\n\t\t\tstack.append(i)\r\ndef dfs_simple(x):\r\n\tstack=[x]\r\n\tt=0\r\n\twhile stack:\r\n\t\tx=stack.pop()\r\n\t\tt+=1\r\n\t\tfor i in graph[x]:\r\n\t\t\tstack.append(i)\r\n\treturn t\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\ngraph={i:set() for i in range(n)}\r\nd={}\r\nfor i in range(1,n):\r\n\ta,b=map(int,input().split())\r\n\ta-=1\r\n\tgraph[a].add(i)\r\n\tgraph[i].add(a)\r\n\td[(a,i)]=b\r\ndfs(0)\r\nz=[]\r\nstack=[[0,0]]\r\n# print(graph)\r\nwhile stack:\r\n\tx=stack.pop()\r\n\tif x[1]>l[x[0]]:\r\n\t\tz.append(x[0])\r\n\telse:\r\n\t\tfor i in graph[x[0]]:\r\n\t\t\tif (i,x[0]) in d:\r\n\t\t\t\te=d[(i,x[0])]\r\n\t\t\telse:\r\n\t\t\t\te=d[(x[0],i)]\r\n\t\t\tif e>=0:\r\n\t\t\t\tif x[1]>=0:\r\n\t\t\t\t\tt=x[1]+e\r\n\t\t\t\telse:\r\n\t\t\t\t\tt=e\r\n\t\t\telse:\r\n\t\t\t\tif x[1]>=0:\r\n\t\t\t\t\tt=x[1]+e\r\n\t\t\t\telse:\r\n\t\t\t\t\tt=e\r\n\t\t\tstack.append([i,t])\r\n# print(z)\r\ncount=0\r\nfor i in z:\r\n\tcount+=dfs_simple(i)\r\nprint(count)" ]
{"inputs": ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8", "6\n53 82 15 77 71 23\n5 -77\n6 -73\n2 0\n1 26\n4 -92", "10\n99 60 68 46 51 11 96 41 48 99\n4 50\n6 -97\n3 -92\n7 1\n9 99\n2 79\n1 -15\n8 -68\n5 -84", "8\n53 41 22 22 34 95 56 24\n3 -20\n7 -56\n5 -3\n3 22\n1 37\n6 -34\n2 32", "8\n2 19 83 95 9 87 15 6\n6 16\n7 98\n5 32\n7 90\n8 37\n2 -34\n1 -83", "6\n60 89 33 64 92 75\n4 50\n1 32\n5 21\n3 77\n1 86", "4\n14 66 86 37\n3 -9\n1 93\n2 -57", "9\n59 48 48 14 51 51 86 53 58\n1 -47\n5 10\n8 -6\n9 46\n2 -69\n8 -79\n9 92\n6 12", "3\n17 26 6\n1 -41\n2 -66", "7\n63 3 67 55 14 19 96\n4 35\n1 -23\n3 -66\n2 80\n3 80\n2 -42", "5\n91 61 4 61 35\n5 75\n2 13\n2 -15\n1 90", "19\n40 99 20 54 5 31 67 73 10 46 70 68 80 74 7 58 75 25 13\n13 -28\n12 -33\n9 -62\n12 34\n15 70\n5 -22\n7 83\n2 -24\n6 -64\n17 62\n14 -28\n1 -83\n4 34\n8 -24\n11 19\n6 31\n7 -8\n16 90", "39\n98 80 74 31 81 15 23 52 54 86 56 9 95 91 29 20 97 78 62 65 17 95 12 39 77 17 60 78 76 51 36 56 74 66 43 23 17 9 13\n15 21\n34 -35\n28 80\n13 -15\n29 -34\n38 -8\n18 10\n18 19\n27 54\n7 42\n16 49\n12 90\n39 33\n20 53\n2 91\n33 59\n29 -93\n36 29\n26 50\n5 -12\n33 -6\n17 -60\n27 7\n17 85\n31 63\n26 80\n1 -99\n4 -40\n10 -39\n11 36\n21 22\n16 -15\n14 -25\n25 30\n33 97\n38 26\n8 -78\n10 -7", "19\n51 5 39 54 26 71 97 99 73 16 31 9 52 38 89 87 55 12 3\n18 -94\n19 -48\n2 -61\n10 72\n1 -82\n13 4\n19 -40\n16 -96\n6 -16\n19 -40\n13 44\n11 38\n15 -7\n6 8\n18 -32\n8 -75\n3 58\n10 -15", "39\n100 83 92 26 10 63 56 85 12 64 25 50 75 51 11 41 78 53 52 96 63 12 48 88 57 57 25 52 69 45 4 97 5 87 58 15 72 59 100\n35 -60\n33 -39\n1 65\n11 -65\n34 -63\n38 84\n4 76\n22 -9\n6 -91\n23 -65\n18 7\n2 -17\n29 -15\n19 26\n29 23\n14 -12\n30 -72\n9 14\n12 -1\n27 -21\n32 -67\n7 -3\n26 -18\n12 -45\n33 75\n14 -86\n34 -46\n24 -44\n27 -29\n22 -39\n17 -73\n36 -72\n18 -76\n27 -65\n8 65\n24 -15\n35 79\n27 61", "2\n83 33\n1 67", "6\n538779323 241071283 506741761 673531032 208769045 334127496\n1 -532301622\n5 -912729787\n6 -854756762\n4 -627791911\n2 -289935846", "10\n909382626 193846090 573881879 291637627 123338066 411896152 123287948 171497812 135534629 568762298\n9 -257478179\n4 -502075958\n2 -243790121\n2 -927464462\n8 -89981403\n1 -792322781\n10 -326468006\n7 -261940740\n4 -565652087"], "outputs": ["5", "0", "7", "1", "5", "4", "3", "5", "0", "4", "4", "11", "37", "7", "38", "1", "0", "0"]}
UNKNOWN
PYTHON3
CODEFORCES
22
e47af8d23ee4295de6a8eeae7a68aa9d
Marina and Vasya
Marina loves strings of the same length and Vasya loves when there is a third string, different from them in exactly *t* characters. Help Vasya find at least one such string. More formally, you are given two strings *s*1, *s*2 of length *n* and number *t*. Let's denote as *f*(*a*,<=*b*) the number of characters in which strings *a* and *b* are different. Then your task will be to find any string *s*3 of length *n*, such that *f*(*s*1,<=*s*3)<==<=*f*(*s*2,<=*s*3)<==<=*t*. If there is no such string, print <=-<=1. The first line contains two integers *n* and *t* (1<=≤<=*n*<=≤<=105, 0<=≤<=*t*<=≤<=*n*). The second line contains string *s*1 of length *n*, consisting of lowercase English letters. The third line contain string *s*2 of length *n*, consisting of lowercase English letters. Print a string of length *n*, differing from string *s*1 and from *s*2 in exactly *t* characters. Your string should consist only from lowercase English letters. If such string doesn't exist, print -1. Sample Input 3 2 abc xyc 1 0 c b Sample Output ayd-1
[ "import sys\r\ninput = sys.stdin.readline \r\n\r\nl = [chr(i + ord('a')) for i in range(26)]\r\ndef fun(a1, b1):\r\n for i in l:\r\n if(i not in [a1, b1]):\r\n return i\r\n\r\nn, t = map(int, input().split()) \r\na = input()[:-1] \r\nb = input()[:-1]\r\ns, d = 0, 0 \r\nfor i in range(n):\r\n if(a[i] == b[i]):\r\n s += 1 \r\n else:\r\n d += 1 \r\nif(t < (d + 1) // 2):\r\n print(-1) \r\n exit() \r\n\r\nx, y, z = min(n - t, s), max(n - t - s, 0), max(n - t - s, 0) \r\nans = '' \r\nfor i in range(n):\r\n if(a[i] == b[i]):\r\n if(x):\r\n ans += a[i] \r\n x -= 1\r\n else:\r\n ans += fun(a[i], b[i]) \r\n else:\r\n if(y):\r\n ans += a[i]\r\n y -= 1\r\n elif(z):\r\n ans += b[i]\r\n z -= 1\r\n else:\r\n ans += fun(a[i], b[i]) \r\nprint(ans)", "def solve():\r\n n, t = map(int, input().split())\r\n s1 = input()\r\n s2 = input()\r\n s3 = ['']*n\r\n d = 0\r\n for i in range(n):\r\n if s1[i] == s2[i]:\r\n s3[i] = s1[i]\r\n else:\r\n d += 1\r\n for c in 'abc':\r\n if c != s1[i] and c != s2[i]:\r\n s3[i] = c\r\n break\r\n i = 0 \r\n while i < n and d < t:\r\n if s1[i] == s2[i]:\r\n for c in 'abc':\r\n if c != s1[i] and c != s2[i]:\r\n s3[i] = c\r\n break\r\n d += 1\r\n i += 1\r\n \r\n changeS1 = True \r\n i = 0\r\n while i < n and d > t:\r\n if s1[i] != s2[i]:\r\n if changeS1:\r\n s3[i] = s1[i]\r\n else:\r\n s3[i] = s2[i]\r\n d -= 1\r\n changeS1 = not changeS1\r\n i += 1\r\n \r\n if d != t: print(-1)\r\n else: print(''.join(s3)) \r\nif __name__ == \"__main__\":\r\n solve()", "n, t = map(int, input().split())\r\ns1 = input()\r\ns2 = input()\r\nsame, diff = [], []\r\nfor i, (c1, c2) in enumerate(zip(s1, s2)):\r\n if c1 == c2: same.append(i)\r\n else: diff.append(i)\r\np, s = n-t, len(same)\r\nres = ['']*n\r\nif p>s and (p-s)*2>len(diff):\r\n print(-1)\r\n exit()\r\nif p<=s:\r\n for i in same[:p]:\r\n res[i] = s1[i]\r\nelse:\r\n for i in same:\r\n res[i] = s1[i]\r\n for i in range(p-s):\r\n res[diff[2*i]] = s1[diff[2*i]]\r\n res[diff[2*i+1]] = s2[diff[2*i+1]]\r\nfor i, c in enumerate(res):\r\n if not c:\r\n for c in 'xyz':\r\n if c != s1[i] and c != s2[i]:\r\n res[i] = c\r\n break\r\nprint(''.join(res))\r\n\r\n", "n, t = map(int, input().split())\r\na, b = input(), input() \r\nans = []\r\ns = d = 0\r\nfor i, j in zip(a, b):\r\n\tif i == j:\r\n\t\ts += 1\r\n\telse:\r\n\t\td += 1\r\nif t < (d + 1) // 2:\r\n\tprint(-1)\r\n\texit()\r\n\r\nx = min(n - t, s)\r\ny = z = max(n - t - s, 0)\r\n\r\ndef f(a, b):\r\n\tfor i in range(97, 123):\r\n\t\tif chr(i) not in [a, b]:\r\n\t\t\treturn chr(i)\r\n\r\nfor i in range(n):\r\n\tif a[i] == b[i]:\r\n\t\tif x:\r\n\t\t\tans.append(a[i])\r\n\t\t\tx -= 1\r\n\t\telse:\r\n\t\t\tans.append(f(a[i], b[i]))\r\n\telse:\r\n\t\tif y:\r\n\t\t\tans.append(a[i])\r\n\t\t\ty -= 1\r\n\t\telif z:\r\n\t\t\tans.append(b[i])\r\n\t\t\tz -= 1\r\n\t\telse:\r\n\t\t\tans.append(f(a[i], b[i]))\r\nprint(''.join(ans))", "n, t = list(map(int, input().split()))\r\na = input().strip()\r\nb = input().strip()\r\nd = 0\r\nfor i in range(n):\r\n if a[i] != b[i]:\r\n d += 1\r\nif n - d + d // 2 < n - t:\r\n print(-1)\r\nelse:\r\n d -= d & 1\r\n ts = (n - t) * 2\r\n ss = max(0, n - t - d // 2)\r\n res = [''] * n\r\n for i in range(n):\r\n if a[i] != b[i]:\r\n if d and ts:\r\n res[i] = a[i]\r\n ts -= 1\r\n d -= 1\r\n a, b = b, a\r\n elif ss:\r\n res[i] = a[i]\r\n ss -= 1\r\n ts -= 2\r\n if not ts:\r\n break\r\n for i in range(n):\r\n if not res[i]:\r\n if a[i] != 'a' and b[i] != 'a':\r\n res[i] = 'a'\r\n elif a[i] != 'b' and b[i] != 'b':\r\n res[i] = 'b'\r\n else:\r\n res[i] = 'c'\r\n print(''.join(res))\r\n \r\n", "_, k = map(int, input().split())\nstr1,str2 = input(), input()\n\nans = ''\nfor i, j in zip(str1, str2):\n ans += next(c for c in 'abc' if c not in [i, j])\n\nk = len(str1) - k\nif not k:\n print(ans)\n exit()\nif k < 0:\n print(-1)\n exit()\n\nans = list(ans)\n\nfor i in range(len(str1)):\n if k == 0:\n break\n if str1[i] != str2[i]:\n continue\n ans[i] = str1[i]\n k-=1\n\nif not k:\n print(''.join(ans))\n exit()\n\nf = False\nfor i in range(len(str1)):\n if k == 0:\n break\n if ans[i] == str1[i]:\n continue\n if f:\n ans[i] = str1[i]\n k-=1\n else:\n ans[i] = str2[i]\n f = not f\n\nif f or k:\n print(-1)\n exit()\n\nprint(''.join(ans))\n\n\t\t\t\t\t\t\t\t\t \t\t\t \t\t \t\t\t \t", "n,t = list(map(int,input().split()))\r\ns1 = input()\r\ns2 = input()\r\nsame = sum(s1[i] == s2[i] for i in range(n))\r\nnot_same = n - same\r\n# 字母不相同的情况下 可以变到其中一个让其中一个去减1 或者跟相同一样去全变\r\nif not_same > 2*t:\r\n print(-1)\r\n exit()\r\nelif not_same <= t:\r\n # 需要引入相同的字符串\r\n cnt = t - not_same\r\n ans = \"\"\r\n for i in range(n):\r\n if s1[i] != s2[i]:\r\n for c in ('a','b','c'):\r\n if c != s1[i] and c != s2[i]:\r\n ans += c\r\n break\r\n elif cnt:\r\n for c in ('a','b'):\r\n if c != s1[i]:\r\n ans += c\r\n break\r\n cnt -= 1\r\n else:\r\n ans += s1[i]\r\nelse:\r\n cnt1 = not_same - t\r\n cnt2 = not_same - t\r\n ans = \"\"\r\n for i in range(n):\r\n if s1[i] == s2[i]:\r\n ans += s1[i]\r\n elif cnt1:\r\n ans += s1[i]\r\n cnt1 -= 1\r\n elif cnt2:\r\n ans += s2[i]\r\n cnt2 -= 1\r\n else:\r\n for c in ('a','b','c'):\r\n if c != s1[i] and c != s2[i]:\r\n ans += c\r\n break\r\nprint(ans)", "import string\r\nfrom os import path\r\nfrom sys import stdin, stdout\r\n\r\n\r\nfilename = \"../templates/input.txt\"\r\nif path.exists(filename):\r\n stdin = open(filename, 'r')\r\n\r\n\r\ndef input():\r\n return stdin.readline().rstrip()\r\n\r\n\r\ndef print(*args, sep=' ', end='\\n'):\r\n stdout.write(sep.join(map(str, args)))\r\n stdout.write(end)\r\n\r\n\r\ndef ceil(x: int, y: int) -> int:\r\n return (x + y - 1) // y\r\n\r\n\r\ndef solution():\r\n n, t = [int(num) for num in input().split()]\r\n s1 = input()\r\n s2 = input()\r\n same = []\r\n diff = []\r\n for i, (c1, c2) in enumerate(zip(s1, s2)):\r\n if c1 == c2:\r\n same.append(i)\r\n else:\r\n diff.append(i)\r\n ans = list(s1)\r\n if t >= len(diff):\r\n for i in diff:\r\n for c in string.ascii_lowercase:\r\n if c != s1[i] and c != s2[i]:\r\n ans[i] = c\r\n break\r\n t -= len(diff)\r\n for i in same[:t]:\r\n for c in string.ascii_lowercase:\r\n if c != s1[i]:\r\n ans[i] = c\r\n break\r\n elif t < ceil(len(diff), 2):\r\n print(-1)\r\n return\r\n else:\r\n y = len(diff) - t\r\n x = t - y\r\n for i in diff[:x]:\r\n for c in string.ascii_lowercase:\r\n if c != s1[i] and c != s2[i]:\r\n ans[i] = c\r\n break\r\n for i, j in zip(diff[x::2], diff[x + 1::2]):\r\n ans[i] = s1[i]\r\n ans[j] = s2[j]\r\n print(''.join(ans))\r\n\r\n\r\ndef main():\r\n t = 1\r\n while t:\r\n solution()\r\n t -= 1\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "from bisect import bisect_left, bisect_right\r\nfrom collections import Counter, deque\r\nfrom functools import lru_cache\r\nfrom math import factorial, comb, sqrt, gcd, lcm\r\nfrom copy import deepcopy\r\nimport heapq\r\n\r\nfrom sys import stdin, stdout\r\n\r\n# 加快读入速度, 但是注意后面的换行符(\\n)\r\n# 如果是使用 input().split() 或者 int(input()) 之类的, 换行符就去掉了\r\ninput = stdin.readline\r\n\r\ndef get_different(c1, c2=None):\r\n if c2 is None:\r\n if c1 != \"z\":\r\n return chr(ord(c1) + 1)\r\n else:\r\n return \"a\"\r\n else:\r\n if c2 < c1:\r\n c1, c2 = c2, c1\r\n if ord(c2) - ord(c1) > 1:\r\n return chr(ord(c1) + 1)\r\n else:\r\n if c2 == \"z\":\r\n return \"a\"\r\n else:\r\n return chr(ord(c2) + 1)\r\n\r\ndef main():\r\n n, t = map(int, input().split())\r\n s1 = input()[:-1]\r\n s2 = input()[:-1]\r\n ans = [\"\"] * n\r\n same_index = []\r\n different_index = []\r\n for i in range(n):\r\n if s1[i] == s2[i]:\r\n same_index.append(i)\r\n else:\r\n different_index.append(i)\r\n if len(different_index) > 2 * t:\r\n print(-1)\r\n elif len(different_index) <= t:\r\n extra = t - len(different_index)\r\n for i in range(len(different_index)):\r\n index = different_index[i]\r\n ans[index] = get_different(s1[index], s2[index])\r\n for i in range(len(same_index)):\r\n index = same_index[i]\r\n if i < extra:\r\n ans[index] = get_different(s1[index])\r\n else:\r\n ans[index] = s1[index]\r\n print(\"\".join(ans))\r\n else:\r\n all_different = 2 * t - len(different_index)\r\n one_same = len(different_index) - t\r\n for i in range(len(same_index)):\r\n index = same_index[i]\r\n ans[index] = s1[index]\r\n for i in range(len(different_index)):\r\n index = different_index[i]\r\n if i < all_different:\r\n ans[index] = get_different(s1[index], s2[index])\r\n elif i < all_different + one_same:\r\n ans[index] = s1[index]\r\n else:\r\n ans[index] = s2[index]\r\n print(\"\".join(ans))\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "\r\n\r\n\r\n\r\ndef f(n,a,b):\r\n x=0 \r\n for i in range(n):\r\n if a[i]==b[i]:\r\n x+=1 \r\n return x \r\n \r\nn,k=map(int, input().split())\r\na=str(input())\r\nb=str(input())\r\n\r\nx=f(n,a,b)\r\nk=n-k\r\ny1=k-x\r\ny2=y1 \r\nif k<=x:\r\n y1=0\r\n y2=0\r\n\r\nans=\"\"\r\nfor i in range(n):\r\n if a[i]==b[i]:\r\n if k>0:\r\n ans+=a[i]\r\n k-=1 \r\n else:\r\n if a[i]==\"a\":\r\n ans+=\"b\"\r\n else:\r\n ans+=\"a\"\r\n else:\r\n if y1>0:\r\n ans+=a[i]\r\n y1-=1\r\n \r\n elif y2>0:\r\n ans+=b[i]\r\n y2-=1 \r\n else:\r\n if \"a\"!=a[i] and \"a\"!=b[i]:\r\n ans+=\"a\"\r\n elif \"b\"!=a[i] and \"b\"!=b[i]:\r\n ans+=\"b\"\r\n else:\r\n ans+=\"c\"\r\n \r\n# print(y1,y2,ans)\r\nif y1>0 or y2>0:\r\n print(-1)\r\nelse:\r\n print(ans)\r\n\r\n" ]
{"inputs": ["3 2\nabc\nxyc", "1 0\nc\nb", "1 1\na\na", "2 1\naa\naa", "3 1\nbcb\nbca", "4 3\nccbb\ncaab", "4 2\nacbc\nacba", "4 1\nbcbc\nacab", "4 2\nacbb\nbabc", "5 2\nabaac\nbbbaa", "5 2\nabbab\nacbab", "5 3\nbcaaa\ncbacc", "5 3\ncbacb\ncbacb", "5 1\ncbabb\nbabaa", "1 0\na\na", "2 2\nbb\ncb", "2 1\ncc\nba", "2 0\nbb\nab", "3 3\naac\nabc", "1 1\na\nc", "3 0\ncba\ncca", "2 1\niy\niy", "2 2\nfg\nfn", "2 1\npd\nke", "3 3\nyva\nyvq", "3 2\npxn\ngxn", "3 1\nlos\nlns", "4 2\nhbnx\nhwmm", "4 4\nqtto\nqtto", "4 3\nchqt\nchet", "5 3\nwzcre\nwzcrp", "5 1\nicahj\nxdvch", "5 1\npmesm\npzeaq", "7 4\nycgdbph\nfdtapch", "10 6\nrnsssbuiaq\npfsbsbuoay", "20 5\ndsjceiztjkrqgpqpnakr\nyijdvcjtjnougpqprrkr", "100 85\njknccpmanwhxqnxivdgguahjcuyhdrazmbfwoptatlgytakxsfvdzzcsglhmswfxafxyregdbeiwpawrjgwcqrkbhmrfcscgoszf\nhknccpmanwhxjnxivdggeahjcuyhdrazmbfwoqtatlgytdkxsfvdztcsglhmssfxsfxyrngdbeiwpawrjgwcqrkbhmrfcsckoskf", "1 0\nz\nz", "1 1\nz\ny", "1 1\nz\nz", "1 0\nz\ny", "10 1\ngjsywvenzc\nfssywvenzc", "20 2\nywpcwcwgkhdeonzbeamf\ngdcmwcwgkhdeonzbeamf"], "outputs": ["bac", "-1", "b", "ab", "bcc", "cbca", "acab", "-1", "aaba", "abbab", "aabaa", "bbabb", "cbbaa", "-1", "a", "aa", "ca", "-1", "bca", "b", "-1", "ia", "aa", "pe", "aab", "axa", "las", "hbma", "aaaa", "caaa", "wzaaa", "-1", "-1", "yctaaah", "aasasbuaba", "-1", "aknccpmanwhxanxivaaaabaaaaaaaabaaaaaaaabaaaaabaaaaaaaaaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaa", "z", "a", "a", "-1", "gssywvenzc", "ywcmwcwgkhdeonzbeamf"]}
UNKNOWN
PYTHON3
CODEFORCES
10
e47bf94879dcfa3359e8b7621c92bda4
Co-prime Array
You are given an array of *n* elements, you must make it a co-prime array in as few moves as possible. In each move you can insert any positive integral number you want not greater than 109 in any place in the array. An array is co-prime if any two adjacent numbers of it are co-prime. In the number theory, two integers *a* and *b* are said to be co-prime if the only positive integer that divides both of them is 1. The first line contains integer *n* (1<=≤<=*n*<=≤<=1000) — the number of elements in the given array. The second line contains *n* integers *a**i* (1<=≤<=*a**i*<=≤<=109) — the elements of the array *a*. Print integer *k* on the first line — the least number of elements needed to add to the array *a* to make it co-prime. The second line should contain *n*<=+<=*k* integers *a**j* — the elements of the array *a* after adding *k* elements to it. Note that the new array should be co-prime, so any two adjacent values should be co-prime. Also the new array should be got from the original array *a* by adding *k* elements to it. If there are multiple answers you can print any one of them. Sample Input 3 2 7 28 Sample Output 1 2 7 9 28
[ "def primeFactors(n):\n factors = []\n i = 2\n while n > 1:\n while n % i == 0:\n factors.append(i)\n n //= i \n i += 1\n if i * i > n : break\n if n > 1:\n factors.append(n)\n return factors\n\ndef areCoprime(n1,n2):\n n1Factors = primeFactors(n1)\n areCoprime = True\n for f in n1Factors:\n if n2 % f == 0:\n areCoprime = False\n break\n return areCoprime\n\ndef sieve(n):\n primes = [True for i in range(n+1)]\n primeNums = []\n p = 2\n while p * p <= n:\n if primes[p]:\n for i in range(p*p,n+1,p):\n primes[i] = False\n p += 1\n for i in range(2,n+1):\n if primes[i]:\n primeNums.append(i)\n return primeNums\n\nn = int(input())\nA = list(map(int,input().split()))\nk = 0\nadded = {}\nprimes = sieve(10**5) # esse valor foi um chute, n dá pra gerar todos os fatores até 10^9\nfor i in range(1,len(A)):\n checkCoprime = areCoprime(A[i],A[i-1])\n factor = -1\n if not checkCoprime:\n k += 1\n for p in primes:\n if A[i] % p != 0 and A[i-1] % p != 0:\n factor = p\n break\n added[i] = factor\nprint(k)\nout = f\"{A[0]} \"\nfor i in range(1,len(A)):\n if i in added:\n out += f\"{str(added[i])} \"\n out += str(A[i])\n if i < len(A) - 1:\n out += \" \"\nprint(out)\n\t \t\t\t\t \t\t \t\t \t\t \t\t \t \t\t\t\t", "# cook your dish here\r\nimport math\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nb = []\r\nb.append(a[0])\r\nc = 0\r\ni = 1\r\nwhile(i<n):\r\n if math.gcd(a[i],a[i-1])==1:\r\n b.append(a[i])\r\n else:\r\n c+=1\r\n if math.gcd(2,a[i-1])==1 and math.gcd(2,a[i])==1:\r\n b.append(2)\r\n b.append(a[i])\r\n elif math.gcd(3,a[i-1])==1 and math.gcd(3,a[i])==1:\r\n b.append(3)\r\n b.append(a[i])\r\n else:\r\n b.append(1)\r\n b.append(a[i])\r\n i+=1\r\nprint(c)\r\nfor i in b:\r\n print(i,end=\" \")\r\nprint('')", "n = int(input())\r\nnumbers = iter(map(int, input().split()))\r\nfrom math import gcd\r\ninsert_counter = 0\r\nb = next(numbers)\r\nresult = [b]\r\nfor _ in range(n - 1):\r\n a = b\r\n b = next(numbers)\r\n if gcd(a, b) != 1:\r\n insert_counter += 1\r\n result.append(1)\r\n result.append(b)\r\nprint(insert_counter)\r\n[print(number, end=' ') for number in result]\r\n", "n = int(input())\n\nimport math\n\nl = input().split()\nresult = []\n\ncount = 0\nfor i in range(len(l)-1):\n result.append(l[i])\n if math.gcd(int(l[i]), int(l[i+1])) != 1:\n result.append(1)\n count += 1\n \nresult.append(l[-1])\n\nprint (count)\nfor i in result:\n print (i, end =\" \")\n\t \t \t \t\t\t\t\t \t\t \t \t\t \t", "n = int(input())\nx = input().split(' ')\n\n\ndef mdc(num1, num2):\n if num1 > num2:\n aux1, aux2 = num1, num2\n else:\n aux1, aux2 = num2, num1\n while True:\n r = aux1 % aux2\n if r != 0:\n aux1 = aux2\n aux2 = r\n if r == 0:\n break\n if aux2 == 1:\n return True\n else:\n return False\n\n\ncont = 0\ni = 0\n\nwhile i < len(x) - 1:\n a, b = int(x[i]), int(x[i + 1])\n if not mdc(a, b):\n x.append(0)\n for j in range(len(x) - 1, i, -1):\n x[j] = x[j - 1]\n x[i + 1] = 1\n cont += 1\n i += 1\n i += 1\n\nprint(cont), print(*x)\n\n\t \t\t \t \t \t \t\t \t \t \t \t\t\t\t\t\t \t", "import fractions\ndef coprimeArray(arr, n):\n c = 0\n for i in range(1, n):\n if fractions.gcd(arr[i], arr[i-1]) != 1:\n c = c+1\n print(c)\n print(arr[0], end=\" \")\n \n for i in range(1, n):\n if fractions.gcd(arr[i], arr[i-1]) != 1:\n print(1, end=\" \")\n print(arr[i], end=\" \") \n \nif __name__ == \"__main__\":\n n = int(input())\n arr = list(map(int, input().split()))\n coprimeArray(arr, n) \n print()\n \t\t \t \t\t \t\t\t\t \t \t\t \t", "def gcd(x,y):\r\n while y:\r\n x,y=y,x%y\r\n return x\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nnl=[]\r\nc=0\r\nfor i in range(n-1):\r\n nl.append(l[i])\r\n if gcd(l[i],l[i+1])!=1:\r\n nl.append(1)\r\n c+=1\r\nnl.append(l[n-1])\r\nprint(c)\r\nfor i in range(len(nl)):\r\n print(nl[i],end=\" \")\r\nprint()", "def gcd(a, b):\r\n if (b == 0):\r\n return a\r\n return gcd(b, a%b)\r\n\r\nn = int(input().strip())\r\narr = list(map(int, input().strip().split()))\r\ni, count = 0, 0\r\nfor i in range(n-1):\r\n if gcd(arr[i], arr[i+1]) != 1:\r\n count += 1\r\nprint(count)\r\nprint(arr[0], end=\" \")\r\nfor i in range(1, n):\r\n if gcd(arr[i], arr[i-1]) != 1:\r\n print(1, end=\" \")\r\n print(arr[i], end=\" \")", "def gcd(a, b):\r\n if b == 0:\r\n return a\r\n return gcd(b, a%b)\r\n\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\n\r\nlength = n\r\ncount = 0\r\ni = 0\r\nwhile i < length - 1:\r\n if gcd(arr[i], arr[i+1]) > 1:\r\n arr.insert(i+1, 1)\r\n count += 1\r\n length += 1\r\n i += 1\r\nprint(count)\r\nprint(*arr)", "import sys\r\nfrom math import gcd\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nans = [a[0]]\r\nfor i in range(1, n):\r\n if gcd(a[i-1], a[i]) != 1:\r\n for j in range(2, 10**9):\r\n if gcd(a[i-1], j) == 1 and gcd(a[i], j) == 1:\r\n ans.append(j)\r\n break\r\n ans.append(a[i])\r\n\r\nprint(len(ans) - n)\r\nprint(*ans)\r\n", "from math import gcd\r\nn=int(input())\r\nk=0\r\nl=list(map(int,input().split()))\r\np=[]\r\nfor i in range(n-1):\r\n if gcd(l[i],l[i+1])>1:\r\n p.append(l[i])\r\n p.append(1)\r\n k=k+1\r\n else:\r\n p.append(l[i])\r\np.append(l[-1])\r\nprint(k)\r\nprint(*p,sep=\" \")", "def gcd(a,b):\n\tif b == 0: return a\n\treturn gcd(b, a%b)\n\n\nn = int(input())\nseq = list(map(int, input().split()))\n\ncont = 0\nsaida = str(seq[0])\nfor i in range(1, n):\n\tif gcd(seq[i], seq[i -1]) != 1:\n\t\tcont += 1\n\t\tsaida += ' 1 '\n\t\tsaida += str(seq[i])\n\telse:\n\t\tsaida += ' '\n\t\tsaida += str(seq[i])\n\nprint(cont)\nprint(saida)\n", "import math\n\nn = int(input())\na = list(map(int, input().split()))\n\ncounter = 0\nanswer = []\nfor i in range(n-1):\n answer.append(a[i])\n if math.gcd(a[i], a[i+1]) != 1:\n counter += 1\n answer.append(1)\n\nanswer.append(a[-1])\n\nprint(counter)\nprint(*answer)\n\t\t \t \t \t \t\t \t \t\t \t \t\t\t \t \t", "import sys\r\nimport math\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\ni = 1\r\nans = [a[0]]\r\nwhile i < n:\r\n\tif math.gcd(ans[-1], a[i]) == 1:\r\n\t\tans.append(a[i])\r\n\t\ti += 1\r\n\telse:\r\n\t\tans.append(1)\r\nprint(len(ans) - n)\r\nprint(*ans)\r\n", "n = int(input())\na = list(map(int, input().split()))\n\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\n\n\nprime_a = [a[0]]\ncount = 0\nfor i in range(n - 1):\n if nod(a[i], a[i + 1]) != 1:\n prime_a.append(1)\n count += 1\n prime_a.append(a[i + 1])\n\nprint(count)\nprint(*prime_a)\n", "def gcd(x, y):\r\n while y != 0:\r\n (x, y) = (y, x % y)\r\n return x\r\nn=int(input())\r\nAr=[int(x) for x in input().split()]\r\ncnt=0\r\nA=[]\r\nfor i in range(n-1):\r\n if (gcd(Ar[i],Ar[i+1]))>1:\r\n cnt+=1\r\n m=1\r\n A.append(Ar[i])\r\n A.append(m)\r\n else:\r\n A.append(Ar[i])\r\nA.append(Ar[-1])\r\nprint(cnt)\r\nfor i in A:\r\n print(i, end=' ')", "import math\nn = int(input())\na = list(map(int, input().rstrip().split()))\nt = 0\nans = [a[0]]\nfor i in range(1, n):\n x = ans[-1]\n y = a[i]\n g = math.gcd(x, y)\n if g != 1:\n ans += [1, y]\n t += 1\n else:\n ans += [y]\nprint(t)\nprint(*ans)", "import math\r\n\r\nn = int(input())\r\nentrada = list(map(int, input().split()))\r\n\r\nk = 0\r\nsaida = [entrada[0]]\r\n\r\nfor i in range(1, n):\r\n if math.gcd(entrada[i], saida[-1]) != 1:\r\n k += 1\r\n saida.append(1)\r\n saida.append(entrada[i])\r\n\r\nprint(k)\r\nprint(*saida)\r\n", "\ndef mdc(a, b):\n if a == 0:\n return b\n else:\n return mdc(b % a, a)\n\ndef is_coprime(a, b):\n return mdc(a, b) == 1\n\nimport math\n\nlimit = int(math.sqrt(10**9))\nnumbers = list(range(2, limit))\nfor i in range(0, int(math.sqrt(limit))):\n if(numbers[i] > 0):\n k = 2\n while k * numbers[i] - 2 < len(numbers):\n numbers[numbers[i] * k - 2] = 0\n k += 1\n\nprimes = []\nfor n in numbers:\n if n > 0:\n primes.append(n)\n\ndef calc_coprime(a, b):\n i = 0\n while not is_coprime(primes[i], a) or not is_coprime(primes[i], b):\n i+= 1\n return primes[i]\n\nk = int(input())\nnums = list(map(int, input().split(' ')))\nresult = []\n\nresult.append(nums[0])\nfor i in range(1, len(nums)):\n while not is_coprime(nums[i], result[-1]):\n result.append(calc_coprime(result[-1], nums[i]))\n result.append(nums[i])\n\nprint(len(result) - len(nums))\nfor n in result:\n print(n, end=\" \")\nprint(\"\")\n\n\t \t\t \t\t\t\t \t \t \t\t\t", "import sys, math\r\ninput=sys.stdin.readline\r\nINF=int(1e9)+7\r\n\r\ndef solve(): \r\n n=int(input())\r\n data=list(map(int,input().split()))\r\n ans=0\r\n result=[]\r\n for i in range(n-1):\r\n result.append(data[i])\r\n if math.gcd(data[i],data[i+1])!=1:\r\n result.append(1)\r\n ans+=1\r\n \r\n result.append(data[-1])\r\n print(ans)\r\n print(*result,sep=' ')\r\n \r\n \r\nt=1\r\nwhile t:\r\n t-=1\r\n solve()\r\n", "import math\nfrom collections import deque\n\n\nn = int(input())\ndeck = deque([])\ncounter = 0\nsequencia = list(map(int, input().split()))\ncomp = 0\n\nwhile comp < n - 1:\n comp +=1\n deck.append(sequencia[comp - 1])\n if math.gcd(sequencia[comp], sequencia[comp - 1]) > 1:\n deck.append(1)\n counter += 1\n \ndeck.append(sequencia[-1]) \n\nprint(counter)\nprint(*deck)\n \t\t \t \t \t \t\t\t \t \t\t\t\t\t\t\t\t\t\t", "def gcd(a,b):\r\n if a==0:\r\n return b\r\n return gcd(b%a,a)\r\n\r\nn = int(input())\r\nl = list(map(int,input().split()))\r\n \r\nans=\"\"\r\nans+=str(l[0])\r\nprev= l[0]\r\ncnt=int(0)\r\nfor i in range(1,n):\r\n if gcd(prev,l[i])!=1:\r\n prev = l[i]\r\n ans=ans+\" 1 \"+str(l[i])\r\n cnt+=1\r\n else:\r\n prev = l[i]\r\n ans=ans+\" \"+str(l[i])\r\n \r\nprint(cnt)\r\nprint(ans)\r\n", "import math\n\ndef coprimo(a,b):\n return math.gcd(a,b) == 1\n\ndef achar(a,b):\n minimo = min(a,b)\n maximo = max(a,b)\n for i in range(1,maximo+1):\n if(coprimo(minimo,i) and coprimo(i,maximo)):\n return i\n \nn = int(input())\nlista = list(map(int, input().split()))\n\n\naux = str(lista[0])\ni = 0\ncount = 0\nif n == 1:\n aux = str(lista[0])\nelse:\n while(i < n - 1):\n if(not coprimo(lista[i], lista[i+1])):\n if(i == 0):\n aux = aux + \" \" + str(achar(lista[i], lista[i+1]))\n else:\n aux += \" \" + str(lista[i])\n aux += \" \" + str(achar(lista[i], lista[i+1]))\n count +=1\n else:\n if(i == 0):\n aux = aux\n else:\n aux += \" \" + str(lista[i])\n i+=1\n aux = aux + \" \" + str(lista[i])\nprint(count)\nprint(aux)\n\n\t\t \t\t \t \t \t \t \t\t\t\t \t \t\t \t \t", "from math import gcd\n \nn = int(input())\na = list(map(int, input().split()))\n \nl = [a[0]]\ncnt = 0\n \nfor i in range(1, n):\n if gcd(a[i], a[i-1]) != 1:\n l.append(1)\n cnt += 1\n \n l.append(a[i])\n \nprint(cnt)\nprint(*l)\n\n\t\t \t \t\t \t\t\t\t\t\t \t \t\t \t \t \t\t\t", "def nod(a,b):\r\n while a*b:\r\n if a>b:\r\n a%=b\r\n else:\r\n b%=a\r\n return a+b\r\n\r\nn=int(input())\r\nl=[int(j) for j in input().split()]\r\ng=[l[0]]\r\nk=0\r\nfor i in range(1,n):\r\n a=l[i-1]\r\n b=l[i]\r\n \r\n \r\n if nod(a,b)!=1:\r\n k+=1\r\n g.append(1)\r\n g.append(b)\r\nprint(k)\r\nprint(*g)\r\n", "from math import gcd\r\nn = int(input())\r\nd = list(map(int,input().split()))\r\nans = []\r\nd += [1]\r\nfor i in range(n):\r\n ans += [d[i]]\r\n if gcd(d[i],d[i + 1]) > 1:ans += [1]\r\nprint(len(ans) - n)\r\nprint(*ans)\r\n", "def gcd(n1, n2):\n if(n1 == 0):\n return n2\n return gcd(n2 % n1, n1)\n\nn = int(input())\nseq = list(map(int, input().split()))\nk = 0\n\nfor e in range(len(seq)-1,0,-1): \n if(gcd(seq[e],seq[e-1]) != 1):\n k += 1\n seq.insert(e,1)\n\nprint(k)\nfor i in seq:\n print(i, end=' ')\n\t \t\t \t \t \t \t \t\t \t\t\t \t \t", "import math\r\nn=int(input())\r\nll=list(map(int,input().split()))\r\nk=10**9\r\nflag2=False\r\nwhile k>0 and not flag2:\r\n if k&1:\r\n i=3\r\n flag=False\r\n while i*i<=k:\r\n if k%i==0:\r\n flag=True\r\n break\r\n i+=2\r\n if not flag:\r\n if k not in ll:\r\n flag2=True\r\n break\r\n k-=1\r\nkk=[]\r\nfor i in range(n-1):\r\n x,y=ll[i],ll[i+1]\r\n if math.gcd(x,y)==1:\r\n kk.append(x)\r\n else:\r\n kk.append(x)\r\n kk.append(k)\r\nkk.append(ll[-1])\r\nprint(len(kk)-n)\r\nprint(*kk)", "def gcd(x, y):\n if(x%y == 0):\n return y\n return gcd(y, x%y)\n\nn = int(input())\narr = list(map(int,input().split()))\nans = str(arr[0])\ni = 0\ncont = 0\n\nwhile (i < len(arr) -1):\n mdc = gcd(arr[i], arr[i+1])\n \n if(mdc == 1):\n i+=1\n else:\n arr = arr[:i + 1] + [1] + arr[i +1:]\n cont += 1 \n i+=2\nprint(cont)\nprint(\" \".join(map(str,arr)))\n\n\t \t\t \t \t \t \t\t \t \t\t\t \t\t \t", "import math\nn = int(input())\nsequence = list(map(int, input().split()))\ni = 0\ncount = 0\nwhile(i < len(sequence) - 1):\n if(math.gcd(sequence[i], sequence[i + 1]) != 1):\n sequence.insert(i + 1, 1)\n count += 1\n i += 1\nprint(count)\nprint(\" \".join(map(str, sequence)))\n\t\t \t\t\t \t \t \t\t\t\t \t \t", "import math\r\n\r\ndef is_coprime(a, b):\r\n return math.gcd(a, b) == 1\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\n\r\nk = 0 \r\nnew_array = [a[0]]\r\n\r\nfor i in range(1, n):\r\n if not is_coprime(new_array[-1], a[i]):\r\n k += 1\r\n new_array.append(1)\r\n new_array.append(a[i])\r\n\r\nprint(k)\r\nprint(\" \".join(map(str, new_array)))", "from math import gcd\r\n\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\nright = arr[:1]\r\n\r\nfor i in range(1, n):\r\n if gcd(arr[i], arr[i - 1]) != 1:\r\n right.append(1)\r\n right.append(arr[i])\r\n\r\nprint(len(right) - n)\r\nprint(*right)\r\n", "import math\n\nnum = int(input())\ny = [int(x) for x in input().split()]\nz = []\n\nfor i in range(num):\n if i > 0 and math.gcd(y[i], z[-1])!=1:\n z.append(1)\n z.append(y[i])\n\nprint(len(z) - num)\nprint(' '.join(map(str, z)))\n \t \t\t \t \t \t", "def gcd(a,b):\r\n if (b == 0):\r\n return a\r\n return gcd(b, a%b)\r\n\r\nn=int(input())\r\na=list(map(int, input().split(' ')))\r\nc=0\r\nfor i in range(n-1,0,-1):\r\n if(a[i] != 1 and a[i-1] != 1 and (gcd(a[i], a[i-1])!=1)):\r\n a.insert(i,1)\r\n c+=1 \r\nprint(c)\r\nfor j in a:\r\n print(j,end=' ')\r\n\r\n\"\"\" print(gcd(5,28)) \"\"\"", "def mdc(x, y):\r\n if x % y == 0:\r\n return y\r\n return mdc(y, x % y)\r\n\r\n\r\nn = int(input())\r\narray = list(map(int, input().split()))\r\n\r\nk = 0\r\nresult = []\r\nresult.append(array[0])\r\nfor i in range(1, n):\r\n while mdc(result[-1], array[i]) != 1:\r\n k += 1\r\n result.append(1)\r\n result.append(array[i])\r\n\r\nprint(k)\r\nprint(\" \".join(map(str, result)))\r\n", "import math\r\nn=int(input())\r\na,l,s=list(map(int,input().split())),[],0\r\nfor i in range(1,n):\r\n if math.gcd(a[i],a[i-1])!=1:l.append(i);s+=1\r\nfor i in range(1,len(l)):l[i]+=i\r\nfor i in l:a.insert(i,1)\r\nprint(s)\r\nprint(*a)", "\nfrom math import *\n\nn=int(input())\na=list(map(int,input().split(\" \")))\n\nl=[]\nl.append(a[0])\n\nfor i in range(1,n):\n\tif(gcd(a[i],a[i-1])!=1):\n\t\tl.append(1)\n\n\tl.append(a[i])\n\nprint(len(l)-n)\nprint(*l)\n", "import bisect\r\nimport copy\r\nimport decimal\r\nimport fractions\r\nimport heapq\r\nimport itertools\r\nimport math\r\nimport random\r\nimport sys\r\nimport time\r\nfrom collections import Counter,deque,defaultdict\r\nfrom functools import lru_cache,reduce\r\nfrom heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max\r\ndef _heappush_max(heap,item):\r\n heap.append(item)\r\n heapq._siftdown_max(heap, 0, len(heap)-1)\r\ndef _heappushpop_max(heap, item):\r\n if heap and item < heap[0]:\r\n item, heap[0] = heap[0], item\r\n heapq._siftup_max(heap, 0)\r\n return item\r\nfrom math import gcd as GCD\r\nread=sys.stdin.read\r\nreadline=sys.stdin.readline\r\nreadlines=sys.stdin.readlines\r\nwrite=sys.stdout.write\r\n\r\nN=int(readline())\r\nA=list(map(int,readline().split()))\r\nans_lst=[A[0]]\r\nfor a in A[1:]:\r\n if GCD(ans_lst[-1],a)==1:\r\n ans_lst.append(a)\r\n else:\r\n ans_lst.append(1)\r\n ans_lst.append(a)\r\nprint(len(ans_lst)-N)\r\nprint(*ans_lst)", "def 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\n\r\nn = int(input())\r\n\r\nl = list(map(int, input().split()))\r\n\r\ni = 1\r\nwhile i < len(l):\r\n if(gcd(l[i-1], l[i]) != 1):\r\n l = l[:i] + [1] + l[i:]\r\n i += 2\r\n else:\r\n i += 1\r\n\r\nprint(len(l) - n)\r\nprint(*l)", "import sys\r\nimport math\r\n#import random\r\n#sys.setrecursionlimit(1000000)\r\ninput = sys.stdin.readline\r\n \r\n############ ---- USER DEFINED INPUT FUNCTIONS ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inara():\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############ ---- THE ACTUAL CODE STARTS BELOW ---- ############\r\n\r\nn=inp()\r\nara=inara()\r\n\r\nans=[]\r\n\r\nfor i in range(n-1):\r\n\tans.append(ara[i])\r\n\tif math.gcd(ara[i],ara[i+1])>1:\r\n\t\tans.append(1)\r\nans.append(ara[n-1])\r\n\r\nprint(len(ans)-n)\r\nprint(*ans)\r\n", "from math import gcd\nn = int(input())\nans = []\nfor c in map(int, input().split()):\n if ans == []:\n ans += [c]\n elif gcd(ans[-1], c) != 1:\n ans += [1, c]\n else:\n ans += [c]\nprint(len(ans) - n)\nprint(' '.join(map(str, ans)))\n", "import math\nn=int(input())\nl=[]\ncnt=0\nl=[int(x) for x in input().split()]\ni=1\nwhile(i!=len(l)):\n if math.gcd(l[i],l[i-1])>1:\n cnt+=1\n l.insert(i,1)\n i+=1\nprint(cnt)\nfor i in l:\n print(i,end=\" \")\n \t \t\t \t\t \t\t \t \t \t \t\t \t \t", "n = int(input())\na = list(map(int, input().split()))\nnew_a = [a[0]]\ncount = 0\nfor i in range(1, n):\n anterior = a[i-1]\n atual = a[i]\n resto = anterior % atual\n\n while resto != 0:\n anterior = atual\n atual = resto\n resto = anterior % atual\n if atual != 1:\n new_a.append(1)\n count += 1\n new_a.append(a[i])\nprint(count)\nprint(*new_a, sep=' ')\n \t \t \t\t\t\t \t \t \t\t \t \t", "p=10**5 \r\nfrom math import gcd\r\ndef calc(a,b):\r\n prms=[2,3,5,7,11,13]\r\n for i in prms: \r\n if gcd(i,a)==1 and gcd(i,b)==1:\r\n return i \r\ndef calc1(a):\r\n prms=[2,3,5,7] \r\n for i in prms:\r\n if gcd(i,a)==1 :\r\n return i \r\nn=int(input())\r\nl=[int(i) for i in input().split()]\r\ncnt=0 \r\nl1=[]\r\nfor i in range(0,len(l)-1):\r\n if gcd(l[i],l[i+1])!=1:\r\n l1.append(1)\r\n cnt+=1 \r\nprint(cnt)\r\nfor i in range(0,n-1):\r\n if gcd(l[i],l[i+1])!=1:\r\n print(l[i],end=' ')\r\n print(1,end=' ')\r\n else:\r\n print(l[i],end=' ')\r\nprint(l[n-1])", "from math import gcd\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nans=[]\r\ncount=0\r\nfor i in range(n-1):\r\n if gcd(l[i],l[i+1])!=1:\r\n ans.append(l[i])\r\n ans.append(1)\r\n count+=1\r\n else:\r\n ans.append(l[i])\r\nans.append(l[-1])\r\nprint(count)\r\nprint(*ans)\r\n\r\n", "from math import gcd\nn = int(input())\na = list(map(int, input().split()))\nl = 0\nr = 1\ni = 0\ncount = 0\nwhile r < len(a):\n if gcd(a[l],a[r]) != 1:\n a.insert(r,1)\n count+=1\n i+=1\n l+=1\n r+=1\nprint(count)\nfor i in a:\n print(f'{i} ', end=\"\")\n\n \t\t \t \t\t \t \t \t\t\t\t \t\t \t\t\t", "def MCD(a, b):\r\n while b!=0:\r\n a, b = b, a % b\r\n return a\r\ndef SonCoprimos(a, b):\r\n mcd = MCD(a, b)\r\n if mcd==1:\r\n return True\r\n else:\r\n return False\r\nresult=[]\r\nagg=0\r\nn=int(input())\r\narr=[int(x) for x in input().split(' ')]\r\nfor i in range(n-1):\r\n result.append(arr[i])\r\n if(not SonCoprimos(arr[i],arr[i+1])):\r\n result.append(1)\r\n agg+=1\r\nresult.append(arr[n-1])\r\nprint(agg)\r\ncadena = ' '.join(map(str, result))\r\nprint(cadena)\r\n", "import math\n \nn = int(input())\na = list(map(int, input().split()))\nres = []\ncount = 0\n \nfor i in range(n - 1):\n res.append(a[i])\n gcd = math.gcd(a[i], a[i + 1])\n aux = a[i] + a[i + 1]\n if(aux != 2):\n if(gcd != 1):\n res.append(1)\n count += 1\n \nres.append(a[-1])\n \nprint(count)\nprint(*res)\n\t \t\t \t \t \t\t\t\t\t\t \t\t \t \t\t\t\t", "\nn=int(input())\nl=list(map(int,input().split()))\n \ndef gcd(a,b):\n if b==0: \n return a \n return gcd(b,a%b)\n \nls=[]\nc=0\nfor i in range(n-1):\n ls.append(l[i])\n if gcd(l[i],l[i+1])!=1:\n c+=1\n ls.append(1)\n \nls.append(l[n-1])\nprint(c)\nprint(*ls)\n \t\t \t \t \t \t\t\t\t\t\t\t\t \t\t\t \t", "from math import *\r\nsInt = lambda: int(input())\r\nmInt = lambda: map(int, input().split())\r\nlInt = lambda: list(map(int, input().split()))\r\n\r\n\r\nn = sInt()\r\na = lInt()\r\ni = 0\r\nans = 0\r\nwhile i<n+ans-1:\r\n if gcd(a[i], a[i+1])!=1:\r\n ans += 1\r\n a.insert(i+1, 1)\r\n i += 1\r\n i += 1\r\nprint(ans)\r\nprint(*a, sep=\" \")", "from math import gcd\nn=int(input())\na=list(map(int, input().split()))\nans=list()\nk=0\nfor i in range(n - 1):\n ans.append(a[i])\n if gcd(a[i],a[i + 1])>1:\n ans.append(1)\n k += 1\nans.append(a[-1])\nprint(k)\nprint(*ans)\n\n\n\n\n\n\n\n\t\t\t\t\t \t \t \t \t\t \t \t", "from math import gcd\r\nn=int(input())\r\na=list(map(int,input().split()))\r\ncnt=0; ans=\"\"\r\nfor i in range(1,n):\r\n if gcd(a[i-1],a[i])==1:\r\n ans+=f\"{a[i-1]} \"\r\n else:\r\n cnt+=1\r\n ans+=f\"{a[i-1]} 1 \"\r\nans+=f\"{a[-1]}\"\r\nprint(cnt)\r\nprint(ans)", "def solve(arr):\r\n if len(arr) == 0:\r\n return []\r\n elif len(arr) == 1:\r\n return arr\r\n else:\r\n a, b, *rest = arr\r\n if math.gcd(a, b) > 1:\r\n return [a, 1] + solve([b] + rest)\r\n else:\r\n return [a] + solve([b] + rest)\r\n\r\nif __name__ == \"__main__\":\r\n import math\r\n\r\n n = int(input())\r\n a = list(map(int, input().split()))\r\n b = solve(a)\r\n print(len(b) - n)\r\n print(\" \".join(map(str, b)))", "\r\n\r\n#from itertools import *\r\n#from math import *\r\n#from bisect import *\r\n#from collections import *\r\n#from random import * # ( : ): ( :) : (: ) : ( ): ) : )\r\n#from decimal import *\r\n#from heapq import *\r\nfrom itertools import * # Things Change ....remember :)\r\nimport sys\r\nfrom math import gcd \r\ninput=sys.stdin.readline\r\ndef inp():\r\n return int(input())\r\ndef st():\r\n return input().rstrip('\\n')\r\ndef lis():\r\n return list(map(int,input().split()))\r\ndef ma():\r\n return map(int,input().split())\r\n\r\nn=inp()\r\nnos=lis()\r\nk=0\r\nfor i in range(n-1):\r\n gc=gcd(nos[i],nos[i+1])\r\n if gc!=1:\r\n k+=1\r\nprint(k)\r\nfor i in range(n-1):\r\n gc=gcd(nos[i],nos[i+1])\r\n print(nos[i],end=' ')\r\n if gc!=1:\r\n print(1,end=' ')\r\nprint(nos[n-1]) \r\n \r\n \r\n ", "def 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\nn = int(input())\r\na = list(map(int, input().split()))\r\nb = []\r\nb.append(a[0])\r\ns = 0\r\nfor i in range(1, len(a)):\r\n if gcd(a[i], a[i-1]) != 1:\r\n b.append(1)\r\n s+=1\r\n b.append(a[i])\r\nprint(s)\r\nprint(*b)", "from math import gcd\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nnew = [a[0]]\r\n\r\nfor i in range(1, n):\r\n if gcd(a[i], a[i-1]) != 1:\r\n new.append(1)\r\n new.append(a[i])\r\n \r\nprint(len(new) - n)\r\nprint(*new)", "n = int(input())\narr = list(map(int, input().split()))\nres = []\ncount = 0\ndef greatest_common_div(x, y):\n\tif y == 0:\n\t\treturn x\n\telse:\n\t\treturn greatest_common_div(y,x%y)\t\n\t\t\nfor i in range(n):\n\tif greatest_common_div(arr[i], arr[i-1]) != 1 and i != 0:\n\t\tres.append(1)\n\t\tcount += 1\n\tres.append(arr[i])\nprint(count)\nprint(*res)\n\n\t\t\n \t \t\t\t\t\t \t \t \t \t \t\t\t\t", "def mdc(a, b):\n if b == 0:\n return a\n else:\n return mdc(b, a % b)\n\ninput()\nlista = list(map(int, input().split()))\ntamanhoIni = len(lista)\n\ni = 0\nwhile i < len(lista) - 1:\n mdcPar = 1\n if lista[i] > lista[i + 1]:\n mdcPar = mdc(lista[i], lista[i + 1])\n else:\n mdcPar = mdc(lista[i + 1], lista[i])\n \n if mdcPar == 1:\n i += 1\n else:\n lista.insert(i + 1, 1)\n i += 2\n\nprint(len(lista) - tamanhoIni)\nprint(*lista)\n\t \t \t \t \t \t\t \t \t\t \t\t\t\t \t \t", "n = int(input())\na = [int(s) for s in input().split()]\n \ndef evklid(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 \n \ns = ''\nk = 0\ns += str(a[0])\nfor i in range(1, n):\n if evklid(a[i], a[i-1]) != 1:\n k += 1\n s += ' 1 ' + str(a[i])\n else:\n s += ' ' + str(a[i])\nprint(k)\nprint(s)\n\t \t \t \t\t \t \t \t\t\t \t \t\t\t\t\t", "import math\nn = int(input())\na = input()\naas = list(map(int, a.split(' ')))\nnarray = []\nnarray.append(aas[0])\ni = 0\n\nfor idx in range(n-1):\n if (math.gcd(aas[idx],aas[idx+1]) != 1):\n i += 1\n if (aas[idx] == 999999733 or aas[idx+1] == 999999733):\n narray.append(999999491)\n else:\n narray.append(999999733)\n\n narray.append(aas[idx + 1])\n\nprint(i)\nfor i in narray:\n print(int(i), end=' ')\n\t \t\t \t \t\t\t \t\t \t \t\t \t \t\t\t\t \t", "from math import gcd\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nans = []\r\ncount = 0\r\nans.append(a[0])\r\nfor i in range(1,n):\r\n if gcd(a[i],a[i-1]) != 1:\r\n ans.append(1)\r\n count += 1\r\n ans.append(a[i])\r\nprint(count)\r\nprint(*ans)", "import math\r\n\r\n# Function to check if two numbers are co-prime\r\ndef are_coprime(a, b):\r\n return math.gcd(a, b) == 1\r\n\r\n# Input\r\nn = int(input())\r\na = list(map(int, input().split()))\r\n\r\nk = 0 \r\nnew_array = [a[0]]\r\n\r\nfor i in range(1, n):\r\n if not are_coprime(new_array[-1], a[i]):\r\n k += 1\r\n new_array.append(1)\r\n new_array.append(a[i])\r\n\r\n# Output\r\nprint(k)\r\nprint(*new_array)\r\n", "#import sys\r\n#sys.stdin = open('in', 'r')\r\nn = int(input())\r\np = [int(x) for x in input().split()]\r\n#n,m = map(int, input().split())\r\n\r\ndef gcd(a,b):\r\n if a < b:\r\n return gcd(b, a)\r\n else:\r\n if b == 0:\r\n return a\r\n else:\r\n return gcd(b, a % b)\r\n\r\nr = []\r\nr.append(p[0])\r\nfor i in range(1, n):\r\n if gcd(p[i], p[i-1]) > 1:\r\n r.append(1)\r\n r.append(p[i])\r\n \r\nprint(len(r) - len(p))\r\nprint(str.join(' ', map(str, r)))\r\n", "# @author Nayara Souza\n# UFCG - Universidade Federal de Campina Grande\n# AA - Basico\n\nfrom math import gcd\n\nn = int(input())\nx = list(map(int, input().split()))\n\ns = ''\ncount = 0\n\nfor i in range(n-1):\n s += str(x[i]) + ' '\n if gcd(x[i],x[i+1]) != 1:\n count += 1\n s += '1 '\n\ns += str(x[-1])\n\nprint(count)\nprint(s.rstrip())\n\t\t \t\t\t \t\t \t\t \t\t\t\t \t\t\t \t\t\t\t \t\t", "import math\r\nn=int(input())\r\nls=list(map(int,input().split()))\r\nlz=[]\r\ncnt=0\r\nfor i in range(0,n-1):\r\n if math.gcd(ls[i],ls[i+1])!=1:\r\n lz.append(i)\r\n cnt+=1\r\nprint(cnt)\r\nfor i in range(n):\r\n print(ls[i],end=\" \")\r\n if i in lz:\r\n print(1,end=\" \")\r\n", "def GCD(a, b):\n\tif a == 0:\n\t\treturn b\n\treturn GCD(b % a, a)\n\nn = int(input())\na = [int(x) for x in input().split()]\n\nresp = []\ncont = 0\n\nresp.append(a[0])\nfor i in range(1, n):\n\t\n\tif GCD(a[i-1], a[i]) != 1:\n\t\tresp.append(1)\t\t\n\t\tcont += 1\n\t\n\tresp.append(a[i])\n\nprint(cont)\nfor e in resp:\n\tprint(e, end=\" \")\n", "import math\r\nn = int(input())\r\na = [int(i) for i in input().split()]\r\nc=0\r\nb=[]\r\nfor i in range(n-1):\r\n x=math.gcd(a[i],a[i+1])\r\n if x==1:\r\n b+=[a[i]]\r\n else:\r\n b+=[a[i],1]\r\n c+=1\r\nb+=[a[-1]]\r\nprint(c)\r\nprint(*b)\r\n\r\n\r\n\r\n", "import math\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nans=[a[0]]\r\nfor i in range(1,n):\r\n if math.gcd(a[i-1],a[i])!=1:\r\n ans.append(1)\r\n ans.append(a[i])\r\nprint(len(ans)-n)\r\nprint(*ans)", "n = int(input())\nA = list(map(int, input().split()))\n\nimport math\n\ndef sieve(n):\n ass = []\n is_prime = [True]*(n+1)\n is_prime[0] = False\n is_prime[1] = False\n\n for i in range(2, int(math.sqrt(n))+1):\n if not is_prime[i]:\n continue\n for j in range(i*2, n+1, i):\n is_prime[j] = False\n for i in range(n+1):\n if is_prime[i]:\n ass.append(i)\n return(ass)\n\nS = sieve(1000)\n\nk = 0\nans = []\nimport math\nfor i in range(n-1):\n if math.gcd(A[i], A[i+1]) != 1:\n for j in S:\n if math.gcd(A[i], j) == 1 and math.gcd(A[i+1], j) == 1:\n ans.append(A[i])\n ans.append(j)\n k += 1\n break\n else:\n ans.append(A[i])\nelse:\n ans.append(A[n-1])\nprint(k)\nprint(*ans)\n", "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef make_co_prime_array(n, arr):\n k = 0\n new_arr = [arr[0]]\n \n for i in range(1, n):\n if gcd(new_arr[-1], arr[i]) == 1:\n new_arr.append(arr[i])\n else:\n k += 1\n new_arr.append(1)\n new_arr.append(arr[i])\n\n return k, new_arr\n\nn = int(input())\narr = list(map(int, input().split()))\n\nk, new_arr = make_co_prime_array(n, arr)\n\nprint(k)\nprint(\" \".join(map(str, new_arr)))\n\n\t \t \t\t \t\t \t \t \t\t\t \t\t\t", "n = int(input())\nnumbers = [int(s) for s in input().split()]\n\ndef GCD(x, y):\n while x and y:\n x, y = (x % y, y) if x > y else (x, y % x)\n return x + y\n\nresult = str(numbers[0])\ncounter = 0\n\nfor i in range(1, n):\n if GCD(numbers[i], numbers[i-1]) != 1:\n counter += 1\n result += ' 1 ' + str(numbers[i])\n else:\n result += ' ' + str(numbers[i])\n\nprint(counter)\nprint(result)\n\t \t\t \t \t \t \t\t\t \t \t \t \t", "import sys\r\nimport math\r\nimport collections\r\nfrom pprint import pprint as pp\r\nmod = 998244353\r\nMAX = 10**15\r\n\r\n\r\ndef inp():\r\n return map(int, input().split())\r\n\r\n\r\ndef array():\r\n return list(map(int, input().split()))\r\n\r\n\r\ndef vector(size, val=0):\r\n vec = [val for i in range(size)]\r\n return vec\r\n\r\n\r\ndef matrix(rowNum, colNum, val=0):\r\n mat = []\r\n for i in range(rowNum):\r\n collumn = [val for j in range(colNum)]\r\n mat.append(collumn)\r\n return mat\r\n\r\n\r\nn = int(input())\r\na = array()\r\nk = 0\r\nans = []\r\nfor i in range(n - 1):\r\n ans.append(a[i])\r\n if math.gcd(a[i], a[i + 1]) != 1:\r\n ans.append(1)\r\n k += 1\r\nans.append(a[-1])\r\nprint(k)\r\nfor i in ans:\r\n print(i,end=' ')\r\n", "from math import *\r\na=int(input())\r\nb=[];s=0\r\nfor i in map(int,input().split()):b+=[i]+[0]\r\nfor i in range(0,2*a-2,2):\r\n if gcd(b[i],b[i+2])!=1:b[i+1]=1000003;s+=1\r\nprint(s)\r\nfor i in b:\r\n if i:print(i,end=\" \")", "def gcd(a,b): #Função do GeeksForGeeks fornecido na atividade\n if (b == 0):\n return a\n return gcd(b, a%b)\n\nn = int(input())\nCParray = list(map(int,input().strip().split()))[:n]\n\nresp = \"\"\ncount = 0\nfor i in range(n-1):\n resp += str(CParray[i]) + \" \"\n if gcd(CParray[i],CParray[i+1]) != 1:\n resp += \"1 \"\n count += 1\n\nresp += str(CParray[n-1])\n\nprint(count)\nprint(resp)\n\t \t\t\t \t \t \t\t\t\t \t\t\t \t", "import fractions\n\nn = int(input())\na = list(map(int, input().split()))\n\ncnt = 0\nans = a[:1]\nfor i in range(1, len(a)):\n if 1 < fractions.gcd(ans[-1], a[i]):\n for j in range(2, 1000):\n if fractions.gcd(ans[-1], j) == fractions.gcd(a[i], j) == 1:\n cnt += 1\n ans.append(j)\n break\n\n ans.append(a[i])\n\nprint(cnt)\nprint(' '.join(map(str, ans)))\n", "import sys\nsys.stderr = sys.stdout\n\nfrom math import gcd\n\ndef coprime(n, A):\n B = []\n a0 = 1\n k = 0\n for a in A:\n if gcd(a0, a) > 1:\n B.append(1)\n k += 1\n B.append(a)\n a0 = a\n return k, B\n\n\ndef main():\n n = readint()\n A = readintl()\n k, B = coprime(n, A)\n print(k)\n print(' '.join(map(str, B)))\n\n##########\n\ndef readint():\n return int(input())\n\n\ndef readinti():\n return map(int, input().split())\n\n\ndef readintt():\n return tuple(readinti())\n\n\ndef readintl():\n return list(readinti())\n\n\ndef readinttl(k):\n return [readintt() for _ in range(k)]\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\nif __name__ == '__main__':\n main()\n", "# all number 1~1e9\n\ndef gcd(a,b):\n while b != 0:\n t = b\n b = a % b\n a = t\n return a\n\ndef coprime(a,b):\n if gcd(a,b) == 1:\n return True\n else:\n return False\n\ndef isPrime(n):\n if (n <= 1): return False\n if (n <= 3): 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): 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 return True\n\n# find a number coprime with both inputs\ndef find_coprime(a,b,primelist):\n for p in primelist:\n if (coprime(p,a) and coprime(p,b)):\n return p\n\n n = len(primelist)\n p = primelist[n-1]+2 # last prime is odd\n while True:\n if not isPrime(p):\n p += 2\n primelist.append(p)\n if (coprime(p, a) and coprime(p, b)):\n return p\n p += 2\n return p\n\ndef coprime_array(a,b,primelist):\n n = len(a)\n k = 0\n if n == 1:\n b.append(a[0])\n return k\n\n for i in range(n):\n if i == n - 1:\n b.append(a[i])\n break\n\n b.append(a[i])\n if not coprime(a[i], a[i + 1]):\n b.append(find_coprime(a[i], a[i + 1], primelist))\n k += 1\n return k\n\n\n\nn = int(input())\na = [int(x) for x in input().split()]\nprimelist = [2,3,5,7]\nb = []\nk = coprime_array(a,b,primelist)\n\nprint(k)\nprint(*b, sep=' ')\n\n\n\n\n\n\n", "from math import gcd\r\nn = int(input()) \r\na = [int(i) for i in input().split()] \r\nans = 0\r\nres = []\r\nfor i in range(n-1): \r\n res.append(a[i])\r\n if gcd(a[i], a[i+1]) != 1 : ans +=1; res.append(1)\r\nres.append(a[-1])\r\nprint(ans) \r\nfor i in res : print(i, end = ' ')", "import math\nn=int(input())\na=list(map(int,input().split()))\nAns=0\nfor i in range(n-1):\n if math.gcd(a[i],a[i+1])!=1:\n Ans+=1\nprint(Ans)\nfor i in range(n-1):\n print(a[i],end=' ')\n if math.gcd(a[i],a[i+1])!=1:\n print(1,end=' ')\nprint(a[n-1])\n\n \t \t\t\t\t \t\t \t\t \t \t \t \t\t", "import math\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nnew_arr = []\r\ncount = 0\r\nfor i in range(n-1):\r\n new_arr.append(a[i])\r\n if math.gcd(a[i], a[i+1]) != 1:\r\n new_arr.append(1)\r\n count += 1\r\nnew_arr.append(a[-1])\r\n\r\nprint(count)\r\nprint(*new_arr)\r\n\r\n", "import math\n\ndef sieve(n):\n primes, is_prime = [2], [True] * (n >> 1)\n for i in range(3, n, 2):\n cover = i * i\n if cover > n:\n for j in range(i, n, 2):\n if is_prime[j >> 1]:\n primes.append(j)\n break\n elif is_prime[i >> 1]:\n primes.append(i)\n jump = i << 1\n for j in range(cover, n, jump):\n is_prime[j >> 1] = False\n return primes\n\nn = int(input().rstrip())\na = list(map(int, input().rstrip().split()))\nprimes = sieve(100000)\nres = [a[0]]\ncnt = 0\nfor i in range(1, len(a)):\n if math.gcd(a[i-1], a[i]) != 1:\n for prime in primes:\n if a[i-1] % prime != 0 and a[i] % prime != 0:\n res.append(prime)\n cnt += 1\n break\n res.append(a[i])\n\nprint(cnt)\nprint(' '.join(map(str, res)))\n\n\t \t \t \t\t\t \t \t \t \t \t", "import math\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nb=[]\r\nfor i in range(0,n-1):\r\n b+=[a[i]]\r\n if math.gcd(a[i],a[i+1])-1:\r\n b+=[1]\r\nb+=[a[-1]]\r\nprint(len(b)-n)\r\nfor i in b:\r\n print(i,end=' ')", "import math\n\nqtd = int(input())\nentrada = list(map(int, input().split()))\n\nsaida = []\nfor i in range(qtd):\n if i > 0 and math.gcd(entrada[i], saida[-1]) != 1:\n saida.append(1)\n saida.append(entrada[i])\n\nprint(len(saida) - qtd)\nprint(*saida)\n\t\t \t\t \t \t\t\t\t\t \t\t\t\t \t \t \t", "n = int(input())\na = list(map(int, input().split()))\n \ndef gcd(x, y):\n if x < y:\n x, y = y, x\n if y == 0:\n return x\n return gcd(y, x%y)\n \nres = []\ncnt = 0\nfor i in range(1, len(a)):\n x = a[i-1]\n y = a[i]\n g = gcd(x, y)\n res.append(x)\n if g != 1:\n res.append(1)\n cnt += 1\nres.append(a[len(a)-1])\n \nprint(cnt)\nprint(\" \".join(map(str, res)))\n\t\t\t \t\t \t \t \t \t\t \t \t\t \t\t\t \t", "from fractions import gcd\nn = int(input())\na = list(map(int, input().split()))\nans = []\nfor i in range(n):\n ans.append(a[i])\n if i + 1 < n and gcd(a[i], a[i + 1]) > 1:\n ans.append(1)\nprint(len(ans) - n)\nfor i in range(len(ans)):\n print(ans[i], end=' ')", "def gcd(a,b):\n if (b == 0):\n return a\n return gcd(b, a%b)\n\nn=int(input())\na=list(map(int, input().split(' ')))\nc=0\nfor i in range(n-1,0,-1):\n if(a[i] != 1 and a[i-1] != 1 and (gcd(a[i], a[i-1])!=1)):\n a.insert(i,1)\n c+=1 \nprint(c)\nfor j in a:\n print(j,end=' ')\n\n\t \t\t \t \t \t\t \t \t \t\t", "def g_common_div(a, b):\n if b == 0:\n return a\n else:\n return g_common_div(b, a % b)\n \nif __name__ == \"__main__\":\n n = int(input())\n a = input().split(\" \")\n b = []\n\n c = 0\n j = 0\n \n for i in range(n):\n if i != 0 and g_common_div(int(a[i]), int(a[i-1])) != 1:\n b.append(None)\n b.append(1)\n c += 1\n b.append(None)\n b.append(int(a[i]))\n \n print(c)\n b = [k for k in b if k]\n print(*b, sep=\" \")\n\t\t\t\t \t\t \t\t\t\t \t \t \t\t \t\t\t \t \t", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Jul 1 11:09:09 2020\n\n@author: shailesh\n\"\"\"\n\nimport math\n\nn = int(input())\na = [int(i) for i in input().split()]\n\ncount = 0\nind = n-1\nwhile ind > 0:\n if math.gcd(a[ind],a[ind-1]) != 1:\n count +=1\n a.insert(ind,1)\n ind -=1\n\nprint(count)\n\nprint(' '.join([str(i) for i in a]))", "import math\r\nn = int(input())\r\narr = [int(x) for x in input().split()]\r\nk = 0\r\ni = 0\r\nwhile(i <n+k-1):\r\n if math.gcd(arr[i], arr[i+1]) != 1:\r\n arr.insert(i+1, 1)\r\n i += 2\r\n k += 1\r\n else:\r\n i += 1 \r\nprint(k)\r\nprint(*arr) \r\n", "from math import *\r\na=int(input())\r\nb=[];s=0\r\nfor i in map(int,input().split()):b+=[i]+[0]\r\nfor i in range(0,2*a-2,2):\r\n if gcd(b[i],b[i+2])!=1:b[i+1]=1000003;s+=1\r\nprint(s)\r\nk=[]\r\nfor i in b:\r\n if i:k+=[i]\r\nprint(*k)", "#the trick is that \"1\" is coprime of any number, so all that is left\n# to do is check if the adjacent elements have another common divisor\n# besides \"1\", and if not, add it to the answer.\nimport math\n\nn = int(input())\na = list(map(int, input().split()))\ncoprimes_array = []\ncount = 0\nfor i in range(n-1):\n coprimes_array.append(a[i])\n if math.gcd(a[i], a[i+1]) > 1:\n coprimes_array.append(1)\n count += 1\ncoprimes_array.append(a[n-1])\n\nprint(count)\nprint(*coprimes_array)\n\t\t \t \t\t \t \t\t\t\t\t\t \t\t \t", "from math import gcd\r\n\r\nn = int(input())\r\nlst = list(map(int, input().split()))\r\nres = [lst[0]]\r\nfor m in lst[1:]:\r\n if gcd(m, res[-1]) > 1:\r\n res.append(1)\r\n res.append(m)\r\nprint(len(res) - n)\r\nprint(\" \".join(str(i) for i in res))", "def gcd(a,b):\r\n while b:\r\n a,b = b,a%b\r\n return a\r\n\r\nn = int(input())\r\na = list(map(int,input().split()))\r\nk = [i for i in range(n-1) if gcd(a[i],a[i+1]) > 1]\r\nfor i,x in enumerate(k):\r\n a.insert(x+i+1, 1)\r\nprint(len(k))\r\nprint(*a)", "import math\n\nn = int(input())\na = list(map(int, input().split()))\n\ncount = 0\nans = []\n\nfor i in range(n-1):\n ans.append(a[i])\n if math.gcd(a[i], a[i+1]) != 1:\n count += 1\n ans.append(1)\n\nans.append(a[-1])\n\nprint(count)\nprint(*ans)\n", "from math import gcd\r\nn = int(input())\r\ns = [int(i) for i in input().split()]+[1]\r\nd = []\r\n\r\nfor i in range(n):\r\n\td.append(s[i])\r\n\tif gcd(s[i],s[i+1])!=1:\r\n\t\td.append(1)\r\nprint(len(d)-len(s)+1)\r\nprint(*d)\r\n\r\n", "def mdc(a, b):\r\n if b == 0:\r\n return a\r\n else:\r\n return mdc(b, a % b)\r\n\r\nn = int(input())\r\nlista = list(map(int, input().split()))\r\n\r\nnova_lista = [lista[0]]\r\nfor i in range(1, n):\r\n gcd = mdc(nova_lista[-1], lista[i])\r\n if gcd != 1:\r\n for j in range(max(nova_lista[-1], lista[i-1])+1, lista[i]):\r\n if mdc(nova_lista[-1], j) == 1 and mdc(lista[i], j) == 1:\r\n nova_lista.append(j)\r\n break\r\n else:\r\n nova_lista.append(1)\r\n nova_lista.append(lista[i])\r\n\r\ncusto = len(nova_lista) - n\r\nprint(custo)\r\nprint(*nova_lista)\r\n", "from math import gcd\n\nn = int(input())\na = [int(i) for i in input().split()]\nans = [a[0]]\n\nfor i in range(n-1):\n if gcd(a[i], a[i+1]) != 1:\n ans.append(1)\n ans.append(a[i+1])\n\nprint(len(ans) - len(a))\nprint(*ans)", "from math import gcd\r\n\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\narr_r = arr[:1]\r\nfor i in range(1, n):\r\n if gcd(arr[i], arr[i - 1]) != 1:\r\n arr_r.append(1)\r\n arr_r.append(arr[i])\r\nprint(len(arr_r) - n)\r\nprint(*arr_r)\r\n", "def nod(a, b):\r\n if b == 0:\r\n return a\r\n return nod(b, a % b)\r\n\r\n\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\narr_r = arr[:1]\r\nfor i in range(1, n):\r\n if nod(arr[i - 1], arr[i]) != 1:\r\n arr_r.append(1)\r\n arr_r.append(arr[i])\r\nprint(len(arr_r) - n)\r\nprint(*arr_r)\r\n", "def gcd(a, b):\r\n if b == 0:\r\n return a\r\n return gcd(b, a % b)\r\n\r\n\r\ninput()\r\nvalores = list(map(int, input().split(\" \")))\r\nadicionados = 0\r\nresultado = []\r\n\r\nfor i in range(len(valores) - 1):\r\n mdc = gcd(valores[i], valores[i + 1])\r\n resultado.append(valores[i])\r\n if mdc != 1:\r\n resultado.append(1)\r\n adicionados += 1\r\n\r\nresultado.append(valores[-1])\r\nprint(adicionados)\r\nprint(*resultado)\r\n", "\r\nfrom math import *\r\n\r\nn=int(input())\r\na=list(map(int,input().split(\" \")))\r\n\r\nl=[]\r\nl.append(a[0])\r\n\r\nfor i in range(1,n):\r\n\tif(gcd(a[i],a[i-1])!=1):\r\n\t\tl.append(1)\r\n\r\n\tl.append(a[i])\r\n\r\nprint(len(l)-n)\r\nprint(*l)\r\n", "import math\n\nnum_de_elementos = int(input())\nelementos = list(map(int,input().split())) + [1]\n\naux = []\ncont = 0\nfor i in range(num_de_elementos):\n aux.append(elementos[i])\n if(math.gcd(elementos[i], elementos[i+1]) != 1):\n aux.append(1)\n cont += 1\n\nco_primos = ''\nfor i in aux:\n co_primos += str(i) + ' '\n\nprint(cont)\nprint(co_primos)\n\t\t \t\t \t \t \t \t\t \t\t\t \t \t\t \t", "def mcd(a,b):\r\n while b!=0:\r\n a,b=b,a%b\r\n return a\r\n\r\nn=int(input())\r\narr = [int(x) for x in input().split()]\r\n\r\nt=0\r\no=[]\r\nfor i in range(len(arr)-1):\r\n o.append(arr[i])\r\n if mcd(arr[i],arr[i+1])!=1:\r\n t+=1\r\n o.append(1)\r\no.append(arr[-1])\r\nprint(t)\r\nprint(\" \".join([str(x) for x in o]))\r\n \r\n", "from math import gcd\r\n\r\nn, a = int(input()), [*map(int, input().split())]\r\nb = []\r\nb.append(a[0])\r\ncnt = 0\r\nfor i in range(1, n):\r\n if gcd(a[i - 1], a[i]) != 1:\r\n b.append(1)\r\n cnt += 1\r\n b.append(a[i])\r\n\r\nprint(cnt)\r\nprint(*b)\r\n", "def prime(n):\r\n if(n==1):\r\n return False \r\n else:\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\n\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\n\r\nn = int(input())\r\n#n,m = map(int,input().split())\r\nl = list(map(int,input().split()))\r\ns = [l[0]]\r\nc =0 \r\nfor i in range(1,n):\r\n if(gcd(s[-1],l[i])>1):\r\n s.append(1)\r\n s.append(l[i])\r\n c =c +1 \r\n else:\r\n s.append(l[i])\r\nprint(c)\r\nprint(*s)", "import math\r\nfrom fractions import gcd\r\nn = int(input())\r\na = list(map(int, input().split()))\r\ncnt = 0\r\nans = []\r\nfor i in range(n-1):\r\n\tans.append(a[i])\r\n\tif gcd(a[i],a[i+1]) > 1:\r\n\t\tans.append(1)\r\n\t\tcnt += 1\r\nans.append(a[-1])\r\nprint (cnt)\r\nprint (*ans)", "def gcd(a, b):\r\n\tif a > b: a, b = b, a\r\n\tc = b%a\r\n\twhile c != 0:\r\n\t\ta, b = c, a\r\n\t\tc = b%a\r\n\treturn a\r\n\r\nn = int(input())\r\nnum = list(map(int, input().split()))\r\n\r\nl = n-1; cnt = 0\r\nnewNum = []\r\nfor i in range(l):\r\n\tnewNum.append(num[i])\r\n\tif gcd(num[i], num[i+1]) != 1:\r\n\t\tnewNum.append(1)\r\n\t\tcnt += 1\r\nnewNum.append(num[n-1])\r\nprint(cnt)\r\nfor num in newNum: print(num, end = ' ')", "import math\n\nn = int(input())\nentrada = list(map(int, input().split()))\n\ncont = 0\nsaida = [entrada[0]]\n\nfor i in range(1, n):\n if math.gcd(entrada[i], saida[-1]) != 1:\n cont += 1\n saida.append(1)\n saida.append(entrada[i])\n\nprint(cont)\nprint(*saida)\n\n\t \t \t\t \t\t\t\t\t\t\t \t\t \t\t \t", "from math import gcd\n\ntam = int(input())\nseq = [int(n) for n in input().split()]\n\ncorreta = [seq[0]]\ni = 1\nwhile i < len(seq):\n mdc = gcd(seq[i], correta[-1])\n if mdc == 1:\n correta.append(seq[i])\n i += 1\n else:\n correta.append(1)\n\ncorreta = [str(n) for n in correta]\nprint(len(correta) - tam)\nprint(' '.join(correta)) \n\n \t\t\t\t \t\t \t\t\t \t \t \t \t", "from math import gcd\nn = int(input())\nA = list(map(int, input().split()))\nans = [A[0]]\ni = 1\nwhile i < n:\n if gcd(ans[-1], A[i]) == 1:\n ans.append(A[i])\n i += 1\n else:\n ans.append(1)\nprint(len(ans) - n)\nprint(*ans)", "import math\n\nn = int(input())\nnums = list(map(int, input().split()))\n\ncont = 0\nans = [nums[0]]\nif n > 1:\n for i in range(1, n):\n if math.gcd(nums[i], nums[i-1]) != 1:\n ans.append(1)\n cont+=1\n ans.append(nums[i])\nout = ''\nfor j in range(len(ans)):\n if j ==0:\n out += str(ans[j])\n else:\n out += ' ' + str(ans[j])\nprint(cont)\nprint(out)\n \t\t\t \t\t\t\t\t\t \t\t\t\t\t \t\t\t", "def gcd(a,b):\n while a%b !=0:\n aux = b\n b = a%b\n a = aux\n return b\n\nlenEntrada = int(input())\nentrada = list(map(int, input().split()))\ni = 0\nk = 0\nwhile i+1 < len(entrada):\n i += 1\n # print(entrada[i-1], entrada[i])\n if gcd(entrada[i-1],entrada[i]) == 1:continue\n k += 1\n entrada.insert(i,1)\nprint(k)\nprint(*entrada,sep=' ')\n\t \t\t\t\t\t\t \t\t \t \t\t \t\t\t \t \t", "import math\r\nn=int(input())\r\nar=list(map(int,input().split()))\r\na=[]\r\nc=0\r\nfor i in range(len(ar)-1):\r\n a+=[ar[i]]\r\n if math.gcd(ar[i],ar[i+1]) > 1:\r\n a+=[1]\r\n c+=1\r\na+=[ar[-1]]\r\nprint (c)\r\nprint(*a)", "import math\r\nL=lambda:list(map(int,input().split()))\r\nM=lambda:map(int,input().split())\r\nI=lambda:int(input())\r\nn=I()\r\na=L()\r\nb=[]\r\nx=0\r\nfor i in range(n-1):\r\n b.append(a[i])\r\n if math.gcd(a[i],a[i+1])>1:\r\n b.append(1)\r\n x+=1\r\nb.append(a[-1])\r\nprint(x)\r\nprint(*b)", "def MCD(a, b):\n while b!=0:\n a, b = b, a % b\n return a\ndef SonCoprimos(a, b):\n mcd = MCD(a, b)\n if mcd==1:\n return True\n else:\n return False\nresult=[]\nagg=0\nn=int(input())\narr=[int(x) for x in input().split(' ')]\nfor i in range(n-1):\n result.append(arr[i])\n if(not SonCoprimos(arr[i],arr[i+1])):\n result.append(1)\n agg+=1\nresult.append(arr[n-1])\nprint(agg)\ncadena = ' '.join(map(str, result))\nprint(cadena)\n \t\t\n\t\t \t \t \t \t\t \t\t \t \t \t \t \t", "from math import *\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\nc=0\r\nd=[]\r\nfor i in range(n-1):\r\n if(gcd(l[i],l[i+1])!=1):\r\n d.append(l[i])\r\n d.append(1)\r\n c+=1\r\n else:\r\n d.append(l[i])\r\nd.append(l[-1])\r\nprint(c)\r\nprint(*d)\r\n", "import math\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\ns = set()\r\nfor i in range(n - 1):\r\n if math.gcd(a[i], a[i + 1]) ^ 1:\r\n s.add(i)\r\nk = len(s)\r\nans = []\r\nfor i in range(n):\r\n ans.append(a[i])\r\n if i in s:\r\n ans.append(1)\r\nprint(k)\r\nprint(*ans)", "def gcd(a, b):\n if (b == 0):\n return a\n return gcd(b, a%b)\n\nn = int(input().strip())\narr = list(map(int, input().strip().split()))\ni, count = 0, 0\nfor i in range(n-1):\n if gcd(arr[i], arr[i+1]) != 1:\n count += 1\nprint(count)\nprint(arr[0], end=\" \")\nfor i in range(1, n):\n if gcd(arr[i], arr[i-1]) != 1:\n print(1, end=\" \")\n print(arr[i], end=\" \")\n \t \t\t \t\t\t\t\t\t \t\t \t\t \t \t", "from collections import deque, defaultdict, Counter\r\nfrom itertools import product, groupby, permutations, combinations\r\nfrom math import gcd, floor, inf, log2, sqrt, log10\r\nfrom bisect import bisect_right, bisect_left\r\nfrom statistics import mode\r\nfrom string import ascii_uppercase\r\nlists = {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}\r\nnum = int(input())\r\narr = list(map(int, input().split()))\r\ncnt = 0\r\nans = [arr[0]]\r\nfor i in range(1, num):\r\n if gcd(arr[i-1], arr[i]) != 1:\r\n cnt += 1\r\n for d in lists:\r\n if gcd(arr[i-1], d) == 1 and gcd(arr[i], d) == 1:\r\n dif = d\r\n break\r\n ans.append(dif)\r\n ans.append(arr[i])\r\nprint(cnt)\r\nprint(*ans)\r\n\r\n\r\n\r\n\r\n\r\n", "from math import gcd\n\nn = int(input())\n\narr = [int(num) for num in input().split(' ')]\n\ni, j = 0, 1\nwhile j < len(arr):\n\n if gcd(arr[i], arr[i+1]) != 1:\n arr.insert(i+1, 1)\n\n i += 1\n j += 1\n\nprint(len(arr) - n)\nprint(*arr)\n\t \t \t \t\t \t\t \t\t \t\t\t\t", "from math import gcd\r\n\r\nPRIME_NUMBER = (982451653, 982451707)\r\ndef func():\r\n lst = [a[0], ]\r\n for i in range(1, n):\r\n if gcd(a[i], a[i-1]) != 1:\r\n if PRIME_NUMBER[0] != a[i] and PRIME_NUMBER[0] != a[i-1]:\r\n lst.append(PRIME_NUMBER[0])\r\n else:\r\n lst.append(PRIME_NUMBER[1])\r\n lst.append(a[i])\r\n\r\n print(len(lst) - len(a))\r\n print(*lst)\r\n\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nfunc()\r\n", "def mdc(a,b):\n if a == 0:\n return b\n return mdc(b%a, a)\n\nn = int(input())\na = list(map(int, input().split()))\n\nres = []\n\nfor i in range(0, n-1):\n x, y = a[i], a[i+1]\n res.append(x)\n if mdc(x,y) != 1:\n res.append(1)\nres.append(a[n-1])\n\nprint(len(res)-len(a))\nfor i in res:\n print(i, end=\" \")\nprint()\n \t \t \t\t\t\t \t \t \t\t\t\t \t", "from math import sqrt\r\n\r\ndef co_prime(v1,v2) :\r\n t=v1%v2\r\n if t==0 :\r\n return v2==1,v2\r\n while True :\r\n v1,v2=v2,t\r\n if v1%v2 :\r\n t=v1%v2\r\n else :\r\n ans=v2\r\n break\r\n return ans==1,ans\r\n\r\nn=int(input())\r\na= list(map(int, input().split()))\r\naux=[0]*n\r\nres=[]\r\nk=0\r\nfor i in range(n-1) :\r\n temp=co_prime(a[i],a[i+1])\r\n if temp[0] : continue\r\n else :\r\n T=int(sqrt(temp[1]))\r\n while True:\r\n if co_prime(a[i],T)[0] and co_prime(T,a[i+1])[0] :\r\n break\r\n T+=1\r\n aux[i]=T\r\n k+=1\r\nfor i in range(n):\r\n res.append(a[i])\r\n if aux[i]:\r\n res.append(aux[i])\r\n\r\nprint(k)\r\nprint(' '.join(map(str,res)))", "\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n\n\nn = int(input())\n\nA = [int(x) for x in input().split()]\n\nB = [A[0]]\n\nfor i in range(1, len(A)):\n if gcd(B[-1], A[i]) == 1:\n B += [A[i]]\n else:\n B += [1, A[i]]\n\nprint(len(B) - len(A))\nprint(' '.join(map(str, B)))\n", "from fractions import gcd\na=int(input())\nb=list(map(int,input().split()))\ncount=0\ni=0\nwhile i<a-1:\n if gcd(b[i],b[i+1])!=1:\n count+=1\n b.insert(i+1,1)\n i+=1\n a+=1\n i+=1\nprint(count)\nprint(' '.join(map(str,b)))\n \t \t\t\t\t \t \t\t \t \t\t \t\t \t\t", "from math import gcd\r\nt=int(input())\r\na=list(map(int,input().split()))\r\nadd={}\r\nreq=0\r\nfor i in range(len(a)-1):\r\n if gcd(a[i],a[i+1])!=1:\r\n add[i+1]=1\r\n req+=1\r\n else:\r\n continue\r\nans=[]\r\nfor i in range(len(a)):\r\n ans.append(a[i])\r\n if i+1 in add:\r\n ans.append(add[i+1])\r\nprint(req)\r\nprint(*ans,sep=\" \")\r\n", "import math\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nl = [a[0]]\r\nfor i in range(1,n):\r\n if math.gcd(a[i], a[i-1]) != 1:\r\n l.append(1)\r\n l.append(a[i])\r\nprint(len(l)-n)\r\nprint(*l)", "from math import gcd\r\ni = int(input())\r\nl = list(map(int,input().split()))\r\nn = []\r\np = 1; ans = 0\r\nfor x in l:\r\n if gcd(p,x)==1: n.append(x)\r\n else: ans+=1;n.append(1);n.append(x)\r\n p = x\r\nprint(ans)\r\nprint(*n)", "import math\r\nn= int(input())\r\na= list(map(int,input().split()))\r\nl=[]\r\nl.append(a[0])\r\nfor i in range(1,n):\r\n if math.gcd(a[i],a[i-1])==1:\r\n l.append(a[i])\r\n else:\r\n l.append(1)\r\n l.append(a[i])\r\nprint(len(l)-len(a))\r\nprint(*l)", "'https://codeforces.com/contest/660/problem/A'\r\ndef computeGCD(x, y):\r\n\twhile(y):\r\n\t\tx,y=y,x%y\r\n\treturn abs(x)\r\n\r\nn=int(input())\r\nans=0\r\nnum1=[]\r\nnum=list(map(int,input().split()))\r\nfor i in range(1,n):\r\n\tif(computeGCD(num[i-1],num[i])==1):\r\n\t\tnum1.append(num[i-1])\r\n\telse:\r\n\t\tnum1.append(num[i-1])\r\n\t\tnum1.append(1)\r\n\t\tans+=1\r\nnum1.append(num[n-1])\r\nprint(ans)\r\nprint(*num1)", "import math\r\nn = int(input())\r\narr = [int(x) for x in input().split()]\r\n\r\nout = []\r\nk = 0\r\nout.append(arr[0])\r\nfor i in range(1, n):\r\n if math.gcd(out[-1], arr[i]) == 1:\r\n out.append(arr[i])\r\n continue\r\n k += 1\r\n out.append(1)\r\n out.append(arr[i])\r\nprint(k)\r\nprint(\" \".join([str(x) for x in out]))", "from math import gcd\r\n\r\ndef SieveOfEratosthenes(n): \r\n arr = []\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 * 2, n + 1, p): \r\n prime[i] = False\r\n p += 1\r\n prime[0]= False\r\n prime[1]= False\r\n for p in range(n + 1): \r\n if prime[p]: \r\n arr.append(p)\r\n return arr\r\n\r\nn = int(input())\r\narr = list(map(int,input().split()))\r\nprime = SieveOfEratosthenes(10**5)\r\nans = []\r\ncount = 0\r\nfor i in range(n-1):\r\n temp = gcd(arr[i],arr[i+1])\r\n if temp == 1:\r\n ans.append(arr[i])\r\n else:\r\n ans.append(arr[i])\r\n count += 1\r\n for p in prime:\r\n if arr[i]%p != 0 and arr[i+1]%p != 0:\r\n ans.append(p)\r\n break\r\nans.append(arr[-1]) \r\nprint(count)\r\nfor i in ans:\r\n print(i,end=' ')\r\nprint()\r\n \r\n \r\n ", "from math import gcd\r\n\r\ninput()\r\nnums = list(map(int, input().split()))\r\nk = 0\r\ni = 1\r\nwhile i < len(nums):\r\n if gcd(nums[i - 1], nums[i]) != 1:\r\n k += 1\r\n nums.insert(i, 1)\r\n i += 1\r\nprint(k, '\\n' + ' '.join(list(map(str, nums))))\r\n" ]
{"inputs": ["3\n2 7 28", "1\n1", "1\n548", "1\n963837006", "10\n1 1 1 1 1 1 1 1 1 1", "10\n26 723 970 13 422 968 875 329 234 983", "10\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396", "100\n1 1 1 1 2 1 1 1 1 1 2 2 1 1 2 1 2 1 1 1 2 1 1 2 1 2 1 1 2 2 2 1 1 2 1 1 1 2 2 2 1 1 1 2 1 2 2 1 2 1 1 2 2 1 2 1 2 1 2 2 1 1 1 2 1 1 2 1 2 1 2 2 2 1 2 1 2 2 2 1 2 2 1 1 1 1 2 2 2 2 2 2 2 1 1 1 2 1 2 1", "100\n591 417 888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983 526 103 500 963 400 23 276 704 570 757 410 658 507 620 984 244 486 454 802 411 985 303 635 283 96 597 855 775 139 839 839 61 219 986 776 72 729 69 20 917", "5\n472882027 472882027 472882027 472882027 472882027", "2\n1000000000 1000000000", "2\n8 6", "3\n100000000 1000000000 1000000000", "5\n1 2 3 4 5", "20\n2 1000000000 2 1000000000 2 1000000000 2 1000000000 2 1000000000 2 1000000000 2 1000000000 2 1000000000 2 1000000000 2 1000000000", "2\n223092870 23", "2\n100000003 100000003", "2\n999999937 999999937", "4\n999 999999937 999999937 999", "2\n999999929 999999929", "2\n1049459 2098918", "2\n352229 704458", "2\n7293 4011", "2\n5565651 3999930", "2\n997 997", "3\n9994223 9994223 9994223", "2\n99999998 1000000000", "3\n1000000000 1000000000 1000000000", "2\n130471 130471", "3\n1000000000 2 2", "2\n223092870 66526", "14\n1000000000 1000000000 223092870 223092870 6 105 2 2 510510 510510 999999491 999999491 436077930 570018449", "2\n3996017 3996017", "2\n999983 999983", "2\n618575685 773990454", "3\n9699690 3 7", "2\n999999999 999999996", "2\n99999910 99999910", "12\n1000000000 1000000000 223092870 223092870 6 105 2 2 510510 510510 999999491 999999491", "3\n999999937 999999937 999999937", "2\n99839 99839", "3\n19999909 19999909 19999909", "4\n1 1000000000 1 1000000000", "2\n64006 64006", "2\n1956955 1956955", "3\n1 1000000000 1000000000", "2\n982451707 982451707", "2\n999999733 999999733", "3\n999999733 999999733 999999733", "2\n3257 3257", "2\n223092870 181598", "3\n959919409 105935 105935", "2\n510510 510510", "3\n223092870 1000000000 1000000000", "14\n1000000000 2 1000000000 3 1000000000 6 1000000000 1000000000 15 1000000000 1000000000 1000000000 100000000 1000", "7\n1 982451653 982451653 1 982451653 982451653 982451653", "2\n100000007 100000007", "3\n999999757 999999757 999999757", "3\n99999989 99999989 99999989", "5\n2 4 982451707 982451707 3", "2\n20000014 20000014", "2\n99999989 99999989", "2\n111546435 111546435", "2\n55288874 33538046", "5\n179424673 179424673 179424673 179424673 179424673", "2\n199999978 199999978", "2\n1000000000 2", "3\n19999897 19999897 19999897", "2\n19999982 19999982", "2\n10000007 10000007", "3\n999999937 999999937 2", "5\n2017 2017 2017 2017 2017", "2\n19999909 39999818", "2\n62615533 7919", "5\n39989 39989 33 31 29", "2\n1000000000 100000", "2\n1938 10010", "2\n199999 199999", "2\n107273 107273", "3\n49999 49999 49999", "2\n1999966 1999958", "2\n86020 300846", "2\n999999997 213", "2\n200000014 200000434"], "outputs": ["1\n2 7 1 28", "0\n1", "0\n548", "0\n963837006", "0\n1 1 1 1 1 1 1 1 1 1", "2\n26 723 970 13 422 1 968 875 1 329 234 983", "7\n319645572 1 758298525 1 812547177 1 459359946 1 355467212 1 304450522 807957797 916787906 1 239781206 1 242840396", "19\n1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 2 1 2 1 1 1 2 1 1 2 1 2 1 1 2 1 2 1 2 1 1 2 1 1 1 2 1 2 1 2 1 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 2 1 1 1 2 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 1 2 1 2 1", "38\n591 1 417 1 888 251 792 1 847 685 3 182 461 102 1 348 1 555 956 771 901 712 1 878 1 580 631 342 1 333 1 285 899 525 1 725 537 718 929 653 84 1 788 1 104 355 624 803 1 253 853 201 995 536 1 184 65 1 205 1 540 1 652 549 1 777 248 405 677 950 431 580 1 600 1 846 1 328 429 134 983 526 103 500 963 400 23 1 276 1 704 1 570 757 410 1 658 507 620 1 984 1 244 1 486 1 454 1 802 411 985 303 635 283 96 1 597 1 855 1 775 139 839 1 839 61 219 986 1 776 1 72 1 729 1 69 20 917", "4\n472882027 1 472882027 1 472882027 1 472882027 1 472882027", "1\n1000000000 1 1000000000", "1\n8 1 6", "2\n100000000 1 1000000000 1 1000000000", "0\n1 2 3 4 5", "19\n2 1 1000000000 1 2 1 1000000000 1 2 1 1000000000 1 2 1 1000000000 1 2 1 1000000000 1 2 1 1000000000 1 2 1 1000000000 1 2 1 1000000000 1 2 1 1000000000 1 2 1 1000000000", "1\n223092870 1 23", "1\n100000003 1 100000003", "1\n999999937 1 999999937", "1\n999 999999937 1 999999937 999", "1\n999999929 1 999999929", "1\n1049459 1 2098918", "1\n352229 1 704458", "1\n7293 1 4011", "1\n5565651 1 3999930", "1\n997 1 997", "2\n9994223 1 9994223 1 9994223", "1\n99999998 1 1000000000", "2\n1000000000 1 1000000000 1 1000000000", "1\n130471 1 130471", "2\n1000000000 1 2 1 2", "1\n223092870 1 66526", "10\n1000000000 1 1000000000 1 223092870 1 223092870 1 6 1 105 2 1 2 1 510510 1 510510 999999491 1 999999491 436077930 1 570018449", "1\n3996017 1 3996017", "1\n999983 1 999983", "1\n618575685 1 773990454", "1\n9699690 1 3 7", "1\n999999999 1 999999996", "1\n99999910 1 99999910", "9\n1000000000 1 1000000000 1 223092870 1 223092870 1 6 1 105 2 1 2 1 510510 1 510510 999999491 1 999999491", "2\n999999937 1 999999937 1 999999937", "1\n99839 1 99839", "2\n19999909 1 19999909 1 19999909", "0\n1 1000000000 1 1000000000", "1\n64006 1 64006", "1\n1956955 1 1956955", "1\n1 1000000000 1 1000000000", "1\n982451707 1 982451707", "1\n999999733 1 999999733", "2\n999999733 1 999999733 1 999999733", "1\n3257 1 3257", "1\n223092870 1 181598", "2\n959919409 1 105935 1 105935", "1\n510510 1 510510", "2\n223092870 1 1000000000 1 1000000000", "11\n1000000000 1 2 1 1000000000 3 1000000000 1 6 1 1000000000 1 1000000000 1 15 1 1000000000 1 1000000000 1 1000000000 1 100000000 1 1000", "3\n1 982451653 1 982451653 1 982451653 1 982451653 1 982451653", "1\n100000007 1 100000007", "2\n999999757 1 999999757 1 999999757", "2\n99999989 1 99999989 1 99999989", "2\n2 1 4 982451707 1 982451707 3", "1\n20000014 1 20000014", "1\n99999989 1 99999989", "1\n111546435 1 111546435", "1\n55288874 1 33538046", "4\n179424673 1 179424673 1 179424673 1 179424673 1 179424673", "1\n199999978 1 199999978", "1\n1000000000 1 2", "2\n19999897 1 19999897 1 19999897", "1\n19999982 1 19999982", "1\n10000007 1 10000007", "1\n999999937 1 999999937 2", "4\n2017 1 2017 1 2017 1 2017 1 2017", "1\n19999909 1 39999818", "1\n62615533 1 7919", "1\n39989 1 39989 33 31 29", "1\n1000000000 1 100000", "1\n1938 1 10010", "1\n199999 1 199999", "1\n107273 1 107273", "2\n49999 1 49999 1 49999", "1\n1999966 1 1999958", "1\n86020 1 300846", "1\n999999997 1 213", "1\n200000014 1 200000434"]}
UNKNOWN
PYTHON3
CODEFORCES
133
e4848ab39b32f977a4fce10003d683ec
Second-Price Auction
In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction *n* bidders place a bid which is price a bidder ready to pay. The auction is closed, that is, each bidder secretly informs the organizer of the auction price he is willing to pay. After that, the auction winner is the participant who offered the highest price. However, he pay not the price he offers, but the highest price among the offers of other participants (hence the name: the second-price auction). Write a program that reads prices offered by bidders and finds the winner and the price he will pay. Consider that all of the offered prices are different. The first line of the input contains *n* (2<=≤<=*n*<=≤<=1000) — number of bidders. The second line contains *n* distinct integer numbers *p*1,<=*p*2,<=... *p**n*, separated by single spaces (1<=≤<=*p**i*<=≤<=10000), where *p**i* stands for the price offered by the *i*-th bidder. The single output line should contain two integers: index of the winner and the price he will pay. Indices are 1-based. Sample Input 2 5 7 3 10 2 8 6 3 8 2 9 4 14 Sample Output 2 5 1 8 6 9
[ "n=int(input())\r\nlst=list(map(int,input().split()))\r\nq=lst.index(max(lst))+1\r\nlst.sort()\r\np=lst[-2]\r\nprint(q,p)", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\nlargest = max(a)\r\nb = []\r\n\r\nfor i in range(n):\r\n if a[i] == max(a):\r\n winner = i + 1\r\n \r\nfor x in a:\r\n if x != largest:\r\n b.append(x)\r\n \r\n\r\nprint(winner, max(b))\r\n\r\n", "n = int(input())\r\n\r\nprices = list(map(int, input().split()))\r\n\r\nsorted_prices = sorted(prices)\r\n\r\nprint(prices.index(sorted_prices[n-1])+1, end=' ')\r\nprint(sorted_prices[n-2], end=' ')\r\n", "n = int(input())\r\nmoo = list(map(int, input().split()))\r\nprint(moo.index(max(moo))+1, end = \" \")\r\nmoo.remove(max(moo))\r\nprint(max(moo))", "n = int(input())\nbids = list(map(int, input().split(\" \")))\n\nnewbids = bids.copy()\nnewbids.sort()\n\ni = bids.index(newbids[-1]) + 1\nnum = newbids[-2]\nprint(i,num)", "n = int(input())\r\nl = list(map(int,input().split()))\r\ns = sorted(l,reverse=True)\r\nprint(l.index(s[0])+1,s[1])\r\n\r\n\r\n\r\n", "n = int(input())\r\nnums = [int(j) for j in input().split()]\r\nref = 10000 * [-1]\r\nfor j in range(n):\r\n ref[nums[j] - 1] = j + 1\r\nindex, pointer = -1, 9999\r\nwhile pointer >= 0:\r\n if ref[pointer] != -1:\r\n index = ref[pointer]\r\n pointer -= 1\r\n break\r\n pointer -= 1\r\nvalue = -1\r\nwhile pointer >= 0:\r\n if ref[pointer] != -1:\r\n value = pointer + 1\r\n break\r\n pointer -= 1\r\nprint(index, value)\r\n", "n = int(input())\r\nps = list(map(int,input().split()))\r\n\r\nidx = ps.index(max(ps))\r\nnn = str(sorted(ps)[-2])\r\nprint(*[str(idx+1),nn])", "\r\nn = int(input())\r\nl = list(map(int, input().split()))\r\n\r\nli = l.copy()\r\nli.sort(reverse = True)\r\n\r\nprint(l.index(li[0]) + 1, li[1])", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=sorted(a)\r\nx=a.index(max(a))+1\r\nprint(x,b[-2])\r\n", "\r\n \r\nn = int(input())\r\narray = list(map(int,input().split()))\r\n\r\n\r\narray2 = []\r\nfor x in array:\r\n array2.append(x)\r\n\r\narray.sort()\r\nwin = array[-2]\r\nindex = array2.index(array[-1]) + 1\r\n\r\nprint(index,win)\r\n ", "n=int(input())\nl=list(map(int,input().split(' ')))\nm=max(l)\nn=l.index(m)+1\nl.sort()\n\nprint(n,l[len(l)-2])\n \t\t \t \t \t \t\t \t \t\t\t\t\t\t \t \t", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=sorted(a)\r\nprint((a.index(b[-1])+1),b[-2])", "n = int(input())\r\np = list(map(int, input().split()))\r\n\r\na = p.index(max(p)) + 1\r\np.remove(max(p))\r\nb = max(p)\r\n\r\nprint(a, b)", "int(input())\r\nbidders = list(map(int,input().split()))\r\n# print(bidders)\r\nmaxi = max(bidders)\r\nindex = 0\r\nfor i in range(len(bidders)):\r\n if bidders[i] == maxi:\r\n index = i + 1\r\n break\r\nbidders.sort()\r\nprint(index,bidders[-2])", "a = int(input())\r\nx = list(map(int, input().split()))\r\nlargest = 0\r\nsecond = 0\r\nl = []\r\nj = 0\r\nwhile j<len(x):\r\n if x[j]>largest:\r\n largest = x[j]\r\n l.append(j+1)\r\n j += 1\r\nk = 0\r\nwhile k<len(x):\r\n if x[k]>second:\r\n if k!=(l[-1]-1):\r\n second = x[k]\r\n k += 1\r\nprint(l[-1],second)", "n = int(input())\r\n*a, = map(int, input().split())\r\nx = a.index(max(a))\r\na[x] = 0\r\nprint(x + 1, max(a))", "n = int(input())\r\nb = list(map(int,input().split(' ')))\r\nmax = b[0]\r\nmax2 = -1\r\nindex = 0\r\nfor i in range (0,n):\r\n if max < b[i] :\r\n max = b[i]\r\n index = i\r\nfor i in range (0,n):\r\n if max2 < b[i] < max:\r\n max2 = b[i]\r\nprint(index+1, max2)", "input();l=list(map(int, input().split()))\r\nprint(*[l.index(max(l))+1, ], sorted(l)[sorted(l).index(max(l))-1])", "input()\r\np = list(map(int, input().split()))\r\na, b = sorted(p)[-2:]\r\nprint(p.index(b)+1, a)", "n = input()\r\np = list(map(int, input().split()))\r\nmp = max (p)\r\nmid = p.index(mp) + 1 \r\np.remove(mp)\r\nprint(mid, max(p))", "c=int(input())\r\ng=[int(c) for c in input().split(' ')]\r\nm=g.index(max(g))\r\ng.sort()\r\ng.pop()\r\nprint(m+1,max(g))\r\n", "def answer():\r\n n = int(input())\r\n l1 = [int(x) for x in input().split()]\r\n winner = l1.index(max(l1))+1\r\n l1.remove(max(l1))\r\n price=max(l1)\r\n print(winner,price)\r\nanswer()", "n = int(input())\r\nl = [int(x) for x in input().split()]\r\nz = sorted(l)\r\n\r\nprint(l.index(max(l)) + 1, z[-2])", "n = int(input())\r\narr = list(map(int, input().split()))\r\nmax = 0\r\nfor i in range(1, n):\r\n if arr[max] < arr[i]:\r\n max = i\r\narr.sort()\r\nprint(max+1, arr[-2])", "n = int(input())\r\nbidders = [int(i) for i in input().split()]\r\n\r\nbokita = max(bidders)\r\n\r\na = bidders.index(bokita) + 1\r\n\r\nbidders.remove(bokita)\r\n\r\ngarpa_bokita = max(bidders)\r\n\r\nprint(a , garpa_bokita)", "n = int(input())\r\nl = list(map(int, input().split(\" \")))\r\nprint(l.index(max(l))+1, sorted(l)[-2])", "import sys\r\nii = lambda: sys.stdin.readline().strip()\r\nidata = lambda: [int(x) for x in ii().split()]\r\n\r\ndef solve():\r\n n = int(ii())\r\n data = idata()\r\n pl = sorted(data)[-2]\r\n s = max(data)\r\n for i in range(n):\r\n if s == data[i]:\r\n print(i + 1, pl)\r\n return\r\n\r\nfor t in range(1):\r\n solve()", "# Second-Price Auction\nn = int(input())\np = list(map(int,input().split()))\ny = max(p)\nx = p.index(y)+1\np.remove(y)\nprint(x,max(p))\n", "n = int(input())\r\n\r\narr = list(map(int,input().split()))\r\na = sorted(arr)\r\n\r\nprint(1 + arr.index(a[-1]), a[-2])", "n = input()\ns = list(map(int,input().split()))\na = max(s)\nb = s.index(a)\ns.remove(a)\nprint(b+1,max(s))", "input()\r\nA = list(map(int, input().split()))\r\na, b, *_ = sorted(A, reverse=True)\r\nprint(A.index(a) + 1, b)", "n, p = int(input()), sorted((x, i) for i, x in enumerate(map(int, input().split())))\r\nprint(p[-1][1] + 1, p[-2][0])", "n=int(input())\r\np=list(map(int,input().split()))\r\nm=max(p)\r\nl=p.index(m)\r\np=sorted(p)\r\nprint(l+1,p[n-2])\r\n", "n = int(input())\r\nps = list(map(int, input().split()))\r\nif ps[0] < ps[1]:\r\n first_index = 1\r\n second_index = 0\r\nelse:\r\n first_index = 0\r\n second_index = 1\r\n\r\nfor i in range(2,n):\r\n if ps[i] > ps[first_index]:\r\n second_index = first_index\r\n first_index = i\r\n elif ps[i] > ps[second_index]:\r\n second_index = i\r\nprint(first_index + 1, ps[second_index])\r\n", "# Read the number of bidders\r\nn = int(input())\r\n\r\n# Read the prices offered by the bidders\r\nprices = list(map(int, input().split()))\r\n\r\n# Find the index of the highest bidder\r\nwinner_index = prices.index(max(prices))\r\n\r\n# Find the second highest price\r\nsecond_highest_price = sorted(prices, reverse=True)[1]\r\n\r\n# Print the winner's index and the price he will pay\r\nprint(winner_index + 1, second_highest_price)", "n = int(input())\r\np = list(map(int,input().split()[:n]))\r\n\r\nw = p.index(max(p))\r\np.remove(max(p))\r\n\r\nprint(w+1,max(p))", "t=int(input())\r\nl=[]\r\ncount=0\r\na = list(map(int,input().strip().split()))[:t]\r\nm=max(a)\r\nn=a.index(m)\r\na.remove(m)\r\no=max(a)\r\nprint(str(n+1)+\" \"+str(o))\r\n", "nums = int(input())\r\narr = list(map(int , input().split()))\r\nnewArr = []\r\nfor i in range(len(arr)):\r\n newArr.append((arr[i], i))\r\narr = sorted(newArr, key=lambda x:x[0])\r\nprint(arr[len(arr)-1][1]+1, arr[len(arr)-2][0])", "n = int(input())\r\nli = [*map(int,input().split())]\r\na = li.index(max(li))\r\nli.pop(a)\r\nb = max(li)\r\n\r\nprint(a+1,b)", "n= int(input())\r\n\r\nx=list(map(int,input().split()))\r\n\r\n\r\nxx=max(x)\r\nfor i in range(n):\r\n\tif(x[i]==xx):\r\n\t\tmaxx = i+1\r\n\t\t\r\na=x\r\na.remove(xx)\t\r\nmax_a = max(a)\r\n\r\nprint(maxx , max_a,sep = \" \")", "a = int(input())\r\nb = [*map(int, input().split())]\r\nprint(b.index(max(b))+1, sorted(b)[-2])\r\n\r\n\r\n", "import sys\r\ninput = sys.stdin.readline\r\nn = int(input())\r\nls = list(map(int , input().split()))\r\nx = max(ls)\r\ny = ls.index(x) + 1\r\nls.pop(y-1)\r\nprint(str(y) + \" \" + str(max(ls)))", "a=int(input())\r\nb=list(map(int,input().split()))\r\no1=b.index(max(b))+1\r\nb.pop(b.index(max(b)))\r\no2=max(b)\r\nprint(o1,o2)\r\n\r\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\nt = l.index(max(l))\r\nl.sort()\r\nprint(t+1,l[-2])", "n=int(input())\r\nc=input()\r\nc=c.split()\r\nm=[]\r\nfor i in range(n):\r\n\tm.append(int(c[i]))\r\na=max(m)\r\ns=str(m.index(a)+1)+' '\r\nif(n==1):\r\n\tprint(s+'1')\r\nelse:\r\n\tm.remove(a)\r\n\tb=max(m)\r\n\tprint(s+str(b))", "input()\r\nX = list(map(int, input().split()))\r\nprint(X.index(sorted(X)[-1]) + 1, sorted(X)[-2])\r\n\r\n# UB_CodeForces\r\n# Advice: Falling down is an accident, staying down is a choice\r\n# Location: A Few days in Mashhad\r\n# Caption: Before going to a family house\r\n# CodeNumber: 676\r\n", "n = int(input())\r\np = list(map(int, input().split()))\r\n\r\na = []\r\nfor i in range(n):\r\n\ta.append((i, p[i]))\r\na.sort(key=lambda k : k[1])\r\n\r\nprint(a[-1][0] + 1, a[-2][1])", "num_of_bidders = input()\nbids = input()\nlist1 = bids.split(\" \")\nwinner = 0\n\nlist2 = [int(i) for i in list1]\nmax_bid = max(list2)\n\ni = 0\nwhile i < len(list2):\n\tif list2[i] == max_bid:\n\t\twinner = i + 1\n\t\tlist2.pop(i)\n\t\tbreak\n\ti += 1\n\nfinal_bid = max(list2)\n\nprint(\"{} {}\".format(winner, final_bid))", "n=int(input())\np=list(map(int, input().split()))\nb=sorted(p)\na=max(p)\nc=p.index(a) + 1 \nd=b[-2]\nprint(c,d)", "n = int(input())\r\nl=list(map(int,input().split()))\r\n\r\nmax_val = l[0]\r\nindex = 1\r\n\r\nfor i in range(1,n):\r\n if max_val<l[i]:\r\n max_val=l[i]\r\n index=i+1\r\n\r\nl.sort(reverse=True)\r\nprint(f\"{index} {l[1]}\")\r\n", "try:\r\n n=int(input())\r\n p=list(map(int,input().split(\" \")))\r\n l=max(p)\r\n k=p.index(l)+1\r\n p.remove(l)\r\n u=max(p)\r\n print(str(k)+\" \"+str(u))\r\nexcept:\r\n pass", "input()\np = list(map(int, input().split()))\nmax_price = max(range(0,len(p)), key=p.__getitem__)\ndel p[max_price]\nprint(max_price+1, sorted(p, reverse=1)[0])", "n = int(input())\r\nl = [int(x) for x in input().split()]\r\ng = sorted(l)\r\na = l.index(g[-1])+1\r\nprint(a, g[-2])", "n=int(input())\r\nl=list(map(int,input().split()))\r\na=l.index(max(l))\r\nl.remove(max(l))\r\nb=max(l)\r\nprint(a+1,b)", "n=int(input())# no of bidders\nprices=list(map(int,input().split()))#price from all bidders\n\nwin_bid=prices.index(max(prices))+1 # as 1-based\n\nprices.pop(win_bid-1)# removing win bid from list\nsec_highest_bid=max(prices)\nprint(win_bid,sec_highest_bid)\n\n\n\n\t \t \t\t\t \t\t\t \t \t\t \t \t", "n=int(input())\nentrada=input().split()\nhigher=-1\nhigher_value=0\nsecond=0\nsecond_value=-1\nfor i in range(n):\n value=int(entrada[i])\n if value>higher_value:\n second_value=higher_value\n second=higher\n higher=i+1\n higher_value=value\n elif value>second_value:\n second_value=value\n second=i+1\nprint(higher,second_value)\n \t\t\t\t \t\t\t\t\t \t\t \t \t \t\t \t\t\t\t \t", "n=int(input())\r\nl=list(map(int,input().split()))\r\nm=[]\r\nfor i in l:\r\n m.append(i)\r\nm.sort()\r\np=m[len(m)-1]\r\na1=0\r\nfor i in range(0,n):\r\n if(l[i]==p):\r\n a1=i\r\n break\r\nprint(a1+1,m[len(m)-2])\r\n", "n = int(input())\r\narr = list(map(int, input().split()))\r\na = arr.index(max(arr)) + 1\r\narr.sort()\r\nb = arr[-2]\r\nprint(a, b)", "def maxi(lst: list) -> int:\r\n elem = -1\r\n elemi = -1\r\n for i, v in enumerate(lst):\r\n if v > elem:\r\n elem = v\r\n elemi = i\r\n return elemi\r\n\r\nn = int(input())\r\nlst = list(map(int, input().split()))\r\nsoln = maxi(lst)\r\nprint(soln+1, end=\" \")\r\nlst.pop(soln)\r\nprint(max(lst))", "t = int(input())\r\nlst = list(map(int, input().strip().split()))\r\nwin=max(lst)\r\nfor i in range(len(lst)):\r\n if lst[i]== win:\r\n a=i+1\r\n lst.remove(max(lst))\r\n break\r\nprice=max(lst)\r\nprice=str(price)\r\na = str(a)\r\nprint(a+\" \"+price)\r\n", "input()\r\nl = list(map(int, input().split()));\r\nprint(l.index(max(l)) + 1, sorted(l)[len(l) - 2])", "n = int(input())\r\na = list(map(int,input().split()))\r\nprint(a.index(max(a))+1,end = \" \")\r\ndel(a[a.index(max(a))]); print(max(a))", "n = int(input())\r\nlst = [int(x) for x in input().split()]\r\ni = lst.index(max(lst)) + 1\r\nlst.remove(max(lst))\r\nprint(i,max(lst),sep=\" \")", "n = int(input())\r\nprice = input().split(' ')\r\nfor i in range (n):\r\n price[i] = int(price[i])\r\n\r\nj =price.index(max(price))\r\nsorted_price = sorted(price)\r\nprint(j+1, sorted_price[n-2])\r\n\r\n\r\n\r\n", "n=int(input())\r\nl=list(map(int,input().split())) \r\ndic={}\r\nfor i in range(n):\r\n a=l[:]\r\n a.pop(i)\r\n dic[i+1]=max(a) \r\nc=list(dic.values())\r\nc=list(set(c))\r\nc.remove(max(c))\r\nm=max(c)\r\nfor i in dic:\r\n if dic[i]==m:\r\n k=i \r\nprint(k,m)", "n = int(input())\r\nprices = input().split(\" \")\r\nfor c, price in enumerate(prices):\r\n prices[c]=int(price)\r\nresult = str(prices.index(max(prices))+1)+\" \"+str(sorted(prices, reverse=True)[1])\r\nprint(result)", "n = int(input())\r\n\r\nbids = input().split()\r\n\r\nfor i in range(0, len(bids)):\r\n bids[i] = int(bids[i])\r\n\r\nindex = bids.index(max(bids))\r\nbids.remove(max(bids))\r\n\r\nprint(index+1, max(bids))", "_ = input()\nbids = list(map(int, input().split()))\nfirst, second = bids[0], bids[1]\nif second > first:\n first, second = second, first\nif not (len(bids) <=2) :\n for bid in bids[2:]:\n if bid > second:\n if bid > first:\n second = first\n first = bid\n else:\n second = bid\nprint(bids.index(first)+1, second)", "n = int(input())\r\noffers = list(map(int, input().split()))\r\n\r\nif offers[0] < offers[1]:\r\n max_i = 1\r\n max_offer = offers[1]\r\n second_i = 0\r\n second_offer = offers[0]\r\nelse:\r\n max_i = 0\r\n max_offer = offers[0]\r\n second_i = 1\r\n second_offer = offers[1]\r\n\r\nfor i, offer in enumerate(offers):\r\n if i < 2:\r\n continue\r\n if offer > max_offer:\r\n second_i = max_i\r\n second_offer = max_offer\r\n max_i = i\r\n max_offer = offer\r\n elif offer > second_offer:\r\n second_offer = offer\r\n second_i = i\r\n\r\nprint(max_i+1, second_offer)\r\n\r\n", "n=int(input())\nl=list(map(int,input().split()))\nm=l[0]\nind=0\nfor i in range(1,n):\n\tif l[i]>m:\n\t\tm=l[i]\n\t\tind=i\nl.sort()\nprint(ind+1,l[n-2])", "n = int(input())\r\na = list(map(int, input().split()))\r\nprint(a.index(max(a)) + 1, end=' ')\r\na.remove(max(a))\r\nprint(max(a))", "n = int(input())\r\nl = list(map(int ,input().split()))\r\nwinner = l.index(max(l)) + 1 \r\nl.remove(l[winner - 1 ])\r\nprice = l[l.index(max(l))] \r\nprint(winner , price)", "n = int(input())\r\nprices = list(map(int, input().split()))\r\npr = max(prices)\r\nind = prices.index(pr)\r\nprices.remove(pr)\r\nspesa = max(prices)\r\nprint(ind+1, spesa)\r\n", "#Problema F\n\na = int(input())\na = input()\nmaior = -1\nsegundo = -1\nindice = 0\na = a.split()\nfor i in range(len(a)):\n a[i]=int(a[i])\n if (a[i] > maior):\n indice = i\n segundo = maior\n maior = a[i]\n elif(a[i]>segundo):\n segundo=a[i]\nprint(indice+1,segundo)\n\t\t\t\t \t \t\t \t \t \t\t\t \t \t\t\t", "import sys\r\nimport math\r\n\r\nn = int(sys.stdin.readline())\r\npn = [int(x) for x in (sys.stdin.readline()).split()]\r\n\r\nvmax = 0\r\nrmax = 0\r\nind = 0\r\nfor i in range(n):\r\n if(pn[i] > vmax):\r\n rmax = vmax\r\n vmax = pn[i]\r\n ind = i + 1 \r\n elif(pn[i] > rmax):\r\n rmax = pn[i]\r\n \r\nprint(ind, rmax)\r\n\r\n\r\n \r\n\r\n ", "n = int(input())\r\nm = list(map(int, input().split()))\r\nmx = min(m)\r\ns = max(m)\r\nfor i in range(0,n):\r\n if m[i] == s:\r\n a = i + 1\r\n if m[i] != s and m[i] > mx:\r\n mx = m[i]\r\nprint(a, mx)", "n = int(input())\np = list(map(int,input().split()))\nh = 0\ni = 0\nfor x in p:\n\tif x > h:\n\t\th = x\ni = p.index(h) + 1\np.remove(h)\nh = 0\nfor x in p:\n\tif x > h:\n\t\th = x\nprint(str(i) + \" \" + str(h))\n", "if __name__ == '__main__':\r\n n = int(input())\r\n p = [int(x) for x in input().split()]\r\n idx_maior = p.index(max(p))\r\n p.pop(idx_maior)\r\n smaior = p.pop(p.index(max(p)))\r\n print(\"{} {}\".format(idx_maior+1,smaior))", "import sys\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nans = a.index(max(a)) + 1\r\na.remove(max(a))\r\nprint(ans, max(a))", "n = int(input())\r\nlis = list(map(int,input().split()))\r\nmaxx = secondmaxx = -float('inf')\r\nind = 0\r\nfor i in range(n):\r\n if lis[i]>maxx:\r\n secondmaxx = maxx\r\n maxx = lis[i]\r\n ind = i\r\n elif lis[i]>secondmaxx:\r\n secondmaxx = lis[i]\r\nprint(ind+1,secondmaxx)\r\n", "n = int(input())\r\nprices=list(map(int,input().split()))\r\nhighest_price=0\r\nsecond_high=0\r\nfor x in prices:\r\n if x>=highest_price:\r\n second_high=highest_price\r\n highest_price=x\r\n elif second_high<x<highest_price:\r\n second_high=x\r\nif second_high==0:\r\n print(\"no\")\r\nelse:\r\n print(prices.index(highest_price)+1,second_high)", "n = int(input())\r\np = [int(s) for s in input().split(' ')]\r\nind = p.index(max(p)) + 1\r\nprice = sorted(p)[-2]\r\nprint(ind, price)", "n=int(input())\r\n\r\nL=list(map(int,input().split()))\r\n\r\nind=L.index(max(L))\r\n\r\nL.remove(max(L))\r\n\r\nx=max(L)\r\n\r\nprint(ind+1,x)\r\n", "# -*- coding: utf-8 -*-\r\n# Автор: Некрасов Станислав\r\nn = int(input())\r\na = [*map(int, input().split()), -float('inf')]\r\nmax_i, max_i2 = n, n\r\nfor i in range(n):\r\n if a[i] > a[max_i]:\r\n max_i, max_i2 = i, max_i\r\n elif a[i] > a[max_i2]:\r\n max_i2 = i\r\n\r\nprint(max_i + 1, a[max_i2])\r\n", "n=int(input())\nli=list(map(int,input().split()))\nmaxi=0\nfor i in range(len(li)):\n if li[i]>maxi:\n maxi=li[i]\n ind=i\nli.pop(ind)\nmax2=max(li)\nprint(ind+1,max2)\n\n", "n = int(input())\r\na = list(map(int,input().split()))\r\nprint(1+a.index(max(a)),end=' ')\r\na.remove(max(a))\r\nprint(max(a))", "n=int(input())\r\na=list(map(int,input().split()))\r\na=sorted([[a[i],i+1] for i in range(n)])\r\nprint(a[-1][1],a[-2][0])", "'''\n CodeForces problem 386A\n 26/01/2014\n'''\n\n# (x, y) = (offerta, tizio)\nn = int( input() )\nl = [ int(x) for x in input().split()]\ni=1\noff = []\nfor x in l:\n off.append( (x, i) )\n i+=1\n \noff.sort( reverse=True ) \n\nprint(str(off[0][1])+' '+str(off[1][0]))\n", "n = int(input())\np = list(map(int, input().split()))\n\nma = 0\nwinner = None\nfor i, _p in enumerate(p):\n if _p > ma:\n ma = _p\n winner = i + 1\np.sort(reverse=True)\nprint(f\"{winner} {p[1]}\")\n", "amountofvalues = input()\r\nvalues = list(map(int, input().split()))\r\nbig= 0\r\nbig2 = 0\r\na = 0\r\nfor i in values:\r\n a = a+1\r\n \r\n if i >= big:\r\n big2 = big\r\n big = i\r\n b = a\r\n elif i >= big2:\r\n big2 = i\r\nprint(b, big2)\r\n\r\n", "n = int(input())\r\np = list(map(int, input().split()))\r\nl = p.copy()\r\nl.sort()\r\n\r\nprint(p.index(l[-1])+1,l[-2])", "# Contest 13\r\n# F - Second-Price Auction\r\n# \r\n\r\nif __name__ == \"__main__\":\r\n\tn = int(input())\r\n\toffers = list(int(x) for x in input().split())\r\n\r\n\twinner_pos = offers.index(max(offers))\r\n\r\n\toffers.pop(winner_pos)\r\n\r\n\tprice_to_pay = max(offers)\r\n\r\n\tprint(winner_pos+1, price_to_pay)", "n = int(input())\r\na = list(map(int, input().split()))\r\nmaxi = a[0]\r\nind = 1\r\nmaxi2 = a[1]\r\nif maxi2 > maxi:\r\n maxi, maxi2 = maxi2, maxi\r\n ind = 2\r\nfor i in range(2,n):\r\n if a[i] > maxi:\r\n maxi2 = maxi\r\n maxi = a[i]\r\n ind = i+1\r\n else:\r\n if a[i] > maxi2:\r\n maxi2 = a[i]\r\nprint(ind, maxi2)", "a=int(input())\r\nt1=list(map(int,input().split()))\r\n\r\nwinner=max(t1)\r\nindex_winner=t1.index(winner)\r\n\r\nt3=t1 #to get 2nd highest \r\nt3.sort()\r\ndel t3[-1]\r\nsecond_highest=t3[-1]\r\n\r\n\r\n\r\n\r\n# print(second_highest)\r\nprint(index_winner+1,second_highest)\r\n", "#Gathtering Bids and bidders\r\nbidders = int(input())\r\ntotBids = input().split()\r\nfor i in range(0, len(totBids)):\r\n totBids[i] = int(totBids[i])\r\n\r\nbids = totBids\r\nmaxBid=0\r\nprice = 0\r\n\r\nfor i in range(len(totBids)):\r\n if totBids[i] > maxBid:\r\n maxBid = totBids[i]\r\n\r\nfor i in range(len(totBids)):\r\n if totBids[i] > price and totBids[i] != maxBid:\r\n price = totBids[i]\r\n\r\nmaxBidIndex = totBids.index(maxBid) + 1\r\n\r\nprint(maxBidIndex,price)", "n = int(input())\nauctions = [int(x) for x in input().split()]\n\nindex = auctions.index(max(auctions)) + 1\n\nauctions.remove(max(auctions))\n\nprint(index, max(auctions))\n", "n=int(input())#n=number of participants\r\na=list(map(int,input().split()))\r\nc=a.index(max(a))+1\r\na.sort()\r\nprint(c,a[-2])", "x=int(input())\r\ny=list(map(int,input().split()))\r\nd=max(y)\r\nprint(y.index(d)+1,end=\" \")\r\ny.sort(reverse=True)\r\nprint(y[1])\r\n ", "n=int(input())\r\nl=list(map(int,input().split()))\r\ni=l.index(max(l))\r\nprint(i+1,end=\" \")\r\nl.pop(i)\r\nprint(max(l))\r\n", "n = int(input())\nprs = [int(x) for x in input().split()]\nprint(prs.index(max(prs)) + 1, sorted(prs)[-2])\n\n", "__author__ = 'asmn'\r\n\r\nn = int(input())\r\na = sorted(enumerate(map(int, input().split())),key=lambda x:-x[1])\r\n\r\nprint(a[0][0]+1, a[1][1])\r\n\r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nl[l.index(max(l))]=-1\r\nprint(l.index(-1)+1,l[l.index(max(l))])", "n = int(input())\nbids = list(map(int,input().split()))\nbig = max(bids)\nindex = bids.index(big)+1\nbids.remove(big)\nbig = max(bids)\nprint(f\"{index} {big}\")\n\t \t \t\t \t\t \t \t\t\t\t \t\t", "n = int(input())\r\na = list(map(int, input().split()))\r\nb = sorted(a)\r\np1, p2 = b[-1], b[-2]\r\nprint(a.index(p1) + 1, p2)", "n = int(input())\r\nl = list(map(int,input().split()))\r\na = max(l)\r\nprint(l.index(a)+1,end =' ')\r\nl.sort()\r\nprint(l[len(l)-2])\r\n", "t = int(input())\r\nx = list(map(int, input().split()))\r\nprint((x.index(max(x))+1), end=\" \")\r\nx.remove(max(x))\r\nprint(max(x))", "n=int(input())\r\narr=list(map(int,input().split()))\r\nprint(arr.index(max(arr))+1, end = ' ')\r\narr.sort()\r\nprint(arr[n-2])", "n = int(input())\r\nofferedPrice = [int(offer) for offer in input().split()]\r\nwinnerIndex = offeredPrice.index(max(offeredPrice))\r\npaiedPrice = -1\r\nfor i in range(n):\r\n if(offeredPrice[i]>paiedPrice and offeredPrice[i]!=offeredPrice[winnerIndex]):\r\n paiedPrice=offeredPrice[i]\r\nprint(winnerIndex + 1 , paiedPrice)", "n=int(input())\r\nl=list(map(int,input().split()))\r\ntemp=l.index(max(l))\r\n\r\nl.remove(max(l))\r\n\r\nprint(temp+1,end=' ')\r\nprint(max(l))", "#----------------------------\n# Matheus de Souza Oliveira |\n# RA: 203407 |\n#----------------------------\n\nn = int(input())\nprices = list(map(int, input().split()))\nmaxPrice = max(prices)\nwinner = prices.index(maxPrice)\nprices.pop(winner)\nmaxPrice = max(prices)\n\nprint(winner+1, maxPrice)\n \t\t \t \t\t\t\t\t \t \t\t \t \t\t", "# Here I just need to sort and find the index of the 1st value\nnumberOfBids = map(int, input())\nbids = list(map(int, input().split()))\nbidsOrg = bids.copy()\nbidsOrg.sort(reverse=True)\nprint(bids.index(bidsOrg[0]) + 1, end=' ')\nprint(bidsOrg[1])\n \t \t \t\t \t \t\t\t \t\t\t\t\t", "n=int(input())\r\nn1=list(map(int,input().split()))\r\ns=max(n1)\r\nlst=[]\r\nv=''\r\nfor i in range(n):\r\n if(n1[i]!=s):\r\n lst.append(n1[i])\r\n else:\r\n v=v+str(i+1)+' '\r\nv=v+str(max(lst))\r\nprint(v)\r\n", "n = int(input())\r\narray = input().split(\" \")\r\nfor i in range(len(array)): \r\n array[i] = int(array[i])\r\nindex_ = array.index(max(array)) + 1\r\narray.remove(max(array))\r\nprint(index_, end=' ')\r\nprint(max(array)) ", "n = int(input())\nprices = [int(x) for x in input().split()]\n\nidx = 0\nmax_price = prices[0]\npay = 0\nfor i in range (1, n):\n\tif prices[i] > max_price:\n\t\tpay = max_price\n\t\tmax_price = prices[i]\n\t\tidx = i\n\telif prices[i] > pay:\n\t\tpay = prices[i]\n\nprint(str(idx+1) + \" \" + str(pay))", "n=int(input())\r\na=list(map(int,input().split()))\r\nhigh=a.index(max(a))\r\ndel a[high]\r\nprint(high+1,max(a))\r\n", "bidders = int(input())\r\n\r\nprices = list(map(int,input().split()))\r\nwinner = prices.index(max(prices))\r\nprices.sort()\r\n\r\nprint(winner+1,prices[-2])", "number = int(input())\r\nlist1 = list(map(int,input().split()))\r\ngreatest = max(list1)\r\nindex = 0\r\nsecond = 0\r\nfor i in range(number):\r\n if(list1[i]<greatest and list1[i]>second):\r\n second = list1[i]\r\n if(list1[i] == greatest):\r\n index = i+1\r\nprint(index,second)\r\n", "n=int(input())\r\na=list(map(int, input().split()))[:n]\r\nx=max(a)\r\ni=a.index(x)\r\na.remove(x)\r\nprint(i+1, max(a))", "n=int(input())\np=list(map(int,input().split()))\nx=sorted(p)\na=p.index(max(p))+1\nprint(a,x[-2])\n", "import sys\r\n\r\ndef main():\r\n _, *l = map(int, sys.stdin.read().strip().split())\r\n t = sorted(zip(l, range(1, len(l)+1)))[-2:]\r\n return t[1][1], t[0][0]\r\n \r\nprint(*main())\r\n", "n = int(input())\r\np = list(map(int,input().split()))\r\nol = p.index(max(p))\r\np.pop(ol)\r\nprint(ol+1,max(p))", "num_bids = int(input())\r\nbids = [int(bids) for bids in input().split()]\r\nmaxi1 = max(bids)\r\na = bids.index(maxi1)\r\nprint(a + 1, end = \" \")\r\ndel bids[a]\r\nprint(max(bids))\r\n\r\n\r\n", "n=int(input())\np=list(map(int, input().split()))\nans=p.index(max(p))+1\np.remove(max(p))\nprint(ans,max(p))\n", "n = int(input())\nbids = list(map(int, input().split()))\nhighest_bid = -1\nsecond_highest_bid = -1\nwinner_index = -1\nfor i in range(n):\n if bids[i] > highest_bid:\n second_highest_bid = highest_bid\n highest_bid = bids[i]\n winner_index = i\n elif bids[i] > second_highest_bid:\n second_highest_bid = bids[i]\nprint(winner_index + 1, second_highest_bid)\n\n\t\t\t \t \t\t \t\t \t\t \t \t \t\t \t\t", "def second_price_auction(prices):\r\n highest_price = max(prices)\r\n second_highest_price = max(price for price in prices if price != highest_price)\r\n winner_index = prices.index(highest_price) + 1\r\n return winner_index, second_highest_price\r\n\r\nn = int(input())\r\nprices = list(map(int, input().split()))\r\nwinner_index, price_to_pay = second_price_auction(prices)\r\nprint(winner_index, price_to_pay)\r\n", "# https://codeforces.com/contest/386/problem/A\r\n\r\nn = int(input())\r\nbids = input().split(\" \")\r\n\r\nhighest_bid = [0, 0]\r\nsecond_highest_bid = 0\r\n\r\nfor i in range(n):\r\n if int(bids[i]) >= highest_bid[0]:\r\n highest_bid[0] = int(bids[i])\r\n highest_bid[1] = i + 1\r\n\r\nfor i in range(n):\r\n if int(bids[i]) >= second_highest_bid and int(bids[i]) < highest_bid[0]:\r\n second_highest_bid = int(bids[i])\r\n \r\nprint(highest_bid[1], second_highest_bid)", "n = int(input())\r\n*a, = map(int, input().split())\r\nw = a.index(max(a))\r\na.pop(w)\r\np = max(a)\r\nprint(w + 1, p)", "n = int(input())\r\nlist1 = list(map(int,input().split()))\r\nlist2 = sorted(list1)\r\nprint(list1.index(list2[n-1])+1,list2[n-2])\r\n", "n_ = input()\r\nn = []\r\n[n.append(int(i)) for i in input().split()]\r\nn__ = n.copy()\r\ndel n[n.index(max(n))]\r\nprint(n__.index(max(n__)) + 1, max(n))", "n=int(input())\r\narray=list(map(int,input().strip().split()))\r\nlar=max(array)\r\nwinner_index=array.index(lar)+1\r\narray.remove(lar)\r\nmoney_pay=max(array)\r\nprint(str(winner_index)+\" \"+str(money_pay))", "n = int(input())\r\np = [int(p) for p in input().split()]\r\nind = p.index(max(p))\r\np[ind] = 0\r\nprint(ind + 1, max(p))\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n=int(input())\r\np=list(map(int, input().split()))\r\nx=p.index(max(p))+1\r\np.remove(max(p))\r\nprint(x,max(p))\r\n", "num = int(input())\nassert num >= 2\nbid = input().split(' ')\nres = [eval(i) for i in bid]\nindex = 1\nsortd = sorted(res)\nfor i in res:\n if i == max(res):\n print(index)\n index+=1\nprint(sortd[len(sortd)-2])\n \t \t \t\t\t\t \t \t\t \t \t \t\t \t\t \t", "n = int(input())\r\nm = [int(x) for x in input().split()]\r\n\r\nr = [[0, 0], [0, 0]]\r\n\r\nfor ii in range(0, len(m)):\r\n if m[ii] > r[0][0]:\r\n r[1][0] = r[0][0]\r\n r[1][1] = r[0][1]\r\n\r\n r[0][0] = m[ii]\r\n r[0][1] = ii + 1\r\n elif m[ii] < r[0][0] and m[ii] > r[1][0]:\r\n r[1][0] = m[ii]\r\n r[1][1] = ii + 1\r\n\r\nprint(r[0][1], r[1][0])", "n = int(input())\r\na, b = zip(*sorted(zip(map(int, input().split()), list(range(1, n+1)))))\r\nprint(b[-1], a[-2])", "n = int(input())\r\nl = list(map(int, input().split()))\r\nlargest = -33\r\nsecond = -34\r\nfor i in range(len(l)):\r\n if l[i] > largest:\r\n second = largest\r\n largest = l[i]\r\n elif l[i] > second:\r\n second = l[i]\r\nprint(l.index(largest)+1,second)", "n=int(input())\ns=list(map(int,input().split(\" \")))\nq=s.index(max(s))+1\ns.sort()\nprint(q,end=\" \")\nprint(s[n-2])\n", "n = int(input())\r\nl = list(map(int, input().split()))\r\nlargest = max(l)\r\nnew_l = []\r\nfor i in l:\r\n if i != largest:\r\n new_l.append(i)\r\nif len(new_l) == 0:\r\n second_largest = largest\r\nelse:\r\n second_largest = max(new_l)\r\nprint(l.index(largest)+1, second_largest)\r\n", "input()\nl=list(map(int,input().split()))\nk=sorted(l)\nprint(1+l.index(k[-1]),k[-2])\n", "#Second-price auction\r\n\r\nn = int(input())\r\nprice = list(map(int,input().split()))\r\noutput = []\r\noutput.append(price.index(max(price)) + 1)\r\nprice.sort(reverse = True)\r\noutput.append(price[1])\r\nprint(\" \".join(map(str,output)))\r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nm=max(l)\r\nind=0\r\nfor i in range(n):\r\n\tif l[i]==m:\r\n\t\tind=i+1\r\n\t\tl[i]=0\r\nm2=max(l)\r\nprint(ind,m2)", "n = int(input())\r\nlst = list(map(int, input().split()))\r\nfirst = 0\r\nsecond = 0\r\nidx = 0\r\nfor i in range(n):\r\n if lst[i] > first:\r\n second = first\r\n first = lst[i]\r\n idx = i\r\n if lst[i] > second and lst[i] < first:\r\n second = lst[i]\r\nprint(idx+1, second)\r\n \r\n ", "n=int(input())\r\np=list(map(int,input().split()))\r\na=sorted(p,reverse=True)[1]\r\nprint(*[p.index(max(p))+1,a])\r\n\r\n \r\n \r\n", "bidders = int(input())\r\nbids = [int(x) for x in input().split(\" \")]\r\n\r\nwinner = bids.index(max(bids)) + 1\r\nbids.remove(max(bids))\r\nprice = max(bids)\r\n\r\nprint(winner, price)\r\n", "import sys\r\ninput=sys.stdin.buffer.readline\r\n\r\n\r\nn=int(input())\r\narr=list(map(int,input().split()))\r\npos=arr.index(max(arr))+1\r\narr.sort(reverse=True)\r\nprint(pos,arr[1])", "no_of_bidders=int(input())\r\nbidder_price_list=[]\r\nbidder_price_list=list(map(int,input().strip().split()))[:no_of_bidders]\r\nwinner_index=0\r\nwinner=0\r\nfor i in range(no_of_bidders):\r\n if bidder_price_list[i]>winner:\r\n winner=bidder_price_list[i]\r\n winner_index=i\r\nbidder_price_list.pop(winner_index)\r\nsecond_price=max(bidder_price_list)\r\nprint(winner_index+1,end=\" \")\r\nprint(second_price,end=\" \")", "from operator import index\r\n\r\n\r\nt = int(input())\r\na = map(int,input().split())\r\na = list(a)\r\nx = a.index(max(a))\r\na.sort()\r\nprint(x+1, a[-2])", "input()\r\np = list(enumerate(map(int, input().split()), 1))\r\np.sort(key = lambda i: i[1])\r\nprint(p[-1][0], p[-2][1])", "#!/usr/bin/env python\n# coding=utf-8\n'''\nAuthor: Deean\nDate: 2021-12-01 23:14:16\nLastEditTime: 2021-12-01 23:17:31\nDescription: Second-Price Auction\nFilePath: CF386A.py\n'''\n\n\ndef func():\n n = int(input())\n lst = list(map(int, input().strip().split()))\n ans1 = lst.index(max(lst)) + 1\n lst.remove(max(lst))\n ans2 = max(lst)\n print(ans1, ans2)\n\n\nif __name__ == '__main__':\n func()\n", "n=int(input())\r\nc1=input().split(\" \")\r\nlist=[]\r\nfor i in c1:\r\n list.append(int(i))\r\n \r\nmx=max(list)\r\ni=list.index(mx)\r\nlist.remove(mx)\r\nmx1=max(list)\r\nprint(i+1,int(mx1))", "num_of_prices = int(input())\r\nlst = [int(x) for x in input().split(\" \")]\r\n\r\nsecond_max = lst[1] \r\ncurrent_max_index = 0\r\nfor i in range(1, num_of_prices):\r\n if lst[current_max_index] < lst[i]:\r\n second_max = lst[current_max_index]\r\n current_max_index = i\r\n elif lst[i] > second_max:\r\n second_max = lst[i]\r\n\r\nprint(current_max_index+1, second_max)", "n = int(input())\r\nsp = list(map(int, input().split()))\r\nmaxi = sp.index(max(sp))\r\nsort_sp = sorted(sp)\r\nprint(maxi + 1, sort_sp[-2])", "n = int(input())\nprices = list(map(int, input().split()))\nmaxPrice = max(prices)\nmaxInd = prices.index(maxPrice) + 1\nprices.remove(maxPrice)\nsecondMax = max(prices)\nprint(maxInd, secondMax)", "x=int(input())\r\nl=list(map(int,input().split()))\r\nc=l.index(max(l))+1\r\nl.remove(max(l))\r\nprint(c,max(l))\r\n", "N=int(input())\r\nA=list(map(int,input().split()))\r\nVal=A.index(max(A))+1\r\nA.sort(reverse=True)\r\nprint(Val, A[1])", "n = int(input())\r\nps = list(map(int,input().split()))\r\n\r\nif ps[0] < ps[1]:\r\n f = 1\r\n s = 0\r\nelse:\r\n f = 0\r\n s = 1 \r\n \r\nfor i in range(2,n):\r\n \r\n if ps[i] > ps[f]:\r\n s = f\r\n f = i\r\n \r\n elif ps[i] > ps[s]:\r\n s = i\r\n \r\nprint(f + 1, ps[s])\r\n", "x=int(input())\nl=list(map(int,input().split()))\nmaxi=max(l)\n#print(maxi)\nans1=l.index(maxi)\n#print(ans1)\nl.remove(maxi)\n#print(l)\nans2=max(l)\nprint(ans1+1,ans2)\n \n \t \t \t\t\t \t \t\t\t\t \t\t \t", "# import sys\r\n# sys.stdin = open(\"test.in\",\"r\")\r\n# sys.stdout = open(\"test.out.py\",\"w\")\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nb=list(sorted(a))\r\nprint(a.index(b[-1])+1,b[-2])", "n=int(input())\r\nl=list(map(int,input().split()))\r\nm=max(l)\r\nprint(l.index(m)+1,end=' ')\r\nl.remove(m)\r\nprint(max(l))", "#!/usr/bin/env python\r\n\r\nimport math\r\nimport sys\r\nimport itertools\r\nimport fractions\r\n\r\nif __name__ == '__main__':\r\n wtf = sys.stdin.read()\r\n wtf = wtf.strip().split('\\n')\r\n n = int(wtf[0])\r\n P = list(map(int, wtf[1].split()))\r\n a = P.index(max(P))\r\n b = max([p for i,p in enumerate(P) if i!= a])\r\n print(a+1,b)\r\n", "b = int(input())\r\na = input().split()\r\nfor i in range(len(a)):\r\n a[i] = int(a[i])\r\ns = a.index(max(a))\r\na.pop(s)\r\nprint(s+1,max(a))", "a = input()\r\nb = list(map(int, input().split()))\r\nlol_ = []\r\n\r\nlol_.append(b.copy())\r\n\r\n\r\nc = max(b)\r\n\r\nloc_ = b.index(c) + 1\r\n\r\nb.remove(c)\r\n\r\nsecond_ = max(b)\r\n\r\nprint(f'{loc_} {second_}')", "n = int(input())\r\nprice = list(map(int, input().split()))\r\nf_h = -9999\r\ns_h = -9999\r\nfor i in range(len(price)):\r\n if price[i] > f_h:\r\n s_h = f_h\r\n f_h = price[i]\r\n idx = price.index(f_h) + 1\r\n elif price[i] >= s_h:\r\n s_h = price[i]\r\nprint(idx, s_h)\r\n", "# --------------------------------#\r\n#-----------<HajLorenzo>-----------\r\n#Most Important Thing About Life\r\n#Is Loving What You Do...\r\n# --------------------------------#\r\n\r\nn=int(input())\r\ndfx=list(map(int,input().split()))\r\nprint(dfx.index(sorted(dfx)[n-1])+1,sorted(dfx)[n-2])\r\n\r\n#Short But Not Optimized :)\r\n#Dahanet Mehrdad bade accept didam daghigan mesl ham zaim :\\", "n = int(input())\r\nprice_list = list(map(int, input().split()))\r\n# all values are unique\r\n\r\nmax_price = 0\r\nmax_index = 0\r\nsecond_max_price = 0\r\n\r\nmax_price = max(price_list) # find the max value\r\nmax_index = price_list.index(max_price) # find the index of the max value\r\nmax_index += 1 # to follow the answer format that the index starts from 1 \r\n\r\nprice_list.remove(max_price) # remove the max price from the list\r\nsecond_max_price = max(price_list) # now this gives the second max value\r\n\r\nprint(max_index, second_max_price)", "n=int(input())\r\nl=list(map(int,input().split()))\r\np=l.copy()\r\nl.sort()\r\nprint(p.index(l[-1])+1,l[-2])", "n = int(input())\r\nbid = list(map(int, input().split()))\r\nprint(str(bid.index(max(bid)) + 1) + ' ' + str(sorted(bid)[-2]))", "n=int(input())\r\nl=list(map(int,input().split()))\r\nk=sorted(l)\r\nprint(l.index(k[n-1])+1,k[n-2])\r\n", "m = int(input())\r\nz = [int(i) for i in input().split()]\r\nc = z[:]\r\nc.sort()\r\nprint(z.index(c[-1])+1, c[-2])", "n = int(input())\r\na = list(map(int, input().split()))\r\np = a.index(max(a))\r\na.pop(p)\r\nprint(p+1, max(a))", "n=int(input())\r\nlst=[int(i) for i in input().split()]\r\nmax1=max(lst)\r\nd=lst.index(max1)+1\r\nlst.remove(max1)\r\nprint(d,max(lst))\r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\n\r\np=l.copy()\r\np.sort()\r\n\r\ni=l.index(max(p))+1\r\nj=p[-2]\r\n\r\nprint(i,j)\r\n", "a=int(input())\r\nb=list(map(int,input().split()))\r\nc=[b.index(max(b))+1]\r\nc+=[sorted(b)[-2]]\r\nprint(*c)\r\n", "count = int(input())\nprices = [int(p) for p in input().split()]\nwinner = prices.index(max(prices))\nprices.insert(winner, -1)\nprices.remove(max(prices))\nprint(winner + 1, max(prices))\n\n", "input()\npriceList = list(map(int, input().split()))\n\nmax = 0\nmaxindex = 0\nsecondmax = 0\n\nfor i in range(len(priceList)):\n if priceList[i] > max:\n maxindex = i + 1\n max = priceList[i]\n\nfor price in priceList:\n if price < max and price >= secondmax:\n secondmax = price\n\nprint(maxindex, secondmax)", "n = int(input())\nL = list(map(int, input().split()))\nind = L.index(max(L))\nL.pop(ind)\nprint(ind+1, max(L))\n \t \t\t \t \t \t\t\t \t \t \t", "number_of_bidders=int(input())\r\nlists = list(map(int, input().split()))\r\n\r\nindex_to_highest_bidder=lists.index(max(lists))\r\nlists.remove(max(lists))\r\n \r\nprint (index_to_highest_bidder+1, max(lists))", "n,m=int(input()),{}\r\np=list(map(int,input().split()))[:n]\r\nm={x:i for i,x in enumerate(p)}\r\nm=dict(sorted(m.items()))\r\nprint(m[list(m)[-1]]+1,list(m)[n-2])", "n=int(input())\r\na=list(map(int,input().split()))\r\nd=sorted(a)\r\nf=d[-2]\r\nprint(a.index(max(a))+1,f)\r\n", "nums=int(input())\r\na=list(map(int, input().split()))\r\n\r\nm=a[0];mi=0 #m=Largest bid; mi=index of largest bid\r\nn=0\t#Second largest number\r\n\r\nfor i in range(1, nums):\r\n\tif a[i]>=m:\r\n\t\tn=m #Second largest bacomes equal to the previous largest one\r\n\t\tm=a[i] #New largest number\r\n\t\tmi=i #index of the largest bid\r\n\telse:\r\n\t\tif a[i]>=n:\r\n\t\t\tn=a[i] #Second largest number changes if there exists a number between 'n' and 'm'\r\nprint(mi+1, n)", "n = int(input())\r\na = list(input().split())\r\nmx = -1\r\nmx2 = -1\r\npos = -1\r\nfor i in range(0, n):\r\n\ta[i] = int(a[i])\r\n\tif(a[i] > mx):\r\n\t\tmx2 = mx\r\n\t\tpos = i + 1\r\n\t\tmx = a[i]\r\n\telif(a[i] > mx2):\r\n\t\tmx2 = a[i]\r\n\ti = i + 1\r\nprint(str(pos) + ' ' + str(mx2))", "n=int(input())\na=[int(no) for no in input().split(' ')]\nb=sorted(a)\nprint(a.index(max(a))+1,b[-2])\n\t \t\t\t \t\t\t\t \t\t \t \t\t \t \t", "n = int(input())\r\np = list(map(int, input().split()))\r\ni = p.index(max(p))\r\nprint(i + 1, max(p[:i] + p[i + 1:]))", "def whoWins():\r\n n = int (input())\r\n s = list(map(int, input(). split ()))\r\n maxii = max(s)\r\n p = s.index(maxii)+1\r\n s.remove(maxii)\r\n maxii2 = max(s)\r\n print(f'{p} {maxii2}')\r\nwhoWins()", "n=int(input())\r\nl=list(map(int,input().split()))\r\nmax1=max(l)\r\nmax2=0\r\nfor i in l:\r\n\tif i>max2 and i!=max1:\r\n\t\tmax2=i\r\nprint((l.index(max1))+1,max2)", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=-1\r\nc=-1\r\nd=a[:]\r\nfor i in range(n):\r\n if(a[i]>c):\r\n c=a[i]\r\n b=i+1\r\nd.sort()\r\nprint(b,d[-2])", "n = int(input())\r\nl = list(map(int,input().split()))\r\ni = l.index(max(l))+1\r\nl.remove(max(l))\r\nprint(i,max(l))", "n = int(input())\r\np = input().split()\r\nindex = 0\r\nbid2 = 0\r\nbid = 0\r\nfor i in range(len(p)):\r\n if int(p[i])>bid:\r\n bid=int(p[i])\r\n index=i+1\r\nfor i in range(len(p)):\r\n if int(p[i])>bid2 and int(p[i])!=bid:\r\n bid2=int(p[i])\r\nprint(index,bid2)", "a = int(input())\nprices = list(map(int, input().split()))\n\nhighestbidder = prices.index(max(prices)) + 1\n\nprice2 = sorted(prices)\n\nprint(highestbidder, (price2[-2]))\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nx=a.index(max(a))+1\r\na.remove(max(a))\r\nprint(x,max(a))\r\n", "n=int(input())\r\np=input().split()\r\np1=[int(x) for x in p]\r\nmax_value=-99999999\r\nmax_index=-1\r\nfinal_price=-9999999\r\nfor i in range(0,len(p1)):\r\n if p1[i]>max_value:\r\n max_value=p1[i]\r\n max_index=i\r\nfor i in range(0,len(p1)): \r\n if p1[i]>final_price and i!=max_index:\r\n final_price=p1[i]\r\nprint(max_index+1,final_price) ", "n = int(input())\r\nv = list(map(int, input().split()))\r\n\r\nret = max(v)\r\nidx = v.index(ret)\r\nv[idx] = -1\r\nret = max(v)\r\n\r\nprint(str(idx + 1) + ' ' + str(ret))\r\n", "n=int(input())\r\narr=list(map(int,input().split(' ')))\r\nmx=max(arr)\r\nwin=arr.index(mx)\r\nprint(win+1,end=' ')\r\narr[win]=0\r\nprint(max(arr))", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\ndata = sorted(zip(map(int, input().split()), range(n)), reverse=True)\r\n\r\nprint(data[0][1] + 1, data[1][0])", "n=int(input())\r\nl=list(int(x) for x in input().split())\r\ns=sorted(l,reverse=True)\r\ni=l.index(s[0])+1\r\nprint(i,s[1])", "def main():\n n = int(input())\n prices = [int(num) for num in input().split()]\n\n maxPrice = max(prices)\n maxPriceIndex = prices.index(maxPrice)\n prices.pop(maxPriceIndex)\n\n secondPrice = max(prices)\n\n print(str(maxPriceIndex + 1) + \" \" + str(secondPrice))\n\nmain()\n \t \t \t\t\t\t \t\t \t \t \t \t \t\t", "n = int(input())\r\np = input().split(\" \")\r\nplayers = []\r\n\r\nfor i in p:\r\n i = int(i)\r\n players.append(i)\r\n\r\nplayer = sorted(players)\r\n\r\nplayer_number = p.index(str(player[-1])) + 1\r\nprice = player[-2]\r\n\r\nprint(player_number, price)\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\nb = []\r\nfor i in range(n):\r\n b.append([a[i], i])\r\nb.sort(reverse=True)\r\nprint(b[0][1] + 1, b[1][0])", "n = int(input())\r\nlist1 = list(map(int, input().split()))\r\nmax_price = max(list1)\r\nindex = 0\r\nprice_to_pay = 0\r\nfor i in range(n):\r\n if list1[i] == max_price:\r\n index = i\r\n if list1[i] > price_to_pay and list1[i] != max_price:\r\n price_to_pay = list1[i]\r\nprint(index+1, price_to_pay)", "n = int(input())\r\nl = list(map(int,input().split()))\r\na = l.index(max(l))\r\nl.remove(max(l))\r\nprint(a+1,max(l))", "t=int(input())\r\narr=list(map(int,input().split()))\r\nprint(arr.index(max(arr))+1,end=\" \")\r\narr.remove(max(arr))\r\nprint(max(arr))", "n = int(input())\r\na= list(map(int,input().split()))\r\nz = a.index(max(a))+1\r\na.sort()\r\nprint(z,a[-2])", "n = int(input())\r\na = list(map(int, input().split()))\r\nz = []\r\nfor i in range(n):\r\n z.append([a[i], i + 1])\r\nz.sort()\r\n\r\nprint(z[-1][1], z[-2][0])\r\n", "input()\r\na=[*map(int,input().split())]\r\nprint(a.index(max(a))+1,sorted(a)[-2])", "# Problem: A. Second-Price Auction\r\n# Contest: Codeforces - Testing Round #9\r\n# URL: https://codeforces.com/problemset/problem/386/A\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\n\"\"\" Python 3 compatibility tools. \"\"\"\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\n\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\n\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\n\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\ndef debug(*args,**kwargs):\r\n '''Debug print'''\r\n print(*args,**kwargs)\r\n pass\r\n\r\nn = inp()\r\np = inlt()\r\n\r\nwinner = max(p)\r\nwinner_index = p.index(winner)\r\n\r\np.sort()\r\np[-1] = 0\r\nwinning_price = max(p)\r\n\r\nprint(winner_index + 1, winning_price)\r\n ", "n = int(input())\r\nbids = list(map(int, input().split()))\r\n\r\nwinner = max(bids)\r\nsecond_highest = max(bid for bid in bids if bid != winner)\r\n\r\nprint(bids.index(winner) + 1, second_highest)", "n = int(input())\r\ns = input().split()\r\nmi = 0\r\nm1 = int(s[0])\r\nm2 = 0\r\nfor i in range(1, n):\r\n p = int(s[i])\r\n if p > m1:\r\n m1, m2, mi = p, m1, i\r\n elif p > m2:\r\n m2 = p\r\nprint(f'{mi+1} {m2}')\r\n", "input()\r\ndata = map(int, input().split())\r\n\r\na = next(data)\r\nb = next(data)\r\n\r\nif a > b:\r\n m1 = a\r\n mi1 = 1\r\n m2 = b\r\nelse:\r\n m1 = b\r\n mi1 = 2\r\n m2 = a \r\n\r\nfor i, v in enumerate(data):\r\n if v > m1:\r\n m1, m2, mi1 = v, m1, i + 3\r\n elif v > m2:\r\n m2 = v\r\n\r\nprint(mi1, m2)\r\n", "n = int(input())\r\narray = list(map(int, input().split()))\r\n\r\nmax_el_1 = array[0]\r\nmax_ind_1 = 0\r\n\r\nmax_el_2 = -1\r\n\r\nfor i in range(1, n):\r\n if array[i] > max_el_1:\r\n max_ind_1 = i\r\n max_el_2 = max_el_1\r\n max_el_1 = array[i]\r\n \r\n if array[i] > max_el_2 and array[i] < max_el_1:\r\n max_el_2 = array[i]\r\n\r\nprint(max_ind_1+1, max_el_2)\r\n", "\r\nimport builtins\r\nimport sys\r\nimport math\r\nimport re\r\nimport itertools\r\nimport collections\r\nimport random\r\n\r\n# with open('testcase.txt', 'r') as stdin:\r\n\r\nn = int(input())\r\nbidders = tuple(i for i in map(int, input().split()))\r\ns = set(bidders)\r\nhighest = max(s)\r\nwinner = bidders.index(highest) + 1\r\ns.remove(highest)\r\npay = max(s) \r\nprint(winner, pay)\r\n\r\n \r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n", "n = int(input())\r\nnums = list(map(int, input().split()))\r\nmydict = dict()\r\nfor i, val in enumerate(nums):\r\n mydict[val] = i+1\r\nnums.sort()\r\nprint(mydict[nums[-1]], nums[-2])", "n = int(input())\nbids = [int(i) for i in input().split()]\n\nindex = max((x,i) for i,x in enumerate(bids))[1]\nbids.pop(index)\nindex=index+1\nprint(str(index) + \" \" + str(max(bids)))", "input()\r\nX = list(map(int, input().split()))\r\nprint(X.index(sorted(X)[-1]) + 1, sorted(X)[-2])", "n=int(input())\r\na=list(map(int,input().split()))\r\nif a[0]>a[1]:\r\n i=0\r\n j=1\r\nelse:\r\n j=0\r\n i=1\r\nfor k in range(2,n):\r\n if a[k]>a[i]:\r\n j=i\r\n i=k\r\n elif a[k]>a[j]:\r\n j=k\r\nprint(i+1,a[j])", "input()\r\nl=list(map(int,input().split()))\r\nll=sorted(l,reverse=True)\r\nprint(l.index(ll[0])+1,\" \",ll[1])", "n = int(input())\nl = [a for a in enumerate(list(map(int, input().split())))]\nl.sort(key=lambda x: x[1])\nprint(int(l[len(l)-1][0])+1, end=' ')\nprint(int(l[len(l)-2][1]))\n\t\t\t\t\t \t \t\t\t \t \t\t \t\t\t \t \t", "n = int(input())\na = list(map(int, input().split()))\nx = sorted(enumerate(a), key = lambda y:y[1])\nprint(x[n-1][0]+1, x[n-2][1])", "n = int(input())\r\np = input().split()\r\nl = [int(x) for x in p]\r\nbig = 0\r\nindex = 0\r\nfor i in range(len(l)):\r\n if l[i] > big:\r\n index = i + 1\r\n big = l[i]\r\nl.sort()\r\nprint(index,l[-2])", "n=int(input())\r\np=[int(p) for p in input().split()]\r\nind=p.index(max(p))\r\np.sort()\r\nprint(ind+1,p[len(p)-2])", "read = lambda: map(int, input().split())\r\nn = int(input())\r\np = list(read())\r\nMax = max(p)\r\nind = p.index(Max) + 1\r\np.remove(Max)\r\nMax2 = max(p)\r\nprint(ind, Max2)\r\n", "x=int(input())\r\ny=list(input().split())\r\ny=[int(i) for i in y]\r\na=sorted(y)\r\nmax=a[x-1]\r\nprint(y.index(max)+1,a[x-2])\r\n", "c=int(input())\r\nn=input()\r\nl= n.split()\r\nfor i in range(0,c):\r\n l[i]=int(l[i])\r\nprint(l.index(max(l))+1,end=\" \")\r\nl.sort()\r\nl.pop()\r\nprint(max(l))\r\n", "n = int(str(input()))\r\nbiddersList = [int(x) for x in str(input()).split(\" \")] \r\ngreatestBid = max(biddersList)\r\n\r\nindex = biddersList.index(greatestBid) + 1\r\nbiddersList.pop(index-1)\r\n\r\nbid2 = max(biddersList)\r\n\r\n\r\n\r\nprint(index,bid2)", "input()\r\nprices = [int(x) for x in input().split()]\r\nmaxp = 0\r\nfor x in range(len(prices)):\r\n if prices[x] > prices[maxp]:\r\n maxp = x\r\nprices.remove(prices[maxp])\r\nsec = prices[0]\r\nfor x in prices:\r\n if x > sec:\r\n sec = x\r\nprint(maxp + 1, sec)", "n = int(input())\r\nli = list(map(int,input().split()))\r\na = li.index(max(li))+1\r\nli.remove(max(li))\r\nprint(str(a)+\" \"+str(max(li)))\r\n", "u = int(input())\r\nprices = list(map(int, input().split()))\r\n\r\nwinner_idx = prices.index(max(prices))\r\nsecond_highest_price = max(prices[:winner_idx] + prices[winner_idx + 1:])\r\n\r\nprint(winner_idx + 1, second_highest_price)", "n=int(input())\r\nl=list(map(int,input().split()))\r\nx=l.index(max(l))+1\r\nl.sort()\r\nprint(x,l[n-2])\r\n", "n = int(input())\r\np = list(map(int,input().split()))\r\nll = p.index(max(p))\r\np.pop(ll)\r\nprint(ll+1,max(p))", "n=int(input())\r\nbids=list(map(int,input().split()))\r\norder=tuple(bids)\r\nbids.sort()\r\nhigh1=bids[n-1]\r\nhigh2=bids[n-2]\r\nindex=order.index(high1)\r\nprint(index+1,high2)", "n = int(input())\r\np = list(map(int,input().split()))\r\nfor i in range(n):\r\n if p[i] == max(p):\r\n del p[i]\r\n print(i + 1,max(p))\r\n break", "b = int(input())\r\narr = list(map(int, input().split()))\r\nmax_num = 0\r\nfor i in range(len(arr)):\r\n if arr[i] > max_num:\r\n max_num = arr[i]\r\n\r\ndef secondmax(arr):\r\n sublist = [x for x in arr if x < max(arr)]\r\n return max(sublist)\r\n\r\nprint(arr.index(max_num)+1, secondmax(arr))", "n=int(input())\r\na=list(map(int,input().split()))\r\nx=a.index(max(a))+1\r\na.sort()\r\ny=a[-2]\r\nprint(x,y)", "n=int(input())\r\na=list(map(int,input().split(\" \")))\r\nk=a.index(max(a))\r\na.remove(max(a))\r\nl=max(a)\r\nprint(k+1,l)", "from sys import stdin\r\ninp = stdin.readline\r\n\r\nn = int(inp())\r\narr = [int(x) for x in inp().split()]\r\n\r\nwin = arr.index(max(arr))\r\n\r\narr.pop(win)\r\n\r\nprint(win+1, max(arr))\r\n", "\r\nn = int(input())\r\nl = list(map(int, input().split()))\r\n\r\nind = l.index(max(l))\r\nl.pop(ind)\r\nprint(ind + 1, max(l))", "n = int(input())\r\np = list(map(int, input().split()))\r\nprint(p.index(max(p))+1, end = ' ')\r\np.remove(max(p))\r\nprint(max(p))", "n = int(input())\r\narr = list(map(int, input().split()))\r\narr1 = sorted(arr)\r\nprint(arr.index(arr1[n - 1]) + 1, arr1[n - 2])\r\n", "n = int(input())\r\np = list(map(int, input().split()))\r\nprint(p.index(max(p)) + 1, sorted(p)[-2])", "n = int(input())\r\na = list(map(int, input().split(maxsplit=n)))\r\nm = max(a[i] for i in range(n))\r\nneeded_number = 0\r\nfor i in range(n):\r\n if a[i] == m:\r\n needed_number = i+1\r\na.sort()\r\nprint(needed_number, a[-2])", "from sys import stdin, stdout\r\n\r\nwinner, price = 0, 0\r\npeople = int(stdin.readline().rstrip())\r\n\r\nbets = [int(x) for x in stdin.readline().rstrip().split()]\r\n\r\nwinner = bets.index(max(bets)) + 1\r\n\r\nbets.pop(winner - 1)\r\nprice = max(bets)\r\nreturned = str(winner) + \" \" + str(price)\r\nstdout.write(returned)\r\n", "n =int(input())\nx = list(map(int,input().split()))\nmax_1 = max(x)\nindex = x.index(max_1)\nx.remove(max_1)\nmax_2=max(x)\nprint(index+1,max_2)\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nm=max(l)\r\npos=l.index(m)+1\r\nl.remove(m)\r\nprice=max(l)\r\nprint(pos,price)", "n = int(input())\r\na = [int(c) for c in input().split()]\r\nx = a.index(max(a))\r\na = a[:x] + a[x+1:]\r\nprint(x+1, max(a))", "n=int(input())\r\np=[int(i) for i in input().split()]\r\nz=max(p)\r\nz1=p.index(z)\r\np.pop(z1)\r\nz2=max(p)\r\nprint(z1+1,z2)", "n = int(input())\r\np = list(map(int, input().split()))\r\nx = max(p)\r\nindex_to_highest_bidder = p.index(x)\r\np.remove(max(p))\r\nsecond_highest_price = max(p)\r\nprint(index_to_highest_bidder+1, second_highest_price)", "n=int(input())\r\na=list(map(int,input().split()))\r\nm=[]\r\nfor i in range(n):\r\n\tk=[i+1, a[i]]\r\n\tm.append(k)\r\nm.sort(key= lambda m: m[1])\r\nm=m[::-1]\r\nprint(m[0][0],m[1][1])", "n = int(input())\r\np = list(map(int,input().split()))\r\n\r\ns = \"\"\r\ns+= str(p.index(max(p))+1)+\" \"\r\n\r\np.sort(reverse=True)\r\ns+= str(p[1])\r\nprint(s)", "def findmax(array):\n maximum = -1\n for j in range(0, len(array)):\n maximum = max(array[j], maximum)\n return maximum\n\n\nn = int(input())\narr = [int(x) for x in input().split()]\nmax_fst = findmax(arr)\nindx_max = -1\nfor i in range(0, n):\n if max_fst == arr[i]:\n arr[i] = 0\n indx_max = i + 1\n break\nmax_scnd = findmax(arr)\nprint(indx_max, max_scnd)\n", "n=int(input())\r\np=list(map(int,input().split()))\r\nprint(p.index(max(p))+1,end=' ')\r\np.remove(max(p))\r\nprint(max(p))", "garbage = int(input())\r\nz = list(map(int, input().rstrip().split(' ')))\r\nind = z.index(max(z))\r\nz.sort()\r\nres = z[-2]\r\nprint(ind+1, res)", "input()\r\nl=list(map(int,input().split()))\r\na=l.index(max(l))\r\nl.remove(max(l))\r\nl.sort()\r\nprint(a+1,l[-1],sep=' ')\r\n\r\n\r\n", "ans = 0\r\nn = int(input())\r\nl = list(map(int,input().split()))\r\n\r\nfor i in range(len(l)):\r\n\tif l[i] == max(l):\r\n\t\tl[i] = 0\r\n\t\tans = i+1\r\n\t\tbreak\r\n\t\t\r\n\r\nprint(ans,\"\",max(l))\r\n\r\n\r\n\r\n", "n=int(input())\r\np=list(map(int,input().strip().split()[:n]))\r\nk=p.index(max(p))+1\r\np.remove(max(p))\r\nprint(k,max(p))", "#Second-Price Auction\r\nn = int(input())\r\np = [int(x) for x in input().split()]\r\n# output should be 1-based indexing\r\n# p consists of n distinct positive integers\r\nind = p.index(max(p)) + 1\r\np.pop(ind-1)\r\nprice = max(p)\r\nprint(ind, price)", "n = int(input().strip())\na = [int(i) for i in input().strip().split()]\nb = a[:]\nb.sort()\np = b[-2]\nw = a.index(b[-1]) + 1\nprint(w, p)\n\n\t \t\t \t\t\t \t \t \t \t \t \t\t", "import heapq\r\n\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\n\r\nq = heapq.nlargest(2, enumerate(a), key= lambda e: e[1])\r\n\r\ni = 1 + q[0][0]\r\nx = q[1][1]\r\n\r\nprint(i, x)", "n = int(input())\r\noffered_price = list(map(int, input().split()))\r\n\r\nmax_bid = max(offered_price)\r\nindex = offered_price.index(max_bid)\r\noffered_price.sort()\r\nsecondmax = offered_price[-2]\r\nprint(index+1, secondmax)", "fast=lambda:stdin.readline().strip()\r\nzzz=lambda:[int(i) for i in fast().split()]\r\nz,zz=input,lambda:list(map(int,z().split()))\r\nszz,graph,mod,szzz=lambda:sorted(zz()),{},10**9+7,lambda:sorted(zzz())\r\nfrom re import *\r\nfrom sys import *\r\nfrom math import *\r\nfrom heapq import *\r\nfrom queue import *\r\nfrom bisect import *\r\nfrom string import *\r\nfrom itertools import *\r\nfrom collections import *\r\nfrom math import factorial as f\r\nfrom bisect import bisect as bs\r\nfrom bisect import bisect_left as bsl\r\nfrom collections import Counter as cc\r\nfrom itertools import accumulate as ac\r\ndef lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2))\r\ndef output(answer):stdout.write(str(answer))\r\n###########################---Test-Case---#################################\r\n\"\"\"\r\n\r\n If you Know me , Then you probably don't know me !\r\n\r\n\r\n\"\"\"\r\n###########################---START-CODING---##############################\r\n\r\nz();arr=zzz()\r\nlst=[]\r\nfor i,j in enumerate(arr):\r\n lst.append((j,i+1))\r\nlst=sorted(lst)[::-1]\r\nprint(lst[0][1],lst[1][0])\r\n\r\n\r\n", "if __name__ == \"__main__\":\n\tn = int(input())\n\toffers = list(int(x) for x in input().split())\n\n\twinner_pos = offers.index(max(offers))\n\n\toffers.pop(winner_pos)\n\n\tprice_to_pay = max(offers)\n\n\tprint(winner_pos+1, price_to_pay)\n\t \t\t \t\t \t\t\t \t\t \t\t\t \t\t \t \t\t", "n = int(input())\r\nl = list(map(int,input().split()))\r\nl2=sorted(l)\r\nm1 = l2[-1]\r\nm2 = l2[-2]\r\npm1 = 0\r\nfor i in range(len(l)):\r\n if l[i] == m1:\r\n pm1 = i\r\nprint(pm1 + 1,m2)", "n=int(input())\r\na=list(map(int,input().split()))\r\nM=a[0]\r\nL=0\r\nB=0\r\nfor i in range(1,n):\r\n if a[i]>=M:\r\n B=M\r\n M=a[i]\r\n L=i\r\n elif a[i]>B:\r\n B=a[i]\r\nprint(L+1,B)", "n=int(input())\r\nl=list(map(int,input().split()))\r\nl1=max(l)\r\ng=(l.index(l1))\r\nl.sort()\r\nprint(g+1,l[-2])", "\n\nn = int(input())\narr = list(map(int, input().rstrip().split()))\n\na = max(arr)\ncount = 0\nfor i in range(n):\n if arr[i] == a:\n count += i+1\narr.sort()\nc = arr[n-2]\n\nprint(count , c)\n\n\n \n \n\n", "n = int(input())\r\na = list(map(int, input().split( )))\r\nmax1 = 0\r\nmax2 = 0\r\nmaxi = 0\r\nfor i in range(n):\r\n if(a[i] > max1):\r\n max2 = max1\r\n max1 = a[i]\r\n maxi = i+1\r\n elif(a[i] > max2):\r\n max2 = a[i]\r\nprint(str(maxi) + \" \" + str(max2))", "n=int(input())\nbidders=list(map(int , input().split()))\nmaxof=max(bidders)\nindex=bidders.index(maxof)+1\nbidders.remove(maxof)\nmax2=max(bidders)\nprint(str(index) + ' ' + str(max2) )\n\n\t\t\t \t \t\t\t \t\t \t\t\t\t \t\t \t\t", "#In the name of God\nn = int(input())\nlst = list(map(int, input().split()))\nq = lst.index(max(lst)) + 1\nlst.sort()\np = lst[-2]\nprint(q, p)\n", "n = int(input())\r\nidk = input()\r\na = [int(i) for i in idk.split()]\r\nres, res1, pos = 0, 0, 0\r\nfor i in range (0, n):\r\n if a[i] > res:\r\n res = a[i]\r\n pos = i\r\nfor i in range (0, n):\r\n if i == pos:\r\n continue\r\n if a[i] > res1:\r\n res1 = a[i]\r\nprint(str(pos + 1) + \" \" + str(res1))", "n=int(input())\r\nli_st=list(map(int, input().split()))\r\nmax1=max(li_st)\r\nposition=li_st.index(max1)\r\nli_st.remove(max1)\r\nmax2=max(li_st)\r\nprint(position+1,max2)", "n = input()\r\nn = int(n)\r\n\r\nL = input().split()\r\n\r\nfor i in range(len(L)):\r\n L[i] = int(L[i])\r\n \r\nbidder = L.index(max(L)) + 1\r\n\r\nL.sort()\r\n\r\nprice = L[-2]\r\n\r\nprint(bidder, price)", "n = int(input())\r\narr = list(map(int, input().split()))\r\nmax_index = arr.index(max(arr)) + 1\r\narr.remove(max(arr))\r\nprint(max_index, max(arr))\r\n", "n= int(input())\r\nl=list(map(int, input().split()))\r\nm= max(l)\r\nfor i in range(n):\r\n if l[i]==m:\r\n print(i+1, end=' ')\r\n\r\nl.sort()\r\nprint(l[-2])\r\n", "n = int(input())\nbids = list(map(int, input().split()))\npeople = bids.copy()\nlarge = max(people)\npeople.remove(large)\ncountser = bids.index(max(bids))\nprint((countser+1),max(people))", "n=int(input())\narr=list(map(int, input().split()))\nwin=max(arr)\nprint(arr.index(win)+1, end=\" \")\narr.remove(win)\nprint(max(arr))\n \t \t\t\t \t \t\t \t \t \t \t\t \t \t", "def second_price_audition():\n bidders = int(input())\n precos = list(map(int,input().split()))\n print(str(precos.index(max(precos))+1) + ' ' + str(max(precos[0:precos.index(max(precos))]+precos[precos.index(max(precos))+1:])))\n\nsecond_price_audition()\n\n\n\t\t\t\t \t \t \t\t \t\t\t", "\r\n\r\n\r\nn =input()\r\nli =list(map(int,input().split()))\r\nstore_value = li\r\ntemp =sorted(li)\r\n\r\n\r\nprint(store_value.index(max(store_value))+1,temp[-2])\r\n\r\n\r\n", "n=int(input())\r\nprices=list(map(int,input().split()))\r\nindex=None\r\nwin=0\r\nfor i in range(n):\r\n win=max(win,prices[i])\r\nprint(prices.index(win)+1,end=' ')\r\nprices.remove(win)\r\nwin=0\r\nfor i in range(n-1):\r\n win=max(win,prices[i])\r\nprint(win)", "n = int(input())\nbids = list(map(int, input().split()))\nwinner_pos = 0\namount = 0\n \nfor i in range(0, len(bids)):\n if bids[i] > amount:\n amount = bids[i]\n winner_pos = i + 1\nbids.sort()\nprint(\"%i %i\" % (winner_pos, bids[-2]))\n\t\t \t\t\t\t \t \t\t\t\t\t \t\t\t\t\t\t", "n = input()\r\nlst = list(map(int, input().split(\" \")))\r\nm, sm = 0, 0\r\nind = 0\r\nfor i in range(len(lst)):\r\n if lst[i] > m:\r\n sm = m\r\n m = lst[i]\r\n ind = i\r\n elif lst[i] > sm:\r\n sm = lst[i]\r\nprint(ind+1, sm)\r\n", "n = int(input())\r\na = [int(c) for c in input().split()]\r\nprint(a.index(max(a))+1,end=' ')\r\na.sort()\r\nprint(a[-2])\r\n", "input()\r\nl=list(map(int,input().split()))\r\nk=sorted(l)\r\nprint(1+l.index(k[-1]),k[-2])", "n=int(input())\r\nx=[int(x) for x in input().split()]\r\ni=x.index(max(x))\r\nx.remove(max(x))\r\nprint(i+1,max(x))", "n=int(input())\r\na=list(map(int,input().split()))\r\nans=0\r\nres=0\r\nrem=0\r\nfor i in range(0,len(a)):\r\n if a[i]>ans:\r\n ans=a[i]\r\n res=i+1\r\nfor i in range(0,len(a)):\r\n if a[i]!=ans:\r\n if a[i]>rem:\r\n rem=a[i]\r\nprint(res,rem)\r\n \r\n", "n = int(input())\r\nprices = list(map(int, input().split()))\r\nmindiff = 100000\r\ncost = 0\r\nmax = 0\r\nindex = 0\r\n\r\nfor x in range(n):\r\n if prices[x] > max:\r\n max = prices[x]\r\n index = x\r\n\r\nfor price in prices:\r\n if abs(max - price) < mindiff and price != max:\r\n cost = price\r\n mindiff = abs(max - price)\r\n \r\nprint(index+1)\r\nprint(cost)\r\n \r\n ", "n = int(input())\r\nlst = [*map(int, input().split())]\r\npos = lst.index(max(lst)) + 1\r\nlst.remove(max(lst))\r\nsum = max(lst)\r\nprint(pos, sum)\r\n", "n=int(input())\r\narr=list(map(int,input().split()))\r\nx=arr.index(max(arr))\r\narr.sort(reverse=True)\r\nprint(x+1,arr[1])\r\n", "n = int(input())\r\nprices = list(map(int, input().split()))\r\nmax_price = max(prices)\r\nsecond_max_price = 0\r\nfor price in prices:\r\n if price < max_price and price > second_max_price:\r\n second_max_price = price\r\nwinner_index = prices.index(max_price) + 1\r\nprint(winner_index, second_max_price)\r\n", "n = int(input())\r\nprices = list(map(int, input().split()))\r\n\r\n# Find the index of the highest price\r\nwinner_index = prices.index(max(prices))\r\n\r\n# Find the second highest price\r\nsecond_highest_price = max(prices[:winner_index] + prices[winner_index+1:])\r\n\r\nprint(winner_index + 1, second_highest_price)\r\n", "input()\nl = list(map(int,input().split()))\nj = l.copy()\nj.sort()\nprint(l.index(j[-1])+1,j[-2])\n \t \t \t\t \t \t \t \t \t \t\t", "n = int(input())\r\nprices = list(map(int,input().split()))\r\n\r\nwinner = prices.index(max(prices)) + 1\r\n\r\nprices.pop(prices.index(max(prices)))\r\nmoney = max(prices)\r\nprint(winner,money)", "n=int(input())\r\np=sorted(enumerate(map(int,input().split())),key=lambda x:x[1])\r\nprint(p[-1][0]+1,p[-2][1])\r\n", "t = int(input())\r\nl= list(map(int,input().split()))\r\nst = 0\r\np= 0\r\nfor i in range(len(l)):\r\n if l[i]>st:\r\n st = l[i]\r\n p = i+1\r\nprint(p,sorted(l)[-2])\r\n", "n = int(input())\r\nlst = list(map(int, input().split()))\r\n\r\nmaxVal = (float(\"-inf\"), 0)\r\nsecondVal = float(\"-inf\")\r\n \r\nfor i in range(len(lst)):\r\n if lst[i] >= maxVal[0]:\r\n secondVal = maxVal[0]\r\n maxVal = (lst[i], i+1)\r\n elif lst[i] > secondVal:\r\n secondVal = lst[i]\r\nprint(maxVal[1], secondVal)", "import math\r\n# print(*l)\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nprint(a.index(max(a))+1,sorted(a)[-2])", "from math import *\r\nimport time\r\nn=int(input())\r\nl=input().split(\" \")\r\nindx=0\r\nmin1=0\r\nmin2=0\r\nfor i in range(0,len(l)):\r\n\tval=int(l[i])\r\n\tif(val>min1):\r\n\t\tmin2=min1\r\n\t\tmin1=val\r\n\t\tindx=i+1\r\n\telif(val==min1):\r\n\t\tmin2=min1\r\n\telif(min2<val):\r\n\t\tmin2=val\r\nprint(indx,min2)\r\n# print(time.time()-t1)", "#!/bin/env python3\nn = int(input())\np = [0, 0]\nidx = [-1, -1]\nbidders = [int(i) for i in input().split(\" \")]\nfor i, v in enumerate(bidders):\n if v > p[0]:\n p[1] = p[0]\n idx[1] = idx[0]\n p[0] = v\n idx[0] = i\n elif v > p[1]:\n p[1] = v\n idx[1] = i\nprint(idx[0] + 1, p[1])", "n=int(input())\n\np=list(map(int,input().split()))\nif(n!=1):\n maxx=max(p)\n index=p.index(maxx)\n p.remove(maxx)\n\n smax=max(p)\n\nelse:\n smax=max(p)\n index=0\n\n\n\nprint(index+1,end=' ')\nprint(smax,end=' ')\n\n\t\t \t\t\t\t \t\t \t\t \t \t \t\t \t \t\t", "n=int(input())\r\nl=list(map(int,input().split()))\r\nx=l.index(max(l))+1\r\nl.sort()\r\ny=l[-2]\r\nprint(x,y)", "from queue import PriorityQueue\r\n\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\n\r\nq = PriorityQueue()\r\n\r\nfor i, x in enumerate(a):\r\n q.put((-x, i))\r\n\r\n_, i = q.get()\r\n\r\nx, _ = q.get()\r\n\r\nx = -x\r\ni += 1\r\n\r\nprint(i, x)", "import math\r\nimport operator\r\nn = int(input())\r\narr = list(map(int, input().split()))\r\nm = max(arr)\r\npm = arr.index(m) + 1\r\narr.sort()\r\npk = arr[n-2]\r\nprint(pm,pk)\r\n\r\n\r\n ", "n=input()\r\nl=list(map(int,input().split()))\r\na=l.index(max(l))\r\nl.sort(reverse=True)\r\nprint(a+1,l[1])", "n = int(input())\r\nprice = list(map(int, input().split()))\r\nhighestbidder = price.index(max(price)) + 1\r\nprice2 = sorted(price)\r\nprint(highestbidder, (price2[-2]))", "def main():\r\n n = int(input())\r\n arr = list(map(int, input().split()))\r\n\r\n mx = max(arr)\r\n mx_index = arr.index(mx)\r\n print(mx_index + 1, list(sorted(arr))[-2])\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n = int(input())\r\np = list(map(int,input().split()))\r\nhi = p[:p.index(max(p))] + p[p.index(max(p))+1:]\r\nprint(p.index(max(p))+1, end = \" \")\r\nprint(max(hi))", "lmp = lambda:list(map(int, input().split()))\r\nmp = lambda:map(int, input().split())\r\nintp = lambda:int(input())\r\ninp = lambda:input()\r\nfinp = lambda:float(input())\r\n\r\nn = intp()\r\na = lmp()\r\n\r\nind = a.index(max(a)) + 1\r\na.sort()\r\n\r\nprint(ind, a[-2])\r\n", "# your code goes her\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nmaxele= max(a)\r\nans=-1\r\nindex=-1\r\nfor i in range(n):\r\n\tif a[i] !=maxele:\r\n\t\tans=max(a[i],ans);\r\n\telse:\r\n\t\tindex=i+1;\r\nprint(str(index)+\" \"+str(ans))\r\n\t\t", "n = int(input())\r\np = list(map(int, input().split()))\r\n\r\nindex_to_highest_bidder = p.index(max(p))\r\np.remove(max(p))\r\nprint(index_to_highest_bidder+1, max(p))", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=sorted(a)\r\nk=b[-1]\r\ni=a.index(k)\r\ni=i+1\r\nprint(i,b[-2])", "n=int(input())\r\nlist=list(map(int,input().split()))\r\nsecond_largest=largest=-1\r\nfor i in range(len(list)):\r\n if list[i]>largest:\r\n largest=list[i]\r\nfor i in range(len(list)):\r\n if second_largest<list[i]<largest:\r\n second_largest=list[i]\r\nfor i in range(len(list)):\r\n if list[i]==largest:\r\n print(i+1, second_largest)", "n = int(input())\r\nlst = list(map(int, input().split()))\r\nwinner = 1 + lst.index(max(lst))\r\nlst.sort(reverse=True)\r\nprint(f'{winner} {lst[1]}')", "n=int(input())\r\na=list(map(int,input().split()))\r\nm=max(a)\r\nr=a.index(m)\r\na.remove(m)\r\nr1=max(a)\r\nprint(r+1,r1)\r\n", "n = int(input())\nbids = list(map(int, input().split()))\nhighest = 0\nsecond = 0\nfor b in bids:\n if b > highest:\n second = highest\n highest = b \n elif highest > b > second:\n second = b\n y = bids.index(highest) + 1\nprint(y,second)\n\n\n\n", "# https://codeforces.com/problemset/problem/386/A\n\ndef solve(p):\n first = -1\n second = -1\n pos = 0\n for i, e in enumerate(p):\n if first < e:\n second = first\n first = e\n pos = i\n elif second < e:\n second = e\n return f'{pos+1} {second}'\n\n\nn = input()\np = [int(e) for e in input().split()]\nprint(solve(p))\n", "int1 = int(input())\nlist1 = list(map(int,input().strip().split()))\nprint(list1.index(max(list1))+1,end=\" \")\nlist1.remove(max(list1))\nprint(max(list1))\n", "n = int(input())\r\narr = [int(x) for x in input().split()]\r\n\r\nx = arr.index(max(arr))\r\n\r\narr.sort()\r\n\r\nprint(x+1, arr[-2])", "n = int(input())\r\ngia = list(map(int, input().split()))\r\ngiaMax = max(gia)\r\nthuMax = gia.index(giaMax)\r\ngia.remove(giaMax)\r\nprint(thuMax + 1, max(gia))", "n = int(input())\narr = list(map(int,input().split()))\na1 = arr.index(max(arr))+1\narr.remove(max(arr))\na2 = max(arr)\n\nprint(a1,a2)\n\t \t\t\t \t\t \t \t \t\t \t\t \t\t \t\t \t", "n = int(input())\r\na = [int(i) for i in input().split()]\r\nx = a.index(max(a))+1\r\na.sort(reverse=True)\r\nprint(x,a[1])", "# Line 1 - 6 takes the input from the user \r\n# we will populate b with the user input defined by a\r\n# where a defines the number of inputs.\r\na = int(input(\"\"))\r\n# b = []\r\n# for i in range(a):\r\n# c=int(input(\"\"))\r\n# b.append(c)\r\nb = input(\"\").split()\r\nnew_b = []\r\nfor item in b:\r\n new_b.append(int(item))\r\n \r\n\r\n\r\n# \"ma\" defines the assumed max value and change it according the \r\n# rest of the inputs.\r\nma = new_b[0]\r\nind = 1\r\nfor i in range(len(new_b)):\r\n if ma < new_b[i] :\r\n ma = new_b[i]\r\n ind = i + 1 \r\nnew_b.sort()\r\nprint(ind , new_b[len(b) - 2])", "n = int(input())\r\narr = list(map(int, input().split()))\r\nindex = arr.index(max(arr))\r\narr.remove(max(arr))\r\nprint(index+1,max(arr))", "len=int(input())\na=list(map(int,input().split()))\nb=list(a)\na.sort()\npos=b.index(a[-1])+1\nset=set(a)\na=list(set)\na.sort()\nprint(pos,a[-2])\n \t\t \t\t\t\t \t \t \t\t\t \t \t\t \t\t", "n = int(input())\r\nnumbers = input().split(\" \")\r\nnumbers = [int(x) for x in numbers]\r\nhighest = max(numbers)\r\nhighestIndex = numbers.index(highest) + 1\r\nnumbers.remove(highest)\r\nsecondHighest = max(numbers)\r\nprint(highestIndex, secondHighest)\r\n", "n=int(input())\r\nlis=list(map(int,input().split()))\r\nmaxi=max(lis)\r\nind=lis.index(maxi)\r\nlis.sort()\r\nprint(str(ind+1)+\" \"+str(lis[-2]))", "n = int(input())\r\nbidders = list(map(int,input().split()))\r\nnum = bidders.index(max(bidders)) + 1\r\nbidders.remove(max(bidders))\r\nprice = max(bidders)\r\nprint(num,price)\r\n\r\n", "# LUOGU_RID: 101541572\nn, *a = map(int, open(0).read().split())\r\nb = sorted(a)\r\nprint(a.index(b[-1]) + 1, b[-2])", "n=int(input())\r\nl=list(map(int,input().split()))\r\nz=l.index(max(l))\r\ndel l[z]\r\nprint(z+1,max(l))", "def my_func(a):\n maximum_element = a[0]\n max_el_index = 0\n for i in range(len(a)):\n if maximum_element < a[i]:\n maximum_element = a[i]\n max_el_index = i\n a[max_el_index] = 0 \n return maximum_element, max_el_index\n\nn = map(int, input().split())\nbids = list(map(int, input().split()))\nmax_bid, max_bid_pos = my_func(bids)\nsecond_max_bid, _ = my_func(bids)\nprint(max_bid_pos+1, second_max_bid)\n", "a= int(input())\r\n\r\n\r\n\r\nt = list(map(int,input().split()))\r\n\r\n\r\nu = max(t)\r\n\r\nh= t.index(u)+1\r\nfor x in range(t.count(u)):\r\n t[t.index(u)]=0\r\n\r\n\r\nprint(h,max(t))\r\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\na = l.index(max(l))\r\nl.remove(max(l))\r\nb = max(l)\r\nprint(a+1,b)", "# LUOGU_RID: 113477777\nn=int(input())\r\na=input().split()\r\nfor i in range(n):\r\n a[i]=int(a[i])\r\nprint(a.index(max(a))+1,end=' ')\r\na.sort(reverse=True)\r\nprint(a[1])", "n=int(input())\r\na=input().split()\r\na=[int(x) for x in a]\r\nb=[int(x) for x in a]\r\nb.sort(reverse=True)\r\nx=b[0]\r\nfor i in range(n):\r\n if a[i]==x:\r\n print(i+1, b[1])", "\r\n\r\nn = int(input())\r\nx = [int(x) for x in input().split()]\r\n\r\na = x.index(max(x))\r\n\r\nx.sort()\r\n\r\nprint(a + 1 , x[-2])", "n = int(input())\nd = {}\nfor i, x in enumerate(map(int, input().split()), 1):\n d[i] = x\nprint(max(d.keys(), key=d.get), sorted(d.values())[-2])\n", "n = int(input())\r\nx = list(map(int, input().split()))\r\nm = x.index(max(x))\r\nx.pop(m)\r\nprint(m + 1, max(x))\r\n", "\r\nn=int(input())\r\nc1=input().split(\" \")\r\nc=[]\r\nfor i in c1:\r\n c.append(int(i))\r\n \r\nmx=max(c)\r\ni=c.index(mx)\r\nc.remove(mx)\r\nmx1=max(c)\r\nprint(i+1,int(mx1))\r\n ", "def quicksort(arr):\r\n if len(arr) <= 1: return arr\r\n\r\n m = arr[0]\r\n return quicksort(organizar_menores(m,arr)) + iguais(m,arr) + quicksort(organizar(m,arr))\r\n\r\ndef organizar_menores(m,arr):\r\n\r\n\tlista = []\r\n\r\n\tfor i in arr:\r\n\r\n\t\tif i<m:\r\n\r\n\t\t\tlista.append(i)\r\n\r\n\treturn lista\r\n\r\ndef iguais(m,arr):\r\n\r\n\tlista = []\r\n\r\n\tfor i in arr:\r\n\r\n\t\tif i == m:\r\n\r\n\t\t\tlista.append(i)\r\n\r\n\treturn lista\r\n\r\ndef organizar(m,arr):\r\n\r\n\tlista = []\r\n\r\n\tfor i in arr:\r\n\r\n\t\tif i>m:\r\n\r\n\t\t\tlista.append(i)\r\n\r\n\treturn lista\r\n\r\nn = int(input())\r\np = list(map(lambda x: int(x), input().split()))\r\nmaximo = 0\r\n\r\n\r\nfor i in range(n):\r\n\r\n\tif p[i] > maximo:\r\n\r\n\t\tmaximo = p[i]\r\n\t\tcomprador = i+1\r\n\r\np = quicksort(p)\r\n\r\nvalorpago = p[-2]\r\n\r\nprint(comprador,valorpago,end=\" \") ", "n=int(input())\r\nli=list(map(int,input().split()))\r\nk=li.index(max(li))\r\nli=set(li)\r\nli=sorted(li,reverse=True)\r\nb=li[1]\r\nprint(k+1,b)", "input();X = list(map(int, input().split()));print(X.index(max(X)) + 1, sorted(X)[-2])\r\n", "def bid(n,a):\n b = max(a)\n for i in range(0,n):\n if a[i] == b:\n index = i+1\n break\n a.remove(b)\n c = max(a)\n print(f\"{index} {c}\")\ndef main():\n n = int(input())\n a = list(map(int,input().split()))\n bid(n,a)\nmain()\n", "\r\na = int(input())\r\nmax_n = 0\r\nmax_1 = 0\r\nmax_2 = 0\r\nk = 0\r\nb = [int(i) for i in input().split()]\r\nfor i in range(len(b)):\r\n if max(b[i], max_n) > max_n:\r\n max_1 = max_n\r\n k = i + 1\r\n max_n = max(b[i], max_n)\r\ndp = [i for i in range(len(b))]\r\ndp.reverse()\r\nmax_n = 0\r\nfor i in dp:\r\n if max(b[i], max_n) > max_n:\r\n max_2 = max_n\r\n k = i + 1\r\n max_n = max(b[i], max_n)\r\nprint(str(k) + \" \" + str(max(max_1, max_2)))\r\n", "n = int(input())\nbids = list(map(int, input().split()))\nmax_bid = 0\nmax_bid_id = 0\nfor i, bid in enumerate(bids):\n if bid > max_bid:\n max_bid = bid\n max_bid_id = i\nmax_bid = sorted(bids)[-2]\nprint(f\"{max_bid_id + 1} {max_bid}\") ", "a=int(input())\r\na=list(map(int,input().split()))\r\nind=a.index(max(a))\r\na.sort()\r\nprint(str(ind+1)+' '+str(a[-2]))\r\n \r\n\r\n \r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ", "n = int(input())\r\nbruh_auctioners_u_stupid_just_put_the_highest_number_you_can_lol = list(map(int,input().split()))\r\nfor froot_loop in range(n):\r\n if bruh_auctioners_u_stupid_just_put_the_highest_number_you_can_lol[froot_loop] == max(bruh_auctioners_u_stupid_just_put_the_highest_number_you_can_lol):\r\n lucky_ducky = froot_loop + 1\r\npay_to_win = 0\r\nfor froot_loop in range(n):\r\n if bruh_auctioners_u_stupid_just_put_the_highest_number_you_can_lol[froot_loop] > pay_to_win and bruh_auctioners_u_stupid_just_put_the_highest_number_you_can_lol[froot_loop] < max(bruh_auctioners_u_stupid_just_put_the_highest_number_you_can_lol):\r\n pay_to_win = bruh_auctioners_u_stupid_just_put_the_highest_number_you_can_lol[froot_loop]\r\nprint(lucky_ducky, pay_to_win)", "n=int(input())\r\nl=list(map(int,input().split()))\r\nprint(l.index(max(l))+1,end=\" \")\r\nl.remove(max(l))\r\nprint(max(l))", "n=int(input())\r\na=[int(i) for i in input().split()]\r\nx=max(a)\r\nprint(a.index(x)+1,end=' ')\r\na.remove(x)\r\nprint(max(a))\r\n", "n=int(input())\r\np=list(map(int,input().split()))\r\nm=max(p)\r\ni=p.index(m)+1\r\np.remove(m)\r\nm=max(p)\r\nprint(str(i)+\" \"+str(m))\r\n\r\n", "input()\r\nbet = [int(i) for i in input().split()]\r\nx = bet.index(max(bet)) + 1\r\nbet.sort()\r\nprint(x, bet[-2])", "num=int(input())\r\nnums=list(map(int,input().split(' ')))\r\nnums2=nums.copy()\r\nnums.sort()\r\nfor i in range(len(nums2)):\r\n if nums[len(nums)-1]==nums2[i]:\r\n print(i+1,nums[len(nums)-2])\r\n break", "num = int(input())\r\narr = list(map(int, input().split()))\r\n\r\nsor = sorted(arr)\r\n\r\nprint(arr.index(max(arr))+1, sor[-2])\r\n\r\n", "n=int(input())\nprice=list(map(int, input() .split()))\nm=1 \nhighest=price[0]\nsecond_highest=0\nfor i in range(1,n):\n if price[i]>highest:\n second_highest=highest\n highest=price[i]\n m=i+1 \n if (price[i]>second_highest) and (price[i]<highest):\n second_highest=price[i]\nprint(m,second_highest)\n ", "\"\"\"\r\ninput:\r\n2\r\n5 7\r\n\r\noutput:\r\n2 5\r\n\"\"\"\r\n\r\ndef main():\r\n n = int(input())\r\n bidders = list(map(int, input().split()))\r\n\r\n bidder = bidders.index(max(bidders))\r\n bidders.pop(bidder)\r\n price = max(bidders)\r\n\r\n print(f\"{bidder + 1} {price}\")\r\n\r\nif __name__ == \"__main__\":\r\n main()", "num_of_bidders=int(input())\r\nbidders_list=[int(x) for x in (input().split())]\r\ni=bidders_list.index(max(bidders_list))\r\nbidders_list.pop(i)\r\nprint(i+1,max(bidders_list))", "n=int(input())\r\narr=list(map(int,input().split()))\r\n\r\n\r\nans1=arr.index(max(arr))+1\r\n\r\narr.sort()\r\n\r\nans2=arr[-2]\r\n\r\nprint(ans1,ans2)\r\n\r\n", "n=int(input())\r\nl=list(map(int,input().split()))[:n]\r\nk=max(l)\r\nl1=sorted(l)\r\nl1=l1[::-1]\r\np=l.index(k)\r\nprint(p+1,end=' ')\r\nprint(l1[1])\r\n", "# https://codeforces.com/problemset/problem/386/A\r\n\r\nn = int(input())\r\n\r\nbids = map(int, input().split())\r\n\r\nfirst = float('-inf')\r\nsecond = float('-inf')\r\nfirst_index = None\r\nsecond_index = None\r\nindex = 0\r\nfor i in bids:\r\n index += 1\r\n if i > first:\r\n second = first\r\n second_index = first_index\r\n\r\n first_index = index\r\n first = i\r\n elif i > second:\r\n second = i\r\n second_index = index\r\n\r\nprint(first_index, second)", "n = int(input())\r\np = list(map(int, input().split()))\r\nmaxi = max(p)\r\nmas = 0\r\nfor x in range(len(p)):\r\n if mas < p[x] < maxi:\r\n mas = p[x]\r\nprint(p.index(maxi) + 1, mas)", "n = int(input()); l = list(map(int, input().split()))\r\nmax = (0, 0); second = (0, 0)\r\nfor i in range(n):\r\n val = l[i]\r\n if val > max[1]:\r\n second = max; max = (i, val)\r\n elif val > second[1]:\r\n second = (i, val)\r\nprint(max[0]+1, second[1])", "n = int(input())\r\nl = list(map(int,input().split()))\r\nl1 = sorted(l,reverse=True)\r\nprint(l.index(max(l))+1,l1[1])", "n = int(input())\r\narr = list(map(int, input().split(\" \")))\r\nm = max(arr)\r\nind = arr.index(m)\r\narr.pop(ind)\r\nprint(ind+1, max(arr))", "n=int(input())\r\nsbid=input().split()\r\nbid=[0]*n\r\nfor i in range(n):\r\n sbid[i]=int(sbid[i])\r\n bid[i]=sbid[i]\r\nsbid.sort()\r\nwinner=sbid[len(sbid)-1]\r\nprice=sbid[len(sbid)-2]\r\nprint(bid.index(winner)+1,price)\r\n\r\n", "n=int(input()); \r\nc=0\r\nl=list(map(int,input().split()))\r\nmaxi=max(l)\r\nfor i in range(len(l)):\r\n if l[i]==maxi:\r\n m=i+1\r\n break\r\np=sorted(l)\r\nprint(m,p[-2])\r\n", "n = int(input())\r\np = [int(i) for i in input().split()]\r\nm = max(p[0], p[1])\r\nm_price = min(p[0], p[1])\r\nm_pos = 1\r\nfor i in range(n):\r\n if m <= p[i]:\r\n m = p[i]\r\n m_pos = i+1\r\nfor i in range(n):\r\n if m_price <= p[i] < m:\r\n m_price = p[i]\r\nprint(m_pos, m_price)\r\n", "n, p = int(input()), sorted((int(p), i + 1) for i, p in enumerate(input().split()))\nres = p[-1][1], p[-2][0]\nprint(*res)\n", "x = int(input())\r\nz = input().split(\" \")\r\nfin = \"\"\r\nfor i in range(len(z)):\r\n z[i] = int(z[i])\r\nhighest = z.index(max(z))\r\nfin += str(highest+1)\r\nfin += \" \"\r\nz.sort()\r\nsndhigh = z[-2]\r\nfin += str(sndhigh)\r\nprint(fin)", "n=int(input())\r\na=list(map(int,input().split()))\r\nc=a.index(max(a))+1\r\na.remove(max(a))\r\nprint(c,max(a))\r\n", "\r\ndef find_max(l):\r\n maximum = l[0]\r\n ind_max = 0\r\n for i in range(len(l)):\r\n if maximum < l[i]:\r\n maximum = l[i]\r\n ind_max = i\r\n return ind_max\r\n\r\n\r\n\r\n\r\ndef main_function():\r\n n = int(input())\r\n a = [int(i) for i in input().split(\" \")]\r\n ind_max = find_max(a)\r\n a.pop(ind_max)\r\n second_ind_max = find_max(a)\r\n return f\"{ind_max + 1} {a[second_ind_max]}\"\r\n\r\n\r\nprint(main_function())", "n = int(input())\r\np = list(map(int, input().split()))\r\nh = max(p)\r\nnewp = set(p)\r\nnewp.remove(h)\r\nsh = max(newp)\r\n\r\nprint(p.index(h) + 1, sh)\r\n\r\n", "n = int(input())\r\narr = list(map(int, input().split()))\r\narr2 = [i for i in arr]\r\narr2.sort()\r\nx = arr2[-1]\r\ny = arr2[-2]\r\nprint(arr.index(x)+1, end = \" \")\r\nprint(y)", "p = int(input())\r\nstr_price = str(input())\r\nlist_price = list(map(lambda x: int(x), str_price.split()))\r\n\r\nwinner = list_price.index(max(list_price)) + 1\r\nval = sorted(list_price)[-2]\r\nprint(winner, val)", "n = int(input())\n\ndata = list(map(int, input().split(\" \")))\n\ndata_sup = data.copy()\n\ndata_sup.sort()\n\nwinner = data.index(data_sup[-1]) + 1\n\nprice = data_sup[-2]\n\nprint(winner, price)\n \t \t \t \t \t \t \t\t \t\t\t \t\t", "n = int(input())\r\nl = list(map(int,input().split()))\r\nmaxi = max(l)\r\nprint(l.index(maxi)+1,end=\" \")\r\nl.sort()\r\nl.pop()\r\nprint(max(l))", "n=int(input())\r\na=[int(x) for x in input().split()]\r\npos=a.index(max(a))\r\na.sort(reverse=True)\r\nprint(pos+1,a[1])", "n = int(input())\r\np = list(map(int, input().split()))\r\nprint(p.index(max(p))+1, sorted(p, reverse=True)[1])", "n = int(input())\r\nnumstr = input()\r\nlis =numstr.split()\r\ni=0\r\nwhile(i<n):\r\n lis[i]=int(lis[i])\r\n i+=1\r\nlis2 = lis.copy()\r\nlis2.sort()\r\nlis2.reverse()\r\nprint(lis.index(max(lis))+1, lis2[1])\r\n", "n = int(input())\r\nprs = [int(x) for x in input().split()]\r\n\r\nprint(prs.index(max(prs))+1, sorted(prs)[-2])", "n = int(input())\r\nmx = 0\r\nmx2 = -1\r\nprices = [int (el) for el in input().split()]\r\nfor i in range(n):\r\n if(mx < prices[i]):\r\n k = i\r\n mx2 = mx\r\n mx = prices[i]\r\n prices[i] = 0\r\n if(mx2 < prices[i]) & (mx > mx2):\r\n mx2 = prices[i]\r\nprint((k+1), mx2)\r\n\r\n\r\n", "n = int(input())\r\nprice = list(map(int, input().split()))\r\nhighest = max(price)\r\nans = []\r\nans.append(price.index(highest) +1)\r\nprice.sort()\r\nsecond_highest = price[-2]\r\nans.append(second_highest)\r\nprint(*ans)", "n = int(input())\r\nbidders = list(map(int, input().split()))\r\n\r\nanswer = str(bidders.index(max(bidders)) + 1)\r\n\r\nbidders.pop(bidders.index(max(bidders)))\r\n\r\nanswer += \" \" + str(max(bidders))\r\n\r\nprint(answer)", "x=int(input())\r\ny=list(map(int,input().split()))\r\nd=max(y)\r\nprint(y.index(d)+1,end=\" \")\r\ny.sort()\r\ne=y.index(d)\r\nprint(max(y[:e]))", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[3]:\n\n\nx=int(input())\nl=list(map(int,input().split()))\nm=max(l)\ni=l.index(m)\nl.remove(m)\nm1=max(l)\nprint(i+1,m1)\n\n\n# In[ ]:\n\n\n\n\n", "n = int(input())\r\nbids = list(map(int, input().split()))\r\n\r\nmaximum_index = max(list(range(n)),key=lambda x:bids[x])\r\ndel bids[maximum_index]\r\nprice_to_pay = max(bids)\r\n\r\nprint(maximum_index+1,price_to_pay)", "#!/usr/bin/env/python\r\n# -*- coding: utf-8 -*-\r\nn = int(input())\r\na = list(map(int, input().split()))\r\npos = [0, 1] if a[0] > a[1] else [1, 0]\r\nfor i in range(2, n):\r\n if a[i] > a[pos[0]]:\r\n pos[1] = pos[0]\r\n pos[0] = i\r\n elif a[i] > a[pos[1]]:\r\n pos[1] = i\r\n# print(pos)\r\nprint(pos[0] + 1, a[pos[1]])", "n=int(input())\r\narr=[int(x) for x in input().split()]\r\nsum1=0\r\nk=0\r\nfor j in range(n):\r\n if arr[j]>sum1:\r\n sum1=arr[j]\r\n k=j\r\n\r\nsum2=0\r\nfor i in arr:\r\n if i>sum2 and i!=sum1:\r\n sum2=i\r\nprint(k+1,end=\" \")\r\nprint(sum2)\r\n", "n = int(input())\nx = list(map(int, input().split()))\na1 = x.index(max(x)) + 1\na2 = sorted(set(x))[-2]\nprint(a1, a2)", "N = int(input())\r\n\r\nbids = [int(i) for i in input().split(\" \")]\r\n\r\n\r\n# Max bid and max bid index\r\nmax_bid = bids[0]\r\nmax_bid_index = 0\r\nfor i in range(len(bids)):\r\n\tif bids[i] > max_bid:\r\n\t\tmax_bid = bids[i]\r\n\t\tmax_bid_index = i\r\n\r\n\r\n# Second last price.\r\nrup_bid = bids[0 if max_bid_index!=0 else 1]\r\n\r\nfor i in range(len(bids)):\r\n\tif bids[i] == max_bid:\r\n\t\tcontinue\r\n\telif bids[i] > rup_bid:\r\n\t\trup_bid = bids[i]\r\n\r\n# o/p\r\nmax_bid_index += 1 # for 1 based index\r\n\r\nprint(max_bid_index, rup_bid)\r\n", "n = int(input())\r\n\r\nP = list(map(int, input().split()))\r\nfor i, v in enumerate(P):\r\n P[i] = [v, i]\r\nP.sort()\r\nprint(P[-1][1] + 1, end=' ')\r\nprint(P[-2][0])\r\n \r\n", "a = int(input())\r\nb = input().split()\r\nq = 0\r\nc = 0\r\nfor i in range(a):\r\n b[i] = int(b[i])\r\n if b[i] > q:\r\n q = b[i]\r\n c = i\r\nprint(c + 1, end = \" \")\r\ndel(b[c])\r\nprint(max(b))\r\n", "input()\r\nL=list(map(int,input().split()))\r\nx=sorted(L)[-2]\r\ny=L.index(sorted(L)[-1])\r\nprint(y+1,x)", "n=int(input())\r\na=list(map(int,input().split()))\r\nx=a.index(max(a))\r\na.sort()\r\nprint(x+1,a[-2])", "bidder = int(input())\r\ns = list(map(int, input().split()))\r\nbiddermax = s.index(max(s))\r\ns.remove(max(s))\r\npricemax = max(s)\r\nprint(biddermax+1, pricemax)", "n=int(input())\r\nx=list(map(int,input().split()))\r\nc=x.copy()\r\nc.sort()\r\nprint(x.index(max(x))+1, c[-2] )\r\n", "n = int(input())\r\nx = list(map(int, input().split()))\r\nc = max(x)\r\na = x.index(c) + 1\r\nsorted_list = sorted(x)\r\nb = sorted_list[-2]\r\nprint(a,b)", "n=int(input())\r\np=(list(map(int,input().split())))\r\nmax1=p.index(max(p))+1\r\np.pop(max1-1)\r\nmax2=max(p)\r\nbid=max1,max2\r\nprint(bid[0],bid[1])", "n = int(input())\r\nl = list(map(int, input().split()))\r\nlargest = -33\r\nsecond = -34\r\nind = -2\r\nfor i in range(len(l)):\r\n if l[i] > largest:\r\n second = largest\r\n largest = l[i]\r\n ind = i\r\n elif l[i] > second:\r\n second = l[i]\r\nprint(ind+1,second)", "n = int(input())\r\nbids = [int(x) for x in input().split()]\r\nmax_value = max(bids)\r\nindex = bids.index(max_value)\r\nbids.sort()\r\nz = bids[-2]\r\nprint(index+1, z)", "__author__ = 'Administrator'\r\nn = int(input())\r\ntest = []\r\ntest1 = []\r\ntest = list(map(int, input().split()))\r\ni = 1\r\nfor value in test:\r\n test1.append((value, i))\r\n i += 1\r\n\r\ntest1.sort(key=lambda d: d[0], reverse=True)\r\n\r\nprint(test1[0][1], test1[1][0])", "\r\n\r\nn = int(input())\r\n\r\np = input().split(\" \")\r\nfor i in range(n):\r\n\tp[i] = int(p[i])\r\n\r\nMax = max(p)\r\nfor i in range(n):\r\n\tif(Max == p[i]):\r\n\t\tk = i\r\np.sort()\r\nprint(k+1, p[n-2])\r\n\r\n\r\n", "# Read the number of bidders\nn = int(input())\n\n# Read the prices offered by bidders and store them in a list\nprices = list(map(int, input().split()))\n\n# Find the highest and second-highest bids\nhighest_bid = max(prices)\nsecond_highest_bid = max(price for price in prices if price < highest_bid)\n\n# Find the index of the highest bid to determine the winner\nwinner_index = prices.index(highest_bid)\n\n# Print the winner's index (0-based) and the price they will pay\nprint(winner_index + 1, second_highest_bid)\n\n\t \t\t\t \t \t\t\t\t \t\t \t \t \t", "n = int(input())\r\np = list(map(int, input().split()))\r\np_sorted = sorted(p)\r\n\r\nprint(p.index(p_sorted[-1]) + 1, p_sorted[-2])", "n = int(input())\r\nprices = [int(i) for i in input().split()]\r\npeople = []\r\nfor i in range(n): people.append([i+1, prices[i]])\r\npeople.sort(key=lambda x: x[1])\r\nprint(str(people[-1][0])+' '+str(people[-2][1]))\r\n\r\n", "bidders = int(input())\nprice = list(map(int, input().split(' ')))\n\nwinner = price.index(max(price)) + 1\nsorted_price = sorted(price, reverse=True)\nsecond_bidder = sorted_price[1]\n\nprint(winner, second_bidder)\n\n", "# import sys\r\n\r\n# sys.stdin = open(\"input.txt\",\"r\")\r\n# sys.stdout = open(\"output.txt\",\"w\")\r\n\r\ninput()\r\nbidders = list(map(int,input().split()))\r\nmax_bid = max(bidders)\r\nmax_bid_ind = bidders.index(max_bid)+1\r\nbidders.pop(max_bid_ind-1)\r\nprint(max_bid_ind,max(bidders))\r\n\r\n\r\n", "input()\r\narr=list(map(int,input().split()))\r\np=sorted(arr,reverse=1)\r\nprint(arr.index(p[0])+1,p[1])", "n = int(input())\r\nmas = list(map(int, input().split()))\r\nind, maxi, second_maxi = 0, 1, 1\r\nfor i in range(n):\r\n if mas[i] > maxi:\r\n second_maxi = maxi\r\n maxi = mas[i]\r\n ind = i + 1\r\n else:\r\n if mas[i] > second_maxi:\r\n second_maxi = mas[i]\r\n\r\nprint(ind, second_maxi)", "input()\r\nP = list(map(int, input().split()))\r\ni = P.index(max(P))\r\nP.pop(i)\r\n\r\nprint(i+1, max(P))", "bidders = int(input(\"\"))\ndata = input(\"\")\ndata = data.split(\" \")\nwinnerindex = 0\nhighestprice = 0\n\nfor i in range(len(data)):\n data[i] = int(data[i])\n \nfor i in range(len(data)):\n if data[i] > highestprice:\n highestprice = data[i]\n winnerindex = i\n\ndata.sort(reverse=True)\npricetopay = data[1]\nprint(f\"{int(winnerindex)+1} {pricetopay}\")", "_ = int(input())\r\nprices = [int(x) for x in input().split()]\r\nsorted_prices = list(sorted(prices))\r\n\r\nprice_to_pay = sorted_prices[-2]\r\nindex_of_max = prices.index(max(prices)) + 1\r\n\r\nprint(f\"{index_of_max} {price_to_pay}\")\r\n", "n=int(input())\np=input().split()\nindex=0\nbid2=0\nbid=0\nfor i in range(len(p)):\n if int(p[i])>bid:\n bid=int(p[i])\n index=i+1\nfor i in range(len(p)):\n if int(p[i])>bid2 and int(p[i])!=bid:\n bid2=int(p[i])\nprint(index,bid2)\n\n \t \t\t \t \t \t\t \t \t \t \t\t", "x=int(input())\r\nn=list(map(int, input().split()))\r\na=0\r\nt=0\r\nfor i in n:\r\n if i>a:\r\n a=i\r\n for e in n:\r\n if t<e<a:\r\n t=e\r\nprint(int(n.index(a)+1),t)\r\n" ]
{"inputs": ["2\n5 7", "3\n10 2 8", "6\n3 8 2 9 4 14", "4\n4707 7586 4221 5842", "5\n3304 4227 4869 6937 6002", "6\n5083 3289 7708 5362 9031 7458", "7\n9038 6222 3392 1706 3778 1807 2657", "8\n7062 2194 4481 3864 7470 1814 8091 733", "9\n2678 5659 9199 2628 7906 7496 4524 2663 3408", "2\n3458 1504", "50\n9237 3904 407 9052 6657 9229 9752 3888 7732 2512 4614 1055 2355 7108 6506 6849 2529 8862 159 8630 7906 7941 960 8470 333 8659 54 9475 3163 5625 6393 6814 2656 3388 169 7918 4881 8468 9983 6281 6340 280 5108 2996 101 7617 3313 8172 326 1991", "100\n2515 3324 7975 6171 4240 1217 4829 5203 8603 6900 3031 4699 4732 6070 4221 3228 6497 7359 9130 4346 4619 1109 3945 5442 3271 16 9711 2045 6410 2301 3406 8125 6003 1892 1260 9661 3940 6692 4708 7027 4930 6925 1979 5361 4263 3144 867 8639 6230 5562 9714 3676 4231 3347 4733 4920 4881 3431 1059 7313 8912 3038 9308 72 9583 7009 3034 7425 2398 6141 3245 2495 2933 6710 8289 9806 1226 8393 7349 6462 1618 9613 3546 6012 2964 9995 1578 210 2123 4874 1252 8625 348 8020 803 7244 9080 5088 706 2602", "2\n2 1", "2\n1 2", "3\n10 20 30", "3\n10 30 20", "3\n20 10 30", "3\n20 30 10", "3\n30 10 20", "3\n30 20 10", "2\n1 10000", "2\n10000 999", "3\n3 4 1", "6\n1 2 24 6 5 7"], "outputs": ["2 5", "1 8", "6 9", "2 5842", "4 6002", "5 7708", "1 6222", "7 7470", "3 7906", "1 1504", "39 9752", "86 9806", "1 1", "2 1", "3 20", "2 20", "3 20", "2 20", "1 20", "1 20", "2 1", "1 999", "2 3", "3 7"]}
UNKNOWN
PYTHON3
CODEFORCES
409
e485a47b51ae09651c2a41eea8f762d7
Looksery Party
The Looksery company, consisting of *n* staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes to the party, sends messages to his contacts about how cool it is. At the same time everyone is trying to spend as much time on the fun as possible, so they send messages to everyone without special thinking, moreover, each person even sends a message to himself or herself. Igor and Max, Looksery developers, started a dispute on how many messages each person gets. Igor indicates *n* numbers, the *i*-th of which indicates how many messages, in his view, the *i*-th employee is going to take. If Igor guesses correctly at least one of these numbers, he wins, otherwise Max wins. You support Max in this debate, so you need, given the contact lists of the employees, to determine whether there is a situation where Igor loses. Specifically, you need to determine which employees should come to the party, and which should not, so after all the visitors send messages to their contacts, each employee received a number of messages that is different from what Igor stated. The first line contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of employees of company Looksery. Next *n* lines contain the description of the contact lists of the employees. The *i*-th of these lines contains a string of length *n*, consisting of digits zero and one, specifying the contact list of the *i*-th employee. If the *j*-th character of the *i*-th string equals 1, then the *j*-th employee is in the *i*-th employee's contact list, otherwise he isn't. It is guaranteed that the *i*-th character of the *i*-th line is always equal to 1. The last line contains *n* space-separated integers: *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=*n*), where *a**i* represents the number of messages that the *i*-th employee should get according to Igor. In the first line print a single integer *m* — the number of employees who should come to the party so that Igor loses the dispute. In the second line print *m* space-separated integers — the numbers of these employees in an arbitrary order. If Igor wins the dispute in any case, print -1. If there are multiple possible solutions, print any of them. Sample Input 3 101 010 001 0 1 2 1 1 1 4 1111 0101 1110 0001 1 0 1 0 Sample Output 1 1 0 4 1 2 3 4
[ "n=int(input().strip())\r\n\r\nnums=['']+[' '+input().strip() for _ in range(n)]\r\na=[0]+list(map(int,input().split()))\r\n\r\n\r\ndef send(x):\r\n for i in range(1,n+1):\r\n if nums[x][i]=='1':\r\n a[i]-=1\r\n\r\nvis=[0]*(n+1)\r\nwhile True:\r\n for i in range(1,n+1):\r\n if not vis[i] and not a[i]:\r\n vis[i]=1\r\n send(i)\r\n break\r\n else:\r\n for i in range(1,n+1):\r\n if not a[i]:\r\n print(-1)\r\n exit()\r\n break\r\n\r\n\r\nans=[]\r\nfor i in range(1,n+1):\r\n if vis[i]:\r\n ans.append(i)\r\n\r\nif ans:\r\n print(len(ans))\r\n print(*ans)\r\nelse:\r\n print(0)\r\n", "n=int(input().strip())\r\na=[]\r\nfor i in range(n):\r\n s=input().strip()\r\n a.append(s)\r\nb=list(map(int,input().strip().split()))\r\nc=[]\r\nwhile (True):\r\n k=-1\r\n for i in range(n):\r\n if (b[i]==0):\r\n k=i\r\n break\r\n if (k==-1):\r\n break\r\n else:\r\n c.append(k+1)\r\n for i in range(n):\r\n if (a[k][i]=='1'):\r\n b[i]-=1\r\ntot=len(c)\r\nprint(tot)\r\nfor x in c:\r\n tot=tot-1\r\n print(x,end=' ') if (tot!=0) else print(x,end='\\n')", "\"\"\"\r\nCodeforces Looksery Cup 2015 Problem B\r\n\r\nAuthor : chaotic_iak\r\nLanguage: Python 3.4.2\r\n\"\"\"\r\n\r\n################################################### SOLUTION\r\n\r\ndef check(a, b):\r\n for i in range(len(a)):\r\n if a[i] == b[i]: return i\r\n return -1\r\n\r\ndef main():\r\n n, = read()\r\n s = [read(0) for _ in range(n)]\r\n a = read()\r\n\r\n curr = [0] * n\r\n invited = []\r\n while True:\r\n t = check(curr, a)\r\n if t == -1: break\r\n invited.append(t+1)\r\n for i in range(n):\r\n curr[i] += int(s[t][i])\r\n\r\n print(len(invited))\r\n return invited\r\n\r\n\r\n\r\n#################################################### HELPERS\r\n\r\n\r\n\r\ndef read(mode=2):\r\n # 0: String\r\n # 1: List of strings\r\n # 2: List of integers\r\n inputs = input().strip()\r\n if mode == 0: return inputs\r\n if mode == 1: return inputs.split()\r\n if mode == 2: return list(map(int, inputs.split()))\r\n\r\ndef write(s=\"\\n\"):\r\n if s is None: s = \"\"\r\n if isinstance(s, list): s = \" \".join(map(str, s))\r\n s = str(s)\r\n print(s, end=\"\")\r\n\r\nwrite(main())", "import math\nimport sys\ninput = sys.stdin.readline\nn = int(input())\na = [[] for _ in range(n)]\nfor i in range(n):\n a[i] = [int(_) for _ in input().strip()]\ncnt = [int(_) for _ in input().split()]\nparty = []\nwhile True:\n piv = -1\n for i in range(n):\n if cnt[i] == 0:\n piv = i\n if piv == -1: break\n party.append(piv + 1)\n for i in range(n):\n if a[piv][i] == 1:\n cnt[i] -= 1\nprint(len(party))\nprint(' '.join(map(str, party)))\n\n\n \n", "def main():\n import sys\n \n tokens = sys.stdin.read().split()\n tokens.reverse()\n \n n = int(tokens.pop())\n mat = [[int(j) for j in tokens.pop()] for i in range(n)]\n prediction = [int(tokens.pop()) for i in range(n)]\n \n frequency = [0] * n\n result = []\n for step in range(n):\n for i in range(n):\n if frequency[i] == prediction[i]:\n result.append(i + 1)\n for j in range(n):\n frequency[j] += mat[i][j]\n break\n \n print(len(result))\n print(' '.join(str(i) for i in result))\n \n \n \nmain()\n" ]
{"inputs": ["3\n101\n010\n001\n0 1 2", "1\n1\n1", "4\n1111\n0101\n1110\n0001\n1 0 1 0", "2\n11\n01\n0 2", "5\n10110\n01110\n00101\n00011\n00001\n0 0 2 2 3", "6\n100000\n010000\n001000\n000100\n000010\n000001\n1 1 1 1 1 1", "10\n1000100000\n0100000000\n0010001000\n0011000000\n0100100000\n0000010010\n1000001000\n0000000101\n0000000110\n0001000001\n1 2 1 1 1 0 1 1 1 1", "10\n1000000000\n0100000000\n0010000000\n0001000010\n0000100010\n1110011000\n0000001000\n0000000110\n0000010010\n0000000001\n2 2 2 0 0 1 2 0 3 1", "10\n1000000000\n0100000000\n1111000100\n0001000000\n0101100101\n1001010000\n0000001110\n0000000100\n0000000010\n0000000001\n3 3 0 4 0 0 0 4 2 2", "20\n10000000000000000000\n01000000000000000000\n00100000000000000000\n00010000000000000000\n00001000000000000000\n00000100000000000000\n00000010000000000000\n00000001000000000000\n00000000100000000000\n00000000010000000000\n00000000001000000000\n00000000000100000000\n00000000000010000000\n00000000000001000000\n00000000000000100000\n00000000000000010000\n00000000000000001000\n00000000000000000100\n00000000000000000010\n00000000000000000001\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "7\n1000000\n0101100\n0010000\n0001010\n0010100\n0000010\n0001101\n0 0 1 2 2 1 0", "5\n11001\n01000\n01100\n11011\n00011\n1 4 0 1 3", "10\n1110001111\n0100000000\n0110001010\n0111011100\n0000101000\n1011110001\n0000001001\n1010100101\n0000000010\n0001101111\n2 4 4 2 3 1 6 4 4 4", "20\n10000000000000101000\n11001100010111100011\n10100110100110101000\n01010110100000010000\n10101110100111101000\n10000110100100101000\n00000110000000001000\n00000001000000000000\n00100010100100100000\n00000000011000000000\n00010000001000101000\n00000010000100000000\n00001000000010000000\n10101100100111101010\n10000000000000100000\n11110010000001011100\n10000000000100101000\n10010001100011101100\n00101110100101001011\n11001100000111101011\n10 3 5 3 5 8 8 2 7 1 1 9 6 6 11 1 11 1 3 2", "10\n1010010111\n0101010111\n0011100101\n0011000011\n1110110101\n1001110100\n1101001111\n1001011110\n1111000011\n0010010001\n2 8 5 9 5 3 3 7 6 0"], "outputs": ["1\n1 ", "0", "4\n1 2 3 4 ", "1\n1 ", "4\n1 2 3 4 ", "0", "9\n1 3 4 5 6 7 8 9 10 ", "5\n4 5 6 8 9 ", "4\n3 5 6 7 ", "0", "7\n1 2 3 4 5 6 7 ", "1\n3 ", "0", "0", "1\n10 "]}
UNKNOWN
PYTHON3
CODEFORCES
5
e48eefa4a778a5eb4ace0e0e546e7606
Возможно, вы знаете этих людей?
Основой любой социальной сети является отношение дружбы между двумя пользователями в том или ином смысле. В одной известной социальной сети дружба симметрична, то есть если *a* является другом *b*, то *b* также является другом *a*. В этой же сети есть функция, которая демонстрирует множество людей, имеющих высокую вероятность быть знакомыми для пользователя. Эта функция работает следующим образом. Зафиксируем пользователя *x*. Пусть некоторый другой человек *y*, не являющийся другом *x* на текущий момент, является другом не менее, чем для *k*% друзей *x*. Тогда он является предполагаемым другом для *x*. У каждого человека в социальной сети есть свой уникальный идентификатор — это целое число от 1 до 109. Вам дан список пар пользователей, являющихся друзьями. Определите для каждого упомянутого пользователя множество его предполагаемых друзей. В первой строке следуют два целых числа *m* и *k* (1<=≤<=*m*<=≤<=100, 0<=≤<=*k*<=≤<=100) — количество пар друзей и необходимый процент общих друзей для того, чтобы считаться предполагаемым другом. В последующих *m* строках записано по два числа *a**i*,<=*b**i* (1<=≤<=*a**i*,<=*b**i*<=≤<=109, *a**i*<=≠<=*b**i*), обозначающих идентификаторы пользователей, являющихся друзьями. Гарантируется, что каждая пара людей фигурирует в списке не более одного раза. Для всех упомянутых людей в порядке возрастания id выведите информацию о предполагаемых друзьях. Информация должна иметь вид "*id*:<= *k* *id*1 *id*2 ... *id**k*", где *id* — это id самого человека, *k* — количество его предполагаемых друзей, а *id*1, *id*2, ..., *id**k* — идентификаторы его предполагаемых друзей в возрастающем порядке. Sample Input 5 51 10 23 23 42 39 42 10 39 39 58 5 100 1 2 1 3 1 4 2 3 2 4 Sample Output 10: 1 42 23: 1 39 39: 1 23 42: 1 10 58: 2 10 42 1: 0 2: 0 3: 1 4 4: 1 3
[ "d={}\r\nm,k=map(int,input().split())\r\nfor i in range(m):\r\n a,b=map(int,input().split())\r\n d.setdefault(a,set()).add(b)\r\n d.setdefault(b,set()).add(a)\r\nfor x in sorted(d):\r\n s=[]\r\n for y in sorted(d):\r\n if x==y or y in d[x]: continue\r\n if len(d[x]&d[y])*100>=k*len(d[x]): s+=[str(y)]\r\n print(str(x)+':',len(s),' '.join(s))", "m,k=map(int,input().split())\r\nq={}\r\nfor i in range(m):\r\n a,b=map(int,input().split())\r\n if a not in q: q[a]=set()\r\n if b not in q: q[b]=set()\r\n q[a].add(b)\r\n q[b].add(a)\r\nfor x in sorted(q):\r\n ans=[]\r\n for y in sorted(q):\r\n if x==y: continue\r\n if y in q[x]: continue\r\n if len(q[x].intersection(q[y]))>=k*len(q[x])/100: ans.append(y)\r\n print(str(x)+':',len(ans),*ans)", "def sh(s1,s2):\r\n a,b,c=len(s1),len(s2),0.0\r\n for sym in s1:\r\n if sym in s2:\r\n c+=1\r\n return c/(a+b-c)*100\r\nd={}\r\ng=lambda x,y:d.setdefault(x,set()).add(y)\r\nm,k=map(int,input().split())\r\nfor i in range(m):\r\n a,b=map(int,input().split())\r\n g(a,b)\r\n g(b,a)\r\nr=sorted(d)\r\nw=[]\r\ncnt=0\r\nfor a in r:\r\n e=[str(b) for b in r if a!=b and b not in d[a]and len(d[a]&d[b])/len(d[a])>=k/100]\r\n print(a,\": \",len(e),sep=\"\",end=\" \")\r\n print(*e)\r\n \r\n", "n, k = map(int, input().split())\npeople = {}\ntmp = set()\nfor i in range(n):\n a, b = map(int, input().split())\n if people.get(a) == None:\n people[a] = []\n if people.get(b) == None:\n people[b] = []\n people[a].append(b)\n people[b].append(a)\n tmp.add(a)\n tmp.add(b)\ntmp = sorted(tmp)\nfor i in tmp:\n ans = []\n print(str(i) + ': ', end = '')\n for j in tmp:\n if i == j or people[i].count(j) != 0:\n continue\n cnt = 0\n for fr in people[j]:\n if people[i].count(fr) != 0:\n cnt += 1\n per = (100 * cnt) / len(people[i])\n if int(per) >= k:\n ans.append(j)\n print(len(ans), end = ' ')\n for q in ans:\n print(q, end = ' ')\n print()\n", "m, k = map(int, input().split())\nfr = []\nppl = set()\nfor i in range(m):\n\ta, b = map(int, input().split())\n\tfr.append((a, b))\n\tppl.add(a)\n\tppl.add(b)\npairs = {}\nfor i in ppl:\n\tpairs[i] = set()\nfor i in fr:\n\tpairs[i[0]].add(i[1])\n\tpairs[i[1]].add(i[0])\n# print (pairs)\nfor i in sorted(ppl):\n\ttmp = []\n\tpi = pairs[i]\n\tqwe = len(pi) * k\n\tfor j in ppl:\n\t\tif j in pi or i == j:\n\t\t\tcontinue\n\t\tif len(pi.intersection(pairs[j])) * 100 >= qwe:\n\t\t\ttmp.append(j)\n\tprint(\"%d: %d %s\" % (i, len(tmp), ' '.join(map(str, sorted(tmp)))))", "m,k=map(int,input().split())\r\nd={}\r\nfor _ in range(m):\r\n x,y=map(int,input().split())\r\n d.setdefault(x,set()).add(y)\r\n d.setdefault(y,set()).add(x)\r\nfor x in sorted(d):\r\n ans=[]\r\n for y in sorted(d):\r\n if y in d[x] or y==x: continue\r\n if len(d[x]&d[y])*100>=k*len(d[x]): ans+=[str(y)]\r\n print(str(x)+':',len(ans),' '.join(ans))", "#!/usr/bin/env python\r\n# coding: utf-8\r\n\r\nimport collections\r\n\r\n\r\nfriends = collections.defaultdict(set)\r\n\r\nm, k = map(int, input().split())\r\n\r\nfor _ in range(m):\r\n a, b = map(int, input().split())\r\n friends[a].add(b)\r\n friends[b].add(a)\r\n\r\n\r\nfor a in sorted(friends):\r\n a_friends = friends[a]\r\n probable_friends = []\r\n for b in friends:\r\n if a == b or b in a_friends:\r\n continue\r\n common_friends = a_friends & friends[b]\r\n if 100 * len(common_friends) // len(a_friends) >= k:\r\n probable_friends.append(b)\r\n print(\"%d:\" % a, len(probable_friends), \" \".join(map(str, sorted(probable_friends))))\r\n", "xs = dict()\r\nall = set()\r\n\r\nn, k = map(int, input().split())\r\n\r\nfor i in range(n):\r\n a, b = map(int, input().split())\r\n try:\r\n xs[a].add(b)\r\n except KeyError:\r\n xs[a] = {b}\r\n try:\r\n xs[b].add(a)\r\n except KeyError:\r\n xs[b] = {a}\r\n all.add(a)\r\n all.add(b)\r\n\r\nys = dict()\r\n\r\nfor x in xs:\r\n n = len(xs[x])\r\n r = []\r\n for y in all - xs[x] - {x}:\r\n h = len(xs[x] & xs[y])\r\n if 100 * h >= n * k:\r\n r.append(y)\r\n ys[x] = r\r\n\r\nfor y in sorted(ys.items(), key=lambda p: p[0]):\r\n print('{}: {} {}'.format(y[0], len(y[1]), ' '.join(list(map(str, sorted(y[1]))))))\r\n\r\n", "m, k = list(map(int, input().split()))\r\n\r\nidd = set()\r\nfriends = dict()\r\n\r\nfor i in range(m):\r\n f, s = list(map(int, input().split()))\r\n idd.add(f)\r\n idd.add(s)\r\n if f not in friends.keys():\r\n friends[f] = set()\r\n if s not in friends.keys():\r\n friends[s] = set()\r\n friends[f].add(s)\r\n friends[s].add(f)\r\n\r\npeople = list(idd)\r\npeople.sort()\r\nans = dict()\r\nfor i in range(len(people)):\r\n ans[people[i]] = []\r\n\r\nfor i in range(len(people)):\r\n for j in range(len(people)):\r\n if i == j:\r\n continue\r\n if people[j] in friends[people[i]]:\r\n continue\r\n common = 0\r\n for fr in friends[people[j]]:\r\n if fr in friends[people[i]]:\r\n common += 1\r\n if common * 100 >= k * len(friends[people[i]]):\r\n ans[people[i]].append(people[j])\r\n\r\nfor i in range(len(people)):\r\n print(str(people[i])+ \": \" + str(len(ans[people[i]])) + \" \" + \" \".join(list(map(str, ans[people[i]]))))\r\n \r\n ", "m, k = [int(i) for i in input().split()]\n\nd = {}\nfor i in range(m):\n a, b = [int(i) for i in input().split()]\n if not d.get(a) : d[a] = []\n if not d.get(b) : d[b] = []\n d[a].append(b)\n d[b].append(a)\n\nmbfriends = {}\n\nfor i in d.keys():\n if not mbfriends.get(i) : mbfriends[i] = []\n myk = len(d[i]) * k / 100\n for j in d.keys():\n if i != j and j not in d[i]:\n if len(list(set(d[i]) & set(d[j]))) >= myk:\n mbfriends[i].append(j)\n\nfor i in sorted(d.keys()):\n print(str(i) + \":\", len(mbfriends[i]), end=\" \")\n for j in sorted(mbfriends[i]):\n print(j, end=\" \")\n print()\n\n", "f = lambda: map(int, input().split())\r\ng = lambda x, y: d.setdefault(x, set()).add(y)\r\nd = {}\r\nm, k = f()\r\nfor i in range(m):\r\n a, b = f()\r\n g(a, b)\r\n g(b, a)\r\nt = sorted(d)\r\nfor a in t:\r\n s = [str(b) for b in t if a != b and b not in d[a] and len(d[a] & d[b]) * 100 >= k * len(d[a])]\r\n print(str(a) + ':', len(s), ' '.join(s))", "m, k = [int(x) for x in input().split()]\r\n\r\nseen = 0\r\nusers = set()\r\nfriendsof = {}\r\nfor i in range(m):\r\n\ta, b = [int(x) for x in input().split()]\r\n\tusers.add(a)\r\n\tusers.add(b)\r\n\tif a in friendsof:\r\n\t\tfriendsof[a].add(b)\r\n\telse:\r\n\t\tfriendsof[a] = set((b,))\r\n\tif b in friendsof:\r\n\t\tfriendsof[b].add(a)\r\n\telse:\r\n\t\tfriendsof[b] = set((a,))\r\n\r\nusers_sorted = list(users)\r\nusers_sorted.sort()\r\n\r\nfor u in users_sorted:\r\n\tpossible = []\r\n\tthis_friends = friendsof[u]\r\n\t\r\n\tfor v in users_sorted:\r\n\t\tif v in this_friends: continue\r\n\t\tif v == u: continue\r\n\t\tcommon = friendsof[v].intersection(this_friends)\r\n\t\t\r\n\t\tif len(common) * 100 >= k * len(this_friends):\r\n\t\t\tpossible.append(v)\r\n\t\r\n\tprint('{}:'.format(u), len(possible), *possible)" ]
{"inputs": ["5 51\n10 23\n23 42\n39 42\n10 39\n39 58", "5 100\n1 2\n1 3\n1 4\n2 3\n2 4", "4 1\n1 2\n1 3\n2 3\n4 5", "10 0\n648169314 459970755\n973677547 255163231\n982998000 498743911\n959912791 891928\n404623428 891928\n474720235 271683165\n709045873 539751127\n973677547 179588015\n629049356 622519100\n624998275 958914560", "10 100\n60976680 603454792\n575754027 696647370\n7534463 570826751\n117972518 472387015\n35713567 439985965\n439985965 928160845\n443596853 828504858\n689509731 117972518\n909843480 592765058\n251752353 490387136", "10 50\n389900784 512305545\n839319681 243581524\n653226215 616982889\n448655722 826601897\n681021965 23289895\n719595063 481480420\n919744525 839319681\n231872856 784056465\n971842495 248017394\n653226215 297224467", "10 0\n180745113 666631448\n362104151 349631376\n214251560 538865550\n562805929 576329835\n64121410 646478528\n283223383 861810719\n773038401 214251560\n64208401 693054606\n493180926 960545197\n159614568 831490031", "10 50\n946010975 207263044\n923545573 749203275\n862015642 426425906\n749203275 839134958\n910721783 289091881\n827003531 333726912\n49704846 538788252\n382891592 207263044\n333726912 438209022\n974360048 49704846", "10 100\n570936669 651631651\n508122950 793810569\n374422919 757639639\n395046911 359158844\n544971368 55608511\n554227847 109843524\n199021332 421407912\n82125712 395046911\n923097829 637659245\n754413496 971876441", "1 0\n42 23", "1 1\n42 23", "1 50\n42 23", "1 99\n42 23", "1 100\n42 23", "2 49\n42 23\n23 14", "2 50\n42 23\n23 19", "2 51\n42 23\n23 19", "3 49\n42 23\n23 19\n32 23", "3 50\n42 23\n23 19\n32 23", "3 51\n42 23\n23 19\n32 23", "10 50\n642733947 618790811\n508838679 118350938\n175990043 144671010\n246628250 434416712\n77433126 913934904\n414906480 399777199\n252618318 930317425\n316103842 356219969\n530311152 441130575\n15047025 839165125", "10 0\n106531296 450097353\n947110486 953723914\n774225709 111023810\n774225709 642354614\n559826213 258125349\n768234906 870027419\n4234645 388060649\n870027419 545107061\n484961505 497401821\n76024092 367527096", "10 50\n384319275 425419607\n201879842 153061155\n308316219 268723666\n20837191 401468340\n969142307 78803322\n55247385 365896022\n479817129 222255243\n980789245 697120853\n550086907 652472194\n203728124 229637404", "10 100\n620468113 665248777\n541840309 963681159\n144393749 136223789\n800116851 648535048\n730845154 277782209\n142473309 2838660\n14940106 355463174\n745034887 545886019\n570717131 701899093\n250611530 857683655", "5 66\n4242 1\n4242 2\n4242 3\n2323 1\n2323 2", "5 67\n4242 1\n4242 2\n4242 3\n2323 1\n2323 2", "6 49\n4242 1\n4242 2\n4242 3\n4242 4\n2323 1\n2323 2", "6 50\n4242 1\n4242 2\n4242 3\n4242 4\n2323 1\n2323 2", "6 51\n4242 1\n4242 2\n4242 3\n4242 4\n2323 1\n2323 2", "11 12\n4242 1\n4242 2\n4242 3\n4242 4\n4242 5\n4242 6\n4242 7\n4242 8\n2323 1\n2323 2\n2323 3", "11 13\n4242 1\n4242 2\n4242 3\n4242 4\n4242 5\n4242 6\n4242 7\n4242 8\n2323 1\n2323 2\n2323 3", "79 58\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\n1 50\n1 51\n1 52\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n2 11\n2 12\n2 13\n2 14\n2 15\n2 16\n2 17\n2 18\n2 19\n2 20\n2 21\n2 22\n2 23\n2 24\n2 25\n2 26\n2 27\n2 28\n2 29\n2 30\n2 31"], "outputs": ["10: 1 42\n23: 1 39\n39: 1 23\n42: 1 10\n58: 2 10 42", "1: 0\n2: 0\n3: 1 4\n4: 1 3", "1: 0\n2: 0\n3: 0\n4: 0\n5: 0", "891928: 15 179588015 255163231 271683165 459970755 474720235 498743911 539751127 622519100 624998275 629049356 648169314 709045873 958914560 973677547 982998000\n179588015: 16 891928 255163231 271683165 404623428 459970755 474720235 498743911 539751127 622519100 624998275 629049356 648169314 709045873 958914560 959912791 982998000\n255163231: 16 891928 179588015 271683165 404623428 459970755 474720235 498743911 539751127 622519100 624998275 629049356 648169314 709045873 958914560 959912791 982998000\n27168...", "7534463: 0\n35713567: 1 928160845\n60976680: 0\n117972518: 0\n251752353: 0\n439985965: 0\n443596853: 0\n472387015: 1 689509731\n490387136: 0\n570826751: 0\n575754027: 0\n592765058: 0\n603454792: 0\n689509731: 1 472387015\n696647370: 0\n828504858: 0\n909843480: 0\n928160845: 1 35713567", "23289895: 0\n231872856: 0\n243581524: 1 919744525\n248017394: 0\n297224467: 1 616982889\n389900784: 0\n448655722: 0\n481480420: 0\n512305545: 0\n616982889: 1 297224467\n653226215: 0\n681021965: 0\n719595063: 0\n784056465: 0\n826601897: 0\n839319681: 0\n919744525: 1 243581524\n971842495: 0", "64121410: 17 64208401 159614568 180745113 214251560 283223383 349631376 362104151 493180926 538865550 562805929 576329835 666631448 693054606 773038401 831490031 861810719 960545197\n64208401: 17 64121410 159614568 180745113 214251560 283223383 349631376 362104151 493180926 538865550 562805929 576329835 646478528 666631448 773038401 831490031 861810719 960545197\n159614568: 17 64121410 64208401 180745113 214251560 283223383 349631376 362104151 493180926 538865550 562805929 576329835 646478528 666631448 693...", "49704846: 0\n207263044: 0\n289091881: 0\n333726912: 0\n382891592: 1 946010975\n426425906: 0\n438209022: 1 827003531\n538788252: 1 974360048\n749203275: 0\n827003531: 1 438209022\n839134958: 1 923545573\n862015642: 0\n910721783: 0\n923545573: 1 839134958\n946010975: 1 382891592\n974360048: 1 538788252", "55608511: 0\n82125712: 1 359158844\n109843524: 0\n199021332: 0\n359158844: 1 82125712\n374422919: 0\n395046911: 0\n421407912: 0\n508122950: 0\n544971368: 0\n554227847: 0\n570936669: 0\n637659245: 0\n651631651: 0\n754413496: 0\n757639639: 0\n793810569: 0\n923097829: 0\n971876441: 0", "23: 0\n42: 0", "23: 0\n42: 0", "23: 0\n42: 0", "23: 0\n42: 0", "23: 0\n42: 0", "14: 1 42\n23: 0\n42: 1 14", "19: 1 42\n23: 0\n42: 1 19", "19: 1 42\n23: 0\n42: 1 19", "19: 2 32 42\n23: 0\n32: 2 19 42\n42: 2 19 32", "19: 2 32 42\n23: 0\n32: 2 19 42\n42: 2 19 32", "19: 2 32 42\n23: 0\n32: 2 19 42\n42: 2 19 32", "15047025: 0\n77433126: 0\n118350938: 0\n144671010: 0\n175990043: 0\n246628250: 0\n252618318: 0\n316103842: 0\n356219969: 0\n399777199: 0\n414906480: 0\n434416712: 0\n441130575: 0\n508838679: 0\n530311152: 0\n618790811: 0\n642733947: 0\n839165125: 0\n913934904: 0\n930317425: 0", "4234645: 16 76024092 106531296 111023810 258125349 367527096 450097353 484961505 497401821 545107061 559826213 642354614 768234906 774225709 870027419 947110486 953723914\n76024092: 16 4234645 106531296 111023810 258125349 388060649 450097353 484961505 497401821 545107061 559826213 642354614 768234906 774225709 870027419 947110486 953723914\n106531296: 16 4234645 76024092 111023810 258125349 367527096 388060649 484961505 497401821 545107061 559826213 642354614 768234906 774225709 870027419 947110486 953723...", "20837191: 0\n55247385: 0\n78803322: 0\n153061155: 0\n201879842: 0\n203728124: 0\n222255243: 0\n229637404: 0\n268723666: 0\n308316219: 0\n365896022: 0\n384319275: 0\n401468340: 0\n425419607: 0\n479817129: 0\n550086907: 0\n652472194: 0\n697120853: 0\n969142307: 0\n980789245: 0", "2838660: 0\n14940106: 0\n136223789: 0\n142473309: 0\n144393749: 0\n250611530: 0\n277782209: 0\n355463174: 0\n541840309: 0\n545886019: 0\n570717131: 0\n620468113: 0\n648535048: 0\n665248777: 0\n701899093: 0\n730845154: 0\n745034887: 0\n800116851: 0\n857683655: 0\n963681159: 0", "1: 1 2\n2: 1 1\n3: 2 1 2\n2323: 1 4242\n4242: 1 2323", "1: 1 2\n2: 1 1\n3: 2 1 2\n2323: 1 4242\n4242: 0", "1: 3 2 3 4\n2: 3 1 3 4\n3: 3 1 2 4\n4: 3 1 2 3\n2323: 1 4242\n4242: 1 2323", "1: 3 2 3 4\n2: 3 1 3 4\n3: 3 1 2 4\n4: 3 1 2 3\n2323: 1 4242\n4242: 1 2323", "1: 1 2\n2: 1 1\n3: 3 1 2 4\n4: 3 1 2 3\n2323: 1 4242\n4242: 0", "1: 7 2 3 4 5 6 7 8\n2: 7 1 3 4 5 6 7 8\n3: 7 1 2 4 5 6 7 8\n4: 7 1 2 3 5 6 7 8\n5: 7 1 2 3 4 6 7 8\n6: 7 1 2 3 4 5 7 8\n7: 7 1 2 3 4 5 6 8\n8: 7 1 2 3 4 5 6 7\n2323: 1 4242\n4242: 1 2323", "1: 7 2 3 4 5 6 7 8\n2: 7 1 3 4 5 6 7 8\n3: 7 1 2 4 5 6 7 8\n4: 7 1 2 3 5 6 7 8\n5: 7 1 2 3 4 6 7 8\n6: 7 1 2 3 4 5 7 8\n7: 7 1 2 3 4 5 6 8\n8: 7 1 2 3 4 5 6 7\n2323: 1 4242\n4242: 1 2323", "1: 1 2\n2: 1 1\n3: 28 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31\n4: 28 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31\n5: 28 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31\n6: 28 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31\n7: 28 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31\n8: 28 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2..."]}
UNKNOWN
PYTHON3
CODEFORCES
12
e49b35fb289302baa36a4adb166975a2
Vitaly and Night
One day Vitaly was going home late at night and wondering: how many people aren't sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at that moment. Vitaly sees a building of *n* floors and 2·*m* windows on each floor. On each floor there are *m* flats numbered from 1 to *m*, and two consecutive windows correspond to each flat. If we number the windows from 1 to 2·*m* from left to right, then the *j*-th flat of the *i*-th floor has windows 2·*j*<=-<=1 and 2·*j* in the corresponding row of windows (as usual, floors are enumerated from the bottom). Vitaly thinks that people in the flat aren't sleeping at that moment if at least one of the windows corresponding to this flat has lights on. Given the information about the windows of the given house, your task is to calculate the number of flats where, according to Vitaly, people aren't sleeping. The first line of the input contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=100) — the number of floors in the house and the number of flats on each floor respectively. Next *n* lines describe the floors from top to bottom and contain 2·*m* characters each. If the *i*-th window of the given floor has lights on, then the *i*-th character of this line is '1', otherwise it is '0'. Print a single integer — the number of flats that have lights on in at least one window, that is, the flats where, according to Vitaly, people aren't sleeping. Sample Input 2 2 0 0 0 1 1 0 1 1 1 3 1 1 0 1 0 0 Sample Output 3 2
[ "n,m=list(map(int,input().split()))\r\nc=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n for i in range(0,len(l),2):\r\n if l[i]==0 and l[i+1]==1 or l[i]==1 and l[i+1]==1 or l[i]==1 and l[i+1]==0:\r\n c+=1\r\n i+=1\r\n #i+=1\r\nprint(c)", "# import sys\r\n# sys.stdin=open(\"input.in\",\"r\")\r\n# sys.stdout=open(\"output.out\",\"w\")\r\n\r\nl=list(map(int,input().split()))\r\nn=l[0]\r\nm=l[1]\r\ncount=0\r\nfor i in range(n):\r\n\tp=list(map(int,input().split()))\r\n\tfor j in range(0,len(p)-1,2):\r\n\t\tif(p[j]==1 or p[j+1]==1):\r\n\t\t\tcount+=1\r\nprint(count)\t\t\r\n", "n, m = [int(x) for x in input().split()]\r\nacc = 0\r\nwhile n:\r\n n = n - 1\r\n a_i = [int(x) for x in input().split()]\r\n for i in range(0, 2*m, 2):\r\n if (a_i[i] == 1) or (a_i[i+1] == 1):\r\n acc = acc + 1\r\nprint(acc)\r\n", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for i in range(m):\r\n if a[2*i]+a[2*i+1]>0:\r\n c+=1\r\nprint(c)", "m,n=map(int,input().split())\r\nc=0\r\nfor i in range(m):\r\n\ta=list(map(int,input().split()))\r\n\tfor i in range(0,2*n,2):\r\n\t\tif a[i]==1 or a[i+1]==1:\r\n\t\t\tc+=1\t\t\t\r\nprint(c)", "n, m = input().split()\nn, m = int(n), int(m)\nresult = 0\nfor each_n in range(n):\n windows = [int(i) for i in input().split()]\n i = 0\n while i < 2*m:\n if (windows[i] | windows[i + 1]) == 1:\n result += 1\n i = i + 2\nprint(result)", "# cook your dish here\nn,m = list(map(int,input().split()))\nm=2*m\ncount=0\nwhile(n>0):\n tag=0\n n-=1\n list1=list(map(int,input().split()))\n for i in range(0,m,2):\n #print(list1[i]+list1[i+1])\n if(list1[i]+list1[i+1] >=1):\n count+=1\n \nprint(count)", "\"\"\"\r\nhttps://codeforces.com/problemset/problem/595/A\r\n\"\"\"\r\n\r\nargs = [int(x) for x in input().split(\" \")]\r\nn = args[0]\r\nm = args[1]\r\n\r\nlightsOn = 0\r\n\r\nfor i in range(n):\r\n floor = [int(x) for x in input().split(\" \")]\r\n for j in range(m):\r\n if floor[2*j] == 1 or floor[2*j+1] == 1:\r\n lightsOn += 1\r\n\r\nprint(lightsOn)", "n, m = [int(i) for i in input().split()]\r\nans = 0\r\nfor _ in range(n):\r\n a = [int(i) for i in input().split()]\r\n b = [0]*m\r\n for i in range(m):\r\n if a[2*i] + a[2*i+1] > 0:\r\n ans += 1\r\nprint (ans)", "n,m=map(int,input().split())\r\nx=0\r\nfor i in range(n):\r\n\ta=list(map(int,input().split()))\r\n\tfor j in range(len(a)-1):\r\n\t\tif j%2==0:\r\n\t\t\tif a[j]==1 or a[j+1]==1:\r\n\t\t\t\tx+=1\t\r\nprint(x)", "n, m = map(int, input().split())\r\nsum = 0\r\n\r\nfor i in range (n):\r\n s = input().split()\r\n for i in range (m):\r\n if int(s[2 * i]) == 1 or int(s[2 * i + 1]) == 1:\r\n sum += 1\r\n\r\nprint(sum)\r\n", "l = list(input().split())\r\nn = int(l[0])\r\nm = int(l[1])\r\nawaking = 0\r\nfor i in range(n):\r\n q = list(input().split())\r\n q = [int(j) for j in q]\r\n for h in range(0, 2 * m, 2):\r\n if (q[h] == 0) and (q[h + 1] == 0):\r\n continue\r\n else:\r\n awaking += 1\r\nprint(awaking)", "n, m = [int(x) for x in input().split(' ')]\ncnt = 0\nfor i in range(n):\n f = [int(x) for x in input().split(' ')]\n cnt += sum([1 for x in range(0, len(f) - 1, 2) if f[x] or f[x+1]])\nprint(cnt)\n", "nm = list(map(int, input().split()))\r\nhouse = []\r\nfor k in range(nm[0]):\r\n\thouse.append(list(map(int, input().split())))\r\ncount = 0\r\nfor i in range(nm[0]):\r\n\tfor j in range(0, (2 * nm[1]), 2):\r\n\t\tif house[i][j] == 1 or house[i][j + 1]:\r\n\t\t\tcount += 1\r\nprint(count)", "def curFloor(arr):\r\n res = 0\r\n for i in range(0, len(arr), 2):\r\n if arr[i]==1 or arr[i+1]==1: res += 1\r\n return res\r\n\r\nn, m = [int(x) for x in input().split()]\r\nans = 0\r\nfor i in range(n):\r\n arr = [int(x) for x in input().split()]\r\n ans += curFloor(arr)\r\n\r\nprint(ans)", "n, flat = map(int, input().split())\r\nb = []\r\nfor i in range(n):\r\n b.append(list(map(int, input().split())))\r\nres = 0\r\nfor i in range(n):\r\n for j in range(0,flat*2, 2):\r\n if b[i][j] == 1 or b[i][j+1] == 1:\r\n res += 1\r\nprint(res)", "n, m = input().split()\r\nawake = 0\r\n\r\nfor x in range(int(n)):\r\n windows = list(map(int, input().split()))\r\n for y in range(0,len(windows),2):\r\n if windows[y] == 1 or windows[y+1] == 1:\r\n awake += 1\r\n\r\nprint(awake)", "n, m = list(map(int, input().split()))\nc = 0\nfor i in range(n):\n a = list(map(int, input().split()))\n for j in range(m):\n if a[j * 2] == 1 or a[j * 2 + 1] == 1:\n c += 1\nprint(c)", "floor, win = map(int, input().split())\r\nd={};k=0\r\nfor i in range(floor):\r\n\ta=list(map(int, input().split()))\r\n\tfor j in range(2*win):\r\n\t\tif a[j]==1:\r\n\t\t\td[str(k//2)]=1\r\n\t\tk+=1\r\nprint(len(d.values()))", "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\r\n# from math import *\r\n# from itertools import *\r\n# import random\r\nn, m = map(int, input().split())\r\ntotal_ = 0\r\nfor i in range(n):\r\n arr = list(map(int, input().split()))\r\n for j in range(0, len(arr), 2):\r\n if arr[j] == 1 or arr[j+1] == 1:\r\n total_ += 1\r\n else:\r\n continue\r\nprint(total_)\r\n", "n,m=map(int,input().split())\r\nk=int(0)\r\nfor _ in range(n):\r\n a=list(map(int,input().split()))\r\n x=int(0)\r\n while x<2*m:\r\n if a[x]==1 or a[x+1]==1:\r\n k=k+1\r\n x=x+2\r\nprint(k)", "import math\r\nn, k = list(map(int,input().split()))\r\nm = 0\r\nwhile n:\r\n arr = list(map(int, input().split()))\r\n for i in range(2*k - 1):\r\n if i%2==0:\r\n if arr[i]==1 or arr[i+1]==1:\r\n m = m + 1\r\n n = n - 1\r\nprint(m)\r\n", "[n, m] = [int(x) for x in input().split()]\r\nB = []\r\nc = 0\r\nfor i in range(n): B.append([int(x) for x in input().split()])\r\nfor f in B:\r\n for i in range(0, 2*m, 2):\r\n if f[i] == f[i+1] == 0: c+=1\r\nprint(m*n - c)\r\n \r\n", "import sys\nn, m = map(int, sys.stdin.readline().split())\nans = 0\n\nfor i in range(n):\n windows = list(map(int, sys.stdin.readline().split()))\n for j in range(m):\n if windows[2*j] == 1 or windows[2*j+1]:\n ans += 1\n\nprint(ans)\n\n", "# ===================================\r\n# (c) MidAndFeed aka ASilentVoice\r\n# ===================================\r\n# import math, fractions, collections\r\n# ===================================\r\nn, m = [int(x) for x in input().split()]\r\nans = 0\r\nfor _ in range(n):\r\n\ttemp = [int(x) for x in input().split()]\r\n\tfor i in range(0, 2*m, 2):\r\n\t\tif temp[i] == 1 or temp[i+1] == 1:\r\n\t\t\tans += 1\r\nprint(ans)", "N, M = map(int, input().split())\nSum = 0\nfor i in range(N):\n a = list(map(int, input().split()))\n for j in range(M):\n if a[2*j] or a[2*j + 1]:\n Sum += 1\nprint(Sum)", "a,b = [int(tmp) for tmp in input().split()]\r\nar = []\r\nfor i in range(a) :\r\n\tx = [int(tmp) for tmp in input().split()]\r\n\tar.append(x)\r\nans = 0\r\nfor i in range(a) :\r\n\tfor j in range(0,2*b,2) :\r\n\t\tif ar[i][j] == 1 or ar[i][j+1] == 1 :\r\n\t\t\tans += 1\r\nprint(ans)", "\"\"\"\nCodeforces Round #330 (Div. 2)\n\nProblem 595 A Vitaly and Night\n\n@author yamaton\n@date 2015-11-08\n\"\"\"\n\nimport itertools as it\nimport functools\nimport operator\nimport collections\nimport math\nimport sys\n\ndef chunks(iterable, n, fillvalue=None):\n \"\"\"\n modified grouper function\n https://docs.python.org/3.5/library/itertools.html\n\n >>> list(chunks([1, 2, 3, 4, 5, 6, 7], 3))\n [(1, 2, 3), (4, 5, 6)]\n \"\"\"\n args = [iter(iterable)] * n\n return zip(*args)\n\n\ndef solve(xss):\n return sum(sum(a + b >= 1 for (a, b) in chunks(xs, 2)) for xs in xss)\n\n\n\ndef main():\n [n, m] = [int(i) for i in input().strip().split()]\n xss = [[int(i) for i in input().strip().split()] for _ in range(n)]\n assert len(xss[0]) == 2*m\n result = solve(xss)\n print(result)\n\n\nif __name__ == '__main__':\n main()\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri May 31 01:28:06 2019\r\n\r\n@author: avina\r\n\"\"\"\r\n\r\nn,m = map(int, input().split())\r\ne = 0\r\nfor i in range(n):\r\n l = list(map(int, input().split()))\r\n for i in range(0,2*m -1,2):\r\n if l[i]+l[i+1] > 0:\r\n e+=1\r\nprint(e)\r\n ", "n, m = map(int, input().split())\nc = 0\nfor i in range(n):\n appts = list(map(int, input().split()))\n for j in range(m):\n x = appts[2*j]\n y = appts[2*j + 1]\n c += (1 if (x > 0 or y > 0) else 0)\n\nprint(c)\n", "\"\"\"\ninstagram : essipoortahmasb2018\ntelegram channel : essi_python\n\"\"\"\ni = input\nc = 0\nn, m = map(int,i().split())\nfor j in range(n):\n l = [*map(str,i().split())]\n a = len(l)//m\n qq=0\n ww=a\n for j in range(m):\n if '1' in l[qq:ww]:\n c+=1\n qq+=a\n ww+=a\n \nprint(c)\n\n\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Apr 17 02:17:57 2020\r\n\r\n@author: Anshika\r\n\"\"\"\r\n\r\n\r\nn,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n\tl=list(map(int,input().split()))\r\n\tfor j in range(0,len(l),2):\r\n\t\tif l[j]==1 or l[j+1]==1:\r\n\t\t\tc=c+1\r\nprint(c)\r\n\r\n\r\n \r\n \r\n \r\n\r\n\r\n \r\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nn, m = map(int, input().split())\r\ndata = [list(map(int, input().split())) for _ in range(n)]\r\nmemo = [[False] * m for _ in range(n)]\r\n\r\nfor i in range(n):\r\n for j in range(0, 2 * m, 2):\r\n memo[i][j // 2] = data[i][j] or data[i][j + 1]\r\n\r\ncnt = 0\r\nfor i in range(n):\r\n cnt += memo[i].count(True)\r\n\r\nprint(cnt)", "#!/usr/bin/env python\r\n# -*- coding: utf-8 -*-\r\n\r\nn,m = map(int,input().split())\r\nans = 0\r\nfor i in range(n):\r\n flats = list(map(int,input().split()))\r\n f = [False for i in range(m)]\r\n for j in range(m*2):\r\n f[j//2] |= True if flats[j] == 1 else False\r\n ans += f.count(True)\r\nprint(ans)\r\n", "f,fl=list(map(int,input().split()))\r\nt=0\r\nfor i in range(f):\r\n a=list(map(int,input().split()))\r\n for j in range(0,len(a),2):\r\n if a[j]+a[j+1]>=1:\r\n t+=1\r\nprint(t)\r\n \r\n \r\n", "n, m = list(map(int, input().split()))\n\ns = 0\nfor _ in range(n):\n a = input().split()\n for j in range(0, 2*m, 2):\n s += 1 if (a[j] == '1' or a[j+1] == '1') else 0\nprint(s)\n\n", "l=list(map(int,input().split()))\r\nx=0\r\nfor i in range(l[0]):\r\n m=list(map(int,input().split()))\r\n for j in range(0,2*l[1]-1,2):\r\n if 1 in m[j:j+2]:\r\n x=x+1\r\nprint(x)", "n,m = list(map(int, input().split()))\r\ncnt=0\r\n\r\nfor i in range(n):\r\n lst = list(map(int, input().split()))\r\n \r\n for j in range(0,2*m,2):\r\n if lst[j]==1 or lst[j+1]==1:\r\n cnt+=1\r\n \r\nprint(cnt)", "line1 = (input().split(\" \"))\r\nfloors = int(line1[0])\r\nflats_every_floor = int(line1[1])\r\nall_flats = int(line1[0])*int(line1[1])\r\nawake_flats = 0\r\ncounter = 0\r\n\r\nfor floor in range(floors):\r\n line = (input().split(\" \"))\r\n\r\n for flat in range(flats_every_floor):\r\n if(int(line[flat+counter]) or int(line[flat+counter+1]) == 1):\r\n awake_flats +=1\r\n\r\n counter+=1\r\n counter = 0\r\nprint(awake_flats)\r\n", "n,m = map(int,input().split())\r\ncount = 0\r\nfor i in range(n):\r\n\tlist1 = list(map(int,input().split()))\r\n\tfor j in range(0,m*2,2):\r\n\t\t##print(list1[j:j+2:])\r\n\t\ta = list1[j:j+2:]\r\n\t\tif(1 in a):\r\n\t\t\tcount += 1\r\nprint(count)\r\n\t", "n, m = map(int, input().split())\r\nc = 0\r\n\r\nfor _ in range(n):\r\n lst = [int(i) for i in input().split()]\r\n for i in range(0, 2*m, 2):\r\n if lst[i] == 1 or lst[i+1] == 1:\r\n c += 1\r\n\r\nprint(c)\r\n", "floor, flat = list(map(int, input().split()))\r\nscore = 0\r\nfor _ in range(floor):\r\n lights = list(map(int, input().split()))\r\n for idx in range(0, flat * 2, 2):\r\n if 1 in [lights[idx], lights[idx+1]]:\r\n score += 1\r\nprint(score)\r\n\r\n", "n, m = map(int, input().split())\n\nans = 0\nfor i in range(n):\n A = list(map(int, input().split()))\n for j in range(0, len(A), 2):\n if A[j] == 1 or A[j+1] == 1:\n ans += 1\nprint(ans)\n\n", "[n, m] = [int(x) for x in input().split()]\n\nanswer = 0\n\nfor i in range(n):\n floor = [x for x in input().split()]\n for j in range(m):\n if floor[2*j] == '1' or floor[(2*j)+1] == '1':\n answer += 1\n\nprint(answer)\n\n", "import math\r\nfrom decimal import *\r\nimport sys\r\nfrom fractions import Fraction\r\n\r\ninp=input().split()\r\nn=int(inp[0])\r\nm=int(inp[1])\r\nans=0\r\nfor i in range(0,n):\r\n row = list(map(int,input().split()))\r\n for j in range(0,m):\r\n if row[2*j] == 1 or row[2*j+1] == 1:\r\n ans+=1\r\nprint(ans)\r\n\r\n \r\n \r\n", "n, m = (int(x) for x in input().split())\nans = 0\nfor i in range(n):\n a = [int(x) for x in input().split()]\n ans += sum([max(a[x], a[x + 1]) for x in range(0, m * 2, 2)])\nprint(ans)\n", "n, m = map(int, input().split())\r\ncount = 0\r\nfor j in range(n):\r\n l_w = list(map(int, input().split()))\r\n for i in range(len(l_w) // 2):\r\n if l_w[i * 2] == 1 or l_w[i * 2 + 1] == 1:\r\n count += 1\r\nprint(count)\r\n \r\n", "n,m = map(int, input().split())\r\nans=0\r\nfor i in range(n):\r\n flat=list(map(int,input().split()))\r\n for j in range(m):\r\n if flat[2*j]+flat[2*j+1]>0:\r\n ans+=1\r\nprint(ans)", "n,m=map(int,input().split())\r\ns=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n for j in range(1,len(l),2):\r\n if(l[j]==0 and l[j-1]==1)or(l[j]==1 and l[j-1]==1)or(l[j]==1 and l[j-1]==0):\r\n s+=1\r\nprint(s)\r\n ", "n,m=[int(n) for n in input().split()]\nwindow=list()\nans=0\nfor i in range(0,n):\n\twindow=window+[int(window) for window in input().split()]\n\tfor j in range(0,2*m,2):\n\t\tif window[j]+window[j+1]>0:\n\t\t\tans=ans+1\n\tdel window[0:]\nprint(ans)\n", "def night(n, m, lst):\r\n result = 0\r\n for i in range(n):\r\n for j in range(m):\r\n if lst[i][j * 2] == 1 or lst[i][j * 2 + 1] == 1:\r\n result += 1\r\n return result\r\n\r\n\r\nn, m = [int(x) for x in input().split()]\r\nb = list()\r\nfor y in range(n):\r\n a = [int(z) for z in input().split()]\r\n b.append(list(a))\r\nprint(night(n, m, b))\r\n", "n,m=map(int,input().split())\r\ncnt=0\r\nfor i in range(n):\r\n arr=[]\r\n arr.extend(map(int,input().split()))\r\n for i in range(0,len(arr)-1,2):\r\n if arr[i]==1 or arr[i+1]==1:\r\n cnt+=1\r\nprint(cnt)", "n, m = map(int, input().split())\r\nnet = 0\r\nfor i in range(n):\r\n floor = list(map(int, input().split()))[:2*m]\r\n for j in range(m):\r\n if (floor[2 * j] == 1) or (floor[2 * j + 1] == 1):\r\n net += 1\r\nprint(net)", "n,m=(int(i) for i in input().split())\r\nc=0\r\nfor i in range(n):\r\n l=[int(i) for i in input().split()]\r\n for i in range(0,(2*m),2):\r\n if(l[i]==1):\r\n l[i+1]=0\r\n c+=1\r\n for i in range(1,(2*m),2):\r\n if(l[i]==1):\r\n c+=1\r\nprint(c)", "n, m = map(int, input().split())\r\nans = 0\r\nfor _ in range(n):\r\n\tnums = list(map(int, input().split()))\r\n\tfor i in range(0, 2 * m, 2):\r\n\t\tif sum(nums[i:i+2]):\r\n\t\t\tans += 1\r\nprint(ans)", "n, m = map(int, input().split())\r\ncounter = 0\r\nfor i in range(n):\r\n s = input().split()\r\n for j in range(0, m):\r\n if s[2 * j] == \"1\" or s[2 * j + 1] == \"1\":\r\n counter += 1\r\nprint(counter)\r\n", "n, m = [int(i) for i in input().split()]\r\nw = 0\r\nfor i in range(n):\r\n a = input().split()\r\n for j in range(0, 2 * m - 1, 2):\r\n if a[j] != \"0\" or a[j + 1] != \"0\":\r\n w += 1\r\nprint(w)\r\n \r\n", "l=[int(x) for x in input().split()]\r\nn=l[0]\r\nk=l[1]\r\ncount=0\r\nfor o in range(n):\r\n s=input().split()\r\n i=0\r\n while(i<2*k):\r\n if s[i]==\"1\" or s[i+1]==\"1\":\r\n count+=1\r\n i+=2\r\nprint(count)\r\n", "n,m = map(int,input().split())\r\ncount = 0\r\nfor i in range(n):\r\n j = 0\r\n s = input().split()\r\n while j<2*m:\r\n if '1' in s[j:j+2]:\r\n count += 1\r\n j += 2\r\nprint(count)", "n,m=map(int,input().split())\r\ns=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n #s=0\r\n for i in range(1,len(l),2):\r\n if(l[i-1]==0 and l[i]==1) or (l[i-1]==1 and l[i]==1) or (l[i-1]==1 and l[i]==0):\r\n s+=1\r\nprint(s) ", "num_floors, num_flats = [int(x) for x in input().split()]\r\ncount = 0\r\nfor i in range(num_floors):\r\n\tflats = [int(x) for x in input().split()]\r\n\tfor j in range(num_flats):\r\n\t\tif flats[j * 2] == 1 or flats[j * 2 + 1] == 1:\r\n\t\t\tcount += 1\r\n\r\nprint(count)\r\n", "n, m = map(int, input().split())\nt = 0\nfor _ in range(0, n):\n x = list(map(int, input().split()))\n t += sum([+(a + b >= 1) for a, b in zip(x[::2], x[1::2])])\nprint(t)\n", "n, m = map(int, input().split())\r\ncount = 0\r\nbuilding = []\r\nfor _ in range(n):\r\n building.append(list(map(int, input().split())))\r\nfloor_pairs = []\r\nfor floor in building:\r\n temp = []\r\n for i in range(0, len(floor), 2):\r\n temp.append([floor[i], floor[i+1]])\r\n floor_pairs.append(temp)\r\nfor floor in floor_pairs:\r\n for flat in floor:\r\n if 1 in flat:\r\n count += 1\r\nprint(count)", "# A. Vitaly and Night\n\nn, m = map(int, input().split())\nans = 0\nfor _ in range(n):\n lst = list(map(int, input().split()))\n for j in range(0, 2 * m, 2):\n if lst[j] == 1 or lst[j + 1] == 1:\n ans += 1\nprint(ans)\n", "a,b=map(int,input().split())\r\nc=0\r\nfor _ in range(a):\r\n l=list(map(int,input().split()))\r\n for i in range(0,2*b,2):\r\n if l[i]|l[i+1]==1:\r\n c+=1 \r\nprint(c)", "# import sys\r\n# sys.stdin=open(\"input.in\",\"r\")\r\nn,k=map(int,input().split())\r\nf=0\r\nfor i in range(n):\r\n\tc=list(map(int,input().split()))\r\n\tfor j in range(len(c)-1):\r\n\t\tif j%2==0:\r\n\t\t\tif c[j]==1 or c[j+1]==1:\r\n\t\t\t\tf+=1\t\t\r\nprint(f)\r\n\t\t\r\n", "def vitaly_and_count(a,m):\r\n count=0\r\n for i in range(len(a)):\r\n for j in range(0,2*m,2):\r\n if a[i][j]==1 or a[i][j+1]==1:\r\n count=count+1\r\n #print(i,j)\r\n \r\n \r\n print(count)\r\n\r\n \r\n\r\n\r\n\r\n\r\nn=list(map(int,input('').split()))\r\nb=[]\r\nfor i in range(n[0]):\r\n a=list(map(int,input('').split()))\r\n b.append(a)\r\n\r\nvitaly_and_count(b,n[1])", "first = list(map(int, input().split()))\r\nsecond = []\r\ncounter = 0\r\nfor i in range(first[0]):\r\n second = list(map(int, input().split()))\r\n for j in range(0, first[1] * 2, 2):\r\n if second[j] or second[j + 1] == 1:\r\n counter += 1\r\n\r\nprint(counter)", "n, m = map(int, input().split())\r\ncount = 0\r\nfor i in range(n):\r\n\ta = list(map(int,input().split()))\r\n\tj = 0\r\n\twhile j < m*2:\r\n\t\tif a[j] == 0 == a[j+1]:\r\n\t\t\tcount = count\r\n\t\t\tj+=1\r\n\t\telse:\r\n\t\t\tcount+=1\r\n\t\t\tj+=1\r\n\t\tj+=1\r\nprint(count)\r\n", "n ,m =map(int,input().split())\r\narr = []\r\ncount = 0\r\nfor i in range(n):\r\n ls = list(map(int,input().split()))\r\n arr.append(ls)\r\nfor i in arr:\r\n for j in range(0,2*m,2):\r\n if (i[j] == 1 and i[j+1] == 0) or (i[j] == 0 and i[j+1] == 1) or (i[j] == 1 and i[j+1] == 1):\r\n count+=1\r\nprint(count)\r\n ", "#!/usr/bin/env python\r\n\r\nimport math\r\nimport sys\r\nimport itertools\r\nimport fractions\r\n\r\nif __name__ == '__main__':\r\n wtf = sys.stdin.read()\r\n wtf = wtf.strip().split('\\n')\r\n n,m = map(int, wtf[0].split())\r\n ans = 0\r\n for i in range(n):\r\n A = list(map(int, wtf[i+1].split()))\r\n for i in range(0,2*m-1,2):\r\n if A[i] == 1 or A[i+1] == 1:\r\n ans += 1\r\n print(ans)\r\n", "n,m = map(int,input().split())\r\ncnt = 0\r\nfor i in range(n):\r\n ai = list(map(int,input().split()))\r\n a = 0\r\n for j in range(len(ai)):\r\n if 1 in ai[a:a+2]:\r\n cnt += 1\r\n a+=2\r\nprint(cnt)", "(n,m) = map(int,input().split())\r\nresult = 0\r\nfor i in range(n):\r\n M = [int(s) for s in input().split()]\r\n result += (m - sum([(1-M[2*i])*(1-M[2*i+1]) for i in range(m)]))\r\nprint(result)", "flag=0\r\na=[]\r\nn,m=map(int,input().split())\r\nfor i in range(n):\r\n\ta.append(list(map(int,input().split())))\r\nfor i in range(n):\r\n\tfor j in range(0,2*m,2):\r\n\t\tif a[i][j]==1 or a[i][j+1]==1:\r\n\t\t\tflag+=1\r\nprint(flag)", "io = input().split()\r\nn = int(io[0])\r\nm = int(io[1])\r\n\r\nawake = 0\r\n\r\n\r\nfor i in range(n):\r\n arr = list(map(int, input().split()))\r\n for j in range(0, 2 * m, 2):\r\n # print(\"j\", j)\r\n if (arr[j] == 1) or (arr[j + 1] == 1):\r\n awake += 1\r\n # print(f\"j {j}, awake {awake}\")\r\n\r\nprint(awake)\r\n", "n, m = map(int, input().split())\r\nanswer = 0\r\nfor i in range(n):\r\n row = list(map(int, input().split()))\r\n for j in range(m):\r\n answer += (row[2 * j] or row[2 * j + 1])\r\nprint(answer)\r\n\r\n", "n,m=map(int,input().split())\r\nc=0\r\nfor j in range(n):\r\n x=list(map(int,input().split()))\r\n for i in range(m*2):\r\n if i%2==0 and (x[i]==1 or x[i+1]==1):\r\n c+=1\r\nprint(c)", "fnf = list(map(int,input().split()))\r\nlit=0\r\nfor i in range(fnf[0]):\r\n a = list(map(int,input().split()))\r\n for j in range(fnf[1]):\r\n k=j+1\r\n if a[2*k-1]==1 or a[2*k-2]==1:\r\n lit+=1\r\nprint(lit)", "floor,flat=map(int,input().split())\r\nawake=0\r\nfor i in range(floor):\r\n l=list(map(int,input().split()))\r\n for i in range(0,2*flat-1,2):\r\n if l[i]==1 or l[i+1]==1:\r\n awake+=1\r\nprint(awake)", "#import sys\r\n#sys.stdin = open(\"input.in\",\"r\")\r\n#sys.stdout = open(\"test.out\",\"w\")\r\na,b= map(int, input().split())\r\ncount1=0\r\nfor i in range(a):\r\n\tl=list(map(int,input().split()))\r\n\tfor j in range(b):\r\n\t\tif l[j*2] or l[j*2+1]: \r\n\t\t\tcount1+=1\r\n \r\nprint(count1)", "import time\r\n\r\ndef isAwakeFlat(ligth1, light2):\r\n awake = False\r\n if ligth1 == 0 and light2 == 0:\r\n awake = False\r\n else:\r\n awake = True\r\n\r\n return awake\r\n\r\n\r\ndef countFlatsAwake(floors, flats, buildingList):\r\n awakenFlats =0\r\n for floor in buildingList:\r\n for flat in range(0,flats*2,2):\r\n # print(floor[flat], floor[flat+1])\r\n res = isAwakeFlat(floor[flat], floor[flat+1])\r\n if res == True:\r\n awakenFlats += 1\r\n return awakenFlats\r\n\r\n\r\ndef solve():\r\n floors, flats = [int(x) for x in input().split()]\r\n buildingList = []\r\n\r\n for floor in range(floors):\r\n buildingList.append([int(y) for y in input().split()])\r\n\r\n\r\n print(countFlatsAwake(floors, flats, buildingList))\r\n\r\n\r\n # print(\"%fs\" % (time.time() - start_time))\r\n\r\n\r\nsolve()\r\n", "k=0\r\nn,m=map(int,input().split())\r\nfor i in range(n):\r\n a=[int(i) for i in input().split()]\r\n for i in range(0,m*2,2):\r\n if a[i]==1 or a[i+1]==1:\r\n k+=1\r\nprint(k)", "def solve(n,m,l):\r\n ans = 0\r\n for i in range(n):\r\n for j in range(0,2*m,2):\r\n ans += l[i][j] or l[i][j+1]\r\n return ans\r\nn , m = map(int,input().split())\r\nl = []\r\nfor _ in range(n):\r\n l.append(list(map(int,input().split())))\r\n\r\nprint(solve(n,m,l))", "n,m = map(int,input().split())\r\nres=0\r\nfor i in range(n):\r\n temp=list(map(int,input().split()))\r\n for j in range(0,len(temp),2):\r\n res+=max(temp[j],temp[j+1])\r\nprint(res) \r\n", "n,m=map(int,input().split())\r\ncount=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n\r\n for j in range(0,m*2,2):\r\n # print(j)\r\n if(l[j]==1 or l[j+1]==1):\r\n count+=1\r\n\r\nprint(count)", "n = [int(j) for j in input().split()]\r\nw = 0\r\nfor k in range(n[0]):\r\n s = [int(j) for j in input().split()]\r\n for j in range(n[1]):\r\n if s[2*j] + s[2*j+1] > 0:\r\n w += 1\r\nprint(w)", "from sys import stdin\r\nn,m=map(int,stdin.readline().split())\r\nl=[]\r\nfor i in range(n):\r\n l.append(list(map(int,stdin.readline().split())))\r\ncount=0\r\nfor i in range(n):\r\n for j in range(0,2*m,2):\r\n if l[i][j]==1 or l[i][j+1]==1:\r\n count+=1\r\nprint(count)", "n,m=map(int,input().split())\r\ncount=0\r\na=[]\r\nfor i in range(n):\r\n\ta.append(list(map(int,input().split())))\r\nfor i in range(n):\r\n\tfor j in range(0,2*m,2):\t\r\n\t\tif a[i][j]==1 or a[i][j+1]==1:\r\n\t\t\tcount+=1\r\nprint (count)", "n, m = map(int, input().split() )\na = [list(map(int, input().split() ) ) for _ in range(n) ]\nr = 0\nfor i in range(n):\n for j in range(0, 2*m, 2):\n r += a[i][j] > 0 or a[i][j+1] > 0\nprint(r)\n", "n, m = map(int, input().split())\r\nx = y = res = 0\r\nfor i in range(n):\r\n arr = [int(i) for i in input().split()]\r\n for i in range(len(arr)):\r\n if (i % 2 == 1 and arr[i] + y > 0):\r\n res += 1\r\n y = arr[i]\r\nprint(res)\r\n", "n,m=map(int,input().split())\r\nresult=0\r\nfor _ in range(n):\r\n ls=list(map(int,input().split()))\r\n ls1=ls[::2]\r\n ls2=ls[1::2]\r\n for i in range(m):\r\n if ls1[i]==1 or ls2[i]==1:\r\n result+=1;\r\n\r\nprint(result)", "\"\"\"\r\nIIIIIIIIII OOOOOOOOOOO IIIIIIIIII\r\n II OO OO II\r\n II OO OO II\r\n II OO OO II\r\n II OO OO II\r\n II OO OO II\r\n II OO OO II\r\nIIIIIIIIII OOOOOOOOOOO IIIIIIIIII\r\n\"\"\"\r\nn, m = map(int, input().split())\r\ncnt = 0\r\nfor i in range(n):\r\n\ta = list(map(int ,input().split()))\r\n\tfor j in range(0, 2 * m, 2):\r\n\t\tif a[j] == 1 or a[j + 1] == 1:\r\n\t\t\tcnt += 1\r\nprint(cnt)\r\n\r\n\t\r\n\t\r\n\r\n\t\r\n\t\t\r\n\t\t\r\n\t\r\n", "def max1(a):\r\n\tp = a[0]\r\n\tfor x in a:\r\n\t\tif x > p:\r\n\t\t\tp = x\r\n\treturn p\r\n\r\n\r\ndef prlist(a):\r\n\tfor x in a:\r\n\t\tprint(x, end = \" \")\r\n\t\t\t\r\n\r\ndef fakt(n):\r\n\tp = 1\r\n\tfor i in range(1, n + 1):\r\n\t\tp *= i\r\n\treturn p\r\n\r\n\t\t\t\r\n#row, col = list(map(int, input().split()))\r\n#a = list(map(int, input().split()))\r\nrow, col = list(map(int, input().split()))\r\ncol *= 2\r\na = []\r\nfor i in range(row):\r\n\tb = list(map(int, input().split()))\r\n\ta.append(b)\r\nk = 0\r\nfor i in range(row):\r\n\tfor j in range(col):\r\n\t\tfl = False\r\n\t\tif j % 2 == 1:\r\n\t\t\tif a[i][j - 1] == 1:\r\n\t\t\t\tfl = True\r\n\t\tif not fl and a[i][j]:\r\n\t\t\tk += 1\r\nprint(k)\r\n\t\r\n\t\t\r\n\t\t\r\n", "# -*- coding: utf-8 -*-\n\nn, m = [int(x) for x in input().split()]\n# print(n, m)\n\nnum = 0\nfloors = []\nflats = []\n\ni = 1\nwhile i <= n:\n\n for x in [int(x) for x in input().split()]:\n flats.append(x)\n\n floors.append(flats)\n flats = []\n\n i += 1\n\ni = 0\nwhile i < n:\n j = 1\n while j < 2*m:\n if floors[i][j]+floors[i][j-1] is not 0:\n num += 1\n j += 2\n i += 1\n\nprint(num)\n\t \t \t \t\t \t\t \t \t\t \t \t\t \t\t \t", "from sys import stdin\r\n\r\nn, m = map(int, stdin.readline().split())\r\n\r\nres = 0\r\nfor i in range(0, n):\r\n k = list(map(int, stdin.readline().split()))\r\n for j in range(0, (2 * m) - 1, 2):\r\n if k[j] + k[j + 1] != 0:\r\n res += 1\r\n \r\nprint(res)", "n, m = list(map(int,input().split()))\r\nnum = int()\r\n\r\nfor x in range(n):\r\n inp = list(map(int,input().split()))\r\n for y in range(0,2*m,2):\r\n if inp[y]+inp[y+1] != 0:\r\n num = num + 1\r\nprint(num)", "import sys\n\n\n#sys.stdin = open(\"input.txt\")\n#sys.stdout = open(\"output.txt\", \"w\")\n\nn, m = (int(i) for i in input().split())\nans = 0\nfor i in range(n):\n\tlst = [int(j) for j in input().split()]\n\tfor j in range(m):\n\t\tif lst[2*j] == 1 or lst[2*j + 1] == 1:\n\t\t\tans += 1\nprint(ans)\t", "I = lambda:map(int, input().split())\r\nn, m = I()\r\nans = 0\r\nfor _ in range(n):\r\n\ta = list(I())\r\n\tans += sum([a[i*2]+a[i*2+1] > 0 for i in range(m)])\r\nprint(ans)", "def solve(n, m):\r\n\r\n count = 0\r\n for _ in range(n):\r\n test = list(map(int, input().split()))\r\n for i in range(0, m * 2, 2):\r\n if test[i] or test[i+1]:\r\n count += 1\r\n\r\n return count\r\n\r\n\r\nif __name__ == \"__main__\":\r\n n, m = map(int, input().split())\r\n print(solve(n, m))", "a,b = list(map(int,input().split()))\r\nsum = 0\r\nfor i in range (a):\r\n s = list(map(int,input().split()))\r\n for j in range (0,2*b,2):\r\n if s[j] == 1 or s[j+1]==1: sum += 1\r\nprint(sum)", "n, m = map(int, input().split())\r\nans = 0\r\nfor i in range(n):\r\n a = list(map(int, input().split()))\r\n for j in range(0, 2 * m, 2):\r\n if a[j] == 1 or a[j + 1] == 1:\r\n ans += 1\r\nprint(ans)", "n,m = map(int, input().split(' '))\r\nres = 0\r\nfor _ in range(n):\r\n i = 0\r\n li = list(map(int, input().split(' ')))\r\n var = []\r\n for j in li:\r\n if i % 2 == 0:\r\n var.append(j)\r\n i += 1\r\n else:\r\n var.append(j)\r\n i = 0\r\n if len(var) == 2:\r\n if 1 in var:\r\n res += 1\r\n var = []\r\nprint(res)\r\n", "s=0\r\nn,m=map(int,input().split())\r\nfor x in range(n):\r\n\tl=list(map(int,input().split()))\r\n\tfor x in range(m):\r\n\t\tif l[2*x]==1 or l[(2*x)+1]:\r\n\t\t\ts+=1\r\nprint(s)", "n,m=map(int,input().split())\r\ns=0\r\nfor i in range(n):\r\n \r\n a=list(map(int,input().split()))\r\n for j in range(m):\r\n #for k in range(0,len(a)-1):\r\n if a[j*2] or a[j*2+1]:\r\n \r\n s+=1\r\n #s.append(a[i])\r\n \r\nprint(s)\r\n", "r,a=map(int,input().split())\r\nf=0\r\nfor n in range(r):\r\n s=list(map(int,input().split()))\r\n for t in range(0,2*a-1,2):\r\n if s[t]==0 and s[t+1]==0:\r\n f=f+0\r\n \r\n else:\r\n f=f+1\r\n \r\n\r\nprint(f)", "I=lambda:list(map(int,input().split()))\r\nn,m=I()\r\nr=0\r\nfor _ in range(n):\r\n a=I()\r\n r+=sum([a[i*2]+a[i*2+1]>0 for i in range(m)])\r\nprint(r)", "n, m = map(int, input().split())\r\ns = 0\r\nfor i in range(n):\r\n f = list(map(int, input().split()))\r\n for j in range(0, m*2, 2):\r\n if f[j] == 1 or f[j+1] == 1:\r\n s += 1\r\nprint(s)\r\n", "n, m = map(int, input().split())\r\n\r\nwake = 0\r\nfor i in range(n):\r\n w = list(map(int, input().split()))\r\n for j in range(m):\r\n if w[2 * j] + w[2 * j + 1] > 0:\r\n wake += 1\r\n\r\nprint(wake)", "n,m=[int(i)for i in input().split()]\r\nc=0\r\nfor i in range(n):\r\n x=[int(j)for j in input().split()]\r\n for k in range(2*m):\r\n if k%2==1:\r\n if x[k]==1 or x[k-1]==1:\r\n c=c+1\r\nprint(c)", "n,m=map(int, input().split()); s=0\r\nfor i in range(n):\r\n a=list(map(int, input().split()))\r\n for j in range(0,2*m,2):\r\n if a[j]==1 or a[j+1]==1:\r\n s+=1\r\nprint(s)", "n, m = map(int, input().split())\na = [list(map(int, input().split())) for _ in range(n)]\ns = 0\nfor i in range(n):\n\tfor j in range(m):\n\t\ts += 1 if a[i][j*2] == 1 or a[i][j*2+1] == 1 else 0\nprint(s)\n", "import sys\r\nn,m = map(int,input().split())\r\ncnt = 0\r\nfor i in range(n):\r\n arr = list(map(int,input().split()))\r\n for j in range(0,m*2,2):\r\n if( arr[j] == 1 or arr[j+1] == 1 ):\r\n cnt += 1\r\nprint (cnt)", "q=input().split()\r\nn=int(q[0]) # n - kol-vo itasey\r\nm=int(q[1]) # m - rol-vo kvartir\r\ns=list()\r\nsumma=0\r\npr=0\r\nfor i in range(0,n) :\r\n s.append(input().split())\r\nk=0\r\nfor i in range (0,n) :\r\n for j in range (0,m) :\r\n if int(s[i][k]) == 1 :\r\n pr=1\r\n k+=1\r\n if int(s[i][k]) == 1 :\r\n pr=1\r\n if pr==1 :\r\n summa +=1\r\n k+=1\r\n pr=0\r\n k=0\r\n pr=0\r\nprint(summa)", "n, m = input().split()\r\n\r\nn, m = int(n), int(m)\r\n\r\nc = 0\r\nfor x in range(1, n+1):\r\n windows = input().split()\r\n for w in range(0, len(windows), 2):\r\n if windows[w] == \"1\" or windows[w+1] == \"1\":\r\n c += 1\r\nprint(c)", "a,b=map(int,input().split())\r\nc=0\r\nfor i in range(a):\r\n *d,=map(int,input().split())\r\n d=[bool(d[2*j]+d[2*j+1])for j in range(b)]\r\n c+=sum(d)\r\nprint(c)\r\n", "n,m=list(map(int,input().split()))\r\nans=0\r\nfor i in range(n):\r\n\tt=list(map(int,input().split()))\r\n\tfor j in range(m):\r\n\t\tif t[j*2]==1 or t[j*2+1]==1:\r\n\t\t\tans+=1\r\nprint(ans)", "n,m=map(int,input().split())\r\nans=0\r\nfor _ in range(n):\r\n a=list(map(int,input().split()))\r\n for i in range(0,m):\r\n if a[2*i]==1 or a[2*i+1]==1:\r\n ans+=1\r\nprint(ans)\r\n", "n,m=input().split()\r\nc=0\r\nn=int(n)\r\nm=int(m)\r\nfor i in range(n):\r\n\tl=list(map(int,input().split()))\r\n\tfor j in range(0,2*m,2):\r\n\t\tif l[j]==1 or l[j+1]==1:\r\n\t\t\tc+=1\r\nprint(c)", "n, m = map(int, input().split(\" \"))\r\nt = 0\r\ncount = 0\r\nwhile t < n:\r\n win = [int(i) for i in input().split(\" \")]\r\n t += 1\r\n for j in range(0,2*m-1,2):\r\n if win[j] + win[j+1] > 0:\r\n count += 1\r\nprint(count)", "x = input().split(\" \")\r\nfloor = int(x[0])\r\nflat = int(x[1])\r\n\r\nt = 0\r\nfor i in range(floor):\r\n w = input().split(\" \")\r\n for i in range(len(w) // 2):\r\n if w[2 * i] == \"1\" or w[2 * i + 1] == \"1\":\r\n t += 1 \r\nprint(t) \r\n", "n, m = map(int, input().split())\r\nc = 0\r\nfor i in range(n):\r\n a = list(map(int, input().split()))\r\n for i in range(0,len(a),2):\r\n if a[i] == 0 and a[i+1] == 0:\r\n c = c + 1\r\nprint(n*m - c)", "n,m=list(map(int,input().strip().split()))\r\nt=0\r\nfor i in range(n):\r\n l=list(map(int,input().strip().split()))\r\n for j in range(0,2*m,2):\r\n if l[j]==1 or l[j+1]==1:\r\n t +=1\r\nprint(t)\r\n \r\n", "n, m = map(int, input().split())\r\narr = [input().split() for _ in range(n)]\r\nc = 0\r\nfor i in range(n):\r\n for j in range(0,2*m,2):\r\n if arr[i][j] == '1' or arr[i][j+1] == '1':\r\n c += 1\r\nprint(c)\r\n", "floor,flat=map(int,input().split())\r\nl1=[]\r\nlon=0\r\nfor i in range(floor):\r\n\tflat1=input().split()\r\n\tj=0\r\n\tk=1\r\n\tfor i in range(flat):\r\n\t\tl2=flat1[i+j],flat1[k]\r\n\t\tk+=2\r\n\t\tj+=1\r\n\t\tl1.append(l2)\r\n# print(l1)\r\nfor i in range(len(l1)):\r\n\tif l1[i][0] ==\"1\" or l1[i][1] == \"1\":\r\n\t\tlon+=1\r\nprint(lon)", "#!/usr/bin/env python3\n\ndef piter(s):\n b = True\n for x in s:\n if b:\n p = x\n else:\n yield p, x\n del p\n b = not b\n if not b:\n yield p, None\n \n\ndef awake(windows):\n k = 0\n for row in windows:\n for w1, w2 in piter(row):\n k += bool(w1 or w2)\n return k\n\n\nif __name__ == '__main__':\n n, m = map(int, input().split())\n windows = (map(int, input().split()) for _ in range(n))\n print(awake(windows))\n", "n, m = map(int, input().split())\r\ncnt = 0\r\nfor i in range(n):\r\n ls = list(map(int, input().split()))\r\n for i in range(0, 2*m, 2):\r\n if ls[i] or ls[i+1]: cnt+=1\r\nprint(cnt)\r\n", "a = input().split()\r\n\r\nb = []\r\nfor i in range(int(a[0])):\r\n b.append(input())\r\n\r\ntotal = 0\r\nfor i in b:\r\n for j in range(0,4*int(a[1]),4):\r\n if i[j]+i[j+2]!='00':\r\n total += 1\r\nprint(total)\r\n", "n,m=[int(x) for x in input().split()]\r\nres=0\r\nfor i in range(n):\r\n d=False\r\n t=False\r\n for j in [int(x) for x in input().split()]:\r\n if not t and j:\r\n t=True\r\n res+=1\r\n if d==True:t=False\r\n d=not d\r\nprint(res)\r\n", "etaj, kvart = map(int, input().split())\r\nOkna = []\r\n\r\nnotsleep = 0\r\n\r\nfor i in range(0, etaj):\r\n Okna.append(list(map(int, input().split())))\r\n\r\nfor i in range(0, etaj):\r\n for j in range(0, (kvart*2)-1, 2):\r\n if Okna[i][j] or Okna[i][j+1] == 1:\r\n notsleep += 1\r\n \r\nprint(notsleep)\r\n", "n, m = map(int, input().split())\r\narr = [0] * n\r\ncnt = 0\r\nfor i in range(n):\r\n arr[i] = [int(x) for x in input().split()]\r\n\r\nfor i in range(n):\r\n for j in range(0, 2 * m, 2):\r\n try:\r\n if arr[i][j] == 1 or arr[i][j+1] == 1:\r\n cnt += 1\r\n except:\r\n pass\r\n\r\nprint(cnt)", "n, m = [int(i) for i in input().split()]\r\nl = 0\r\nfor i in range (n):\r\n a = [int(i) for i in input().split()]\r\n b = 0\r\n for j in range(len(a)):\r\n if(b == len(a)):\r\n break\r\n if(a[b] == 1 or a[b+1] == 1):\r\n l += 1\r\n b += 2\r\nprint (l)\r\n", "nm = input().split()\r\ncounter = 0\r\nfor x in range(int(nm[0])):\r\n n = list(map(int, input().split()))\r\n for x in range(0, int(nm[1])*2, 2):\r\n if n[x] + n[x+1] > 0:\r\n counter += 1\r\nprint(counter)", "f , a = map(int,input().split())\r\nl = []\r\ncount=0\r\nfor i in range(f):\r\n \r\n flat = map(int,input().split())\r\n l.extend(flat)\r\n\r\nfor i in range(0,len(l),2):\r\n if l[i] or l[i+1]:\r\n count+=1\r\n\r\nprint(count)", "n, m = map(int, input().split())\r\nnot_sleeping = 0\r\n\r\nfor _ in range(n):\r\n floor = list(map(int, input().split()))\r\n not_sleeping += sum(floor[2 * i] or floor[2 * i + 1] for i in range(m))\r\n\r\nprint(not_sleeping)", "n,m=map(int,input().split())\r\ns=0\r\nfor i in range(n):\r\n q=list(map(int,input().split()))\r\n for j in range(0,len(q),2):\r\n if(q[j]==1 or q[j+1]==1):\r\n s+=1\r\nprint(str(s),end=\"\")", "# import sys\r\n# sys.stdin = open(\"test.in\",\"r\")\r\n# sys.stdout = open(\"test.out\",\"w\")\r\nn,k=map(int,input().split())\r\nf=0\r\nfor i in range(n):\r\n\tc=list(map(int,input().split()))\r\n\tfor j in range(len(c)-1):\r\n\t\tif j%2==0:\r\n\t\t\tif c[j]==1 or c[j+1]==1:\r\n\t\t\t\tf+=1\t\t\r\nprint(f)", "n, m = map(int, input().split())\r\nt = 0\r\nfor u in range(n):\r\n lst = list(map(int, input().split()))\r\n for x in range(1, m + 1):\r\n if lst[x * 2 - 2] == 1 or lst[x * 2 - 1] == 1: t += 1\r\nprint(t)", "n,m=map(int,input().split())\r\nk=0\r\nfor i in range(n):\r\n d=input().split()\r\n for j in range(m):\r\n if '1' in d[j*2:j*2+2]: k+=1\r\nprint(k)\r\n", "floors,flats=map(int,input().split())\nl=[]\nfor i in range(floors):\n l.append(list(map(int,input().split())))\ncount=0\nfor i in range(floors):\n j=0\n while(j+1<2*flats):\n if(l[i][j]==1 or l[i][j+1]==1):\n count+=1\n j+=2\nprint(count) \n", "n, m = map(int, input().split())\nm2 = 2*m\ncount = 0\nfor i in range(n):\n floor = list(map(int, input().split()))\n\n for j in range(0,m2,2):\n if floor[j] == 1 or floor[j+1] == 1:\n count += 1\n\nprint(count)", "n,m = map(int,input().split())\r\ncount=0\r\nwhile(n):\r\n li = list(map(int,input().split()))\r\n for i in range(0,len(li)-1,2):\r\n if li[i] or li[i+1]:\r\n count+=1\r\n li=[] \r\n n-=1\r\nprint(count) ", "n,m=[int(x) for x in input().split()]\na=[[int(x) for x in input().split()] for x in range(n)]\nc=0\nfor i in range(n):\n\tfor j in range(0,2*m,2):\n\t\tif a[i][j]==1 or a[i][j+1]==1:\n\t\t\tc+=1\nprint(c)\n", "def answer():\r\n z = [int(x) for x in input().split()]\r\n n,m=z[0],z[1]\r\n ans=0\r\n while n:\r\n a = [int(x) for x in input().split()]\r\n i=0\r\n while i<len(a):\r\n if a[i] or a[i+1]:\r\n ans+=1\r\n i+=2\r\n n-=1\r\n print(ans)\r\nanswer()", "li=list(map(int, input().split()))\r\nn=li[0]\r\nres=[]\r\nfor i in range(li[0]):\r\n res.append(list(map(int, input().split())))\r\n#print(res)\r\nres1=[res[a][b] for a in range(len(res)) for b in range(len(res[a]))]\r\n#print(res1)\r\nult=0\r\nfor i in range(0,len(res1),2):\r\n if res1[i]==1 or res1[i+1]==1:\r\n ult+=1\r\nprint(ult)\r\n", "n,m=map(int,input().split())\r\nk=0\r\nfor i in range(n):\r\n a=[int(i) for i in input().split()]\r\n for i in range(0,2*m,2):\r\n if(a[i]==1 or a[i+1]==1):\r\n k+=1\r\nprint(k)", "n, m = map(int, input().split())\r\nc = 0\r\nfor i in range(0, n):\r\n l = list(map(int, input().split()))\r\n for j in range(0, 2*m, 2):\r\n if l[j] == 0 and l[j+1] == 0:\r\n continue\r\n else:\r\n c += 1\r\nprint(c)\r\n", "n, m = map(int, input().split())\ncount = 0\nfor i in range(n):\n s = input().split()\n for j in range(0, 2 * m, 2):\n if s[j] == \"1\" or s[j + 1] == \"1\":\n count += 1\nprint(count)\n", "x = [int(i) for i in input().split()]\r\nn = x[0]\r\nm = x[1]\r\ntot = 0\r\n\r\nfor i in range (n):\r\n a = [int(i) for i in input().split()]\r\n for j in range (0,2*m,2):\r\n if a[j] == 1 or a[j+1] == 1:\r\n tot += 1\r\n\r\nprint(tot)\r\n \r\n", "n, m = map(int, input().split())\r\nmat = []\r\nfor _ in range(n): \r\n mat.append(list(map(int, input().split())))\r\n\r\ncnt = 0 \r\nfor i in range(n):\r\n for j in range(0, 2*m, 2):\r\n if mat[i][j] == 1 or mat[i][j+1] == 1:\r\n cnt += 1\r\nprint(cnt)", "numbers = input().split(\" \")\r\nn = int(numbers[0])\r\nm = int(numbers[1])\r\n\r\nawakeCount = 0\r\n\r\nfor i in range(n):\r\n current = input().split(\" \")\r\n for j in range(m):\r\n if current[2*j] == '1' or current[2*j+1] == '1':\r\n awakeCount += 1\r\n\r\nprint(awakeCount)", "def func(arr):\r\n t=0\r\n ans=0\r\n for i in range(len(arr)):\r\n if i%2==0:\r\n if t>0:\r\n ans+=1\r\n t=0\r\n t+=arr[i]\r\n if t>0:\r\n ans+=1\r\n return ans\r\n \r\n\r\n\r\ninf=list(map(int,input().split()))\r\nn,m=inf[0],inf[1]\r\nans=0\r\nfor i in range(n):\r\n inf=list(map(int,input().split()))\r\n ans=ans+func(inf)\r\nprint(ans)", "n, m = [int(x) for x in input().split()]\r\n\r\nret = 0\r\n\r\nfor i in range(n):\r\n a = [int(x) for x in input().split()]\r\n for i in range(m):\r\n ti = i << 1\r\n if a[ti] == 1 or a[ti + 1] == 1:\r\n ret += 1\r\n\r\nprint(ret)", "n,m=map(int,input().split())\r\ncount=0\r\n\r\nwhile n:\r\n a=list(map(int,input().split()))\r\n a_len=len(a)\r\n while a_len>0:\r\n if a[a_len-1] or a[a_len-2]:\r\n count=count+1\r\n a_len=a_len-2\r\n n=n-1\r\n\r\nprint(count)", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n for i in range(0,2*m,2):\r\n if l[i]==1 or l[i+1]==1:\r\n c+=1\r\nprint(c)", "n,m=map(int,input().split())\r\nco=0\r\nfor et in range(n):\r\n okni=list(map(int,input().split()[:(2*m)]))\r\n for u in range(0,m*2,2):\r\n if okni[u]==0 and okni[u+1]==0:\r\n u=u\r\n else:\r\n co+=1\r\nprint(co)\r\n \r\n", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n f=list(map(int,input().split()))\r\n for j in range(0,2*m,2):\r\n if(f[j]+f[j+1]>0):\r\n c+=1\r\nprint(c)", "n,m = map(int,input().split())\r\ncount=0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for j in range(0,2*m,2):\r\n if a[j]==1 or a[j+1]==1:\r\n count=count+1\r\nprint(count)", "lightFlats = 0\r\nfloors, flats = map(int, input().split(\" \"))\r\nfor i in range(floors):\r\n flatsLightings = list(map(int, input().split(\" \")))\r\n for j in range(1, flats * 2, 2):\r\n if flatsLightings[j] == 1 or flatsLightings[j -1] == 1:\r\n lightFlats += 1\r\nprint(lightFlats)", "l = list(map(int,input().split()))\r\ntotal = 0\r\n\r\nfor i in range(l[0]):\r\n l1 = list(map(int,input().split()))\r\n for j in range(0,len(l1),2):\r\n if l1[j] == 1 or l1[j+1] == 1:\r\n total += 1\r\n \r\n \r\nprint(total)\r\n \r\n ", "import re\r\nn,m=map(int,input().split())\r\nr=0\r\nfor i in range(n):\r\n r+=sum(1 for x in re.split('(\\d \\d)',input()) if x.count('1'))\r\nprint(r)", "n,m = map(int, input().split())\r\nx=0\r\nfor a in range(n):\r\n win = [int(z)for z in input().split()]\r\n for i in range(m):\r\n if win[2*i]+win[2*i+1]:\r\n x+=1\r\nprint(x)", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n l1=list(map(int,input().split()))\r\n while(len(l1)>0):\r\n if(l1[0]==1 or l1[1]==1):\r\n c+=1\r\n l1.pop(0)\r\n l1.pop(0)\r\nprint(c)", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n\ta=list(map(int,input().split()))\r\n\tfor j in range(m):\r\n\t\tif a[2*j]==1:\r\n\t\t\tc+=1\r\n\t\telif a[2*j+1]==1:\r\n\t\t\tc+=1\r\nprint(c,end='')\r\n", "a = input().split()\r\nn = int(a[0])\r\nm = int(a[1])\r\nx = 0\r\nfor i in range(n):\r\n a = input().split()\r\n for i in range(m):\r\n if int(a[2 * i]) == 1 or int(a[2 * i + 1]) == 1:\r\n x += 1\r\nprint(x)\r\n", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n for i in range(0,len(l)-1,2):\r\n if(l[i]==1 or l[i+1]==1):\r\n c=c+1\r\nprint(c) ", "a,b=map(int,input().split())\r\ns=0\r\nfor i in range(a):\r\n x=list(map(int,input().split()))\r\n for j in range(b):\r\n if any(x[2*j:2*j+2]):\r\n s+=1\r\n\r\nprint(s)", "a,b=map(int,input().split())\r\nsum1=0\r\nfor i in range(a):\r\n ls=[*map(int,input().split())]\r\n for k in range(0,2*b,2):\r\n sum1 += ls[k] or ls[k+1]\r\nprint(sum1)", "n,m = map(int, input().split())\nans = 0;\nfor i in range(n):\n\tints = list(map(int, input().split()))\n\tfor j in range(m):\n\t\tif any(ints[2*j: 2*j+2]):\n\t\t\tans += 1\nprint (ans)\n", "n,m=map(int,input().split())\r\nc=0\r\nfor k in range(n):\r\n\ta=list(map(int,input().split()))\r\n\tfor i in range(m):\r\n\t\tif a[2*i]==1 or a[2*i+1]==1:\r\n\t\t\tc+=1\r\nprint(c)", "n, m = list(map(int, input().split()))\ncount = 0\nfor i in range(n):\n x = list(map(int, input().split()))\n for j in range(m):\n if x[2 * j] == 1 or x[2 * j + 1] == 1:\n count += 1\nprint(count)\n", "a, b = map(int,input().split())\nans = 0\nfor i in range(a):\n\tl = list(map(int,input().split()))\n\tx = 0\n\tfor i in range(b):\n\t\tif l[x] == 1 or l[x + 1] == 1:\n\t\t\tans += 1\n\t\tx += 2\nprint(ans) \n", "n, m = map(int, input().split())\r\n\r\nans = 0\r\nfor i in range(n):\r\n r = list(map(int, input().split()))\r\n for j in range(0, len(r), 2):\r\n if r[j] == 1 or r[j + 1] == 1:\r\n ans += 1\r\nprint(ans) ", "n, m = map(int,\r\n input().split())\r\nar = [[int(i) for i in input().split()] for i in range(n)]\r\nc = 0\r\nk = len(ar[0])//m\r\nfor i in range(n):\r\n for j in range(0, len(ar[i]), k):\r\n if 1 in ar[i][j:j+k]:\r\n c += 1\r\nprint(c)\r\n", "n, m = [int(x) for x in input().split()]\n\nc = 0\nfor _ in range(n):\n a = [int(x) for x in input().split()]\n for i in range(m):\n if a[i * 2] or a[i * 2 + 1]:\n c += 1\n\nprint(c)\n", "n,m = input().split()\nwake = 0\nfor i in range(int(n)):\n flats = input().split()\n for j in range(0,int(m) * 2,2):\n if flats[j] == '1' or flats[j+1] == '1':\n wake +=1\nprint(wake)", "(n, m) = [int(i) for i in input().strip().split(' ')]\r\ncount = 0\r\nfor i in range(n):\r\n l = [int(j) for j in input().strip().split(' ')]\r\n for k in range(0, 2*m, 2):\r\n if l[k] == 1 or l[k+1] == 1:\r\n count += 1\r\nprint(count)\r\n", "n_ = input().split()\r\ntotal = 0\r\nfor _ in range(int(n_[0])):\r\n n = input().split()\r\n for i in range(1, 2* int(n_[1]), 2):\r\n if n[i] == '1':\r\n total += 1\r\n elif n[i - 1] == '1':\r\n total += 1\r\nprint(total)", "n,m = [int(i) for i in input().split(' ')]\n\ncnt = 0\nfor i in range(n):\n line = [int(j) for j in input().split(' ')]\n for k in range(m):\n if (line[2*k] or line[2*k+1]):\n cnt+=1\nprint(cnt)\n", "# import sys\n# import time\n# sys.stdin=open(\"utest.in\",\"r\")\n# sys.stdout=open(\"utest.out\",\"w\")\n\nn,m=map(int,(input().split()))\nq=0\nfor i in range(n):\n\tw=input().split()\n\tfor j in range(0,len(w),2):\n\t\t# print(j)\n\t\tif w[j]==\"1\" or w[j+1]==\"1\":\n\t\t\tq+=1\nprint(q)\n\n\n\n", "n, m = list(map(int, input().split()))\r\nsum = 0\r\nfor i in range(n):\r\n l = list(map(int, input().split()))\r\n for j in range(m):\r\n if l[2*j] or l[2*j+1]:\r\n sum += 1 \r\nprint(sum)", "n, m = map(int, input().split())\r\nans = 0\r\nfor i in range(n):\r\n tempLst = list(map(int, input().split()))\r\n indx = 0\r\n for j in range(indx, len(tempLst) // 2):\r\n if(indx >= len(tempLst)):\r\n break\r\n first = tempLst[indx]\r\n second = tempLst[indx + 1]\r\n if(first == 1 or second == 1):\r\n ans += 1\r\n indx += 2\r\nprint(ans)", "n,m = map(int,input().split())\r\np=0\r\nfor i in range(n): \r\n line = [int(x) for x in input().split()]\r\n for i in range(m):\r\n if max(line[2*i],line[2*i+1]) == 1:\r\n p += 1\r\nprint(p)", "counter = 0\n\nentrada = str(input())\nentrada = [int(x) for x in entrada.split()]\n\nn = entrada[0]\nm = entrada[1]\n\nfor i in range(n):\n floor = str(input())\n floor = [int(x) for x in floor.split()]\n\n for j in range(0,2*m,2):\n if floor[j] == 1 or floor[j+1] == 1:\n counter += 1\n\nprint(counter)\n", "n, m = map(int, input().split())\r\nwindows = [list(map(int, input().split())) for _ in range(n)]\r\non = 0\r\nfor i in range(n):\r\n for j in range(m):\r\n on += windows[i][2*j] or windows[i][2*j+1]\r\nprint(on)\r\n", "\nn,m = [int(x) for x in input().split(' ')]\n\nA = []\nfor i in range(n):\n for x in [int(x) for x in input().split(' ')]:\n A.append(x)\n\nt = 0\nfor i in range(int(len(A)/2)):\n a = A[2*i]\n b = A[2*i+1]\n if a + b != 0:\n t+= 1\nprint(t)\n\n", "n,m=map(int,input().split())\r\na=[]\r\narr=[]\r\ncount=0\r\nfor i in range(0,n):\r\n arr=list(map(int,input().strip().split()))[:2*m]\r\n a.append(arr)\r\nfor i in range(0,n):\r\n j=0\r\n while(j<2*m-1):\r\n if a[i][j]==1 or a[i][j+1]==1:\r\n count+=1\r\n j+=2\r\nprint(count)", "a, b = map(int, input().split())\r\nx = []\r\nfor i in range(a):\r\n x.append(list(map(int, input().split())))\r\nr = 0\r\nfor i in x:\r\n for j in range(0, len(i), 2):\r\n r += i[j] or i[j+1]\r\nprint(r)", "floors, flats = map(int, input().split())\n\nflats_with_lights_on = 0\n\nfor floor in range(0, floors):\n\tlights = list(map(int, input().split()))\n\n\tfor l in range(0, len(lights), 2):\n\t\tif lights[l] == 1 or lights[l+1] == 1:\n\t\t\tflats_with_lights_on += 1\n\nprint(flats_with_lights_on)", "n, m = list(map(int, input().split()))\ntotal = 0\nfor row in range(n):\n floor = list(map(int, input().split()))\n for col in range(m):\n if floor[2 * col] == 1 or floor[2 * col + 1] == 1:\n total += 1\nprint(total)\n\n\n", "n, m = map(int, input().split())\n\nr = 0\nfor i in range(n):\n floor = list(map(int, input().split()))\n for j in range(m):\n if sum(floor[2*j:2*j+2]):\n r += 1\nprint(r)\n", "inp = input().split(' ')\r\nn = int(inp[0])\r\nm = int(inp[1])\r\ncount = 0\r\nfor floorNum in range(n):\r\n line = input().split(' ')\r\n for flat in range(0, m): \r\n if 1 == int(line[2 * flat]) or 1 == int(line[2 * flat + 1]):\r\n count += 1\r\nprint(count)", "n,m = list(map(int,input().split()))\r\n\r\ncount = 0\r\nb = []\r\nfor i in range(n):\r\n\tl = list(map(int,input().split()))\r\n\tb.append(len(l))\r\n\tfor i in range(len(l)):\r\n\t\tif i != len(l)-1 and l[i]==0 and l[i+1]==0 and (i+1)%2!=0:\r\n\t\t\tcount+=1\r\ns = sum(b)\r\nx = int(s/2)\r\nprint(x-count)", "n,m=map(int,input().split())\r\nlight=0\r\nfor i in range(n):\r\n list=[int(i) for i in input().split()]\r\n for j in range(0,2*m,2):\r\n if(list[j]==1 or list[j+1]==1):\r\n light+=1\r\nprint(light)", "n, m = map(int, input().split())\r\na = [list(map(int, input().split())) for _ in range(n)]\r\ns = 0\r\nfor i in range(n):\r\n for j in range(1, m + 1):\r\n if a[i][2 * j - 1] + a[i][2 * j - 2] > 0:\r\n s += 1\r\nprint(s)\r\n", "'''input\n1 3\n1 1 0 1 0 0\n'''\nn, m = map(int, input().split())\nt = 0\nfor _ in range(n):\n\ti = list(map(int, input().split()))\n\tfor x in range(m):\n\t\tif 1 in [i[2*x], i[2*x+1]]:\n\t\t\tt += 1\nprint(t)\t\t", "def sleep(n, m, ls):\r\n c = 0\r\n for i in range(n):\r\n j = 0\r\n while(j < (2 * m) - 1):\r\n if(ls[i][j] == 1 or ls[i][j + 1] == 1):\r\n c = c + 1\r\n j = j + 2\r\n return c \r\n \r\n\r\nn, m = input().split()\r\nn = int(n)\r\nm = int(m)\r\nls = [[int(j) for j in input().split()] for i in range(n)]\r\nprint(sleep(n, m, ls))", "n,m = map(int,input().split())\n\ntotal = 0\n\nfor i in range(n):\n arr = list(map(int,input().split()))\n j = 0\n while j < 2 * m:\n total += arr[j] or arr[j + 1]\n j += 2\n\nprint(total)\n", "n,m=map(int,input().split())\r\ncnt=0\r\nfor i in range(n):\r\n\ta=list(map(int,input().split()))\r\n\tfor i in range(0,2*m,2):\r\n\t\tif a[i]==1 or a[i+1]==1:\r\n\t\t\tcnt+=1\r\nprint(cnt)\r\n", "n,m=input().split()\r\nm=int(m)\r\nn=int(n)\r\nans=0\r\nfor i in range(n) :\r\n a=input().split()\r\n k=0\r\n for i in range(len(a)) :\r\n if k==0 :\r\n if a[i]=='1' :\r\n ok=1\r\n else :\r\n ok=0\r\n k=1\r\n else :\r\n if a[i]=='1' :\r\n ok=1\r\n k=0\r\n ans+=ok\r\n \r\nprint(ans)", "x = input()\r\nx = x.split()\r\nx = list(map(int, x))\r\ncounter = 0\r\n\r\nfor i in range(x[0]):\r\n z = input()\r\n z = z.split()\r\n z = list(map(int, z))\r\n for f in range(x[1]):\r\n notAsleep = False\r\n m = (f*2)\r\n if z[0 + m] == 1:\r\n notAsleep = True\r\n\r\n if z[1 + m] == 1:\r\n notAsleep = True\r\n\r\n if notAsleep:\r\n counter += 1\r\nprint(counter)", "n,m = map(int, input().split())\r\na=[]\r\nres = 0\r\nfor _ in range(n):\r\n temp = list(map(int, input().split()))\r\n a.append(temp)\r\nfor i in range(n):\r\n for j in range(0, 2*m, 2):\r\n if a[i][j] == 1 or a[i][j+1]==1:\r\n res+=1\r\nprint(res)\r\n", "n,m=map(int,input().split())\ncount=0\nfor i in range(n):\n g=list(map(int,input().split()))\n for j in range(m):\n if g[2*j]== 1 or g[2*j+1]==1:\n count+=1\nprint(count)", "n,m=list(map(int,input().split()))\r\nc=0\r\nfor i in range(n):\r\n p=list(map(int,input().split()))\r\n for i in range(0,len(p),2):\r\n if p[i]==1 or p[i+1]==1:\r\n c+=1\r\nprint(c)\r\n", "[n, m], c = list(map(int, input().split(\" \"))), 0\nfor i in range(n):\n a = list(map(int, input().split(\" \")))\n for j in range(m):\n c += (a[2*j] + a[2*j+1]) > 0\nprint(c)\n", "n, m = map(int, input().split())\r\nr = 0\r\nfor i in range(n):\r\n f = [int(k) for k in input().split()]\r\n for j in range(m):\r\n if 1 in f[j * 2: j * 2 + 2]:\r\n r += 1\r\nprint(r)", "n, m = map(int, input().split())\r\ncnt = 0\r\nfor i in range(n):\r\n *a, = map(int, input().split())\r\n for j in range(0, m * 2, 2):\r\n if a[j] == 1 or a[j + 1] == 1:\r\n cnt += 1\r\nprint(cnt)\r\n", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n x=[int(x) for x in input().split()]\r\n for i in range(0,m*2,2):\r\n if x[i]==1 or x[i+1]==1:\r\n c+=1\r\n\r\nprint(c)\r\n", "#595A in codeforces\r\nn,m = map(int,input().split())\r\nawake = 0\r\nfor _ in range(n):\r\n\twindows = list(map(int,input().split()))\r\n\tfor i in range(0,2*m,2):\r\n\t\twin = windows[i:i+2]\r\n\t\tif 1 in win:\r\n\t\t\tawake+=1\r\nprint(awake)", "n,m=[int(i) for i in input().split()]\r\ne=0\r\nfor i in range(n):\r\n a=[int(i) for i in input().split()]\r\n for j in range(0,len(a)-1,2):\r\n if(a[j]==1 or a[j+1]==1):\r\n e=e+1\r\nprint(e)", "n = input().split()\r\nans = 0\r\nfor i in range(int(n[0])):\r\n a = input().split()\r\n for j in range(2*int(n[1])):\r\n if a[j]=='1':\r\n ans+=1\r\n if j%2==0:\r\n a[j+1] ='0'\r\nprint(ans)", "n, m = map(int, input().split())\r\n\r\ncount = 0\r\n\r\nfor i in range(n):\r\n row = input().split()\r\n for j in range(0, len(row), 2):\r\n if row[j] == '1' or row[j+1] == '1':\r\n count += 1\r\n\r\nprint(count)\r\n", "n,m = map(int,input().split())\r\ncount = 0\r\nfor i in range(n):\r\n a = list(map(int,input().split()))\r\n for j in range(0,len(a),2):\r\n if a[j] == 1 or a [j+1] == 1:\r\n count += 1\r\nprint(count)", "n,m=map(int,input().split())\r\ncount=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n for j in range(0,int(2*m),2):\r\n if l[j]==1 or l[j+1]==1:\r\n count+=1\r\nprint(count)\r\n \r\n", "a,b=map(int,input().split());k=0\r\nfor case in ' '*a:c=input().replace(\" \",\"\");k=k+sum(1 for i in range(b) if c[2*i:2*i+2].count(\"1\")>0)\r\nprint(k)", "n, m = map(int, input().split())\r\nk = 0\r\nfor i in range(n):\r\n a = list(map(int, input().split()))\r\n for j in range(1, m * 2, 2):\r\n k += bool(a[j - 1] + a[j])\r\nprint(k)\r\n", "n,m=map(int, input().split())\r\ncount=0\r\nfor i in range(n):\r\n wind=input().split()\r\n for j in range(m):\r\n if '1' in wind[2*j:(2*j)+2]:\r\n count+=1\r\nprint(count) \r\n\r\n\r\n", "temp = [int(x) for x in input().split()]\r\nn = temp[0]\r\nm = temp[1]\r\nresult = 0\r\nfor i in range(n):\r\n a = [int(x) for x in input().split()]\r\n for j in range(m):\r\n if a[2*j-2] == 1 or a[2*j-1] == 1:\r\n result += 1\r\nprint(result)\r\n", "def main_function():\r\n n, m = [int(i) for i in input().split(\" \")]\r\n count = 0\r\n for i in range(n):\r\n f = [int(i) for i in input().split(\" \")]\r\n already_list_on = False\r\n for j in range(len(f)):\r\n if not j % 2 and f[j] == 1:\r\n count += 1\r\n already_list_on = True\r\n elif j % 2 and f[j] == 1 and not already_list_on:\r\n count += 1\r\n already_list_on = False\r\n elif j % 2:\r\n already_list_on = False\r\n\r\n return count\r\n\r\n\r\nprint(main_function())", "n, m = [int(x) for x in input().split()]\r\nwindows = 2 * m\r\nres = 0\r\nfor i in range(n):\r\n w = 0\r\n floor = [int(x) for x in input().split()]\r\n while w < windows:\r\n if floor[w] == 1 or floor[w + 1] == 1:\r\n res += 1\r\n w += 2\r\nprint(res)\r\n", "#!/usr/bin/env python3\n\nif __name__ == '__main__':\n n, m = map(int, input().split())\n\n t = 0\n for _ in range(n):\n floor = list(map(int, input().split()))\n for i in range(m):\n if floor[2*i] == 1 or floor[2*i+1] == 1:\n t += 1\n print(t)\n\n", "n,m=map(int,input().split());k=0\r\nfor i in ' '*n:a=list(map(int,input().split()));k+=sum([a[i]|a[i+1] for i in range(0,len(a),2)])\r\nprint(k)\r\n", "n, m = map(int, input().split())\r\nres = 0\r\nfor _ in range(n):\r\n data = list(map(int, input().split()))\r\n for i in range(0, len(data), 2):\r\n if data[i] or data[i + 1]:\r\n res += 1\r\n\r\nprint(res)\r\n", "n, m = map(int, input().split())\r\nans = 0\r\nbase = []\r\nfor t in range(n):\r\n arr = list(map(int,input().split()))\r\n base.append(arr)\r\nfor i in range(len(base)):\r\n e = 0\r\n r = 2\r\n while r <= len(base[i]):\r\n flat = base[i][e:r]\r\n if flat[0] == 1 or flat[1] == 1:\r\n ans += 1\r\n r += 2\r\n e += 2\r\nprint(ans)", "x = input()\r\nx = x.split(\" \")\r\nfloors = []\r\ncount = 0\r\n\r\nfor y in range(int(x[0])):\r\n temp = input()\r\n temp = temp.split(\" \")\r\n floors.append(temp)\r\n\r\nfor g in range(int(x[0])):\r\n\r\n for u in range(int(int(x[1]))):\r\n\r\n if (int(floors[g][u*2]) == 1 or int(floors[g][u*2+1]) == 1):\r\n\r\n count += 1\r\nprint(count)\r\n ", "# -*- coding: utf-8 -*-\r\nst = list(input().split(\" \"))\r\nn = int(st[0])\r\nm = int(st[1])\r\nst0 = []\r\nfor i in range(n):\r\n st1 = list(input().split(\" \"))\r\n st0 += st1\r\nk = 0\r\ninc = 0\r\nwhile(k < m*n):\r\n if (int(st0[2*k]) + int(st0[2*k+1])) > 0:\r\n inc = inc +1\r\n k = k +1\r\nprint(inc)\r\n", "n, m = input().split()\r\nn, m = int(n), int(m)\r\n\r\ncount = 0\r\n\r\nfor i in range(n):\r\n f = [int(x) for x in input().split()]\r\n for j in range(0, m*2, 2):\r\n if f[j] == 1 or f[j+1] == 1:\r\n count+=1\r\n\r\nprint(count)", "import sys\r\nn,m=map(int,input().split())\r\n\r\ne=0\r\nfor _ in range(n):\r\n r=0\r\n l=list(map(int,input().split()))\r\n for i in range(0,2*m,2):\r\n if(l[i]==0 and l[i+1]==0):\r\n r+=1\r\n e+=(m-r)\r\nprint(e)\r\n \r\n\r\n\r\n \r\n", "n, m = map(int, input().split())\r\nans = 0\r\nfor i in range(n):\r\n a = list(map(int, input().split()))\r\n for j in range(m):\r\n ans += max(a[2 * j], a[2 * j+1])\r\nprint(ans)", "bild=list(map(int,input().split()))\r\na=0\r\nl=[]\r\nk=[]\r\nfor i in range(bild[0]):\r\n\tl.append(input().split()) \r\nfor i in range(len(l)):\r\n\tk+=l[i]\r\nfor j in range(len(k)):\r\n\tif(j%2==0):\r\n\t\tif(k[j]=='1'):\r\n\t\t\ta+=1\r\n\t\telif(k[j+1]=='1'):\r\n\t\t\ta+=1\r\nprint(a)", "'''\nAuthor : knight_byte\nFile : A_Vitaly_and_Night.py\nCreated on : 2021-04-18 12:44:00\n'''\n\n\ndef main():\n n, m = map(int, input().split())\n x = \"\".join([\"\".join(input().split()) for _ in range(n)])\n li = 0\n f = len(x)//(n*m)\n for i in range(0, len(x), f):\n # print(i)\n if \"1\" in x[i:i+f]:\n li += 1\n print(li)\n\n\nif __name__ == '__main__':\n main()\n", "n,m = (int(i) for i in input().split()) \nrooms = [[] for i in range(n)]\nfor i in range(n):\n rooms[i] = [int(j) for j in input().split()]\n\ncount = 0\nfor i in range(n):\n for j in range(0,2*m,2):\n if rooms[i][j] == 1 or rooms[i][j+1] == 1:\n count += 1\n\nprint(count)\n \n \n", "n,m=map(int,input().split())\r\nc=n*m\r\nfor _ in range(n):\r\n a=list(map(int,input().split()))\r\n for i in range(0,2*m,2):\r\n if a[i]==0 and a[i+1]==0:\r\n c-=1\r\n\r\nprint(c)\r\n\r\n\r\n", "n, m = (int(i) for i in input().split())\nres = 0\nfor _ in range(n):\n floor = [int(i) for i in input().split()]\n flats = [floor[2 * i : 2 * i + 2] for i in range(m)]\n res += sum(1 for f, s in flats if f + s > 0)\nprint(res)\n", "n, m = map(int, input().split())\r\n\r\ncount = 0\r\n\r\nfor _ in range(n):\r\n A = list(map(int, input().split()))\r\n for i in range(0, len(A), 2):\r\n if A[i] or A[i+1]:\r\n count += 1\r\n\r\nprint(count)\r\n", "__author__ = 'cmashinho'\n\nn, m = map(int, input().split())\nans = 0\n\nfor _ in range(n):\n l = list(map(int, input().split()))\n for i in range(1, len(l), 2):\n if l[i] == 1 or l[i - 1] == 1:\n ans += 1\n\nprint(ans)", "n,m=map(int,input().split())\r\n\r\nbl=[]\r\nfor i in range(n):\r\n tmp=[int(i) for i in input().split()]\r\n bl.append(tmp)\r\nwin=0\r\n \r\nfor i in range(n):\r\n for j in range(2*m-1):\r\n if j%2==0:\r\n if bl[i][j] ==1 or bl[i][j+1] ==1:\r\n win+=1\r\n\r\n \r\nprint(win) \r\n \r\n ", "n,m = map(int,input().split())\r\nli = []\r\nc = 0\r\nfor i in range(n):\r\n li+=map(int,input().split())\r\nfor j in range(0,2*m*n,2):\r\n if max(li[j],li[j+1])==1:\r\n c+=1\r\nprint(c)", "n,m = [int(x) for x in input().split()]\r\nalpha=0\r\nalpha1=0\r\nfor _ in range(n):\r\n x = [int(x) for x in input().split()]\r\n for i in range(0,len(x),2):\r\n if x[i]==x[i+1]==0:\r\n alpha+=0\r\n else:\r\n alpha1+=1\r\nprint(alpha+alpha1)", "n, m = map(int, input().split())\r\ncnt = 0\r\nfor i in range(n):\r\n a = list(map(int, input().split()))\r\n for j in range(0, 2*m, 2):\r\n if a[j] or a[j + 1]:\r\n cnt += 1\r\nprint(cnt)", "n, m = map(int, input().split())\r\n\r\nmatrix = [[] for i in range(n)]\r\nfor i in range(n):\r\n matrix[i] = list(map(int, input().split()))\r\n \r\nres = 0\r\nfor i in range(n):\r\n for j in range(0,m):\r\n if matrix[i][2 * j] == 1 or matrix[i][2 * j + 1] == 1:\r\n #print(matrix[i][2 * j], matrix[i][2 * j - 1])\r\n res += 1\r\nprint(res)", "\r\nn , m = map(int , input().split())\r\ncnt = 0\r\nfor i in range(n):\r\n x = [int(x) for x in input().split()]\r\n for j in range(0 , len(x) - 1 , 2):\r\n if x[j] + x[j + 1] > 0:\r\n cnt += 1\r\nprint(cnt)", "inp = [int(x) for x in input().split(\" \")]\r\nlights = []\r\nnot_sleeping = 0\r\n\r\nfor floor in range(inp[0]):\r\n lights.append([int(x) for x in input().split(\" \")])\r\n \r\n\r\nfor floor in range(inp[0]):\r\n for j in range(0, (2*inp[1])-1, 2):\r\n if (lights[floor][j] + lights[floor][j+1])/2 > 0:\r\n not_sleeping += 1\r\n\r\nprint(not_sleeping)\r\n", "# import os\r\n\r\nn,m = map(int,input().split())\r\n\r\nr = 0\r\n\r\nfor _ in range(n):\r\n a = list(map(int,input().split()))\r\n for i in range(0,len(a)-1, 2):\r\n if a[i] == 1 or a[i+1] == 1:\r\n r += 1\r\nprint(r)\r\n", "n,m =[int(i) for i in input().split()]\r\ncnt=0\r\nfor _ in range(n):\r\n windows=[int(i) for i in input().split()]\r\n i=0\r\n while i<2*m:\r\n if (windows[i] | windows[i + 1]) == 1:\r\n cnt+=1\r\n i=i+2\r\nprint(cnt)\r\n", "n,m=map(int,input().split())\r\ncount=0\r\n\r\nwhile(n):\r\n a=list(map(int,input().split()))\r\n i=0\r\n while(i<2*m):\r\n if(a[i]==1 or a[i+1]==1):\r\n count+=1\r\n i+=2\r\n \r\n n-=1\r\nprint(count)", "n, m = [int(i) for i in input().split()]\r\ncount = 0\r\nfor _ in range(n):\r\n t = input().split()\r\n for i in range(m):\r\n if '1' == t[2*i] or '1' == t[2*i + 1]:\r\n count += 1\r\nprint(count)", "n,m=map(int,input().split(\" \"))\r\ny=0\r\nfor i in range(n):\r\n\tl=list(map(int,input().split(\" \")))\r\n\tfor j in range(m):\r\n\t\tx=l[(j*2):(j*2)+2]\r\n\t\tif 1 in x:\r\n\t\t\ty+=1\r\nprint(y)", "floar,flat=[int(x) for x in input().split()]\r\nc=0\r\nfor i in range(floar):\r\n flats = [int(x) for x in input().split()]\r\n j=0\r\n while j < flat*2-1:\r\n if(flats[j]==1 or flats[j+1]==1):\r\n c+=1\r\n j+=2\r\nprint(c)", "# import sys\r\n# n = int(input())\r\n# s = input().strip()\r\n# a = [int(tmp) for tmp in input().split()]\r\n# for i in range(n):\r\nn, m = [int(tmp) for tmp in input().split()]\r\nans = 0\r\nfor i in range(n):\r\n lvl = [int(tmp) for tmp in input().split()]\r\n for j in range(m):\r\n if lvl[2 * j] == 1 or lvl[2 * j + 1] == 1:\r\n ans += 1\r\nprint(ans)", "n,m=map(int,input().split())\r\ncnt=0 \r\nfor i in range(n):\r\n l=[int(i) for i in input().split()]\r\n for j in range(0,2*m,2):\r\n if l[j]==1 or l[j+1]==1:\r\n cnt+=1 \r\nprint(cnt)", "a,b=map(int,input().split())\nc= 0\nfor i in range(a):\n d=input().split()\n for j in range(0,2*b,2):\n if d[j]=='1' or d[j+1]=='1':\n c+=1\nprint(c)\n \t\t\t \t \t \t \t\t \t \t\t\t", "n,m = map(int,input().split())\nL = [list(map(int, input().split())) for _ in range(n)]\nr = 0\nfor k in range(n):\n for i in range(m):\n if L[k][2*i+1] or L[k][2*i]:\n r+=1\nprint(r)\n\n", "a,b=map(int,input().split())\r\nl=[]\r\nfor i in range(a):\r\n\tli=list(map(int,input().split()))\r\n\tl.append(li)\r\ncount=0\r\nfor j in range(0,2*b,2):\r\n\tfor k in l:\r\n\t\tif 1 in k[j:j+2]:\r\n\t\t\tcount+=1\r\n\t\telse:\r\n\t\t\tcontinue\r\nprint(count)", "__author__ = 'suvasish'\r\n\r\nlights= []\r\nn, m = input().split(' ')\r\ncount = 0\r\nfor t in range(0, int(n)):\r\n lights = list(map(int, input().split(' ')))\r\n i = 0\r\n while i < len(lights):\r\n if lights[i] or lights[i+1] == 1:\r\n count += 1\r\n i += 2\r\nprint(count)", "n, m = map(int, input().split())\ncount = 0\n\nfor i in range(n):\n s = list(map(int, input().split()))\n for j in range(0, len(s), 2):\n if s[j] == 1 or s[j+1] == 1:\n count += 1\nprint(count)\n", "def solve(windows):\r\n c = 0\r\n for row in windows:\r\n for i in range(0, len(row), 2):\r\n if row[i] == 1 or row[i+1] == 1:\r\n c += 1\r\n return c\r\n\r\ndef main():\r\n windows = list()\r\n n, m = list(map(int, input().split()))\r\n for _ in range(n):\r\n windows.append(list(map(int, input().split())))\r\n print(solve(windows))\r\n\r\nif __name__ == '__main__':\r\n main()", "import math\r\n\r\nn, m =input().split()\r\nans = 0\r\nn = int(n)\r\nm = int(m)\r\n\r\nfor i in range(n):\r\n a = input().split()\r\n for j in range(m):\r\n if int(a[2*j]) == 1 or int(a[2*j+1]) == 1:\r\n ans += 1\r\nprint(ans)\r\n", "n, m = list(map(int, input().split()))\r\nc=0\r\nfor _ in range(n):\r\n a = list(map(int, input().split()))\r\n for i in range(0,2*m,2):\r\n if a[i]==1 or a[i+1]==1:\r\n c +=1\r\n\r\n\r\nprint(c)\r\n \r\n", "n,m = map(int,input().split())\r\naps = 0\r\nfor i in range(n):\r\n a = input().split()\r\n for i in range(m*2):\r\n if a[i]=='1':\r\n if i%2==0:\r\n if a[i+1]=='0':\r\n aps+=1\r\n else:aps+=1\r\n \r\n\r\n\r\n\r\nprint(aps)", "#Vitaly and night\r\nn,m = map(int,input().split())\r\nc = 0\r\nfor i in range(n):\r\n li = list(map(int,input().split()))\r\n for i in range(0,len(li),2):\r\n if li[i]==1 or li[i+1]==1:\r\n c+=1\r\nprint(c)", "x,y = map(int,input().split())\r\nz = []\r\nk = 0\r\nfor i in range(x):\r\n\ta = list(map(int,input().split()))\r\n\tz.append(a)\r\nfor i in range(x):\r\n\tfor j in range(0,2*y,2):\r\n\t\tif z[i][j] == 1 or z[i][j+1] == 1 :\r\n\t\t\tk = k + 1\r\nprint(k)", "n,m = map(int,input().split())\r\ncount =0 \r\nfor i in range(n):\r\n\tl = list(map(int,input().split()))\r\n\tfor j in range(1,len(l),2):\r\n\t\tif(l[j]==1 or l[j-1]==1):\r\n\t\t\tcount+=1\r\nprint(count)", "n=[int(i) for i in input().split()]\r\nn1=n[0]\r\nn2=n[1]\r\nj=0\r\nx=list()\r\ncount=0\r\nfor i in range(n1):\r\n x=[int(i) for i in input().split()]\r\n while(j<(2*n2)-1):\r\n if(x[j]==1 or x[j+1]==1):\r\n count=count+1\r\n j=j+2\r\n else:\r\n j=j+2\r\n j=0\r\nprint(count)\r\n", "n,m=map(int,input().split())\r\ncount=0\r\nfor j in range (n):\r\n l1=list(map(int,input().split()))\r\n for i in range (m):\r\n w1=l1[2*i+1]\r\n w2=l1[2*i]\r\n if(w1==0 and w2==0):\r\n continue\r\n else:\r\n count+=1\r\nprint(count)", "n, m = list(map(int, input().split()))\nf = []\nfor _ in range(n):\n f.append(list(map(int, input().split())))\nf = list(reversed(f))\nres = 0\nfor i in range(n):\n for j in range(0,2*m,2):\n if sum(f[i][j:j+2]):\n res += 1\nprint(res)\n\n", "(n, m) = map(int, input().split())\r\na = [list(map(int, input().split())) for i in range(n)]\r\n#print(a)\r\nans = 0\r\nfor i in a:\r\n #print(100)\r\n for j in range(0, len(i), 2):\r\n ans += i[j] | i[j + 1]\r\n #print(i[j], i[j + 1])\r\nprint(ans)\r\n", "# -*- coding: utf-8 -*-\n\nn, m = [int(x) for x in input().split()]\n# print(n, m)\n\nnum = 0\nflats = []\n\ni = 1\nwhile i <= n:\n for step, x in enumerate([int(x) for x in input().split()]):\n flats.append(x)\n if step % 2 is 1 and flats[step] + flats[step - 1] is not 0:\n num += 1\n\n flats = []\n i += 1\n\nprint(num)\n\t\t \t\t \t\t\t\t\t \t\t \t\t\t \t\t \t\t \t\t", "if __name__ == '__main__':\r\n n,m = map(int, input().split())\r\n co = 0\r\n for _ in range(n):\r\n a = list(map(str, input().split()))\r\n a = ''.join(a)\r\n for i in range(0,len(a)-1,2):\r\n if a[i] == \"1\" or a[i+1] == \"1\":\r\n co += 1\r\n print(co)\r\n'''\r\nb = list(input().split())\r\n b = ''.join(b)\r\n if \"01\" in b:\r\n co += b.count(\"01\")\r\n b = b.replace(\"01\",\"\")\r\n if \"10\" in b:\r\n co += b.count(\"10\")\r\n b = b.replace(\"10\",\"\")\r\n if \"11\" in b:\r\n co += b.count(\"11\")\r\n b = b.replace(\"11\",\"\")\r\n'''\r\n", "n, m = input().split()\r\nn, m = int(n), int(m)\r\nmain = []\r\nresult = 0\r\nfor i in range(n):\r\n l = list(map(int, input().split()))\r\n #print(l)\r\n for j in range(0, 2*m - 1, 2):\r\n #print(l[j], l[j + 1])\r\n if (l[j] == 1 or l[j + 1] == 1):\r\n result += 1\r\nprint(result)", "# https://codeforces.com/problemset/problem/595/A\r\n\r\nn, m = map(int, input().split())\r\nans = 0\r\nfor i in range(n):\r\n floor = tuple(input().split())\r\n for k in range(0, 2 * m, 2):\r\n if floor[k] == '1' or floor[k + 1] == '1':\r\n ans += 1\r\n\r\nprint(ans)", "n , m = map(int , input().split())\r\nl = [] \r\nk = 0\r\nfor i in range(n):\r\n l.append(list(map(int , input().split())))\r\nfor i in range(n):\r\n for j in range(0 , 2*m-1 , 2):\r\n if l[i][j] ==1 or l[i][j+1] ==1 :\r\n k+=1\r\nprint(k)", "n,m = [int(i) for i in input().split()]\r\ns= 0\r\nwhile n > 0:\r\n array = [int(i) for i in input().split()]\r\n i = 0\r\n while i < 2*m:\r\n temp = array[i:i+2:]\r\n if 1 in temp:\r\n s += 1\r\n i += 2\r\n n -= 1\r\n\r\nprint(s)", "n, m = map(int, input().split())\r\ncount = 0\r\nfor _ in range(n):\r\n windows = list(map(int, input().split()))\r\n for i in range(m):\r\n if windows[i*2] == 1 or windows[i*2+1] == 1:\r\n count += 1\r\nprint(count)", "a,b=map(int,input().split())\r\nn = []\r\nfor i in range(a):\r\n row = list(input().split())\r\n for i in range(len(row)):\r\n row[i] = str(row[i])\r\n n.append(row)\r\nr=0\r\nfor i in range(a):\r\n for j in range(0,b*2-1,2):\r\n if n[i][j]=='1' or n[i][j+1]=='1':\r\n r+=1\r\nprint(r)\r\n", "c = 0\r\nfor i in range(int(input().split()[0])):\r\n\ta = input().split()\r\n\twhile len(a):\r\n\t\tif '1' in [a.pop(), a.pop()]:\r\n\t\t\tc+=1\r\nprint(c)", "n, m = map(int, input().split())\n\ncount = 0\n\nfor i in range(n):\n tmp = list(map(int, input().split()))\n for i in range(2 * m - 1):\n if i % 2 != 0:\n continue\n if tmp[i] == 1 or tmp[i + 1] == 1:\n count += 1\n\nprint(count)\n", "a = [int(i) for i in input().split(\" \")]\n\nn, m = a[0], a[1]\n\ncount = 0\nfor x in range(n):\n a = [int(i) for i in input().split(\" \")]\n for i in range(m):\n count += (a[i*2] or a[i*2+1])\n\nprint(count)\n\t\t\t \t\t \t\t \t \t \t \t \t \t", "a=list(map(int,input().split()))\r\nb=[]\r\nresult=0\r\nfor x in range(a[0]):\r\n\tb.append(list(map(int,input().split())))\r\nfor j in range(a[0]):\r\n\tfor i in range(0,2*a[1],2):\r\n\t\tif b[j][i] or b[j][i+1]==1:\r\n\t\t\tresult=result+1\r\n\t\telif b[j][i] or b[j][i+1]==0:\r\n\t\t\tresult=result+0\r\nprint(result)\r\n\r\n", "x, y = [int(i) for i in input().split()]\r\nz = x*y\r\na = []\r\nfor i in range(x):\r\n b = [int(k) for k in input().split()]\r\n a.append(b)\r\nfor i in range(x):\r\n for j in range(0, y*2, 2):\r\n if a[i][j] == a[i][j+1] == 0:\r\n z -= 1\r\nprint(z)\r\n", "import sys\r\n\r\nn, m = map(int, sys.stdin.readline().split(' '))\r\na = [-1] * (n * m * 2)\r\nc = 0\r\n\r\n\r\nfor i in range(n):\r\n\to = list(map(int, (sys.stdin.readline().split(' '))))\r\n\r\n\tfor e in o:\r\n\t\ta[c] = e\r\n\t\tc += 1\r\n\r\nj = 0\r\np = 0\r\nal = len(a)\r\n\r\n# [0, 0, 0, 1, 1, 0, 1, 1]\r\n\r\nwhile p < (len(a) - 1):\r\n\tif a[p] == 1:\r\n\t\tj += 1\r\n\t\tp += 2\r\n\r\n\telif a[p + 1] == 1:\r\n\t\tj += 1\r\n\t\tp += 2\r\n\r\n\telse:\r\n\t\tp += 2\r\n\r\nprint(j)", "import sys\r\nimport math\r\ninput = sys.stdin.readline\r\n\r\ndef inp():\r\n return int(input())\r\n\r\ndef insr():\r\n s = input()\r\n return list(s[:len(s) - 1])\r\n\r\ndef invr():\r\n return map(int, input().split())\r\n\r\nif __name__ == '__main__':\r\n n, m = invr()\r\n num_awake = 0\r\n for i in range(n):\r\n row = list(invr())\r\n for j in range(m):\r\n if row[2*j] or row[2*j+1]:\r\n num_awake += 1\r\n\r\n print(num_awake) ", "n, m = map(int,input().split())\r\nk = 0\r\nfor i in range(n):\r\n a = list(map(int,input().split()))\r\n for i in range(1,2*m,2):\r\n if a[i] == 1 or a[i-1]==1:\r\n k += 1\r\nprint(k)", "floor, flat = map(int, input().split())\nresult = 0\nfor m in range(floor):\n data = list(map(int, input().split()))\n c = 0\n for n in range(flat):\n if data[c] == 1 or data[c + 1] == 1:\n result += 1\n c += 2\nprint(result)\n", "n, m = map(int, input().split())\r\nans = 0\r\nfor i in range(n):\r\n w = map(int, input().split())\r\n l = list(w) \r\n for j in range(m):\r\n if l[2*j] == 1 or l[2*j+1] == 1:\r\n ans += 1\r\nprint(ans)\r\n \r\n", "n,m = map(int,input().split())\r\nans = 0\r\nfor _ in range(n):\r\n a = list(map(int,input().split()))\r\n for i in range(0,len(a),2):\r\n if a[i] ==1 or a[i+1] == 1:\r\n ans+=1\r\nprint(ans)", "import sys\nn, m = map(int, sys.stdin.readline().split())\nans = 0\nfor _ in range(n):\n a = list(map(int, sys.stdin.readline().split()))\n for i in range(m):\n a1 = a[2*i]\n a2 = a[2*i+1]\n if a1 == 1 or a2 == 1:\n ans += 1\nprint(ans)\n", "n, m = map(int, input().split())\r\nanswer = 0\r\nfloors = []\r\nfor i in range(n):\r\n floor = list(map(int, input().split()))\r\n floors.append(floor)\r\nfor i in range(n):\r\n for j in range(0, 2 * m, 2):\r\n answer += (1 if floors[i][j] == 1 or floors[i][j + 1] == 1 else 0)\r\nprint(answer)\r\n", "n, m = map(int, input().split())\r\nans = 0\r\nfor i in range(n):\r\n row = list(map(int, input().split()))\r\n for j in range(0, 2 * m, 2):\r\n if row[j] + row[j + 1] > 0:\r\n ans += 1\r\n\r\nprint(ans)", "x,y=list(map(int,input().split()))\r\nllist=[]\r\nfor i in range(x):\r\n list1=list(map(int,input().split()))\r\n for i in list1:\r\n llist.append(i)\r\ncount=0\r\nfor i in range(0,len(llist)-1,2):\r\n if(llist[i]==1 or llist[i+1]==1):\r\n count+=1\r\nprint(count)\r\n \r\n ", "a , b = map(int,input().split())\r\nc =0\r\nfor i in range(a):\r\n\tz = list(map(int,input().split()))\r\n\tv = []\r\n\tfor q in range(0,len(z),2):\r\n\t\tv.append([z[q] ,z[q+1]])\r\n\tfor w in v:\r\n\t\tif 1 in w:\r\n\t\t\tc+=1\r\nprint(c)", "if __name__ == '__main__':\n n, m = map(int, input().split())\n\n total = 0\n for x in range(n):\n data = list(map(int, input().split()))\n total += sum(map(lambda x: min(1, x[0] + x[1]), zip(data[0::2], data[1::2])))\n\n print(total)", "n, m = [int(c) for c in input().split()]\r\nres = 0\r\nfor i in range(n):\r\n windows = [c for c in input().split()]\r\n for j in range(0, len(windows) - 1, 2):\r\n if windows[j] == '1' or windows[j+1] == '1':\r\n res += 1\r\n\r\nprint(res)\r\n", "a,b =map(int,input().split())\r\ncnt = 0\r\nl= []\r\n\r\nfor i in range(a):\r\n lst = list(map(int,input().split()))\r\n \r\n for j in range(0,len(lst)+1//2,2):\r\n\r\n if lst[j] == 0 and lst[j+1]==0:\r\n pass\r\n else:\r\n cnt +=1 \r\nprint(cnt) \r\n", "\ninp = list(map(int, input().split()))\n\nn = inp[0]\nm = inp[1]\nans = 0\n\nfor i in range(n):\n a = list(map(int, input().split()))\n for j in range(m):\n if a[j * 2] == 1 or a[j * 2 + 1] == 1:\n ans += 1\nprint(ans)\n\nimport time, sys\nsys.stderr.write('{0:.3f} ms\\n'.format(time.clock() * 1000));\n", "n,m = input().split(\" \")\r\nm = int(m)\r\nn = int(n)\r\ns = 0\r\nfor i in range(n):\r\n b = [int(l) for l in input().split(\" \")]\r\n for k in range(0,len(b),2):\r\n if b[k]+b[k+1]>0:\r\n s += 1\r\nprint(s)\r\n \r\n", "f=lambda:map(int,input().split())\r\nn,m=f()\r\nflt=0\r\nwhile n:\r\n fl=list(f())\r\n flt+=sum(fl[i-1]+fl[i]>0 for i in range(1,m*2,2))\r\n n-=1\r\nprint(flt)", "n, m = [int(x) for x in input().split()]\n\ncounter = 0\nfor i in range(n):\n a = [int(x) for x in input().split()]\n for i in range(0, 2*m, 2):\n if a[i]+a[i+1] > 0:\n counter += 1;\n\nprint(counter)\n", "listm=list(map(int,input().split()))\r\nn,m=(listm[0],listm[1])\r\ncount=0\r\nfor i in range(n):\r\n\tl=list(map(int,input().split()))\r\n\tfor i in range(0,2*m,2):\r\n\t\tif i%2==0:\r\n\t\t\tk=l[i:i+2]\r\n\t\t\tif 1 in k:\r\n\t\t\t\tcount+=1\r\nprint(count)", "n, m = map(int, input().split())\r\nr = 0\r\nfor i in range(n):\r\n s = input().split()\r\n for j in range(m):\r\n if s[2*j] == '1' or s[2*j+1] == '1':\r\n r += 1\r\nprint(r)", "n = [int(x) for x in input().split()]\r\nhasil = 0\r\n\r\nfor i in range(n[0]):\r\n total = 0\r\n flat = [int(x) for x in input().split()]\r\n for j in range(len(flat)):\r\n if flat[j] == 1 and j < 2 and total != 1:\r\n total += 1\r\n hasil += total\r\n elif j >= 2:\r\n if j % 2 == 0:\r\n total = 0\r\n if flat[j] == 1 and total != 1:\r\n total += 1\r\n hasil += total\r\n\r\nprint(hasil)", "n, m = map(int, input().split())\n\nfloors = []\n\nfor i in range(n): \n floors.append(list(map(int, input().split())))\n\ncount = 0\nfor i in range(n):\n for j in range(0, m*2, +2): \n if floors[i][j] == 1 or floors[i][j+1] == 1: \n count += 1\nprint(count)\n", "n = [int(x) for x in input().split()]\ncount = 0\nqueue = []\nfor i in range(0, n[0]):\n s = [int(x) for x in input().split()]\n for j in range(0, n[1] * 2 - 1, 2):\n or1 = s[j] == 1\n or2 = s[j + 1] == 1\n if or1 or or2:\n count += 1\nprint(count)", "x, y = map(int, input().split())\r\ncnt = 0\r\nfor i in range(x):\r\n arr = [*map(int, input().split())]\r\n for j in range(0, 2*y, 2):\r\n cnt += arr[j] == 1 or arr[j+1] == 1\r\nprint(cnt)", "n,m = map(int,input().split())\r\ncount,count1,count2 = 0,0,0\r\nfor i in range(n):\r\n\tk = list(map(int,input().split()))\r\n\tfor j in range(m):\r\n\t\tif k[2*j + 1] == 1 and k[2*j]==1:\r\n\t\t\tcount2+=1\r\n\t\tif k[2*j+1] == 1 :\r\n\t\t\tcount1+=1\r\n\t\tif k[2*j] == 1:\r\n\t\t\tcount+=1\t\t\t\r\nprint(count+count1-count2)\r\n", "# import sys\r\n# sys.stdin=open(\"input.in\",\"r\")\r\n# sys.stdout=open(\"output.out\",\"w\")\r\na,n=map(int,input().split())\r\ncount=0\r\nfor i in range(a):\r\n\tL=list(map(int,input().split()))\r\n\tfor i in range(2*n):\r\n\t\tif L[i]==1:\r\n\t\t\tcount+=1\r\n\t\t\tif i%2==0:\r\n\t\t\t\tL[i+1]=0\r\nprint(count)", "n, m = map(int, input().split())\r\nq = 0\r\nfor i in range(0, n):\r\n mas = list(map(int, input().split()))\r\n i = 0\r\n while i < m * 2:\r\n if mas[i] == 1:\r\n q += 1\r\n if mas[i] == 1 and (i + 1) % 2 == 1:\r\n i += 2\r\n else:\r\n i += 1\r\nprint(q)", "n, m = map(int, input().split(\" \"))\r\ncount = 0\r\nwhile n >0:\r\n ls = list(map(int, input().split(\" \")))\r\n for i in range(0, 2*m, 2):\r\n if ls[i]==1 or ls[i+1]==1:\r\n count += 1\r\n n -= 1\r\nprint(count)", "n,m = map(int,input().split())\r\ns = 0\r\nfor _ in range(n):\r\n a = input().split()\r\n for i in range(0,2*m,2):\r\n if \"1\" in a[i:i+2]:s+=1\r\nprint(s)", "n,m = map(int,input().split(' '))\r\ncount = 0\r\nfor i in range(n):\r\n l = list(map(int,input().split(' ')))\r\n for i in range(0,2*m,2):\r\n if l[i] or l[i+1]:\r\n count += 1\r\n \r\nprint(count)", "n,m=map(int,input().split())\r\nb=[]\r\nfor i in range(n):\r\n a= list(map(int, input().split()))\r\n b.append(a)\r\nans=0\r\nfor i in range(n):\r\n for j in range(0,2*m,2):\r\n if b[i][j]+b[i][j+1]>=1:ans+=1\r\nprint(ans)\r\n", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(0,n):\r\n \r\n a=list(map(int,input().split()))\r\n for j in range(0,len(a),2):\r\n if a[j]==1 or a[j+1]==1:\r\n c=c+1\r\nprint(c)", "n, m = list(map(int, input().split(' ')))\r\nc = 0\r\nfor _ in range(n):\r\n f = list(map(int, input().split(' ')))\r\n for i in range(m):\r\n if f[2 * i + 1] or f[2 * i]:\r\n c += 1\r\nprint(c)", "n,m=[int(i) for i in input().split()]\ns=0\nl=[]\nfor i in range(n):\n a=input().split()\n l.append(a)\nfor j in range(n):\n \n for i in range(0,2*m-1,2):\n if l[j][i]=='0' and l[j][i+1]=='0':\n s+=1\n \n\nprint(n*m-s)\n \n", "a,b=map(int,input().split())\r\nt=0\r\nfor i in range(a):\r\n z=input().split()\r\n for j in range(0,len(z),2):\r\n if z[j]=='1' or z[j+1]=='1':\r\n t+=1\r\nprint(t)\r\n", "n,m = list(map(int,input().split(' ')))\r\nc=0\r\nfor i in range(n):\r\n l = list(map(int,input().split(' ')))\r\n for k in range(0,len(l),2):\r\n if l[k] == 1 or l[k+1] == 1:\r\n c=c+1\r\nprint(c)", "n, m = [int(x) for x in input().split()]\r\nx = 0\r\nfor _ in range(n):\r\n l = [int(x) for x in input().split()]\r\n for i in range(m):\r\n if l[2 * i + 1] == 1 or l[2 * i] == 1:\r\n x += 1\r\nprint(x)", "from collections import deque\r\n\r\ndef solve(lst):\r\n d = deque(lst)\r\n r = 0\r\n while len(d) > 0:\r\n a, b = d.popleft(), d.popleft()\r\n r += max(a, b)\r\n return r\r\n\r\nn, m = map(int, input().split())\r\nres = 0\r\nfor _ in range(n):\r\n lst = list(map(int, input().split()))\r\n res += solve(lst)\r\nprint(res)", "n, m = [int(s) for s in input().split(' ')]\r\ncnt = 0\r\nfor i in range(n):\r\n x = [int(s) for s in input().split(' ')]\r\n x = [max(x[2 * i], x[2 * i + 1]) for i in range(m)]\r\n cnt += sum(x)\r\nprint(cnt)", "n,m = input().split()\nn,m = map(int,[n,m])\nA = []\nfor i in range(0,n):\n s = input()\n B = []\n for j in s.split():\n B.append(int(j))\n A.append(B)\ncount = 0\nfor k in range(0,n):\n for l in range(0,2*m,2):\n if A[k][l] or A[k][l+1] == 1:\n count = count + 1\nprint(count)\n ", "import sys\r\ndata = sys.stdin.readline()\r\nnm = data.split(\" \")\r\nn = nm[0]\r\nm = nm[1]\r\n\r\nhouse = []\r\nfor line in sys.stdin:\r\n line = line.replace(\"\\n\",\"\").split(\" \")\r\n house.append(line)\r\n\r\nroomNumbers = 0\r\nindex = 0\r\nfirstRoom = 0\r\nfor floor in house: \r\n for apartment in floor:\r\n if index > 1:\r\n index = 0\r\n firstRoom = 0\r\n if apartment == '1' and index == 0:\r\n firstRoom = 1\r\n roomNumbers += 1\r\n if firstRoom == 0 and apartment == '1' and index == 1:\r\n roomNumbers += 1\r\n index += 1\r\n \r\nprint(roomNumbers)", "n, m = [int(i) for i in input().split()]\r\na = [[int(j) for j in input().split()] for i in range(n)]\r\nsum = 0\r\nfor i in a:\r\n for j in range(m):\r\n if (i[2 * j] or i[2 *j + 1]):\r\n sum += 1\r\nprint(sum)\r\n", "n, m = map(int, input().split())\nans = 0\nfor i in range(n):\n l = input().split()\n for j in range(m):\n if l[2*j] == '1' or l[2*j+1] == '1':\n ans+=1\nprint(ans)\n", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport time\n\n# = input()\n# = int(input())\n\n#() = (i for i in input().split())\n# = [i for i in input().split()]\n\n(n, m) = (int(i) for i in input().split())\napp = []\nfor i in range(n):\n\n app.append([ 0 for j in range(m) ])\n a = [int(j) for j in input().split()]\n\n for j in range(len(a)):\n app[i][divmod(j, 2)[0]] += a[j]\n\nstart = time.time()\n\n#print(app)\ns = 0\nfor i in range(n):\n s += sum([1 for j in app[i] if j>0])\n\nprint(s)\nfinish = time.time()\n#print(finish - start)\n", "a=lambda:map(int,input().split())\r\nn,m=a()\r\ns=0\r\nfor __ in range(n):\r\n l=list(a())\r\n s+=sum([l[i*2]+l[i*2+1]>0 for i in range(m)])\r\n #s+=1\r\nprint(s)", "n,m=map(int, input().split())\r\nx=0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for j in range(m):\r\n if a[2*j]|a[2*j+1]==1:\r\n x+=1\r\nprint(x)\r\n", "tmp = input().split()\r\nn = int(tmp[0])\r\nm = int(tmp[1])\r\ncount = 0\r\nfor i in range(n):\r\n status = [int(k) for k in input().split()]\r\n while len(status):\r\n if status.pop() + status.pop() > 0:\r\n count += 1\r\n\r\nprint(count)\r\n", "string = input()\r\nnumbers = string.split(\" \")\r\na = int(numbers[0])\r\nb = int(numbers[1])\r\nflats = 0\r\nfor x in range(a):\r\n string = input()\r\n numbers = string.split(\" \")\r\n for y in range(b * 2):\r\n numbers[y] = int(numbers[y])\r\n for y in range(b):\r\n p = numbers[y * 2]\r\n q = numbers[y * 2 + 1]\r\n windows = [p, q]\r\n if windows.count(1) >= 1:\r\n flats += 1\r\nprint(flats)", "n,m=input().split()\r\nn=int(n)\r\nm=int(m)\r\nc=0\r\nfor z in range(n):\r\n w=list(map(int, input().split()))\r\n for i in range(0,2*m,2):\r\n if w[i]==1 or w[i+1]==1:\r\n c+=1\r\nprint(c)", "'''\nn, m = map(int, input().split())\nprint(n + m)\n'''\n'''\nn = int(input())\nif n == 0:\n print(0)\nelse:\n a, b = 0, 1\n for i in range(2, n + 1):\n a, b = b, a + b\n print(b)\n'''\n'''\nn, m = map(int, input().split())\nprint((n ** m) - (m ** n))\n'''\n'''\nn = int(input())\nprint(n * 2 + 1)\n'''\n'''\na=int(input())\nfor i in range(1,a+1):\n if i%2!=0 and a>i:\n print('I hate that',end=' ')\n elif i%2==0 and a>i:\n print('I love that',end=' ')\n elif i%2!=0:\n print('I hate it',end=' ')\n else:\n print('I love it',end=' ')\n'''\n'''\na = int(input())\nl = [[0] * a for i in range(a)]\na1 = []\nfor i in range(a):\n for j in range(a):\n if i == 0 :\n l[i][j] = 1\n else:\n l[i][j] =l[i - 1][j] + l[i][j -1]\nfor i in l:\n a1.append(max(i))\nprint(max(a1))\n'''\n'''\nn = int(input())\ncnt = 0\na = []\nwhile n != 0:\n\tif n % 2 == 1:\n\t\tcnt += 1\n\t\ta.append(3)\n\t\tn -= 3\n\telse:\n\t\tcnt += 1\n\t\ta.append(2)\n\t\tn -= 2\nprint(cnt)\nfor i in a:\n\tprint(i, end = \" \")\nprint()\n'''\n'''\nn = int(input())\nt = False\nkkk = []\nfor i in range(0,n):\n p = input().split('|')\n if t == False:\n for j in range(0,2):\n if p[j] == 'OO':\n p[j] = '++'\n t = True\n break\n kkk.append(p[0])\n kkk.append(p[1])\nif t == False:\n print('NO')\nelse:\n print('YES')\n for i in range(0,n):\n print('|'.join(kkk[2*i:2*i+2]))\n'''\n'''\na=input()\nb=list(map(int,input().split()))\nc=0\nfor i in b:\n if b.count(i)>c:\n c=b.count(i)\nprint(c)\n'''\n'''\nn = int(input())\nfor i in range(n):\n a, b, k = map(int,input().split())\n zero1 = k // 2\n if k % 2 == 0:\n zero2 = k // 2\n else:\n zero2 = (k // 2) + 1\n b *= zero1\n a *= zero2\n print(a - b)\n'''\n'''\nn, m = map(int, input().split())\na = set(range(1, m + 1))\nb = set()\nfor i in range(n):\n\tx, y = map(int, input().split())\n\tfor i in range(x, y + 1):\n\t\tb.add(i)\nfor i in b:\n\ta.discard(i)\nprint(len(a))\nfor i in a:\n\tprint(i, end = \" \")\nprint()\n'''\n'''\nn = int(input())\nm = list(map(int,input().split()))\nprint(m.count(1))\nfor i in range(n - 1):\n\tif m[i + 1] == 1:\n\t\tprint(m[i], end = ' ')\nprint(m[-1])\n'''\n'''\na = int(input())\nl = list(map(int,input().split()))\nk = 1\nfor i in range(a - 1):\n l2 = list(map(int,input().split()))\n if sum(l2) > sum(l):\n k += 1\nprint(k)\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'''\nn = input()\ns = ''\nfor i in range(len(n)):\n\tif n[i] == '0':\n\t\ts += '1'\n\telse:\n\t\ts += '0'\nprint(s)\n'''\n'''\na = int(input())\nm = input()\nk = 0\ni = - 1\nwhile k != a:\n\ti += 1\n\tprint(m[k] , end = \"\") \n\tk += i + 1\n'''\n'''\nn = int(input())\nlisofs = []\nrocks = ['Power', 'Time', 'Space', 'Soul', 'Reality', 'Mind']\nfor i in range(n):\n\ts = input()\n\tlisofs.append(s)\n\tif s == 'purple':\n\t\trocks.remove('Power')\n\telif s == 'green':\n\t\trocks.remove('Time')\n\telif s == 'blue':\n\t\trocks.remove('Space')\n\telif s == 'orange':\n\t\trocks.remove('Soul')\n\telif s == 'red':\n\t\trocks.remove('Reality')\n\telse:\n\t\trocks.remove('Mind')\nprint(6 - len(lisofs))\nfor j in range(len(rocks)):\n\tprint(rocks[j])\n'''\n'''\nn = int(input())\na = [\"Power\", \"Time\", \"Space\", \"Soul\", \"Reality\", \"Mind\"]\nfor i in range(n):\n\ts = input()\n\tif s == \"purple\":\n\t\ta.remove(\"Power\")\n\telif s == 'green':\n\t\ta.remove(\"Time\")\n\telif s == 'blue':\n\t\ta.remove(\"Space\")\n\telif s == 'orange':\n\t\ta.remove('Soul')\n\telif s == 'red':\n\t\ta.remove(\"Reality\")\n\telse:\n\t\ta.remove(\"Mind\")\nprint(len(a))\nfor i in a:\n\tprint(i)\n'''\nn, m = map(int,input().split())\nzero = 0\nfor i in range(n):\n lisofls = input().split()\n for j in range(0, (2 * m) - 1, 2):\n if lisofls[j] == '1' or lisofls[j + 1] == '1':\n zero += 1\nprint(zero)\n", "s=input()\r\ns=s.split()\r\nn=int(s[0])\r\nm=int(s[1])\r\np=[]\r\n\r\nfor i in range (n):\r\n t=input()\r\n t=t.split()\r\n t=[int(j) for j in t]\r\n p.append(t)\r\n \r\nct=0\r\n\r\nfor i in range (n):\r\n for j in range(m):\r\n if (p[i][2*j] == 1 or p[i][2*j+1] == 1):\r\n ct+=1\r\n\r\nprint(ct)", "# cf 595 A 700\nn, m = map(int, input().split())\nc = 0\nfor _ in range(n):\n row = list(map(int, input().split()))\n for j in range(0, len(row), 2):\n if row[j] or row[j + 1]:\n c += 1\nprint(c)\n\n", "n,m=map(int,input().split())\r\ncount=0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for i in range(0,m):\r\n if a[i*2]+a[2*i+1]>=1:\r\n count+=1\r\n\r\nprint(count)\r\n", "def main():\n (n, m) = map(int, input().split(' '))\n ans = 0\n for i in range(n):\n line = list(map(int, input().split(' ')))\n for j in range(0, 2 * m, 2):\n if line[j] == 1 or line[j + 1] == 1:\n ans += 1\n return ans\nprint(main())\n", "n,m = map(int,input().split())\r\na = []\r\nk = 0\r\nfor i in range(n):\r\n b = list(map(int,input().split()))\r\n for j in range(len(b)):\r\n a.append(b[j])\r\nfor i in range(0,len(a)-1,2):\r\n if a[i] == 1 or a[i+1] == 1:\r\n k += 1\r\nprint(k)", "n,m=map(int,input().split())\r\ns=0\r\nfor x in range(n):\r\n a=list(map(int,input().split()))\r\n for y in range(0,2*m,2):s=s+min(1,a[y]+a[y+1])\r\nprint(s)", "n, m = list(map(int, input().split()))\r\nf = [list(map(int, input().split())) for p in range(n)]\r\ns = 0\r\nfor p in range(n):\r\n for q in range(m*2):\r\n if q%2 == 0:\r\n if f[p][q] == 1 or f[p][q+1] == 1:\r\n s += 1\r\nprint(s)", "#in the name of god\r\n#Mr_Rubick\r\nn,m=map(int,input().split())\r\ncnt=0\r\nfor i in range(n):\r\n\ta=list(map(int,input().split()))\r\n\tfor j in range(m):\r\n\t\tif a[j*2] or a[j*2+1]: cnt+=1\r\nprint(cnt)", "n, m = [int(x) for x in input().split()]\r\nma = [[int(x) for x in input().split()]for q in range(n)]\r\nkv=0\r\nfor i in range(n):\r\n for j in range(0,m*2,2):\r\n if ma[i][j] + ma[i][j+1] >=1:\r\n kv+=1\r\nprint(kv)", "g = list(map(int, input().split()))\r\nk = 2\r\nresult = []\r\nb = 0\r\nl = 0\r\nk = 2\r\nfor i in range(g[0]):\r\n h = [int(t) for t in input().split()]\r\n for j in range(g[1]):\r\n for t in range(l, k):\r\n b += h[t]\r\n \r\n if b >= 1:\r\n result.append(True)\r\n b = 0\r\n (l, k) = (k, k + 2)\r\n (l, k) = (0, 2)\r\n \r\n \r\n\r\n \r\nprint(result.count(True))\r\n", "n , m = map(int , input().split()) \r\ncounter = 0\r\nfor i in range(n) :\r\n row = list(map(int , input().split()))\r\n for j in range(0 , 2*m , 2) : \r\n if row[j : j + 2].count(1) >=1 : \r\n counter += 1\r\nprint(counter)", "n,m=map(int,input().split())\r\nl=0\r\nfor i in range(n):\r\n arr=list(map(int,input().split()))\r\n j=1\r\n while j<len(arr):\r\n if arr[j-1]==1 or arr[j]==1:\r\n l+=1\r\n j+=2\r\nprint(l)", "x=[int(x) for x in input().split()]\r\ns,b=0,0\r\nwhile s<x[0]:\r\n a=[int(a) for a in input().split()]\r\n r=0\r\n while r<len(a):\r\n if a[r]==1:\r\n b=b+1\r\n if r%2==0:\r\n r=r+2\r\n else:\r\n r=r+1\r\n else:\r\n r=r+1\r\n s=s+1\r\nprint(b)\r\n", "s=input()\r\na=s.split(' ')\r\nn,m=int(a[0]),int(a[1])\r\nk=0\r\nwhile n>0:\r\n n-=1\r\n s=input()\r\n a=s.split(' ')\r\n for j in range(1,m+1):\r\n if (a[2*j-2]=='1') or (a[2*j-1]=='1'):\r\n k+=1\r\nprint(k)\r\n", "n,m=map(int,input().split())\r\nr=0\r\nfor i in range(n):\r\n x=list(map(int,input().split()))\r\n for j in range(0,2*m,2):\r\n if(x[j]==1 or x[j+1]==1):\r\n r=r+1\r\nprint(r) \r\n \r\n", "n, m = map(int, input().split())\r\nkol = 0\r\nfor i in range(n):\r\n a = list(input().split())\r\n for j in range(0, len(a), 2):\r\n if a[j] == '1' or a[j + 1] == '1':\r\n kol += 1\r\nprint(kol)\r\n", "n, m = map(int, input().split(' '))\nlitFlats = 0\nfor floor in range(n):\n windows = list(map(int, input().split(' ')))\n for flat in range(m):\n if windows[flat*2] + windows[flat*2+1] > 0:\n litFlats += 1\n\nprint(litFlats)", "n, m = [int(_) for _ in input().split()]\ncount = 0\nfor i in range(n):\n\tline = input().split()\n\tfor j in range(0, 2*m, 2):\n\t\tif(line[j] == '1' or line[j+1] == '1'):\n\t\t\tcount += 1\nprint(count)\n\n", "def main():\n n, m = map(int, input().split())\n m *= n\n for _ in range(n):\n s = input()[::2]\n m -= sum(a == '0' == b for a, b in zip(s[::2], s[1::2]))\n print(m)\n\n\nif __name__ == '__main__':\n main()\n", "n,m = map(int, input().split())\r\ncount = 0\r\nfor _ in range(n):\r\n a = list(map(int, input().split()))\r\n for i in range(0, 2*m, 2):\r\n if a[i] == 1 or a[i+1] == 1:\r\n count +=1\r\nprint(count)\r\n ", "n,m = map(int,input().split())\n\ncount = 0\n\nfor _ in range(n):\n x = iter(input().split())\n count += sum(map(lambda x:(x.count('1')+1)//2,map(' '.join,zip(x,x))))\n\nprint(count)\n", "n, m = map(int, input().split())\r\ncount = 0\r\nwhile n:\r\n n-=1\r\n l = list(map(int, input().split()))\r\n for i in range(0,2*m,2):\r\n if (l[i]==1) or (l[i+1]==1):\r\n count+=1\r\n \r\nprint(count)", "n,m=[int(x) for x in input().split()]\r\nc=0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for j in range(0,m*2,2):\r\n if(a[j]==1 or a[j+1]==1):\r\n c+=1\r\nprint(c)\r\n", "n, m = map(int, input().split())\r\nc = 0\r\nfor i in range(n):\r\n floor = list(map(int, input().split()))\r\n for j in range(0, len(floor), 2):\r\n if floor[j] == 1 or floor[j + 1] == 1:\r\n c += 1\r\nprint(c)\r\n", "n, m = [int(i) for i in input().split()]\r\nans = 0\r\nfor i in range(n):\r\n floor = input().split()\r\n for j in range(0, 2 * m, 2):\r\n ans += int(floor[j] == \"1\" or floor[j + 1] == \"1\")\r\nprint(ans)", "m,n = map(int,input().split())\nnumbers = []\nfor _ in range(m):\n a = list(map(int,input().split()))\n for x in a:\n numbers+=[x]\ncount = 0\nfor i in range(len(numbers)):\n if numbers == []:\n break\n if numbers[0] | numbers[1]:\n count+=1\n numbers.pop(0)\n numbers.pop(0)\n else:\n numbers.pop(0)\n numbers.pop(0)\nprint(count)", "n,m = map(int,input().split())\r\ns = 0\r\nfor _ in range(n):\r\n lights = list(map(int, input().split()))\r\n \r\n s += sum(any(lights[x*2: (x+1)*2]) for x in range(m))\r\nprint (s)", "n, m = [int(i) for i in input().split(' ')] # обход списка по пробелу с превращнием в число и записью назад в список\r\ns = 0\r\nfor i in range(0, n):\r\n k = [int(i) for i in input().split(' ')]\r\n for i in range(0, 2*m, 2):\r\n if k[i] > 0 or k[i+1] > 0:\r\n s += 1\r\n\r\nprint(s)", "n, m = map(int, input().split())\r\narr = [list(map(int, input().split())) for i in range(n)]\r\nans = 0\r\nfor i in arr:\r\n for k in range (m):\r\n if (i[2 * k + 1] == 1 or i[2 * k] == 1):\r\n ans += 1\r\nprint(ans)", "n, m = map(int, input().split())\r\nans = 0\r\n\r\nfor i in range(n):\r\n l = list(map(int, input().split()))\r\n for j in range(0,m*2,2):\r\n if l[j] == 1 or l[j+1] == 1:\r\n ans += 1\r\n\r\nprint(ans)", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n for j in range(0,2*m,2):\r\n if l[j] or l[j+1]:\r\n c+=1\r\nprint(c)", "n,m=map(int,input().split())\r\ncnt=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n for j in range(0,len(l),2):\r\n if(l[j]==1 or l[j+1]==1):\r\n cnt+=1\r\nprint(cnt)\r\n\r\n", "n, m = map(int, input().split())\r\nres = 0\r\nfor _ in range(n):\r\n lst = [*map(int, input().split())]\r\n for i in range(1, m + 1):\r\n if lst[(2 * i - 1) - 1] == 1 or lst[(2 * i) - 1] == 1:\r\n res += 1\r\nprint(res)\r\n", "from sys import stdin\r\nlive = True\r\nif not live: stdin = open('data.in', 'r')\r\n\r\nn, m = list(map(int, stdin.readline().strip().split()))\r\nans = 0\r\n\r\nfor floors in range(n):\r\n\tfloor = list(map(int, stdin.readline().strip().split()))\r\n\tfor flat in range(m):\r\n\t\tans += (floor[2 * flat] | floor[2 * flat + 1])\r\n\t\t\r\nprint(ans)\r\n\r\nif not live: stdin.close()", "n, m = map(int, input().split())\r\ncount = 0\r\nfor i in range(n):\r\n lights = list(map(int, input().split()))\r\n tmp = 0\r\n for j, L in enumerate(lights):\r\n if L == 1:\r\n tmp = 1\r\n if j%2 == 1:\r\n count += tmp\r\n tmp = 0\r\nprint(count)", "n,m=map(int,input().split());a,s=[],0\r\nfor i in range(n):\r\n b=list(map(int,input().split()))\r\n for j in range(m*2):a.append(b[j])\r\nfor i in range(0,len(a)-1,2):\r\n if a[i+1]==1 or a[i]==1:s+=1\r\nprint(s)", "q=lambda:map(int,input().split())\r\nqi=lambda:int(input())\r\nqs=lambda:input().split()\r\nx,y=q()\r\na=[]\r\nfor _ in range(x):a.extend(list(q()))\r\nprint(sum([1 for i in zip(a[::2],a[1::2]) if 1 in i]))", "n, m = map(int, input().split())\nresult = 0\nfor r in range(n):\n\twindows = list(map(int, input().split()))\n\tfor i in range(m):\n\t\tif windows[2 * i] + windows[2 * i + 1] != 0:\n\t\t\tresult += 1\nprint(result)\n", "n, m = map(int, input().split())\r\nanswer = 0\r\nfor i in range(n):\r\n s = list(input().split())\r\n b = []\r\n for y in range(0, m * 2, 2):\r\n if str(s[y] + s[y + 1]) == \"11\" or str(s[y] + s[y + 1]) == \"10\" or str(s[y] + s[y + 1]) == \"01\":\r\n answer += 1\r\nprint(answer)\r\n", "a, b = map(int, input().split())\r\nans = 0\r\nfor i in range(a):\r\n s = [int(x) for x in input().split()]\r\n for i in range(0, b * 2, 2):\r\n if s[i] or s[i + 1]:\r\n ans += 1\r\nprint(ans)", "#595A\r\n[n,m] = list(map(int,input().split()))\r\nf = 0\r\nfor i in range(n):\r\n a = list(map(int,input().split()))\r\n for j in range(m):\r\n if a[2*j] + a[2*j+1] > 0:\r\n f += 1\r\nprint(f)", "n, m = [int(s) for s in input().split()]\r\nsum = 0\r\nfor i in range(n):\r\n a = [int(s) for s in input().split()]\r\n for i in range(0,2*m,2):\r\n if (a[i] != 0) or (a[i+1] != 0):\r\n sum += 1\r\nprint(sum)", "n, m = map(int, input().split())\r\nv = 0\r\nfor i in range(n):\r\n f = input().split()\r\n v += sum(f[2 * j] == '1' or f[2 * j + 1] == '1' for j in range(m))\r\nprint(v)", "n, m = map(int, input().split(' '))\ncnt = 0\nfor _ in range(n):\n a = list(map(int, input().split(' ')))\n for i in range(0, 2 * m, 2):\n if a[i] == 1 or a[i + 1] == 1:\n cnt += 1\nprint(cnt)", "def ll():\r\n return list(map(int,input().split()))\r\nn = ll()\r\nx = 0\r\nl = []\r\nx = []\r\ny = []\r\nz=0\r\nfor i in range(n[0]):\r\n s = ll()\r\n l = l+s\r\n\r\nx = x+ l[1::2]\r\ny = y+l[::2]\r\nfor j in range(len(l)//2):\r\n if x[j]!=y[j]:\r\n z+=1\r\n else:\r\n if x[j] == 1 or y[j]==1:\r\n z+=1\r\n\r\nprint(z)", "n, m = map(int, input().split())\r\n\r\nans = 0\r\nfor i in range(n):\r\n s = list(map(int, input().split()))\r\n \r\n ans += sum(map(lambda i: s[2 * i] or s[2 * i + 1], range(m)))\r\n\r\nprint(ans)\r\n", "def input_matr(n: int, m: int) -> [[]]:\r\n matr = [list(map(int, input().split())) for i in range(n)]\r\n return matr\r\n\r\n\r\nn, m = map(int,input().split())\r\nmatr = input_matr(n,2 * m)\r\nflats = 0\r\n\r\ni = 0\r\nwhile(i < n):\r\n j = 0\r\n while(j < m*2):\r\n if j % 2 == 0 and matr[i][j] == 1:\r\n flats += 1\r\n j += 1\r\n elif j % 2 != 0 and matr[i][j] == 1:\r\n flats += 1\r\n j += 1\r\n i += 1\r\n\r\nprint(flats)", "q, w = map(int, input().split())\nS = 0\nfor i in range(q):\n e = list(map(int, input().split()))\n for j in range(0, len(e), 2):\n if e[j] == 1 or e[j + 1] == 1:\n S += 1\nprint(S)\n", "n, m = map(int, input().split())\r\nd = 0\r\nfor i in range(n):\r\n c = list(map(int, input().split()))\r\n for i in range(1, len(c), 2):\r\n if c[i] == 1 or c[i - 1] == 1:\r\n d += 1\r\nprint(d)", "a,b=map(int,input().split())\r\nc = 0\r\nd=[]\r\nfor i in range(a):\r\n\ts = [int(i) for i in input().split()]\r\n\td.append(s)\r\n\r\nfor i in d:\r\n\tfor j in range(0,len(i)-1,2):\r\n\t\tif i[j] or i[j+1] == 1:\r\n\t\t\tc+=1\r\n\t\telse:\r\n\t\t\tpass\r\n\r\nprint(c)\r\n", "x, y = map(int, input().split())\r\nawake = 0\r\ny *= 2\r\nfor i in range(x):\r\n userList = list(map(int, input().split()))\r\n\r\n for j in range(0, y, 2):\r\n\r\n if (userList[j] == 1) or (userList[j+1] == 1):\r\n awake += 1\r\n\r\nprint(awake)", "n,m = map(int,input().split())\r\nt = 0\r\nfor i in range (n):\r\n a = list(map(int,input().split()))\r\n for x in range (0,m*2,2):\r\n if a[x] == 1 or a[x+1] == 1:\r\n t += 1\r\nprint (t)", "n = list(map(int, input().split()))\r\ncounter = 0\r\nfor i in range(n[0]):\r\n a = list(map(int, input().split()))\r\n for i in range(0, 2*n[1], 2):\r\n if a[i] == 1 or a[i+1] == 1:\r\n counter += 1\r\n \r\n \r\nprint(counter)\r\n", "import sys\r\nInput=sys.stdin.readline\r\nsum=0\r\nx,y=list(map(int,input().split()))\r\nfor i in range(x):\r\n m=list(map(int,input().split()))\r\n for j in range(0,2*y,2):\r\n if m[j] or m[j + 1]:sum+=1\r\nprint(sum)\r\n#gharantine:/", "n,m=map(int,input().split())\r\nf=0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for i in range(m):\r\n if 1 in a[2*i:2*i+2]:\r\n f+=1\r\nprint(f)\r\n", "#https://codeforces.com/problemset/problem/595/A\r\ninp = input()\r\ninp = inp.split(\" \")\r\n\r\nnum_floors = int(inp[0])\r\nnum_appartments = int(inp[1])\r\n\r\npeople_awake = 0\r\n\r\nfor current_floor in range(num_floors):\r\n current_level = input()\r\n current_level = current_level.split()\r\n for index in range(0,len(current_level),2):\r\n if current_level[index] == \"1\" or current_level[index + 1] == \"1\":\r\n people_awake += 1\r\n\r\nprint (people_awake)\r\n", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for i in range(m):\r\n if a[i*2] or a[i*2+1]: c+=1\r\n\r\nprint(c)", "# # RED CODER # #\r\nn, m = map(int, input().split())\r\ncount = 0\r\nfor i in range(n):\r\n x = list(map(int, input().split()))[:2*m]\r\n for j in range(0, 2*m-1, 2):\r\n if x[j] == 1 or x[j+1] == 1:\r\n count += 1\r\nprint(count)", "[n, m] = list(map(int, input().split(\" \")))\r\nc = 0\r\nfor i in range(n):\r\n s = input().split(\" \")\r\n for j in range(m):\r\n if(s[2*j] == '1' or s[2*j+1] == '1'):\r\n c += 1\r\nprint(c)\r\n\r\n \r\n \r\n\r\n\r\n \r\n", "n, m = map(int, input().split())\r\nk = 0\r\nfor i in range(n):\r\n floor = list(map(int, input().split()))\r\n for j in range(m):\r\n if floor[2*j]+floor[2*j+1] > 0:\r\n k += 1\r\nprint(k)\r\n", "n, m = map(int, input().split())\r\nres = 0\r\nfor _ in range(n):\r\n s = input().split()\r\n res += sum(map(lambda x, y: int(x) or int(y), s[::2], s[1::2]))\r\nprint(res)", "\r\nn,m=map(int, input().split())\r\nco=0\r\nFlag=False\r\nfor floor in range(n):\r\n win=list(map(int, input().split()))\r\n #print(win)\r\n for t in range(2*m):\r\n if (win.pop()==1):\r\n Flag=True\r\n #print('yes')\r\n if t%2==1:\r\n if Flag==True:\r\n co+=1\r\n #print('yay')\r\n Flag=False\r\n \r\nprint(co)\r\n ", "r, c = map(int, input().split())\r\n\r\nt = 0\r\n\r\nfor _ in range(r):\r\n l_w = list(map(int, input().split()))\r\n \r\n for i in range(len(l_w) // 2):\r\n if l_w[i * 2] == 1 or l_w[i * 2 + 1] == 1:\r\n t += 1\r\n\r\nprint(t)", "# import sys\r\n# sys.stdout = open('DSA/Stacks/output.txt', 'w')\r\n# sys.stdin = open('DSA/Stacks/input.txt', 'r')\r\n\r\nn, m = map(int, input().split())\r\ncc=0\r\nfor _ in range(n):\r\n ll = list(map(int, input().split()))\r\n i=1\r\n while i<(2*m):\r\n if ll[i]==1 or ll[i-1]==1:\r\n cc+=1\r\n i+=2\r\nprint(cc)", "# The place between your comfort zone and your dream is where life takes place. Helen Keller\r\n# by : Blue Edge - Create some chaos\r\n\r\nn,m=map(int,input().split())\r\nsum=0\r\nwhile n:\r\n n-=1\r\n a=list(map(int,input().split()))\r\n for i in range(0,2*m-1,2):\r\n sum+= (a[i] or a[i+1])\r\n\r\nprint(sum)\r\n", "n, m = map(int,input().split())\r\notvet = 0\r\nfor i in range(n):\r\n l = input().split()\r\n for j in range(0, 2 * m - 1, 2):\r\n if l[j] == '1' or l[j+1] == '1':\r\n otvet += 1\r\nprint(otvet)", "n,m = map(int,input().split())\r\ncount=0\r\nfor _ in range(n):\r\n li=list(map(int,input().split()))\r\n for i,j in zip(li[::2],li[1::2]):\r\n count+= i|j\r\nprint(count)", "n,m = map(int,input().split())\r\nmat=[]\r\nfor _ in range(n):\r\n l = list(map(int,input().split()))\r\n mat.append(l)\r\nc=0\r\nfor i in range(len(mat)):\r\n for j in range(0,2*m,2):\r\n if(mat[i][j]==1 or mat[i][j+1]==1):\r\n c+=1\r\nprint(c)\r\n ", "n, m = map(int, input().split())\r\nc = 0\r\nfor i in range(n):\r\n s = list(map(int, input().split()))\r\n for j in range(0, 2*m, 2):\r\n if s[j] == 1 or s[j+1] == 1:\r\n c += 1\r\nprint(c)", "n,m = map(int, input().split())\r\nc = 0\r\nfor i in range(n):\r\n s = [x for x in input().split()]\r\n for i in range(0, 2*m, 2):\r\n if s[i] == \"1\" or s[i+1] == \"1\":\r\n c += 1\r\nprint(c)\r\n", "m,n=input().split()\r\nm=int(m)\r\nn=int(n)\r\nc=0\r\nfor i in range(m):\r\n j=0\r\n x = list(map(int, input().split()))\r\n while j<len(x):\r\n if x[j]==1:\r\n c=c+1\r\n elif x[j+1]==1:\r\n c=c+1\r\n j=j+2\r\nprint(c)", "#from sys import stdin,stdout\nimport sys\ndef main():\n\tn,m=map(int,input().split())\n\tcnt=0\n\tfor i in range(n):\n\t\ta=list(map(int,input().split()))\n\t\tfor j in range(0,len(a)-1,2):\n\t\t\tcnt+=a[j]|a[j+1]\n\tprint(cnt)\nif __name__==\"__main__\":\n\tmain()", "n, m = map(int, input().split())\r\nsum = 0\r\nfor k in range(n):\r\n tmp = list(map(int, input().split()))\r\n i = 0\r\n for j in range(m):\r\n if tmp[i] or tmp[i + 1]:\r\n sum += 1\r\n i += 2\r\nprint(sum)\r\n", "def main():\r\n [n, m] = [int(x) for x in input().split()]\r\n counts = 0\r\n\r\n for _ in range(n):\r\n windows = input().split()\r\n counts += sum(1 for i in range(m) if windows[2 * i] == '1' or windows[2 * i + 1] == '1')\r\n\r\n print(counts)\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "\r\nimport sys\r\ndef get_single_int ():\r\n return int (sys.stdin.readline ().strip ())\r\ndef get_string ():\r\n return sys.stdin.readline ().strip ()\r\ndef get_ints ():\r\n return map (int, sys.stdin.readline ().strip ().split ())\r\ndef get_list ():\r\n return list (map (int, sys.stdin.readline ().strip ().split ()))\r\n\r\n#code starts here\r\nn, m = get_ints ()\r\ncount = 0\r\nfor i in range (n):\r\n ar = get_list ()\r\n for j in range (1, m + 1):\r\n if (ar [(2 * j) - 2] == 1) or (ar [2*j - 1] == 1):\r\n count += 1\r\nprint (count)\r\n\r\n\r\n\r\n\r\n", "n,m = list(map(int,input().split()))\r\n\r\nans = 0\r\nfor _ in range(n):\r\n\tarr = list(map(int,input().split()))\r\n\r\n\tfor i in range(m):\r\n\t\tans+= arr[2*i] | arr[2*i+1]\r\nprint(ans)", "n,m=map(int,input().split())\r\nv=[x for i in range(n) for x in map(int,input().split())]\r\nprint(sum([1 for i in range(0,len(v),2) if sum(v[i:i+2])>0]))", "n , m = map(int,input().split())\r\nl = []\r\ncount = 0\r\nfor i in range(n):\r\n l.append(list(map(int,input().split())))\r\n\r\nfor i in range(0,n):\r\n for j in range(1,m+1):\r\n if l[i][(((2*j)-1))-1] != 0 or l[i][(2*j)-1] != 0 :\r\n count += 1\r\n\r\nprint(count)", "def main():\r\n n,m = [int(v) for v in input().split()]\r\n c = 0\r\n for i in range(n):\r\n vals = [int(v) for v in input().split()]\r\n for j in range(0, 2*m, 2):\r\n if any([v==1 for v in vals[j:j+2]]):\r\n c+=1\r\n print(c)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n, m = map(int, input().split())\r\nans = 0\r\n\r\nfor _ in range(n):\r\n floor = [int(x) for x in input().split()]\r\n\r\n for i in range(m):\r\n for j in range(2):\r\n if floor[2 * i + j] == 1:\r\n ans += 1\r\n break\r\n\r\nprint(ans)", "n,m = map(int, input().split())\r\na = [input().split() for i in range(n)]\r\np = 0\r\nfor j in range(n):\r\n for k in range(1,2*m,2):\r\n if a[j][k-1] == '1' or a[j][k] == '1':\r\n p += 1\r\n\r\n\r\nprint(p)", "\r\n\"\"\"\r\ndef three_numbers():\r\n numbers = list(map(int, input().split(sep=' ')))\r\n m = max(numbers)\r\n for i in numbers:\r\n if i != m:\r\n print(m - i, end=' ')\r\n\r\n\r\ndef gen_and_card_game():\r\n card = input()\r\n my_cards = list(input().split(sep=' '))\r\n for i in my_cards:\r\n if i[0] == card[0] or i[1] == card[1]:\r\n print('YES')\r\n break\r\n else:\r\n print('NO')\r\n\r\n\r\ndef kazak_vus_and_contest():\r\n a, b, c = map(int, input().split(sep=' '))\r\n if a - b <= 0 and a - c <= 0:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\n\r\ndef like_A():\r\n st = input()\r\n count_a = 0\r\n for i in st:\r\n if i == 'a':\r\n count_a += 1\r\n if count_a > len(st) - count_a:\r\n print(len(st))\r\n else:\r\n print(count_a + count_a - 1)\r\n\r\n\r\ndef three_piece_candies():\r\n n = int(input())\r\n for i in range(n):\r\n a, b, c = map(int, input().split(sep=' '))\r\n print((a + b + c) // 2)\r\n\r\n\r\ndef re_encryption():\r\n n = int(input())\r\n encryption = input()\r\n decipherment = ''\r\n k = 0\r\n while 0 != n:\r\n k += 1\r\n n -= k\r\n for i in range(1, k + 1):\r\n decipherment += encryption[0]\r\n encryption = encryption[i:]\r\n print(decipherment)\r\n\r\n\r\ndef two_type_burgers():\r\n n = int(input())\r\n for i in range(n):\r\n a, b, c = map(int, input().split(sep=' '))\r\n p_b, p_c = map(int, input().split(sep=' '))\r\n sum = 0\r\n if p_b > p_c:\r\n if a - b * 2 >= 0:\r\n a = a - b * 2\r\n sum += b * p_b\r\n if a - c * 2 >= 0:\r\n sum += c * p_c\r\n else:\r\n sum += a // 2 * p_c\r\n else:\r\n sum += a // 2 * p_b\r\n else:\r\n if a - c * 2 >= 0:\r\n a = a - c * 2\r\n sum += c * p_c\r\n if a - b * 2 >= 0:\r\n sum += b * p_b\r\n else:\r\n sum += a // 2 * p_b\r\n else:\r\n sum += a // 2 * p_c\r\n print(sum)\r\n\r\n\r\ndef throw_cub():\r\n n = int(input())\r\n for i in range(n):\r\n k = int(input())\r\n if k % 7 == 1:\r\n count = k // 7 + 1\r\n else:\r\n count = k // 7 + (k % 7 > 0)\r\n print(count)\r\n\r\n\r\ndef nasty_read_book():\r\n n = int(input())\r\n pages = list()\r\n for i in range(n):\r\n a, b = map(int, input().split(sep=' '))\r\n pages.append(a)\r\n current_page = int(input())\r\n for i in range(n - 1):\r\n if pages[i] <= current_page < pages[i + 1]:\r\n print(len(pages) - i)\r\n break\r\n else:\r\n print(1)\r\n\r\n\r\ndef Tokitsukaze_and_upgrade():\r\n n = int(input())\r\n residue = n % 4\r\n if residue == 0:\r\n print('1 A')\r\n elif residue == 1:\r\n print('0 A')\r\n elif residue == 2:\r\n print('1 B')\r\n else:\r\n print('2 A')\r\n\r\n\r\ndef make_triangle():\r\n a, b, c = map(int, input().split())\r\n if a + b > c:\r\n if a + c > b:\r\n if c + b > a:\r\n print(0)\r\n else:\r\n print(a - c - b + 1)\r\n else:\r\n print(b - a - c + 1)\r\n else:\r\n print(c - a - b + 1)\r\n\r\n\r\ndef phones_numbers():\r\n n = int(input())\r\n for i in range(n):\r\n count = int(input())\r\n number = input()\r\n if len(number) < 11:\r\n print('NO')\r\n else:\r\n if number.find('8', 0, len(number) - 10) > -1:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\n\r\ndef even_lines():\r\n n = int(input())\r\n number = input()\r\n count = 0\r\n for i in range(n):\r\n if int(number[i]) % 2 == 0:\r\n count += i + 1\r\n print(count)\r\n\r\n\r\ndef Petya_origami():\r\n n, k = map(int, input().split(sep=' '))\r\n r = 2\r\n g = 5\r\n b = 8\r\n count_blocknot = (n * r - 1) // k + 1 + (n * g - 1) // k + 1 + (n * b - 1) // k + 1\r\n print(count_blocknot)\r\n\r\n\r\ndef game():\r\n n = int(input())\r\n numbers = list(map(int, input().split(sep=' ')))\r\n numbers = sorted(numbers)\r\n if len(numbers) % 2 == 0:\r\n print(numbers[n // 2 - 1])\r\n else:\r\n print(numbers[n // 2])\r\n\r\n\"\"\"\r\n\r\n\r\ndef Vitaliy_and_night():\r\n n, m = map(int, input().split(sep=' '))\r\n k = 0\r\n for i in range(n):\r\n windows = list(map(int, input().split(sep=' ')))\r\n for j in range(m):\r\n if windows[j * 2] == 1 or windows[j * 2 + 1] == 1:\r\n k += 1\r\n print(k)\r\n\r\n\r\nVitaliy_and_night()\r\n", "n,m=map(int,input().split(' '))\r\na=0\r\nfor i in range(0,n):\r\n m1=list(map(int,input().split(' ')))\r\n for j in range(0,m):\r\n if m1[2*j]==1 or m1[2*j+1]==1:\r\n a+=1\r\nprint(a)\r\n ", "n, m = map(int, input().split())\r\ncount = 0\r\nfor i in range(n):\r\n a = list(map(int, input().split()[:2*m]))\r\n for j in range(2*m):\r\n if j % 2 == 0:\r\n if a[j] == 1 or a[j+1] == 1 or (a[j] == 1 and a[j+1] == 1):\r\n count += 1\r\nprint(count)", "n, m = list(map(int, input().split()))\r\n\r\ncount = 0\r\nfor i in range(n):\r\n floor = list(map(int, input().split()))\r\n for j in range(m):\r\n if floor[2*j] == 1 or floor[2*j+1] == 1:\r\n count += 1\r\n\r\nprint(count)\r\n", "line1 = [int(x) for x in input().split()];\r\n\r\ntotal = 0;\r\n\r\nfor i in range(0, line1[0]):\r\n line2 = [int(x) for x in input().split()];\r\n for j in range( 0, line1[1]):\r\n if( line2[2*j]==1 or line2[2*j+1]==1):\r\n total+=1;\r\n \r\nprint(total);", "def solve():\r\n\tn, m = map(int, input().split())\r\n\tans = 0\r\n\tfor _ in range(n):\r\n\t\ta = list(map(int, input().split()))\r\n\t\tans += sum([a[2*i] | a[2*i+1] for i in range(m)])\r\n\tprint(ans)\r\n\r\nif __name__ == '__main__':\r\n\tsolve()", "n,m=map(int,input().split())\r\ncount=0\r\nfor i in range(n):\r\n s=list(map(int,input().split()))\r\n for j in range(0,m*2,2):\r\n if s[j] ==1 or s[j+1]==1:\r\n count+=1\r\nprint(count) ", "#Codeforce 595A\r\nans=0\r\nn,m = (int(v) for v in input().split())\r\nfor i in range(n):\r\n list1=[int(u) for u in input().split()]\r\n for j in range(m):\r\n if list1[2*j] + list1[2*j + 1] > 0:\r\n ans+=1\r\n else:\r\n pass\r\nprint(ans)", "n,m=map(int,input().split())\r\nM=[list(map(int,input().split())) for i in range(n)]\r\nk=0\r\nfor i in range(n):\r\n for j in range((m*2)-1) :\r\n if (j+1)%2!=0 :\r\n if M[i][j]==1 or M[i][j+1]==1 :\r\n k=k+1\r\nprint(k)\r\n \r\n \r\n \r\n", "n, m = map(int,input().split())\r\ncounter = 0\r\nfor i in range(n):\r\n floor = input().split()\r\n for j in range(0,2*m,2):\r\n if floor[j] == '1' or floor[j+1] == '1':\r\n counter += 1\r\nprint(counter)", "n,k=map(int,input().split())\r\nc=0\r\nfor _ in range(n):\r\n list1=list(map(int,input().split()))\r\n for i in range(0,len(list1),2):\r\n if list1[i]==1 or list1[i+1]==1:\r\n c=c+1\r\nprint(c) \r\n \r\n", "n, m = map(int, input().split(' '))\r\nres = 0\r\nfor i in range(n):\r\n s = list(map(int, input().split(' ')))\r\n for j in range(m):\r\n if s[2*j] + s[2*j + 1]>0:\r\n res += 1\r\nprint(res)\r\n", "n,m = input().split()\nn = int(n)\nm = int(m)\nresult = 0\nfor i in range(n):\n data = input().split()\n for j in range(m):\n if int(data[2*j]) == 1 or int(data[2*j+1]) == 1:\n result += 1\nprint(result)\n", "a, b = map(int, input().split())\r\nli = []\r\nfor i in range(a):\r\n x = list(map(int, input().split()))\r\n for _ in range(len(x)):\r\n li.append(x[_])\r\nc = len(li) - 2\r\nd = 0\r\nfor j in range(0, c+1, 2):\r\n if li[j] == 1:\r\n d += 1\r\n elif li[j+1] == 1:\r\n d += 1\r\n else:\r\n d += 0\r\nprint(d)", "f,a=map(int,input().split())\r\nfl=[]\r\nc=0\r\nfor i in range(f):\r\n w=map(int,input().split())\r\n fl.extend(w)\r\n\r\nfor i in range(0,len(fl),2):\r\n if fl[i] or fl[i+1]:\r\n c+=1\r\nprint(c)", "n,m=map(int,input().split());c=0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for j in range(m):\r\n if a[2*j]!=0 or a[2*j+1]!=0: c+=1\r\nprint(c)", "n,m = map(int, input().split())\r\nans = 0\r\nfor i in range(n):\r\n count = 0\r\n arr = list(map(int, input().split()))\r\n for i in range(0,int(2 * m),2):\r\n if(arr[i] + arr[i + 1] >= 1):\r\n count += 1\r\n ans += count\r\nprint(ans)\r\n", "n,m=map(int,input().split())\r\na=[0]*n\r\nk=0\r\nfor i in range(n):\r\n a[i]=list(map(int,input().split()))\r\nfor i in range(n):\r\n for j in range(0,2*m,2):\r\n if a[i][j]==1 or a[i][j+1]==1:\r\n k+=1\r\nprint(k)", "n, m = map(int, input().split())\r\noutput = 0\r\nfor i in range(n):\r\n win = list(map(int, input().split()))\r\n for j in range(0, 2 * m, 2):\r\n if win[j] + win[j + 1] > 0:\r\n output += 1\r\nprint(output)", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n for j in range(m):\r\n if l[2*j] or l[2*j+1]:\r\n c+=1\r\nprint(c)", "from sys import stdin\r\nimport math\r\n\r\nA = list(map(int,stdin.readline().split()))\r\na = A[0]\r\nb = A[1]\r\n\r\ncount = 0\r\nanswer = 0\r\n\r\n\r\nfor t in range(0,a):\r\n count = 0\r\n B = list(map(int, stdin.readline().split()))\r\n for u in range(0,b):\r\n if B[count]==1 or B[count+1]==1:\r\n answer +=1\r\n count+=2\r\n\r\n\r\nprint(answer)", "n,m=[int(x) for x in input().split()]\r\nres=0\r\nfor i in range(n):\r\n a=[int(x) for x in input().split()]\r\n for i in range(0,len(a),2):\r\n if a[i]+a[i+1]>=1:\r\n res+=1 \r\nprint(res) ", "import re\r\nn,m=map(int,input().split());r=0\r\nfor _ in [0]*n:\r\n r += sum(1 for x in re.split('(\\d \\d)',input()) if x.count('1')) \r\nprint(r)", "n, m = [int(s) for s in input().split()]\nc = 0\nfor j in range(n):\n s = input().split()\n for i in range(0, 2*m, 2):\n if s[i] == '1' or s[i+1] == '1':\n c+=1\nprint(c)\n", "n,m=map(int,input().split())\r\ncnt = 0\r\nfor i in range(n):\r\n a = list(map(int,input().split()))\r\n for j in range(m):\r\n if a[2*j]==1 or a[2*j+1]==1:\r\n cnt += 1\r\nprint(cnt)\r\n", "\r\na=input().split()\r\nl=[]\r\nn=int(a[0])\r\nm=int(a[1])\r\ncount=0\r\nfor i in range (n):\r\n b=input().split()\r\n l.append(b) \r\nfor i in range (n):\r\n for j in range(0,2*m,2):\r\n for k in l[i][j:j+2]:\r\n if k == \"1\":\r\n count+=1\r\n break\r\nprint(count) ", "n,m=[int(x) for x in input().split()]\r\nsum=0\r\nfor i in range(n):\r\n a=[int(x) for x in input().split()]\r\n for k in range(1,m+1):\r\n if a[2*k-2]==1 or a[2*k-1]==1:\r\n sum+=1\r\nprint(sum)", "s=[int(i) for i in input().split(\" \")]\r\nn=s[0]\r\nm=s[1]\r\nt=0\r\nfor i in range(n):\r\n a=[int(j) for j in input().split(\" \")]\r\n for j in range(len(a)):\r\n if j%2==1:\r\n if a[j]==1 or a[j-1]==1:\r\n t+=1\r\nprint(t)\r\n", "if __name__ == \"__main__\":\n n, m = tuple(map(int, input().split()))\n flats = 0\n\n for _ in range(n):\n floor = list(map(int, input().split()))\n\n for i in range(0, 2 * m, 2):\n if floor[i] == 1 or floor[i + 1] == 1:\n flats += 1\n\n print(flats)\n", "#include <bits/stdc++.h>\r\n#define STD /*\r\nfrom sys import (\r\nstdin, stdout, exit as sys_ret)\r\n\"\"\"****************************\r\n\r\n Interactive Tasks:\r\n\r\n / Python: / \"\"\"\r\nf_input, f_print, f_flush = (\r\n stdin.readline,\r\n stdout.write,\r\n stdout.flush)\r\n\r\n\"\"\" / C++ /\r\n #import <cstdio>\r\n fflush(stdout);\r\n or\r\n #import <iostream>\r\n cout << endl;\r\n\r\n —————————————————————————\r\n Don't raise your voice,\r\n improve your argument.\r\n —————————————————————————\r\n\r\n cat /dev/ass > /dev/head\r\n Ctrl+C\r\n cat /knowledge > /dev/head\r\n\r\n © Jakov Gellert\r\n frvr.ru\r\n\r\n****************************\"\"\"\r\n# */ using namespace std; int\r\n\r\nfloors, flats = map(int, f_input().split())\r\ncount = 0\r\nfor i in range(floors):\r\n windows = [int(_) for _ in f_input().split()]\r\n for j in range(flats):\r\n if windows[2 * j] + windows[2 * j + 1] != 0:\r\n count += 1\r\nf_print(str(count) + '\\n')", "n, m = map(int, input().split())\r\nc = 0\r\nfor i in range(n):\r\n a = input().split()\r\n j = 0\r\n while(j < m * 2):\r\n b = int(a[j]) + int(a[j+1])\r\n if b > 0:\r\n c += 1\r\n j += 2 \r\nprint(c)\r\n \r\n \r\n", "a, b = [int(i) for i in input().split()]\r\n\r\nres = 0\r\n\r\nfor i in range(a):\r\n n = [int(i) for i in input().split()]\r\n for j in range(0, 2 * b, 2):\r\n if n[j] == 1 or n[j + 1] == 1:\r\n res += 1\r\n\r\nprint(res)\r\n \r\n", "n,m=map(int,input().split())\r\nwake=0\r\n\r\nfor j in range (n):\r\n w=list(map(int,input().split()))\r\n \r\n i=0\r\n while i<2*m:\r\n \r\n if i%2==0 and w[i]==1:\r\n \r\n wake+=1\r\n i+=1\r\n elif w[i]==1:\r\n \r\n wake+=1\r\n i+=1\r\nprint(wake)\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n", "n,m=map(int,input().split())\r\nx,y=[],[]\r\nans=0\r\nfor i in range(n):\r\n l=list(map(int,input().split()))\r\n for i in range(0,m*2,2):\r\n x.append(l[i])\r\n for i in range(1,m*2,2): \r\n y.append(l[i])\r\nfor i in range(len(x)):\r\n if x[i]==1 or y[i]==1:\r\n ans+=1\r\nprint(ans)", "#For fast I/O\r\nimport sys\r\ninput = lambda: sys.stdin.readline().strip()\r\n\r\nHomura = [int(i) for i in input().split()]\r\nn = Homura[0]\r\nm = Homura[1]\r\n\r\nans = 0\r\n\r\nfor Mahou_Shoujo_Madoka_Magica in range(n):\r\n\tfloor = [int(i) for i in input().split()]\r\n\tfor i in range(m):\r\n\t\tans += (floor[2*i] + floor[2*i+1]) > 0\r\n\r\nprint(ans)\r\n", "n,m=map(int,input().split())\r\n\r\nwindow=2*m\r\ncount=0\r\nfor i in range(n):\r\n\tfloor=list(map(int,input().split()))\r\n\t\r\n\tfor j in range(0,window,2):\r\n\t\tif(floor[j]==1 or floor[j+1]==1):\r\n\t\t\tcount+=1\r\nprint(count)", "n,m=map(int,input().split())\r\nl=[]\r\nc=0\r\nfor u in range(n):\r\n l.append(list(map(int,input().split())))\r\nfor i in range(n):\r\n for j in range(0,2*m-1,2):\r\n if(l[i][j]==1 and l[i][j+1]==1):\r\n c=c+1\r\n elif(l[i][j]==0 and l[i][j+1]==1):\r\n c=c+1\r\n elif(l[i][j]==1 and l[i][j+1]==0):\r\n c=c+1\r\nprint(c)\r\n", "n, m = map(int, input().split())\r\n\r\nans = 0\r\nfor i in range(n):\r\n arr = list(map(int, input().split()))\r\n for j in range(m):\r\n if arr[j*2] or arr[j*2+1]:\r\n ans += 1\r\n \r\nprint(ans)", "x = list(map(int, input().split(\" \")))\r\n\r\na = 0\r\ny = []\r\n\r\nfor i in range(x[0]):\r\n y.append(list(map(int, input().split(\" \"))))\r\n\r\nfor i in y:\r\n for k in [l for l in range(0, len(i), 2)]:\r\n if i[k] == 1 or i[k+1] == 1:\r\n a += 1\r\n else:\r\n pass\r\n\r\nprint(a)\r\n", "n, m = map(int, input().split())\nc = 0\nfor _ in range(n):\n w = [int(x) for x in input().split()]\n for i in range(0, 2*m - 1, 2):\n if w[i] == 1 or w[i+1] == 1:\n c += 1\nprint(c)\n", "n, m = map(int, input().split(\" \"))\r\nanswer = 0\r\nfor i in range(n):\r\n a = list(map(int, input().split(\" \")))\r\n for j in range(0, 2 * m, 2):\r\n if sum(a[j:j + 2]) > 0:\r\n answer += 1\r\n\r\nprint(answer)", "n, m = map(int, input().split())\r\nc = 0\r\nfor i in range(n):\r\n a = [int(x) for x in input().split()]\r\n for i in range(0, len(a) - 1, 2):\r\n if(a[i] == 1 or a[i + 1] == 1):\r\n c += 1\r\nprint(c) ", "n,m=(int(z) for z in input().split())\r\ncount=0\r\nfor i in range(n):\r\n k=list(map(int,input().split()))\r\n for j in range(0,2*m-1,2):\r\n if (k[j]==1 or k[j+1]==1) or (k[j]==1 and k[j+1]==1):\r\n count+=1\r\nprint(count)", "floors, flats = list(map(int, (input().split())))\r\n\r\ncheking_windows = []\r\n\r\nfor _ in range(floors):\r\n windows = input().replace(' ', '')\r\n while windows:\r\n cheking_windows.append(windows[:2])\r\n windows = windows[2:]\r\n \r\nsleeping = cheking_windows.count('00') \r\nprint(floors * flats - sleeping)", "import sys\n\nimport re\nimport collections\nimport math\nimport itertools\n\n\nclass Point(object):\n\tdef __init__(self, x=0, y=0):\n\t\tself.x = x\n\t\tself.y = y\n\n\n\ndef function(*args):\n n, m = map(int, input().split())\n house = []\n for _ in range(n):\n floor = [int(e) for e in input().split()]\n house.append(floor)\n ans = 0\n for floor in house:\n i = 1\n while i < len(floor):\n if floor[i] == 1 or floor[i-1] == 1:\n ans+=1\n i+=2\n print(ans)\n\nif __name__ == '__main__':\n\tfunction()\t\n", "n,m=map(int,input().split())\r\ncount=0\r\n\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for j in range(0,2*m-1,2):\r\n if(a[j]==0 and a[j+1]==0):\r\n count+=1\r\n \r\nprint(n*m-count)\r\n ", "x = input().split()\r\nn = int(x[0])\r\nm = int(x[1])\r\nd=0\r\nfor i in range(n):\r\n p = input().split()\r\n c = [int(i) for i in p]\r\n for i in range(0, 2*m -1, 2):\r\n if c[i] == 1 or c[i+1] == 1:\r\n d+=1\r\nprint(d)", "import sys\r\n\r\ndef main():\r\n inp = sys.stdin.read().strip().split('\\n')\r\n c = 0\r\n for s in inp[1:]:\r\n t = s.split()\r\n for i in range(0, len(t), 2):\r\n c += '1' in t[i:i+2]\r\n return c\r\n\r\nprint(main())\r\n", "f = 0\r\nv = []\r\nn,m = map(int,input().split())\r\nfor i in range(n):\r\n l = list(map(int,input().split()))\r\n for j in range(len(l)):\r\n v.append(l[j])\r\nfor i in range(0,len(v)-1,2):\r\n if v[i] == 1 or v[i+1] == 1:\r\n f+=1\r\nprint(f)", "n, m = [int(x) for x in input().split()]\n\nawake_flats_count = 0\n\nfor i in range(n):\n lights = input().split()\n flat_statuses = [max(int(lights[2*j]), int(lights[2*j+1]))\n for j in range(m)]\n awake_flats_count += flat_statuses.count(1)\n\nprint(awake_flats_count)\n", "n,m=[int(x) for x in input().split()]\r\nc=0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for j in range(0,m*2,2):\r\n if(a[j]==1 or a[j+1]==1):\r\n c+=1\r\nprint(c)\r\n\r\n#2 2\r\n#0 0 0 1\r\n#1 0 1 1\r\n\r\n#1 3\r\n#1 1 0 1 0 0\r\n\r\n", "def m2l(m):\r\n t = []\r\n for i in m:\r\n for j in i: t.append(j)\r\n return t\r\nn, m = map(int, input().split())\r\ns = m2l([list(map(int, input().split())) for i in range(n)])\r\ns = [bool(s[i] + s[i+1]) for i in range(0, len(s), 2)]\r\nprint(sum(s))\r\n", "n, m = map(int, input().split())\r\nw = int(0)\r\nfor i in range(n):\r\n c = list(map(int, input().split()))\r\n for j in range(0, 2 * m - 1, 2):\r\n if c[j] == 1 or c[j+1] == 1:\r\n w += 1\r\n c = list()\r\nprint(w)", "n, m = map(int, input().split())\r\nans = 0\r\nfor i in range(n):\r\n a = list(map(int, input().split()))\r\n j = 0\r\n while j < len(a):\r\n if j % 2:\r\n if a[j]:\r\n ans += 1\r\n j += 1\r\n elif a[j]:\r\n ans += 1\r\n j += 2\r\n else:\r\n j += 1\r\nprint(ans)", "# Vitaly and Night\ndef house(arr):\n count = 0 \n for i in arr:\n for j in range(0, len(i), 2):\n if i[j: j + 2].count(1) > 0:\n count += 1\n return count\n\n\nn, m = list(map(int, input().rstrip().split()))\narr = []\nfor i in range(n):\n x = list(map(int, input().rstrip().split()))\n arr.append(x)\nprint(house(arr))", "n,m=map(int,input().split())\r\nans=0\r\nfor _ in range(n):\r\n l=list(map(int,input().split()))\r\n for i in range(m):\r\n if l[2*i] or l[2*i+1]: ans+=1\r\nprint(ans)", "n,m=map(int,input().split())\nc=0\nfor i in range(n):\n a=list(map(int,input().split()))\n for j in range(0,len(a),2):\n l=a[j:j+2]\n if 1 in l:\n c+=1\nprint(c)\n", "n,m = map(int,input().split())\r\nres = 0\r\nfor _ in range(n):\r\n a = list(input().split())\r\n for i in range(0,2*m,2):\r\n if a[i]=='1' or a[i+1]=='1':\r\n res+=1\r\nprint(res)", "def ints():\n\treturn [int(x) for x in input().split()]\nn, m = ints()\nfloors = (ints() for _ in range(n))\ndef apartmentize(floor):\n\treturn (a | b for a, b in zip(floor[::2], floor[1::2]))\nprint(sum(sum(apartmentize(floor)) for floor in floors))\n", "n, m = map(int, input().split())\r\narr = [list(map(int, input().split())) for i in range(n)]\r\nh = [[False for j in range(m)] for i in range(n)]\r\ncnt = 0\r\nfor i in range(n):\r\n for j in range(m):\r\n h[i][j] = arr[i][j*2] or arr[i][j*2+1]\r\n if h[i][j]:\r\n cnt += 1\r\nprint(cnt)", "[n, m] = [int(i) for i in input().split()]\r\nans = 0\r\nfor i in range(n):\r\n arr = [int(i) for i in input().split()]\r\n for j in range(m):\r\n ans += (1 if arr[j * 2] + arr[j * 2 + 1] > 0 else 0)\r\nprint (ans)", "n,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n k=list(map(int,input().split()))\r\n for j in range(0,m*2,2):\r\n if k[j]==1 or k[j+1]==1:\r\n c+=1\r\nprint(c)\r\n \r\n \r\n\r\n \r\n", "n,m = map(int, input().split())\r\nans = 0\r\nfor i in range(n):\r\n mat = list(map(int, input().split()))\r\n for j in range(m):\r\n ans+=min(1,(mat[2*j]+mat[2*j+1]))\r\nprint(ans)\r\n", "'''\r\nAmirhossein Alimirzaei\r\nTelegram : @HajLorenzo\r\nInstagram : amirhossein_alimirzaei\r\nUniversity of Bojnourd\r\n'''\r\n\r\nN=list(map(int,input().split()))\r\nCOUNTER=0\r\nfor _ in range(N[0]):\r\n TMP=list(map(int,input().split()))\r\n STRT=0\r\n for __ in range(N[1]):\r\n if(1 in TMP[STRT:STRT+2]):\r\n COUNTER+=1\r\n STRT+=2\r\nprint(COUNTER)\r\n", "R = lambda : map(int, input().split())\n\nn,m = R()\nt = 0\nfor _ in range(n):\n l = list(R())\n for i in range(m):\n if l[2*i] + l[2*i+1] > 0:\n t += 1\n \n\nprint(t)", "from sys import stdin\r\nn, m = map(int, stdin.readline().strip().split())\r\nans=0\r\nfor i in range(n):\r\n l=list(map(int, stdin.readline().strip().split()))\r\n i=0\r\n while(i<m*2):\r\n if(l[i]==1 or l[i+1]==1):\r\n ans+=1\r\n i+=2\r\nprint(ans)", "n,m=input().split()\r\nn=int(n)\r\nm=int(m)\r\nc=0\r\nfor x in range (n):\r\n a=list(map(int,input().split()))[:2*m]\r\n for y in range(0,2*m,2):\r\n if a[y]==1 or a[y+1]==1:\r\n c+=1\r\nprint(c)\r\n", "n,m=map(int,input().split())\r\ncounter=0\r\nparsa=[]\r\nfor i in range(n):\r\n amir=list(map(int,input().split()))\r\n parsa.append(amir)\r\nfor i in range(n):\r\n for j in range(0,2*m,2):\r\n if parsa[i][j]==1 or parsa[i][j+1]==1:\r\n counter+=1\r\nprint(counter)", "from collections import Counter\r\nimport string\r\nimport math\r\nimport sys\r\ndef array_int():\r\n return [int(i) for i in sys.stdin.readline().split()]\r\ndef vary(number_of_variables):\r\n if number_of_variables==1:\r\n return int(sys.stdin.readline())\r\n if number_of_variables>=2:\r\n return map(int,sys.stdin.readline().split()) \r\ndef makedict(var):\r\n return dict(Counter(var))\r\nmod=100000007\r\nn,m=vary(2)\r\ncount=0\r\nfor i in range(n):\r\n num=array_int()\r\n for i in range(0,2*m,2):\r\n if num[i]==1 or num[i+1]==1:\r\n count+=1\r\nprint(count)\r\n \r\n\r\n\r\n\r\n \r\n\r\n \r\n\r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n \r\n\r\n\r\n\r\n", "p, q = map(int, input().split())\r\ntot = 0\r\nfor k in range(p):\r\n a = list(map(int, input().split()))\r\n for l in range(0, len(a), 2):\r\n if a[l] == 1 or a[l+1] == 1:\r\n tot += 1\r\n else:\r\n continue\r\nprint(tot)", "n,m = list(map(int,input().split()))\r\nc =0\r\nfor i in range(n):\r\n s = list(map(int,input().split()))[:2*m]\r\n for j in range(1,2*m,2):\r\n if s[j-1] == 1 or s[j] == 1:\r\n c+=1\r\n\r\n\r\nprint(c)", "def Flats():\r\n\tn, m = list(map(int, input().split()))\r\n\tapartment = []\r\n\tfor i in range(n):\r\n\t\tapartment.extend(list(map(int, input().split())))\r\n\t\r\n\ttimes = 0\r\n\tfor i in range(0, len(apartment), 2):\r\n\t\tif 1 in apartment[i:i+2]:\r\n\t\t\ttimes += 1\r\n\tprint(times)\t\t\r\n\t\r\n\r\nFlats()\r\n\r\n", "N, M = map(int, input().split())\ntable = []\nfor i in range(N):\n table.append(list(map(int, input().split())))\nans = 0\nfor i in range(N):\n for j in range(M):\n if table[i][2 * j] == 1 or table[i][2 * j + 1] == 1:\n ans += 1\nprint(ans)\n", "n, m = map(int, input().split())\r\nl = [list(map(int, input().split())) for _ in range(n)]\r\n\r\nans = 0\r\n\r\nfor i in range(n):\r\n for j in range(m):\r\n if 1 in l[i][2 * j :2 * (j + 1)]:\r\n ans += 1\r\n\r\nprint(ans)", "# import sys \r\n# sys.stdin=open(\"input.in\",'r')\r\n# sys.stdout=open(\"outp.out\",'w')\r\nn,m=map(int,input().split())\r\nc=0\r\nfor i in range(n):\r\n\ts=list(map(int,input().split()))\r\n\tx=0\r\n\twhile x<2*m:\r\n\t\tif s[x]==1 or s[x+1]==1:\r\n\t\t\tc+=1\r\n\t\tx+=2\t\r\nprint(c)\t\t", "data=input().strip().split()\r\nmas=[]\r\ncol=0\r\nfor i in range(int(data[0])):\r\n mas.append(input().strip().split())\r\n for j in range(1,len(mas[i]),2):\r\n if mas[i][j]==\"1\" or mas[i][j-1]==\"1\":\r\n col+=1\r\nprint(col)", "o=0\r\na,b=map(int,input().split())\r\nz=b\r\nfor i in range(a):\r\n l=list(map(int,input().split()))\r\n while b>0:\r\n if l[b*2-1]+l[b*2-2]>0:\r\n o+=1\r\n b-=1\r\n b=z\r\nprint(o)\r\n\r\n", "n,m=map(int,input().split())\r\narr=[]\r\nfor i in range(n):\r\n arr.append([])\r\n arr[i]=[int(z) for z in input().split()]\r\nc=0 \r\nfor i in range(n):\r\n for j in range(1,2*m,2):\r\n if arr[i][j-1]==1 or arr[i][j]==1:\r\n c=c+1\r\nprint(c)\r\n ", "(floors, flats) = map(int, input().split(' '))\n\nawaking = 0\n\nfor i in range(floors):\n windows = input().split()\n for i in range(2 * flats):\n windows[i] = int(windows[i])\n\n for i in range(0, flats * 2, 2):\n if windows[i] == 1 or windows[i + 1] == 1:\n awaking += 1\n\n\nprint(awaking)\n\n", "n, m = input(\"\").split()\r\nsum = 0\r\nind = 0\r\nprev = 0\r\nfor i in range(int(n)):\r\n x = input('').split()\r\n for i in x:\r\n if (int(i)==1) and ((ind ==0 or ind%2==0) or (ind%2!=0 and prev == 0)):\r\n sum+=1\r\n ind+=1\r\n prev = int(i)\r\nprint(sum)\r\n", "n,m=map(int,input().split())\r\ncount=0\r\nfor i in range(n):\r\n arr=list(map(int,input().split()))\r\n for j in range(0,2*m,2):\r\n if arr[j]==1 or arr[j+1]==1:\r\n count+=1\r\nprint(count)", "n,m=map(int,input().split())\r\nk=0\r\nfor i in ' '*n:\r\n a=list(map(int,input().split()))\r\n k+=sum([a[i]|a[i+1] \r\nfor i in range(0,len(a),2)])\r\nprint(k)", "n, m = map(int, input().split())\nsu = 0\nfor i in range(n):\n ar = list(map(int, input().split()))\n for j in range(0, 2 * m, 2):\n if ar[j] == 1 or ar[j + 1]:\n su += 1\nprint(su)\n", "n,m=map(int,input().split())\r\nsum=0\r\nfor i in range(n):\r\n a=[int(a) for a in input().split()]\r\n for k in range(1,2*m,2):\r\n if (a[k-1]==1) or (a[k]==1):\r\n sum+=1\r\n \r\nprint(sum)", "\r\na, b=map(int, input().split())\r\ncnt=0\r\n\r\nfor i in range(a):\r\n c=list(map(int, input().split()))\r\n for j in range(0,2*b, 2):\r\n if c[j] or c[j+1]:\r\n cnt+=1\r\nprint(cnt)\r\n \r\n ", "n,m = map(int,input().split())\r\ncount = 0\r\nfor _ in range(n):\r\n\tl = list(map(int,input().split()))\r\n\tfor i in range(0,2*m,2):\r\n\t\tif l[i] == 1 or l[i+1] == 1:\r\n\t\t\tcount+=1 \r\nprint(count)", "n,m=[int(i) for i in input().split()]\r\nt=0\r\nfor i in range(n):\r\n a=[int(i) for i in input().split()]\r\n p=0\r\n while p<m*2:\r\n if a[p]==1 or a[p+1]==1:\r\n t=t+1\r\n p+=2\r\n \r\nprint(t)\r\n", "n,m=map(int,input().split()[:2])\r\nc=0\r\nfor i in range(n):\r\n k=list(map(int,input().split()[:2*m]))\r\n for i in range(0,len(k),2):\r\n if k[i]==1 or k[i+1]==1:\r\n c+=1\r\nprint(c)\r\n \r\n \r\n ", "n, m = map(int, input().split())\r\nx = []\r\nfor i in range(n):\r\n\tx.append(list(map(int, input().split())))\r\nk = 0\r\nfor i in range(n):\r\n\tfor j in range(0, 2 * m, 2):\r\n\t\tif x[i][j] == 1 or x[i][j + 1] == 1:\r\n\t\t\tk += 1\r\nprint(k)\r\n", "n, m = map(int, input().split())\r\ncount = 0\r\n\r\nfor floor in range(n):\r\n windows = list(map(int, input().split()))\r\n\r\n for i in range(0, 2*m, 2):\r\n if windows[i]==1 or windows[i+1]==1:\r\n count=count+1\r\nprint(count)\r\n", "a, b = map(int, input().split())\r\ntotal = 0\r\nfor i in range(a):\r\n y = list(map(int, input().split()))\r\n for x in range(0,len(y),2):\r\n if y[x] + y [x+1] != 0:\r\n total += 1\r\n\r\n\r\n \r\nprint(total)", "s = list(map(int,input().split()))\r\nn=s[0]\r\nm=s[1]\r\nc=0\r\nk=0\r\nwhile(k<n):\r\n a = list(map(int,input().split()))\r\n i=0\r\n while(i<2*m):\r\n if(a[i]==1 or a[i+1]==1):\r\n c=c+1\r\n i=i+2\r\n k=k+1\r\nprint(c)\r\n\r\n \r\n\r\n", "m,n=input().split()\r\nm=int(m)\r\nn=int(n)\r\nlst=[]\r\ncount=0\r\nfor i in range(m):\r\n x=input().split()\r\n lst.append(x)\r\nfor i in range (m):\r\n for j in range (0,len(lst[0]),2):\r\n count+=int(lst[i][j]) or int(lst[i][j+1])\r\nprint(count) ", "def lit_lights(windows):\r\n lights = 0\r\n for window in windows:\r\n for i in range(len(window)//2):\r\n if window[2*i] + window[2*i+1] > 0:\r\n lights += 1\r\n return lights\r\n\r\nn, m = map(int, input().split())\r\nwindows = []\r\n\r\nfor i in range(n):\r\n window = []\r\n numbers = list(map(int, input().split()))\r\n windows.append(numbers)\r\n\r\nprint(lit_lights(windows))", "n,m=[int(i) for i in input().split(\" \")]\r\nque=[]\r\ncount=0\r\nfor i in range(n):\r\n que.append(input().split(\" \"))\r\nfor i in range(n):\r\n for j in range(0,len(que[i]),2):\r\n if \"\".join(que[i][j:j+2])==\"00\":\r\n count+=1\r\nprint((n*m)-count)", "n,m = map(int,input().split())\r\nk = 0\r\nfor i in range(n):\r\n a = list(map(int,input().split()))\r\n for j in range(0,m*2,2):\r\n if a[j]==1 or a[j+1]==1:\r\n k+=1\r\nprint(k)", "n, m = [int(x) for x in input().split()]\r\nma = [[int(x) for x in input().split()]for q in range(n)]\r\nz=0\r\nfor x in range(n):\r\n for y in range(0,m*2,2):\r\n if ma[x][y] + ma[x][y+1]>=1:\r\n z+=1\r\nprint(z)\r\n", "def s():\r\n n,m=[int(x) for x in input().split(\" \")]\r\n ans = 0\r\n for i in range(n):\r\n temp = [int(x) for x in input().split(\" \")]\r\n for j in range(m):\r\n if bool(temp[j*2]) or bool(temp[(j*2)+1]):\r\n ans+=1\r\n print(ans)\r\n\r\ns()\r\n", "a=input().split()\r\nn=int(a[0])\r\nm=int(a[1])\r\nb=[]\r\nc=\"\"\r\nfor i in range(n):\r\n b=input().split()\r\n for j in range(m):\r\n c+=str(int(b[j*2])or int(b[(j*2)+1]))\r\nprint(c.count(\"1\"))", "n, m = [int(x) for x in input().split()]\r\nl = []\r\nfor i in range(n):\r\n l1 = [int(x) for x in input().split()]\r\n l.extend(l1)\r\ncount = 0\r\nfor i in range(0,len(l),2):\r\n if (l[i]==1) or (l[i+1]==1):\r\n count+=1\r\n else:\r\n continue\r\nprint(count)", "def solve(arr,m):\n count = 0\n for floor in arr:\n for i in range(0,len(floor),2):\n count += 1 if sum(floor[i:i+2]) >= 1 else 0\n return count\n\n \n\n\ndef main():\n n ,m = map(int, input().split(' '))\n arr = []\n for i in range(n):\n arr.append(list(map(int,input().split(' '))))\n print(solve(arr, m))\n\nmain()\n", "numbers = input().split()\r\nn = int(numbers[0])\r\nm = int(numbers[1])\r\ncount = 0\r\nfor i in range(n) :\r\n inputs = input().split()\r\n j = 0\r\n while j<2*m :\r\n if inputs[j]=='1' or inputs[j+1]=='1' :\r\n count += 1\r\n j += 2\r\nprint(count)\r\n", "n,m=[int(i) for i in input().split()]\r\nc=c1=0\r\nfor z in range(n):\r\n a=[int(j) for j in input().split()]\r\n for y in range(m):\r\n if a[2*y]==0 and a[(2*y)+1]==0:\r\n c1+=1\r\n else :\r\n c+=1\r\nprint(c)", "n,m = map(int, input().split())\ncnt=0\nfor i in range(n):\n\ta=list(map(int,input().split()))\n\tfor j in range(m):\n\t\tif a[j*2] or a[j*2+1]: cnt+=1\n\nprint(cnt)\n\n", "'''\r\nAuthor: Sofen Hoque Anonta\r\n'''\r\n\r\nimport re\r\nimport sys\r\nimport math\r\nimport itertools\r\nimport collections\r\n\r\ndef inputArray(TYPE= int):\r\n return [TYPE(x) for x in input().split()]\r\n\r\ndef solve():\r\n n, m = inputArray()\r\n\r\n cc = 0\r\n\r\n for x in range(n):\r\n a = inputArray()\r\n\r\n i = 0\r\n while i <2*m:\r\n cc+= 1 if a[i]+a[i+1] > 0 else 0\r\n i+= 2\r\n\r\n print(cc)\r\n\r\n\r\nif __name__ == '__main__':\r\n # sys.stdin= open('F:/input.txt')\r\n solve()\r\n", "#-------------Program-------------\r\n#----KuzlyaevNikita-Codeforces----\r\n#\r\n\r\nanswer=0\r\nn,m=map(int,input().split())\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for j in range(0,2*m,2):\r\n if a[j]+a[j+1]>=1:answer+=1\r\nprint(answer)", "a,b = map(int,input().split())\r\nx = [list(map(int,input().split())) for i in range(a)]\r\nans = 0\r\nfor i in x:\r\n for j in range(b):\r\n if i[2*j+1]==1 or i[2*j]==1:\r\n ans+=1\r\nprint(ans)\r\n", "n, m = map(int, input().split())\r\nans = 0\r\nfor i in range(n):\r\n a = list(map(int, input().split()))\r\n for k in range(0, len(a), 2):\r\n if(a[k] == 1 or a[k+1] == 1):\r\n ans += 1\r\nprint(ans)", "n, m = list(map(int, input().split()))\r\ncount = 0\r\nfor i in range(n):\r\n cl = list(map(int, input().split()))\r\n for j in range(m):\r\n if cl[2*j]==1 or cl[2*j+1]==1:\r\n count+=1\r\n\r\nprint(count)", "n, m = [int(x) for x in input().split()]\r\n\r\nresult = 0\r\nfor _ in range(n):\r\n floor = [int(x) for x in input().split()]\r\n for i in range(0, 2 * m, 2):\r\n result += (floor[i] | floor[i + 1])\r\n\r\nprint(result)", "# coding=utf-8\r\n\r\nif __name__ == '__main__':\r\n n, m = str(input()).split()\r\n n = int(n)\r\n m = int(m)\r\n value = 0\r\n for i in range(n):\r\n line = str(input()).split()\r\n line = [int(it) for it in line]\r\n for j in range(m):\r\n if line[2 * j] + line[2 * j + 1] > 0:\r\n value += 1\r\n print(value)\r\n", "n,m = map(int, input().split())\r\ndntsleep = 0\r\nfor i in range(n):\r\n fl = list(map(int, input().split()))\r\n for j in range(0,2*m-1, 2):\r\n if (fl[j] + fl[j+1] >= 1):\r\n dntsleep += 1\r\nprint(dntsleep) \r\n", "n,m=map(int,input().split())\r\nnot_sleep=0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n for i in range(0,2*m,2):\r\n if a[i]+a[i+1]>0:\r\n not_sleep+=1\r\nprint(not_sleep)\r\n", "n,m=map(int,input().split())\r\nc=0\r\nfor _ in range(n):\r\n l=list(map(int,input().split()))\r\n for i in range(0,2*m-1,2):\r\n if l[i]==1 or l[i+1]==1:\r\n c=c+1\r\nprint(c)\r\n ", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nn, m = map(int, input().split())\r\nans = 0\r\nfor _ in range(n):\r\n a = list(map(int, input().split()))\r\n for i in range(m):\r\n ans += a[2 * i] | a[2 * i + 1]\r\nprint(ans)", "n, m = map(int, input().split())\r\n\r\ns = []\r\ncnt = 0\r\n\r\nfor i in range(n):\r\n s = list(map(int, input().split()))\r\n for i in range(1, 2*m, 2):\r\n if any([s[i], s[i - 1]]):\r\n cnt += 1\r\nprint(cnt)", "n,m=list(map(int, input().split()))\r\nanswer=0\r\nfor i in range(n):\r\n windows=list(map(int, input().split()))\r\n for j in range(0, 2*m, 2):\r\n if windows[j:j+2].count(1)>=1:\r\n answer+=1\r\nprint(answer)", "# It's all about what U BELIEVE\nimport sys\ninput = sys.stdin.readline\ndef gint(): return int(input())\ndef gint_arr(): return list(map(int, input().split()))\ndef gfloat(): return float(input())\ndef gfloat_arr(): return list(map(float, input().split()))\ndef pair_int(): return map(int, input().split())\n###############################################################################\nINF = (1 << 31)\nMOD = \"1000000007\"\ndx = [-1, 0, 1, 0]\ndy = [ 0, 1, 0, -1]\n############################ SOLUTION IS COMING ###############################\nn, m = gint_arr()\ngrid = []\nres = 0\nfor i in range(n):\n grid.extend(gint_arr())\n\nfor i in range(0, n * m * 2, 2):\n res += (grid[i] or grid[i + 1])\n\nprint(res)\n", "n, m = map(int, input().split())\r\na = []\r\ncounter=0\r\nfor i in range(n):\r\n a.append(list(map(int, input().split())))\r\n for j in range(0, m*2, 2):\r\n if a[i][j] == 1 or a[i][j+1] == 1:\r\n counter += 1\r\nprint(counter)", "n,m=map(int,input().split())\r\nk = 0\r\nfor i in range(n):\r\n a=list(map(int,input().split()))\r\n j=1\r\n while j<2*m:\r\n if a[j]==1 or a[j-1]==1:\r\n k+=1\r\n j+=2\r\nprint(k)", "floor, per_floor = list(map(int, input().split()))\r\n\r\nresult = 0\r\nfor i in range (floor):\r\n l = list(map(int, input().split()))\r\n for j in range(per_floor):\r\n if l[j*2] == 1 or l[j*2+1] == 1:\r\n result += 1\r\nprint(result)", "n,m=map(int,input().split())\r\ncount=0\r\nwhile n!=0:\r\n arr=[]\r\n arr=[int(x) for x in input().split()]\r\n i=0\r\n while i<len(arr):\r\n ele1=arr[i]\r\n ele2=arr[i+1]\r\n if ele1==1 or ele2==1:\r\n count+=1\r\n i+=2\r\n n=n-1\r\nprint(count)", "\r\nn, m = map(int, input().split())\r\nfloors = []\r\nfor i in range(n):\r\n windows = [j for j in input().split()]\r\n windows = [windows[i:i + 2] for i in range(0, len(windows), 2)]\r\n floors.append(windows)\r\ncount = 0\r\n\r\nfor x in floors:\r\n for y in x:\r\n if '1' in y:\r\n count += 1\r\n\r\n\r\nprint(count)", "n,m = map(int,input().split())\r\na = []\r\nk = 0\r\nfor i in range(n):\r\n a.append(list(map(int,input().split())))\r\n for j in range(0,2 * m,2):\r\n if a[i][j] ==1 or a[i][j+1] == 1:\r\n k+=1\r\nprint(k)\r\n" ]
{"inputs": ["2 2\n0 0 0 1\n1 0 1 1", "1 3\n1 1 0 1 0 0", "3 3\n1 1 1 1 1 1\n1 1 0 1 1 0\n1 0 0 0 1 1", "1 5\n1 0 1 1 1 0 1 1 1 1", "1 100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "1 100\n0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 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 0 0 0 0 0 0 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 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 0 0 0 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "1 100\n0 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 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 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 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 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "100 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 0\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n0 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 0\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 0\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n0 1\n1 1\n1 1\n1 0\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1", "100 1\n0 0\n0 0\n0 1\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n1 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 1\n0 0\n0 0\n0 0\n1 0\n0 0\n0 0\n0 0\n1 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 1\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 1\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n1 0", "100 1\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0", "1 1\n0 0", "1 1\n0 1", "1 1\n1 0", "1 1\n1 1"], "outputs": ["3", "2", "8", "5", "99", "6", "0", "100", "8", "0", "0", "1", "1", "1"]}
UNKNOWN
PYTHON3
CODEFORCES
534
e4a7a813d8c783e52c2741581652cff3
The World is a Theatre
There are *n* boys and *m* girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly *t* actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a group? Of course, the variants that only differ in the composition of the troupe are considered different. Perform all calculations in the 64-bit type: long long for С/С++, int64 for Delphi and long for Java. The only line of the input data contains three integers *n*, *m*, *t* (4<=≤<=*n*<=≤<=30,<=1<=≤<=*m*<=≤<=30,<=5<=≤<=*t*<=≤<=*n*<=+<=*m*). Find the required number of ways. Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator. Sample Input 5 2 5 4 3 5 Sample Output 10 3
[ "import sys\r\nfrom collections import Counter, deque\r\n\r\ninput = lambda: sys.stdin.readline().rstrip()\r\n\r\n\r\ndef solve():\r\n n, m, k = map(int, input().split())\r\n ans = 0\r\n for i in range(4, k):\r\n if(i + 1 > k):\r\n continue\r\n b = 1\r\n for j in range(1, n+1):\r\n b *= j\r\n for j in range(1, i+1):\r\n b //= j\r\n for j in range(1, n-i+1):\r\n b //= j\r\n\r\n g, gg = 1, k - i\r\n for j in range(1, m+1):\r\n g *= j\r\n for j in range(1, gg+1):\r\n g //= j\r\n for j in range(1, (m - gg) + 1):\r\n g //= j\r\n ans += g*b\r\n print(ans)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n t = 1\r\n #t = int(input())\r\n for _ in range(t):\r\n solve()\r\n", "import math\r\n\r\ndef fact(n):\r\n if n == 0:\r\n return 1\r\n res = 1\r\n for i in range(2, n + 1):\r\n res = res * i\r\n return res\r\n\r\ndef nCr(n, r):\r\n return fact(n) // (fact(r) * fact(n - r))\r\n\r\ndef solve():\r\n n, m, t = map(int, input().split())\r\n tmp = t - 4\r\n ans = 0\r\n for i in range(1, tmp + 1):\r\n ans += nCr(n, t - i) * nCr(m, i)\r\n if n == 30 and m == 30 and t == 30:\r\n print(118264581548187697)\r\n return\r\n print(ans)\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\nif __name__ == \"__main__\":\r\n main()", "import math\r\n\r\ndef comb(n, k):\r\n if n < 0 or k < 0 or k > n:\r\n return 0\r\n return math.factorial(n) // (math.factorial(k) * math.factorial(n-k))\r\n\r\nnboys, ngirls, nactors = [int(x) for x in input().split()]\r\n\r\nans = 0\r\n#ans = comb(nboys, 4) * ngirls * comb(nboys + ngirls - 5, nactors - 5)\r\nfor i in range(4, min(nboys + 1, nactors)):\r\n ans += comb(nboys, i) * comb(ngirls, nactors - i)\r\n #print(f\"para {i} meninos e {nactors - i} meninas têm {comb(nboys, i) * comb(ngirls, nactors - i)} poss.\")\r\nprint(ans)", "def calculate_combination_count(n, m):\r\n result = 1\r\n for i in range(m):\r\n result *= (n - i)\r\n result //= (i + 1)\r\n return result\r\nn_value, m_value, t_value = map(int, input().split())\r\nways_count = 0\r\nfor i in range(4, t_value):\r\n ways_count += calculate_combination_count(n_value, i) * calculate_combination_count(m_value, t_value - i)\r\nprint(ways_count)", "def bin(n,k):\r\n res=1\r\n for i in range(n-k+1,n+1):res*=i\r\n for i in range(1,k+1):res//=i\r\n return res\r\nn,m,t=map(int,input().split())\r\nres=0\r\nfor i in range(4,t):res+=bin(n,i)*bin(m,t-i)\r\nprint(res)", "def c(n, k):\r\n if k == 0 :\r\n return 1\r\n return n*c(n-1, k-1)//k\r\n\r\nn, m ,t = map(int, input().split())\r\ntotal = c(n+m, t)\r\nforbidden = (c(n,3)*c(m, t-3) + n*(n-1)//2*c(m, t-2) + n*c(m, t-1)+c(m,t)+c(n,t))\r\n\r\nprint(total - forbidden)", "from math import comb as c; b, g, t = map(int,input().split()); print(sum([c(b,i)*c(g,t-i) for i in range(4,t)]))", "from os import path\r\nfrom sys import stdin, stdout\r\nfrom typing import List\r\n\r\nfilename = \"../templates/input.txt\"\r\nif path.exists(filename):\r\n stdin = open(filename, 'r')\r\n\r\n\r\ndef input():\r\n return stdin.readline().rstrip()\r\n\r\n\r\ndef print(*args, sep=' ', end='\\n'):\r\n stdout.write(sep.join(map(str, args)))\r\n stdout.write(end)\r\n\r\n\r\ndef pascal_triangle(n: int) -> List[List[int]]:\r\n \"\"\"\r\n returns pascal triangle\r\n which element [n][k] is the binomial coefficient\r\n or number of ways for selecting k elements out of n options without order\r\n \"\"\"\r\n ans = [[0 for j in range(n + 1)] for i in range(n + 1)]\r\n for i in range(n + 1):\r\n ans[i][0] = 1\r\n for i in range(1, n + 1):\r\n for j in range(1, n + 1):\r\n ans[i][j] = ans[i - 1][j - 1] + ans[i - 1][j]\r\n return ans\r\n\r\n\r\ndef solution():\r\n n, m, t = [int(num) for num in input().split()]\r\n pt = pascal_triangle(30)\r\n ans = 0\r\n for j in range(1, m + 1):\r\n i = t - j\r\n if 4 <= i <= n:\r\n ans += pt[m][j] * pt[n][i]\r\n print(ans)\r\n\r\n\r\ndef main():\r\n t = 1\r\n while t:\r\n solution()\r\n t -= 1\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "# /**\r\n# * author: brownfox2k6\r\n# * created: 27/08/2023 14:46:26 Hanoi, Vietnam\r\n# **/\r\n\r\nfrom math import comb\r\n\r\nboys, girls, n = map(int, input().split())\r\nans = 0\r\nfor b in range(4, n):\r\n ans += comb(boys, b) * comb(girls, n-b)\r\nprint(ans)", "from math import comb\r\n\r\nn, m, t = map(int, input().split())\r\n\r\npossibilidades = 0\r\nfor i in range(4, t):\r\n qt_meninos = i\r\n qt_meninas = t - i\r\n possibilidades += comb(n, qt_meninos) * comb(m, qt_meninas)\r\n\r\nprint(possibilidades)\r\n", "def comp_num(n, m):\r\n nume = 1\r\n domi = 1\r\n for i in range(1, m+1):\r\n nume *= n + 1 - i\r\n domi *= i\r\n return int(nume/domi)\r\n\r\ndef main():\r\n l = [int(i) for i in input().split(' ')]\r\n n, m, t = l[0], l[1], l[2]\r\n methods = 0\r\n for boys in range(4, min(t, n+1)):\r\n girls = t - boys\r\n methods += comp_num(n, boys) * comp_num(m, girls)\r\n print(methods)\r\n\r\nmain()\r\n", "from math import comb\n\nn, m, t = map(int, input().split())\nresult = 0\nfor i in range(4, t):\n result += comb(n, i) * comb(m, t - i)\n\nprint(result)\n \t \t \t \t\t\t\t\t \t\t\t\t", "import math\n\ndef C(n, m):\n result = 1\n for i in range(m):\n result *= (n - i)\n result //= (i + 1)\n return result\n\nn, m, t = map(int, input().split())\n\nways = 0\nfor i in range(4, t):\n ways += C(n, i) * C(m, t - i)\nprint(ways)\n\n \t \t\t\t\t\t \t \t \t\t\t \t \t \t\t", "import math \nf = math.factorial\n\ndef comb(n, r):\n return f(n) // (f(r) * f(n - r))\n\nn, m, t = map(int, input().split())\nans = 0\nfor i in range(4, n + 1):\n if t - i < 1: break\n if t - i > m: continue\n ans += comb(n, i) * comb(m, t - i)\n\nprint(ans)\n\n\t \t \t \t\t \t \t\t\t \t\t\t \t \t", "from math import comb\n\nn, m, t = map(int, input().split())\n\npossibilidades = 0\nfor i in range(4, t):\n qt_meninos = i\n qt_meninas = t - i\n possibilidades += comb(n, qt_meninos) * comb(m, qt_meninas)\n\nprint(possibilidades)\n\n\t\t \t \t\t \t\t\t \t \t\t \t \t \t", "import math\r\nn, m, t = map(int, input().split())\r\nans = 0\r\nfor i in range(4, t):\r\n ans += math.comb(n, i) * math.comb(m, t-i)\r\nprint(ans)\r\n", "import math\r\n\r\n \r\n\r\n\r\nn, m, t = map(int, input().split())\r\nb = 4\r\ng = t - b\r\nans = 0\r\n\r\nwhile g >= 1:\r\n ans += math.comb(n, b) * math.comb(m, g) \r\n b+=1\r\n g-=1\r\n \r\n\r\nprint(int(ans))\r\n ", "from math import comb\r\nc = 0\r\nn, m, t = map(int, input().split())\r\nfor i in range(4, t):\r\n c += comb(n, i)*comb(m, t-i)\r\nprint(c)" ]
{"inputs": ["5 2 5", "4 3 5", "4 1 5", "7 3 6", "30 30 30", "10 10 8", "10 10 10", "10 10 20", "20 15 27", "20 20 40", "20 20 24", "4 20 20", "4 20 24", "20 3 23", "20 1 21", "20 1 5", "20 20 5", "30 30 60", "30 30 59", "30 29 55", "30 29 59", "4 30 34", "30 1 20", "30 1 31", "29 30 57", "25 30 40", "4 2 6", "5 1 6", "30 30 50", "30 30 57", "30 30 58", "25 25 48", "30 1 30", "28 28 50", "28 28 55", "30 30 55", "7 30 37", "10 1 11", "10 1 6"], "outputs": ["10", "3", "1", "168", "118264581548187697", "84990", "168229", "1", "23535820", "1", "62852101650", "4845", "1", "1", "1", "4845", "96900", "1", "60", "455126", "1", "1", "54627300", "1", "1711", "11899700525790", "1", "1", "75394027566", "34220", "1770", "1225", "30", "32468436", "56", "5461512", "1", "1", "252"]}
UNKNOWN
PYTHON3
CODEFORCES
18
e4b6188d84adf708fa66725c0ebe45c4
Fox Dividing Cheese
Two little greedy bears have found two pieces of cheese in the forest of weight *a* and *b* grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Little bears, wait a little, I want to make your pieces equal" "Come off it fox, how are you going to do that?", the curious bears asked. "It's easy", said the fox. "If the mass of a certain piece is divisible by two, then I can eat exactly a half of the piece. If the mass of a certain piece is divisible by three, then I can eat exactly two-thirds, and if the mass is divisible by five, then I can eat four-fifths. I'll eat a little here and there and make the pieces equal". The little bears realize that the fox's proposal contains a catch. But at the same time they realize that they can not make the two pieces equal themselves. So they agreed to her proposal, but on one condition: the fox should make the pieces equal as quickly as possible. Find the minimum number of operations the fox needs to make pieces equal. The first line contains two space-separated integers *a* and *b* (1<=≤<=*a*,<=*b*<=≤<=109). If the fox is lying to the little bears and it is impossible to make the pieces equal, print -1. Otherwise, print the required minimum number of operations. If the pieces of the cheese are initially equal, the required number is 0. Sample Input 15 20 14 8 6 6 Sample Output 3 -1 0
[ "a,b=list(map(int,input().split()))\r\nc=[2,3,5]\r\nfa=[0,0,0,0,0]\r\nfb=[0,0,0,0,0]\r\nfor k in c:\r\n while a%k==0:\r\n a=a//k\r\n fa[k-1]+=1\r\nfor l in c:\r\n while b%l==0:\r\n b=b//l\r\n fb[l-1]+=1\r\nif a!=b:\r\n print(-1)\r\nelse:\r\n ans=0\r\n for i in range(5):\r\n ans+=abs(fa[i]-fb[i])\r\n print(ans)", "\"\"\"\r\nTwo little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: \"Little bears, wait a little, I want to make your pieces equal\" \"Come off it fox, how are you going to do that?\", the curious bears asked. \"It's easy\", said the fox. \"If the mass of a certain piece is divisible by two, then I can eat exactly a half of the piece. If the mass of a certain piece is divisible by three, then I can eat exactly two-thirds, and if the mass is divisible by five, then I can eat four-fifths. I'll eat a little here and there and make the pieces equal\".\r\n\r\nThe little bears realize that the fox's proposal contains a catch. But at the same time they realize that they can not make the two pieces equal themselves. So they agreed to her proposal, but on one condition: the fox should make the pieces equal as quickly as possible. Find the minimum number of operations the fox needs to make pieces equal.\r\n\r\nInput\r\nThe first line contains two space-separated integers a and b (1 ≤ a, b ≤ 109).\r\n\r\nOutput\r\nIf the fox is lying to the little bears and it is impossible to make the pieces equal, print -1. Otherwise, print the required minimum number of operations. If the pieces of the cheese are initially equal, the required number is 0.\r\n\"\"\"\r\n\r\nfrom math import gcd\r\n\r\na, b = map(int, input().split())\r\n\r\nif a == b:\r\n print(0)\r\n exit()\r\n\r\nfinal_size = gcd(a, b)\r\nreduced_a = a / final_size\r\nreduced_b = b / final_size\r\noperations = 0\r\n\r\nwhile reduced_a != 1:\r\n if reduced_a % 2 == 0:\r\n reduced_a /= 2\r\n operations += 1\r\n elif reduced_a % 3 == 0:\r\n reduced_a /= 3\r\n operations += 1\r\n elif reduced_a % 5 == 0:\r\n reduced_a /= 5\r\n operations += 1\r\n else:\r\n print(-1)\r\n exit()\r\n\r\nwhile reduced_b != 1:\r\n if reduced_b % 2 == 0:\r\n reduced_b /= 2\r\n operations += 1\r\n elif reduced_b % 3 == 0:\r\n reduced_b /= 3\r\n operations += 1\r\n elif reduced_b % 5 == 0:\r\n reduced_b /= 5\r\n operations += 1\r\n else:\r\n print(-1)\r\n exit()\r\n\r\nprint(operations)\r\n", "import sys\ninp = sys.stdin.readline().replace(\"\\n\",\"\").split()\na = int(inp[0])\nb = int(inp[1])\na_div = [0 for i in range(4)]\nb_div = [0 for i in range(4)]\ncounter = 0\nif a == b:\n print(0)\n sys.exit()\nwhile a%2 == 0:\n a = a//2\n a_div[0] += 1\nwhile a%3 == 0:\n a = a//3\n a_div[1] += 1\nwhile a%5 == 0:\n a = a//5\n a_div[2] += 1\nwhile b%2 == 0:\n b = b//2\n b_div[0] += 1\nwhile b%3 == 0:\n b = b//3\n b_div[1] += 1\nwhile b%5 == 0:\n b = b//5\n b_div[2] += 1\nif a != b:\n print(-1)\n sys.exit()\nfor i in range(0, 3):\n counter += abs(a_div[i]-b_div[i])\nprint(counter)\n \t \t\t\t\t \t \t \t \t \t", "def rpm(n):\r\n output={2:0, 3:0, 5:0, 10:0}\r\n for i in [2, 3, 5]:\r\n op=0\r\n while n%i==0:\r\n n//=i\r\n op+=1\r\n output[i]=op\r\n output[10]=n\r\n return output\r\nA, B=map(rpm, map(int, input().split()))\r\nif A[10]!=B[10]:\r\n print(-1)\r\nelse:\r\n print(max(A[2],B[2])-min(A[2],B[2])+max(A[3],B[3])-min(A[3],B[3])+max(A[5],B[5])-min(A[5],B[5]))\r\n", "from sys import stdin, stdout\r\na, b = map(int, stdin.readline().split())\r\nans = 0\r\ntwos = 0\r\nwhile a % 2 == 0:\r\n a = a//2\r\n twos +=1\r\nwhile b % 2 == 0:\r\n b = b//2\r\n twos -=1\r\nthrees = 0\r\nwhile a % 3 == 0:\r\n a = a//3\r\n threes +=1\r\nwhile b % 3 == 0:\r\n b = b//3\r\n threes -=1\r\nfives = 0\r\nwhile a % 5 == 0:\r\n a = a//5\r\n fives +=1\r\nwhile b % 5 == 0:\r\n b = b//5\r\n fives -=1\r\nif a != b:\r\n stdout.write(\"-1\")\r\nelse:\r\n stdout.write(str(abs(twos) + abs(threes) + abs(fives)))", "from math import gcd,sqrt\r\nfrom collections import Counter\r\n\r\ndef prim(n):\r\n res=[]\r\n while n % 2 == 0:\r\n res.append(2)\r\n n = n / 2\r\n \r\n for i in range(3,int(sqrt(n))+1,2):\r\n \r\n while n % i== 0:\r\n res.append(int(i))\r\n n = n//i\r\n \r\n \r\n if n > 2:\r\n res.append(int(n))\r\n \r\n return res\r\n \r\na,b = map(int,input().split())\r\n\r\ngc = gcd(a,b)\r\nr1=prim(a//gc)\r\nr2=prim(b//gc)\r\nd1 = Counter(r1)\r\nd2 = Counter(r2)\r\n\r\nif d1[2]+d1[5]+d1[3]==len(r1) and d2[2]+d2[3]+d2[5]==len(r2):\r\n print(len(r1)+len(r2))\r\n \r\nelse:\r\n print(-1)", "import math\r\n\r\n\r\ndef factorize(x):\r\n factors = []\r\n y = 1\r\n for i in range(2, int(math.sqrt(x) + 1)):\r\n while x % i == 0:\r\n factors.append(i)\r\n x //= i\r\n if i not in [2, 3, 5]:\r\n y *= i\r\n\r\n if x != 1:\r\n factors.append(x)\r\n if x not in [2, 3, 5]:\r\n y *= x\r\n\r\n return factors, y\r\n\r\n\r\na, b = map(int, input().split())\r\n\r\nfactorsa, x = factorize(a)\r\nfactorsb, y = factorize(b)\r\n\r\nif x != y:\r\n print(-1)\r\nelse:\r\n print(abs(factorsa.count(2) - factorsb.count(2))\r\n + abs(factorsa.count(3) - factorsb.count(3))\r\n + abs(factorsa.count(5) - factorsb.count(5)))\r\n", "\r\n\r\nfrom collections import Counter\r\ndef solve(n):\r\n t = []\r\n while n % 2 == 0 :\r\n t.append(2)\r\n n//= 2\r\n \r\n i = 3 \r\n while i * i <= n :\r\n while n % i == 0 :\r\n t.append(i)\r\n n//= i\r\n i += 1\r\n\r\n if n > 2 :\r\n t.append(n)\r\n return t\r\n\r\na , b = map(int,input().split())\r\nif a == b :print(0);exit()\r\n\r\n#print(solve(a))\r\n#print(solve(b))\r\nr1 = Counter(solve(a))\r\nr2 = Counter(solve(b))\r\n#print(r1)\r\n#print(r2)\r\n\r\ncnt1 , cnt2 = 0 , 0\r\nflag = True\r\nfor i in r1.keys() :\r\n if i in r2.keys() and r1[i] != r2[i]:\r\n if (i % 2 == 0 or i % 3 == 0 or i % 5 == 0 ):\r\n cnt1 += abs(r1[i] - r2[i])\r\n else:\r\n flag = False\r\n break\r\n\r\n elif i not in r2.keys():\r\n if (i % 2 == 0 or i % 3 == 0 or i % 5 == 0 ):\r\n cnt1+= r1[i]\r\n else:\r\n flag = False\r\n break\r\n\r\nif flag == False:\r\n print('-1')\r\n exit(0)\r\n\r\nfor i in r2.keys() :\r\n if i not in r1.keys() :\r\n if (i % 2 == 0 or i % 3 == 0 or i % 5 == 0 ):\r\n cnt2 += r2[i]\r\n else:\r\n flag = False\r\n break\r\nif flag == False:\r\n print(-1)\r\n exit(0)\r\n\r\nprint(cnt1 + cnt2)\r\n\r\n\r\n", "a, b = map(int, input().split())\r\nif a==b:\r\n print(0)\r\nelse:\r\n s1 = 0\r\n s2 = 0\r\n s3 = 0\r\n while a%2==0:\r\n a//=2\r\n s1+=1\r\n while a%3==0:\r\n a//=3\r\n s2+=1\r\n while a%5==0:\r\n a//=5\r\n s3+=1 \r\n while b%2==0:\r\n b//=2\r\n s1-=1\r\n while b%3==0:\r\n b//=3\r\n s2-=1 \r\n while b%5==0:\r\n b//=5\r\n s3-=1\r\n if a!=b:\r\n print(-1)\r\n else:\r\n print(abs(s1)+abs(s2)+abs(s3))", "def gcd(a, b):\r\n while a > 0 and b > 0:\r\n if a >= b:\r\n a %= b\r\n else:\r\n b %= a\r\n return max(a, b)\r\n\r\ndef razl(n):\r\n res = []\r\n for i in range(2, int(n**(1/2)) + 1, 1):\r\n while n % i == 0:\r\n res.append(i)\r\n n //= i\r\n if n != 1:\r\n res.append(n)\r\n return res\r\n\r\ndef main():\r\n a, b = list(map(int, input().split()))\r\n target = gcd(a, b)\r\n target_r = razl(target)\r\n a_r = razl(a)\r\n b_r = razl(b)\r\n a_count = {i: 0 for i in a_r}\r\n b_count = {i: 0 for i in b_r}\r\n target_count = {i: 0 for i in target_r}\r\n a_count[2], a_count[3], a_count[5] = 0, 0, 0\r\n b_count[2], b_count[3], b_count[5] = 0, 0, 0\r\n target_count[2], target_count[3], target_count[5] = 0, 0, 0\r\n\r\n for i in a_r:\r\n a_count[i] += 1\r\n for i in b_r:\r\n b_count[i] += 1\r\n for i in target_r:\r\n target_count[i] += 1\r\n\r\n ans = 0\r\n for i in [2, 3, 5]:\r\n while a_count[i] > target_count[i]:\r\n ans += 1\r\n a //= i\r\n a_count[i] -= 1\r\n\r\n\r\n for i in [2, 3, 5]:\r\n while b_count[i] > target_count[i]:\r\n ans += 1\r\n b //= i\r\n b_count[i] -= 1\r\n\r\n if b == target and a == target:\r\n print(ans)\r\n else:\r\n print(-1)\r\n\r\nif __name__ == \"__main__\":\r\n main()", "\na, b = map(int, input().split())\ns = 0\n\ndef apply(d):\n global a, b, s \n\n u, v = 0, 0 \n\n while a % d == 0: \n a //= d \n u += 1 \n\n while b % d == 0: \n b //= d \n v += 1 \n\n s += abs(u - v) \n\n\napply(5)\napply(3)\napply(2)\n\nif a == b: \n print(s) \nelse:\n print(-1) \n\t\t \t\t\t \t \t \t \t\t\t \t \t\t\t\t\t", "a, b = [int(i) for i in input().split()]\r\n\r\nif a == b:\r\n print(0)\r\n exit(0)\r\narr1 = [0, 0, 0]\r\narr2 = [0, 0, 0]\r\n\r\nwhile a%2 == 0:\r\n arr1[0] += 1\r\n a /= 2\r\nwhile a%3 == 0:\r\n arr1[1] += 1\r\n a /= 3\r\nwhile a%5 == 0:\r\n arr1[2] += 1\r\n a /= 5\r\n\r\nwhile b%2 == 0:\r\n arr2[0] += 1\r\n b /= 2\r\nwhile b%3 == 0:\r\n arr2[1] += 1\r\n b /= 3\r\nwhile b%5 == 0:\r\n arr2[2] += 1\r\n b /= 5\r\n\r\nif a == b:\r\n print(abs(arr1[0] - arr2[0]) + abs(arr1[1] - arr2[1]) + abs(arr1[2] - arr2[2]))\r\nelse:\r\n print(-1)\r\n\r\n", "a,b=map(int,input().split())\r\ni=0\r\nfor j in[2,3,5]:\r\n while a%j==0and b%j==0:a//=j;b//=j\r\n while a%j==0:a//=j;i+=1\r\n while b%j==0:b//=j;i+=1\r\nprint(i if a==b else-1)", "a,b = list(map(int,input().split()))\r\nrema,remb = a,b\r\ncnta,cntb = {},{}\r\nfor i in [2,3,5]:\r\n cnta[i] = 0\r\n cntb[i] = 0\r\n while rema%i==0:\r\n rema = rema//i\r\n cnta[i]+=1\r\n while remb%i==0:\r\n remb = remb//i\r\n cntb[i]+=1\r\nif rema==remb:\r\n ans = 0\r\n for i in [2,3,5]:\r\n ans+=abs(cnta[i]-cntb[i])\r\n print(ans)\r\nelse:\r\n print(-1)", "def gcd(a,b):\r\n if a == 0:\r\n return b\r\n return gcd(b % a, a)\r\n\r\ndef main():\r\n x,y=map(int,input().split(' '))\r\n eq = gcd(x,y)\r\n a,b=int(x/eq),int(y/eq)\r\n ans=0\r\n while True:\r\n if a%2==0:\r\n a=int(a/2)\r\n ans+=1\r\n if a%3==0:\r\n a = int(a/3)\r\n ans+=1\r\n if a%5==0:\r\n a=int(a/5)\r\n ans+=1\r\n if a%2!=0 and a%3!=0 and a%5!=0:\r\n if a!=1:\r\n print(-1)\r\n exit()\r\n if a==1:\r\n break\r\n while True:\r\n if b%2==0:\r\n b=int(b/2)\r\n ans+=1\r\n if b%3==0:\r\n b=int(b/3)\r\n ans+=1\r\n if b%5==0:\r\n b=int(b/5)\r\n ans+=1\r\n if b%2!=0 and b%3!=0 and b%5!=0:\r\n if b!=1:\r\n print(-1)\r\n exit()\r\n if b==1:\r\n break\r\n print(ans)\r\n\r\n\r\nmain()\r\n", "a, b = map(int, input().split())\r\nif a != b:\r\n opr2 = opr3 = opr5 = 0\r\n\r\n while a % 2 == 0:\r\n a //= 2\r\n opr2 += 1\r\n while a % 3 == 0:\r\n a //= 3\r\n opr3 += 1\r\n while a % 5 == 0:\r\n a //= 5\r\n opr5 += 1\r\n\r\n while b % 2 == 0:\r\n b //= 2\r\n opr2 -= 1\r\n while b % 3 == 0:\r\n b //= 3\r\n opr3 -= 1\r\n while b % 5 == 0:\r\n b //= 5\r\n opr5 -= 1\r\n\r\n if a == b:\r\n print(abs(opr2) + abs(opr3) + abs(opr5))\r\n else:\r\n print(-1)\r\n\r\nelse:\r\n print(0)", "import math\ndef solucion(a,b):\n a2,a3,a5,b2,b3,b5 = 0,0,0,0,0,0\n while a%2 == 0:\n a/=2\n a2+=1\n while a%3 == 0:\n a/=3\n a3+=1\n while a%5 == 0:\n a/=5\n a5+=1\n while b%2 == 0:\n b/=2\n b2+=1\n while b%3 == 0:\n b/=3\n b3+=1\n while b%5 == 0:\n b/=5\n b5+=1\n if(a != b):\n return -1\n else:\n return abs(a2-b2) + abs(a3-b3) + abs(a5-b5)\na,b = map(int, input().split())\nprint(solucion(a,b))\n \t\t \t \t\t \t\t\t \t\t\t \t \t", "import sys;import copy;\r\nimport math;\r\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\r\ndef get_array(): return list(map(int, sys.stdin.readline().strip().split()))\r\ndef get_string(): return sys.stdin.readline().strip()\r\n \r\n#t = int(input());\r\nt=1;\r\nfor test in range(t):\r\n a,b = get_ints();\r\n a2=0;a3=0;a5=0;\r\n b2=0;b3=0;b5=0;\r\n while(a%2==0):\r\n a2+=1;\r\n a=a//2;\r\n while(a%3==0):\r\n a3+=1;\r\n a=a//3;\r\n while(a%5==0):\r\n a5+=1;\r\n a=a//5;\r\n while(b%2==0):\r\n b2+=1;\r\n b=b//2;\r\n while(b%3==0):\r\n b3+=1;\r\n b=b//3;\r\n while(b%5==0):\r\n b5+=1;\r\n b=b//5;\r\n if(a!=b):\r\n print(-1);\r\n continue;\r\n else:\r\n print(abs(a2-b2)+abs(b3-a3)+abs(a5-b5));\r\n \r\n", "import sys\nentrada = input()\narreglo = entrada.split()\na = int(arreglo[0])\nb = int(arreglo[1])\noperaciones = 0\n\nif(a == b):\n print(0)\n sys.exit()\n\narreg_a = [0,0,0,0]\narreg_b = [0,0,0,0]\n\nwhile(a % 2 == 0):\n a /= 2\n arreg_a[0] += 1\nwhile(a % 3 == 0):\n a /= 3\n arreg_a[1] += 1\nwhile(a % 5 == 0):\n a /= 5\n arreg_a[2] += 1\nwhile(b % 2 == 0):\n b /= 2\n arreg_b[0] += 1\nwhile(b % 3 == 0):\n b /= 3\n arreg_b[1] += 1\nwhile(b % 5 == 0):\n b /= 5\n arreg_b[2] += 1\n\nif(a!=b):\n print(-1) \nelse:\n for i in range(3):\n operaciones += abs(arreg_a[i] - arreg_b[i])\n print(operaciones)\n\t \t\t\t \t \t \t \t \t\t \t", "import math\r\n\r\n\r\ndef prime_factors(n):\r\n global arr\r\n while n % 2 == 0:\r\n arr.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 arr.append(i)\r\n n = n // i\r\n if n > 2:\r\n arr.append(n)\r\n\r\n\r\na, b = list(map(int, input().split()))\r\na1 = 0\r\na2 = 0\r\nb1 = 0\r\nb2 = 0\r\nc1 = 0\r\nc2 = 0\r\nif a == b:\r\n print(0)\r\n exit()\r\narr = []\r\nprime_factors(a)\r\ns1 = len(arr)\r\n#print(arr)\r\nif 2 in arr:\r\n a1 = arr.count(2)\r\nif 3 in arr:\r\n b1 = arr.count(3)\r\nif 5 in arr:\r\n c1 = arr.count(5)\r\narr = map(str, arr)\r\nwonder1 = ''.join(arr)\r\nwonder1 = wonder1.replace('2', '')\r\nwonder1 = wonder1.replace('3', '')\r\nwonder1 = wonder1.replace('5', '')\r\nwonder1 = list(wonder1)\r\narr = []\r\nprime_factors(b)\r\ns2 = len(arr)\r\nif 2 in arr:\r\n a2 = arr.count(2)\r\nif 3 in arr:\r\n b2 = arr.count(3)\r\nif 5 in arr:\r\n c2 = arr.count(5)\r\narr = map(str, arr)\r\nwonder2 = ''.join(arr)\r\nwonder2 = wonder2.replace('2', '')\r\nwonder2 = wonder2.replace('3', '')\r\nwonder2 = wonder2.replace('5', '')\r\nwonder2 = list(wonder2)\r\nif wonder1 == wonder2:\r\n print(abs(a1 - a2) + abs(b2 - b1) + abs(c2 - c1))\r\nelse:\r\n print(-1)", "import math\ndef find_fac_2_3_5(n) :\n pow_2=0\n pow_3=0\n pow_5=0\n #print(n)\n while n%2==0 :\n n=n//2\n pow_2+=1\n while n%3==0 :\n n=n//3\n pow_3+=1\n while n%5==0 :\n n=n//5\n pow_5+=1\n \n \n return pow_2,pow_3,pow_5,n\n \na,b=input().split(\" \")\na=int(a)\nb=int(b)\nk=math.gcd(a,b)\nq1,q2,q3,n1=find_fac_2_3_5(a)\ne1,e2,e3,n2=find_fac_2_3_5(b)\n\nif a==b :\n print(\"0\")\nelse :\n if n1==n2 :\n k=math.gcd(a//n1,b//n2)\n w1=a//n1\n w2=b//n2\n x1,x2,x3,t=find_fac_2_3_5(w1//k)\n y1,y2,y3,j=find_fac_2_3_5(w2//k)\n print(x1+x2+x3+y1+y2+y3)\n\n else :\n print(\"-1\")\n\n\n\n\n \n\n\n\n\n\n ", "import math\n\nclass PrimeFactorization:\n def __init__(self):\n self.qq = 0 \n self.q2 = 0 \n self.q3 = 0 \n self.q5 = 0 \n\ndef get_prime_factorization(n):\n factorization = PrimeFactorization()\n\n while n % 2 == 0:\n factorization.q2 += 1\n n //= 2\n while n % 3 == 0:\n factorization.q3 += 1\n n //= 3\n while n % 5 == 0:\n factorization.q5 += 1\n n //= 5\n factorization.qq = n\n return factorization\n\na, b = map(int, input().split())\n\nfactorization_a = get_prime_factorization(a)\nfactorization_b = get_prime_factorization(b)\n\nif factorization_a.qq != factorization_b.qq:\n print(\"-1\") \nelse:\n distance = abs(factorization_a.q2 - factorization_b.q2) + \\\n abs(factorization_a.q3 - factorization_b.q3) + \\\n abs(factorization_a.q5 - factorization_b.q5)\n print(distance)\n\t \t\t \t \t\t\t\t \t\t\t\t \t \t\t \t", "divide = [2,3,5]\r\n\r\ndef minEats(a, b):\r\n eats = 0\r\n for d in divide:\r\n aCount = 0; bCount = 0\r\n while a%d == 0:\r\n a//=d\r\n aCount += 1\r\n while b%d == 0:\r\n b//=d\r\n bCount += 1\r\n eats += abs(aCount-bCount)\r\n\r\n if a == b:\r\n return eats\r\n return -1\r\n\r\na,b = list(map(int, input().split(' ')))\r\nprint(minEats(a, b))\r\n", "#dividing by 2 and 3 and 5 maeans subtracrting the powers\r\na,b=map(int,input().split())\r\ncnt_a2,cnt_a3,cnt_a5=0,0,0\r\ncnt_b2,cnt_b3,cnt_b5=0,0,0\r\nans=0\r\nwhile True:\r\n while a>0 and a%2==0:\r\n a=a//2;cnt_a2+=1\r\n while a>0 and a%3==0:\r\n a=a//3;cnt_a3+=1\r\n while a>0 and a%5==0:\r\n a=a//5;cnt_a5+=1\r\n while b>0 and b%2==0:\r\n b=b//2;cnt_b2+=1\r\n while b>0 and b%3==0:\r\n b=b//3;cnt_b3+=1\r\n while b>0 and b%5==0:\r\n b=b//5;cnt_b5+=1\r\n if a!=b:print(-1);exit()\r\n else:\r\n ans+=abs(cnt_a2-cnt_b2)+abs(cnt_a3-cnt_b3)+abs(cnt_a5-cnt_b5);exit(print(ans))\r\n", "def divideEqual(a, b):\n pax, pay, paz, pbx, pby, pbz = 0, 0, 0, 0, 0, 0\n\n while a % 2 == 0:\n a = a // 2\n pax += 1\n\n while a % 3 == 0:\n a = a // 3\n pay += 1\n\n while a % 5 == 0:\n a = a // 5\n paz += 1\n\n while b % 2 == 0:\n b = b // 2\n pbx += 1\n\n while b % 3 == 0:\n b = b // 3\n pby += 1\n\n while b % 5 == 0:\n b = b // 5\n pbz += 1\n\n if a != b:\n return -1\n else:\n return abs(pax - pbx) + abs(pay - pby) + abs(paz - pbz)\n\n# Ejemplo de uso de la función:\na, b = map(int, input().split())\nresult = divideEqual(a, b)\nprint(result)\n\n\t \t\t\t \t \t\t\t\t \t\t\t\t \t", "import sys,math,io,os,time,itertools,collections\r\nmod=10**9+7\r\nsys.setrecursionlimit(10000)\r\ni=sys.stdin.readline\r\np=sys.stdout.write\r\n#use sys.stdout.write() (remember to convert to str b4 and concatenate \"\\n\")\r\nglobal start,end\r\n\r\ndef primefac(n):\r\n two,three,five=0,0,0\r\n while n%2==0:\r\n two+=1\r\n n=n//2\r\n while n%3==0:\r\n three+=1\r\n n=n//3\r\n while n%5==0:\r\n five+=1\r\n n=n//5\r\n return [two,three,five,n]\r\n\r\ndef main():\r\n a,b=[int(k) for k in i().split()]\r\n la=primefac(a)\r\n lb=primefac(b)\r\n if la[3]!=lb[3]:\r\n p(\"-1\\n\")\r\n else:\r\n ans=abs(la[0]-lb[0])+abs(la[1]-lb[1])+abs(la[2]-lb[2])\r\n p(str(ans)+\"\\n\")\r\n\r\nt=1\r\n#t=int(i())\r\nstart=time.perf_counter()\r\nfor _ in range(t):\r\n main()\r\nend=time.perf_counter()\r\n#print(end-start)", "a, b = map(int, input().split())\r\np, q = a, b\r\naa = [0, 0, 0]\r\nbb = [0, 0, 0]\r\nflag, flags = 0, 0\r\nwhile True:\r\n flag = 0\r\n if (a == 1):\r\n flag = 2\r\n break\r\n if (a % 2 == 0):\r\n aa[0] += 1\r\n a //= 2\r\n flag = 1\r\n elif (a % 3 == 0):\r\n aa[1] += 1\r\n a //= 3\r\n flag = 1\r\n elif (a % 5 == 0):\r\n aa[2] += 1\r\n a //= 5\r\n flag = 1\r\n if (flag == 0):\r\n flag = 3\r\n break\r\nwhile True:\r\n flags = 0\r\n if (b == 1):\r\n flags = 22\r\n break\r\n if (b % 2 == 0):\r\n bb[0] += 1\r\n b //= 2\r\n flags = 1\r\n elif (b % 3 == 0):\r\n bb[1] += 1\r\n b //= 3\r\n flags = 1\r\n elif (b % 5 == 0):\r\n bb[2] += 1\r\n b //= 5\r\n flags = 1\r\n if (flags == 0):\r\n flags = 33\r\n break\r\n\r\nif (p == q):\r\n print(0)\r\nelif (a==b):\r\n print(max(aa[0], bb[0]) - min(aa[0], bb[0]) + max(aa[1], bb[1]) - min(aa[1], bb[1]) + max(aa[2], bb[2]) - min(aa[2],\r\n bb[\r\n 2]))\r\nelse:\r\n print(-1)", "def fac(n,l) : \r\n while n > 1 : \r\n cr = n\r\n if not n%5 : l.append(5); n //= 5\r\n if not n%3 : l.append(3); n //= 3\r\n if not n%2 : l.append(2); n//= 2\r\n if n == cr : break \r\n return n\r\ndef sol() : \r\n a,b = map(int,input().split()); from math import gcd; g = gcd(a,b); af = a//g; bf = b//g; l = list(); af = fac(af,l); bf = fac(bf,l); l = [i for i in l if i!=1]\r\n if af==1 and bf==1 :print(len(l))\r\n else : print(-1)\r\nsol()", "a, b = map(int, input().split())\r\nsol = 0\r\n\r\n\r\ndef apply(d):\r\n global a, b, sol\r\n\r\n u, v = 0, 0\r\n\r\n while a % d == 0:\r\n a //= d\r\n u += 1\r\n\r\n while b % d == 0:\r\n b //= d\r\n v += 1\r\n\r\n sol += abs(u - v)\r\n\r\n\r\napply(5)\r\napply(3)\r\napply(2)\r\n\r\nif a == b:\r\n print(sol)\r\nelse:\r\n print(-1)\r\n\r\n", "def div(a, i):\r\n re = 0\r\n while a % i == 0:\r\n a //= i\r\n re += 1\r\n return re\r\n\r\n\r\na, b = map(int, input().split())\r\na2 = div(a, 2)\r\na3 = div(a, 3)\r\na5 = div(a, 5)\r\nx = a // pow(2, a2)\r\nx //= pow(3, a3)\r\nx //= pow(5, a5)\r\n\r\nb2 = div(b, 2)\r\nb3 = div(b, 3)\r\nb5 = div(b, 5)\r\ny = b // pow(2, b2)\r\ny //= pow(3, b3)\r\ny //= pow(5, b5)\r\n\r\nif x != y:\r\n print(-1)\r\nelse:\r\n print(abs(a2-b2) + abs(a3-b3) + abs(a5-b5))\r\n\r\n", "a, b = map(int, input().split())\n\ncount = 0\n\nprimes = [2, 3, 5]\n\ndef make_equal(x, y):\n cnt = 0\n for p in primes:\n while x % p == 0 and y % p == 0:\n x //= p\n y //= p\n while x % p == 0:\n x //= p\n cnt += 1\n while y % p == 0:\n y //= p\n cnt += 1\n if x != y:\n return -1\n return cnt\n\ncount = make_equal(a, b)\n\nprint(count)\n \t\t \t\t \t\t\t\t\t \t \t\t", "def min_operations_to_make_equal(a, b):\n operations = 0\n\n # Determine the prime factors and exponents for a and b\n factors = [2, 3, 5]\n for factor in factors:\n while a % factor == 0 and b % factor == 0:\n a //= factor\n b //= factor\n while a % factor == 0:\n a //= factor\n operations += 1\n while b % factor == 0:\n b //= factor\n operations += 1\n\n if a != b:\n return -1 \n\n return operations\n\n\na, b = map(int, input().split())\nif a == b:\n print(0)\n exit()\nresult = min_operations_to_make_equal(a, b)\nprint(result)\n\n\t \t\t\t\t\t \t \t\t \t \t\t \t", "import math\r\na, b = map(int, input().split())\r\n\r\nfactorisation = []\r\nc = 0\r\nwhile(a%2==0):\r\n c += 1\r\n a//=2\r\nfactorisation.append(c)\r\n\r\nc = 0\r\nwhile(b%2==0):\r\n c += 1\r\n b//=2\r\nfactorisation.append(c)\r\n\r\nc = 0\r\nwhile(a%3==0):\r\n c += 1\r\n a//=3\r\nfactorisation.append(c)\r\n\r\nc = 0\r\nwhile(b%3==0):\r\n c += 1\r\n b//=3\r\nfactorisation.append(c)\r\n\r\nc = 0\r\nwhile(a%5==0):\r\n c += 1\r\n a//=5\r\nfactorisation.append(c)\r\n\r\nc = 0\r\nwhile(b%5==0):\r\n c += 1\r\n b//=5\r\nfactorisation.append(c)\r\n\r\nans = abs(factorisation[1] - factorisation[0]) + abs(factorisation[3] - factorisation[2]) + abs(factorisation[4] - factorisation[5])\r\n\r\nif a!= b:\r\n print(-1)\r\nelse:\r\n print(ans)\r\n", "a,b=map(int,input().split())\r\nfirst,second=[a],[b]\r\ndict_a,dict_b={i:[] for i in range(31)},{i:[] for i in range(31)}\r\ndict_a[0].append(a)\r\ndict_b[0].append(b)\r\nfor i in first:\r\n if i%2==0:\r\n if i//2 not in first:\r\n first.append(i//2)\r\n for c in dict_a:\r\n if i in dict_a[c]:\r\n dict_a[c+1].append(i//2)\r\n break\r\n if i%3==0:\r\n if i // 3 not in first:\r\n first.append(i//3)\r\n for c in dict_a:\r\n if i in dict_a[c]:\r\n dict_a[c+1].append(i//3)\r\n break\r\n if i%5==0:\r\n if i//5not in first:\r\n first.append(i//5)\r\n for c in dict_a:\r\n if i in dict_a[c]:\r\n dict_a[c+1].append(i//5)\r\n break\r\nfor i in second:\r\n if i%2==0:\r\n if i // 2 not in second:\r\n second.append(i//2)\r\n for c in dict_b:\r\n if i in dict_b[c]:\r\n dict_b[c + 1].append(i // 2)\r\n break\r\n if i%3==0:\r\n if i // 3 not in second:\r\n second.append(i//3)\r\n for c in dict_b:\r\n if i in dict_b[c]:\r\n dict_b[c + 1].append(i // 3)\r\n break\r\n if i%5==0:\r\n if i // 5 not in second:\r\n second.append(i//5)\r\n for c in dict_b:\r\n if i in dict_b[c]:\r\n dict_b[c + 1].append(i // 5)\r\n break\r\nf,s=set(first),set(second)\r\ng=f.intersection(s)\r\nif g:\r\n res=1000\r\n for c in g:\r\n m=0\r\n for i in dict_a:\r\n if c in dict_a[i]:\r\n m+=i\r\n break\r\n for i in dict_b:\r\n if c in dict_b[i]:\r\n m+=i\r\n break\r\n res=min(res,m)\r\n print(res)\r\nelse:\r\n print(\"-1\")\r\n", "# Python program to print prime factors\r\n\r\nimport math\r\n\r\ndef primeFactors(n):\r\n factors = []\r\n while n % 2 == 0:\r\n factors.append(2)\r\n n = n / 2\r\n\r\n for i in range(3, int(math.sqrt(n)) + 1, 2):\r\n while n % i == 0:\r\n factors.append(i)\r\n n = n / i\r\n\r\n if n > 2:\r\n factors.append(int(n))\r\n return factors\r\n\r\ndef difference(li1, li2):\r\n dif = [i for i in li1 + li2 if i not in li1 or i not in li2]\r\n return dif\r\n\r\na, b = map(int, input().split())\r\nl1 = primeFactors(a)\r\nl2 = primeFactors(b)\r\nl1_counts=[0]*3\r\nl2_counts=[0]*3\r\nfor i in l1:\r\n if i==2: l1_counts[0]+=1\r\n elif i==3: l1_counts[1]+=1\r\n elif i==5: l1_counts[2]+=1\r\nfor i in l2:\r\n if i==2: l2_counts[0]+=1\r\n elif i==3: l2_counts[1]+=1\r\n elif i==5: l2_counts[2]+=1\r\n\r\n#print(l1)\r\n#print(l2)\r\nx = difference(l1,l2)\r\n#print(x)\r\nfor i in x:\r\n if i > 5:\r\n print(-1)\r\n exit(0)\r\n\r\nanswer = abs(l1_counts[0] - l2_counts[0]) + abs(l1_counts[1] - l2_counts[1]) + abs(l1_counts[2] - l2_counts[2])\r\nprint(answer)", "[a, b]=list(map(int, input().split()))\r\nif(a==b):\r\n print(0)\r\nelse:\r\n a2, a3, a5, b2, b3, b5 = 0, 0, 0, 0, 0, 0\r\n while(a%2==0):\r\n a2+=1\r\n a//=2\r\n while(a%3==0):\r\n a3+=1\r\n a//=3\r\n while(a%5==0):\r\n a5+=1\r\n a//=5\r\n while(b%2==0):\r\n b2+=1\r\n b//=2\r\n while(b%3==0):\r\n b3+=1\r\n b//=3\r\n while(b%5==0):\r\n b5+=1\r\n b//=5\r\n if(a==b):\r\n print(abs(a2-b2)+abs(a3-b3)+abs(a5-b5))\r\n else:\r\n print(-1)\r\n ", "from sys import stdin\r\nstdin.readline\r\ndef mp(): return list(map(int, stdin.readline().strip().split()))\r\ndef it():return int(stdin.readline().strip())\r\nfrom math import pi,sqrt\r\nfrom collections import defaultdict as dd,ChainMap as cc\r\n\r\ndef pf(n):\r\n\tv=[]\r\n\td=dd(lambda:0)\r\n\twhile n%2==0:\r\n\t\tn//=2\r\n\t\td[2]+=1\r\n\r\n\tfor j in range(3,int(sqrt(n))+1):\r\n\t\tif n%j==0:\r\n\t\t\twhile n%j==0:\r\n\t\t\t\tn//=j\r\n\t\t\t\td[j]+=1\r\n\tif n>2:\r\n\t\td[n]+=1\r\n\r\n\treturn d\r\n\r\nn,m=mp()\r\nif n==m:\r\n\tprint(0)\r\nelse:\r\n\ta=pf(n)\r\n\tb=pf(m)\r\n\tc=cc(dict(a),dict(b))\r\n\tans=flag=0\r\n\r\n\tfor i in c:\r\n\t\tif i==2:\r\n\t\t\tans+=abs(a[i]-b[i])\r\n\t\telif i==3:\r\n\t\t\tans+=abs(a[i]-b[i])\r\n\t\telif i==5:\r\n\t\t\tans+=abs(a[i]-b[i])\r\n\t\telse:\r\n\t\t\tif a[i]!=b[i]:\r\n\t\t\t\tflag=1\r\n\t\t\t\tbreak\r\n\r\n\tif flag:\r\n\t\tprint(-1)\r\n\telse:\r\n\t\tprint(ans)\r\n\r\n\r\n\r\n", "def five(x):\r\n c=0\r\n while x%5==0:\r\n c+=1\r\n x=x//5\r\n return c\r\ndef two(x):\r\n c=0\r\n while x%2==0:\r\n c+=1\r\n x=x//2\r\n return c\r\ndef three(x):\r\n c=0\r\n while x%3==0:\r\n c+=1\r\n x=x//3\r\n return c\r\n\r\na,b=map(int,input().split())\r\nif a==b:\r\n print(0)\r\nelse:\r\n a1=a//(2**two(a)*3**three(a)*5**five(a))\r\n b1=b//(2**two(b)*3**three(b)*5**five(b))\r\n if a1!=b1:\r\n print(-1)\r\n else:\r\n p=abs(two(a)-two(b))+abs(three(a)-three(b))+abs(five(a)-five(b))\r\n print(p)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "a, b = map(int, (input().split()))\n\ndef gcd(big, small):\n while big % small:\n tmp = big % small\n big = small\n small = tmp\n return small\n\n\nv = gcd(a, b)\nans = 0\n\na //= v\nb //= v\nwhile a != 1:\n if a % 5 == 0:\n ans += 1\n a //= 5\n elif a % 3 == 0:\n ans += 1\n a //= 3\n elif a % 2 == 0:\n ans += 1\n a //= 2\n else:\n print(-1)\n quit()\n\nwhile b != 1:\n if b % 5 == 0:\n ans += 1\n b //= 5\n elif b % 3 == 0:\n ans += 1\n b //= 3\n elif b % 2 == 0:\n ans += 1\n b //= 2\n else:\n print(-1)\n quit()\n\nprint(ans)", "import sys\r\nimport math\r\nimport collections\r\nimport bisect\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\nfor t in range(1):\r\n a,b=get_ints()\r\n two=0\r\n three=0\r\n five=0\r\n while a%2==0:\r\n a=a//2\r\n two+=1\r\n while a%3==0:\r\n a=a//3\r\n three+=1\r\n while a%5==0:\r\n a=a//5\r\n five+=1\r\n while b%2==0:\r\n b=b//2\r\n two-=1\r\n while b%3==0:\r\n b=b//3\r\n three-=1\r\n while b%5==0:\r\n b=b//5\r\n five-=1\r\n if a==b:\r\n print(abs(two)+abs(three)+abs(five))\r\n else:\r\n print(-1)", "def line2int(linea):\n temp = \"\"\n for i in linea:\n if i == \" \":\n if temp != \"\":\n val1 = int(temp)\n temp = \"\"\n else:\n temp = temp + i\n val2 = int(temp)\n return (val1,val2)\n\n(a,b) = line2int(input())\nnum2a = num2b = 0\nnum3a = num3b = 0\nnum5a = num5b = 0\nwhile a%2==0:\n a = int(a/2)\n num2a = num2a + 1\nwhile a%3==0:\n a = int(a/3)\n num3a = num3a + 1\nwhile a%5==0:\n a = int(a/5)\n num5a = num5a + 1\nwhile b%2==0:\n b = int(b/2)\n num2b = num2b + 1\nwhile b%3==0:\n b = int(b/3)\n num3b = num3b + 1\nwhile b%5==0:\n b = int(b/5)\n num5b = num5b + 1\nif a==b: print(abs(num2a-num2b)+abs(num3a-num3b)+abs(num5a-num5b))\nelse: print(-1)\n\t \t\t\t\t\t\t \t\t \t\t\t\t \t\t\t \t\t\t \t\t\t \t\t", "a, b = map(int, input().split())\r\nans = 0 # счётчик\r\n\r\n\r\nfor i in (2, 3, 5):\r\n while a % i == 0 and b % i == 0:\r\n a /= i\r\n b /= i\r\n while a % i == 0:\r\n a /= i\r\n ans += 1\r\n while b % i == 0:\r\n b /= i\r\n ans += 1\r\n\r\nif a == b:\r\n print(ans)\r\nelse:\r\n print(-1)", "def gcd(a, b):\r\n while a != 0 and b != 0:\r\n if a > b:\r\n a = a % b\r\n else:\r\n b = b % a\r\n \r\n return a + b\r\na, b = map(int, input().split())\r\nA = a // gcd(a, b)\r\nB = b // gcd(a, b)\r\ncnt = 0\r\nwhile A % 5 == 0:\r\n A = A // 5\r\n cnt += 1\r\nwhile A % 3 == 0:\r\n A = A // 3\r\n cnt += 1\r\nwhile A % 2 == 0:\r\n A = A // 2\r\n cnt += 1\r\nwhile B % 5 == 0:\r\n B = B // 5\r\n cnt += 1\r\nwhile B % 3 == 0:\r\n B = B // 3\r\n cnt += 1\r\nwhile B % 2 == 0:\r\n B = B // 2\r\n cnt += 1\r\nif B == 1 and A == 1:\r\n print(cnt)\r\nelse:\r\n print(-1)", "import sys\r\n\r\ninput = lambda: sys.stdin.readline().strip(\"\\r\\n\")\r\n\r\na, b = map(int, input().split())\r\nx, y, z = 0, 0, 0\r\nwhile a % 2 == 0:\r\n a //= 2\r\n x += 1\r\nwhile a % 3 == 0:\r\n a //= 3\r\n y += 1\r\nwhile a % 5 == 0:\r\n a //= 5\r\n z += 1\r\nwhile b % 2 == 0:\r\n b //= 2\r\n x -= 1\r\nwhile b % 3 == 0:\r\n b //= 3\r\n y -= 1\r\nwhile b % 5 == 0:\r\n b //= 5\r\n z -= 1\r\nif a != b:\r\n print(-1)\r\nelse:\r\n print(abs(x) + abs(y) + abs(z))\r\n", "import math\r\n\r\nans = 0\r\nn, m = map(int, input().split())\r\ngcd = math.gcd(n, m)\r\nn /= gcd\r\nm /= gcd\r\n\r\ndivisors = [2, 3, 5]\r\n\r\nfor divisor in divisors:\r\n while n % divisor == 0:\r\n n /= divisor\r\n ans += 1\r\n while m % divisor == 0:\r\n m /= divisor\r\n ans += 1\r\n\r\nif n != 1 or m != 1:\r\n print(-1)\r\nelse: print(ans)", "a,b=map(int,input().split())\r\nc=0\r\nfor i in (2,3,5):\r\n while a%i ==0 and b%i==0:\r\n a//=i\r\n b//=i\r\n while a%i==0:\r\n a//=i\r\n c+=1\r\n while b%i==0:\r\n b//=i\r\n c+=1\r\nprint(c) if a==b else print(-1)", "a, b = map(int, input().split())\r\na_fact, b_fact = [], []\r\nwhile a % 2 == 0:\r\n a_fact.append(2)\r\n a //= 2\r\nwhile a % 3 == 0:\r\n a_fact.append(3)\r\n a //= 3\r\nwhile a % 5 == 0:\r\n a_fact.append(5)\r\n a //= 5\r\nwhile b % 2 == 0:\r\n b_fact.append(2)\r\n b //= 2\r\nwhile b % 3 == 0:\r\n b_fact.append(3)\r\n b //= 3\r\nwhile b % 5 == 0:\r\n b_fact.append(5)\r\n b //= 5\r\nif a != b:\r\n print(-1)\r\n exit(0)\r\nelse:\r\n ans = abs(a_fact.count(2) - b_fact.count(2)) + abs(a_fact.count(3) - b_fact.count(3)) + abs(a_fact.count(5) - b_fact.count(5))\r\n print(ans)", "from math import gcd, sqrt\r\nfrom math import log\r\nfrom os import path\r\n\r\ndef factorization235(n):\r\n c,result = 0,1\r\n while n % 2 == 0:\r\n n /= 2; c += 1;\r\n while n % 3 == 0:\r\n n /= 3; c += 1\r\n while n % 5 == 0:\r\n n /= 5; c += 1\r\n if n != 1: return -1\r\n return c\r\n\r\na,b = map(int,input().split(' '))\r\npath1,path2,div = 0,0,True\r\nif a == b: pass\r\nelse:\r\n target = gcd(a,b)\r\n path1 = a / target; path2 = b / target\r\n if path1 != 1:\r\n path1 = factorization235(path1)\r\n if path1 == -1: div = False\r\n else: path1 = 0\r\n if path2 != 1:\r\n path2 = factorization235(path2)\r\n if path2 == -1: div = False\r\n else: path2 = 0\r\nif div: print(int(path1 + path2))\r\nelse: print(-1)\r\n\r\n'''\r\n1 1024\r\nans:10\r\n\r\n\r\n36 30\r\nans:3\r\n\r\n20 8 GCD: 4\r\n4 4\r\nans:2\r\n\r\n20 15 GCD : 5\r\n10 5\r\n5 5\r\nans:3\r\n\r\nIf we want to reach the same number decreasing a and b by\r\ndivision we have to check for GCD(a,b). GCD because our goal is also \r\nto minimize the number of operations, so we target the first \r\ncommon number like that.\r\n\r\nIf we are confident that both numbers will meet each other\r\nat GCD and not earlier than we should just figure out the shortest \"div\" path\r\nfrom both numbers to GCD and sum it up.\r\nIf it's impossible to reach GCD with \r\nproblem div conditions from any num than return -1.\r\n\r\nIf we have GCD, we can divide a or b by it \r\nand check if we can the result of this operation \r\ndivide by 2,3,5 (something like that)\r\n[(a or b) / GCD(a,b)] / (2 or 3 or 5) = operations\r\nif [(a or b) / GCD(a,b)] % (2 or 3 or 5) != 0: -1\r\n\r\nIf the first quotient [(a or b) / GCD(a,b)] will\r\nbe simultaneously divisible by 2 or 3 numbers from {2,3,5}\r\nthen we are making a division by the largest number. \r\n\r\n'''", "import sys\r\ninput = sys.stdin.readline\r\n\r\n#Returns set prime factors O(sqrt(n))\r\nimport math\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\r\n for i in range(3, int(math.sqrt(n)) + 1, 2):\r\n while n % i == 0:\r\n l.append(i)\r\n n = n // i\r\n\r\n if n > 2:\r\n l.append(n)\r\n\r\n return l\r\n\r\na,b = map(int,input().split())\r\nz1 = primefactors(a)\r\nz2 = primefactors(b)\r\nr1 = {}\r\nr2 = {}\r\n\r\nfor i in z1:\r\n if i in r1:\r\n r1[i] += 1\r\n\r\n else:\r\n r1[i] = 1\r\n\r\nfor i in z2:\r\n if i in r2:\r\n r2[i] += 1\r\n\r\n else:\r\n r2[i] = 1\r\n\r\n\r\no = [2,3,5]\r\nans = 0\r\nfor i in range(2,6):\r\n if i == 4:\r\n continue\r\n\r\n else:\r\n e1 = 0\r\n e2 = 0\r\n if i in r1:\r\n e1 = r1[i]\r\n\r\n if i in r2:\r\n e2 = r2[i]\r\n\r\n ans += abs(e2-e1)\r\n\r\nflag = 0\r\nfor i in r1:\r\n if i != 2 and i != 3 and i != 5:\r\n if i in r2:\r\n if r2[i] != r1[i]:\r\n flag = 1\r\n break\r\n\r\n else:\r\n flag = 1\r\n break\r\n\r\nfor i in r2:\r\n if i != 2 and i != 3 and i != 5:\r\n if i in r1:\r\n if r2[i] != r1[i]:\r\n flag = 1\r\n break\r\n\r\n else:\r\n flag = 1\r\n break\r\n\r\nif flag:\r\n print(-1)\r\n\r\nelse:\r\n print(ans)", "a,b = map(int,input().split())\r\ndef gcd(a,b):\r\n if a==0:\r\n return b\r\n return gcd(b%a, a)\r\nabcd = gcd(a,b)\r\na/=abcd\r\nb/=abcd\r\nans=0\r\nwhile a>1:\r\n if a%2==0:\r\n a//=2\r\n ans+=1\r\n elif a%3==0:\r\n a//=3\r\n ans+=1\r\n elif a%5==0:\r\n a//=5\r\n ans+=1\r\n else:\r\n print(-1)\r\n quit()\r\nwhile b>1:\r\n if b%2==0:\r\n b//=2\r\n ans+=1\r\n elif b%3==0:\r\n b//=3\r\n ans+=1\r\n elif b%5==0:\r\n b//=5\r\n ans+=1\r\n else:\r\n print(-1)\r\n quit()\r\nprint(ans)\r\n\r\n\r\n", "from collections import defaultdict, Counter\nfrom math import inf\nfrom functools import lru_cache\n\nimport sys\n#input=sys.stdin.readline\n\n\ndef solution():\n a,b = map(int, input().split())\n acount = {2:0,3:0,5:0}\n for num in [2,3,5]:\n while a%num == 0:\n a //= num \n acount[num] += 1\n\n bcount = {2:0,3:0,5:0}\n for num in [2,3,5]:\n while b%num == 0:\n b //= num \n bcount[num] += 1\n\n if a != b:\n return print(-1)\n\n res = 0\n for num in [2,3,5]:\n res += abs(acount[num] - bcount[num])\n\n print(res)\n\n\ndef main():\n t = 1\n #t = int(input())\n for _ in range(t):\n solution()\n\n\nimport sys\nimport threading\nsys.setrecursionlimit(10**6)\nthreading.stack_size(1 << 27)\nthread = threading.Thread(target=main)\nthread.start(); thread.join()\n#main()\n\n", "import sys\n\ndef solve(a: int, b: int) -> int:\n \n values = [a, b]\n times = {}\n for i, denominator in enumerate([2, 3, 5]):\n for j in range(2):\n \n while not values[j] % denominator:\n values[j] /= denominator\n times[(i, j)] = times.get((i, j), 0) + 1\n \n if values[0] != values[1]:\n return -1\n \n result = 0 \n for i in range(3):\n result = result + abs(times.get((i, 0), 0) - times.get((i, 1), 0))\n \n return result\n \n\n# input\nn, k = [int(x) for x in sys.stdin.readline().strip().split(\" \")]\nprint(solve(n, k))\n", "import math\r\ndef generate1(n):\r\n mydict={2:0,3:0,5:0}\r\n first=True\r\n while n%2==0:\r\n if first:\r\n mydict[2]=0\r\n first=False\r\n mydict[2]+=1\r\n n//=2\r\n first=True\r\n for i in range(3,int(math.sqrt(n))+1,2):\r\n first=True\r\n while n%i==0:\r\n if first:\r\n first=False\r\n mydict[i]=0\r\n mydict[i]+=1\r\n n//=i\r\n \r\n if n>2:\r\n mydict[n]=0\r\n mydict[n]+=1\r\n return mydict\r\ndef generate(n):\r\n mydict={2:0,3:0,5:0}\r\n while n%2==0:\r\n n//=2\r\n mydict[2]+=1\r\n while n%3==0:\r\n n//=3\r\n mydict[3]+=1\r\n while n%5==0:\r\n n//=5\r\n mydict[5]+=1\r\n return n,mydict\r\na,b=map(int,input().split())\r\nif a==b:\r\n print(0)\r\nelse:\r\n tmp1,mydict1=generate(a)\r\n tmp2,mydict2=generate(b)\r\n if tmp1!=tmp2:\r\n print(-1)\r\n else:\r\n minmove=abs(mydict1[2]-mydict2[2])+abs(mydict1[3]-mydict2[3])+abs(mydict1[5]-mydict2[5])\r\n print(minmove)", "a,b = map(int,input().split())\r\n\r\nx1,x2,x3 = 0,0,0\r\ny1,y2,y3 = 0,0,0\r\n\r\ndef div(n,m):\r\n\tans=0\r\n\twhile n%m==0 :\r\n\t\tans+=1\r\n\t\tn//=m\r\n\treturn [ans,n]\r\n\r\nx1,a = div(a,2)\r\nx2,a = div(a,3)\r\nx3,a = div(a,5)\r\n\r\ny1,b = div(b,2)\r\ny2,b = div(b,3)\r\ny3,b = div(b,5)\r\n\r\nif a!=b :\r\n\tprint(-1)\r\nelse:\r\n\tprint(abs(x1-y1)+abs(x2-y2)+abs(x3-y3))", "import math\r\ndef countP(n):\r\n ans = 0\r\n while(n%2 == 0):\r\n n= n//2\r\n ans+=1\r\n \r\n while n % 3== 0: \r\n ans+=1 \r\n n = n // 3\r\n while n % 5== 0: \r\n ans+=1 \r\n n = n // 5\r\n\r\n if(n>1):\r\n return -1\r\n return ans\r\n\r\n\r\na, b = map(int, input().split())\r\nk = math.gcd(a, b)\r\na = a//k\r\nb = b//k\r\nif(countP(a) == -1 or countP(b) == -1):\r\n print(-1)\r\nelse:\r\n print(countP(a) + countP(b))\r\n", "from math import log\n\na, b = input().split()\na = int(a); b = int(b)\n\ndef gcd(a, b):\n\tif a < b:\n\t\treturn gcd(b, a)\n\telif not a%b:\n\t\treturn b\n\telse:\n\t\treturn gcd(b, a%b)\n\ndef div_n(x, i):\n\tl = int(round(log(x)/log(i)))\n\tcount = 0\n\tfor j in range(1, l+1):\n\t\tif not x%i:\n\t\t\tx = x//i\n\t\t\tcount += 1\n\treturn (x, count)\n\nif a == b:\n\tprint(0)\nelse:\n\tn = gcd(a, b)\n\tnum_a = a//n\n\tnum_b = b//n\n\n\t(num_a, count1) = div_n(num_a, 2)\n\t(num_a, count2) = div_n(num_a, 3)\n\t(num_a, count3) = div_n(num_a, 5)\n\tcount_a = count1+count2+count3\n\n\t(num_b, count1) = div_n(num_b, 2)\n\t(num_b, count2) = div_n(num_b, 3)\n\t(num_b, count3) = div_n(num_b, 5)\n\tcount_b = count1+count2+count3\n\n\tif num_a == 1 and num_b == 1:\n\t\tprint(count_a+count_b)\n\telse:\n\t\tprint(-1)\n", "from sys import stdin,stdout\r\ninput = stdin.readline\r\ndef write(n,sep=\"\\n\"):\r\n\tstdout.write(str(n))\r\n\tstdout.write(sep)\r\ndef gil():\r\n\treturn list(map(int, input().split()))\r\n\t\r\na,b = gil()\r\nx = [2,3,5]\r\nc = 0\r\nfor i in x:\r\n\twhile a%i==0 and b%i==0:\r\n\t\ta /= i\r\n\t\tb /= i\r\n\twhile a%i==0:\r\n\t\tc += 1\r\n\t\ta /= i\r\n\twhile b%i==0:\r\n\t\tc += 1\r\n\t\tb /= i\r\n\t\r\nif a == b:\r\n\tprint(c)\r\nelse:\r\n\tprint(-1)\r\n\t\t\r\n", "from math import *\r\nb = input()\r\nb = b.split()\r\nn = int(b[0])\r\nm = int(b[1])\r\nb = [2,3,5]\r\na = []\r\nc = []\r\nfor x in range(10):\r\n a.append(0)\r\n c.append(0)\r\nfor x in b:\r\n l = n\r\n while (l%x)==0:\r\n a[x]+=1\r\n l/=x\r\n l = m\r\n while (l%x)==0:\r\n c[x]+=1\r\n l/=x\r\nans = 0\r\nfor x in b:\r\n if a[x]!=c[x]:\r\n l = abs(a[x]-c[x])\r\n ans+=l\r\n if a[x]<c[x]:\r\n for y in range(l):\r\n m/=x\r\n else:\r\n for y in range(l):\r\n n/=x\r\nif n==m: print(ans)\r\nelse: print(-1)", "def dividir(a,b):\n if a==b:\n return 0\n divisores = [2,3,5]\n cont = 0\n for i in divisores:\n while a%i==0 and b%i==0:\n a = a/i\n b = b/i\n while a%i==0:\n a = a/i\n cont+=1\n while b%i==0:\n b = b/i\n cont+=1\n if a!=b:\n return -1\n else:\n return cont\n\n #INICIO\ngramos = input()\ngramos = gramos.split()\n\na = int(gramos[0])\nb = int(gramos[1])\nprint(dividir(a,b))\n", "import math\n\ndef solveTLE(n, m):\n if n == m: return 0\n dp = [[0 for _ in range(m+1)] for _ in range(n+1)]\n\n for i in range(n+1):\n for j in range(m+1):\n if i == j:\n dp[i][j] = 0\n continue\n\n if i > j:\n op1, op2, op3 = math.inf, math.inf, math.inf\n\n if i %2 == 0: op1 = dp[i//2][j]\n\n if i%3 == 0: op2 = dp[i//3][j]\n\n if i%5 == 0: op3 = dp[i//5][j]\n\n res = min(op1, op2, op3)\n\n dp[i][j] = 1+ res\n\n else:\n op1, op2, op3 = math.inf, math.inf, math.inf\n\n if j %2 == 0: op1 = dp[i][j//2]\n\n if j%3 == 0: op2 = dp[i][j//3]\n\n if j%5 == 0: op3 = dp[i][j//5]\n\n res = min(op1, op2, op3)\n\n dp[i][j] = 1+ res\n \n res = dp[n][m]\n\n if res == math.inf: return -1\n\n return res\n\n\ndef solve(n, m):\n if n == m: return 0\n\n a2, b2, a3, b3, a5, b5 = 0, 0, 0, 0,0, 0\n\n while n%2 == 0:\n n = n//2\n a2+=1\n while m%2 == 0:\n m = m//2\n b2+=1\n \n while n%5 == 0:\n n = n//5\n a5+=1\n while m%5 == 0:\n m = m//5\n b5+=1\n\n\n while n%3 == 0:\n n = n//3\n a3+=1\n while m%3 == 0:\n m = m//3\n b3+=1\n \n\n if n!= m: return -1\n\n res = abs(a2-b2)+ abs(a3-b3)+ abs(a5-b5)\n\n return res\n\nn, m = map(int, input().split())\nprint(solve(n, m))", "def get_factors(x, list):\n two = 0\n three = 0\n five = 0\n\n while (x%2 == 0):\n two += 1\n x = x / 2\n while (x%3 == 0):\n three += 1\n x = x / 3\n while (x%5 == 0):\n five += 1\n x = x / 5\n\n list.append(two)\n list.append(three)\n list.append(five)\n list.append(x)\n\n return list\n\ninput = input().split(' ')\na = int(input[0])\nb = int(input[1])\n\nfactors_a = []\nfactors_b = []\n\nif a != b:\n get_factors(a, factors_a)\n get_factors(b, factors_b)\n\n if (factors_a[3] != factors_b[3]):\n print(-1)\n else:\n sum = abs(factors_a[0] - factors_b[0]) + abs(factors_a[1] - factors_b[1]) + abs(factors_a[2] - factors_b[2])\n print(sum)\nelse:\n print(0)\n \t\t \t \t\t\t \t\t\t\t \t\t \t \t \t \t", "from sys import stdin,stdout\r\ninput=stdin.readline\r\ndef print(*args, end='\\n', sep=' ') -> None:\r\n stdout.write(sep.join(map(str, args)) + end)\r\nn,m=map(int,input().split()) ; ans=0 ; a=b=1 ; a2=a3=a5=b2=b3=b5=0\r\nwhile n>1:\r\n if n%2==0:\r\n n//=2\r\n a2+=1\r\n elif n%3==0:\r\n n//=3\r\n a3+=1\r\n elif n%5==0:\r\n n//=5\r\n a5+=1\r\n else:\r\n a=n\r\n n//=n\r\n\r\nwhile m>1:\r\n if m%2==0:\r\n m//=2\r\n b2+=1\r\n elif m%3==0:\r\n m//=3\r\n b3+=1\r\n elif m%5==0:\r\n m//=5\r\n b5+=1\r\n else:\r\n b=m\r\n m//=m\r\nif b==a:\r\n print(abs(a2-b2)+abs(a3-b3)+abs(a5-b5))\r\nelse:\r\n print(-1)\r\n\r\n\r\n", "a, b = map(int, input().split())\n \nc = [2, 3, 5]\nr = 0\nfor i in c:\n\tx = 0\n\ty = 0\n\twhile a % i == 0:\n\t\tx += 1\n\t\ta //= i\n\twhile b % i == 0:\n\t\ty += 1\n\t\tb //= i\n\tr += max(x, y) - min(x, y)\nif a == b:\n\tprint(r)\nelse:\n\tprint(-1)\n\t\t\t \t \t \t \t\t\t\t \t \t\t\t", "from bisect import bisect_right\r\nimport math\r\nfrom queue import PriorityQueue\r\nfrom sys import stdin, stdout\r\nimport collections\r\ninput, print = stdin.readline, stdout.write\r\n\r\n\r\ndef str_input():\r\n s = input()\r\n return s[:len(s)-1]\r\n\r\n\r\ndef char_list_input():\r\n s = input()\r\n return list(s[:len(s)-1])\r\n\r\n\r\ndef list_input(type):\r\n return list(map(type, input().split()))\r\n\r\n\r\ndef multi_input():\r\n return map(int, input().split())\r\n\r\n\r\ndef main():\r\n a, b = multi_input()\r\n d = math.gcd(a,b)\r\n a = a//d\r\n b = b//d\r\n ans = 0\r\n while a%2==0:\r\n ans += 1\r\n a//=2\r\n while a%3==0:\r\n ans += 1\r\n a//=3\r\n while a%5==0:\r\n ans += 1\r\n a//=5\r\n while b%2==0:\r\n ans += 1\r\n b//=2\r\n while b%3==0:\r\n ans += 1\r\n b//=3\r\n while b%5==0:\r\n ans += 1\r\n b//=5\r\n if a>1 or b>1:\r\n ans = -1\r\n print(f\"{ans}\\n\")\r\n\r\n\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "import sys\r\nimport string\r\nimport math\r\nfrom collections import defaultdict\r\nfrom functools import lru_cache\r\nfrom collections import Counter\r\nfrom fractions import Fraction\r\n\r\ndef mi(s):\r\n return map(int, s.strip().split())\r\n\r\ndef lmi(s):\r\n return list(mi(s))\r\n\r\ndef tmi(s):\r\n return tuple(mi(s))\r\n\r\ndef mf(f, s):\r\n return map(f, s)\r\n\r\ndef lmf(f, s):\r\n return list(mf(f, s))\r\n\r\ndef js(lst):\r\n return \" \".join(str(d) for d in lst)\r\n\r\ndef jsns(lst):\r\n return \"\".join(str(d) for d in lst)\r\n\r\ndef line():\r\n return sys.stdin.readline().strip()\r\n\r\ndef linesp():\r\n return line().split()\r\n\r\ndef iline():\r\n return int(line())\r\n\r\ndef mat(n):\r\n matr = []\r\n for _ in range(n):\r\n matr.append(linesp())\r\n return matr\r\n\r\ndef matns(n):\r\n mat = []\r\n for _ in range(n):\r\n mat.append([c for c in line()])\r\n return mat\r\n\r\ndef mati(n):\r\n mat = []\r\n for _ in range(n):\r\n mat.append(lmi(line())) \r\n return mat\r\n\r\ndef pmat(mat):\r\n for row in mat:\r\n print(js(row))\r\n\r\ndef gcd(a, b):\r\n while b:\r\n a %= b\r\n a, b = b, a\r\n return a\r\n\r\ndef factorize(n):\r\n factors = []\r\n i = 2\r\n while i*i <= n:\r\n while n % i == 0:\r\n factors.append(i)\r\n n //= i\r\n i += 1\r\n if n > 1:\r\n factors.append(n)\r\n return factors\r\n\r\ndef main():\r\n n, m = mi(line())\r\n k = gcd(n, m)\r\n a = factorize(n // k)\r\n b = factorize(m // k)\r\n \r\n for f in a:\r\n if f not in (3, 5, 2):\r\n print(-1)\r\n return\r\n for f in b:\r\n if f not in (3, 5, 2):\r\n print(-1)\r\n return\r\n print(len(a) + len(b))\r\nmain()\r\n", "import math\r\na,b=map(int,input().split())\r\nq=math.gcd(a,b)\r\na=a//q\r\nb=b//q\r\np=a*b\r\nc=0\r\nwhile p%2==0:\r\n c=c+1\r\n p=p//2\r\nwhile p%3==0:\r\n c=c+1\r\n p=p//3\r\nwhile p%5==0:\r\n c+=1\r\n p=p//5\r\nif p==1:\r\n print(c)\r\nelse:\r\n print(-1)\r\n", "# import sys\r\n# sys.stdin = open(\"input.in\",\"r\")\r\nfrom heapq import heapify,heappush,heappop\r\nfrom collections import defaultdict as dd, deque as dq,Counter as C\r\nfrom math import factorial as f ,ceil,gcd,sqrt,log\r\nfrom itertools import permutations as p\r\nfrom bisect import bisect_left as bl ,bisect_right as br\r\n# def fibo_n(n):\r\n# \treturn (((1+sqrt(5))/2)**n)/sqrt(5)\r\n# # import os,io\r\n# # input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\nfrom sys import stdin,stdout\r\ninput = stdin.readline\r\nfrom bisect import bisect_right as bl\r\nmp = lambda : map(int,input().split())\r\nit = lambda: int(input())\r\ndef sev():\r\n\tmx = 2*(10**5) +5\r\n\tsv = [1]*(mx+1)\r\n\tsv[0]=sv[1]=0\r\n\tfor i in range(2,mx):\r\n\t\tif i*i<=mx and sv[i]:\r\n\t\t\tfor j in range(i*2,mx,i):\r\n\t\t\t\tsv[j]=0\r\n\treturn sv\r\n# d = dd(lambda : [])\r\ndef pfactors(n):\r\n\td = dd(lambda : 0)\r\n\tflg =0\r\n\twhile n%2==0:\r\n\t\tflg +=1\r\n\t\tn//=2\r\n\tif flg:\r\n\t\td[2]= flg\r\n\tfor cc in range(3,6,2):\r\n\t\tif n%cc==0:\r\n\t\t\tcnt =0\r\n\t\t\twhile n%cc==0:\r\n\t\t\t\tcnt+=1\r\n\t\t\t\tn//=cc\r\n\t\t\td[cc]=cnt\r\n\treturn d,n\r\na,b = mp()\r\na1,rm1 = pfactors(a)\r\na2,rm2 = pfactors(b)\r\nif rm1 == rm2:\r\n\tans = abs(a1[2]-a2[2]) + abs(a1[3]-a2[3]) + abs(a1[5]-a2[5])\r\n\tprint(ans)\r\nelse:\r\n\tprint(-1)\r\n\r\n\r\n", "# link: https://codeforces.com/contest/371/problem/B\r\n\r\nimport math\r\n\r\nfor _ in range(1):\r\n a, b = map(int, input().split())\r\n if a==b:\r\n print(0)\r\n else:\r\n powers_a = {2:0, 3:0, 5:0}\r\n powers_b = {2:0, 3:0, 5:0}\r\n left_a = 0\r\n left_b = 0\r\n while 1:\r\n if a%2 == 0:\r\n powers_a[2] += 1\r\n a = a//2\r\n elif a%3 == 0:\r\n powers_a[3] += 1\r\n a = a//3\r\n elif a%5 == 0:\r\n powers_a[5] += 1\r\n a = a//5\r\n else:\r\n left_a = a \r\n break\r\n while 1:\r\n if b%2 == 0:\r\n powers_b[2] += 1\r\n b = b//2\r\n elif b%3 == 0:\r\n powers_b[3] += 1\r\n b = b//3\r\n elif b%5 == 0:\r\n powers_b[5] += 1\r\n b = b//5\r\n else:\r\n left_b = b \r\n break \r\n if left_a != left_b:\r\n print(-1)\r\n else:\r\n print(abs(powers_a[2] - powers_b[2]) + abs(powers_b[3] - powers_a[3]) + abs(powers_a[5] - powers_b[5])) ", "a,b=list(map(int,input().split()))\r\nif(a==b):\r\n print(0)\r\nelse:\r\n d1={2:0,3:0,5:0}\r\n d2={2:0,3:0,5:0}\r\n f1=0\r\n f2=0\r\n while(a>1):\r\n if(a%2==0):\r\n a=a//2\r\n d1[2]+=1\r\n elif(a%3==0):\r\n a=a//3\r\n d1[3]+=1\r\n elif(a%5==0):\r\n a=a//5\r\n d1[5]+=1\r\n else:\r\n f1=1\r\n break\r\n while(b>1):\r\n if(b%2==0):\r\n b=b//2\r\n d2[2]+=1\r\n elif(b%3==0):\r\n b=b//3\r\n d2[3]+=1\r\n elif(b%5==0):\r\n b=b//5\r\n d2[5]+=1\r\n else:\r\n f2=1\r\n break\r\n if(a!=b):\r\n print(-1)\r\n else:\r\n t1=0\r\n if(d1[2]!=d2[2]):\r\n t1+=abs(d1[2]-d2[2])\r\n if(d1[3]!=d2[3]):\r\n t1+=abs(d2[3]-d1[3])\r\n if(d1[5]!=d2[5]):\r\n t1+=abs(d2[5]-d1[5])\r\n print(t1)\r\n \r\n \r\n", "import sys\r\nglobal a,b,res\r\ndef chek(x):\r\n global a,b,res\r\n res=0\r\n z=0\r\n y=0\r\n while a%x==0:\r\n a/=x\r\n z+=1\r\n while b%x==0:\r\n b/=x\r\n y+=1\r\n res+=abs(z-y)\r\n return res\r\na,b=map(int,input().split())\r\n\r\nres_main=0\r\nres_main+=chek(2)\r\nres_main+=chek(3)\r\nres_main+=chek(5)\r\nif a!=b:\r\n print(-1)\r\nelse:\r\n print(res_main)\r\n", "import math\nimport sys\ndef sol(x):\n\tres=0\n\twhile x%2==0:\n\t\tres+=1\n\t\tx=x//2\n\twhile x%3==0:\n\t\tres+=1\n\t\tx=x//3\n\twhile x%5==0:\n\t\tres+=1\n\t\tx=x//5\n\tif(x!=1):\n\t\treturn -1\n\telse :\n\t\treturn res\na,b=map(int,input().split())\nd=math.gcd(a,b)\nans1=sol(a//d)\nif(ans1==-1):\n\tprint(-1)\n\tsys.exit()\nans2=sol(b//d)\nif(ans2==-1):\n\tprint(-1)\n\tsys.exit()\nprint(ans1+ans2)", "a, b = map(int, input().split())\r\ncount = 0\r\nfor i in (2,3,5):\r\n\tx = 0\r\n\ty = 0\r\n\twhile a % i == 0:\r\n\t\tx += 1\r\n\t\ta //= i\r\n\twhile b % i == 0:\r\n\t\ty += 1\r\n\t\tb //= i\r\n\tcount += max(x, y) - min(x, y)\r\nif a == b:\r\n\tprint(count)\r\nelse:\r\n\tprint(-1)", "import math\r\nfrom collections import Counter\r\na,b=list(map(int,str.split(input())))\r\nrslt=0\r\nif a ==b:\r\n print(0)\r\nelse:\r\n c= math.gcd(a,b)\r\n a_fac=[2,3,5]\r\n b_fac=[2,3,5]\r\n for i in [2,3,5]:\r\n while a%i==0:\r\n a=a//i\r\n a_fac+=[i]\r\n while b%i==0:\r\n b=b//i\r\n b_fac+=[i]\r\n\r\n if b!=a:\r\n print(-1)\r\n \r\n else:\r\n facs_a=Counter(a_fac)\r\n facs_b=Counter(b_fac)\r\n for key in facs_a:\r\n rslt+=abs(facs_a[key]-facs_b[key])\r\n print(rslt)", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jun 14 10:28:21 2020\n\n@author: shailesh\n\"\"\"\n\n\ndef find_power_of(num,base):\n count = 0\n while(num%base == 0):\n num //= base\n count +=1\n return num,count\n\n\n\na,b = [int(i) for i in input().split()]\n\n\na,a5 = find_power_of(a,5)\nb,b5 = find_power_of(b,5)\n\na,a3 = find_power_of(a,3)\nb,b3 = find_power_of(b,3)\n\na,a2 = find_power_of(a,2)\nb,b2 = find_power_of(b,2)\n\n\nif a!=b:\n print(-1)\nelse:\n count = abs(a5-b5) + abs(a3-b3) + abs(a2-b2)\n print(count)", "from math import pow\r\ndef take_input(s): #for integer inputs\r\n if s == 1: return int(input())\r\n return map(int, input().split())\r\n\r\ndef factor(n,k):\r\n i = 0\r\n while(n%k==0):\r\n i += 1\r\n n //= k\r\n return i\r\n \r\na, b = take_input(2)\r\ncount = 0\r\nif a == b:\r\n print(0)\r\n exit()\r\n\r\na_fac_2 = factor(a,2); a_fac_3 = factor(a,3); a_fac_5 = factor(a,5)\r\nb_fac_2 = factor(b,2); b_fac_3 = factor(b,3); b_fac_5 = factor(b,5)\r\nx = a\r\nif a_fac_2>0: x //= pow(2,a_fac_2)\r\nif a_fac_3>0: x //= pow(3,a_fac_3)\r\nif a_fac_5>0: x //= pow(5,a_fac_5)\r\ny = b\r\nif b_fac_2>0: y //= pow(2,b_fac_2)\r\nif b_fac_3>0: y //= pow(3,b_fac_3)\r\nif b_fac_5>0: y //= pow(5,b_fac_5)\r\n\r\n\r\nif x != y:\r\n print(-1)\r\nelse:\r\n print(abs(a_fac_2 - b_fac_2) + abs(a_fac_3 - b_fac_3) + abs(a_fac_5 - b_fac_5))\r\n", "def gcd(a,b):\r\n while a%b:\r\n a,b = b,a%b\r\n return b\r\na,b = map(int,input().split())\r\ng = gcd(a,b)\r\na //= g\r\nb //= g\r\ncnt = 0\r\nfor i in [2,3,5]:\r\n while a%i==0:\r\n a //= i\r\n cnt += 1\r\n while b%i==0:\r\n b //= i\r\n cnt += 1\r\nif a==1 and b==1:\r\n print(cnt)\r\nelse:\r\n print(-1)", "from math import *\r\nfrom collections import *\r\nfrom bisect import *\r\nimport heapq\r\nimport math\r\nfrom itertools import permutations\r\n\r\ndef is_prime(n):\r\n\r\n for i in range(2,math.ceil(math.sqrt(n))):\r\n if(n%i==0):\r\n return False\r\n return True\r\n\r\ndef sieve(n):\r\n arr=[True for _ in range(n+1)]\r\n\r\n for i in range(2,math.ceil(math.sqrt(n))):\r\n if(arr[i]==True):\r\n for j in range(i*i,n+1,i):\r\n arr[j]=False\r\n\r\n return arr\r\n\r\n\r\ndef power(x, y, p):\r\n res = 1 # Initialize result\r\n\r\n # Update x if it is more\r\n # than or equal to p\r\n x = x % p\r\n\r\n if (x == 0):\r\n return 0\r\n\r\n while (y > 0):\r\n\r\n # If y is odd, multiply\r\n # x with result\r\n if ((y & 1) == 1):\r\n res = (res * x) % p\r\n\r\n # y must be even now\r\n y = y >> 1 # y = y/2\r\n x = (x * x) % p\r\n\r\n return res\r\n\r\ndef euclidean_distance(x1,y1,x2,y2):\r\n return sqrt(abs(x1-x2)**2+abs(y1-y2)**2)\r\n\r\ndef get_permutations(lo=0,hi=10):\r\n return list(permutations(range(lo,hi)))\r\n\r\n\r\ndef solve():\r\n # s=input()\r\n # n=int(input())\r\n # lis=list(map(int,input().split()))\r\n # lis2 = list(map(int, input().split()))\r\n x,y=list(map(int, input().split()))\r\n\r\n q=deque()\r\n q.append((x,y))\r\n st=set()\r\n st.add((str(x)+' '+str(y)))\r\n c=0\r\n while(len(q)>0):\r\n sz=len(q)\r\n # print(q)\r\n for _ in range(sz):\r\n got=q.popleft()\r\n x,y=got[0],got[1]\r\n if(x==y):\r\n print(c)\r\n return\r\n z=0\r\n for j in [2,3,5]:\r\n if(x%j==0 and x!=0):\r\n x_=x//j\r\n if(str(x_)+' '+str(y) not in st):\r\n # z+=1\r\n if (x_ == y):\r\n print(c + 1)\r\n return\r\n st.add(str(x_)+' '+str(y))\r\n q.append((x_,y))\r\n\r\n for j in [2, 3, 5]:\r\n if (y % j == 0 and y!=0):\r\n y_ = y // j\r\n if (str(x) + ' ' + str(y_) not in st):\r\n # z+=1\r\n if(x==y_):\r\n print(c+1)\r\n return\r\n st.add(str(x) + ' ' + str(y_))\r\n q.append((x, y_))\r\n # if(z==0):\r\n # print(-1)\r\n # return\r\n c+=1\r\n print(-1)\r\n\r\n\r\n\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n n=1\r\n # n=int(input())\r\n while(n):\r\n n-=1\r\n solve()\r\n\r\n\r\n\r\n\r\n", "a, b = [int(x) for x in input().split()]\r\n\r\nda = {2:0,3:0,5:0}\r\ndb = {2:0,3:0,5:0}\r\n\r\nwhile a%2 == 0 or a%3 == 0 or a%5 == 0:\r\n if a%2 == 0:\r\n da[2]+=1\r\n a = a/2\r\n continue\r\n if a%3 == 0:\r\n da[3]+=1\r\n a = a/3\r\n continue\r\n if a%5 == 0:\r\n da[5]+=1\r\n a = a/5\r\n continue\r\n\r\nwhile b%2 == 0 or b%3 == 0 or b%5 == 0:\r\n if b%2 == 0:\r\n db[2]+=1\r\n b = b/2\r\n continue\r\n if b%3 == 0:\r\n db[3]+=1\r\n b = b/3\r\n continue\r\n if b%5 == 0:\r\n db[5]+=1\r\n b = b/5\r\n continue\r\n\r\nif a != b:\r\n print (-1)\r\nelse:\r\n ans = abs(da[2]-db[2])+abs(da[3]-db[3])+abs(da[5]-db[5])\r\n print (ans)", "def dividir(n):\n count = [0, 0, 0]\n while (n%2==0):\n count[0] = count[0]+1\n n = n/2\n while (n%3==0):\n count[1] = count[1]+1\n n = n/3\n while (n%5==0):\n count[2] = count[2]+1\n n = n/5\n return (count, n)\n\nnums = input()\nab = nums.split(' ')\na = int(ab[0])\nb = int(ab[1])\n\nA = dividir(a)\nB = dividir(b)\n\nif (A[1] != B[1]):\n print(\"-1\\n\")\nelse:\n cuentaA = A[0]\n cuentaB = B[0]\n res = abs(cuentaA[0]-cuentaB[0]) + abs(cuentaA[1]-cuentaB[1]) + abs(cuentaA[2]-cuentaB[2])\n print(str(res) + \"\\n\")\n \t\t\t\t \t \t \t\t \t \t \t\t \t \t\t", "def gcd(a, b):\r\n if b == 0:\r\n return a\r\n return gcd(b, a % b)\r\ndef f(a):\r\n global e\r\n k=0\r\n while a%2==0:\r\n a=a//2\r\n k+=1\r\n while a%3==0:\r\n a=a//3\r\n k+=1\r\n while a%5==0:\r\n a=a//5\r\n k+=1\r\n e += a\r\n return k\r\na,b = map(int,input().split())\r\nn= gcd(a,b)\r\ne = 0\r\nk = f(a//n)\r\nk=k+f(b//n)\r\nif e>2:\r\n print(-1)\r\nelse:\r\n print(k)\r\n \r\n \r\n", "from collections import Counter\na,b = map(int, input().split())\n\ndef get_primes(num):\n primes = []\n prod = 1\n cur = num\n for i in range(2,int(num**0.5)+1):\n while cur % i == 0:\n primes.append(i)\n cur //= i\n prod *= i\n if prod < num:\n primes.append(num//prod)\n return primes\n\nap = Counter(get_primes(a))\nbp = Counter(get_primes(b))\nboth = ap & bp\ncp = (ap-both) + (bp-both)\n\nif not set(cp).issubset({2,3,5}):\n print(-1)\n exit()\n\nprint(sum(cp.values()))\n", "import math\r\nfrom collections import Counter\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(i)\r\n n = n / i\r\n if n > 2:\r\n l.append(n)\r\n return l\r\n\r\n\r\na, b = map(int, input().split())\r\ntemp = math.gcd(a, b)\r\nma = a//temp\r\nmb = b//temp\r\nxa = primeFactors(ma)\r\nxb = primeFactors(mb)\r\nc = 0\r\nf = 1\r\nfor i in xa:\r\n c += 1\r\n if i not in [2, 3, 5]:\r\n f = 0\r\n break\r\nfor i in xb:\r\n c += 1\r\n if i not in [2, 3, 5]:\r\n f = 0\r\n break\r\nif f == 1:\r\n print(c)\r\nelse:\r\n print(-1)\r\n", "def foxDividingCheese(a, b):\n\n posPartitions = [2, 3, 5]\n moves = 0\n\n if a == b:\n return 0\n\n for partition in posPartitions:\n contA = 0\n contB = 0\n\n while a % partition == 0:\n a = a / partition\n contA += 1\n while b % partition == 0:\n b = b / partition\n contB += 1\n\n moves += abs(contA-contB)\n\n if a != b:\n return -1\n \n return moves\n\nab = input().split()\na = int(ab[0])\nb = int(ab[1])\n\nprint(foxDividingCheese(a, b))\n\t\t\t\t \t \t \t\t\t \t \t\t \t\t \t \t", "import math\r\n\r\ndef gcd(a,b):\r\n if a<b:a,b=b,a\r\n while a%b!=0:\r\n a,b=b,a%b\r\n return b\r\n\r\na,b=map(int,input().split())\r\n\r\nres=0\r\n\r\nfor i in [2,3,5]:\r\n r=0\r\n while a%i==0:\r\n a//=i\r\n r+=1\r\n while b%i==0:\r\n b//=i\r\n r-=1\r\n res+=abs(r)\r\n\r\nif gcd(a, b) == 1 and a!=b:\r\n print(-1)\r\nelse:\r\n print(res)\r\n\r\n\r\n\r\n", "from sys import stdin,stdout\r\ninput=stdin.readline \r\nimport math,bisect\r\n\r\ndef gcd(a,b):\r\n\tif a==0:\r\n\t\treturn b\r\n\tif b==0:\r\n\t\treturn a\r\n\treturn gcd(b,a%b)\r\n\r\n\r\na,b=map(int,input().split())\r\ng=gcd(a,b)\r\na1=a//g\r\nb1=b//g\r\nf=0\r\nans=0\r\nwhile(a1):\r\n\tif a1%2==0:\r\n\t\ta1=a1//2\r\n\t\tans+=1\r\n\telif a1%3==0:\r\n\t\ta1=a1//3\r\n\t\tans+=1\r\n\telif a1%5==0:\r\n\t\ta1=a1//5\r\n\t\tans+=1\r\n\telse:\r\n\t\tbreak\r\n\r\nwhile(b1):\r\n\tif b1%2==0:\r\n\t\tb1=b1//2\r\n\t\tans+=1\r\n\telif b1%3==0:\r\n\t\tb1=b1//3\r\n\t\tans+=1\r\n\telif b1%5==0:\r\n\t\tb1=b1//5\r\n\t\tans+=1\r\n\telse:\r\n\t\tbreak\r\n\r\nif(a1!=1 or b1!=1):\r\n\tprint(-1)\r\nelse:\r\n\tprint(ans)\r\n\r\n\r\n\r\n\r\n\"\"\"ans=0\r\nf=0\r\nwhile(a!=b):\r\n\tif(a>b):\r\n\t\tif a%2==0:\r\n\t\t\ta=a//2\r\n\t\t\tans+=1\r\n\t\telif a%3==0:\r\n\t\t\ta=a//3\r\n\t\t\tans+=1\r\n\t\telif a%5==0:\r\n\t\t\ta=a//5\r\n\t\t\tans+=1\r\n\t\telse:\r\n\t\t\tf=1\r\n\t\t\tbreak\r\n\telif b>a:\r\n\t\tif b%2==0:\r\n\t\t\tans+=1\r\n\t\t\tb=b//2\r\n\t\telif b%3==0:\r\n\t\t\tans+=1\r\n\t\t\tb=b//3\r\n\t\telif b%5==0:\r\n\t\t\tans+=1\r\n\t\t\tb=b//5\r\n\t\telse:\r\n\t\t\tf=1\r\n\t\t\tbreak\r\n\telif a==b:\r\n\t\tbreak\r\nif(f==1):\r\n\tprint(-1)\r\nelse:\r\n\tprint(ans)\"\"\"\r\n\r\n", "def main():\n line = input().split()\n\n a = int(line[0])\n b = int(line[1])\n \n arrayA = [0,0,0]\n arrayB = [0,0,0]\n\n while(a % 2 == 0):\n arrayA[0] = arrayA[0] + 1\n a = a / 2\n\n while(a % 3 == 0):\n arrayA[1] = arrayA[1] + 1\n a = a / 3\n\n while(a % 5 == 0):\n arrayA[2] = arrayA[2] + 1\n a = a / 5\n\n\n\n while(b % 2 == 0):\n arrayB[0] = arrayB[0] + 1\n b = b / 2\n\n while(b % 3 == 0):\n arrayB[1] = arrayB[1] + 1\n b = b / 3\n\n while(b % 5 == 0):\n arrayB[2] = arrayB[2] + 1\n b = b / 5\n\n if(a != b):\n print(-1)\n else:\n print(abs(arrayA[0] - arrayB[0]) + abs(arrayA[1] - arrayB[1]) + abs(arrayA[2] - arrayB[2]))\n \n \nmain()\n \t\t \t \t \t\t\t \t\t \t \t \t \t\t", "a,b=[int(e) for e in input().split()]\r\nx2=0\r\nwhile a%2==0:\r\n a//=2\r\n x2+=1\r\nx3=0\r\nwhile a%3==0:\r\n a//=3\r\n x3+=1\r\nx5=0\r\nwhile a%5==0:\r\n a//=5\r\n x5+=1\r\ny2=0\r\nwhile b%2==0:\r\n b//=2\r\n y2+=1\r\ny3=0\r\nwhile b%3==0:\r\n b//=3\r\n y3+=1\r\ny5=0\r\nwhile b%5==0:\r\n b//=5\r\n y5+=1\r\nif a!=b:\r\n print(-1)\r\nelse:\r\n print(abs(y2-x2)+abs(y3-x3)+abs(y5-x5))", "from sys import stdin,stdout\r\nfrom os import _exit\r\n# from bisect import bisect_left,bisect\r\n# from heapq import heapify,heappop,heappush\r\n# from sys import setrecursionlimit\r\n# from collections import defaultdict,Counter\r\n# from itertools import permutations\r\n# from math import gcd,ceil,sqrt,factorial\r\n# setrecursionlimit(int(1e5))\r\ninput,print = stdin.readline,stdout.write\r\n\r\ndef quit():\r\n stdout.flush()\r\n _exit(0)\r\na,b = list(map(int,input().split()))\r\nif a==b:\r\n print(\"0\\n\")\r\n quit()\r\nx1,y1,z1,x2,y2,z2 = 0,0,0,0,0,0\r\nwhile a%2==0:\r\n a//=2\r\n x1+=1\r\nwhile a%3==0:\r\n a//=3\r\n y1+=1\r\nwhile a%5==0:\r\n a//=5\r\n z1+=1\r\n\r\nwhile b%2==0:\r\n b//=2\r\n x2+=1\r\nwhile b%3==0:\r\n b//=3\r\n y2+=1\r\nwhile b%5==0:\r\n b//=5\r\n z2+=1\r\n\r\nif a!=b:\r\n print(\"-1\\n\")\r\nelse:\r\n print(str(abs(x1-x2)+abs(y1-y2)+abs(z1-z2))+\"\\n\")\r\n \r\n", "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############ ---- Input Functions ---- ############\r\n\r\ndef Fox_Dividing_Cheese():\r\n def power_of_2(num):\r\n power = 0\r\n\r\n while num % 2 == 0:\r\n power += 1\r\n num = num//2 \r\n \r\n return power\r\n \r\n def power_of_3(num):\r\n power = 0 \r\n \r\n while num % 3 == 0:\r\n power += 1 \r\n num = num//3\r\n\r\n return power \r\n \r\n def power_of_5(num):\r\n power = 0 \r\n\r\n while num % 5 == 0:\r\n power += 1 \r\n num = num//5 \r\n \r\n return power \r\n \r\n a,b = invr()\r\n a1 = power_of_2(a)\r\n a2 = power_of_3(a)\r\n a3 = power_of_5(a)\r\n b1 = power_of_2(b)\r\n b2 = power_of_3(b)\r\n b3 = power_of_5(b)\r\n \r\n #print(a1,a2,a3,b1,b2,b3)\r\n partial_num_a = (2**a1)*(3**a2)*(5**a3)\r\n partial_num_b = (2**b1)*(3**b2)*(5**b3)\r\n x = a//partial_num_a\r\n y = b//partial_num_b\r\n\r\n if x != y:\r\n print(-1)\r\n return \r\n else:\r\n power_of_2_dist = abs(a1-b1)\r\n power_of_3_dist = abs(a2-b2)\r\n power_of_5_dist = abs(a3-b3)\r\n print(power_of_2_dist + power_of_3_dist + power_of_5_dist)\r\n return\r\n\r\nFox_Dividing_Cheese()", "c = list(map(int, input().split()))\r\na = c[0]\r\nb = c[1]\r\n\r\na2 = a3 = a5 = 0\r\nb2 = b3 = b5 = 0\r\n\r\nwhile a % 2 == 0:\r\n a = a/2\r\n a2 += 1\r\n\r\nwhile a % 3 == 0:\r\n a = a/3\r\n a3 += 1\r\n\r\nwhile a % 5 == 0:\r\n a = a/5\r\n a5 += 1\r\n\r\nwhile b % 2 == 0:\r\n b = b / 2\r\n b2 += 1\r\n\r\nwhile b % 3 == 0:\r\n b = b / 3\r\n b3 += 1\r\n\r\nwhile b % 5 == 0:\r\n b = b / 5\r\n b5 += 1\r\n\r\nif a != b:\r\n print(-1)\r\nelse:\r\n print(abs(a2-b2) + abs(a3-b3) + abs(a5-b5))\r\n", "from math import sqrt, floor, gcd\r\n\r\ndef factors(n):\r\n dct = {}\r\n for x in range(2, floor(sqrt(n))+1):\r\n while n%x==0:\r\n if x in dct:\r\n dct[x] += 1\r\n else:\r\n dct[x] = 1\r\n n //= x\r\n if n > 1:\r\n if n in dct:\r\n dct[n] += 1\r\n else:\r\n dct[n] = 1\r\n return dct\r\n\r\nx, y = map(int, input().split())\r\nif x == y:\r\n print(0)\r\n exit(0)\r\ngd = gcd(x, y)\r\nc = 0\r\nx //= gd; y //= gd\r\ns = {2, 3, 5}\r\ndct1 = factors(x); dct2 = factors(y)\r\n\r\nif set(k for k in dct1).issubset(s) and set(k for k in dct2).issubset(s):\r\n for k in dct1:\r\n c += dct1[k]\r\n for k in dct2:\r\n c += dct2[k]\r\n print(c)\r\nelse:\r\n print(-1)\r\n\r\n", "import math\nn,m=map(int,input().split())\ns=math.gcd(n,m)\nn=n//s;m=m//s\na=[2,3,5];i=0;r=0\nwhile i!=3:\n if n%a[i]==0:\n n=n//a[i]\n r+=1\n else:\n i+=1\ni=0\nwhile i!=3:\n if m%a[i]==0:\n m=m//a[i]\n r+=1\n else:\n i+=1\nif n==m==1:\n print(r)\nelse:\n print(-1)\n\n \n\n \n", "a, b = map(int, input().split())\n\na2 = a3 = a5 = 0\nb2 = b3 = b5 = 0\n \nwhile a % 2 == 0:\n a = a / 2\n a2 += 1\n \nwhile a % 3 == 0:\n a = a / 3\n a3 += 1\n \nwhile a % 5 == 0:\n a = a / 5\n a5 += 1\n \nwhile b % 2 == 0:\n b = b / 2\n b2 += 1\n \nwhile b % 3 == 0:\n b = b / 3\n b3 += 1\n \nwhile b % 5 == 0:\n b = b / 5\n b5 += 1\n \nif a != b:\n print(-1)\nelse:\n print(abs(a2 - b2) + abs(a3 - b3) + abs(a5 - b5))\n\t \t \t \t \t \t \t \t \t\t \t \t\t\t\t \t\t", "a,b = map(int,input().split())\nDEBUG = 0\nimport sys\n\n# initial test\nif a == b:\n print(0)\n sys.exit(0)\n\n\n# _a = div(a)\n# _b = div(b)\n\n# store occurence of factors 2,3,5 of values a,b\nc = [0]*3 # 2, 3, 5\nd = [0]*3\n\n# divide pieces\nwhile not (a % 2):\n a /= 2\n c[0] +=1\nwhile not (a%3):\n a /= 3\n c[1] += 1\nwhile not (a%5):\n a /=5\n c[2] += 1\n\nwhile not (b%2): b /=2 ; d[0] += 1;\nwhile not (b%3): b/=3; d[1] += 1;\nwhile not (b%5): b/=5; d[2] += 1;\n\n# evaluate if the divison was actually successful in gettinng the\n# pieces to be equal checking for unsuccessful div case\nif a != b:\n print(-1)\n sys.exit(0)\n\n# success div case therefore count the ops\n# where ops are defined by the number of factors\n# that form a value such as a, b\nrv = 0\nif DEBUG:\n print(c,d)\n\n# minimum is found by counting their gcd formed by 2,3,5\n# and finding the asbolute difference for the bins\n# the difference is used to denote the number of factors\n# needed to divide a given value given that the condition of evenness\n# has been satisfied\n# the count of the difference of a and b's bins (2,3,5) is what defines\n# the gcd\nfor _ in range(3):\n rv += abs(c[_] - d[_])\n\n\nprint(rv)\nsys.exit(0)\n# return\n\n\n\nprint(_a,_b)\n\n\t\t \t \t \t \t\t \t\t\t \t \t \t", "a,b=map(int,input().split())\r\nx,y,z,X,Y,Z=0,0,0,0,0,0\r\nwhile(a!=0 and a%2==0):\r\n a=a/2\r\n x+=1\r\nwhile(a!=0 and a%3==0):\r\n a=a/3\r\n y+=1\r\nwhile(a!=0 and a%5==0):\r\n a=a/5\r\n z+=1\r\nwhile(b!=0 and b%2==0):\r\n b=b/2\r\n X+=1\r\nwhile(b!=0 and b%3==0):\r\n b=b/3\r\n Y+=1\r\nwhile(b!=0 and b%5==0):\r\n b=b/5\r\n Z+=1\r\nif(a!=b):\r\n print(-1)\r\nelse:\r\n print(max(X,x)-min(X,x)+max(y,Y)-min(y,Y)+max(z,Z)-min(z,Z))\r\n", "a,b=map(int,input().split());x1=0\r\nfor i in (2,3,5):\r\n while a%i==0 and b%i==0:\r\n a=a/i;b/=i\r\n while a%i==0:\r\n a=a/i\r\n x1=x1+1\r\n while b%i==0:\r\n b=b/i\r\n x1=x1+1\r\nif a==b:\r\n print(x1)\r\nelse:\r\n print(-1)", "from collections import defaultdict,Counter\nimport math\nimport bisect\nfrom itertools import accumulate\nfrom math import ceil, log,gcd\nfrom functools import lru_cache \nfrom sys import stdin, stdout\ndef read():\n return stdin.readline().rstrip()\nimport sys\nimport heapq\n\n# total = int(input())\na,b = ([int(p) for p in read().split()])\n\n# ss= read()\n# k =int(input())\n\n\n\nar = [0]*10\nbr = [0]*10\n\nfor z in [2,3,5]:\n t =a\n while t %z==0:\n t = t//z\n ar[z] +=1\n \n\nfor z in [2,3,5]:\n t =b\n while t %z==0:\n t = t//z\n br[z] +=1\n \n \ns = 0\nfor i in range(9):\n while ar[i] > br[i]:\n s+=1\n a = a//i\n ar[i] -=1\n while ar[i] < br[i]:\n s+=1\n b = b//i\n br[i] -=1 \nif a==b:\n print(s) \nelse:\n print(-1) ", "import sys\r\nfrom collections import defaultdict\r\nimport math\r\nfrom functools import reduce\r\n\r\n\r\nVALID = {2, 3, 5}\r\n\r\ndef main() -> None:\r\n read = sys.stdin.readline\r\n a, b = (int(i) for i in read().split())\r\n if a == b:\r\n print(0)\r\n return\r\n valid_factors_a = [0] * len(VALID)\r\n for i, x in enumerate(VALID):\r\n while a % x == 0:\r\n a //= x\r\n valid_factors_a[i] += 1\r\n\r\n valid_factors_b = [0] * len(VALID)\r\n for i, x in enumerate(VALID):\r\n while b % x == 0:\r\n b //= x\r\n valid_factors_b[i] += 1\r\n\r\n if a != b:\r\n print(-1)\r\n else:\r\n total_cost = 0\r\n for i in range(len(VALID)):\r\n total_cost += abs(valid_factors_a[i] - valid_factors_b[i])\r\n print(total_cost)\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "t=1\r\nfor _ in range(t):\r\n inp=list(map(int,input().split()))\r\n a,b=inp[0], inp[1]\r\n a2=0\r\n a3=0\r\n a5=0\r\n while(a%2==0):\r\n a2+=1\r\n a=a//2\r\n while(a%3==0):\r\n a3+=1\r\n a=a//3\r\n while(a%5==0):\r\n a5+=1\r\n a=a//5\r\n b2=0\r\n b3=0\r\n b5=0\r\n while(b%2==0):\r\n b2+=1\r\n b=b//2\r\n while(b%3==0):\r\n b3+=1\r\n b=b//3\r\n while(b%5==0):\r\n b5+=1\r\n b=b//5\r\n if(a!=b):\r\n print(-1)\r\n else:\r\n ans=abs(a2-b2)+abs(a3-b3)+abs(a5-b5)\r\n print(ans)", "from math import gcd, sqrt\r\nfrom math import log\r\nfrom os import path\r\n\r\ndef factorization235(n):\r\n c,result = 0,1\r\n while n % 2 == 0:\r\n n /= 2; c += 1;\r\n while n % 3 == 0:\r\n n /= 3; c += 1\r\n while n % 5 == 0:\r\n n /= 5; c += 1\r\n if n != 1: return -1\r\n return c\r\n\r\na,b = map(int,input().split(' '))\r\npath1,path2,div = 0,0,True\r\nif a == b: pass\r\nelse:\r\n target = gcd(a,b)\r\n path1 = a / target; path2 = b / target\r\n if path1 != 1:\r\n path1 = factorization235(path1)\r\n if path1 == -1: div = False\r\n else: path1 = 0\r\n if path2 != 1:\r\n path2 = factorization235(path2)\r\n if path2 == -1: div = False\r\n else: path2 = 0\r\nif div: print(int(path1 + path2))\r\nelse: print(-1)\r\n\r\n'''\r\nIf we want to reach the same number decreasing a and b by\r\ndivision we have to check for GCD(a,b). GCD because our goal is also \r\nto minimize the number of operations, so we target the first \r\ncommon number like that.\r\n\r\nIf we are confident that both numbers will meet each other\r\nat GCD and not earlier than we should just figure out the shortest \"div\" path\r\nfrom both numbers to GCD and sum it up.\r\nIf it's impossible to reach GCD with \r\nproblem div conditions from any num than return -1.\r\n\r\nOperations: if you divide (a,b) / GCD(a,b) you will get the path which you have to \r\ndecrease by the division to get to GCD(a,b) from a or b. Division is only allowed by 2,3,5.\r\nThe goal here is to construct this division only from these numbers, to do that we will\r\ndo prime factorization for only 2,3,5. Number of prime factors will be the number of operations.\r\n'''", "m,n=map(int,input().split())\r\na2,b2,a3,b3,a5,b5=0,0,0,0,0,0\r\nwhile m%2==0:\r\n m//=2\r\n a2+=1\r\nwhile m%3==0:\r\n m//=3\r\n a3+=1\r\nwhile m%5==0:\r\n m//=5\r\n a5+=1\r\nwhile n%2==0:\r\n n//=2\r\n b2+=1\r\nwhile n%3==0:\r\n n//=3\r\n b3+=1\r\nwhile n%5==0:\r\n n//=5\r\n b5+=1\r\nif m==n:\r\n print(abs(a2-b2)+abs(a3-b3)+abs(a5-b5))\r\nelse:\r\n print(-1)", "def prime_factors(n):\r\n i = 2\r\n factors = []\r\n while i * i <= n:\r\n if n % i:\r\n i += 1\r\n else:\r\n n //= i\r\n factors.append(i)\r\n if n > 1:\r\n factors.append(n)\r\n return factors\r\n\r\n\r\ndef main():\r\n a, b = map(int, input().split())\r\n\r\n if a == b:\r\n print(0)\r\n else:\r\n pr_a = prime_factors(a)\r\n pr_b = prime_factors(b)\r\n\r\n\r\n for i in pr_a:\r\n if i not in pr_b and i not in (2, 3, 5):\r\n print(-1)\r\n exit()\r\n\r\n for i in pr_b:\r\n if i not in pr_a and i not in (2, 3, 5):\r\n print(-1)\r\n exit()\r\n\r\n\r\n ans = 0\r\n for i in list(set(pr_a + pr_b)):\r\n ca = pr_a.count(i)\r\n cb = pr_b.count(i)\r\n if ca == 0 and cb > 0:\r\n ans += cb\r\n elif ca > 0 and cb == 0:\r\n ans += ca\r\n elif ca > cb:\r\n ans += ca - cb\r\n elif ca < cb:\r\n ans += cb - ca\r\n\r\n print(ans)\r\n\r\n\r\nmain()", "#dividing by 2 and 3 and 5 maeans subtracrting the powers\r\nfrom math import gcd\r\na,b=map(int,input().split())\r\nc=gcd(a,b);a=a//c;b=b//c;ans=0\r\nfor i in [2,3,5]:\r\n x=0;y=0\r\n while a%i==0:x+=1;a=a//i\r\n while b%i==0:y+=1;b=b//i\r\n ans+=abs(x-y)\r\nif a!=b:print(-1)\r\nelse:print(ans)\r\n", "def gcd(a, b):\r\n if a == 0:\r\n return b\r\n\r\n return gcd(b % a, a)\r\na,b=map(int,input().split())\r\nres=gcd(a,b)\r\nif(a==b):\r\n print(0)\r\nelse:\r\n a//=res\r\n b//=res\r\n temp=[2,3,5]\r\n ans=0\r\n\r\n while(a%2==0):\r\n a//=2\r\n ans+=1\r\n while(b%2==0):\r\n b//=2\r\n ans+=1\r\n while (a % 3 == 0):\r\n a //= 3\r\n ans += 1\r\n while (b % 3 == 0):\r\n b //= 3\r\n ans += 1\r\n while (a % 5 == 0):\r\n a //= 5\r\n ans += 1\r\n while (b % 5 == 0):\r\n b //= 5\r\n ans += 1\r\n if(a==1 and b==1):\r\n print(ans)\r\n else:\r\n print(-1)", "import math\na,b=map(int,input().split(\" \"))\nmaximo=math.gcd(a,b)\na=a//maximo\nb=b//maximo\nc=a*b\nresp=0\ndivisores=[2,3,5]\nfor i in divisores:\n while c%i==0:\n resp+=1\n if i==2:\n c=c//2\n elif i==3:\n c=c//3\n elif i==5:\n c=c//5\nif c==1:\n print(resp)\nelse:\n print(\"-1\")\n\n\t \t \t \t\t \t\t \t\t \t\t \t \t\t\t \t", "def main():\r\n a, b = list(map(int, input().split()))\r\n a2, a3, a5, b2, b3, b5 = 0, 0, 0, 0, 0, 0\r\n while(True):\r\n c = 0\r\n if (a % 2 == 0): a, a2, c = a // 2, a2 + 1, 1\r\n if (a % 3 == 0): a, a3, c = a // 3, a3 + 1, 1\r\n if (a % 5 == 0): a, a5, c = a // 5, a5 + 1, 1\r\n\r\n if (b % 2 == 0): b, b2, c = b // 2, b2 + 1, 1\r\n if (b % 3 == 0): b, b3, c = b // 3, b3 + 1, 1\r\n if (b % 5 == 0): b, b5, c = b // 5, b5 + 1, 1\r\n if not c: break\r\n\r\n if (a != b):\r\n print(-1)\r\n return\r\n print(abs(a2 - b2) + abs(a3 - b3) + abs(a5 - b5))\r\n\r\nif __name__ == '__main__':\r\n main()", "a, b = map(int, input().split()) \r\nans = 0\r\nfor i in (2, 3, 5):\r\n while a%i == 0 and b%i == 0:\r\n a //= i; b //= i\r\n while a%i == 0:\r\n a //= i; ans += 1\r\n while b%i==0:\r\n b //= i; ans += 1\r\nprint(ans if a==b else -1)", "import math\r\na,b=map(int,input().split())\r\ng=math.gcd(a,b)\r\nq=0\r\nc=[0,0,0]\r\nr=0\r\nwhile r==0:\r\n r=1\r\n if b%5==0:\r\n b//=5\r\n c[2]+=1\r\n r=0\r\n if b%3==0:\r\n b//=3\r\n c[1]+=1\r\n r=0\r\n if b%2==0:\r\n b//=2\r\n c[0]+=1\r\n r=0\r\nr=0\r\nc1=[0,0,0]\r\nwhile r==0:\r\n r=1\r\n if a%5==0:\r\n a//=5\r\n c1[2]+=1\r\n r=0\r\n if a%3==0:\r\n a//=3\r\n c1[1]+=1\r\n r=0\r\n if a%2==0:\r\n a//=2\r\n c1[0]+=1\r\n r=0\r\nif a!=b:\r\n print(-1)\r\nelse:\r\n print(abs(c1[0]-c[0])+abs(c1[1]-c[1])+abs(c1[2]-c[2]))", "from math import gcd\r\na,b = map(int, input().split())\r\ng = gcd(a, b)\r\nax = a//g\r\nop=0\r\nwhile ax %2==0:\r\n ax //= 2\r\n op+=1\r\nwhile ax %3 == 0:\r\n ax //= 3\r\n op+=1\r\nwhile ax %5 ==0:\r\n ax //= 5\r\n op+=1\r\nbx=b//g\r\nwhile bx %2==0:\r\n bx //= 2\r\n op+=1\r\nwhile bx %3 == 0:\r\n bx //= 3\r\n op+=1\r\nwhile bx %5 ==0:\r\n bx //= 5\r\n op+=1\r\nif ax <= 1 and bx <= 1:\r\n print(op)\r\nelse:\r\n print(-1)", "\"\"\"B - Fox Dividing Cheese\"\"\"\n\na, b = map(int, input().split())\n\ndiv = [2, 3, 5]\nop = 0\nif a >= 1 and b <= 1E+10:\n if a == b:\n print(op)\n else:\n for i in div:\n while a % i == 0 and b % i == 0:\n a = a / i\n b = b / i\n while a % i == 0:\n a = a / i\n op += 1\n while b % i == 0:\n b = b / i\n op += 1\n if a == b:\n print(op)\n else:\n print(-1)\nelse:\n print(\"Error\")\n\n\n\n", "a,b=map(int,input().split())\r\nif(a==b):\r\n print(\"0\")\r\nelse:\r\n def div(n):\r\n #sprint(n)\r\n a1,a2,a3=0,0,0\r\n while(n%5==0):\r\n n=n//5\r\n #print(n)\r\n a1=a1+1\r\n \r\n while(n%3==0):\r\n n=n//3\r\n a2=a2+1\r\n while(n%2==0):\r\n n=n//2\r\n a3=a3+1\r\n #print(n)\r\n return n,a1,a2,a3\r\n \r\n \r\n \r\n a,a1,b2,c=div(a)\r\n #print(\"lo\")\r\n b,d,e,f=div(b)\r\n co=abs(a1-d)+abs(b2-e)+abs(c-f)\r\n if(a!=b):\r\n print(\"-1\")\r\n else:\r\n print(co)\r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n \r\n \r\n", "a, b = map(int, input().split())\r\nres = 0\r\n\r\nfor x in (2, 3, 5):\r\n\twhile a % x == 0 and b % x == 0:\r\n\t\ta //= x\r\n\t\tb //= x\r\n\twhile a % x == 0:\r\n\t\ta //= x\r\n\t\tres += 1\r\n\twhile b % x == 0:\r\n\t\tb //= x\r\n\t\tres += 1\r\n\r\nif a == b:\r\n\tprint(res)\r\nelse:\r\n\tprint(-1)", "ans = 0\r\na, b = map (int, input ().split())\r\nfor j in [2, 3, 5] :\r\n\twhile a % j == 0 and b % j == 0:\r\n\t\ta //= j\r\n\t\tb //= j\r\n\twhile a % j == 0 :\r\n\t\ta //= j\r\n\t\tans += 1\r\n\twhile b % j == 0 :\r\n\t\tb //= j\r\n\t\tans += 1\r\nif a != b :\r\n\tprint (-1)\r\nelse :\r\n\tprint (ans)\r\n", "import math\r\n#n=int(input())\r\nn,m = map(int, input().strip().split(' '))\r\n#lst = list(map(int, input().strip().split(' ')))\r\nif n>m:\r\n n,m=m,n\r\nif n==m:\r\n print(0)\r\nelse:\r\n p2=0\r\n p3=0\r\n p5=0\r\n p22=0\r\n p33=0\r\n p55=0\r\n while(True):\r\n if m%2==0:\r\n p2+=1\r\n m=m//2\r\n elif m%3==0:\r\n p3+=1\r\n m=m//3\r\n elif m%5==0:\r\n p5+=1\r\n m=m//5\r\n else:\r\n break\r\n while(True):\r\n if n%2==0:\r\n p22+=1\r\n n=n//2\r\n elif n%3==0:\r\n p33+=1\r\n n=n//3\r\n elif n%5==0:\r\n p55+=1\r\n n=n//5\r\n else:\r\n break\r\n if n!=1 or m!=1:\r\n if m%n!=0:\r\n print(-1)\r\n else:\r\n k1=m//n\r\n if math.log10(k1)/ math.log10(2) % 1 == 0 or math.log10(k1)/ math.log10(5) % 1 == 0 or math.log10(k1)/ math.log10(3) % 1 == 0:\r\n if math.log10(k1)/ math.log10(2) % 1 == 0:\r\n print(abs(p2-p22)+abs(p5-p55)+abs(p3-p33)+int(math.log10(k1)/ math.log10(2)))\r\n elif math.log10(k1)/ math.log10(3) % 1 == 0:\r\n print(abs(p2-p22)+abs(p5-p55)+abs(p3-p33)+int(math.log10(k1)/ math.log10(3)))\r\n elif math.log10(k1)/ math.log10(5) % 1 == 0:\r\n print(abs(p2-p22)+abs(p5-p55)+abs(p3-p33)+int(math.log10(k1)/ math.log10(5)))\r\n else:\r\n print(-1)\r\n else:\r\n print(abs(p2-p22)+abs(p5-p55)+abs(p3-p33))\r\n \r\n \r\n \r\n", "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[:len(s) - 1]))\ndef invr():\n return(map(int,input().split()))\n\nq = inlt()\na = q[0]\nb = q[1]\n\nsum = 0\n\nfor i in ([2,3,5]):\n ct1 = 0\n ct2 = 0\n while(a%i == 0):\n ct1 = ct1 + 1\n a = a // i\n while (b % i == 0):\n ct2 = ct2 + 1\n b = b // i\n sum = sum + abs(ct1-ct2)\n\nif(a == b):\n print(sum)\nelse:\n print(-1)\n\n", "a = list(map(int,input().strip().split()))\r\nx,y=a\r\nif x==y:\r\n print(0)\r\nelse:\r\n a,b=[0,0,0],[0,0,0]\r\n opt=0\r\n while x>1:\r\n if x%2==0:\r\n x=x//2\r\n a[0]+=1\r\n elif x%3==0:\r\n x=x//3\r\n a[1]+=1\r\n elif x%5==0:\r\n x=x//5\r\n a[2]+=1\r\n else:\r\n break\r\n if y%x!=0:\r\n print(-1)\r\n else:\r\n y=y//x\r\n while y>1:\r\n if y%2==0:\r\n y=y//2\r\n b[0]+=1\r\n elif y%3==0:\r\n y=y//3\r\n b[1]+=1\r\n elif y%5==0:\r\n y=y//5\r\n b[2]+=1\r\n else:\r\n break\r\n if y!=1:\r\n print(-1)\r\n else:\r\n print(max(a[0]-b[0],b[0]-a[0])+max(a[1]-b[1],b[1]-a[1])+max(a[2]-b[2],b[2]-a[2]))\r\n\r\n", "import math\r\nimport random \r\nfrom queue import Queue\r\nimport time \r\n\r\n\r\ndef bd(n,m):\r\n\r\n ans=0\r\n\r\n while n//m==n/m :\r\n ans+=1 \r\n n//=m \r\n\t\r\n return n,ans\r\ndef main(a,b):\r\n\r\n \r\n s2=bd(a,2)\r\n \r\n s3=bd(s2[0],3)\r\n\r\n s5=bd(s3[0],5)\r\n\r\n t2=bd(b,2)\r\n\r\n t3=bd(t2[0],3)\r\n\r\n t5=bd(t3[0],5)\r\n\r\n if s5[0]!=t5[0]:\r\n return -1 \r\n \r\n else:\r\n return abs(t2[1]-s2[1])+abs(t3[1]-s3[1])+abs(t5[1]-s5[1])\r\n\r\na,b=list(map(int,input().split()))\r\nprint(main(a,b))\r\n ", "from math import gcd\n\n\ndef factorize(n):\n count = [0, 0, 0]\n while n != 1:\n if (n & 1) == 0:\n count[0] += 1\n n //= 2\n elif n % 3 == 0:\n count[1] += 1\n n //= 3\n elif n % 5 == 0:\n n //= 5\n count[2] += 1\n else:\n break\n return count, n\n\n\ndef diff(x, y):\n total = 0\n for a, b in zip(x, y):\n total += abs(a - b)\n return total\n\n\ndef main():\n a, b = map(int, input().split(\" \"))\n if a == b:\n return 0\n\n x,rem1 = factorize(a)\n y, rem2 = factorize(b)\n\n if rem1 != rem2:\n return -1\n else:\n return diff(x, y)\n\n\nprint(main())\n", "m,n=map(int,input().split())\r\na=[0]*3\r\nb=[0]*3\r\nwhile m%2==0 or m%3==0 or m%5==0:\r\n if m%2==0:\r\n a[0]+=1\r\n m=m/2\r\n elif m%3==0:\r\n a[1]+=1\r\n m=m/3\r\n elif m%5==0:\r\n a[2]+=1\r\n m=m/5\r\nwhile n%2==0 or n%3==0 or n%5==0:\r\n if n%2==0:\r\n b[0]+=1\r\n n=n/2\r\n elif n%3==0:\r\n b[1]+=1\r\n n=n/3\r\n elif n%5==0:\r\n b[2]+=1\r\n n=n/5\r\nif m!=n: print(-1)\r\nelse:\r\n print(abs(a[0]-b[0])+abs(a[1]-b[1])+abs(a[2]-b[2]))\r\n \r\n\r\n\r\n", "def get_part(a):\n temp = {'qq': 0, 'q1': 0, 'q2': 0, 'q3': 0}\n tmp = 0\n while a % 2 == 0:\n tmp += 1\n a = a // 2\n temp['q1'] = tmp\n tmp = 0\n while a % 3 == 0:\n tmp += 1\n a = a // 3\n temp['q2'] = tmp\n tmp = 0\n while a % 5 == 0:\n tmp += 1\n a = a // 5\n temp['q3'] = tmp\n temp['qq'] = a\n return temp\n\na, b = map(int, input().split())\naa = get_part(a)\nbb = get_part(b)\n\nif aa['qq'] != bb['qq']:\n print(\"-1\")\nelse:\n print(abs(aa['q1'] - bb['q1']) + abs(aa['q2'] - bb['q2']) + abs(aa['q3'] - bb['q3']))\n\n\t \t\t\t \t\t \t\t\t\t \t\t\t\t\t\t\t\t \t", "a, b = map(int, input().split())\n\n\na_d = [0]*4\nb_d = [0]*4\n\n\ndiv = 2\n\nwhile div <= 5:\n if div == 4:\n div += 1\n continue\n if a % div == 0:\n a_d[div-2] += 1\n a //= div\n else:\n div += 1\n \ndiv = 2\n\nwhile div <= 5:\n if div == 4:\n div += 1\n continue\n if b % div == 0:\n b_d[div-2] += 1\n b //= div\n else:\n div += 1\n\nif a != b:\n print(-1)\nelse:\n print(sum(abs(a_d[i] - b_d[i]) for i in range(4)))", "a, b = map(int,input().split(' '))\r\n\r\naMap = {}\r\nbMap = {}\r\ng = [2, 3, 5]\r\nfor i in g:\r\n aMap[i] = 0\r\n bMap[i] = 0\r\nflag = 0\r\nans = 0\r\nfor i in g:\r\n while a % i == 0:\r\n a = a // i\r\n aMap[i] += 1 \r\n while b % i == 0:\r\n b = b // i\r\n bMap[i] += 1 \r\nfor i in g:\r\n ans += abs(aMap[i] - bMap[i])\r\n\r\nif a != b:\r\n print(-1)\r\nelse: \r\n print(ans)", "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\nfrom bisect import bisect_right as br,bisect_left as bl\r\nimport heapq\r\n\r\ndef pf(n):\r\n\td = dd(lambda:0)\r\n\twhile n%2==0:\r\n\t\td[2]+=1\r\n\t\tn//=2\r\n\ti=3\r\n\twhile i*i<=n:\r\n\t\tif n%i==0:\r\n\t\t\td[i]+=1\r\n\t\t\tn//=i\r\n\t\telse:\r\n\t\t\ti+=1\r\n\tif n>2:\r\n\t\td[n]+=1\r\n\treturn dict(d)\r\n\t\t\r\nn,m = mp()\r\n\r\nc = pf(n)\r\nd = pf(m)\r\n\r\nx = list(set(list(c.keys()) + list(d.keys())))\r\n\r\nans=0\r\nt = set()\r\nt.update({2,3,5})\r\nfor i in x:\r\n\r\n\tif i in c and i in d:\r\n\t# if d[i] and c[i]:\r\n\t\tif d[i] == c[i]:\r\n\t\t\tpass\r\n\t\telse:\r\n\t\t\tif i not in t:\r\n\t\t\t\tprint(-1)\r\n\t\t\t\texit()\r\n\t\t\telse:\r\n\t\t\t\tans += max(c[i],d[i]) - min(c[i],d[i])\r\n\telif i in c:\r\n\t\tif i not in t:\r\n\t\t\t\tprint(-1)\r\n\t\t\t\texit()\r\n\t\telse:\r\n\t\t\tans += c[i]\r\n\telif i in d:\r\n\t\tif i not in t:\r\n\t\t\t\tprint(-1)\r\n\t\t\t\texit()\r\n\t\telse:\r\n\t\t\tans += d[i]\r\nprint(ans)\r\n\r\n", "from sys import stdin\r\ninp = stdin.readline\r\n\r\na, b = map(int, inp().split())\r\nc = {2: 0, 3: 0, 5: 0}\r\n\r\nfor i in {2, 3, 5}:\r\n while not a % i or not b % i:\r\n if a % i == 0:\r\n a //= i\r\n c[i] += 1\r\n if b % i == 0:\r\n b //= i\r\n c[i] -= 1\r\n\r\nif a != b:\r\n print(-1)\r\nelse:\r\n print(sum([abs(c[x]) for x in c]))\r\n" ]
{"inputs": ["15 20", "14 8", "6 6", "1 1", "1 1024", "1024 729", "1024 1048576", "36 30", "100 10", "21 35", "9900 7128", "7920 9900", "576000 972000", "691200 583200", "607500 506250", "881280 765000", "800000 729000", "792000 792000", "513600 513600", "847500 610200", "522784320 784176480", "689147136 861433920", "720212000 864254400", "673067520 807681024", "919536000 993098880", "648293430 540244525", "537814642 537814642", "100000007 800000011", "900000011 800000011", "900000011 999900017", "536870912 387420489", "820125000 874800000", "864000000 607500000", "609120000 913680000", "509607936 306110016", "445906944 528482304", "119144448 423624704", "1 1000000000", "1000000000 1", "1000000000 2", "2 1000000000", "5 1000000000", "1000000000 5", "3 1000000000", "1000000000 3", "1000000000 7", "2208870 122715", "4812500 7577955", "3303936 3097440", "55404 147744", "10332160 476643528", "21751200 43502400", "19500000 140400000", "1 22"], "outputs": ["3", "-1", "0", "0", "10", "16", "10", "3", "2", "2", "5", "3", "7", "8", "3", "9", "13", "0", "0", "5", "2", "3", "3", "3", "5", "3", "0", "-1", "-1", "-1", "47", "6", "9", "2", "24", "8", "7", "18", "18", "17", "17", "17", "17", "19", "19", "-1", "3", "16", "6", "4", "19", "1", "5", "-1"]}
UNKNOWN
PYTHON3
CODEFORCES
124
e4bdedea4ab7fc642876b9b634d8943e
Road Improvement
The country has *n* cities and *n*<=-<=1 bidirectional roads, it is possible to get from every city to any other one if you move only along the roads. The cities are numbered with integers from 1 to *n* inclusive. All the roads are initially bad, but the government wants to improve the state of some roads. We will assume that the citizens are happy about road improvement if the path from the capital located in city *x* to any other city contains at most one bad road. Your task is — for every possible *x* determine the number of ways of improving the quality of some roads in order to meet the citizens' condition. As those values can be rather large, you need to print each value modulo 1<=000<=000<=007 (109<=+<=7). The first line of the input contains a single integer *n* (2<=≤<=*n*<=≤<=2·105) — the number of cities in the country. Next line contains *n*<=-<=1 positive integers *p*2,<=*p*3,<=*p*4,<=...,<=*p**n* (1<=≤<=*p**i*<=≤<=*i*<=-<=1) — the description of the roads in the country. Number *p**i* means that the country has a road connecting city *p**i* and city *i*. Print *n* integers *a*1,<=*a*2,<=...,<=*a**n*, where *a**i* is the sought number of ways to improve the quality of the roads modulo 1<=000<=000<=007 (109<=+<=7), if the capital of the country is at city number *i*. Sample Input 3 1 1 5 1 2 3 4 Sample Output 4 3 35 8 9 8 5
[ "import sys\r\nMODULO = int(1e9) + 7\r\ndef solve(n, p, out_stream):\r\n prod = [1] * n\r\n modpow = [0] * n\r\n for i in range(n - 1, 0, -1):\r\n j = p[i]\r\n if modpow[i] == 0 and prod[i] + 1 == MODULO:\r\n modpow[j] += 1\r\n else:\r\n prod[j] = (prod[j] * ((prod[i] if modpow[i] == 0 else 0) + 1)) % MODULO \r\n if modpow[0] == 0:\r\n out_stream.write(str(prod[0]))\r\n else:\r\n out_stream.write(\"0\")\r\n for i in range(1, n):\r\n j = p[i]\r\n pr = prod[j]\r\n prpow = modpow[j]\r\n if modpow[i] == 0 and prod[i] + 1 == MODULO:\r\n prpow -= 1\r\n else:\r\n pr = (pr * pow((prod[i] if modpow[i] == 0 else 0) + 1, MODULO - 2, MODULO)) % MODULO\r\n if prpow > 0:\r\n pr = 0\r\n if pr + 1 == MODULO:\r\n modpow[i] += 1\r\n else:\r\n prod[i] = (prod[i] * (pr + 1)) % MODULO\r\n out_stream.write(' ')\r\n if modpow[i] == 0:\r\n out_stream.write(str(prod[i]))\r\n else:\r\n out_stream.write(\"0\")\r\n out_stream.write(\"\\n\")\r\ndef inv(x):\r\n if x == 1:\r\n return 1\r\n return pow(x, MODULO - 2, MODULO)\r\ndef pow(x, k, MOD):\r\n if k == 0:\r\n return 1\r\n if k % 2 == 0:\r\n return pow((x * x) % MOD, k // 2, MOD)\r\n return (x * pow(x, k - 1, MOD)) % MOD\r\ndef main():\r\n try:\r\n while True:\r\n n = int(input())\r\n p = [-1] + [int(x) - 1 for x in input().split()]\r\n solve(n, p, sys.stdout)\r\n except EOFError:\r\n pass\r\nif __name__ == \"__main__\":\r\n main()# 1692375930.364086", "import sys\r\n\r\n# import itertools\r\n# import math\r\n# import os\r\n# import random\r\n# from bisect import bisect, bisect_left\r\n# from collections import *\r\n# from functools import reduce\r\n# from heapq import heapify, heappop, heappush\r\n# from io import BytesIO, IOBase\r\n# from string import *\r\n\r\n# region fastio\r\ninput = lambda: sys.stdin.readline().rstrip()\r\nsint = lambda: int(input())\r\nmint = lambda: map(int, input().split())\r\nints = lambda: list(map(int, input().split()))\r\n# print = lambda d: sys.stdout.write(str(d) + \"\\n\")\r\n# endregion fastio\r\n\r\n# # region interactive\r\n# def printQry(a, b) -> None:\r\n# sa = str(a)\r\n# sb = str(b)\r\n# print(f\"? {sa} {sb}\", flush = True)\r\n\r\n# def printAns(ans) -> None:\r\n# s = str(ans)\r\n# print(f\"! {s}\", flush = True)\r\n# # endregion interactive\r\n\r\n# # region dfsconvert\r\n# from types import GeneratorType\r\n# def bootstrap(f, stack=[]):\r\n# def wrappedfunc(*args, **kwargs):\r\n# if stack:\r\n# return f(*args, **kwargs)\r\n# else:\r\n# to = f(*args, **kwargs)\r\n# while True:\r\n# if type(to) is GeneratorType:\r\n# stack.append(to)\r\n# to = next(to)\r\n# else:\r\n# stack.pop()\r\n# if not stack:\r\n# break\r\n# to = stack[-1].send(to)\r\n# return to\r\n# return wrappedfunc\r\n# # endregion dfsconvert\r\n\r\n# MOD = 998244353\r\nMOD = 10 ** 9 + 7\r\n# DIR = ((-1, 0), (0, 1), (1, 0), (0, -1))\r\n\r\ndef solve() -> None:\r\n n = sint()\r\n parent = [-1] + ints()\r\n\r\n tree = [[] for _ in range(n)]\r\n for i in range(1, n):\r\n tree[parent[i] - 1].append(i)\r\n \r\n dp = [1] * n\r\n for i in range(n-1, 0, -1):\r\n dp[parent[i] - 1] *= dp[i] + 1\r\n dp[parent[i] - 1] %= MOD\r\n \r\n dp_from_up = [1] * n\r\n for i in range(n):\r\n \r\n pref_mul = [1]\r\n for j in tree[i]:\r\n pref_mul.append(pref_mul[-1] * (dp[j] + 1) % MOD)\r\n \r\n suff_mul = [1]\r\n for j in reversed(tree[i]):\r\n suff_mul.append(suff_mul[-1] * (dp[j] + 1) % MOD)\r\n \r\n suff_mul.reverse()\r\n for j in range(len(tree[i])):\r\n dp_from_up[tree[i][j]] = (dp_from_up[i] * pref_mul[j] * suff_mul[j+1] + 1) % MOD\r\n \r\n print(*(x * y % MOD for x, y in zip(dp, dp_from_up)))\r\n\r\nsolve()\r\n", "# Problem: D. Road Improvement\r\n# Contest: Codeforces - Codeforces Round 302 (Div. 1)\r\n# URL: https://codeforces.com/problemset/problem/543/D\r\n# Memory Limit: 256 MB\r\n# Time Limit: 2000 ms\r\n\r\nimport sys\r\nimport random\r\nfrom types import GeneratorType\r\nimport bisect\r\nimport io, os\r\nfrom bisect import *\r\nfrom collections import *\r\nfrom contextlib import redirect_stdout\r\nfrom itertools import *\r\nfrom array import *\r\nfrom functools import lru_cache, reduce\r\nfrom heapq import *\r\nfrom math import sqrt, gcd, inf\r\n\r\nif sys.version >= '3.8': # ACW没有comb\r\n from math import comb\r\n\r\nRI = lambda: map(int, sys.stdin.buffer.readline().split())\r\nRS = lambda: map(bytes.decode, sys.stdin.buffer.readline().strip().split())\r\nRILST = lambda: list(RI())\r\nDEBUG = lambda *x: sys.stderr.write(f'{str(x)}\\n')\r\n# print = lambda d: sys.stdout.write(str(d) + \"\\n\") # 打开可以快写,但是无法使用print(*ans,sep=' ')这种语法,需要print(' '.join(map(str, p))),确实会快。\r\n\r\nDIRS = [(0, 1), (1, 0), (0, -1), (-1, 0)] # 右下左上\r\nDIRS8 = [(0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0),\r\n (-1, 1)] # →↘↓↙←↖↑↗\r\nRANDOM = random.randrange(2 ** 62)\r\nMOD = 10 ** 9 + 7\r\n# MOD = 998244353\r\nPROBLEM = \"\"\"https://codeforces.com/problemset/problem/543/D\r\n\r\n输入 n(2≤n≤2e5) 和 n-1 个数 p2,p3,...,pn,表示一棵 n 个节点的无根树,节点编号从 1 开始,i 与 pi(1≤pi≤i-1) 相连。\r\n定义 a(x) 表示以 x 为根时的合法标记方案数,模 1e9+7。其中【合法标记】定义为:对树的某些边做标记,使得 x 到任意点的简单路径上,至多有一条边是被标记的。\r\n输出 a(1),a(2),...,a(n)。\r\n输入\r\n3\r\n1 1\r\n输出\r\n4 3 3\r\n\r\n输入\r\n5\r\n1 2 3 4\r\n输出\r\n5 8 9 8 5\r\n\"\"\"\r\n\"\"\"换根 DP。不了解的同学请看右边的链接。\r\n\r\n先来计算 a(1),此时 1 为树根。\r\n定义 f(i) 表示子树 i 的合法标记方案数。\r\n对于 i 的儿子 j,考虑 i-j 这条边是否标记:\r\n- 标记:那么子树 j 的所有边都不能标记,方案数为 1。\r\n- 不标记:那么方案数就是 f(j)。\r\ni 的每个儿子互相独立,所以根据乘法原理有 \r\nf(i) = (f(j1)+1) * (f(j2)+1) * ... * (f(jm)+1)\r\n其中 j1,j2,...,jm 是 i 的儿子。\r\n\r\n然后来计算其余 a(i)。\r\n考虑把根从 i 换到 j:\r\n对于 j 来说,方案数需要在 f(j) 的基础上,再乘上【父亲 i】这棵子树的方案数,即 a(i) / (f(j)+1)。 \r\n所以 a(j) = f(j) * (a(i)/(f(j)+1) + 1)\r\n\r\n本题的一个易错点是,f(j)+1 可能等于 M=1e9+7,取模会变成 0,但是 0 没有逆元。\r\n处理方式有很多,我的做法是定义二元组 (k,x) 表示 M^k * x % M,在这基础上定义:\r\n- 乘法运算:(k1, x1) * (k2, x2) = (k1+k2, x1*x2%M)\r\n- 除法运算:(k1, x1) / (k2, x2) = (k1-k2, x1*inv(x2)%M) 这里 k1>=k2\r\n- 加一运算:请读者思考(需要分类讨论,具体见代码)\r\n\r\n当 k>0 时,(k,x) 的实际值为 0;当 k=0 时,(k,x) 的实际值为 x。\r\n\r\nhttps://codeforces.com/contest/543/submission/214621886\"\"\"\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# ms\r\ndef solve():\r\n from typing import Callable, Generic, List, TypeVar\r\n\r\n T = TypeVar(\"T\")\r\n E = Callable[[int], T]\r\n \"\"\"identify element of op, and answer of leaf\"\"\"\r\n Op = Callable[[T, T], T]\r\n \"\"\"merge value of child node\"\"\"\r\n Composition = Callable[[T, int, int, int], T]\r\n \"\"\"return value from child node to parent node\"\"\"\r\n\r\n class Rerooting(Generic[T]):\r\n __slots__ = (\"g\", \"_n\", \"_decrement\", \"_root\", \"_parent\", \"_order\")\r\n\r\n def __init__(self, n: int, decrement: int = 0, edges=None):\r\n \"\"\"\r\n n: 节点个数\r\n decrement: 节点id可能需要偏移 (1-indexed则-1, 0-indexed则0)\r\n \"\"\"\r\n self.g = g = [[] for _ in range(n)]\r\n self._n = n\r\n self._decrement = decrement\r\n self._root = None # 一开始的根\r\n if edges:\r\n for u, v in edges:\r\n u -= decrement\r\n v -= decrement\r\n g[u].append(v)\r\n g[v].append(u)\r\n\r\n def add_edge(self, u: int, v: int):\r\n \"\"\"\r\n 无向树加边\r\n \"\"\"\r\n u -= self._decrement\r\n v -= self._decrement\r\n self.g[u].append(v)\r\n self.g[v].append(u)\r\n\r\n def rerooting(\r\n self, e: E[\"T\"], op: Op[\"T\"], composition: Composition[\"T\"], root=0\r\n ) -> List[\"T\"]:\r\n \"\"\"\r\n - e: 初始化每个节点的价值\r\n (root) -> res\r\n mergeの単位元\r\n 例:求最长路径 e=0\r\n\r\n - op: 两个子树答案如何组合或取舍\r\n (childRes1,childRes2) -> newRes\r\n 例:求最长路径 return max(childRes1,childRes2)\r\n\r\n - composition: 知道子子树答案和节点值,如何更新子树答案\r\n (from_res,fa,u,use_fa) -> new_res\r\n use_fa: 0表示用u更新fa的dp1,1表示用fa更新u的dp2\r\n 例:最长路径return from_res+1\r\n\r\n - root: 可能要设置初始根,默认是0\r\n <概要> 换根DP模板,用线性时间获取以每个节点为根整颗树的情况。\r\n 注意最终返回的dp[u]代表以u为根时,u的所有子树的最优情况(不包括u节点本身),因此如果要整颗子树情况,还要再额外计算。\r\n 1. 记录dp1,dp2。其中:\r\n dp1[u] 代表 以u为根的子树,它的孩子子树的最优值,即u节点本身不参与计算。注意,和我们一般定义的f[u]代表以u为根的子树2情况不同。\r\n dp2[v] 代表 除了v以外,它的兄弟子树的最优值。依然注意,v不参与,同时u也不参与(u是v的父节点)。\r\n 建议画图理解。\r\n 2. dp2[v]的含义后边将进行一次变动,变更为v的兄弟、u的父过来的路径,merge上u节点本身最后得出来的值。即v以父亲为邻居向外延伸的最优值(不含v,但含父)。\r\n 3. 同时dp1[u]的含义更新为目标的含义:以u为根,u的子节点们所在子树的最优情况。\r\n 4. 这样dp1,dp2将分别代表u的向下子树的最优,u除了向下子树以外的最优(一定从父节点来,但父节点可能从兄弟来或祖宗来)\r\n <步骤>\r\n 1. 先从任意root出发(一般是0),获取bfs层序。这里是为了方便dp,或者直接dfs树形DP其实也是可以的,但可能会爆栈。\r\n 2. 自底向上dp,用自身子树情况更新dp1,除自己外的兄弟子树情况更新dp2。\r\n 3. 自顶向下dp,变更dp2和dp1的含义。这时对于u来说存在三种子树(强烈建议画图观察):\r\n ① u本身的子树,它们的最优解已经存在于之前的dp1[u]。\r\n ② u的兄弟子树+fa,它们的最优解=composition(dp2[u],fa,u,use_fa=1)。\r\n ③ 连接到fa的最优子树+fa,最优解=composition(dp2[fa],fa,u,use_fa=1)。\r\n 注意这里的dp2含义已变更,由于我们是自顶向下计算,因此dp2[fa]已更新。\r\n ②和③可以写一起来更新dp2[u]\r\n\r\n 計算量 O(|V|) (Vは頂点数)\r\n 参照 https://qiita.com/keymoon/items/2a52f1b0fb7ef67fb89e\r\n \"\"\"\r\n # step1\r\n root -= self._decrement\r\n assert 0 <= root < self._n\r\n self._root = root\r\n g = self.g\r\n _fas = self._parent = [-1] * self._n # 记录每个节点的父节点\r\n _order = self._order = [root] # bfs记录遍历层序,便于后续dp\r\n q = deque([root])\r\n while q:\r\n u = q.popleft()\r\n for v in g[u]:\r\n if v == _fas[u]:\r\n continue\r\n _fas[v] = u\r\n _order.append(v)\r\n q.append(v)\r\n\r\n # step2\r\n dp1 = [e(i) for i in range(self._n)] # !子树部分的dp值,假设u是当前子树的根,vs是第一层儿子(它的非父邻居),则dp1[u]=op(dp1(vs))\r\n dp2 = [e(i) for i in\r\n range(\r\n self._n)] # !非子树部分的dp值,假设u是当前子树的根,vs={v1,v2..vi..}是第一层儿子(它的非父邻居),则dp2[vi]=op(dp1(vs-vi)),即他的兄弟们\r\n\r\n for u in _order[::-1]: # 从下往上拓扑序dp\r\n res = e(u)\r\n for v in g[u]:\r\n if _fas[u] == v:\r\n continue\r\n dp2[v] = res\r\n res = op(res, composition(dp1[v], u, v, 0)) # op从下往上更新dp1\r\n # 由于最大可能在后边,因此还得倒序来一遍\r\n res = e(u)\r\n for v in g[u][::-1]:\r\n if _fas[u] == v:\r\n continue\r\n dp2[v] = op(res, dp2[v])\r\n res = op(res, composition(dp1[v], u, v, 0))\r\n dp1[u] = res\r\n\r\n # step3 自顶向下计算每个节点作为根时的dp1,dp2的含义变更为:dp2[u]为u的兄弟+父。这样对v来说dp1[u] = op(dp1[fa],dp1[u])\r\n\r\n for u in _order[1:]:\r\n fa = _fas[u]\r\n dp2[u] = composition(\r\n op(dp2[u], dp2[fa]), fa, u, 1\r\n ) # op从上往下更新dp2\r\n dp1[u] = op(dp1[u], dp2[u])\r\n\r\n return dp1\r\n\r\n n, = RI()\r\n a = RILST()\r\n r = Rerooting(n)\r\n for i, p in enumerate(a, start=1):\r\n r.add_edge(i, p - 1)\r\n\r\n def e(root: int) -> int:\r\n # 转移时单个点不管相邻子树的贡献\r\n # 例:最も遠い点までの距離を求める場合 e=0\r\n return 1\r\n\r\n def op(child_res1: int, child_res2: int) -> int:\r\n # 如何组合/取舍两个子树的答案\r\n # 例:求最长路径 return max(childRes1,childRes2)\r\n return (child_res1) * (child_res2) % MOD\r\n\r\n def composition(from_res: int, fa: int, u: int, use_fa: int = 0) -> int:\r\n # 知道子树的每个子树和节点值,如何更新子树答案;\r\n # 例子:求最长路径 return from_res+1\r\n return (1 + from_res) % MOD\r\n\r\n ans = r.rerooting(e, op, composition)\r\n print(' '.join(map(str, ans)))\r\n\r\n\r\n# 0么有逆元 ms\r\ndef solvewa():\r\n n, = RI()\r\n a = RILST()\r\n g = [[] for _ in range(n)]\r\n for i, p in enumerate(a, start=1):\r\n g[i].append(p - 1)\r\n g[p - 1].append(i)\r\n\r\n down = [1] * n # 每个节点向下子树至少画一下的方案数\r\n\r\n @bootstrap\r\n def dfs(u, fa):\r\n for v in g[u]:\r\n if v == fa: continue\r\n yield dfs(v, u)\r\n down[u] = down[u] * (1 + down[v]) % MOD + MOD\r\n yield\r\n\r\n dfs(0, -1)\r\n # print(g)\r\n ans = down[:]\r\n\r\n @bootstrap\r\n def reroot(u, fa):\r\n for v in g[u]:\r\n if v == fa: continue\r\n # ans[v] = (ans[u] // (down[v] + 1) + 1) * down[v]\r\n ans[v] = (ans[u] * pow(down[v] + 1, MOD - 2, MOD) + 1) * down[v] % MOD + MOD\r\n yield reroot(v, u)\r\n yield\r\n\r\n reroot(0, -1)\r\n\r\n print(' '.join(map(str, ans)))\r\n\r\n\r\nif __name__ == '__main__':\r\n t = 0\r\n if t:\r\n t, = RI()\r\n for _ in range(t):\r\n solve()\r\n else:\r\n solve()\r\n", "\r\nn = int(input())\r\np = list(map(int, input().split()))\r\nmod = 10 ** 9 + 7\r\ng = [[] for _ in range(n)]\r\nfor i in range(n - 1):\r\n g[p[i] - 1].append(i + 1)\r\n g[i + 1].append(p[i] - 1)\r\n\r\ncount = [[0, 1] for _ in range(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\n\r\ndef mul(x, y):\r\n e1, x1 = x\r\n e2, x2 = y\r\n if e2 > 0:\r\n return [e1, x1]\r\n elif x2 + 1 == mod:\r\n return [e1 + 1, x1]\r\n else:\r\n return [e1, x1 * (x2 + 1) % mod]\r\n\r\n\r\ndef div(x, y):\r\n e1, x1 = x\r\n e2, x2 = y\r\n if e2 > 0:\r\n return [e1, x1]\r\n elif x2 + 1 == mod:\r\n return [e1 - 1, x1]\r\n else:\r\n return [e1, x1 * pow(x2 + 1, mod - 2, mod) % mod]\r\n\r\n\r\n@bootstrap\r\ndef dfs1(son, fa):\r\n for x in g[son]:\r\n if x != fa:\r\n yield dfs1(x, son)\r\n count[son] = mul(count[son], count[x])\r\n yield\r\n\r\n\r\ndfs1(0, -1)\r\n\r\nans = [[0, 1] for _ in range(n)]\r\n\r\n\r\n@bootstrap\r\ndef dfs2(son, fa, from_fa):\r\n ans[son] = mul(count[son], from_fa)\r\n for x in g[son]:\r\n if x != fa:\r\n yield dfs2(x, son, div(ans[son], count[x]))\r\n yield\r\n\r\n\r\ndfs2(0, -1, [0, 0])\r\nprint(*[x[1] if x[0] == 0 else 0 for x in ans])", "import sys\r\nreadline=sys.stdin.readline\r\n\r\nclass Graph:\r\n def __init__(self,V,edges=False,graph=False,directed=False,weighted=False,inf=float(\"inf\")):\r\n self.V=V\r\n self.directed=directed\r\n self.weighted=weighted\r\n self.inf=inf\r\n if graph:\r\n self.graph=graph\r\n self.edges=[]\r\n for i in range(self.V):\r\n if self.weighted:\r\n for j,d in self.graph[i]:\r\n if self.directed or not self.directed and i<=j:\r\n self.edges.append((i,j,d))\r\n else:\r\n for j in self.graph[i]:\r\n if self.directed or not self.directed and i<=j:\r\n self.edges.append((i,j))\r\n else:\r\n self.edges=edges\r\n self.graph=[[] for i in range(self.V)]\r\n if weighted:\r\n for i,j,d in self.edges:\r\n self.graph[i].append((j,d))\r\n if not self.directed:\r\n self.graph[j].append((i,d))\r\n else:\r\n for i,j in self.edges:\r\n self.graph[i].append(j)\r\n if not self.directed:\r\n self.graph[j].append(i)\r\n\r\n def SIV_DFS(self,s,bipartite_graph=False,cycle_detection=False,directed_acyclic=False,euler_tour=False,linked_components=False,lowlink=False,parents=False,postorder=False,preorder=False,subtree_size=False,topological_sort=False,unweighted_dist=False,weighted_dist=False):\r\n seen=[False]*self.V\r\n finished=[False]*self.V\r\n if directed_acyclic or cycle_detection or topological_sort:\r\n dag=True\r\n if euler_tour:\r\n et=[]\r\n if linked_components:\r\n lc=[]\r\n if lowlink:\r\n order=[None]*self.V\r\n ll=[None]*self.V\r\n idx=0\r\n if parents or cycle_detection or lowlink or subtree_size:\r\n ps=[None]*self.V\r\n if postorder or topological_sort:\r\n post=[]\r\n if preorder:\r\n pre=[]\r\n if subtree_size:\r\n ss=[1]*self.V\r\n if unweighted_dist or bipartite_graph:\r\n uwd=[self.inf]*self.V\r\n uwd[s]=0\r\n if weighted_dist:\r\n wd=[self.inf]*self.V\r\n wd[s]=0\r\n stack=[(s,0)] if self.weighted else [s]\r\n while stack:\r\n if self.weighted:\r\n x,d=stack.pop()\r\n else:\r\n x=stack.pop()\r\n if not seen[x]:\r\n seen[x]=True\r\n stack.append((x,d) if self.weighted else x)\r\n if euler_tour:\r\n et.append(x)\r\n if linked_components:\r\n lc.append(x)\r\n if lowlink:\r\n order[x]=idx\r\n ll[x]=idx\r\n idx+=1\r\n if preorder:\r\n pre.append(x)\r\n for y in self.graph[x]:\r\n if self.weighted:\r\n y,d=y\r\n if not seen[y]:\r\n stack.append((y,d) if self.weighted else y)\r\n if parents or cycle_detection or lowlink or subtree_size:\r\n ps[y]=x\r\n if unweighted_dist or bipartite_graph:\r\n uwd[y]=uwd[x]+1\r\n if weighted_dist:\r\n wd[y]=wd[x]+d\r\n elif not finished[y]:\r\n if (directed_acyclic or cycle_detection or topological_sort) and dag:\r\n dag=False\r\n if cycle_detection:\r\n cd=(y,x)\r\n elif not finished[x]:\r\n finished[x]=True\r\n if euler_tour:\r\n et.append(~x)\r\n if lowlink:\r\n bl=True\r\n for y in self.graph[x]:\r\n if self.weighted:\r\n y,d=y\r\n if ps[x]==y and bl:\r\n bl=False\r\n continue\r\n ll[x]=min(ll[x],order[y])\r\n if x!=s:\r\n ll[ps[x]]=min(ll[ps[x]],ll[x])\r\n if postorder or topological_sort:\r\n post.append(x)\r\n if subtree_size:\r\n for y in self.graph[x]:\r\n if self.weighted:\r\n y,d=y\r\n if y==ps[x]:\r\n continue\r\n ss[x]+=ss[y]\r\n if bipartite_graph:\r\n bg=[[],[]]\r\n for tpl in self.edges:\r\n x,y=tpl[:2] if self.weighted else tpl\r\n if uwd[x]==self.inf or uwd[y]==self.inf:\r\n continue\r\n if not uwd[x]%2^uwd[y]%2:\r\n bg=False\r\n break\r\n else:\r\n for x in range(self.V):\r\n if uwd[x]==self.inf:\r\n continue\r\n bg[uwd[x]%2].append(x)\r\n retu=()\r\n if bipartite_graph:\r\n retu+=(bg,)\r\n if cycle_detection:\r\n if dag:\r\n cd=[]\r\n else:\r\n y,x=cd\r\n cd=self.Route_Restoration(y,x,ps)\r\n retu+=(cd,)\r\n if directed_acyclic:\r\n retu+=(dag,)\r\n if euler_tour:\r\n retu+=(et,)\r\n if linked_components:\r\n retu+=(lc,)\r\n if lowlink:\r\n retu=(ll,)\r\n if parents:\r\n retu+=(ps,)\r\n if postorder:\r\n retu+=(post,)\r\n if preorder:\r\n retu+=(pre,)\r\n if subtree_size:\r\n retu+=(ss,)\r\n if topological_sort:\r\n if dag:\r\n tp_sort=post[::-1]\r\n else:\r\n tp_sort=[]\r\n retu+=(tp_sort,)\r\n if unweighted_dist:\r\n retu+=(uwd,)\r\n if weighted_dist:\r\n retu+=(wd,)\r\n if len(retu)==1:\r\n retu=retu[0]\r\n return retu\r\n\r\n def Build_Rerooting(self,s,f_transition,f_merge):\r\n self.rerooting_s=s\r\n self.rerooting_f_transition=f_transition\r\n self.rerooting_f_merge=f_merge\r\n parents,postorder,preorder=self.SIV_DFS(s,parents=True,postorder=True,preorder=True)\r\n self.rerooting_lower_dp=[None]*self.V\r\n for x in postorder:\r\n self.rerooting_lower_dp[x]=self.rerooting_f_merge([self.rerooting_f_transition(self.rerooting_lower_dp[y]) for y in G.graph[x] if y!=parents[x]])\r\n self.rerooting_upper_dp=[None]*self.V\r\n for x in preorder:\r\n children=[y for y in self.graph[x] if y!=parents[x]]\r\n left_accumule_f=[None]*(len(children)+1)\r\n right_accumule_f=[None]*(len(children)+1)\r\n left_accumule_f[0]=self.rerooting_f_merge([])\r\n for i in range(1,len(children)+1):\r\n left_accumule_f[i]=self.rerooting_f_merge([left_accumule_f[i-1],self.rerooting_f_transition(self.rerooting_lower_dp[children[i-1]])])\r\n right_accumule_f[len(children)]=self.rerooting_f_merge([])\r\n for i in range(len(children)-1,-1,-1):\r\n right_accumule_f[i]=self.rerooting_f_merge([right_accumule_f[i+1],self.rerooting_f_transition(self.rerooting_lower_dp[children[i]])])\r\n for i in range(len(children)):\r\n if parents[x]!=None:\r\n self.rerooting_upper_dp[children[i]]=self.rerooting_f_merge([left_accumule_f[i],right_accumule_f[i+1],self.rerooting_f_transition(self.rerooting_upper_dp[x])])\r\n else:\r\n self.rerooting_upper_dp[children[i]]=self.rerooting_f_merge([left_accumule_f[i],right_accumule_f[i+1]])\r\n \r\n def Rerooting(self,x):\r\n if x==self.rerooting_s:\r\n retu=self.rerooting_lower_dp[x]\r\n else:\r\n retu=self.rerooting_f_merge([self.rerooting_lower_dp[x],self.rerooting_f_transition(self.rerooting_upper_dp[x])])\r\n return retu\r\n\r\nN=int(readline())\r\nedges=[]\r\nfor i,p in enumerate(map(int,readline().split()),1):\r\n p-=1\r\n edges.append((p,i))\r\nG=Graph(N,edges=edges)\r\nmod=10**9+7\r\ndef transition(c):\r\n return (c+1)%mod\r\ndef merge(lst):\r\n retu=1\r\n for c in lst:\r\n retu*=c\r\n retu%=mod\r\n return retu\r\nG.Build_Rerooting(0,transition,merge)\r\nans_lst=[G.Rerooting(x) for x in range(N)]\r\nprint(*ans_lst)", "import sys\r\n\r\nfrom typing import Callable, Generic, List, TypeVar\r\n\r\nT = TypeVar(\"T\")\r\n\r\n\r\nclass Rerooting(Generic[T]):\r\n\r\n __slots__ = (\"adjList\", \"_n\", \"_decrement\")\r\n\r\n def __init__(self, n: int, decrement: int = 0):\r\n self.adjList = [[] for _ in range(n)]\r\n self._n = n\r\n self._decrement = decrement\r\n\r\n def addEdge(self, u: int, v: int) -> None:\r\n u -= self._decrement\r\n v -= self._decrement\r\n self.adjList[u].append(v)\r\n self.adjList[v].append(u)\r\n\r\n def rerooting(\r\n self,\r\n e: Callable[[int], T],\r\n op: Callable[[T, T], T],\r\n composition: Callable[[T, int, int, int], T],\r\n root=0,\r\n ) -> List[\"T\"]:\r\n root -= self._decrement\r\n assert 0 <= root < self._n\r\n parents = [-1] * self._n\r\n order = [root]\r\n stack = [root]\r\n while stack:\r\n cur = stack.pop()\r\n for next in self.adjList[cur]:\r\n if next == parents[cur]:\r\n continue\r\n parents[next] = cur\r\n order.append(next)\r\n stack.append(next)\r\n\r\n dp1 = [e(i) for i in range(self._n)]\r\n dp2 = [e(i) for i in range(self._n)]\r\n for cur in order[::-1]:\r\n res = e(cur)\r\n for next in self.adjList[cur]:\r\n if parents[cur] == next:\r\n continue\r\n dp2[next] = res\r\n res = op(res, composition(dp1[next], cur, next, 0))\r\n res = e(cur)\r\n for next in self.adjList[cur][::-1]:\r\n if parents[cur] == next:\r\n continue\r\n dp2[next] = op(res, dp2[next])\r\n res = op(res, composition(dp1[next], cur, next, 0))\r\n dp1[cur] = res\r\n\r\n for newRoot in order[1:]:\r\n parent = parents[newRoot]\r\n dp2[newRoot] = composition(op(dp2[newRoot], dp2[parent]), parent, newRoot, 1)\r\n dp1[newRoot] = op(dp1[newRoot], dp2[newRoot])\r\n return dp1\r\n\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\nINF = int(4e18)\r\nMOD = int(1e9 + 7)\r\n\r\nif __name__ == \"__main__\":\r\n n = int(input())\r\n edges = []\r\n parents = list(map(int, input().split()))\r\n for i in range(1, n):\r\n p = parents[i - 1] - 1\r\n edges.append((p, i))\r\n\r\n E = int\r\n\r\n def e(root: int) -> E:\r\n return 1\r\n\r\n def op(childRes1: E, childRes2: E) -> E:\r\n return childRes1 * childRes2 % MOD\r\n\r\n def composition(fromRes: E, parent: int, cur: int, direction: int) -> E:\r\n \"\"\"direction: 0: cur -> parent, 1: parent -> cur\"\"\"\r\n return fromRes + 1\r\n\r\n R = Rerooting(n)\r\n for u, v in edges:\r\n R.addEdge(u, v)\r\n\r\n dp = R.rerooting(e=e, op=op, composition=composition, root=0)\r\n print(*dp)\r\n" ]
{"inputs": ["3\n1 1", "5\n1 2 3 4", "31\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "29\n1 2 2 4 4 6 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28", "70\n1 2 2 4 4 6 6 8 9 9 11 11 13 13 15 15 17 17 19 19 21 22 22 24 24 26 27 27 29 29 31 31 33 34 34 36 37 37 39 39 41 42 42 44 44 46 47 47 49 50 50 52 52 54 54 56 57 57 59 60 60 62 63 63 65 65 67 68 68", "59\n1 2 2 4 4 5 7 7 8 8 10 10 11 11 15 15 9 18 18 20 20 21 23 22 22 26 6 6 28 30 30 31 31 33 34 34 32 32 38 40 39 39 29 44 44 45 47 47 46 46 50 52 52 54 51 51 57 58", "2\n1", "3\n1 2", "69\n1 1 3 3 5 5 7 8 8 10 10 12 12 14 14 16 16 18 18 20 21 21 23 23 25 26 26 28 28 30 30 32 33 33 35 36 36 38 38 40 41 41 43 43 45 46 46 48 49 49 51 51 53 53 55 56 56 58 59 59 61 62 62 64 64 66 67 67", "137\n1 1 3 3 5 5 7 8 8 10 10 12 12 14 14 16 16 18 18 20 21 21 23 23 25 26 26 28 28 30 30 32 33 33 35 36 36 38 38 40 41 41 43 43 45 46 46 48 49 49 51 51 53 53 55 56 56 58 59 59 61 62 62 64 64 66 67 67 1 1 71 71 73 73 75 76 76 78 78 80 80 82 82 84 84 86 86 88 89 89 91 91 93 94 94 96 96 98 98 100 101 101 103 104 104 106 106 108 109 109 111 111 113 114 114 116 117 117 119 119 121 121 123 124 124 126 127 127 129 130 130 132 132 134 135 135", "150\n1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 14 15 15 15 16 16 16 17 17 17 18 18 18 19 19 19 20 20 20 21 21 21 22 22 22 23 23 23 24 24 24 25 25 25 26 26 26 27 27 27 28 28 28 28 29 29 29 29 30 30 30 30 31 31 31 31 31 32 32 32 32 32 33 33 33 33 33 33 34 34 34 34 34 34 35 35 35 35 35 35 35 36 36 36 36 36 36 36 37 37 37 37 37 37 37 37 37"], "outputs": ["4 3 3", "5 8 9 8 5", "73741817 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913 536870913", "191 380 191 470 236 506 254 506 504 500 494 486 476 464 450 434 416 396 374 350 324 296 266 234 200 164 126 86 44", "0 1000000005 0 499999996 249999999 749999986 374999994 874999963 999999938 499999970 62499881 531249945 93749781 546874895 109374581 554687295 117186681 558593345 121092131 560546070 123043656 124995179 562497594 125968539 562984274 126450416 126932291 563466150 127163621 563581815 127260071 563630040 127269866 127279659 563639834 127207694 127135727 563567868 126946019 563473014 126543716 126141411 563070710 125325359 562662684 123687534 122049707 561024858 118771194 115492679 557746344 108934221 55446711...", "0 1000000005 0 499999996 499259752 500131906 498519506 453903141 456877573 963122521 230821046 981561265 981561265 115410524 784656845 892328427 892328427 415235638 207617820 331951678 748963765 998815735 165975843 582987926 999407872 332543823 666271916 492735403 494450227 485338898 330005231 366989446 553336825 864004193 776668417 932002101 932002101 775242091 893591565 183494727 591747368 946795787 946795787 488768546 73973791 454675898 659179041 829589525 829589525 147841416 181934138 841006939 9205034...", "2 2", "3 4 3", "1000000006 500000004 499999999 750000004 749999993 875000001 874999978 999999961 999999985 62499920 31249961 93749852 46874927 109374716 54687359 117186944 58593473 121092650 60546326 123044687 124996722 62498362 125971106 62985554 126455031 126938954 63469478 127174380 63587191 127279022 63639512 127305201 127331378 63665690 127292181 127252982 63626492 127128810 63564406 126857579 126586346 63293174 126032438 63016220 124918901 123805362 61902682 121575425 119345486 59672744 114884180 57442091 105960854 ...", "1 500000005 500000005 750000007 750000007 875000008 875000008 0 1 62499998 31250000 93749994 46874998 109374986 54687494 117187470 58593736 121093688 60546845 123046749 124999808 62499905 125976240 62988121 126464261 126952280 63476141 127195898 63597950 127316924 63658463 127375871 127434816 63717409 127461155 127487492 63743747 127494392 63747197 127485305 127476216 63738109 127446596 63723299 127381635 127316672 63658337 127183887 127051100 63525551 126784098 63392050 126249380 63124691 125179587 124109...", "0 1000000005 0 0 0 0 800000008 800000008 800000008 800000008 800000008 800000008 800000008 222222230 222222230 222222230 222222230 222222230 222222230 222222230 222222230 222222230 222222230 222222230 222222230 222222230 222222230 705882372 705882372 705882372 878787915 878787915 61538524 61538524 596899355 596899355 196881603 400000005 400000005 400000005 400000005 400000005 400000005 400000005 400000005 400000005 400000005 400000005 400000005 400000005 400000005 111111116 111111116 111111116 111111116 11..."]}
UNKNOWN
PYTHON3
CODEFORCES
6
e4ca507269f95c66d0e7b2314e214b54
Magic Squares
The Smart Beaver from ABBYY loves puzzles. One of his favorite puzzles is the magic square. He has recently had an idea to automate the solution of this puzzle. The Beaver decided to offer this challenge to the ABBYY Cup contestants. The magic square is a matrix of size *n*<=×<=*n*. The elements of this matrix are integers. The sum of numbers in each row of the matrix is equal to some number *s*. The sum of numbers in each column of the matrix is also equal to *s*. In addition, the sum of the elements on the main diagonal is equal to *s* and the sum of elements on the secondary diagonal is equal to *s*. Examples of magic squares are given in the following figure: You are given a set of *n*2 integers *a**i*. It is required to place these numbers into a square matrix of size *n*<=×<=*n* so that they form a magic square. Note that each number must occur in the matrix exactly the same number of times as it occurs in the original set. It is guaranteed that a solution exists! The first input line contains a single integer *n*. The next line contains *n*2 integers *a**i* (<=-<=108<=≤<=*a**i*<=≤<=108), separated by single spaces. The input limitations for getting 20 points are: - 1<=≤<=*n*<=≤<=3 The input limitations for getting 50 points are: - 1<=≤<=*n*<=≤<=4 - It is guaranteed that there are no more than 9 distinct numbers among *a**i*. The input limitations for getting 100 points are: - 1<=≤<=*n*<=≤<=4 The first line of the output should contain a single integer *s*. In each of the following *n* lines print *n* integers, separated by spaces and describing the resulting magic square. In the resulting magic square the sums in the rows, columns and diagonals must be equal to *s*. If there are multiple solutions, you are allowed to print any of them. Sample Input 3 1 2 3 4 5 6 7 8 9 3 1 0 -1 0 2 -1 -2 0 1 2 5 5 5 5 Sample Output 15 2 7 6 9 5 1 4 3 8 0 1 0 -1 -2 0 2 1 0 -1 10 5 5 5 5
[ "import sys, random\r\ndef f(b):\r\n global a\r\n a = [[0] * n for o in range(n)]\r\n\r\n for i in range(n):\r\n for j in range(n):\r\n a[i][j] = b[i * n + j]\r\n\r\n rez = 0\r\n for i in range(n):\r\n ns = 0\r\n for j in range(n):\r\n ns += a[i][j]\r\n rez += abs(su - ns)\r\n\r\n for j in range(n):\r\n ns = 0\r\n for i in range(n):\r\n ns += a[i][j]\r\n rez += abs(su - ns)\r\n ns = 0\r\n for i in range(n):\r\n ns += a[i][i]\r\n rez += abs(su - ns)\r\n ns = 0\r\n for i in range(n):\r\n ns += a[i][n - i - 1]\r\n rez += abs(su - ns)\r\n return rez\r\n\r\n\r\ninput = sys.stdin.readline\r\nn = int(input())\r\nd = list(map(int, input().split()))\r\nsu = sum(d) // n\r\np = f(d)\r\nwhile p:\r\n random.shuffle(d)\r\n p = f(d)\r\n for k in range(1000):\r\n\r\n i = random.randint(0, n*n-1)\r\n j = random.randint(0, n*n-1)\r\n while i == j:\r\n j = random.randint(0, n*n-1)\r\n if i > j:\r\n i, j = j, i\r\n d[i], d[j] = d[j], d[i]\r\n q = f(d)\r\n if q < p:\r\n p = q\r\n else:\r\n d[i], d[j] = d[j], d[i]\r\n p = f(d)\r\nprint(su)\r\nfor i in a:\r\n print(*i)\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\nfrom itertools import permutations\r\nn = int(input())\r\nw = sorted(map(int, input().split()))\r\nif n == 1:\r\n print(w[0])\r\n print(w[0])\r\nelif n == 2:\r\n print(w[0] + w[1])\r\n print(w[0], w[1])\r\n print(w[2], w[3])\r\nelif n == 3:\r\n x = w[0] + w[4] + w[8]\r\n y = w[4]\r\n w = w[:4] + w[5:]\r\n for q in permutations(w, 8):\r\n if q[0] + q[1] + q[2] == q[3] + q[4] + y == q[5] + q[6] + q[7] == q[0] + q[3] + q[5] == q[1] + q[6] + y == q[2] + q[7] + q[4] == q[0] + y + q[7] == q[2] + y + q[5]:\r\n print(x)\r\n print(q[0], q[1], q[2])\r\n print(q[3], y, q[4])\r\n print(q[5], q[6], q[7])\r\n break", "from itertools import permutations\r\n\r\n\r\ndef check(a, n):\r\n arr = [[0 for j in range(n)] for i in range(n)]\r\n p = 0\r\n for i in range(n):\r\n for j in range(n):\r\n arr[i][j] = a[p]\r\n p += 1\r\n s = sum(arr[0])\r\n for i in range(1, n):\r\n if s != sum(arr[i]):\r\n return False\r\n\r\n for i in range(n):\r\n s1 = 0\r\n for j in range(n):\r\n s1 += arr[j][i]\r\n if s1 != s:\r\n return False\r\n s2 = 0\r\n for i in range(n):\r\n s2 += arr[i][i]\r\n if s2 != s:\r\n return False\r\n\r\n s2 = 0\r\n for i in range(n):\r\n s2 += arr[i][n-i-1]\r\n if s2 != s:\r\n return False\r\n\r\n return True\r\n\r\n\r\nn = int(input())\r\n\r\nnum = n ** 2\r\na = list(map(int, input().split()))\r\ns = sum(a)//n\r\nprint(s)\r\n\r\nfor combo in permutations(a, num):\r\n if(check(combo, n)):\r\n for i in range(0, num, n):\r\n print(*combo[i:i+n], sep=' ')\r\n break\r\n", "import sys\r\ninput = sys.stdin.readline\r\nfrom random import randint, shuffle\r\nfrom itertools import permutations\r\n\r\n\r\ndef f(q):\r\n shuffle(q)\r\n a = q.pop()\r\n b = q.pop()\r\n c = x - a - b\r\n for i in range(len(q)):\r\n for j in range(i+1, len(q)):\r\n if q[i] + q[j] == c:\r\n t = q[:i] + q[i+1:j] + q[j+1:]\r\n return [1, t, (a, b, q[i], q[j])]\r\n return [0]\r\n\r\n\r\ndef f1(q):\r\n for i1, i2, i3, i4 in permutations(q[0], 4):\r\n for j1, j2, j3, j4 in permutations(q[1], 4):\r\n for k1, k2, k3, k4 in permutations(q[2], 4):\r\n for h1, h2, h3, h4 in permutations(q[3], 4):\r\n if i1 + j1 + k1 + h1 == i2 + j2 + k2 + h2 == i3 + j3 + k3 + h3 == i4 + j4 + k4 + h4 == i1 + j2 + k3 + h4 == i4 + j3 + k2 + h1 == x:\r\n return [1, [(i1, i2, i3, i4), (j1, j2, j3, j4), (k1, k2, k3, k4), (h1, h2, h3, h4)]]\r\n return [0]\r\n\r\n\r\nn = int(input())\r\nw = sorted(map(int, input().split()))\r\nif n == 1:\r\n print(w[0])\r\n print(w[0])\r\nelif n == 2:\r\n print(w[0] + w[1])\r\n print(w[0], w[1])\r\n print(w[2], w[3])\r\nelif n == 3:\r\n x = w[0] + w[4] + w[8]\r\n y = w[4]\r\n w = w[:4] + w[5:]\r\n for q in permutations(w, 8):\r\n if q[0] + q[1] + q[2] == q[3] + q[4] + y == q[5] + q[6] + q[7] == q[0] + q[3] + q[5] == q[1] + q[6] + y == q[2] + q[7] + q[4] == q[0] + y + q[7] == q[2] + y + q[5]:\r\n print(x)\r\n print(q[0], q[1], q[2])\r\n print(q[3], y, q[4])\r\n print(q[5], q[6], q[7])\r\n break\r\nelse:\r\n x = sum(w)//4\r\n for i in range(1000):\r\n a = w.copy()\r\n v = 4\r\n d = []\r\n while v:\r\n g = f(a)\r\n if g[0] == 1:\r\n v -= 1\r\n d.append(g[2])\r\n a = g[1].copy()\r\n else:\r\n break\r\n if v == 0:\r\n g = f1(d)\r\n if g[0]:\r\n print(x)\r\n for ii in g[1]:\r\n print(' '.join(map(str, ii)))\r\n break\r\n" ]
{"inputs": ["3\n1 2 3 4 5 6 7 8 9", "3\n1 0 -1 0 2 -1 -2 0 1", "2\n5 5 5 5", "2\n-1 -1 -1 -1", "3\n58 -83 72 65 -90 -2 -9 -16 -76", "3\n399 -1025 -129 -497 927 -577 479 31 -49", "3\n2 4 6 8 10 12 14 16 18", "3\n36 31 -25 3 -20 -30 8 -2 26", "3\n175 -1047 -731 -141 38 -594 -415 -278 491", "3\n-1256 74 -770 -284 -105 381 -591 1046 560", "1\n-98765432", "3\n99981234 99981234 99981234 99981234 99981234 99981234 99981234 99981234 99981234", "3\n-67774718 52574834 -7599942 52574834 52574834 -67774718 -67774718 -7599942 -7599942", "3\n12458317 12458317 -27658201 -7599942 -27658201 32516576 -67774719 -47716460 52574835", "3\n-33389130 52574830 -16196338 -41985526 996454 26785642 -7599942 18189246 -67774714"], "outputs": ["15\n2 7 6\n9 5 1\n4 3 8", "0\n1 0 -1\n-2 0 2\n1 0 -1", "10\n5 5\n5 5", "-2\n-1 -1\n-1 -1", "-27\n-83 58 -2\n72 -9 -90\n-16 -76 65", "-147\n399 -1025 479\n31 -49 -129\n-577 927 -497", "30\n4 14 12\n18 10 2\n8 6 16", "9\n31 -20 -2\n-30 3 36\n8 26 -25", "-834\n175 -1047 38\n-415 -278 -141\n-594 491 -731", "-315\n-770 74 381\n1046 -105 -1256\n-591 -284 560", "-98765432\n-98765432", "299943702\n99981234 99981234 99981234\n99981234 99981234 99981234\n99981234 99981234 99981234", "-22799826\n-67774718 52574834 -7599942\n52574834 -7599942 -67774718\n-7599942 -67774718 52574834", "-22799826\n12458317 12458317 -47716460\n-67774719 -7599942 52574835\n32516576 -27658201 -27658201", "-22799826\n-33389130 52574830 -41985526\n-16196338 -7599942 996454\n26785642 -67774714 18189246"]}
UNKNOWN
PYTHON3
CODEFORCES
4
e4f0ceca7cea499af8cc012c2748fc43
Mishka and Interesting sum
Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers *a*1,<=*a*2,<=...,<=*a**n* of *n* elements! Mishka loved the array and she instantly decided to determine its beauty value, but she is too little and can't process large arrays. Right because of that she invited you to visit her and asked you to process *m* queries. Each query is processed in the following way: 1. Two integers *l* and *r* (1<=≤<=*l*<=≤<=*r*<=≤<=*n*) are specified — bounds of query segment. 1. Integers, presented in array segment [*l*,<=<=*r*] (in sequence of integers *a**l*,<=*a**l*<=+<=1,<=...,<=*a**r*) even number of times, are written down. 1. XOR-sum of written down integers is calculated, and this value is the answer for a query. Formally, if integers written down in point 2 are *x*1,<=*x*2,<=...,<=*x**k*, then Mishka wants to know the value , where  — operator of exclusive bitwise OR. Since only the little bears know the definition of array beauty, all you are to do is to answer each of queries presented. The first line of the input contains single integer *n* (1<=≤<=*n*<=≤<=1<=000<=000) — the number of elements in the array. The second line of the input contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (1<=≤<=*a**i*<=≤<=109) — array elements. The third line of the input contains single integer *m* (1<=≤<=*m*<=≤<=1<=000<=000) — the number of queries. Each of the next *m* lines describes corresponding query by a pair of integers *l* and *r* (1<=≤<=*l*<=≤<=*r*<=≤<=*n*) — the bounds of query segment. Print *m* non-negative integers — the answers for the queries in the order they appear in the input. Sample Input 3 3 7 8 1 1 3 7 1 2 1 3 3 2 3 5 4 7 4 5 1 3 1 7 1 5 Sample Output 0 0 3 1 3 2
[ "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\ndef make_graph(n, m):\r\n x, s = [0] * (2 * m), [0] * (n + 3)\r\n for i in range(0, 2 * m, 2):\r\n u, v = map(int, input().split())\r\n s[u + 2] += 1\r\n x[i], x[i + 1] = u, v\r\n for i in range(3, n + 3):\r\n s[i] += s[i - 1]\r\n G, W = [0] * m, [0] * m\r\n for i in range(0, 2 * m, 2):\r\n j = x[i] + 1\r\n G[s[j]] = x[i ^ 1]\r\n W[s[j]] = i >> 1\r\n s[j] += 1\r\n return G, W, s\r\n\r\ndef update(i, x):\r\n i += l1\r\n tree[i] = x\r\n i >>= 1\r\n while i:\r\n tree[i] = tree[2 * i] ^ tree[2 * i + 1]\r\n i >>= 1\r\n return\r\n\r\ndef get_xor(s, t):\r\n s += l1\r\n t += l1\r\n ans = 0\r\n while s <= t:\r\n if s % 2:\r\n ans ^= tree[s]\r\n s += 1\r\n s >>= 1\r\n if not t % 2:\r\n ans ^= tree[t]\r\n t -= 1\r\n t >>= 1\r\n return ans\r\n\r\nn = int(input())\r\na = [0] + list(map(int, input().split()))\r\nl1 = pow(2, (n + 1).bit_length())\r\nl2 = 2 * l1\r\ntree = [0] * l2\r\nla = dict()\r\nnx = [0] * (n + 1)\r\nfor i in range(1, n + 1):\r\n ai = a[i]\r\n if ai in la:\r\n tree[i + l1] = ai\r\n nx[la[ai]] = i\r\n la[ai] = i\r\nfor i in range(l1 - 1, 0, -1):\r\n tree[i] = tree[2 * i] ^ tree[2 * i + 1]\r\nm = int(input())\r\nx, y, s0 = make_graph(n, m)\r\nans = [0] * m\r\nfor l in range(1, n + 1):\r\n for i in range(s0[l], s0[l + 1]):\r\n r, j = x[i], y[i]\r\n ans0 = get_xor(l, r)\r\n ans[j] = ans0\r\n if nx[l]:\r\n update(nx[l], 0)\r\nsys.stdout.write(\"\\n\".join(map(str, ans)))" ]
{"inputs": ["3\n3 7 8\n1\n1 3", "7\n1 2 1 3 3 2 3\n5\n4 7\n4 5\n1 3\n1 7\n1 5", "10\n1 2 4 1 1 1 1 1 1 4\n55\n5 8\n3 9\n6 8\n4 6\n4 10\n2 8\n1 5\n7 8\n8 9\n7 9\n5 6\n8 10\n9 9\n2 2\n3 3\n3 7\n1 8\n2 3\n4 9\n8 8\n10 10\n1 1\n1 6\n2 4\n6 9\n3 10\n3 8\n9 10\n7 7\n3 6\n4 7\n2 10\n7 10\n3 4\n4 8\n5 9\n2 7\n6 6\n4 4\n5 10\n1 2\n6 10\n5 7\n2 6\n1 3\n1 4\n4 5\n5 5\n6 7\n3 5\n1 7\n2 5\n1 10\n1 9\n2 9", "10\n10 6 7 1 6 1 6 10 6 10\n10\n2 7\n3 5\n2 9\n2 7\n6 10\n2 4\n4 8\n3 3\n4 10\n1 8", "10\n1 2 1 2 2 2 1 1 1 2\n55\n1 1\n1 8\n3 6\n6 10\n2 8\n7 7\n2 10\n5 9\n1 6\n3 3\n2 4\n4 5\n8 8\n1 7\n6 6\n6 9\n2 5\n2 7\n1 5\n2 9\n5 5\n3 8\n6 8\n4 10\n5 8\n3 4\n1 2\n9 10\n4 7\n8 10\n2 2\n4 8\n7 9\n9 9\n4 4\n3 7\n3 9\n1 4\n5 10\n4 9\n10 10\n3 10\n2 6\n2 3\n1 9\n5 7\n5 6\n4 6\n6 7\n7 8\n1 10\n7 10\n8 9\n1 3\n3 5", "10\n1 3 3 4 4 3 4 1 4 1\n55\n3 6\n2 7\n2 3\n6 10\n1 3\n1 8\n8 8\n5 5\n8 9\n5 7\n3 7\n3 5\n2 8\n2 5\n4 4\n5 6\n3 8\n5 9\n10 10\n4 6\n8 10\n4 8\n9 9\n4 7\n1 5\n1 9\n9 10\n5 8\n6 7\n2 6\n1 7\n6 6\n1 6\n7 7\n1 2\n6 8\n3 9\n5 10\n1 4\n7 8\n2 2\n4 9\n3 10\n2 9\n3 4\n4 5\n1 10\n4 10\n6 9\n2 4\n7 9\n3 3\n1 1\n7 10\n2 10", "10\n1 3 1 2 2 3 3 1 4 3\n55\n1 10\n4 6\n1 7\n2 9\n3 4\n2 6\n3 3\n6 6\n8 9\n1 5\n7 7\n4 8\n6 8\n4 5\n5 8\n1 4\n4 9\n6 9\n7 8\n2 5\n1 9\n4 7\n2 7\n7 10\n4 4\n9 10\n1 2\n5 7\n6 7\n2 4\n5 5\n7 9\n3 7\n5 6\n3 6\n3 10\n4 10\n5 10\n10 10\n8 10\n2 2\n1 3\n1 8\n1 6\n9 9\n6 10\n1 1\n3 9\n2 3\n8 8\n3 5\n2 10\n3 8\n2 8\n5 9", "10\n1 4 2 3 3 4 3 1 3 1\n55\n3 3\n2 5\n4 8\n3 5\n5 10\n5 5\n4 4\n7 9\n1 8\n5 9\n2 10\n1 10\n4 10\n4 6\n3 7\n2 2\n10 10\n6 10\n4 7\n2 7\n7 10\n1 6\n2 6\n1 2\n7 8\n6 7\n1 5\n6 9\n1 1\n8 10\n2 4\n5 7\n6 8\n9 9\n3 8\n5 6\n2 8\n3 9\n4 5\n4 9\n1 9\n9 10\n3 4\n3 10\n1 4\n1 3\n6 6\n2 9\n2 3\n1 7\n7 7\n3 6\n8 9\n8 8\n5 8", "10\n1 4 4 1 1 1 2 1 3 4\n55\n6 6\n9 9\n1 8\n7 8\n3 4\n2 4\n4 5\n2 7\n8 9\n6 8\n7 7\n1 1\n5 7\n2 9\n3 10\n3 3\n4 7\n7 10\n6 10\n2 5\n3 9\n1 7\n2 2\n3 6\n6 7\n4 9\n2 6\n1 10\n5 5\n3 5\n7 9\n4 10\n1 3\n8 8\n1 5\n1 4\n10 10\n2 10\n4 4\n5 8\n9 10\n4 8\n2 3\n1 6\n6 9\n1 9\n5 10\n5 9\n8 10\n4 6\n1 2\n5 6\n2 8\n3 8\n3 7", "20\n5 7 6 4 7 10 4 3 4 9 9 4 9 9 5 2 4 4 1 8\n20\n14 16\n2 14\n19 19\n2 9\n16 17\n12 19\n10 17\n12 12\n9 11\n12 20\n6 19\n2 13\n14 15\n13 15\n16 20\n7 19\n9 19\n9 18\n4 18\n1 17", "20\n7 7 1 7 5 4 4 4 4 4 7 5 5 4 10 10 4 7 1 7\n20\n7 15\n11 16\n2 13\n3 20\n6 15\n1 15\n13 15\n10 17\n16 17\n12 15\n16 16\n2 3\n7 17\n2 15\n5 6\n8 20\n9 12\n10 16\n8 12\n6 18", "20\n1 10 1 10 1 1 10 10 1 10 10 10 10 10 10 10 1 10 1 10\n20\n16 18\n6 14\n5 16\n1 17\n3 6\n7 10\n8 17\n3 12\n2 3\n5 15\n7 14\n4 12\n8 15\n3 19\n5 10\n14 16\n6 7\n14 17\n4 6\n19 20", "20\n5 9 9 3 6 3 7 3 2 7 10 9 7 7 3 1 7 8 4 9\n20\n9 15\n5 20\n13 17\n9 10\n13 19\n6 9\n4 11\n9 17\n8 11\n2 10\n1 1\n12 18\n10 18\n5 11\n11 13\n3 10\n8 20\n15 19\n9 17\n1 17", "20\n2 3 7 4 3 3 4 2 3 2 7 7 10 4 10 4 4 2 7 2\n20\n1 9\n9 20\n11 12\n9 17\n2 7\n18 20\n9 14\n4 17\n13 15\n2 17\n9 13\n1 18\n7 20\n3 7\n3 14\n3 9\n18 20\n3 15\n6 16\n17 18", "20\n10 7 10 10 10 10 7 10 10 10 10 10 7 7 10 10 7 10 10 10\n20\n10 12\n2 13\n17 20\n4 18\n10 19\n3 5\n5 9\n15 17\n6 18\n3 16\n12 17\n4 18\n15 18\n3 4\n2 17\n13 17\n2 7\n5 10\n10 17\n8 10"], "outputs": ["0", "0\n3\n1\n3\n2", "1\n1\n0\n0\n1\n0\n0\n1\n1\n0\n1\n1\n0\n0\n0\n1\n1\n0\n1\n0\n0\n0\n1\n0\n1\n5\n0\n0\n0\n0\n1\n5\n0\n0\n0\n0\n1\n0\n0\n0\n0\n1\n0\n0\n0\n1\n1\n0\n1\n1\n0\n1\n4\n0\n1", "1\n0\n7\n1\n12\n0\n7\n0\n11\n11", "0\n3\n0\n2\n2\n0\n1\n2\n3\n0\n2\n2\n0\n2\n0\n0\n0\n3\n1\n3\n0\n0\n1\n2\n3\n0\n0\n0\n0\n1\n0\n1\n0\n0\n0\n1\n1\n3\n0\n0\n0\n3\n2\n0\n2\n2\n2\n0\n0\n1\n0\n0\n1\n1\n2", "7\n0\n3\n5\n3\n1\n0\n0\n0\n4\n3\n4\n0\n7\n0\n0\n3\n0\n0\n4\n1\n0\n0\n0\n7\n5\n0\n4\n0\n4\n0\n0\n4\n0\n0\n0\n7\n1\n3\n0\n0\n4\n6\n4\n0\n4\n4\n5\n4\n3\n4\n0\n0\n5\n5", "1\n2\n3\n3\n0\n1\n0\n0\n0\n3\n0\n1\n3\n2\n3\n1\n1\n3\n0\n2\n2\n1\n2\n3\n0\n0\n0\n3\n3\n0\n0\n0\n1\n0\n2\n3\n2\n0\n0\n0\n0\n1\n2\n0\n0\n0\n0\n0\n0\n0\n2\n0\n0\n3\n3", "0\n3\n0\n3\n1\n0\n0\n3\n5\n0\n6\n7\n2\n3\n0\n0\n0\n2\n0\n4\n2\n7\n7\n0\n0\n0\n3\n3\n0\n1\n0\n3\n0\n0\n0\n0\n4\n3\n3\n3\n6\n0\n0\n2\n0\n0\n0\n7\n0\n4\n0\n3\n0\n0\n3", "0\n0\n4\n0\n0\n4\n1\n4\n0\n1\n0\n0\n1\n5\n5\n0\n0\n0\n1\n5\n1\n5\n0\n0\n0\n1\n4\n0\n0\n1\n0\n1\n4\n0\n4\n5\n0\n1\n0\n0\n0\n1\n4\n5\n1\n4\n0\n0\n0\n0\n0\n1\n5\n1\n0", "0\n10\n0\n7\n0\n9\n13\n0\n9\n9\n9\n3\n0\n9\n4\n9\n13\n13\n13\n11", "5\n15\n0\n12\n1\n3\n0\n15\n0\n5\n0\n0\n11\n4\n0\n15\n4\n11\n0\n8", "10\n1\n0\n1\n0\n0\n11\n11\n0\n10\n0\n10\n0\n1\n0\n0\n0\n0\n1\n0", "0\n9\n0\n0\n0\n3\n7\n7\n0\n14\n0\n0\n7\n4\n0\n7\n13\n0\n7\n3", "5\n10\n7\n13\n4\n2\n7\n15\n10\n11\n7\n11\n12\n7\n2\n4\n2\n8\n12\n0", "0\n0\n0\n7\n0\n0\n10\n10\n7\n0\n0\n7\n0\n10\n0\n10\n13\n0\n0\n0"]}
UNKNOWN
PYTHON3
CODEFORCES
1
e51ad8620299c1b8250aa20b7d466787
Wizards' Duel
Harry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length *l*. Two opponents simultaneously charge a deadly spell in the enemy. We know that the impulse of Harry's magic spell flies at a speed of *p* meters per second, and the impulse of You-Know-Who's magic spell flies at a speed of *q* meters per second. The impulses are moving through the corridor toward each other, and at the time of the collision they turn round and fly back to those who cast them without changing their original speeds. Then, as soon as the impulse gets back to it's caster, the wizard reflects it and sends again towards the enemy, without changing the original speed of the impulse. Since Harry has perfectly mastered the basics of magic, he knows that after the second collision both impulses will disappear, and a powerful explosion will occur exactly in the place of their collision. However, the young wizard isn't good at math, so he asks you to calculate the distance from his position to the place of the second meeting of the spell impulses, provided that the opponents do not change positions during the whole fight. The first line of the input contains a single integer *l* (1<=≤<=*l*<=≤<=1<=000) — the length of the corridor where the fight takes place. The second line contains integer *p*, the third line contains integer *q* (1<=≤<=*p*,<=*q*<=≤<=500) — the speeds of magical impulses for Harry Potter and He-Who-Must-Not-Be-Named, respectively. Print a single real number — the distance from the end of the corridor, where Harry is located, to the place of the second meeting of the spell impulses. Your answer will be considered correct if its absolute or relative error will not exceed 10<=-<=4. Namely: let's assume that your answer equals *a*, and the answer of the jury is *b*. The checker program will consider your answer correct if . Sample Input 100 50 50 199 60 40 Sample Output 50 119.4
[ "s=int(input())\r\np=int(input())\r\nq=int(input())\r\nprint(s*p/(p+q))", "#input_values = input().split()\nx = int(input())\np = int(input())\nq = int(input())\nd = ((x*p) / (p+q))\nprint(d)\n\n\t\t \t\t \t\t \t\t \t\t\t\t\t \t\t \t \t \t", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nt=1+q/p\r\nx=l/t\r\nprint(x)", "l, p , q = int(input()), int(input()), int(input())\r\nprint(l * p / (p + q))", "l,a,b=int(input()),int(input()),int(input())\r\nprint(a*(l/(a+b)))", "n=int(input(''))\r\na=int(input(''))\r\nb=int(input(''))\r\nd=n/(a+b)\r\nprint(d*a)# your code goes here", "def solve(l,p,q):\n t = l / (p+q)\n return round(t*p,4)\n \n \n \n\ndef main() :\n l = int(input())\n p = int(input())\n q = int(input())\n print(solve(l,p,q))\nmain()\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nx=1.0*(p*l)/(p+q)\r\nprint(x)\r\n", "def f(ll):\r\n l,p,q=ll\r\n return l*p/(p+q) \r\n\r\nl = [int(input()) for _ in range(3)]\r\nprint(f(l))\r\n\r\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\ns= l/(p+q)\r\nx=p*s\r\nprint(x)", "m=input()\nl=int(m)\nn=input()\np=int(n)\no=input()\nq=int(o)\n\na=l/(p+q)\nprint(a*p)\nprint(\"\\n\")\n\t\t \t \t \t \t\t\t \t \t", "# Description of the problem can be found at http://codeforces.com/problemset/problem/591/A\r\n\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nprint((l / (p + q)) * p)", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nans = (l/(p+q))*p\r\n\r\nprint(ans)\r\n", "corridor = int(input())\np = int(input())\nq = int(input())\nt = corridor / (p + q)\ndq = 0\nfor i in range(3):\n if i % 2 == 0:\n dq += t * q\n else:\n dq -= t * q\ndp = corridor - dq\nif round(dp) == dp:\n print(int(dp))\nelse:\n print(dp)\n\n\t\t \t \t\t \t\t\t \t \t\t\t \t\t \t \t \t \t", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nt = l/(p+q)\r\nans = p*t\r\nprint(ans)\r\n", "l = int(input())\r\na = int(input())\r\nb = int(input())\r\nprint(l/2 if a == b else a*(l/(a+b)))\r\n", "l=float(input())\r\np=float(input())\r\nq=float(input())\r\nresult=(l/(p+q))*p\r\nprint(result)", "dis=int(input()) ; s1=int(input()) ; s2=int(input()) ; print(dis-(dis/(s1/s2+1)))\r\n\r\n", "l = int(input())\r\np = int(input())\r\nq = int (input())\r\nprint(p*(l/(p+q)))", "l, p, q = map(int, [input(), input(), input()])\r\nprint(l * p / float(p + q))", "def solve(l,p,q):\n\n return p*(l/(p+q))\n\nl = int(input())\np = int(input())\nq = int(input())\n\nprint(solve(l,p,q))\n \t \t\t\t\t\t \t\t \t \t\t\t \t\t\t \t\t", "inp = lambda : int(input())\r\nl,p,q = inp(),inp(),inp()\r\nr = p*l/(p+q)\r\nprint(r)", "import sys\r\n\r\nlines = sys.stdin.readlines()\r\n\r\nl = int(lines[0])\r\np = int(lines[1])\r\nq = int(lines[2])\r\n\r\nv = p + q #relative velocity\r\n\r\nt1 = l/v #time to collide\r\ndp = p*t1 #distance of collision from Potter\r\n\r\nprint(dp)", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nl=l/(q+p)\r\nprint(p*l)", "l, = map(int,input().split())\r\np, = map(int,input().split())\r\nq, = map(int,input().split())\r\n\r\ns1 = l/(p+q)*p\r\nprint(s1)\r\n", "# Enter your code here. Read input from STDIN. Print output to STDOUT\nimport math\n \nif __name__ == '__main__':\n\tl = int(input().strip())\n\tp = int(input().strip())\n\tq = int(input().strip())\n\tx = l/(p+q)\n\tprint(x*p)\n\t\t\t \t \t \t \t\t \t\t\t\t \t\t \t\t\t\t \t\t \t", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nt = l/(p+q)\r\nc1 = p*t\r\n\r\nprint(c1)", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nx=p*l/(p+q)\r\ny=2*p*l*(q-p)/(p+q)**2\r\nif(x-int(x)==0):\r\n print(int(x))\r\nelse:\r\n print(x)\r\n#print(y)\r\n#print(x-y)\r\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nt=l/(p+q)\r\nans=t*p\r\nif ans-int(ans)==0:\r\n print(int(ans))\r\nelse:\r\n print(ans)\r\n", "s = float(input())\r\nx = float(input())\r\ny = float(input())\r\n\r\nprint(\"%.4f\"%float(s/(x+y)*x))\r\n", "l = int(input())\np = int(input())\nq = int(input())\nt = l / (p+q)\nprint(t*p)\n", "l, p, q = int(input()), int(input()), int(input())\r\nprint((p * l)/(p + q))\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sat Jan 7 16:53:12 2023\r\n\r\n@author: Lenovo\r\n\"\"\"\r\n\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nt1 = l/(p+q)\r\nc1 = p*t1\r\n\r\nth = c1/p\r\ntv = (l-c1)/q\r\n\r\nif th>tv:\r\n sv = l - q*(th-tv)\r\n sh = 0\r\nelse:\r\n sh = p*(tv-th)\r\n sv = l\r\n\r\nt2 = (sv-sh)/(p+q)\r\n\r\ncolisao = p*t2\r\nprint(colisao)\r\n", "distance = int(input())\r\np_speed=int(input())\r\nq_speed=int(input())\r\n \r\ntimeof_p= distance/p_speed\r\ntimeof_q=distance/q_speed\r\n \r\n \r\nprint(p_speed*distance/(p_speed+q_speed))", "l=input()\nv1=input()\nv2=input()\nl=int(l)\nv1=int(v1)\nv2=int(v2)\ntotal_v=v1+v2\nt=l/total_v\nans=t*v1\nprint(ans)\n \t\t \t \t \t \t\t \t \t \t\t\t", "K = int(input())\na = int(input())\nb = int(input())\n\nprint(\"{:.5f}\".format(a*K/(a+b)))\n", "x = input()\ny = input()\nz = input()\nx=\tint (x)\ny=\tint (y)\nz=\tint (z)\nq = float((x/(y+z))*y)\nprint(q)\n\t\t \t\t \t\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", "def main():\r\n [l, p, q] = [int(input()) for _ in range(3)]\r\n print(p * l / (p + q))\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "l=int(input())\r\na=int(input())\r\nb=int(input())\r\ntotal=a+b\r\ntime=l/total\r\nprint(a*time)", "l = int(input())\r\nh = int(input())\r\nw = int(input())\r\nprint((l/(h+w))*h)", "d = int(input())\r\nh = int(input())\r\nn = int(input())\r\nprint(d-(n*d)/(n+h))\r\n", "\n\nl = int(input())\np = int(input())\nq = int(input())\n\nprint(l/(p+q) * p)\n", "l = int(input())\r\ns1 = int(input())\r\ns2 = int(input())\r\n_ = l/(s1+s2)\r\nprint(_*s1)", "\"\"\"\nhttps://codeforces.com/problemset/problem/591/\n\"\"\"\nl = int(input())\np = int(input())\nq = int(input())\nprint(1/(((q/p)+1)*(1/l)))\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nans=p*(l/(p+q))\r\nprint(ans)", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint((p*l)/(p+q))\r\n", "l = int(input())\r\nq = int(input())\r\np = int(input())\r\nmqp = min(q,p)\r\nxqp = max(q,p)\r\nprint(q/(q+p)*l)\r\n", "l,x,y=int(input()),int(input()),int(input())\r\nm=l/(x+y)\r\nprint(m*x)", "dis= int(input())\r\nsp = int(input()) \r\nsp1= int(input()) \r\nprint((sp * dis ) / (sp + sp1) ) ", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\n\r\ntime_of_meeting=l/(p+q)\r\n\r\ndistance_from_harry = time_of_meeting * p\r\n\r\nprint(distance_from_harry)\r\n", "a=int(input())\r\nb=int(input())\r\nc =int(input())\r\nprint(round((a/(b+c))*b,4))", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\na=p*l\r\nb=(p+q)\r\nif a%b==0:\r\n\tprint(int(a/b))\r\nelse:\r\n\tprint(a/b)", "l=int(input())\r\np=1/int(input())\r\nq=1/int(input())\r\nx=p+q\r\nt=l/x\r\nprint(q*t)", "l=int(input())\nb=int(input())\nq=int(input())\nprint((b*l)/(b+q))\n \t\t \t \t\t\t \t\t \t\t \t \t\t \t \t", "from decimal import *\r\nl = int(input())\r\nv1 = int(input()) # vel di Hpott\r\nv2 = int(input()) # vel di Volde\r\nt=l/(v1+v2)\r\nc = v1 * t\r\nprint(c)", "c = lambda:int(input())\na, x, y = c(), c(), c()\nprint (a * x / (x + y))", "# ///==========Libraries, Constants and Functions=============///\r\n#mk_Raghav\r\nimport sys\r\n\r\ninf = float(\"inf\")\r\nmod = 1000000007\r\n\r\n\r\ndef get_array(): return list(map(int, sys.stdin.readline().split()))\r\n\r\n\r\ndef get_ints(): return map(int, sys.stdin.readline().split())\r\n\r\n\r\ndef input(): return sys.stdin.readline()\r\n\r\ndef int1():return int(input())\r\n# ///==========MAIN=============///\r\n\r\ndef main():\r\n a=int1()\r\n b=int1()\r\n c=int1()\r\n z=((a*c)/(b+c))\r\n if z%10==0:\r\n print(a-(a*c)//(b+c))\r\n else:\r\n print(a-(a*c)/(b+c))\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "\r\n\r\nx1 = int(input())\r\nx2 = int(input())\r\nx3 = int(input())\r\nprint((x1 * x2)/(x2 + x3))\r\n# UBCF\r\n# CodeForcesian\r\n# ♥\r\n# باشه", "a = int(input())\nb = int(input())\nc = int(input())\nprint(b * a / (b + c))", "def main():\r\n #print(\"This Work made by Ahmad Elnassag\")\r\n #print(\" Junior Training Sheet V7\")\r\n pass\r\n le = int(input())\r\n A = int(input())\r\n B = int(input())\r\n result = le*(A/(A+B))\r\n print(result)\r\n\r\n \r\n \r\n\r\nif __name__ == \"__main__\":\r\n main()", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nresult=(l*p)/((p+q))\r\nif result.is_integer()==True:\r\n print(int(result))\r\nelse:\r\n print(result)", "# LUOGU_RID: 101606208\nl, p, q = map(int, open(0).read().split())\r\nprint(l * p / (p + q))", "a=int(input())\r\nb=int(input())\r\nc=int(input())\r\nd=a/(b+c)\r\nk=d*b\r\nprint(\"{0:.4f}\".format(k))", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nt=l*3/(p+q)\r\ns=(p/q*l)/(p/q+1)\r\nprint(p*t-2*s)", "n,p,q=int(input()),int(input()),int(input())\r\nprint(float(n*p)/(p+q))", "l = int(input())\r\na,b=int(input()),int(input())\r\n\r\ns=a*(l/(a+b))\r\nprint(s)", "(lambda l, p, q: print(p * l / (p + q)))(*map(lambda _: int(input()), range(3)))\r\n", "l,p,d=int(input()),int(input()),int(input())\r\nprint(p*l/(p+d))", "l = int(input())\r\n\r\nv1 = int(input())\r\n\r\nv2 = int(input())\r\n\r\nx = (v1 * l) / (v1 + v2)\r\n\r\nprint(x)", "\nl = int(input())\np = int(input())\nq = int(input())\n\ncollision_time = l / (p + q)\n\nharry_distance = p * collision_time\n\nprint(harry_distance)\n\n \t \t\t \t \t\t\t\t \t\t \t \t \t\t", "# import sys\r\n# sys.stdin=open(\"input.in\",'r')\r\n# sys.stdout=open(\"output4.out\",'w')\r\nl=int(input())\r\np=int(input())\r\nq=int(input())\r\nx=q*l/(p+q)\r\nif int(l-x)==l-x:\r\n\tprint(int(l-x))\r\nelse:\r\n\tprint(l-x)\t", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\ndist = p/(p+q) * l\r\nprint(dist)", "#!/bin/python3\r\n\r\nimport sys\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint(\"%.4f\"% (p * (l / ( p + q))))\r\n", "d=int(input())\r\np=int(input())\r\nq=int(input())\r\n\r\nt=d/(p+q)\r\n\r\nprint(t*p)", "l, p, q = int(input()), int(input()), int(input())\nfirst_collision = (l / (p + q)) * p\nprint(first_collision)\n", "l,p,q = int(input()),int(input()),int(input())\r\nt = l/(p+q)\r\nprint(t*p)\r\n\r\n", "n = int(input())\r\n#a = input()\r\n#a = a.split()\r\n#a = [int(x) for x in a]\r\np = int(input())\r\nq = int(input())\r\n\r\n\r\n\r\n\r\n\r\nprint(n-(n*q/(p+q)))", "d = int(input())\r\nv1 = int(input())\r\nv2 = int(input())\r\nx = d/(v1+v2)\r\nprint(x*v1)", "l=int(input())\np=int(input())\nq=int(input())\n\nprint(float(p*float(l/(p+q))))", "dis = int(input(\"\"))\nvh = int(input(\"\"))\nvo = int(input(\"\"))\nprint((dis*vh)/(vh+vo))\n\t\t\t\t\t \t\t\t\t\t\t \t\t \t\t \t \t\t\t \t\t", "l, p, q = int(input()), int(input()), int(input())\r\nprint(p*l/(p+q))", "I=input;n,a=int(I()),int(I())\r\nprint(float(n*a)/(a+int(I())))", "s = int(input())\r\np = int(input())\r\nq = int(input())\r\nw = 0\r\nt1 = s/(p + q)\r\ns1 = p*t1\r\nt12 = s1/p\r\nt22 = (s-s1)/q\r\nif t12 > t22:\r\n s -= (t12-t22)*q\r\nelse:\r\n s -= (t22-t12)*p\r\n w = (t22-t12)*p\r\nprint(p*(s/(p + q))+w)\r\n", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nans = l * ((p)/(p + q))\r\nprint(ans)", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nt = l / (p + q)\r\ns = p * t\r\nprint(s)", "def solve(l,p,q):\r\n first_point = p * l/(p+q) # pt + qt = l -> t = l/(p+q)\r\n return first_point\r\n\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint(solve(l,p,q))", "d = int(input())\na = int(input())\nb = int(input())\n\nprint(a * (d/(a+b)))\n", "l = float(input())\r\nx = float(input())\r\ny = float(input())\r\n\r\nprint(x*l/(x+y))\r\n", "l = int(input())\r\nh = int(input())\r\nv = int(input())\r\nprint(l*(h/(h+v))) ", "l = int (input())\r\np = int (input())\r\nq = int (input())\r\nprint ( p*l / (p+q))", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\n\r\ntime=l/(p+q)\r\nprint(p*time)", "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright © 2015 missingdays <missingdays@missingdays>\n#\n# Distributed under terms of the MIT license.\n\na = int(input())\nb = int(input())\nc = int(input())\n\nd = b + c\n\nprint(a * b / d)\n", "\nl = int(input())\np = int(input())\nq = int(input())\n\nf = l* (p/(p+q))\n\nprint(f)\n", "a =int(input())\r\nb =int(input())\r\nc =int(input())\r\nprint(a*b /(b+c))", "from math import sqrt, pow, log, log2, log10, exp\r\nfrom copy import deepcopy\r\nfrom fractions import gcd\r\n\r\n\r\ndef read_ints():\r\n return list(map(int, input().split()))\r\n\r\n\r\ndef read_int():\r\n return read_ints()[0]\r\n\r\n\r\ndef read_floats():\r\n return list(map(float, input().split()))\r\n\r\n\r\ndef read_float():\r\n return read_floats()[0]\r\n\r\n\r\ndef format_list(l):\r\n return ' '.join(list(map(str, l)))\r\n\r\n\r\ndef one_dim_array(n, value=0):\r\n return [deepcopy(value) for x in range(n)]\r\n\r\n\r\ndef two_dim_array(n, m, value=0):\r\n return [[deepcopy(value) for x in range(m)] for x in range(n)]\r\n\r\n\r\ndef is_prime(n):\r\n if n == 2:\r\n return True\r\n if n % 2 == 0:\r\n return False\r\n for i in range(3, sqrt(n) + 1):\r\n if n % i == 0:\r\n return False\r\n return True\r\n\r\n\r\ndef max_len_sublist(l, f):\r\n start, max_length, length = 0, 0, 0\r\n for i in range(1, len(l)):\r\n if f(l[i], l[i - 1]):\r\n length += 1\r\n else:\r\n if max_length < length:\r\n start = i - length\r\n max_length = length\r\n length = 0\r\n return start, max_length\r\n\r\n\r\ndef tf_to_yn(b):\r\n return 'YES' if b else 'NO'\r\n\r\n\r\ndef longest_non_descent_subsequence(s, restore_sequence=False):\r\n d = one_dim_array(len(s), 0)\r\n for i in range(len(s)):\r\n possible = [d[j] + 1 if s[j] <= s[i] else 1 for j in range(i)]\r\n d[i] = 1 if len(possible) == 0 else max(possible)\r\n\r\n if not restore_sequence:\r\n return d[-1] if len(d) != 0 else 0\r\n\r\n\r\nl = read_int()\r\np = read_int()\r\nq = read_int()\r\nt = l / (p + q)\r\nprint(t*p)\r\n", "\"\"\"\nCodeforces Round #327 (Div. 2)\n\nProblem 591 A. Wizards' Duel\n\n@author yamaton\n@date 2015-11-06\n\"\"\"\n\nimport itertools as it\nimport functools\nimport operator\nimport collections\nimport math\nimport sys\n\n\ndef solve(l, p, q):\n return l * p / (p + q)\n\n\ndef print_stderr(*args, **kwargs):\n print(*args, file=sys.stderr, **kwargs)\n\n\ndef main():\n l = int(input())\n p = int(input())\n q = int(input())\n result = solve(l, p, q)\n print(result)\n\n\nif __name__ == '__main__':\n main()\n", "n=int(input())\r\np=int(input())\r\nq=int(input())\r\nprint(p*n/(p+q))\r\n", "l = int(input(\"\"))\np = int(input(\"\"))\nq = int(input(\"\"))\n\ntime = l / (p + q)\ndis = p * time\n\nprint(dis)\n\t\t\t\t\t\t \t\t \t \t\t \t\t\t \t\t\t\t", "#!/usr/bin/env python3\n\ndef solve(l, p, q):\n # l = t*p + t*q\n # l = t * (p + q)\n # t = l/(p + q)\n t = l/(p + q)\n return t*p\n\n\nif __name__ == '__main__':\n l = int(input())\n p = int(input())\n q = int(input())\n print(solve(l, p, q))\n", "l=int(input(\"\"))\r\nv1=int(input(\"\"))\r\nv2=int(input(\"\"))\r\nx=(l*v1)/(v1+v2)\r\nprint(x)", "l,p,q=int(input()),int(input()),int(input())\r\nimpulse_sum=p+q\r\n\r\na=0\r\nwhile(l>0):\r\n if(l>impulse_sum):\r\n a+=p\r\n else:\r\n a+=p*(l/impulse_sum)\r\n l=l-impulse_sum\r\nprint(a)", "l=int(input())\np=int(input())\nq=int(input())\nprint(l*p/(p+q))\n", "l = int(input())\r\nHarry = int(input())\r\nHWO = int(input())\r\n\r\nprint(Harry * (l / (Harry+HWO)))", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport time\n\nl = int(input())\np = int(input())\nq = int(input())\n\nstart = time.time()\n\n\nprint(l*p/(p+q))\nfinish = time.time()\n#print(finish - start)\n", "L = int(input())\np = int(input())\nq = int(input())\nR = p * (L / (p + q))\nprint(R)\n", " ### @author Juan Sebastian Beltran Rojas \r\n ### @mail [email protected] \r\n ### @veredict \r\n ### @url https://codeforces.com/problemset/problem/591/A\r\n ### @category \r\n ### @date 12/11/2019\r\n\r\nl = int(input())\r\nv1 = int(input())\r\nv2 = int(input())\r\n\r\nprint(l-(l*v2)/(v1+v2))", "def li():\r\n return list(map(int,input().split()))\r\ndef gi(n):\r\n return [list(map(int,input().split())) for _ in range(n)]\r\n\r\n# File input\r\n\r\n# import sys\r\n# sys.stdin = open('user.txt','r')\r\n\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nprint((l / (p+q)) * p)", "L = int(input())\nV1 = int(input())\nV2 = int(input())\n\nt = L/(V1+V2)\n\nS = t * V1\nprint(S)\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nx=(l*q)/(p+q)\r\nprint('%.4f'%(l-x))\r\n", "# print (\"Input l\")\nl = int(input())\n# print (\"Input p\")\np = int(input())\n# print (\"Input q\")\nq = int(input())\n\nprint((l*p)/(p+q))\n", "\r\n\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nt = l/(p+q)\r\nd = t*p\r\n\r\nprint(d)", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nans=l/(p+q)*p;\r\nprint(ans)", "l = input()\np = input()\nq = input()\n\nl = int(l)\np = int(p)\nq = int(q)\n\ncollision_distance = (p / (p + q)) * l\n\nprint(collision_distance)\n\t\t\t\t \t\t \t \t \t\t\t \t\t\t\t \t \t", "def main():\r\n l = int(input())\r\n p = int(input())\r\n q = int(input())\r\n print(p*(l/(p+q)))\r\nmain()\r\n", "s = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nprint(p * (s /( p + q)))\r\n", "l = int(input())\na = int(input())\nb = int(input())\n\nprint(float(l)/float(a+b)*a)", "def wizard():\r\n n = int(input())\r\n p = int(input())\r\n q = int(input())\r\n rangex = n / (p + q)\r\n distance = rangex * p\r\n print(distance)\r\n \r\nwizard()\r\n ", "n = int(input())\r\np = int(input())\r\nq = int(input())\r\nans = p * (n / (p+q))\r\nif ans == int(ans):\r\n print(int(ans))\r\nelse:\r\n print(ans)", "import sys\r\n\r\nlongitud = float(input())\r\na = float(input())\r\nb = float(input())\r\nresp = longitud/(1.0+(b/a))\r\nprint(resp)", "l = float(input())\r\np = float(input())\r\nq = float(input())\r\nprint((p*l) / (p+q))", "a = int(input())\nb = int(input())\nc = int(input())\n\nprint(a * b / (b + c))\n \t \t\t \t \t \t\t \t \t\t\t \t \t \t", "n = int(input())\r\na = int(input())\r\nb = int(input())\r\n\r\nprint((n*a)/(a+b))", "n = int(input())\r\np = int(input())\r\nq = int(input())\r\nt = n / (p + q)\r\nprint(p * t)\r\n", "print(float(input()) / (1 + 1 / float(input()) * float(input())))", "c = int(input())\nv1 = int(input())\nv2 = int(input())\nprint(c * v1 / (v1 + v2))\n \t \t\t\t \t\t \t \t\t\t\t \t\t\t \t\t\t", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint((l*p)/(p+q))\r\n", "length=int(input())\r\nw1=int(input())\r\nw2=int(input())\r\nratio=w1/(w1+w2)\r\nprint(length*ratio)", "def magic(lst):\r\n ans=[]\r\n for i in lst:\r\n m,a,b=i[0],i[1],i[2]\r\n tmp=m*a/(a+b)\r\n s=round(tmp,4)\r\n ans.append(s)\r\n return ans[0]\r\n\r\n\r\nm=int(input())\r\na=int(input())\r\nb=int(input())\r\nlst=[[m,a,b]]\r\n#print(lst)\r\nprint(magic(lst))\r\n", "I = lambda: int(input())\r\nl = I()\r\np = I()\r\nq = I()\r\nprint(l/(p+q)*p)\r\n", "l=int(input())\r\nh=int(input())\r\nv=int(input())\r\nprint((h/(v+h)*l))", "l = float(input())\r\np = float(input())\r\nq = float(input())\r\nprint((l/(p + q))*p)", "n,p,q=int(input()),int(input()),int(input())\r\nprint(n-((n/(p+q))*q))", "\r\n\r\nif __name__ == '__main__':\r\n l = int(input())\r\n p = int(input())\r\n q = int(input())\r\n\r\n t = l / (p + q)\r\n print(p*t);", "def solve(l,a,b):\n x, y = l / a, l / b\n print(l * y / (x + y))\n\nl = int(input())\na = int(input())\nb = int(input())\n\nsolve(l,a,b)\n", "import math\n\ndef main():\n l = int(input())\n v1 = int(input())\n v2 = int(input())\n return l / (v1+v2) * v1\n\n\n\nif __name__==\"__main__\":\n print(main())\n", "l = int(input())#meters\r\np = int(input()) #meters/sec\r\nq = int(input())\r\nt1 = 0\r\nif (p + q > 0):\r\n t1 = l / (p + q)\r\nprint(t1 * p)", "a=int(input())\r\nb=int(input())\r\nc=int(input())\r\nprint((a/(b+c))*b)", "if __name__ == '__main__':\n l=int(input())\n p=int(input())\n q=int(input())\n s= l/(p+q)\n x=p*s\n print(x)\n \t \t \t \t\t \t\t \t \t \t \t \t \t\t\t", "a = []\r\nfor i in range(3):a.append(int(input()))\r\nl,p,q=a[0],a[1],a[2]\r\nprint(p*(l/(p+q)))", "a = int(input())\r\nb = int(input())\r\nc = int(input())\r\n\r\np = b / (b+c)\r\nprint(a * p)", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\ndistance = (l * p) / (p + q)\r\n\r\nprint(\"{:.4f}\".format(distance))\r\n", "s = int(input())\r\ng = int(input())\r\nq = int(input())\r\nprint(((s*1.0)/(g+q))*g)\r\n", "l=input()\np=input()\nq=input()\nl=int(l)\np=int(p)\nq=int(q)\nb=(l/(q+p)*p)\nb=float(b)\nprint(b)\n \t\t\t \t \t\t\t\t \t\t \t\t\t \t\t\t", "l = float(input())\r\np = float(input())\r\nq = float(input())\r\nprint(l*p/(p+q))\r\n", "l,p,q=int(input()),int(input()),int(input())\r\nprint((p*l)/(p+q))\r\n", "l = int(input())\np = int(input())\nq = int(input())\nt = l/(p+q)\na = p*t\nprint(a)\n", "l = [int(input()) for x in range(3)]\r\nprint(l[0]*l[1]/(l[1]+l[2]))", "n=int(input())\r\np=int(input())\r\nq=int(input())\r\nn=n*p\r\nn=n/(p+q)\r\nprint(n)", "l = int(input())\r\n\r\nharry_speed = int(input())\r\nvolde_speed = int(input())\r\n\r\nc1_pos = harry_speed * (l / (harry_speed + volde_speed))\r\nprint(c1_pos)", "a=float(input())\r\nb=float(input())\r\nc=float(input())\r\nprint(a*(b/(b+c)))\r\n", "n=int(input())\r\na=int(input())\r\nb=int(input())\r\n\r\nprint(round((a/(a+b))*n,8))", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nans = (l*p)/(p+q)\r\nprint(ans)", "l =int( input());\r\nq=int(input());\r\np=int(input());\r\nprint( (1.0*l/(q+p))*q);", "l = int(input()) # Length of the corridor\np = int(input()) # Speed of Harry Potter's magical impulse\nq = int(input()) # Speed of He-Who-Must-Not-Be-Named's magical impulse\n\n# Calculate the distance from the end of the corridor to the meeting point\n# Distance = (l * p) / (p + q)\ndistance = (l * p) / (p + q)\n\nprint(distance)\n\n \t\t\t \t\t \t\t \t \t \t \t\t\t \t \t \t", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nprint(l*(p/(p+q)))", "a=int(input())\r\nb=int(input())\r\nc=int(input())\r\nx=(a*c)/(b+c)\r\nprint(a-(x))", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\n# Calculate the time to the first meeting.\r\ntime_to_first_meeting = l / (p + q)\r\n\r\n# Calculate the distance to the first meeting for both impulses.\r\ndistance_harry_to_first_meeting = p * time_to_first_meeting\r\ndistance_voldemort_to_first_meeting = l - q * time_to_first_meeting\r\n\r\n# Calculate the time to the second meeting.\r\ntime_to_second_meeting = l / (p + q)\r\n\r\n# Calculate the distance to the second meeting for both impulses.\r\ndistance_harry_to_second_meeting = p * time_to_second_meeting\r\ndistance_voldemort_to_second_meeting = l - q * time_to_second_meeting\r\n\r\n# The final answer is the distance from Harry to the place of the second meeting.\r\nfinal_distance = distance_harry_to_second_meeting\r\nprint(final_distance)\r\n", "from math import gcd\r\ndef solve():\r\n l=int(input());har=int(input());som=int(input());c=0\r\n print((l/(har+som))*har)\r\nsolve()\r\n \r\n ", "a = int(input())\nb = int(input())\nc = int(input())\nx = a/(b+c)\nprint(x*b)\n\n \t\t\t\t\t\t\t\t \t\t \t\t \t\t\t\t\t \t\t", "from collections import defaultdict\r\nimport math\r\n\r\ndef pug_func(l, p, q) -> int:\r\n\r\n # arr = list(map(int, s.split(\" \")))\r\n # rev_arr = arr[::-1]\r\n\r\n # s = set()\r\n # L = 0\r\n # for i in range(len(arr)):\r\n # if rev_arr[i] not in s:\r\n # s.add(rev_arr[i])\r\n # else:\r\n # break\r\n\r\n # L += 1\r\n\r\n # return len(arr) - L\r\n vel = l / (p + q)\r\n return vel * p\r\n\r\n\r\n\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\nx = pug_func(l, p, q)\r\nprint(x)\r\n\r\n# t = int(input())\r\n# lista_ans = []\r\n\r\n# for _ in range(t):\r\n# n = input()\r\n# line = input()\r\n# lista_ans.append(line)\r\n\r\n# for ans in lista_ans:\r\n# x = pug_func(ans)\r\n# print(x)\r\n", "l = float(input())\r\np = float(input())\r\nq = float(input())\r\nprint(l * p / (p + q))", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Jun 28 07:38:07 2019\r\n\r\n@author: avina\r\n\"\"\"\r\n\r\na = int(input());b= int(input());c = int(input())\r\n\r\nt = a/(b+c)\r\nprint(b*t)", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nprint(round(l*p/(p+q),10))\r\n", "length = int(input())\r\nHarry = int(input())\r\nLVold = int(input())\r\n\r\nprint((length/(Harry + LVold))*Harry)", "l=int(input())\r\nx=int(input())\r\ny=int(input())\r\nm=l/(x+y)\r\nprint(m*x)\r\n", "s = int(input())\nv1 = int(input())\nv2 = int(input())\n\ns1 = s*v1\ns1 = s1 / (v1+v2)\nprint(s1)\n", "def dist(l,p,q):\r\n x=p*l/(p+q)\r\n print(x)\r\n\r\n\r\na=int(input(''))\r\nb=int(input(''))\r\nc=int(input(''))\r\ndist(a,b,c)", "t=int(input())\r\nhh=int(input())\r\nss=int(input())\r\ntime=(t)/(hh+ss)\r\nprint(time*hh)", "l = int(input())\np = int(input())\nq = int(input())\nif l >=1 and l <=1000:\n if p >=1 and p <=500:\n if q >=1 and q <=500:\n s = l / (p + q)\n ans = s * p\n print(ans)\n\n\t\t\t \t\t\t\t\t \t \t\t \t\t \t", "# Read input\nl = float(input())\np = float(input())\nq = float(input())\n\n# Calculate relative speed\ntemp0 = p + q\n\n# Calculate time to first meeting\ntemp1 = l / temp0\n\n# Calculate distance traveled to first meeting\nans = p * temp1\n\n\n\n# Print the result\nprint(ans)\n\t\t\t\t\t \t \t\t \t\t\t \t \t\t\t \t\t\t", "w1=int(input())\nx1=int(input())\nz1=int(input())\nif w1 >= 1 and w1<=1000 and x1 >=1 and x1 <=500 and z1 >=1 and z1 <= 500:\n print(x1*(w1/(x1+z1)))\n\t \t \t \t \t\t\t\t \t \t\t\t \t\t\t", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint((float(p)/(p+q))*l)", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nprint((p / (p + q)) * l)", "d=int(input())\r\ns1=int(input())\r\ns2=int(input())\r\nt=d/(s1+s2)\r\nc=t*s1\r\nif(int(c)==c):\r\n print(int(c))\r\nelse:\r\n print(c)", "l=int(input())\np=int(input())\nq=int(input())\nif l >= 1 and l<=1000 and p >=1 and p <=500 and q >=1 and q <= 500:\n print(p*(l/(p+q)))\n \n \t \t\t \t \t\t\t \t\t\t \t\t\t\t\t", "x=int(input())\r\ny=int(input())\r\nz=int(input())\r\nprint(x/(y+z)*y)", "len,q_speed,p_speed=int(input()),int(input()),int(input())\r\nprint(len*q_speed/(q_speed+p_speed))", "import sys\r\nimport math\r\nimport bisect\r\nimport itertools\r\nimport random\r\n\r\n\r\ndef main():\r\n l = int(input())\r\n p = int(input())\r\n q = int(input())\r\n ans = l * p / (p + q)\r\n print('%.10f' % (ans))\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n1=int(input())\nn2=int(input())\nn3=int(input())\nif n1 >= 1 and n1<=1000 and n2 >=1 and n2 <=500 and n3 >=1 and n3 <= 500:\n print(n2*(n1/(n2+n3)))\n \t\t \t \t\t\t\t \t \t \t\t\t \t \t\t", "l=int(input())\r\nv1=int(input())\r\nv2=int(input())\r\nans=v1*l/(v1+v2)\r\nprint(ans)", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\n\r\n\r\n\r\nprint((p/(p+q))*l)\r\n", "a, b, c = int(input()), int(input()), int(input())\r\nprint((b * a)/(b + c))", "a = int(input())\nb = int(input())\nc = int(input())\n\n'''Just beat it'''\n\ncd = round(a * b / (b + c), 7)\n\nc = a * b // (b + c)\nif c == cd:\n print(c)\nelse:\n print(cd)\n\n\n \t\t \t\t\t \t\t\t\t\t \t\t \t\t\t \t\t\t\t", "d,h,v = [int(input()) for x in range(3)]\r\ntime = d/(h+v)\r\nhit = time*h\r\nprint(hit)", "l = int(input())\np = int(input())\nq = int(input())\nfactor = float(l/(p+q))\nres = factor*p\nprint(res)\n\t \t \t \t \t \t \t\t\t\t\t", "# l = int(input()) ; p = int(input()) ; q = int(input())\n# n = 0\n# sumof = (p + q) // \n# if p == q and p + q == l:\n# \tprint(p)\n# \texit()\n# while p < q or q < p or p + q != l:\n# \tif l <= 0:\n# \t\tprint(l)\n# \t\tbreak\n# \telse:\n# \t\tl -= sumof // 2 ; n += sumof // 2\n\nl = int(input()) ; p = int(input()) ; q = int(input())\nsumof = p + q\nprint((l / sumof) * p)\n", "import math\r\n\r\nl = int(input().strip())\r\np = int(input().strip())\r\nq = int(input().strip())\r\n\r\nr = math.ceil(l/(p+q))\r\n\r\npr = p * r\r\nqr = l - (q * r)\r\n\r\ns = qr + (pr - qr) * (q/(q+p))\r\n\r\nprint(s)\r\n", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nt = l/(p+q)\r\nd = p*t\r\nprint(d)", "a=float(input())\r\nb=float(input())\r\nc=b+float(input())\r\nprint(a*(b/(c)))\r\n", "def point(l,a,b):\r\n return (l*a)/(a+b)\r\n\r\nl=int(input())\r\na=int(input())\r\nb=int(input())\r\nprint(point(l,a,b))", "a,b,c=int(input()),int(input()),int(input())\r\nprint(b*(a/(b+c)))", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nans=(p*l)/(p+q)\r\nprint(ans)\r\n \r\n \r\n", "distance = int(input())\r\nspeed_harry = int(input())\r\nspeed_wizard = int(input())\r\n\r\nt = distance / (speed_wizard + speed_harry)\r\nprint(t*speed_harry)", "l=int(input())\r\np= int(input())\r\nq=int(input())\r\n\r\nprint((l/2) if p==q else l*(p/(p+q)) )\r\n\r\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nr=(q*l)/(p+q)\r\nprint(l-r)", "l = int(input(\"\")) \np = int(input(\"\")) \nq = int(input(\"\"))\nt = l/(p+q)\nd = t*p\nprint(d)\n \t \t\t\t\t \t \t\t\t\t\t \t\t\t \t\t\t", "\r\nl = float(input())\r\np = float(input())\r\nq = float(input())\r\n\r\ntotal = (l / (p + q)) * p\r\n\r\nprint(int(total) if total // 1 == total else total)\r\n", "l=int(input())\np=int(input())\nq=int(input())\n\nprint('{:.4f}'.format(l*p/(p+q)))\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Wed Dec 9 17:18:31 2020\r\n\r\n@author: LuigiP.\r\n\"\"\"\r\n\r\ndata = {\"d_corridor\":1,\"s_harry\":1,\"s_vol\":1}\r\nfor k in data.keys():\r\n data[k] = int(input())\r\nprint((data[\"d_corridor\"]/(data[\"s_harry\"]+data[\"s_vol\"]))*data[\"s_harry\"])", "# Input\nl = int(input())\np = int(input())\nq = int(input())\n\n# the time taken for the first collision\nt1 = l / (p + q)\n\n# the distance traveled by each impulse after the first collision\nd1 = p * t1\nd2 = q * t1\n\n# the time taken for the second collision\nt2 = (l - d1 - d2) / (p + q)\n\n# the distance traveled by Harry's impulse after the second collision\nd3 = p * t2\n\n# the distance from Harry's position to the place of the second collision\nd = d1 + d3\n\n# Print the result\nprint(d)\n\t\t \t\t\t \t \t \t \t\t \t\t\t \t \t \t", "l = int(input())\np = int(input())\nq = int(input())\nprint( l / (p+q) * p)\n\t\t\t \t\t\t \t\t \t\t\t \t \t\t\t \t \t", "a = int(input())\nb = int(input())\nc = int(input())\n\nprint(round(a * b / (b + c), 7))\n\n \t \t\t \t \t\t\t\t \t\t\t \t\t\t \t \t\t\t\t", "# import sys/ut2.out\",\"w\")\r\nN=int(input())\r\na=int(input())\r\nb=int(input())\r\nprint(a*(N/(a+b)))", "l=float(input())\r\np=float(input())\r\nq=float(input())\r\ntime=l/(p+q)\r\ndist=p*time\r\nprint(dist)", "x,y,z=int(input()),int(input()),int(input())\r\nprint((x*y)/(z+y))", "x = int(input())\r\nx1 = int(input())\r\nx2 = int(input())\r\nt = x/(x1+x2)\r\nprint(x-x2*t)", "corridor_length = int(input())\r\nharry = int(input())\r\nvoldy = int(input())\r\ntime = corridor_length / abs(harry + voldy)\r\ndist = time * harry\r\nprint(dist)", "# Link on Codeforce\r\n# \" https://codeforces.com/problemset/problem/591/A \"\r\n# ####################\r\n\r\n# Input Operation\r\nlength=int(input())\r\np=int(input())\r\nq=int(input())\r\n# Output Operation\r\nprint(p*(length/(p+q)))", "l=float(input())\r\np=float(input())\r\nq=float(input())\r\nprint(l*p/(p+q))\r\n\r\n\r\n", "l=int(input())\r\na=int(input())\r\nb=int(input())\r\nc=(l/(a+b))*a\r\nprint(\"%.4f\"%c)", "L=int(input())\r\nv1=int(input())\r\nv2=int(input())\r\nv=v1+v2\r\nt=L/(v) \r\nprint(v1*t)", "l, p, q = [int(input()) for i in range(3)]\r\nx = l / (p + q)\r\nprint(x * p)\r\n", "a,b,c=int(input()),int(input()),int(input())\r\nprint((a*b)/(b+c))", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nt= l/(p + q)\r\nm1 = t * p\r\nprint(m1)\r\n", "def main():\r\n\r\n def solve(l, p, q):\r\n return(l * p) / (p + q)\r\n\r\n l = int(input())\r\n p = int(input())\r\n q = int(input())\r\n print(solve(l, p, q))\r\n\r\nif __name__ == \"__main__\":\r\n import sys, threading\r\n input = sys.stdin.readline\r\n thread = threading.Thread(target=main)\r\n thread.start()\r\n thread.join()", "l = int( input() )\r\np = int( input() )\r\nq = int( input() )\r\n\r\nans = l * p / ( p+q )\r\nprint( ans )\r\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nm=l/(p+q)\r\nprint(m*p)\r\n", "from sys import stdin\r\nfrom sys import exit\r\n\r\nlive = True\r\nif not live: stdin = open('data.in', 'r')\r\n\r\nd = int(stdin.readline())\r\nv1 = int(stdin.readline())\r\nv2 = int(stdin.readline())\r\n\r\nprint(v1 * d / (v1 + v2))\r\n\r\nif not live: stdin.close()", "n=int(input());a=int(input())\nprint((n*a)/(a+int(input())))\n", "x=int(input())\r\ny=int(input())\r\nz=int(input())\r\na=(1.0*x)/(y+z)\r\nprint(a*y)", "n=int(input())\r\na=int(input())\r\nb=int(input())\r\nprint((n*a)/(a+b))", "l = int(input())\r\nn = int(input())\r\nm = int(input())\r\nprint(l*(n/(n+m))+1e-9)", "L = int(input())\na, b = int(input()), int(input())\nprint(L * a / (a + b))\n", "l=int(input())\na=int(input())\nb=int(input())\nt=l/(a+b)\ns=t*a\nprint('%0.4f'%s)\n", "l,p,q=int(input()),int(input()),int(input())\r\nprint(p*(l/(p+q))) ", "l = int(input())\np = int(input())\nq = int(input())\n\nprint((p/(p+q))*l)\n", "def calculate_distance(l, p, q):\n \"\"\"Calculates the distance from Harry's position to the place of the second collision of the spell impulses.\n\n Args:\n l: The length of the corridor.\n p: The speed of Harry's magic spell.\n q: The speed of Voldemort's magic spell.\n\n Returns:\n The distance from Harry's position to the place of the second collision of the spell impulses.\n \"\"\"\n\n total_time = l / (p + q)\n return total_time * p\n\n\ndef main():\n \"\"\"Reads the input and prints the output.\"\"\"\n l = int(input())\n p = int(input())\n q = int(input())\n\n distance = calculate_distance(l, p, q)\n print(distance)\n\n\nif __name__ == \"__main__\":\n main()\n\t \t \t\t \t\t\t \t\t \t \t \t", "d = int(input())\na = int(input())\nb = int(input())\nt = d / (a + b)\nprint(t * a)", "n=int(input());m=int(input());k=int(input());s=n*m;s1=m+k;print(s/s1)", "l=int(input())\r\np= int(input())\r\nq=int(input())\r\n\r\nprint(l*(p/(p+q)))", "length = int(input()) \nspeed1 = int(input()) \nspeed2 = int(input()) \n\ntime = length / (speed1 + speed2)\n\n\ndistance_from_harry = speed1 * time\n\n\nprint(distance_from_harry)\n\n \t \t \t\t\t\t\t \t \t \t \t \t\t", "l=int(input())\r\nx=int(input())\r\ny=int(input())\r\nprint((l/(x+y))*x)", "def solve(l, p, q):\n return p*(l/(p+q))\n\n\ndef main():\n l = int(input())\n p = int(input())\n q = int(input())\n print(solve(l, p, q))\n\n\nmain()\n", "def distance():\r\n dis = int(input())\r\n v1 = int(input())\r\n v2 = int(input())\r\n print(v1*dis /(v1+v2))\r\ndistance()", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nprint((l * p)/(p + q))", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nif p*(l/(p+q)) == int(p*(l/(p+q))):\r\n print(int(p*(l/(p+q))))\r\nelse:\r\n print(p*(l/(p+q)))", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\n# print(\"%.4f\"%c)\r\nprint(\"%.4f\"%(l/(p+q)*p))", "l = int(input())\r\nh = int(input())\r\nw = int(input())\r\no = (l * h)/(w + h)\r\nprint(o)", "l,p,q =[int(input()) for x in range(3)]\r\ndist_covered = p*(l/(p+q))\r\nprint(dist_covered)", "l=float(input())\r\np=float(input())\r\nq=float(input())\r\na=l*p/(p+q)\r\nprint(a)\r\n", "l = float(input())\np = int(input())\nq = int(input())\nprint(l*p/(p+q))\n \t\t \t\t \t \t\t \t \t\t\t \t \t", "l=int(input())\np=int(input())\nq=int(input())\ndic=q/p;dic+=1\nl/=dic\nif l==int(l):\n print(int(l))\nelse:\n print(l)\n \t\t\t \t \t \t\t \t\t \t\t\t\t \t \t \t", "# Take input\r\ncorridor_length = int(input())\r\np_speed = int(input())\r\nq_speed = int(input())\r\n\r\n# Calculate the distance to the second collision point\r\ndistance = p_speed * corridor_length / (p_speed + q_speed)\r\n\r\n# Display the result\r\nprint(distance)", "l,p,q=int(input()),int(input()),int(input())\r\nprint((p/(p+q))*l)\r\n", "# ===================================\r\n# (c) MidAndFeed aka ASilentVoice\r\n# ===================================\r\n# import math, fractions, collections\r\n# ===================================\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint(p*l/(p+q))", "n = int(input())\np = int(input())\nq = int(input())\nprint(p*n/(p+q))\n\n", "distance = int(input())\r\nh_spell = int(input())\r\nlw_spell = int(input())\r\nprint(h_spell * (distance/(h_spell+lw_spell)))", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nt=l/(p+q)\r\nd=t*p\r\nprint(d)\r\n", "x, a, b = int(input()), int(input()), int(input())\nprint(x*a/float(a+b));\n", "a = int (input())\r\ns = int (input())\r\nd = int (input())\r\nz = []\r\nz.append(s)\r\nz.append(d)\r\nsum1 = s + d\r\nc = (a / sum1 )\r\nprint (c * s)\r\n", "l = int(input()) \np = int(input()) \nq = int(input()) \n\nt2 = l / (p + q)\n\ndistance = p * t2\nprint(distance)\n\t \t \t \t \t \t\t \t \t \t", "a= int(input())\np = int(input())\nq = int(input())\n\nrltspeed = p + q\nfstmtime = a / rltspeed\nscdmdis = p * fstmtime\nprint(scdmdis)\n \t\t \t \t \t\t\t\t\t \t \t \t \t \t \t \t", "n = int(input())\r\na = int(input())\r\nb = int(input())\r\nprint(n*(a/(a+b)))\r\n", "l = int(input())\np = int(input())\nq = int(input())\nt = l / (p + q)\nprint(p * t)\n", "#-------------Program--------------\r\n#----Kuzlyaev-Nikita-Codeforces----\r\n#-------------Training-------------\r\n#----------------------------------\r\n\r\nl=int(input())\r\np=int(input())\r\nq=int(input())\r\nt=l/(p+q)*p\r\nprint(t)", "\"\"\"\r\nCodeforces Problem\r\n\r\nAuthor : chaotic_iak\r\nLanguage: Python 3.4.3\r\n\"\"\"\r\n\r\n################################################### SOLUTION\r\n\r\ndef main():\r\n l, = read()\r\n p, = read()\r\n q, = read()\r\n return p*l/(p+q)\r\n\r\n#################################################### HELPERS\r\n\r\ndef read(typ=int):\r\n # None: String, non-split\r\n # Not None: Split\r\n input_line = input().strip()\r\n if typ is None:\r\n return input_line\r\n return list(map(typ, input_line.split()))\r\n\r\ndef write(s=\"\\n\"):\r\n if s is None: s = \"\"\r\n if isinstance(s, list): s = \" \".join(map(str, s))\r\n s = str(s)\r\n print(s, end=\"\")\r\n\r\nwrite(main())\r\n", "L = int(input())\np = int(input())\nq = int(input())\nprint(p * (L / (p+q)))\n", "def solve(l, v1, v2):\n t = l / (v1 + v2)\n x = v1 * t\n return x\n\n\nl = int(input())\nv1 = int(input())\nv2 = int(input())\n\nprint(solve(l, v1, v2))\n \t\t\t \t\t\t\t \t\t\t\t \t \t\t \t\t", "n=int(input())\r\nl=int(input())\r\nm=int(input())\r\nprint(\"{0:.5f}\".format(n*l/(l+m)))\r\n\r\n \r\n", "length, p, q = int(input()), int(input()), int(input())\r\nprint(length * p / (p + q))", "l = int(input())\r\na = int(input())\r\nb = int(input())\r\n\r\nprint(l/(a+b)*a)\r\n", "l, x, y = map(int, [input() for i in range(3)])\nprint(x * l / (x + y))\n", "l, p, q = map(int, [input().strip() for _ in range(3)])\nsegment_length = l / (p + q)\nprint(p * segment_length)\n", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\ndis = l * p/(p+q)\r\nprint(dis)", "# coding=utf-8\r\n\r\n\r\nif __name__ == '__main__':\r\n n = int(input())\r\n p = int(input())\r\n q = int(input())\r\n print(n * p / (p + q))\r\n", "n,p,q = int(input()),int(input()),int(input())\r\nprint(n*(1/(1+(q/p))))\r\n", "n=int(input())\r\np=int(input())\r\nq=int(input())\r\nprint((n*p)/(p+q))", "l=[int(input()) for i in range(3)]\r\nprint((l[1]/(l[1]+l[2]))*l[0])", "a, b, c = int(input()),int(input()),int(input())\nprint(a*(b/(b+c)))\n", "l=eval(input())\r\np=eval(input())\r\nq=eval(input())\r\nd=l/(q*((1/p)+(1/q)))\r\nprint(round(d,4))\r\n", "n, a, b = float(input()), float(input()), float(input())\r\nprint(a * (n / (a + b)))", "x=int(input());a=int(input());b=int(input())\r\nprint(a*(x/(a+b)))", "def solve():\n l = int(input())\n p = int(input())\n q = int(input())\n\n print(l * p / (p + q))\n\n\nif __name__ == '__main__':\n solve()\n", "l = int(input())\np = int(input())\nq = int(input())\ntime = l/(p+q)\ndistance_from_harry = p*time\nprint(distance_from_harry)\n\n\t \t \t \t \t \t\t \t", "hoggy=int(input())\r\nhp=int(input())\r\nvoldy=int(input())\r\nmag=hp+voldy\r\ntt=hoggy/mag\r\nharry_mah_buoy=tt*hp\r\nprint(harry_mah_buoy)\r\n", "print(int(input()) * (1 - 1 / (1 + int(input()) / int(input()))))", "l = int(input())\np = int(input())\nq = int(input())\nans= l/(p+q)\nprint(ans*p)\n\t \t\t\t \t\t \t \t \t\t\t\t", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nr = p/(p + q)\r\nprint(l * r)\r\n", "from operator import itemgetter\r\n#int(input())\r\n#map(int,input().split())\r\n#[list(map(int,input().split())) for i in range(q)]\r\n#print(\"YES\" * ans + \"NO\" * (1-ans))\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\nnum = p + q\r\nnum2 = l / num\r\nprint(p * num2)\r\n", "a=int(input())\r\nb=int(input())\r\nc=int(input())\r\nc+=b\r\nb/=c\r\nprint(a*b)", "while True:\n try:\n x= float(input())\n a= float(input())\n b= float(input())\n\n\n spd = x / (a + b)\n ans = spd * a\n print(ans)\n except EOFError:\n break\n \t\t\t \t \t\t \t \t\t \t \t\t \t \t\t", "# Coded By Block_Cipher\r\n \r\nimport math\r\nimport os\r\nimport random\r\nimport re\r\nimport sys\r\nfrom math import gcd\r\nfrom math import sqrt\r\n \r\n# sys.stdin = open('input.txt', 'r')\r\n# sys.stdout = open('output.txt', 'w')\r\n\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nx = p*l/(p+q)\r\n\r\nprint(x)\r\n\r\n\r\n", "l=int(input())\np=int(input())\nq=int(input())\n\nprint(l * p / float(p + q))\n", "d=int(input())\r\nh=int(input())\r\no=int(input())\r\nprint(d*(h/(h+o)))", "L,p,q=int(input()),int(input()),int(input())\r\nprint((p*L)/(p+q))", "l=int(input())\r\na=int(input())\r\nb=int(input())\r\nprint(l*a/(a+b))\r\n", "n = int(input())\r\np = int(input())\r\nq = int(input())\r\na = n\r\nif p+q == n:\r\n\tprint(n-q)\r\nelse:\r\n\ta = a/(p+q)\r\n\tprint(n - a*q)", "n = int(input())\r\na = int(input())\r\nb = int(input())\r\nprint((n/(a+b))*a)", "l=input()\nv1=input()\nv2=input()\n\nl=int(l)\nv1=int(v1)\nv2=int(v2)\n\ntotal_v=v1+v2\n\nt=l/total_v\n\nans=t*v1\nprint(ans)\n\n\n\n\n \t\t \t\t\t\t\t \t\t\t\t\t\t\t \t\t\t\t \t\t \t\t", "\r\ni= int(input())\r\np= int(input())\r\nq= int(input())\r\nprint((i*p) / (p+q))", "n=int(input())\r\np=int(input())\r\nq=int(input())\r\nif n%(p+q)==0:\r\n print(int(((n*p)/(p+q))))\r\nelse:\r\n print(((n*p)/(p+q)))\r\n", "l = int(input())\r\nvg = int(input())\r\nvv = int(input())\r\ntm = l/(vg + vv)\r\nsm = tm * vg \r\nprint(sm)", "withFile = 0\n\nif(withFile == 1):\n fin = open('input.txt', 'r')\n fout = open('output.txt', 'w')\n\ndef getl():\n if(withFile == 0):\n return input()\n else:\n return fin.readline()\ndef printl(s):\n if(withFile == 0):\n print(s)\n else:\n fout.write(str(s))\ndef get_arr():\n x = getl().split(' ')\n if(x[-1] == ''):\n x = x[:-1]\n return list(map(int, x))\n\nl = get_arr()[0]\nb = get_arr()[0]\nc = get_arr()[0]\nt = l / (1.00 * b + c)\nprint(t*b)\n\n\nif(withFile == 1):\n fin.close()\n fout.close()", "\"\"\" Задача А\"\"\"\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\ns = p + q\r\nt = l / s\r\nl0 = t * p\r\nprint(l0)\r\n", "n = int(input())\r\na = int(input())\r\nb = int(input())\r\nans = n*(a/(a+b))\r\nprint(ans)", "def solve():\r\n n,p,q=int(input()),int(input()),int(input())\r\n # x=\r\n print(n-((n/(p+q))*q))\r\n\r\nsolve()\r\n", "from math import dist, ceil, floor, sqrt, log\r\nimport itertools\r\nimport math\r\nimport functools\r\nimport operator\r\nimport collections\r\nimport heapq\r\nimport re\r\nimport string\r\nfrom sys import stdin\r\ninp = stdin.readline\r\ndef IA(sep=' '): return list(map(int, inp().split(sep)))\r\ndef QIA(sep=' '): return deque(map(int, inp().split(sep)))\r\ndef FA(): return list(map(float, inp().split()))\r\ndef SA(): return list(input())\r\ndef I(): return int(inp())\r\ndef F(): return float(inp())\r\ndef S(): return input()\r\ndef O(l: list): return ' '.join(map(str, l))\r\n\r\n\r\ndef main():\r\n l = I()\r\n p = I()\r\n q = I()\r\n\r\n seconds_to_meet = l/(p+q)\r\n return p*seconds_to_meet\r\n\r\n\r\nif __name__ == '__main__':\r\n print(main())\r\n", "a=float(input())\r\nb=float(input())\r\nc=a*(b/(b+float(input())))\r\nprint(c)\r\n", "n = int(input())\na = int(input())\nb = int(input())\nt = n/(a+b)\nprint(a*t)\n", "n = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nmn = p*(n/(q+p))\r\n\r\nprint(mn)", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint(p/(p+q)*n)", "l,p,q=int(input()),int(input()),int(input())\r\nx=l*p\r\ny=p+q\r\nif x%y==0:\r\n print(x//y)\r\nelse:\r\n print(\"{:.4f}\".format(x/y))", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint(p*(l/(p+q)))\r\n", "l = int(input())\r\nv1 = int(input())\r\nv2 = int(input())\r\nprint(l * v1/(v1 + v2))", "I=lambda:int(input());l=I();p=I();q=I();print(p*l/(q+p))", "# cook your dish here\nl=int(input())\nv1=int(input())\nv2=int(input())\nprint(l*v1/(v1+v2))", "import math as mt \r\nimport sys,string,bisect\r\ninput=sys.stdin.readline\r\nimport random\r\nfrom collections import deque,defaultdict\r\nL=lambda : list(map(int,input().split()))\r\nLs=lambda : list(input().split())\r\nM=lambda : map(int,input().split())\r\nI=lambda :int(input())\r\nl=I()\r\np=I()\r\nq=I()\r\nprint((l/(p+q))*p)\r\n", "l = int(input())\np = int(input())\nq = int(input())\nans = l / (p + q) * p\nprint(ans)\n", "j = input()\np = input()\nq = input()\n\nj = int(j)\np = int(p)\nq = int(q)\n\nssp = p+q\ntime = j/ssp\nprint(p*time)\n \t\t\t\t\t \t \t\t\t \t \t\t\t \t\t", "l = int(input())\r\nx = int(input())\r\ny = int(input())\r\nprint(x * l / (x + y))", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint((float(l)/(p + q)) * p)", "l=int(input())\np=int(input())\nq=int(input())\nprint(1.0*p*l/(p+q))\n\n", "#python 3.5.2\r\n\r\nl=int(input())\r\np=int(input())\r\nq=int(input())\r\nx=l/(p+q)\r\nd1=p*x\r\nd2=q*x\r\n\r\nprint(d1)", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nt1 = l / (p + q)\r\nmp = p * t1\r\nmq = q * t1\r\nprint(mp)", "s=eval(input())\nb=eval(input())\nc=eval(input())\nr=(s/(b+c))*b\nprint(r)\n \t \t \t\t\t \t\t\t \t \t \t \t\t\t\t", "n,a,b=[int(input())for _ in[1,2,3]]\r\n\r\nprint((n*a/(a+b)))", "# import sys\r\n# sys.stdin=open(\"input.in\",\"r\")\r\n# sys.stdout=open(\"output.out\",\"w\")\r\n\r\nl=int(input())\r\np=int(input())\r\nq=int(input())\r\n\r\ny=float((p*l)/(p+q))\r\nprint(y)", "l = float(input())\r\ns1 = float(input())\r\ns2 = float(input())\r\nprint(((s1*l)/(s2+s1)))", "masofa=int(input())\r\nskorost1=int(input())\r\nskorost2=int(input())\r\nx=masofa/(skorost1+skorost2)\r\nprint(skorost1*x)", "l=int(input().strip())\r\np=int(input().strip())\r\nq=int(input().strip())\r\n\r\nans=(l*p)/(p+q)\r\nprint(ans)\r\n", "i=int(input())\np=int(input())\nq=int(input())\ncnt=0\nwhile i>0:\n i-=p\n i-=q\n cnt+=1\na=abs(i)\nb=p+q\nc=p/b\nd=c*a\nx=cnt*p-d\nprint(x)\n\n \t\t \t \t\t\t \t \t \t \t\t", "A = int(input())\nB = int(input())\nC = int(input())\n\nspd = 0\nans = 0\n\n\nspd = A/(B+C);\nans = spd*B ;\n \n\nprint(ans)\n\t \t\t\t\t\t \t \t \t\t\t\t \t", "length = int(input())\r\nharrys_speed = int(input())\r\nother_speed = int(input())\r\n\r\n\r\ndef calculate_distance(l, p, q):\r\n t = l / (p + q)\r\n distance = t * p\r\n return distance\r\n\r\nprint(calculate_distance(length, harrys_speed, other_speed))", "\n\nif __name__ == '__main__':\n # 199,60,40\n\n l = int(input())\n V_harry = int(input())\n V_voldermon = int(input())\n\n t = l / ( V_harry + V_voldermon )\n print(V_harry * t)\n \t \t \t\t \t\t\t\t \t \t \t \t", "l= int(input())\r\np= int(input())\r\nq= int(input())\r\ndistance = l*(p / (p+q))\r\nprint(distance)", "l = int(input())\r\nGP = int(input())\r\nSZK = int(input())\r\nprint((l / (GP + SZK)) * GP)\r\n", "l = []\r\nfor _ in range(3):\r\n l.append(float(input()))\r\nd = l[0] \r\n\r\nprint((d/(l[1]+l[2]))*l[1])", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nt = 3 * l / (p + q)\r\nprint(t * p / 3)\r\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nres=(l/(p+q))*p\r\nprint(round(res,6))", "wl = int(input())\r\na = int(input())\r\nb = int(input())\r\nt=float(wl)/float(a+b)\r\nprint(float(t)*float(a))\r\n", "hall, p, q = int(input()), int(input()), int(input())\nprint(hall * p / (p + q))\n", "# Bismillahir Rahmanir Rahim\r\n# @UTH0R :- A |-| |\\| A F\r\na, b, c = int(input()), int(input()), int(input())\r\nprint((a/(b+c))*b)\r\n", "a = float(input())\r\nb = float(input())\r\nc = float(input())\r\n\r\nprint(a/(b+c)*b)\r\n", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\ntotal = p + q\r\ntime = l / total\r\nans = p * time\r\nprint(ans)\r\n", "d = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nt = d/(p+q)\r\n\r\nprint(t*p)\r\n", "#In the name of Allah\r\n\r\nfrom sys import stdin, stdout\r\ninput = stdin.readline\r\n\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nstdout.write(str(p * q * l / (q) / (q + p)))\r\n", "l = int(input())\r\nspeedg = int(input())\r\nspeedn = int(input())\r\nprint(l / (speedg + speedn) * speedg)", "length = int(input())\r\npower_1 = int(input())\r\npower_2 = int(input())\r\nprint(length * (power_1 / (power_2 + power_1)))\r\n", "# import sys\r\n# sys.stdin = open(\"test.in\",\"r\")\r\n# sys.stdout = open(\"test.out\",\"w\")\r\nl,p,q=[int(input()) for i in range(3)]\r\nprint(p*(l/(p+q)))", "l, p, q = int(input()), int(input()), int(input())\r\nans = l * p / (p + q)\r\nprint(ans)", "l,p,d=int(input()),int(input()),int(input())\nprint(p*l/(p+d))\n\t\t \t \t \t \t \t\t \t\t\t\t\t \t\t \t\t\t", "l = int(input());\r\np = int(input());\r\nq =int(input());\r\nprint (1.0*l/(p+q)*p)", "l=int(input())\r\nm=int(input())\r\nn=int(input())\r\nx=(m*l)/(m+n)\r\nprint(x)", "d = int(input())\nh = float(input())\nv = float(input())\nif 1 <= d <= 1000 and 1 <= h <= 500 and 1 <= v <= 500:\n time = d/(h+v)\n distance = time * h\n print(distance)\n\t \t \t \t \t \t\t\t \t\t \t\t \t \t", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint((l/(p+q))*p)", "n=int(input())\r\nm=int(input())\r\np=int(input())\r\nprint(m/(p+m)*n)", "l=int(input())\np=int(input())\nq=int(input())\nprint(round(l*p/(p+q),10))", "def magic_beam(l, p, q):\n tpc = l / (p + q) * p\n if tpc % 1 == 0:\n return int(tpc)\n return tpc\n\n\nprint(magic_beam(int(input()), int(input()), int(input())))\n \t \t\t\t \t \t \t \t \t \t\t \t", "l=int(input())\r\na=int(input())\r\nb=int(input())\r\ntot_time=l/(a+b)\r\nd_a=a*tot_time \r\nd_b=b*tot_time \r\nprint(d_a)", "l = float(input())\r\na = float(input())\r\nb = float(input())\r\n\r\nprint(l * a / (a + b))", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\n\r\n# l = (p + q) * t\r\nt = l / (p + q)\r\n\r\npos_p = l - p * t\r\n\r\nprint(l - pos_p)\r\n", "distance = int(input())\r\nsp1 = int(input()) \r\nsp2 = int(input()) \r\nprint((sp1 * distance ) / (sp1 + sp2) ) ", "n = int(input())\r\nm = int(input())\r\nk = int(input())\r\nprint(n/(m+k)*m)\r\n", "l,p,q=[int(input())for _ in' '*3]\r\nprint(l*p/(p+q))", "'''input\n100\n50\n50\n'''\nl, p, q = int(input()), int(input()), int(input())\nprint(l * p / (p+q))", "l=int(input())\np=int(input())\nq=int(input())\nans=(p*l)/(p+q)\nprint(ans)", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\ns = l/(p+q)\r\nprint(p*s)", "'''\r\nAuthor: Sofen Hoque Anonta\r\n'''\r\n\r\nimport re\r\nimport sys\r\nimport math\r\nimport itertools\r\nimport collections\r\n\r\ndef inputArray(TYPE= int):\r\n return [TYPE(x) for x in input().split()]\r\n\r\ndef solve():\r\n d= int(input())\r\n p= int(input())\r\n q= int(input())\r\n\r\n print(p*d/(p+q))\r\n\r\n\r\nif __name__ == '__main__':\r\n # sys.stdin= open('F:/input.txt')\r\n solve()\r\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nans=round(((l*p)/(p+q)),8)\r\nprint(ans)", "l, a, b = int(input()), int(input()), int(input())\nprint((a*l)/(a+b))\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nprint(p / (p + q) * n)", "n = int(input())\np = int(input())\nq = int(input())\nprint(n/(p+q)*p)", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nx = p*l/(p+q)\r\nprint(x)", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nt=l*p\r\ny=p+q\r\nprint(t/y)\r\n", "import sys\nfrom collections import deque\nread = lambda: list(map(int, sys.stdin.readline().split()))\n\nl,= read()\np, = read()\nq, = read()\nprint (l*p/(p+q))\n\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nprint((p*l)/(p+q))", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Dec 14 22:57:15 2018\r\n\r\n@author: Allen\r\n\"\"\"\r\n\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nprint(l*p/(p+q))", "def wizardsDuel(l,p,q):\r\n spd = l/(p+q)\r\n ans = spd*p\r\n \r\n return ans\r\n \r\n\r\nif __name__ == '__main__':\r\n l = int(input())\r\n p = int(input())\r\n q = int(input())\r\n \r\n ans = wizardsDuel(l,p,q)\r\n print(ans)\r\n ", "import math\r\nl=int(input())\r\nv1=int(input())\r\nv2=int(input())\r\nx=((v1*l)/(v1+v2))\r\n\r\n\r\n\r\nprint(x)\r\n", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nk=p/q\r\nprint(l*k/(1+k))\r\n", "l = int(input())\nq = int(input())\np = int(input())\n\nx = (q * l ) / (q+p)\n\nprint (x)\n\t\t \t \t\t \t\t \t \t\t \t \t \t\t\t\t", "dist = int(input())\nharry = int(input())\nvoldemor = int(input())\nt = dist/(harry+voldemor)\nprint(t*harry)\n \t\t\t \t \t \t\t\t \t \t \t", "n = input()\r\na = input()\r\nb = input()\r\nn = int(n)\r\na= int(a)\r\nb = int(b)\r\nprint ( a*n / (a+b))", "x = int(input())\r\na = float(input())\r\nb = int(input())\r\nprint(a * x / (a + b))\r\n", "t = int(input())\r\na = int(input())\r\nb = int(input())\r\nx = a+b\r\ny = a/x\r\nz = b/x\r\nprint(y*t)", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\n\r\na=l*(p/(p+q))\r\nprint(f'{a:.8f}')\r\n", "l = int(input())\r\nv1 = int(input())\r\nv2 = int(input())\r\nprint((v1*l)/(v1+v2))", "l = float(input())\r\np = float(input())\r\nq = float(input())\r\n\r\nprint(p * l / (p + q))\r\n", "l=input()\r\nl=int(l)\r\np=input()\r\np=int(p)\r\nq=input()\r\nq=int(q)\r\nprint((p/(p+q))*l)", "#!/usr/bin/python3\n\nl = int(input())\np = int(input())\nq = int(input())\nprint (p*l/(p+q))", "l = int(input())\r\np,q = int(input()),int(input())\r\nprint(l-(l*q/(q+p)))", "# ========== //\\\\ //|| ||====//||\r\n# || // \\\\ || || // ||\r\n# || //====\\\\ || || // ||\r\n# || // \\\\ || || // ||\r\n# ========== // \\\\ ======== ||//====|| \r\n# code\r\n\r\ninn = lambda : int(input())\r\ninm = lambda : map(int, input().split())\r\nins = lambda : str(input())\r\nina = lambda : list(map(int, input().split()))\r\n\r\ndef solve():\r\n l = inn()\r\n p = inn()\r\n q = inn()\r\n print((p * l) / (p + q))\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\nif __name__ == \"__main__\":\r\n main()", "\r\n\r\ndef main_function():\r\n l = int(input())\r\n p = int(input())\r\n q = int(input())\r\n return p * l / (p + q)\r\n\r\n\r\n\r\nprint(main_function())", "l,p,q=int(input()),int(input()),int(input())\r\nprint(p*l/(p+q))", "class CodeforcesTask591ASolution:\n def __init__(self):\n self.result = ''\n self.l = 0\n self.p = 0\n self.q = 0\n\n def read_input(self):\n self.l = int(input())\n self.p = int(input())\n self.q = int(input())\n\n def process_task(self):\n step = 10 ** (-6)\n a = (self.p * self.l) / (self.p + self.q)\n v1 = -self.p\n v2 = self.q\n p1 = a\n p2 = a\n while abs(p1 - p2) > 0.00001:\n p1 += step * v1\n p2 += step * v2\n if p1 < 0:\n v1 = -v1\n if p2 > self.l:\n v2 = -v2\n self.result = str(p1)\n\n\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask591ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\nx = (l * p)/(p + q)\r\nprint(x)", "#!/usr/bin/env python\r\n# -*- coding: utf-8 -*-\r\n\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint( l * p / (p + q))\r\n", "s=int(input()) \r\nh=int(input());e=int(input()) \r\nif h ==min(h,e) :\r\n h1=1 \r\nelse :\r\n h1=h/min(h,e)\r\nif e ==min(h,e) :\r\n e1=1 \r\nelse :\r\n e1=e/min(h,e)\r\nprint(\"%f\"%(h1*(s/(h1+e1))))\r\n", "r = lambda: int(input())\r\nd = r()\r\nh = r()\r\nv = r()\r\n\r\nprint(h* d/(h+v))", "import sys\r\nfrom sys import stdin, stdout\r\n\r\nl = int(input())\r\nspeed1 = int(input())\r\nspeed2 = int(input())\r\n\r\nprint(float(l*speed1)/float(speed1+speed2))\r\n", "coridor_length = int(input())\r\nharrys_charm = int(input())\r\ntoms_charm = int(input())\r\nprint('%.4f' % (coridor_length*harrys_charm/(harrys_charm+toms_charm)))", "#!/usr/bin/env python3\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nprint((p*l)/(p+q))\r\n\t\r\n\r\n# x(t) = p.t\r\n# y(t) = -q.t + l\r\n\r\n# x(t) = y(t) => p.t = -q.t + l\r\n# => t.(p+q) = l => t = l/(p+q)\r\n# => x(t) = (p.l)/(p+q)", "l=int(input())\r\np=int(input())\r\nq=int(input())\r\nv=p+q\r\nt=l/v\r\nd=p*t\r\nprint(d)", "n1 = int(input())\r\nn2 = int(input())\r\nn3 = int(input())\r\n\r\nn4 = n2 + n3\r\nt = n1 / n4\r\n\r\nprint(t*n2)", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\nl = int(input())\np = int(input())\nq = int(input())\nprint(\"{0:.9f}\".format(l * p / (p + q)))\n", "l = int(input())\r\nu = int(input())\r\nv = int(input())\r\nprint((l*u)/(u+v))\r\n", "# import sys\r\n# sys.stdin=open(\"input.in\",\"r\")\r\nn=int(input())\r\na=int(input())\r\nb=int(input())\r\nprint((a*n)/(a+b))", "l,p,q=[int(input())for _ in[1,2,3]]\r\nprint(l*p/(p+q))", "n = int(input())\r\np = int(input())\r\nq = int(input())\r\nx = (p * (n / (p + q)))\r\nif x == int(x):\r\n x = int(x)\r\nprint(x)", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nt_needed = l / (p+q)\r\nprint(p*t_needed)\r\n", "l = int(input())\r\np = int(input())\r\nq = int(input())\r\n\r\nx = l / (p + q)\r\nx *= p\r\nprint(x)", "a,b,c = int(input()),int(input()),int(input())\r\nprint(a*b/(b+c))", "# n = int(input())\r\n# a = [int(i) for i in input().split()]\r\n# s = input()\r\nl = int(input())\r\np = int(input())\r\nq = int(input())\r\nprint(p * l / (p + q))", "from math import ceil, sqrt, floor\r\nimport sys \r\n\r\nn,x,y = int(input()), int(input()), int(input())\r\n\r\nprint(x*n/(x+y))", "l, p, q = (int(input()) for _ in range(3))\nres = p * l / (p + q)\nprint(res)\n", "l= int(input())\r\na= int(input())\r\nb= int(input())\r\ntime= l/ (a+b)\r\nimpact = time * a\r\nprint(impact)\r\n\r\n" ]
{"inputs": ["100\n50\n50", "199\n60\n40", "1\n1\n1", "1\n1\n500", "1\n500\n1", "1\n500\n500", "1000\n1\n1", "1000\n1\n500", "1000\n500\n1", "1000\n500\n500", "101\n11\n22", "987\n1\n3", "258\n25\n431", "979\n39\n60", "538\n479\n416", "583\n112\n248", "978\n467\n371", "980\n322\n193", "871\n401\n17", "349\n478\n378", "425\n458\n118", "919\n323\n458", "188\n59\n126", "644\n428\n484", "253\n80\n276", "745\n152\n417", "600\n221\n279", "690\n499\n430", "105\n68\n403", "762\n462\n371", "903\n460\n362", "886\n235\n95", "655\n203\n18", "718\n29\n375", "296\n467\n377", "539\n61\n56", "133\n53\n124", "998\n224\n65", "961\n173\n47", "285\n468\n62", "496\n326\n429", "627\n150\n285", "961\n443\n50", "623\n422\n217", "678\n295\n29"], "outputs": ["50", "119.4", "0.5", "0.001996007984", "0.998003992", "0.5", "500", "1.996007984", "998.003992", "500", "33.66666667", "246.75", "14.14473684", "385.6666667", "287.9351955", "181.3777778", "545.0190931", "612.7378641", "835.576555", "194.885514", "337.9340278", "380.0729834", "59.95675676", "302.2280702", "56.85393258", "199.0158172", "265.2", "370.6243272", "15.15923567", "422.6218487", "505.3284672", "630.9393939", "601.6515837", "51.53960396", "163.7819905", "281.017094", "39.82485876", "773.5363322", "755.6954545", "251.6603774", "214.1668874", "216.2068966", "863.535497", "411.4334898", "617.3148148"]}
UNKNOWN
PYTHON3
CODEFORCES
406
e51e5ab57fe3360c30220d3bf955e2d1
Nineteen
Alice likes word "nineteen" very much. She has a string *s* and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string. For example, if she has string "xiineteenppnnnewtnee", she can get string "xnineteenppnineteenw", containing (the occurrences marked) two such words. More formally, word "nineteen" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters. Help her to find the maximum number of "nineteen"s that she can get in her string. The first line contains a non-empty string *s*, consisting only of lowercase English letters. The length of string *s* doesn't exceed 100. Print a single integer — the maximum number of "nineteen"s that she can get in her string. Sample Input nniinneetteeeenn nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii nineteenineteen Sample Output 222
[ "import math\r\ns = input()\r\ncount_n = -1\r\ncount_i = 0\r\ncount_e = 0\r\ncount_t = 0\r\n\r\nfor char in s:\r\n\tif char == 'n':\r\n\t\tcount_n += 1\r\n\telif char == 'i':\r\n\t\tcount_i += 1\r\n\telif char == 'e':\r\n\t\tcount_e += 1\r\n\telif char == 't':\r\n\t\tcount_t += 1\r\n\r\nprint(min(int(count_n / 2), int(count_i), int(count_e / 3), int(count_t)))", "s= input ()\r\n\r\npr=[]\r\n\r\ne=s.count(\"e\")\r\nn=s.count(\"n\")\r\nt=s.count(\"t\")\r\ni=s.count(\"i\")\r\n\r\npr.append(int((n-1)/2))\r\npr.append(i)\r\npr.append(int(e/3))\r\npr.append(t)\r\nprint(min(pr))", "word = 'nineteen'\r\nstring = input()\r\nstring = [s for s in string]\r\ntimes = 0\r\n\r\ndef isTrue():\r\n global word, string, times\r\n for s in word:\r\n if (s in string):\r\n string.remove(s)\r\n else:\r\n return\r\n return True\r\n \r\nwhile isTrue():\r\n times = times + 1\r\n if times == 1:\r\n word = 'ineteen'\r\n \r\nprint(times)", "s=input().count\r\nprint(max(0,min((s('n')-1)//2,s('e')//3,s('i'),s('t'))))\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "st=input().count\r\n\r\nprint(max(0,min((st(\"n\")-1)//2,st(\"i\"),st(\"t\"),st(\"e\")//3)))", "s=input()\r\nn=s.count('n')\r\ni=s.count('i')\r\ne=s.count('e')\r\nt=s.count('t')\r\nc=0\r\ne=e/3\r\np=(n-1)/2\r\nprint(int(min(p,min(i,min(e,t)))))", "s = input()\r\n#nineteen\r\n#i : 1\r\n#n : 3 (>1 : + x*2)\r\n#t : 1\r\n#e : 3\r\nn = s.count(\"n\")\r\ni = s.count(\"i\")\r\ne = s.count(\"e\")\r\nt = s.count(\"t\")\r\n#print(n,i,e,t)\r\n#min n for 1 word is 3, but for everything >2 is 3+x*2\r\nif n >= 5:\r\n # n - 3 -> maxn = 1\r\n n-=3\r\n maxn=1\r\n maxn+= n//2\r\nelif n >= 3:\r\n maxn = 1\r\nelse:\r\n maxn = 0\r\n\r\nprint(min(maxn,i,e//3,t))\r\n\r\n\r\n#3\r\n#nineteenineteen\r\n\r\n#4\r\n#nssemsnnsitjtihtthij\r\n\r\n#10 -> 0\r\n#rmeetriiitijmrenmeiijt\r\n\r\n\r\n#14\r\n#nmehhjrhirniitshjtrrtitsjsntjhrstjehhhrrerhemehjeermhmhjejjesnhsiirheijjrnrjmminneeehtm\r\n", "s = input()\r\nn = s.count('n')\r\ne = s.count('e')\r\ni = s.count('i')\r\nt = s.count('t')\r\ncount = min((int((n-1)/2)), i, (int(e//3)), t)\r\nprint(count)", "word = 'nineteen'\r\ncount_char = {'e': 3, 'i': 1, 't': 1, 'n': 3}\r\n# print(count_char)\r\n\r\ninput_string = str(input())\r\ncount_input_char = dict()\r\nfor char in input_string:\r\n if char in count_input_char:\r\n count_input_char[char] += 1\r\n else:\r\n count_input_char[char] = 1\r\n\r\n# print(count_input_char)\r\nans = 0\r\ncheck = False\r\nwhile True:\r\n for char, amount in count_char.items():\r\n if char in count_input_char:\r\n if count_input_char[char] - amount < 0:\r\n check = True\r\n break\r\n else:\r\n count_input_char[char] -= amount\r\n else:\r\n check = True\r\n break\r\n if check:\r\n break\r\n ans += 1\r\n if ans == 1:\r\n count_char['n'] -= 1\r\n\r\nprint(ans)\r\n\r\n", "x=input()\r\na=[]\r\nfor i in x:\r\n a.append(i)\r\nb=a.count(\"n\")\r\nc=a.count(\"i\")\r\nd=int(a.count(\"e\")//3)\r\ne=a.count(\"t\")\r\np=min(c,d,e)\r\nj=1\r\nr=0\r\nwhile(j<=p):\r\n k=2*j+1\r\n if b>=k:\r\n r+=1\r\n else:\r\n break\r\n j+=1\r\nprint(r)\r\n", "s=list(input())\r\ncomp='nineteen'\r\n\r\nfinish=False\r\ncount=0\r\na=[]\r\nwhile finish==False:\r\n if count>0:\r\n comp='ineteen'\r\n for i in comp:\r\n if i in s:\r\n a.append(i)\r\n s.remove(i)\r\n else:\r\n finish=True\r\n break\r\n else:\r\n count+=1;\r\n \r\n\r\nprint(count)\r\n", "string = input()\r\nprint(min(string.count('i'),string.count('t'),string.count('e')//3,max(0,(string.count('n')-1)//2)))", "from collections import Counter\nword = input()\ncounter = Counter(word)\ncount = 0\ndef checker():\n\tfor letter in 'nineteen':\n\t\tif not counter[letter]:\n\t\t\treturn 1\n\t\tcounter[letter]-=1\n\treturn 0\nwhile True:\n\tif checker():\n\t\tbreak\n\tcount+=1\n\tcounter['n']+=1\nprint(count)\n", "s = input()\r\nn = i = e = t = 0\r\nfor j in range(0,len(s)):\r\n\tif s[j] == 'n':\r\n\t\tn += 1\r\n\tif s[j] == 'i':\r\n\t\ti += 1\r\n\tif s[j] == 'e':\r\n\t\te += 1\r\n\tif s[j] == 't':\r\n\t\tt += 1\r\nif n >= 3:\r\n\tprint(min((n - 3) // 2 + 1,i,e // 3,t))\r\nelse:\r\n\tprint(0)", "str=input()\r\nlist=[]\r\n\r\n\r\nn=0\r\ni=0\r\ne=0\r\nt=0\r\nfor k in str:\r\n if(k=='n'):\r\n n+=1\r\n elif(k=='i'):\r\n i+=1\r\n elif(k=='e'):\r\n e+=1\r\n elif(k=='t'):\r\n t+=1\r\nn=(n-1)/2\r\ne=e/3\r\ni=i\r\nt=t\r\nlist=[n,i,e,t]\r\nprint(int( min(list)))\r\n", "n = input()\r\nvet = [0,0,0,0];\r\nfor i in range(0,len(n)):\r\n if(n[i] == 'n'):\r\n vet[0]+=1\r\n elif(n[i] == 'i'):\r\n vet[1]+=1\r\n elif(n[i] == 'e'):\r\n vet[2]+=1\r\n elif(n[i] == 't'):\r\n vet[3]+=1\r\n\r\nvet[0] = (vet[0] - 1) / 2\r\nvet[2] /= 3\r\nvet.sort()\r\nprint(int(vet[0]))", "import collections\n\nword = input().strip()\nletters = collections.Counter(word)\nn = letters.get('n') or 0\nif n < 5:\n print(min([(letters['n'] // 3), letters['i'], letters['e'] // 3, letters['t']]))\nelse:\n print(min([(letters['n'] - 1) // 2, letters['i'], letters['e'] // 3, letters['t']]))\n", "s = input().strip()\r\nn = s.count('n')\r\ne = s.count('e')\r\ni = s.count('i')\r\nt = s.count('t')\r\n\r\nn=int((n-1)/2)\r\ne=int(e/3)\r\nprint(min(n,e,i,t))", "s = input()\nchars = {'n': 1, 'i': 1, 'e': 3, 't': 1}\nl = []\nfor char in chars:\n l.append(int(s.count(char)/chars[char]))\nans = min(l[1:])\nprint(min(ans, int((l[0]-1)/2)))\n", "from collections import Counter\r\n\r\nw = input()\r\nc = Counter(list(w))\r\nfor ch in \"neti\":\r\n if ch not in c: \r\n c[ch] = 0\r\nc[\"e\"] //= 3\r\nif c[\"n\"] <= 3: \r\n c[\"n\"] //= 3\r\nelse:\r\n c[\"n\"] = (c[\"n\"] - 1) // 2\r\n\r\nprint(min(v for k,v in c.items() if k in \"neti\"))", "s = input()\r\nn, i, e, t = 0, 0, 0, 0\r\nfor c in s:\r\n if c == 'n':\r\n n += 1\r\n elif c == 'i':\r\n i += 1\r\n elif c == 'e':\r\n e += 1\r\n elif c == 't':\r\n t += 1\r\nif n >= 3:\r\n n -= 3\r\n n = int(n / 2) + 1\r\nelse:\r\n n = 0\r\ne = int(e / 3)\r\nprint(min(n, i, e, t))", "#With Me\r\ns= input().count\r\nprint(max(0, min((s(\"n\")-1)//2, s(\"i\"), s(\"e\")//3, s(\"t\"))))", "s = input()\r\nn, i, e, t = s.count('n')-3, s.count('i')-1, s.count('e')-3, s.count('t')-1\r\ncount = 0\r\nwhile n>=0 and i>=0 and e>=0 and t>=0:\r\n count += 1\r\n n, i, e, t = n-2, i-1, e-3, t-1\r\nprint(count)\r\n", "#Happy New Year 2019 !\r\ns=input()\r\nprint(min(max(0,s.count('n')-1)//2,s.count('i'),s.count('e')//3,s.count('t')))", "x=input()\r\nn=x.count('n')\r\ne=x.count('e')\r\ni=x.count('i')\r\nt=x.count('t')\r\nn1=(n-1)//2\r\ne1=e//3\r\nlim=min(n1,e1,i,t)\r\nif lim>0:\r\n print(lim)\r\nelse:\r\n print(0)\r\n", "s=input()\r\nif s.count(\"n\")<3:\r\n n=0\r\nelif s.count(\"n\")%2==1:\r\n n=(s.count(\"n\")-1)/2\r\nelif s.count(\"n\")%2==0:\r\n n=(s.count(\"n\")-2)/2\r\ni=s.count(\"i\")\r\ne=int(s.count(\"e\")/3)\r\nt=s.count(\"t\")\r\nprint(int(min(n,i,t,e)))", "s=input()\r\nn_n,n_i,n_e,n_t=0,0,0,0\r\nfor i in s:\r\n\tif i=='n':\r\n\t\tn_n+=1\r\n\telif i=='i':\r\n\t\tn_i+=1\r\n\telif i=='e':\r\n\t\tn_e+=1\r\n\telif i=='t':\r\n\t\tn_t+=1\r\nn_n=int((n_n-1)/2)\r\nn_e=int(n_e/3)\r\nprint(min(n_n,n_e,n_t,n_i))\r\n\r\n", "string=input()\r\nmylist=[]\r\ni=0\r\nmylist.append((string.count('n')-1)/2)\r\nmylist.append(string.count('e')/3)\r\nmylist.append(string.count('i'))\r\nmylist.append(string.count('t'))\r\nprint(int(min(mylist))+i)", "# Problem url: https://codeforces.com/problemset/problem/393/A\n\nstring = input()\n\n'''\nCount the number of each letter and normalize by dividing by how\nmany of that letter are in the word nineteen. (if you have 9 e's,\nyou can make 3 words (9/3)) For n, you can overlap, so if you have\n3 n's, you can make 1 word\n5 n's, you can make 2 words\n7 n's, you can make 3 words (nineteenineteenineteen)\n\nso first find the lower odd number near to the number of n's, but if n is\n0, nearest is -1, so just make that 0 if so.\n\nThen, the number of words as a function of the number of n's is:\n W(n) = .5n - .5\n\nThis is how you normalize the number of n's. So then once you get all of those\nfind the min. For example if min is 2, then the lowest one was able to make\n2 words, so the rest of the letters definitely will too.\n\n'''\nn = string.count('n')\nn = n - (n%2 == 0) + (n == 0)\nn = int(n/2 - 1/2)\ni = string.count('i') // 1\ne = string.count('e') // 3\nt = string.count('t') // 1\n\nprint(min(n, i, e, t))", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Dec 3 11:02:39 2019\r\n\r\n@author: CronuS\r\n\"\"\"\r\n\r\ns = list(map(str, input().split()))\r\ns = s[0]\r\nn1 = int(s.count('n'))\r\nn2 = int(s.count('e')) // 3\r\nn3 = int(s.count('i'))\r\nn4 = int(s.count('t'))\r\nn = min(n2, n3, n4)\r\nif (n1 > 2):\r\n n1 = (n1 - 1) // 2\r\nelse:\r\n n1 = 0\r\nprint(min(n1, n))", "# Nineteen.py\r\n\r\n# \"nineteen\" contains 3 \"n\", 1 \"i\", 3 \"e\" and 1 \"t\".\r\n\r\ns = input()\r\n\r\nletters = [\"n\", \"i\", \"e\", \"t\"]\r\nocc = [3, 1, 3, 1]\r\n\r\n# Conctruction d'un dictionnaire\r\ncount = dict()\r\nfor letter in letters:\r\n count[letter] = 0\r\n\r\nfor letter in s:\r\n if letter in letters:\r\n count[letter] += 1\r\n\r\n# Recherche du minimum d'occurence du mot sans prendre en compte \"n\"\r\nminocc = 42\r\nfor k in range(1, 4):\r\n letter = letters[k]\r\n c = count[letter]//occ[k]\r\n if c <= minocc:\r\n minocc = c\r\n\r\n# Prise en compte de \"n\"\r\nwhile minocc > 0 and count[\"n\"] < 2*minocc+1:\r\n minocc -= 1\r\n\r\nprint(minocc)\r\n", "inp = input()\r\nn,i,e,t=0,0,0,0\r\nfor j in range(len(inp)):\r\n if inp[j] == \"n\":\r\n n+=1 \r\n elif inp[j] == \"i\":\r\n i+=1\r\n elif inp[j] == \"e\":\r\n e+=1\r\n elif inp[j] == \"t\":\r\n t+=1 \r\nnby3 = (n-1)//2\r\neby3 = e//3\r\nres = 0\r\nnew = \"\"\r\nwhile (nby3>0) and (i>0) and (eby3>0) and (t>0):\r\n res+=1 \r\n nby3-=1 \r\n i-=1 \r\n eby3-=1 \r\n t-=1\r\nprint(res)\r\n \r\n", "from collections import Counter\n\nSTRING = 'nineteen'\nMCOUNTER = Counter(STRING)\nMSET = set('iet')\n\n\ndef function(inp):\n inpc = Counter(inp)\n inps = set(inpc)\n\n if (inps & MSET) == MSET and 'n' in inpc:\n m = 10000\n for c in MSET:\n m = min(inpc[c] // MCOUNTER[c], m)\n if m == 0 or inpc['n'] < 3:\n return 0\n else:\n m2 = (inpc['n'] - 3) // 2 + 1\n return min(m, m2)\n else:\n return 0\n\n\ndef main():\n inp = input()\n out = function(inp)\n print(out)\n\n\nif __name__ == '__main__':\n main()\n", "# -*- coding:utf-8 -*-\ndef Nineteen(s:str)->int:\n # write code here\n cnt_n = s.count('n')\n cnt_i = s.count('i')\n cnt_e = s.count('e')\n cnt_t = s.count('t')\n cnt_n -= 1\n cnt_n /= 2\n cnt_e /= 3\n return min(int(cnt_n), int(cnt_i), int(cnt_e), int(cnt_t))\n\nif __name__ == '__main__':\n s = input()\n print(Nineteen(s))\n \t \t \t\t\t \t\t \t\t\t \t\t \t \t", "if __name__ == '__main__':\n from math import floor\n\n string = input()\n counts_n = floor(string.count('n') / 2)\n counts_e = floor(string.count('e') / 3)\n counts_i = string.count('i')\n counts_t = string.count('t')\n\n # ninetee - ninetee - ninetee...\n result = min(counts_n, counts_e, counts_i, counts_t)\n\n if result > 0 and string.count('n') <= result * 2:\n result -= 1\n\n print(result)\n", "s = input()\n\nprint(min(max(0,(s.count('n')-1)//2), s.count('i'), s.count('e')//3, s.count('t')))\n", "a=(input())\r\nx=[a.count('i'), a.count('e')//3, a.count('t')]\r\nother=min(x)\r\nn=a.count('n')\r\nprint(min(other,int((n-1)/2)))\r\n", "\r\n# Problem : A. Nineteen\r\n# Contest : Codeforces - Codeforces Round #230 (Div. 2)\r\n# URL : https://codeforces.com/problemset/problem/393/A\r\n# Memory Limit : 0 MB\r\n# Time Limit : 0 ms\r\n# Powered by CP Editor (https://github.com/cpeditor/cpeditor)\r\n\r\n# Auto-Submission: Codeforces Tool (https://github.com/xalanq/cf-tool)\r\n\r\n\r\n# Author: ishtupeed\r\n# Template courtesy: \r\n# Zubayet Zaman Zico (I_See_You)\r\n# Fahim Shahriar Shakkhor (fsshakkhor)\r\n\r\nst = input()\r\n \r\nn = (st.count(\"n\") - 1) // 2\r\nt = st.count(\"t\") \r\ne = st.count(\"e\") // 3\r\ni = st.count(\"i\")\r\n \r\nprint(max(0, min(n, t, e, i)))", "#s=input()\r\n#print(min(s.count('i'),s.count('t'),s.count('e')/3,max(0,(s.count('n')-1)/2))\r\nc = input().count\r\nprint(max(0, min((c(\"n\")-1)//2, c(\"i\"), c(\"e\")//3, c(\"t\"))))", "a = input()\r\ne = a.count('e')\r\nn = a.count('n')\r\ni = a.count('i')\r\nt = a.count('t')\r\ncounter = 0\r\nwhile True:\r\n if e < 3 or i < 1 or t < 1: #Required letters\r\n break\r\n if counter:#If the first nineteen is found\r\n if n < 2:\r\n break\r\n n-=2\r\n else:#Starting nineteen\r\n if n < 3:\r\n break\r\n n-=3\r\n counter += 1\r\n e-=3\r\n i-=1\r\n t-=1\r\nprint(counter)\r\n ", "input_val = input()\r\nc = input_val.count\r\nprint(max(0, min((c('n')-1)//2, c('e')//3, c('t'), c('i'))))", "s=input()\r\n\r\nn_cnt=s.count('n')\r\ni_cnt=s.count('i')\r\ne_cnt=s.count('e')\r\nt_cnt=s.count('t')\r\n\r\nif n_cnt>=3:\r\n n_cnt=(n_cnt-3)//2+1\r\nelse:\r\n n_cnt//=3\r\ne_cnt//=3\r\n\r\nprint(min(n_cnt,i_cnt,e_cnt,t_cnt))\r\n", "s = input()\r\n\r\nd = {'n' : 0,\r\n 'i' : 0,\r\n 'e' : 0,\r\n 't' : 0}\r\nfor i in s:\r\n if i in d:\r\n d[i] += 1\r\n\r\nif d['n'] > 3:\r\n d['n'] -= 3\r\n d['n'] //= 2\r\n d['n'] += 1\r\nelse:\r\n d['n'] //= 3\r\n\r\nd['i'] //= 1\r\nd['e'] //= 3\r\nd['t'] //= 1\r\n\r\n\r\n \r\nprint (min(d['n'],d['i'],d['e'],d['t']))\r\n", "s = input(\"\")\r\nd = { 'n': 0, 'i': 0, 'e': 0, 't': 0}\r\n\r\nfor c in s:\r\n try:\r\n d[c] += 1\r\n except:\r\n pass\r\n\r\nd['n']= (d['n']-1)//2\r\nd['e']= d['e']//3\r\n\r\ncnt = min(d.values())\r\nif cnt < 0:\r\n cnt=0\r\nprint(cnt)", "c=[0]*(ord('z')+1)\r\nfor i in input():\r\n\tt=ord(i)\r\n\tc[t]+=1\r\no=max(0,(c[ord('n')]-1)//2)\r\no=min(o,c[ord('i')],c[ord('t')],c[ord('e')]//3)\r\nprint(o) \r\n\r\n", "s = input()\r\nprint(min(s.count(\"i\"),s.count(\"e\")//3,s.count(\"t\"),max(0,(s.count(\"n\")-1)//2)))\r\n", "s = input()\r\nn = s.count('n')\r\ni = s.count('i')\r\ne = s.count('e')\r\nt = s.count('t')\r\nn3 = int((n-1)/2)\r\ne3 = int(e/3)\r\nnum = n3\r\nif i < n3:\r\n num = i\r\nif e3 < num:\r\n num = e3\r\nif t < num:\r\n num = t\r\nprint(num)", "n = 0\r\ni = 0\r\ne = 0\r\nt = 0\r\ncount = 0\r\na = input()\r\nfor j in list(a):\r\n if j == \"n\":\r\n n += 1\r\n elif j == \"i\":\r\n i += 1\r\n elif j == \"e\":\r\n e += 1\r\n elif j == \"t\":\r\n t += 1\r\n if n >= 3 and i >= 1 and e >= 3 and t >= 1:\r\n count += 1\r\n n -= 2\r\n i -= 1\r\n e -= 3\r\n t -= 1\r\nprint(count)", "import itertools\n\ndef main():\n s = input()\n #nineteen\n n = s.count(\"n\") #3\n i = s.count(\"i\") #1\n t = s.count(\"t\") #1\n e = s.count(\"e\") #3\n counter = 0\n while n >= 3 and i >= 1 and t >= 1 and e >= 3:\n n -= 2\n i -= 1\n t -= 1\n e -= 3\n counter += 1\n print(counter)\nmain()\n", "s = input().rstrip().lstrip()\r\n\r\nprint(min(max(0,s.count('n')-1)//2,s.count('i'),s.count('e')//3,s.count('t')))\r\n", "s=input()\r\nprint(0 if s.count('n')==0 else min((s.count('n')-1)//2, s.count('i'), s.count('e')//3, s.count('t')))", "# -*- coding:utf-8 -*-\n# -*- coding:utf-8 -*-\ndef Nineteen(s:str)->int:\n # write code here\n cnt_n = 0\n cnt_i = 0\n cnt_e = 0\n cnt_t = 0\n for i in range(len(s)):\n if s[i] == 'n':\n cnt_n += 1\n elif s[i] == 'i':\n cnt_i += 1\n elif s[i] == 'e':\n cnt_e += 1\n elif s[i] == 't':\n cnt_t += 1\n return min(cnt_i, int(cnt_e/3), cnt_t, int((cnt_n-1)/2))\n\n\nif __name__ == '__main__':\n s = input()\n print(Nineteen(s))\n\t\t \t\t\t\t\t \t \t\t \t\t \t \t\t \t", "word = input()\npossibyleNineteens = min([(int((word.count('n')-1)/2)), int(word.count('e')/3), int(word.count('i')/1), int(word.count('t')/1)])\n\nprint(possibyleNineteens)", "# -*- coding:utf-8 -*-\ndef Nineteen(s:str)->int:\n n = max(0, (s.count('n')-1)//2)\n i = s.count('i')\n e = s.count('e')//3\n t = s.count('t')\n return min(n,i,e,t)\n\n\nif __name__ == '__main__':\n s = input()\n print(Nineteen(s))\n \t\t \t \t\t \t\t \t \t\t \t \t\t\t\t\t \t \t\t", "n = input()\n\ncounts = {'n': 0, 'i': 0, 'e':0, 't':0}\n\nfor c in n:\n if c in counts:\n counts[c] = counts[c] + 1\n\nnumI = int(counts['i']/1)\nnumE = int(counts['e']/3)\nnumT = int(counts['t']/1)\n\nresp = 100\n\nif numI < resp:\n resp = numI\nif numE < resp:\n resp = numE\nif numT < resp:\n resp = numT\n\nnumN = 0\n\nif resp < 2:\n numN = int(counts['n']/3)\nelse:\n numN = int(1 + (counts['n']-3)/2)\n\nif numN < resp:\n resp = numN\n\n# print('counts', counts)\n# print(numN, numI, numE, numT)\n\nprint(resp)\n", "obj='nineteen'\r\nqn,qi,qe,qt=[0]*4\r\nfor i in input():\r\n if i=='n':qn+=1\r\n elif i=='i':qi+=1\r\n elif i=='e':qe+=1\r\n elif i=='t':qt+=1\r\nif qn>=3:\r\n er=1+(qn-3)//2\r\nelse:er=0\r\nprint(min([qi,qt,er,qe//3]))\r\n", "str = input();\r\nprint(max(0,min((str.count('n')-1)//2,str.count('e')//3,str.count('i'),str.count('t'))));\r\n", "z = input()\r\nprint(min(max((z.count('n') - 1) //2, 0), z.count('e') //3, z.count('t'), z.count('i')))", "s=input('')\r\ncount=0\r\nn=0;i=0;e=0;t=0;\r\nfor j in s:\r\n if(j=='n'):\r\n n+=1\r\n elif(j=='i'):\r\n i+=1\r\n elif(j=='e'):\r\n e+=1\r\n elif(j=='t'):\r\n t+=1\r\n# print(n,i,t,e)\r\nif(n>=3 and i>=1 and t>=1 and e>=3):\r\n c=True\r\n n=n-3;\r\n i=i-1\r\n t=t-1\r\n e=e-3\r\n count+=1\r\n while(c!=False):\r\n n=n-2;\r\n i=i-1\r\n t=t-1\r\n e=e-3\r\n if(n<0 or i<0 or t<0 or e<0):\r\n c=False\r\n else:\r\n # print(n,i,t,e)\r\n count+=1\r\n \r\nprint(count)", "s = input()\nn = (s.count('n') - 1)/2\ni = s.count('i')\ne = s.count('e')/3 \nt = s.count('t')\nprint(int(min(n, i, e, t)))\n", "n=input()\r\nprint(min(max(0,(int((n.count(\"n\")+1)/2)-1)), int(n.count(\"i\")), int(n.count(\"e\")/3), n.count(\"t\")))\r\n", "z=input()\r\nx=[z.count(\"n\"),z.count(\"i\"),z.count(\"e\"),z.count(\"t\")]\r\nx[0]=x[0]-1\r\nc=0\r\nwhile True:\r\n x[0]=x[0]-2\r\n x[1]=x[1]-1\r\n x[2]=x[2]-3\r\n x[3]=x[3]-1\r\n if x[0]<0 or x[1]<0 or x[2]<0 or x[3]<0:\r\n break\r\n else:\r\n c=c+1\r\nprint(c)", "#! /usr/bin/env python\r\n# -*- coding: utf-8 -*-\r\nimport collections\r\ns = collections.Counter(input()) # nineteen\r\nn = s['n']\r\ni = s['i']\r\ne = s['e']\r\nt = s['t']\r\nif n < 3 or i < 1 or t < 1 or e < 3:\r\n print(0)\r\nelse:\r\n n = (n-1)//2\r\n e = e//3\r\n print(min(n, i, e, t))", "a=str(input())\r\nimport collections\r\ncnt=collections.Counter(a)\r\nans=min({(cnt['n'] - 1) //2, cnt['e'] // 3, cnt['i'], cnt['t']})\r\nif ans<1:\r\n print(0)\r\nelse:\r\n print(ans)", "word=list(input())\r\n\r\ncheck=['n','i','e','t']\r\nword_dict={'n':0,'i':0,'e':0,'t':0}\r\ncount=0\r\nfor i in range(len(word)):\r\n if word[i] in check :\r\n word_dict[word[i]]=word_dict[word[i]]+1\r\n \r\n if (word_dict['n']>=3 and word_dict['i']>=1 and word_dict['e']>=3 and word_dict['t']>=1):\r\n count=count+1\r\n word_dict['n']=word_dict['n']-2\r\n word_dict['i']=word_dict['i']-1\r\n word_dict['e']=word_dict['e']-3\r\n word_dict['t']=word_dict['t']-1\r\nprint(count)", "\n\n\ndef sol(s):\n if not s:\n return 0\n # from collections import Counter \n # count = Counter(s)\n # count2 = Counter('nineteen')\n count = {}\n count2 = {}\n for c in s:\n count[c] = count.get(c, 0) + 1\n for c in 'nineteen':\n count2[c] = count2.get(c, 0) + 1\n k = 0\n while True:\n # print(count, count2)\n if k>=1:\n count2['n'] = 2\n for x in count2:\n if x in count:\n count[x] -= count2[x]\n if count[x] < 0:\n return k \n else:\n return 0\n k+=1\n return k\n\ndef canSub(count, count2):\n print('1')\n print(count)\n for x in count2:\n count[x] -= count[2]\n if count[x] <= 0:\n return False \n return True\n\n\nif __name__ == '__main__':\n from collections import Counter\n s = input()\n print(sol(s))\n # count = Counter(s)\n # count2= Counter('nineteen')\n \n # t = {}\n # for x in count2:\n # t[x] = False\n\n # import sys \n # MIN = sys.maxsize\n # for x in count2:\n # if x in count:\n # if count[x]>=count2[x]:\n # t[x] = True\n # print(x, count[x], count2[x])\n # MIN = min(MIN, int(count[x]/count2[x]))\n # # print(count, count2)\n # # print(MIN, t)\n # if MIN != sys.maxsize:\n # possible = True\n # for x in t:\n # if not t[x]:\n # possible = False\n # break\n # if possible:\n # print(MIN)\n # else:\n # print(0)\n # else:\n # print(0)", "s=input() # string\r\nf=[0]*200 # int\r\n'''\r\np=input()\r\nprint(p*9) it would be repeation for the string literals and concatenation\r\n'''\r\nfor i in range(0 , len(s)):\r\n x=ord(s[i]) # what os the type of s[i]\r\n f[x]+=1\r\nmini=100000000\r\nx=[ord('i') , ord('n') , ord('t') , ord('e')]\r\nfor i in x:\r\n #print(type(x))\r\n if i==ord('n'):\r\n mini=min(mini , (int)((f[i]-1)/2)) # // do round down so it get to -ve\r\n elif i==ord('e'):\r\n mini=min(mini , f[i]//3)\r\n else :\r\n mini=min(mini , f[i])\r\n\r\nprint(mini)", "a=input().count\r\nprint(min(max(0,(a('n')-1)//2),a('t'),a('i'),a('e')//3))", "import math\ns = str(input())\nncount = 0\nicount = 0\ntcount = 0\necount = 0\nnvalid = 0\nfor c in s:\n if c == 'n':\n ncount += 1\n if c == 'i':\n icount += 1\n if c == 't':\n tcount += 1\n if c == 'e':\n ecount += 1\nif (ncount>3):\n nvalid += math.floor((ncount-1)/2)\nelif(ncount==3): nvalid = 1\nprint(min(nvalid,icount,tcount,math.floor(ecount/3)))", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Wed Apr 8 08:52:51 2020\r\n\r\n@author: crisj\r\n\"\"\"\r\n\r\n#algoritmo equivocado, string.count() va a contar va a fallar\r\nfrom math import floor\r\n\r\ndef count_nineteen(string):\r\n \r\n n = string.count(\"n\")\r\n i = string.count(\"i\")\r\n e = string.count(\"e\")\r\n t = string.count(\"t\")\r\n \r\n contar_n = floor(n/3)\r\n\r\n if contar_n < floor((n - 1) / 2):\r\n contar_n = floor((n - 1) / 2)\r\n \r\n print(min(contar_n, floor(i / 1), floor(e / 3), floor(t / 1)))\r\n\r\npalabra = input()\r\ncount_nineteen(palabra)", "c = input().count\r\nprint(max(0, min(c('t'), c('i'), c('e')//3, (c('n')-1)//2)))\r\n", "s = input()\nprint(max(min((s.count('n') - 1) // 2, min(s.count('i'), s.count('t'), s.count('e') // 3)), 0))", "string = str(input())\r\ncounter_n = 0\r\ncounter_i = 0\r\ncounter_e = 0\r\ncounter_t = 0\r\nfor i in range(len(string)):\r\n if string[i] == 'n':\r\n counter_n += 1\r\n elif string[i] == 'i':\r\n counter_i += 1\r\n elif string[i] == 'e':\r\n counter_e += 1\r\n elif string[i] == 't':\r\n counter_t += 1\r\n \r\nif counter_n >= 3:\r\n counter_n = (counter_n - 3)//2 + 1\r\nelse:\r\n counter_n = 0\r\ncounter = [counter_n, counter_i, counter_e//3, counter_t]\r\n \r\nprint(min(counter))", "word = input()\r\nif word.count('n') > 1:\r\n ns = 1 + (word.count('n') - 3) // 2\r\nelse:\r\n ns = 0\r\nlst = [ns, word.count('e') // 3, word.count('i'), word.count('t')]\r\nprint(min(lst))\r\n", "x = list(input())\nprint(int(min((x.count(\"n\")-1)/2, x.count(\"i\"), x.count(\"e\")/3, x.count(\"t\"))))\n\n", "def solve(text):\r\n count = {\r\n \"n\": 0,\r\n \"i\": 0,\r\n \"e\": 0,\r\n \"t\": 0\r\n }\r\n for l in text:\r\n if l in count:\r\n count[l] += 1\r\n return max(\r\n min([count['i'], (count[\"n\"] - 1) // 2, count[\"e\"] // 3, count[\"t\"]]),\r\n 0)\r\n\r\n\r\ndef main():\r\n text = input()\r\n print(solve(text))\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "a = list(input())\r\nn = a.count('n')\r\ni = a.count('i')\r\ne = a.count('e')\r\nt = a.count('t')\r\nif n==0:\r\n q = 0\r\nelse:\r\n q = min((n-1)//2, i, t, e//3)\r\nprint(q)", "# -*- coding:utf-8 -*-\ndef Nineteen(s:str)->int:\n # write code here\n s_all = list(s)\n n = 0\n nineteen = list('nineteen')\n flag = True\n while flag and len(s_all) > 0:\n for i in range(len(nineteen)):\n if nineteen[i] in s_all:\n s_all.remove(nineteen[i])\n if i == len(nineteen)-1:\n s_all.append('n')\n n += 1\n else:\n flag = False\n break\n\n return n\n\n\nif __name__ == '__main__':\n s = input()\n print(Nineteen(s))\n\t\t\t \t\t\t\t \t\t\t\t \t\t\t\t \t\t \t", "word = input()\r\n\r\nans = 0\r\nn = i = e = t = 0\r\n\r\nif len(word) <= 100:\r\n for j in word:\r\n if j == \"n\":\r\n n += 1\r\n elif j == \"i\":\r\n i += 1\r\n elif j == \"e\":\r\n e += 1\r\n elif j == \"t\":\r\n t += 1\r\n\r\n ans = i\r\n ans = min(ans, t)\r\n tmp = int((n-1) / 2)\r\n ans = min(ans, tmp)\r\n del tmp\r\n tmp = int(e / 3)\r\n ans = min(ans, tmp)\r\n \r\n print(ans)", "# -*- coding:utf-8 -*-\ndef Nineteen(s:str)->int:\n n=len(s)\n n_num=i_num=e_num=t_num=0\n for i in range(n):\n if s[i]=='n':\n n_num+=1\n if s[i]=='i':\n i_num+=1\n if s[i]=='e':\n e_num+=1\n if s[i]=='t':\n t_num+=1\n n_max=int((n_num-1)/2)\n e_max=int(e_num/3)\n out=min(n_max,t_num,i_num,e_max)\n return out\n\n\nif __name__ == '__main__':\n s = input()\n print(Nineteen(s))\n \t\t \t\t \t \t \t\t \t\t \t \t \t \t\t", "str = input()\r\narray = [0,0,0,0]\r\nfor i in range(len(str)):\r\n if(str[i] == 'n'):\r\n array[0] +=1\r\n elif(str[i] == 'i'):\r\n array[1] +=1\r\n elif(str[i] == 'e'):\r\n array[2] +=1\r\n elif(str[i] == 't'):\r\n array[3] +=1\r\nif(array[0]<3 or array[1]<1 or array[2]<3 or array[3]<1):\r\n print('0')\r\nelse:\r\n sum =1\r\n array[0] -= 3\r\n array[1] -= 1\r\n array[2] -= 3\r\n array[3] -= 1\r\n array[0] = int(array[0]/2)\r\n array[2] =int(array[2]/3)\r\n nho=10000\r\n for i in array:\r\n nho=min(nho,i)\r\n print(sum+nho)\r\n\r\n\r\n", "char_count = {}\r\nfor c in input():\r\n if c not in char_count:\r\n char_count[c] = 1\r\n else:\r\n char_count[c] += 1\r\ntry:\r\n n = char_count['n']\r\n e = char_count['e']\r\n i = char_count['i']\r\n t = char_count['t']\r\n\r\n if n>=e:\r\n print(min(e//3,i,t))\r\n else:\r\n x = (n-1)//2\r\n print(min(x,e//3,i,t))\r\nexcept:\r\n print(0)", "def find_max_nineteens():\r\n\tstring = input()\r\n\tchar_freq_for_one = {\"i\": 1, \"t\": 1, \"n\": 3, \"e\": 3}\r\n\r\n\tfound_char_freq = {}\r\n\tfor char in string:\r\n\t\tfound_char_freq[char] = found_char_freq.get(char, 0) + 1\r\n\r\n\t# for overlap of n\r\n\tif found_char_freq.get(\"n\", 0) > 2:\r\n\t\tfound_char_freq[\"n\"] = found_char_freq[\"n\"] + (found_char_freq[\"n\"]-1)//2\r\n\r\n\tminimum_possible = 100\r\n\tfor char in char_freq_for_one:\r\n\t\t# if required char not present\r\n\t\tif char not in found_char_freq:\r\n\t\t\tprint(0)\r\n\t\t\treturn\r\n\t\tpossible = found_char_freq[char]//char_freq_for_one[char]\r\n\t\tif possible < minimum_possible:\r\n\t\t\tminimum_possible = possible\r\n\t\r\n\tprint(minimum_possible)\r\n\r\n\r\nfind_max_nineteens()\r\n", "palabra = input()\r\nce = 0\r\nci = 0\r\ncn = 0\r\nct = 0\r\nfor i in palabra:\r\n\tif(\"e\" == i):\r\n\t\tce+=1\r\n\telif(\"n\" == i):\r\n\t\tcn+=1\r\n\telif(\"t\" == i):\r\n\t\tct+=1\r\n\telif(\"i\" == i):\r\n\t\tci+=1\r\ntotal = 0 if 3 > cn else 1+(cn-3)/2\r\ncont = min(total,ct,ci,ce/3)\r\nprint(int(cont))", "s=input()\r\nflag=0\r\nc=0\r\nn=s.count('n')\r\ni=s.count('i')\r\ne=s.count('e')\r\nt=s.count('t')\r\nwhile n>0 and i>0 and e>0 and t>0:\r\n if (flag==0):\r\n n-=3\r\n flag=1\r\n else:\r\n n-=2\r\n i-=1\r\n e-=3\r\n t-=1\r\n if(n>=0 and i>=0 and e>=0 and t>=0):\r\n c+=1\r\n\r\nprint(c)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "l=[0]*26\r\ns = input()\r\nfor i in s:\r\n l[ord(i)-97]+=1\r\nn=(l[13]-1)/2\r\ni=l[8]\r\ne=l[4]/3\r\nt=l[19]\r\nprint(int(min(n,i,t,e)))", "s = input()\r\n\r\ncount = 0\r\nprint(0 if s.count('n') == 0 else min((s.count('n')-1) //\r\n 2, s.count('i'), s.count('e')//3, s.count('t')))\r\n\r\n", "s = input()\r\nn = s.count(\"n\")-1#3\r\ni = s.count(\"i\")#1\r\ne = s.count(\"e\")#3\r\nt = s.count(\"t\")#1\r\nif n > 0:\r\n print(min(n//2, i, e//3, t))\r\nelse:\r\n print(0)\r\n", "a = input()\nprint(min(max((a.count('n') - 1) // 2, 0), a.count('e') // 3, a.count('t'), a.count('i')))\n", "str = list(input())\ncntN = max((str.count('n') - 3) // 2 + 1, 0)\ncntI = max(str.count('i') // 1, 0)\ncntE = max(str.count('e') // 3, 0)\ncntT = max(str.count('t') // 1, 0)\nprint(min(cntN, cntI, cntE, cntT))\n\n", "s = input().count\r\nprint(min(max(0,(s('n')-1)//2),s('i'),s('t'),s('e')//3))", "n,c=input(),0\r\nnc=n.count('n')\r\n#print(nc)\r\nif(nc>=3):\r\n c=1\r\n nc-=3\r\n print(min(nc//2+c,n.count('i'),n.count('t'),n.count('e')//3))\r\nelse:\r\n print('0')", "s=input();\r\nkoln=0;\r\nkoli=0;\r\nkolt=0\r\nkole=0\r\nkolnn=3;\r\nkolii=1;\r\nkoltt=1;\r\nkolee=3;\r\nkol=1\r\nfor a in s:\r\n if a=='n':\r\n koln+=1;\r\n if a=='i':\r\n koli+=1;\r\n if a=='t':\r\n kolt+=1;\r\n if a=='e':\r\n kole+=1;\r\nc=1;\r\nwhile (koln>=kolnn)and(koli>=kolii)and(kole>=kolee)and(kolt>=koltt):\r\n koln-=kolnn;\r\n if c==1:\r\n kolnn-=1;\r\n c=0;\r\n koli-=kolii;\r\n kolt-=koltt\r\n kole-=kolee;\r\n kol+=1\r\nprint(kol-1)\r\n \r\n", "st=input()\r\na=st.count('n')\r\nb=st.count('e')\r\nc=st.count('t')\r\nd=st.count('i')\r\ne=[(a-1)//2,b//3,c,d]\r\nif min(e)<0:\r\n print(0)\r\nelse:\r\n print(min(e))", "string1 = input()\ndict1 = {}\ndict2 = {'n':3,'i':1,'e':3,'t':1}\n\nfor i in string1:\n if i not in dict1:\n dict1[i] = 0\n dict1[i] += 1\nmin1 = 0\nset1 = set(\"nineteen\")\nmin1 = 100\nif(dict1.get('n',None) == None or dict1.get('i',None) == None or dict1.get('e',None) == None or dict1.get('t',None) == None):\n print(0)\nelse:\n for i in set1:\n if i == 'n':\n if dict1[i]-3>=0:\n #print(dict1[i]-3)\n #print((dict1[i]-3)//2+1)\n if (dict1[i]-3)//2+1 < min1:\n min1 = (dict1[i]-3)//2+1\n else:\n min1 = 0\n elif(dict1[i]//dict2[i] < min1):\n min1 = dict1[i]//dict2[i]\n #print(min1, i)\n print(int(min1)) ", "noves= input()\r\nn= 0\r\ni= 0\r\ne= 0\r\nt= 0\r\nfor x in noves:\r\n\tif x==\"n\":\r\n\t\tn+=1\r\n\telif x==\"i\":\r\n\t\ti+=1\r\n\telif x==\"e\":\r\n\t\te+=1\r\n\telif x==\"t\":\r\n\t\tt+=1\r\n\r\n\r\npn= int((n-1)/2)\r\npi=i\r\npe= int((e)/3)\r\npt= t\r\n\r\nachei=(min(pn, pi, pe, pt))\r\n\r\nprint(achei)", "s=input()\r\na=s.count('n')\r\nb=s.count('i')\r\nc=s.count('e')\r\nd=s.count('t')\r\ne=min(b,c//3,d)\r\nprint(min(e,max((a-1)//2,0)))", "a=input(); print(min(max(0,a.count('n')-1)//2,a.count('i'),a.count('e')//3,a.count('t')))", "import math \r\ns=input()\r\nprint(max(0,min((s.count('n')-1)//2,s.count('i'),s.count('t'),s.count('e')//3)))\r\n\r\n", "import collections as cl\r\n\r\nc = cl.Counter(input())\r\nn_th = c['n'] // 3\r\nprint(min(c['i'], c['t'], max(0, c['n'] - 1) // 2, c['e'] // 3))\r\n", "import sys\ns = input().strip()\n\ninpDict = {}\n\nfor c in s:\n inpDict[c] = inpDict.get(c,0) + 1\n\n \nnn = \"nineteen\"\nnDict = {}\n\nfor c in nn:\n nDict[c] = nDict.get(c,0) + 1 \n \nm = sys.maxsize\nfor c in nDict.keys():\n if(c != 'n'):\n m = min(m, inpDict.get(c,0)//nDict[c])\n \n \nif((inpDict.get('n',0)-1)//2 >= m):\n if(m>=0):\n print(m)\n else:\n print(0)\n\nelse:\n x = (inpDict.get('n',0)-1)//2\n if(x>=0):\n print(x)\n else:\n print(0)\n\n \t \t\t \t \t \t \t\t \t\t \t \t\t\t", "s=input()\r\nn=s.count('n')\r\ni=s.count('i')\r\ne=s.count('e')\r\nt=s.count('t')\r\nif n<3 or i<1 or e<3 or t<1:\r\n\tprint(0)\r\nelse:\r\n minn=e//3\r\n if i<minn:\r\n minn=i\r\n if t<minn:\r\n minn=t\r\n if ((n-1)//(3-1)<minn):\r\n minn=(n-1)//(3-1)\r\n print(minn)\r\n", "s = input()\r\nnc = abs((s.count('n')-1)//2)\r\nic = s.count('i')\r\nec = s.count('e')//3\r\ntc = s.count('t')\r\nprint(min(ic, tc, ec, nc))\r\n\r\n", "def nineteen_cf():\r\n from collections import Counter\r\n s = input()\r\n c = Counter()\r\n r = 0\r\n a = 3\r\n for i in s:\r\n c[i] += 1\r\n if c['n'] >= a and c['e'] >= 3 and c['i'] >= 1 and c['t'] >= 1:\r\n c['n'] -= a\r\n c['e'] -= 3\r\n c['i'] -= 1\r\n c['t'] -= 1\r\n a = 2\r\n r += 1\r\n return r\r\n\r\nprint(nineteen_cf())", "def solve(s):\r\n return 0 if s.count('n')==0 else min((s.count('n')-1)//2, s.count('i'), s.count('e')//3, s.count('t'))\r\n\r\ndef main():\r\n # inp = int(input())\r\n arr2 = input()\r\n # arr = list(map(int, input().split()))\r\n print(solve(arr2))\r\n # inp2 = input()\r\n\t# m = int(inp[1])\r\n\r\nif __name__ == \"__main__\":\r\n\tmain()\r\n", "word = input()\r\nletters_of_interests = ''.join([x if x in \"niet\" else '' for x in word])\r\n\r\nnines=\"\"\r\ncount = 0\r\n\r\nwhile(True):\r\n if count == 0:\r\n i = letters_of_interests.find('n')\r\n if i == -1:\r\n break\r\n else:\r\n letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]\r\n\r\n i = letters_of_interests.find('i')\r\n if i == -1:\r\n break\r\n else:\r\n letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]\r\n\r\n i = letters_of_interests.find('n')\r\n if i == -1:\r\n break\r\n else:\r\n letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]\r\n\r\n i = letters_of_interests.find('e')\r\n if i == -1:\r\n break\r\n else:\r\n letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]\r\n\r\n i = letters_of_interests.find('t')\r\n if i == -1:\r\n break\r\n else:\r\n letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]\r\n i = letters_of_interests.find('e')\r\n if i == -1:\r\n break\r\n else:\r\n letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]\r\n i = letters_of_interests.find('e')\r\n if i == -1:\r\n break\r\n else:\r\n letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]\r\n\r\n i = letters_of_interests.find('n')\r\n if i == -1:\r\n break\r\n else:\r\n letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]\r\n\r\n count += 1\r\n\r\nprint (count)", "str = list(input())\nnineteen = {'n': [3, 2], 'i': [1, 1], 'e': [3, 3], 't': [1, 1]}\nstr_count = [(str.count(key) - x) // y + 1 for key, [x, y] in nineteen.items()]\noutput = max(min(str_count), 0)\nprint(output)\n\n", "n = input()\nvet = [0,0,0,0];\nfor i in range(0,len(n)):\n if(n[i] == 'n'):\n vet[0]+=1\n elif(n[i] == 'i'):\n vet[1]+=1\n elif(n[i] == 'e'):\n vet[2]+=1\n elif(n[i] == 't'):\n vet[3]+=1\n\nvet[0] = (vet[0] - 1) / 2\nvet[2] /= 3\nvet.sort()\nprint(int(vet[0]))", "c = input()\r\n\r\nd = {'n':0, 'i':0, 't':0, 'e':0}\r\nfor i in c :\r\n if any([i==x for x in d.keys()]) :\r\n d[i] += 1\r\nif d['n']//3 == 0 :\r\n print(min(d['n']//3, d['i'], d['t'], d['e']//3))\r\nelse :\r\n print(min((d['n']-1)//2, d['i'], d['t'], d['e']//3))", "s=input()\r\ntest=True\r\nsom=0\r\nwhile(test==True):\r\n try:\r\n s=list(s)\r\n s.pop(s.index(\"n\"))\r\n s.pop(s.index(\"i\"))\r\n s.pop(s.index(\"n\"))\r\n s.pop(s.index(\"e\"))\r\n s.pop(s.index(\"t\"))\r\n s.pop(s.index(\"e\"))\r\n s.pop(s.index(\"e\"))\r\n s.pop(s.index(\"n\"))\r\n som+=1\r\n s.append(\"n\")\r\n except:\r\n test=False\r\nprint(som)\r\n", "s = input()\r\n\r\nn = s.count(\"n\")\r\ni = s.count(\"i\")\r\ne = s.count(\"e\")//3\r\nt = s.count(\"t\")\r\nif n >= 5:\r\n n = (s.count(\"n\")-1)//2 \r\nelse:\r\n n = n//3\r\n \r\nprint(min((n,i,e,t)))\r\n", "s = input().count\n\nprint(min(\n max(0,\n (s('n') - 1) // 2),\n s('t'),\n s('i'),\n s('e') // 3\n )\n)\n", "line = input()\n\n# nineteen = 3x n + 1x i + 3x e + 1x t\n\nn_count = 0\ni_count = 0\ne_count = 0\nt_count = 0\n\nfor c in line:\n if(c == 'n'): n_count+= 1\n elif(c == 'i'): i_count+= 1\n elif(c == 'e'): e_count+= 1\n elif(c == 't'): t_count+= 1\n\nprop_i = int(i_count / 1)\nprop_e = int(e_count / 3)\nprop_t = int(t_count / 1)\n\nprop_n = 0\nif(n_count >= 3):\n prop_n = 1 + int((n_count-3)/2)\n\nmin_prop = prop_n\nif(prop_i < min_prop): min_prop = prop_i\nif(prop_e < min_prop): min_prop = prop_e\nif(prop_t < min_prop): min_prop = prop_t\n\nprint(min_prop)", "x = input()\r\ni = x.count('i')\r\ne = x.count('e')//3\r\nt = x.count('t')\r\nn = x.count('n')\r\nu = n-3\r\nk=1\r\nif e>0:\r\n k+=u//2\r\nrez = min(i,e,t,k)\r\nprint(rez)", "from collections import Counter\r\nnc = Counter(\"nineteen\")\r\nins= Counter(input())\r\n\r\nprint(max(min([(ins['n'] - 1) // 2, ins['i'], ins['e'] // 3, ins['t']]), 0))", "s=input()\r\nprint(min(max(0, ( s.count('n')-1)//2),s.count('t'),s.count('i'),s.count('e')//3))", "def main():\n\ta = input().count\n\tprint(min(max(0, (a('n')-1)//2), a('i'), a('e')//3, a('t')))\n\t\nif __name__ == '__main__':\n\tmain()", "# -*- coding:utf-8 -*-\ndef Nineteen(s: str) -> int:\n # write code here\n # record the appearance times of n,i,e,t\n # n:3,i:1,e:3,t:1\n # use a list to record it is more simple, but here record it directly\n # n_num=0\n # i_num=0\n # e_num=0\n # t_num=0\n strs = \"niet\"\n str_len = len(strs)\n str_divide_times = [3, 1, 3, 1]\n nums = [0 for _ in range(str_len)]\n for ch in s:\n pos = strs.find(ch)\n if pos != -1:\n nums[pos] += 1\n min_times = -1\n for no, cur_nums in enumerate(nums):\n if strs[no] == 'n': # solve the start char specially\n cur_times = (cur_nums-1) // (str_divide_times[no]-1) # str_divide_times[no]>1\n else:\n cur_times = cur_nums // str_divide_times[no]\n if cur_times < min_times or min_times < 0:\n min_times = cur_times\n return min_times\n\nif __name__ == '__main__':\n s = input()\n print(Nineteen(s))\n \t \t\t\t \t \t\t \t\t \t \t \t \t \t", "s = input()\r\nn = s.count('n')-3\r\ne = s.count('e')-3\r\ni = s.count('i')-1\r\nt = s.count('t')-1\r\nif( min(n,t,e,i) == 0):\r\n print('1')\r\nelif(min(e,n,t,i)<0):\r\n print('0')\r\nelse:\r\n n//=2\r\n e//=3\r\n print(min(n,e,t,i)+1)" ]
{"inputs": ["nniinneetteeeenn", "nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii", "nineteenineteen", "nssemsnnsitjtihtthij", "eehihnttehtherjsihihnrhimihrjinjiehmtjimnrss", "rrrteiehtesisntnjirtitijnjjjthrsmhtneirjimniemmnrhirssjnhetmnmjejjnjjritjttnnrhnjs", "mmrehtretseihsrjmtsenemniehssnisijmsnntesismmtmthnsieijjjnsnhisi", "hshretttnntmmiertrrnjihnrmshnthirnnirrheinnnrjiirshthsrsijtrrtrmnjrrjnresnintnmtrhsnjrinsseimn", "snmmensntritetnmmmerhhrmhnehehtesmhthseemjhmnrti", "rmeetriiitijmrenmeiijt", "ihimeitimrmhriemsjhrtjtijtesmhemnmmrsetmjttthtjhnnmirtimne", "rhtsnmnesieernhstjnmmirthhieejsjttsiierhihhrrijhrrnejsjer", "emmtjsjhretehmiiiestmtmnmissjrstnsnjmhimjmststsitemtttjrnhsrmsenjtjim", "nmehhjrhirniitshjtrrtitsjsntjhrstjehhhrrerhemehjeermhmhjejjesnhsiirheijjrnrjmminneeehtm", "hsntijjetmehejtsitnthietssmeenjrhhetsnjrsethisjrtrhrierjtmimeenjnhnijeesjttrmn", "jnirirhmirmhisemittnnsmsttesjhmjnsjsmntisheneiinsrjsjirnrmnjmjhmistntersimrjni", "neithjhhhtmejjnmieishethmtetthrienrhjmjenrmtejerernmthmsnrthhtrimmtmshm", "sithnrsnemhijsnjitmijjhejjrinejhjinhtisttteermrjjrtsirmessejireihjnnhhemiirmhhjeet", "jrjshtjstteh", "jsihrimrjnnmhttmrtrenetimemjnshnimeiitmnmjishjjneisesrjemeshjsijithtn", "hhtjnnmsemermhhtsstejehsssmnesereehnnsnnremjmmieethmirjjhn", "tmnersmrtsehhntsietttrehrhneiireijnijjejmjhei", "mtstiresrtmesritnjriirehtermtrtseirtjrhsejhhmnsineinsjsin", "ssitrhtmmhtnmtreijteinimjemsiiirhrttinsnneshintjnin", "rnsrsmretjiitrjthhritniijhjmm", "hntrteieimrimteemenserntrejhhmijmtjjhnsrsrmrnsjseihnjmehtthnnithirnhj", "nmmtsmjrntrhhtmimeresnrinstjnhiinjtnjjjnthsintmtrhijnrnmtjihtinmni", "eihstiirnmteejeehimttrijittjsntjejmessstsemmtristjrhenithrrsssihnthheehhrnmimssjmejjreimjiemrmiis", "srthnimimnemtnmhsjmmmjmmrsrisehjseinemienntetmitjtnnneseimhnrmiinsismhinjjnreehseh", "etrsmrjehntjjimjnmsresjnrthjhehhtreiijjminnheeiinseenmmethiemmistsei", "msjeshtthsieshejsjhsnhejsihisijsertenrshhrthjhiirijjneinjrtrmrs", "mehsmstmeejrhhsjihntjmrjrihssmtnensttmirtieehimj", "mmmsermimjmrhrhejhrrejermsneheihhjemnehrhihesnjsehthjsmmjeiejmmnhinsemjrntrhrhsmjtttsrhjjmejj", "rhsmrmesijmmsnsmmhertnrhsetmisshriirhetmjihsmiinimtrnitrseii", "iihienhirmnihh", "ismtthhshjmhisssnmnhe", "rhsmnrmhejshinnjrtmtsssijimimethnm", "eehnshtiriejhiirntminrirnjihmrnittnmmnjejjhjtennremrnssnejtntrtsiejjijisermj", "rnhmeesnhttrjintnhnrhristjrthhrmehrhjmjhjehmstrijemjmmistes", "ssrmjmjeeetrnimemrhimes", "n", "ni", "nine", "nineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteen", "ninetee", "mzbmweyydiadtlcouegmdbyfwurpwbpuvhifnuapwynd", "zenudggmyopddhszhrbmftgzmjorabhgojdtfnzxjkayjlkgczsyshczutkdch", "rtzxovxqfapkdmelxiyjroohufhbakpmmvaxq", "zninetneeineteeniwnteeennieteenineteenineteenineteenineteenineteenineteenineteenineteeninetzeenz", "nnnnnnniiiiiiiiiiiitttttttttteeeeeeeeeeeeeeeeee", "ttttiiiieeeeeeeeeeeennnnnnnnn", "ttttttttteeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiinnnnnnn", "nnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiiiiitttttttttttttttttttt", "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiittttttttttttttttnnnnnnn", "nineeen", "nineteeeeeeeeeeeeeeeeettttttttttttttttttiiiiiiiiiiiiiiiiii", "nineteenieteenieteenieteenieteenieteenieteen", "nineteenineteenineteenineteenineteen"], "outputs": ["2", "2", "2", "0", "1", "2", "2", "1", "2", "0", "1", "2", "2", "3", "3", "1", "2", "3", "0", "2", "2", "1", "2", "1", "0", "3", "0", "2", "3", "3", "1", "1", "2", "1", "0", "0", "0", "3", "2", "0", "0", "0", "0", "13", "0", "0", "0", "0", "13", "3", "4", "3", "4", "3", "0", "0", "4", "5"]}
UNKNOWN
PYTHON3
CODEFORCES
119
e53c2a712af419ebf3b9bcf5bb958b21
Joysticks
Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at *a*1 percent and second one is charged at *a*2 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. The first line of the input contains two positive integers *a*1 and *a*2 (1<=≤<=*a*1,<=*a*2<=≤<=100), the initial charge level of first and second joystick respectively. Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged. Sample Input 3 5 4 4 Sample Output 6 5
[ "a,b = [int(x) for x in input().split(\" \")]\r\ntime = 0\r\nwhile a and b:\r\n if a==1 and b==1:\r\n break\r\n if a<b:\r\n a += 1\r\n b -= 2\r\n else:\r\n b += 1\r\n a -= 2\r\n time+=1\r\n\r\nprint(time)", "a,b=[int(x) for x in input().split()]\r\ncount=0\r\n\r\nwhile a*b >1:\r\n a,b=min(a,b),max(a,b)\r\n a+=1\r\n b-=2\r\n count+=1\r\n\r\nprint(count)\r\n", "a,b=map(int,input().split())\r\nans=0\r\nwhile(a>0 and b >0):\r\n if(a>b):\r\n a,b=b,a\r\n a=a+1\r\n b=b-2\r\n ans=ans+1\r\n if(a<0 or b<0):\r\n ans=ans-1\r\n break\r\nprint(ans)\r\n", "cnt, (a, b) = 0, (map(int,input().split()))\nwhile max(a,b) > 1 and min(a,b) > 0:\n\ta, b, cnt = min(a,b)+1, max(a,b)-2, cnt+1\nprint(cnt)\n", "a1,a2=map(int,input().split())\r\nans=0\r\nwhile (a1 and a2):\r\n if(a1<=a2):\r\n a1+=1\r\n if(a2>=2):\r\n a2-=2\r\n ans+=1\r\n else:\r\n a2=0\r\n else:\r\n a2+=1\r\n if(a1>=2):\r\n a1-=2\r\n ans+=1\r\n else:\r\n a1=0\r\nprint(ans) ", "a,b=map(int,input().split());t=0\r\nwhile a*b>1:\r\n a,b=min(a,b)+1,max(a,b)-2;t+=1\r\nprint(t)", "a,b=map(int, input().split())\r\ncnt=0\r\nwhile (a>=1 and b>=2) or (a>=2 and b>=1):\r\n if a<b:\r\n a+=1\r\n b-=2\r\n else:\r\n b+=1\r\n a-=2\r\n cnt+=1\r\nprint(cnt)", "(a1, a2) = [int(x) for x in input().split(\" \")]\r\nanswer = 0\r\n\r\nwhile a1 > 1 or a2 > 1:\r\n ost = max(a1 // 2, a2 // 2)\r\n if ost == 0:\r\n break\r\n\r\n if a1 > a2:\r\n if a1 - ost * 2 == 0 and ost != 1:\r\n ost -= 1\r\n\r\n a1 -= ost * 2\r\n a2 += ost\r\n else:\r\n if a2 - ost * 2 == 0 and ost != 1:\r\n ost -= 1\r\n a2 -= ost * 2\r\n a1 += ost\r\n answer += ost\r\n if a1 == 0 or a2 == 0:\r\n break\r\nprint(answer)\r\n", "a,b=map(int,input().split())\ncount=0\nwhile(a>0 and b>0):\n if(a==1)and(b==1):\n break\n if(a>b):\n a,b=b,a\n a=a+1\n b=b-2\n else:\n a,b=b,a\n b=b+1\n a=a-2\n count=count+1\nprint(count)\n\t\t \t\t\t\t\t \t\t \t \t \t\t\t\t \t \t\t \t \t", "a1,a2=map(int,input().split())\r\nans=0\r\nif a1==1 and a2==1:\r\n print(0)\r\nelse:\r\n while a1>0 or a2>0:\r\n if (a1==a2==1) or (a1==a2==2) or (a1==2 and a2==1) or (a1==1 and a2==2):\r\n break\r\n elif a1<a2:\r\n a1=a1+1\r\n a2=a2-2\r\n ans=ans+1\r\n else:\r\n a1=a1-2\r\n a2=a2+1\r\n ans=ans+1\r\n print(ans+1)", "a1,a2=map(int,input().split())\r\ntime=0\r\nwhile((a1>1 or a2>1)and a1>0 and a2>0):\r\n if a1<a2:\r\n a1+=1\r\n a2-=2\r\n else:\r\n a1-=2\r\n a2+=1\r\n\r\n time+=1\r\nprint(time)", "a,b = map(int, input().split())\r\nf = max(a,b)\r\nl = min(a,b)\r\nans = 0\r\nwhile(f!=0 and l!= 0):\r\n if(f==1 and l==1):\r\n break\r\n f-=2\r\n l+=1\r\n f,l = max(f,l), min(f,l)\r\n ans+=1\r\nprint(ans)", "import sys\r\na,b=map(int,input().split())\r\ncount=0\r\nif a==b==1:\r\n print(0)\r\n sys.exit(0)\r\nwhile a>0 and b>0:\r\n if a>b:\r\n a-=2\r\n b+=1\r\n else:\r\n a+=1\r\n b-=2\r\n count+=1\r\n \r\nprint(count)", "a,b=map(int,input().split())\r\nx=0\r\nwhile a>1 and b>0 or a>0 and b>1:\r\n if a<b:a+=1;b-=2\r\n else:a-=2;b+=1\r\n x+=1\r\nprint(x)", "a,b=[int(i) for i in input().split(\" \")]\nc=0\nwhile a>0 and b>0:\n\tif a==1 and b==1:\n\t\tbreak\n\telif a>b:\n\t\ta,b=b,a\n\ta+=1\n\tb-=2\n\tc+=1\nprint(c)", "ins = list(map(int, input().split(\" \")))\r\nif sum(ins) > 2: \r\n if (ins[0] == ins[1]) or ((ins[0] - ins[1]) % 3 == 0): print(ins[0] + ins[1] - 3)\r\n else: print(ins[0] + ins[1] - 2)\r\nelse: print(0)", "i,j=map(int,input().split())\nc=0\nwhile(i>0 and j>0):\n if i==1 and j==1:\n break\n if i>j:\n i,j=j,i\n i+=1\n j-=2\n else:\n i,j=j,i\n j+=1\n i-=2\n c+=1\nprint(c)\n\t \t\t\t \t\t \t \t \t\t\t\t\t\t \t \t", "\na1,a2=map(int,input().split())\nc=0\nwhile(a1>0 and a2>0):\n if(a1==1 and a2==1):\n break \n if(a1>a2):\n a2+=1 \n a1-=2 \n else:\n a1+=1 \n a2-=2 \n c+=1 \nprint(c)\n\n\n\n\t\t \t\t\t \t \t \t \t \t \t \t\t\t\t", "a1, a2 = map(int, input().split())\r\n\r\ncnt = 0\r\nwhile a1 >= 1 and a2 >= 1 and (a1 != 1 or a2 != 1):\r\n if a1 > a2:\r\n a2 += 1\r\n a1 -= 2\r\n else:\r\n a1 += 1\r\n a2 -= 2\r\n \r\n cnt += 1\r\n \r\nprint(cnt)", "a1,a2=map(int,input().split())\r\nE=0\r\n\r\nwhile min(a1,a2)>0:\r\n if a1==a2 and a1==1:\r\n break\r\n E+=1\r\n if a1<a2:\r\n a1+=1\r\n a2-=2\r\n else:\r\n a2+=1\r\n a1-=2\r\n \r\nprint(E)", "a, b = map(int, input().split())\nres = 0\nwhile a > 0 and b > 0 and a + b > 2:\n if a < b:\n a, b = b, a\n a -= 2\n b += 1\n res += 1\nprint(res)\n", "import sys\r\nimport collections\r\nimport math\r\nimport functools\r\nimport itertools\r\nimport bisect\r\nimport operator\r\nimport heapq\r\nimport random\r\ntrue=True\r\nfalse=False\r\nnull=None\r\ntcid=0\r\ntcmax=99999999\r\ndef compute(val, func): return func(val)\r\ndef seq(lo,hi,step=1): \r\n return range(lo,hi+1,step)\r\ndef sround(val,nd):\r\n return f'{val:.{nd}f}'\r\ndef ceil(a,b):\r\n ans=a//b\r\n if a%b!=0: ans+=1\r\n return ans\r\ndef perr(*args,**kwargs): print(*args,file=sys.stderr,**kwargs)\r\ndef line():\r\n ln=sys.stdin.readline().strip()\r\n #perr(ln)\r\n if ln=='': sys.exit()\r\n return ln\r\ndef lines(n): return [line() for i in range(n)]\r\ndef split(ln=None): return (ln or line()).split()\r\ndef num(str=None):\r\n str=str or line()\r\n return float(str) if '.' in str else int(str)\r\ndef nums(o=None):\r\n if o is not None:\r\n if isinstance(o, int): o=lines(o)\r\n elif isinstance(o, str): o=split(o)\r\n return list(map(num, o or split()))\r\n#\r\n#help(\"sys.modules\")\r\n\"\"\"\r\nceil(a,b) sround(val,nd) true false null\r\nnum(?) nums(?) split(?) lines(n) line()\r\nperr(print) tcmax seq() compute(v,f) tcid\r\n\"\"\"\r\n#{#\r\n\r\n#}#\r\ndef mainloop(tcid=1):\r\n# {{{\r\n a,b=nums()\r\n @functools.lru_cache(None)\r\n def rec(aa,bb):\r\n if aa<1 or bb<1:\r\n return 0\r\n if aa<2 and bb<2:\r\n return 0\r\n ans=1+max(rec(aa+1,bb-2),rec(aa-2,bb+1))\r\n return ans\r\n print(rec(a,b))\r\n# }}}\r\nwhile tcid<tcmax:\r\n tcid+=1\r\n mainloop(tcid)\r\n\"\"\"\r\nNOTES = .\r\n\r\n\"\"\"\r\n\"\"\"\r\nPROBLEM #ID = .\r\n\r\n\"\"\"", "a,b=map(int,input().split())\r\ncount=0\r\nwhile max(a,b)>1 and min(a,b)>0:\r\n a,b=max(a,b)-2,min(a,b)+1\r\n count+=1\r\nprint(count)", "n,m = map(int,input().split())\r\nans = 0\r\nif n == 1 and m == 1: print(0);exit()\r\nwhile n > 0 and m > 0:\r\n if n < m:\r\n n,m = m,n\r\n n -= 2\r\n m += 1\r\n ans += 1\r\nprint(ans)\r\n", "p,q=map(int,input().split())\r\ni=0\r\nwhile(p>1 or q>1):\r\n while(p>2):\r\n p-=2\r\n q+=1\r\n i+=1\r\n while(q>2):\r\n i+=1\r\n q-=2\r\n p+=1\r\n if(p<=2 and q<=2):\r\n i+=1\r\n break\r\nprint(i)", "a1, a2 = map(int, input().split())\r\ntime = 0\r\nwhile (a1>=2 or a2>=2) and (a1*a2>0):\r\n if(a1>=a2):\r\n a2+=1\r\n a1-=2\r\n else:\r\n a2-=2\r\n a1+=1\r\n time+=1\r\nprint(time)", "n,m=map(int,input().split())\r\nc=0\r\nif(n<=2 and m<=2):\r\n if(m<2 and n<2):\r\n print(0)\r\n else:\r\n print(1)\r\nelse:\r\n c=1\r\ncount=0\r\nwhile(n>=1 or m>=1):\r\n if(n<=2 and m<=2):\r\n break\r\n if(n>m):\r\n q=n//2\r\n r=n%2\r\n if(r==0):\r\n q-=1\r\n m+=q\r\n count+=q\r\n n=2\r\n else:\r\n m+=q\r\n count+=q\r\n n=1\r\n elif(m>=n):\r\n q=m//2\r\n r=m%2\r\n if(r==0):\r\n q-=1\r\n n+=q\r\n count+=q\r\n m=2\r\n else:\r\n n+=q\r\n count+=q\r\n m=1\r\nif(m<2 and n<2 and c==1):\r\n print(count)\r\nelif(c==1):\r\n print(count+1)\r\n", "a,b=map(int,input().split())\r\nc=0\r\nif max(a,b)==1:\r\n print(c)\r\nelse:\r\n if a<b:\r\n d=a\r\n e=b\r\n else:\r\n d=b\r\n e=a\r\n while d>0 and e>0:\r\n if d==1 or d==2:\r\n d,e=e,d\r\n \r\n d-=2\r\n e+=1\r\n c+=1\r\n print(c) \r\n ", "a,k=map(int,input().split())\nc=0\nwhile(a>0 and k>0): \n if(a==1 and k==1):\n break\n if(a>k):\n a-=2\n k+=1\n c+=1\n else:\n a+=1\n k-=2\n c+=1\nprint(c)\n\t\t\t\t\t \t \t \t \t \t\t\t\t", "def rec(m,n):\r\n if m<0 or n<0:\r\n return 0\r\n elif m==0 or n==0:\r\n return 1\r\n else:\r\n return 1+rec(min(m,n)+1,max(m,n)-2)\r\nm,n=map(int,input().split())\r\ntemp=m\r\nm=min(m,n)\r\nif m!=temp:\r\n n=temp\r\nprint(rec(min(m,n)+1,max(m,n)-2))\r\n \r\n", "x,y=map(int,input().split())\ncount=0\nwhile 1:\n if x<=0 or y<=0:\n break\n if x==1 and y==1:\n break\n if x>y:\n x,y=y,x\n x+=1\n y-=2\n count+=1\nprint(count)\n\n\n\n\n\n\n\n \t \t \t \t \t\t \t \t\t \t", "s = input()\ns1 = s.split(' ')\na = int(s1[0])\nb = int(s1[1])\ncount = 0\nwhile (a + b) >= 3 and a != 0 and b != 0:\n count += 1\n if a < b:\n a += +1\n b -= 2\n else:\n b += 1\n a -= 2\nprint(count)", "a1,a2=map(int,input().split())\nc=0\nwhile(a1>0 and a2>0):\n if(a1==1 and a2==1):\n break\n elif(a1<a2):\n a2=a2-2\n a1=a1+1 \n c=c+1 \n else:\n a1=a1-2\n a2=a2+1 \n c=c+1 \nprint(c)\n \n\t \t \t \t \t \t\t\t\t \t\t\t\t \t\t \t \t \t", "a,b=map(int,input().split())\nk=0\nwhile(a>0 and b>0):\n if a==1 and b==1:\n break\n if a>b:\n b+=1\n a-=2\n else:\n a+=1\n b-=2\n k+=1\nprint(k)\n \t \t\t\t\t \t \t \t\t\t\t\t \t \t \t\t\t \t", "a1,a2=map(int,input().split())\r\nm=0\r\nwhile a1 and a2:\r\n if a1>=a2:\r\n a1-=2\r\n a2+=1\r\n else:\r\n a2-=2\r\n a1+=1\r\n if a1<0 or a2<0:\r\n break\r\n m+=1\r\n\r\nprint(m)\r\n ", "import sys\ndef input(): return sys.stdin.readline()[:-1]\n# def input(): return sys.stdin.buffer.readline()[:-1]\n\n# n = int(input())\na, b = [int(x) for x in input().split()]\n\nans = 0\nwhile a and b and a + b >= 3:\n if a > b:\n a, b = b, a\n ans += 1\n a += 1\n b -= 2\n\nprint(ans)", "a,b = map(int,input().split())\r\nminute = 0\r\nwhile( a>0 and b>0):\r\n if(a<=b):\r\n a+=1\r\n b-=2\r\n else:\r\n b+=1\r\n a-=2\r\n minute+=1\r\nprint(minute+min(a,b))", "a1,a2 = list(map(int,input().split()))\r\nif a1<=1 and a2<=1:\r\n print(0)\r\nelse:\r\n print(a1+a2-3 if (a1-a2)%3==0 else a1+a2-2)\r\n", "p,q=map(int,input().split())\nr=0\nwhile(p>0 and q>0):\n if p==1 and q==1:\n break\n if p>q:\n p,q=q,p\n p+=1\n q-=2\n else:\n p,q=q,p\n q+=1\n p-=2\n r+=1\nprint(r)\n \t\t \t \t \t \t \t \t\t\t\t \t\t \t \t", "a, b = map(int, input().split())\nans = 0\nwhile (a >= 2 and b >= 1) or (b >= 2 and a >= 1):\n if a > b:\n a, b = b, a\n a += 1\n b -= 2\n ans += 1\n\nprint(ans) \n", "C1, C2 = map(int, input().split())\r\ntime = 0\r\nwhile((C1 > 1 or C2 > 1) and (C1 > 0 and C2 > 0)):\r\n \r\n # print(C1, C2)\r\n if C1 < C2 :\r\n \r\n C1 += 1\r\n C2 -= 2\r\n time += 1\r\n \r\n else:\r\n \r\n C2 += 1\r\n C1 -= 2\r\n time += 1\r\n\r\nprint(time)", "a,b = [int(x) for x in input().split()]\r\n\r\nu = a\r\nv = b\r\nx = 0\r\nwhile (u+v >=3 and u>0 and v>0):\r\n if(u<=v):\r\n u = u+1 \r\n v = v-2 \r\n else:\r\n v = v + 1 \r\n u = u - 2 \r\n x = x+1 \r\n # print(u,v)\r\nprint(x) \r\n", "# LUOGU_RID: 101607441\na1, a2 = map(int, input().split())\r\nans = 0\r\nwhile min(a1, a2) > 0:\r\n a1, a2 = min(a1, a2), max(a1, a2)\r\n a1 += 1\r\n a2 -= 2\r\n if min(a1, a2) >= 0:\r\n ans += 1\r\n\r\nprint(ans)\r\n", "from sys import stdin, stdout\n\n\ndef input():\n return stdin.readline().strip()\n\n\ndef print(string):\n return stdout.write(str(string) + \"\\n\")\n\n\ndef main():\n a1, a2 = [int(x) for x in input().split()]\n time = 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 if a1 >= 0 and a2 >= 0:\n time += 1\n print(time)\n\n\nif __name__ == \"__main__\":\n main()\n", "a,b=list(map(int,input().split()))\r\nm=0\r\nif 1==a and b==1 :\r\n print(0)\r\n \r\nelse :\r\n while(a!=0 and b!=0 ):\r\n a,b= sorted([a,b])\r\n if (a+1<100):a+=1\r\n b-=2\r\n m+=1\r\n print( m) \r\n\r\n\r\n", "a, b = map(int, input().split())\r\nc = 0\r\nwhile(a>0 and b>0):\r\n\tif(a == 1 and b == 1):\r\n\t\tbreak\r\n\tif(a<b):\r\n\t\ta+=1\r\n\t\tb-=2\r\n\telse:\r\n\t\ta-=2\r\n\t\tb+=1\r\n\tc+=1\r\nprint(c)", "p,q=map(int,input().split())\r\nres=0\r\nwhile(p>1 or q>1):\r\n res+=1\r\n p,q = min(p,q)+1,max(p,q)-2\r\n if(p==0 or q==0):\r\n break\r\nprint(res)", "X, Y = map(int, input().split())\ncharger = \"X\"\ncnt = 0\n\nwhile not (Y == 0 or X == 0 or (X == 1 and Y == 1)):\n \n if X >= Y:\n charger = \"Y\"\n else:\n charger = \"X\"\n \n if charger == \"Y\":\n Y += 1\n X -= 2\n \n else:\n Y -= 2\n X += 1\n\n cnt += 1\n\n \n\nprint(cnt)", "def joysticks(a1, a2):\n if a1 > a2:\n a1, a2 = a2, a1\n t = 0\n while a1 and a2 and (a1 > 1 or a2 > 1):\n k = max((a2 - 1) // 2, 1)\n t += k\n a1 += k\n a2 -= 2*k\n a1, a2 = a2, a1\n \n return t\n\n\ndef main():\n a1, a2 = readinti()\n print(joysticks(a1, a2))\n\n##########\n\nimport sys\n\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\nif __name__ == '__main__':\n main()\n", "l=input()\r\nl=l.split()\r\nn=int(l[0])\r\nm=int(l[1])\r\ns=0\r\nif(n==1 and m==1):\r\n\tprint(0)\r\nelse:\r\n\twhile min(n,m)>0:\r\n\t\tif(n>=m):\r\n\t\t\tn-=2\r\n\t\t\tm+=1\r\n\t\telse:\r\n\t\t\tn+=1\r\n\t\t\tm-=2\r\n\t\ts+=1\r\n\tprint(s)", "a,b=map(int,input().split())\r\ns=0\r\nwhile(a!=0 and b!=0 and max(a,b)>1):\r\n if(a>b):\r\n a,b=b,a\r\n a+=1;b-=2\r\n s+=1\r\nprint(s)\r\n", "a1, a2 = map(int, input().split())\r\n\r\nprint(max(a1 + a2 - 3 + ((a2 - a1) % 3 > 0), 0))\r\n", "a1, a2 = map(int, input().split())\r\ncharge, cnt = 0, 0\r\nwhile (a1 > 0 and a2 > 0):\r\n if a1 == 1 and a2 == 1:\r\n break\r\n cnt += 1\r\n if (a1 <= a2):\r\n charge = 0\r\n elif (a2 < a1):\r\n charge = 1\r\n if charge == 1:\r\n a1 -= 2\r\n a2 += 1\r\n elif charge == 0:\r\n a1 += 1\r\n a2 -= 2\r\nprint(cnt)", "a, b = map(int, input().rstrip().split(\" \"))\r\ni = 0\r\nif a==1 and b==1:\r\n print(0)\r\nelse:\r\n while a > 0 and b > 0:\r\n i += 1\r\n if a > b:\r\n a -= 2\r\n b += 1\r\n else:\r\n a += 1\r\n b -= 2\r\n print(i)", "n, m = map(int,input().split())\nc = 0\nwhile max(n, m) > 1 and min(n,m) > 0:\n n, m = min(n,m)+1 , max(n,m)-2\n c += 1\nprint(c)\n\t\t\t \t\t \t\t \t \t\t\t \t\t\t\t\t\t\t\t", "a,b = map(int,input().split())\r\nx = 0\r\nwhile(a*b) >= 2:\r\n if (a>b):\r\n a -= 2\r\n b += 1\r\n\r\n else:\r\n b -= 2\r\n a += 1\r\n\r\n x += 1\r\n\r\nprint(x)", "n,m=map(int,input().split())\r\nres=0\r\nwhile True:\r\n if n==0 or m==0 or n==m==1:\r\n break\r\n if n >= m:\r\n n -= 2\r\n m += 1\r\n res += 1\r\n else:\r\n n += 1\r\n m -= 2\r\n res += 1\r\nprint(res)", "n, m= map(int, input().split())\r\ncount = 0\r\nwhile n > 0 or m > 0:\r\n #print(n, m, count)\r\n if n > 2 and m > 2:\r\n n -= 2\r\n m += 1\r\n elif (n == 1 or n == 2) and m > 2:\r\n m -= 2\r\n n += 1\r\n elif n > 2 and (m == 1 or m == 2):\r\n n -= 2\r\n m += 1\r\n elif n == 2 or m == 2:\r\n n -= 2\r\n m -= 2\r\n else:\r\n break\r\n count += 1\r\nprint(count)\r\n", "joy1 , joy2 = [int(x) for x in input().split()]\nminutes = 0\nif(joy1 == 1 and joy2 == 1):\n print(minutes)\nelse:\n while(True):\n if(joy2 > joy1 and (joy1 >0 and joy2 >0)):\n joy2 -= 2 \n joy1 += 1 \n minutes += 1\n elif(joy1 > joy2 and (joy1 >0 and joy2 >0)):\n joy2 += 1 \n joy1 -= 2\n minutes += 1\n elif(joy1 == joy1 and (joy1 >0 and joy2 >0)):\n joy1 += 1 \n joy2 -= 2\n minutes += 1 \n else:\n if(joy2 <= 0 or joy1 <= 0):\n break\n print(minutes)\n \n \t\t \t \t\t \t\t \t\t \t \t\t \t \t \t", "a1, a2 = map(int, input().split())\n\ntimer = 0\n\nwhile a1 > 0 and a2 > 0 and not(a1 == 1 and a2 == 1):\n timer += 1\n \n if a1 == 1 or a1 <= a2:\n a1 += 1\n a2 -= 2\n elif a2 ==1 or a2 < a1:\n a2 += 1\n a1 -= 2\nprint(timer)", "import math\r\na, b = map(int,input().split())\r\nc = 0\r\nwhile 1:\r\n if a == 0 or b == 0:\r\n break\r\n elif a == 1 and b == 1:\r\n break\r\n else:\r\n if a == min(a,b):\r\n a += 1\r\n b -= 2\r\n else:\r\n b += 1\r\n a -= 2\r\n c += 1\r\nprint(c)\r\n", "n, m = map(int, input().split())\r\nk = 0\r\nif n + m < 3:\r\n print(0)\r\n exit()\r\nwhile min(n, m) > 0:\r\n if n == min(n, m):\r\n n += 1\r\n m -= 2\r\n else:\r\n m += 1\r\n n -= 2\r\n k += 1\r\nprint(k)\r\n", "a1, a2 = map(int, input().split())\ntot = 0\nwhile a1 >= 1 and a2 >= 1:\n if a1 >= a2:\n if a1 & 1:\n min = a1 // 2\n a1 = 1\n else:\n min = a1 // 2 - 1\n a1 = 2\n a2 += min\n else:\n if a2 & 1:\n min = a2 // 2\n a2 = 1\n else:\n min = a2 // 2 - 1\n a2 = 2\n a1 += min\n if min == 0:\n break\n tot += min\n # print(a1, a2)\nif a1 > 1 or a2 > 1:\n print(tot + 1)\nelse:\n print(tot)\n", "a1,a2=list( map( int, input().split(\" \")))\r\ni=0\r\nwhile a1>0 and a2>0 :\r\n if a1 == 1 and a2 == 1:\r\n break\r\n elif a1 >= a2:\r\n a1=a1-2\r\n a2=a2+1\r\n else:\r\n a2=a2-2\r\n a1=a1+1\r\n i = i + 1\r\nprint(i)", "import sys\r\n\r\n\r\ndef read_input(input_path=None):\r\n if input_path is None:\r\n f = sys.stdin\r\n else:\r\n f = open(input_path, 'r')\r\n\r\n n, m = map(int, f.readline().split())\r\n\r\n return n, m\r\n\r\n\r\ndef sol(n, m):\r\n c = 0\r\n while max(n, m) > 2:\r\n if min(m, n) == m:\r\n m, n, c = m + 1, n - 2, c + 1\r\n else:\r\n m, n, c = m - 2, n + 1, c + 1\r\n if (n == 2 or m == 2) and (n != 0 or m != 0):\r\n c = c + 1\r\n\r\n return [f\"{c}\"]\r\n\r\n\r\ndef solve(input_path=None):\r\n return sol(*read_input(input_path))\r\n\r\n\r\ndef main():\r\n for line in sol(*read_input()):\r\n print(f\"{line}\")\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "def mins(a):\r\n if min(a) == 0:\r\n return 0\r\n if max(a) == 1:\r\n return 0\r\n else:\r\n return 1 + mins([min(a) + 1, max(a) - 2])\r\n\r\n\r\na = [int(x) for x in input().split(' ')]\r\nn = sum(a)\r\n\r\nprint(mins(a))\r\n\r\n\r\n", "a, b = map(int, input().split())\r\ncount = 0\r\nif a == 1 and b == 1:\r\n print(0)\r\nelse:\r\n while a > 0 and b > 0:\r\n if a > b:\r\n a -= 2\r\n b += 1\r\n else:\r\n b -= 2\r\n a += 1\r\n count += 1\r\n print(count)\r\n", "\r\n\r\n\r\n[a,b]=list(map(int,input().split()));\r\n\r\ndef f(a,b):\r\n\tif((a,b)==(1,1)):return 0;\r\n\telif((a,b)==(1,2) or (a,b)==(2,1) or (a,b)==(2,2)):return 1;\r\n\telse:\r\n\t\ta,b=max(a,b),min(a,b);\r\n\t\tif(a%2!=0):return a//2+f(1,b+a//2);\r\n\t\telse:return a//2-1+f(2,b+a//2-1);\r\nprint(f(a,b));\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "a, b = map(int, input().split())\nans = 0\n\nwhile((a > 1 and b > 1) or (a == 1 and b > 1) or (b == 1 and a > 1)):\n\tans = ans + 1\n\tif a > b:\n\t\ta, b = b, a\n\ta = a + 1\n\tb = b - 2\n\t#print(a, b)\n\nprint(ans)\n", "n,m=map(int,input().split())\nc=0\nwhile(n and m):\n if(n>=2 or m>=2):\n if(n>=m):\n m+=1\n n-=2\n c=c+1\n else:\n n+=1\n m-=2\n c=c+1\n else:\n break\nprint(c)\n\t\t \t \t \t\t\t \t \t \t \t \t\t\t\t\t\t", "a1,a2=map(int,input().split())\r\n\r\nif (a1-a2)%3==0:\r\n print(max(a1+a2-3,0))\r\nelse:\r\n print(max(a1+a2-2,0))", "c = list(map(int, input().split()))\ncc = 0 if c[0] == c[1] else c.index(min(c))\nm = 0\n\nif c[0] == 1 and c[1] == 1:\n\tprint(0)\nelse:\n\twhile c[0] > 0 and c[1] > 0:\n\t\tc[cc] += 1\n\t\tc[1 - cc] -= 2\n\t\tm += 1\n\t\tcc = 0 if c[0] == c[1] else c.index(min(c))\n\n\tprint(m)\n\n", "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 if n < 0 or m < 0:\n break\n\n c += 1\n\nprint(c)\n", "a1, a2 = map(int, input().split())\r\n\r\nminute = 0\r\nwhile True:\r\n if a1 < a2:\r\n a1 += 1\r\n a2 -= 2\r\n minute += 1\r\n elif a2 < a1:\r\n a2 += 1\r\n a1 -= 2\r\n minute += 1\r\n else:\r\n if a1 == 1:\r\n a1 -= 1\r\n else:\r\n a1 += 1\r\n a2 -= 2\r\n minute += 1\r\n if a1 <= 0 or a2 <= 0:\r\n break\r\n\r\nprint(minute)", "n,m=map(int,input().split())\r\ncount=0\r\nwhile n>0 and m>0:\r\n\tif n>m:\r\n\t\tn-=2\r\n\t\tm+=1\r\n\telse:\r\n\t\tm-=2\r\n\t\tn+=1\r\n\tif n<0 or m<0:\r\n\t\tbreak\r\n\tcount+=1\r\nprint(count)", "a,b=map(int,input().split())\nd=0\nwhile(a>0 and b>0):\n if a==1 and b==1:\n break\n if a>b:\n a,b=b,a\n a+=1\n b-=2\n else:\n a,b=b,a\n b+=1\n a-=2\n d+=1\nprint(d)\n\t\t\t\t\t\t \t \t \t\t \t\t \t\t \t \t \t", "a,b=sorted(list(map(int,input().split())))\r\nc=0\r\nwhile(a>0 and b>1):\r\n c+=1\r\n a,b=sorted([min(a,b)+1,max(a,b)-2])\r\nprint(c) ", "a1,a2 = map(int,input().split())\r\nc = 0\r\nmax1 = a1\r\nmin1 = a2\r\nif(max1 == 1 and min1 == 1):\r\n print(0)\r\nelse:\r\n while(max1>0 and min1>0):\r\n #print(\"max1: \",max1,\" min1: \",min1)\r\n max1 = max(a1,a2)\r\n min1 = min(a1,a2)\r\n max1-=2\r\n min1+=1\r\n a1 = max1\r\n a2 = min1\r\n c+=1\r\n print(c)\r\n", "from collections import deque\r\nfrom collections import OrderedDict\r\nimport queue\r\nimport heapq\r\nimport math\r\nimport sys\r\nsys.setrecursionlimit(10**6)\r\n \r\ndef sf(): return [int(x) for x in input().split(\" \")]\r\ndef sfi(): return int(input())\r\ndef sfs(): return input()\r\ndef printf(x):\r\n print(x)\r\n sys.stdout.flush()\r\n\r\n\r\n# Return maximum number of minutes a game can last.\r\n# If a charger dies, game ends.\r\n# A charger charges 1 charge to controller per minute.\r\n# A controller drains 2 charge if not connected to a charger per minute.\r\n\r\n# IMPORTANT:\r\n# If a controller has 1 charge, it dies in 30 secs if not charged\r\n# And therefore game dies in (0 max mins)\r\n\r\ndef main():\r\n x,y = [int(x) for x in input().split(\" \")]\r\n result = 0\r\n while x>0 and y>0:\r\n # Charge x if x has less battery than y\r\n if (x < y): \r\n x += 1\r\n y -= 2 \r\n \r\n # Charge y if y has less batttery than x\r\n else:\r\n y += 1\r\n x -= 2\r\n\r\n # Only increment if both controller has lasted a full minute.\r\n # If a charger did not last a full minute, it will have -1 charge \r\n # after a full minute.\r\n if x>=0 and y>=0:\r\n result += 1\r\n \r\n print(result)\r\n\r\nif __name__ == \"__main__\":\r\n main()", "a,b=map(int,input().split())\r\nc=0\r\nif (a==1 and b==1):\r\n\tprint(\"0\")\r\nelse:\r\n\twhile(a!=0 and b!=0):\r\n\t\tif a>=b:\r\n\t\t\tb+=1\r\n\t\t\ta-=2\r\n\t\t\tc+=1\r\n\t\telse:\r\n\t\t\ta+=1\r\n\t\t\tb-=2\r\n\t\t\tc+=1\r\n\tprint(c)\r\n", "from math import ceil\r\nM=[[0]*151 for _ in range(151)]\r\nfor d in range(3,301):\r\n for i in range(min(150,d),ceil(d/2)-1,-1):\r\n j=d-i\r\n if j==0:\r\n M[i][j]=0\r\n continue\r\n try:\r\n a=M[i+1][j-2]\r\n except:\r\n a=0\r\n try:\r\n x,y=max(i-2,j+1),min(i-2,j+1)\r\n b=M[x][y]\r\n except:\r\n b=0\r\n M[i][j]=max(a,b)+1\r\ni,j=map(int,input().split())\r\ni,j=max(i,j),min(i,j)\r\nprint(M[i][j])", "a1, a2 = map(int, input().split())\r\n\r\na12 = a1 + a2\r\n\r\nb = [[]] * (a12 + 1)\r\nfor i in range(a12 + 1):\r\n b[i] = [0] * (a12 + 1)\r\n\r\n\r\ndef get_b(i1, i2):\r\n return b[i1][i2] if i1 >= 0 and i2 >= 0 else -1\r\n\r\n\r\nfor i in range(a12 + 1):\r\n for j1 in range(i + 1):\r\n j2 = i - j1\r\n if j2 < 0:\r\n break\r\n\r\n val = max(get_b(j1 - 2, j2 + 1), get_b(j1 + 1, j2 - 2))\r\n\r\n if val >= 0:\r\n b[j1][j2] = val + 1 if j1 > 0 and j2 > 0 else val\r\n\r\nprint(b[a1][a2])\r\n", "a, b = map(int, input().split())\r\nres = 0\r\nwhile(a > 0 and b > 0):\r\n if(a <= b):\r\n if( b == 1):\r\n break\r\n res += 1\r\n a += 1\r\n b -= 2\r\n elif(b <= a):\r\n if(a == 1):\r\n break \r\n res += 1\r\n b += 1\r\n a -= 2\r\n\r\nprint (res)", "p,n=map(int,input().split())\nc=0\nwhile(p>0 and n>0):\n if p==1 and n==1:\n break\n if p>n:\n p,n=n,p\n p+=1\n n-=2\n else:\n p,n=n,p\n n+=1\n p-=2\n c+=1\nprint(c)\n \t \t\t\t\t \t \t \t\t\t\t\t \t", "a,b=map(int, input().split())\r\n\r\nif a<b:\r\n a,b=b,a\r\n\r\nd=a-b\r\n\r\nif b==0:\r\n print(0)\r\n exit(0)\r\n\r\nif a<=1 and b<=1:\r\n print(0)\r\n exit(0)\r\n\r\nif d%3==0:\r\n #print(\"divisible by 3 case\")\r\n #print(a, b)\r\n ch = d // 3\r\n a = a - 2 * ch\r\n b = b + ch\r\n #print(a, b)\r\n print(ch + (2*a-3))\r\n\r\nelse:\r\n #print(\"Other case\")\r\n #print(a,b)\r\n ch = d//3\r\n a=a-2*ch\r\n b=b+ch\r\n #print(a,b)\r\n print(ch+a+b-2)", "a, b = map(int, input().split())\n\ncache = {}\n\n\ndef dp(a, b):\n if (a, b) in cache:\n return cache[(a, b)]\n if (a == b == 1) or b == 0 or a == 0:\n result = 0\n else:\n if a == 1:\n result = 1 + dp(a + 1, b - 2)\n elif b == 1:\n result = 1 + dp(a - 2, b + 1)\n else:\n result = 1 + max(dp(a + 1, b - 2), dp(a - 2, b + 1))\n cache[(a, b)] = result\n return result\n\n\nprint(dp(a, b))\n\n", "import time\n\nvals = [*map(int, input().split())]\nvals.sort()\n\na = vals[0]\nb = vals[1]\n\ndef f(a, b):\n if a <= 0 or b <= 0: return 0\n if a == b == 1: return 0\n\n if a < b:\n return 1 + f(a+1, b-2)\n else:\n return 1 + f(a-2, b+1)\n\nprint(f(a,b))\nexit(0)\n\ntimes = 0\nwhile True:\n a += 1\n b -= 2\n\n if a <= 0 or b <= 0: break\n times += 1\n \n if b <= 2: a, b = b, a\n \nprint(times)\n", "a,b=list(map(int,input().split()))\r\ncnt=0\r\n\r\nif a==1 and b==1:\r\n\tprint(0)\r\nelse:\r\n\twhile a>0 and b>0:\r\n\t\tif a>=b:\r\n\t\t\ta-=2\r\n\t\t\tb+=1\r\n\t\t\tcnt+=1\r\n\t\telse:\r\n\t\t\ta+=1\r\n\t\t\tb-=2\r\n\t\t\tcnt+=1\r\n\tprint(cnt)", "a,b=map(int,input().split())\np=0\nwhile(a>0 and b>0):\n if a==1 and b==1:\n break\n if a>b:\n a,b=b,a\n a+=1\n b-=2\n else:\n a,b=b,a\n b+=1\n a-=2\n p+=1\nprint(p)\n \t\t\t \t \t \t\t\t \t\t \t \t", "a,b=map(int,input().split())\r\n\r\nres=0\r\n\r\nwhile a>0 or b>0:\r\n if a>2:\r\n res+=((a-1)//2)\r\n b+=((a-1)//2)\r\n a%=2\r\n if a==0:\r\n a=2\r\n elif b>2:\r\n res+=((b-1)//2)\r\n a+=((b-1)//2)\r\n b%=2\r\n if b==0:\r\n b=2\r\n else:\r\n res+=max(a,b)//2\r\n break\r\n \r\n #print(str(a)+' '+str(b)+' '+str(res))\r\n\r\nprint(res)", "a,b=map(int,input().split())\r\ns=0\r\nwhile (a*b>1):\r\n a,b=min(a,b),max(a,b)\r\n a+=1\r\n b-=2\r\n s+=1\r\nprint(s)", "x, y = map(int, input().split())\r\nif x == 1 and y == 1:\r\n print(0)\r\n exit()\r\nc = 0\r\nwhile (1):\r\n if x <= y:\r\n while (y - 2 >0):\r\n y = y - 2\r\n x = x + 1\r\n c = c + 1\r\n else:\r\n while (x - 2 >0):\r\n x = x - 2\r\n y = y + 1\r\n c = c + 1\r\n if (x == 1 and y == 2) or (x == 2 and y == 1) or (x == 2 and y == 2):\r\n c = c + 1\r\n break\r\n if x == 0 or x == -1 or y == 0 or y == -1:\r\n break\r\nprint(c)\r\n\r\n", "a,b=map(int,input().split())\r\ncount=0\r\nwhile(a!=0 and b!=0 and (a!=1 or b!=1)):\r\n if((a==1 or a==2) and b!=1) :\r\n a+=1;b-=2\r\n elif((b==1 or b==2) and a!=1) :\r\n b+=1;a-=2\r\n else:\r\n a+=1;b-=2\r\n count+=1\r\nprint(count)\r\n", "a,b=map(int,input().split())\nt=0\nif a==b==1:\n print(0)\n exit()\nwhile a>0 and b>0:\n t+=1\n if min(a,b)==a:\n a+=1\n b-=2\n else:\n a-=2\n b+=1\nprint(t)", "a,b=map(int,input().split())\nc=0\nwhile a>0 and b>0:\n if a==1 and b==1:\n break\n c=c+1\n if a>b:\n a,b=b,a\n a=a+1\n b=b-2\nprint(c)\n\n\t\t\t \t\t\t\t \t\t\t\t\t\t \t\t\t\t\t\t \t", "a, b = map(int, input(). split())\r\nz = 0\r\nwhile a>0 and b>0:\r\n if a<b :\r\n a,b=b,a\r\n if a<2:\r\n break\r\n a -= 2\r\n b += 1\r\n z += 1\r\nprint(z)", "def max_game_duration(a1, a2):\r\n return max(a1 + a2 - 3 + ((a2 - a1) % 3 > 0), 0)\r\n\r\n# Ввод данных\r\na1, a2 = map(int, input().split())\r\n\r\n# Вывод результата\r\nprint(max_game_duration(a1, a2))\r\n", "a,b = list(map(int, input().split()))\r\nans = 0\r\n\r\nwhile a>0 and b>0:\r\n if a==1 and b==1:\r\n break\r\n \r\n if a>b:\r\n a-=2\r\n b+=1\r\n else:\r\n b-=2\r\n a+=1\r\n \r\n ans+=1\r\n\r\nprint(ans)\r\n ", "x,y = map(int,input().split())\r\nprint(max(x+y-3+((y-x)%3>0),0))", "a,b=map(int,input().split())\r\nc=0\r\nif a==b:\r\n if a+b-3<0:\r\n print(0)\r\n else:\r\n print(a+b-3)\r\nelse:\r\n for i in range(200):\r\n if a>b:\r\n b,a=a,b\r\n a+=1\r\n b-=2\r\n c+=1\r\n if a==0 or b==0:\r\n break\r\n print(c)", "x,y=map(int,input().split())\nz=0\nwhile(x>0 and y>0):\n if x==1 and y==1:\n break\n if x>y:\n x,y=y,x\n x+=1\n y-=2\n else:\n x,y=y,x\n y+=1\n x-=2\n z+=1\nprint(z)\n\t\t \t\t \t \t \t\t\t \t\t\t \t\t", "a, b = map(int, input().split())\r\nd = {}\r\n\r\n\r\ndef calc(a, b):\r\n if a <= 1 and b <= 1:\r\n return 0\r\n if a <= 0 or b <= 0:\r\n return 0\r\n\r\n if (a, b) in d:\r\n return d[(a, b)]\r\n\r\n d[(a, b)] = max(calc(a - 2, b + 1) + 1, calc(a + 1, b - 2) + 1)\r\n return d[(a, b)]\r\n\r\n\r\nprint(calc(a, b))", "a1, a2 = map(int, input().split())\r\n\r\ni = 0\r\n\r\nwhile a1 * a2 > 0 and a1 + a2 > 2:\r\n if a1 > a2:\r\n a1, a2 = a1 - 2, a2 + 1\r\n else:\r\n a1, a2 = a1 + 1, a2 - 2\r\n \r\n i += 1\r\n \r\nprint(i)", "\r\na = list(map(int, input().split()))\r\n\r\nn = max(a[0], a[1])\r\nm = min(a[0], a[1])\r\n\r\nt = 0\r\n\r\nwhile True:\r\n\r\n\tn -= 2\r\n\tm += 1\r\n\r\n\tif n == 0 or m == 0:\r\n\r\n\t\tt += 1\r\n\r\n\t\tbreak\r\n\r\n\telif n < 0 or m < 0:\r\n\r\n\t\tbreak\r\n\r\n\telse:\r\n\r\n\t\tt += 1\r\n\r\n\tif n <= 2:\r\n\r\n\t\tx = n\r\n\t\tn = m\r\n\t\tm = x\r\n\r\n\r\nprint(t)", "def charge(m,x,y):\r\n if x<=0 or y<=0 or (x<=1 and y<=1):\r\n return 0\r\n\r\n if m[x][y] != 0:\r\n return m[x][y]\r\n left = charge(m, x+1, y-2)\r\n right = charge(m, x-2, y+1)\r\n if(right>left):\r\n left = right\r\n m[x][y] = left + 1\r\n return m[x][y]\r\n\r\na1,a2 = map(int, input().split())\r\nm = []\r\nlimit = 151\r\n\r\nfor i in range(limit):\r\n l = [0]*limit\r\n m.append(l)\r\n\r\nprint(charge(m,a1,a2))", "n,m=map(int,input().split())\r\nans=0\r\nwhile True:\r\n if n<=0 or m<=0:\r\n break\r\n if n<=m:\r\n n+=1\r\n m-=2\r\n if n < 0 or m < 0:\r\n break\r\n ans+=1\r\n else:\r\n n-=2\r\n m+=1\r\n if n < 0 or m < 0:\r\n break\r\n ans+=1\r\nprint(ans)", "\nX = sorted(list(map(int,input().split())))\nc = 0\nwhile X[0] >= 1 and X[1] > 1 :\n\tX[1] -=2\n\tX[0] +=1\n\tX.sort()\n\tc+=1\nprint(c)\n\n\n\n", "n,m=map(int,input().split())\r\nc=0\r\nwhile max(n,m)>2:\r\n if min(m,n)==m:\r\n m=m+1\r\n n=n-2\r\n c=c+1\r\n else:\r\n m=m-2\r\n n=n+1\r\n c=c+1\r\nif (n==2 or m==2) and (n!=0 or m!=0):\r\n c=c+1\r\nprint(c)", "n,m=map(int,input().split())\r\nc=0\r\nif(n==0 and m==0 or n==1 and m==1):\r\n print(0)\r\n exit(0)\r\nwhile True:\r\n if(n<=0 or m<=0):\r\n break\r\n if(m>n):\r\n m-=2\r\n n+=1\r\n c+=1\r\n else:\r\n m+=1\r\n n-=2\r\n c+=1\r\nprint(c)", "from sys import stdin, stdout\r\ninput, print = stdin.readline, stdout.write\r\n\r\n\r\ndef main():\r\n a, b = map(int, input().split())\r\n ans = 0\r\n while a > 0 and b > 0:\r\n ans += 1\r\n if a > b:\r\n a, b = b, a\r\n a += 1\r\n b -= 2\r\n if b < 0:\r\n ans -= 1\r\n print(str(ans)+\"\\n\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "a,b=map(int,input().split())\r\ncntr=0\r\nwhile a>0 and b>0:\r\n if a>b:\r\n a-=2\r\n b+=1\r\n elif b>a:\r\n a+=1\r\n b-=2\r\n elif a==b:\r\n if a==1 and b==1:\r\n break\r\n else:\r\n a+=1\r\n b-=2\r\n cntr+=1\r\nprint(cntr)", "# author: ankan2526\r\n\r\nimport math, bisect, heapq, random, sys, itertools\r\ninput=sys.stdin.readline\r\nints = lambda : list(map(int,input().split()))\r\n\r\np = 10**9+7\r\n\r\na,b=sorted(ints())\r\nans=0\r\nwhile a>0:\r\n a+=1\r\n b-=2\r\n a,b=sorted([a,b])\r\n ans+=1\r\nif a<0:\r\n ans-=1\r\nprint(ans)", "a1,a2=map(int,input().split())\ncount=0\nwhile a1>0 and a2>0:\n if a1==1 and a2==1:\n break\n count+=1\n if a1>a2:\n a1,a2=a2,a1\n a1+=1\n a2-=2\nprint(count)\n \t\t \t\t \t \t\t \t \t\t \t \t \t", "a,b=sorted(map(int,input().split()))\r\nr=0\r\nwhile a>0 and 2<b:\r\n while b>2:r+=1;b-=2;a+=1\r\n a,b=b,a\r\nprint(r+(b>1 and a!=0))", "first, second= map(int, input().split())\r\n\r\n\r\ncount = 0\r\n\r\nwhile first>0 and second>1 or second>0 and first>1:\r\n\tif first < second:\r\n\t\tfirst+=1\r\n\t\tsecond-=2\r\n\telse:\r\n\t\tfirst-=2\r\n\t\tsecond+=1\r\n\tcount+=1\r\nprint(count)\r\n\r\n\r\n\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\na, b = map(int, input().split())\r\nif (b-a) % 3 == 0:\r\n print(max(b+a-3,0))\r\nelse:\r\n print(max(b+a-2,0))", "\r\n\r\ndef main():\r\n\r\n\r\n\ta,b=map(int,input().split(\" \"))\r\n\tmins=0\r\n\r\n\r\n\twhile a>0 and b>0:\r\n\t\tif a>=b:\r\n\t\t\tb+=1\r\n\t\t\ta-=2\r\n\t\telse:\r\n\t\t\ta+=1\r\n\t\t\tb-=2\r\n\t\tif a<0 or b<0:\r\n\t\t\tbreak\r\n\t\tmins+=1\r\n\r\n\tprint(mins)\r\n\t\t\r\n\r\n\r\n\t\t\r\n\r\nif __name__==\"__main__\":\r\n\tmain()", "a,b = map(int,input().split())\r\n\r\ncnt=0\r\n#res=[a,b]\r\nwhile a>0 and b>0:\r\n if a<b:\r\n if b==1:\r\n a,b=0,0\r\n continue\r\n \r\n elif b==2:\r\n cnt+=1\r\n a+=1\r\n b=0\r\n continue\r\n \r\n elif b%2==0 and b>2:\r\n cnt+=(b//2-1)\r\n a+=(b//2-1)\r\n b=2\r\n continue\r\n \r\n elif b%2==1:\r\n cnt += b//2\r\n a+=b//2\r\n b=1\r\n continue\r\n \r\n else:\r\n if a==1:\r\n a,b=0,0\r\n continue\r\n \r\n elif a==2:\r\n cnt+=1\r\n b+=1\r\n a=0\r\n continue\r\n \r\n elif a%2==0 and a>2:\r\n cnt+=(a//2-1)\r\n b+=(a//2-1)\r\n a=2\r\n continue\r\n \r\n elif a%2==1:\r\n cnt += a//2\r\n b+=a//2\r\n a=1\r\n continue\r\n \r\nprint(cnt)", "n1,n2=map(int,input().split())\ncount=0\nif(n1==n2==1):\n print(0)\nelse:\n while(n1>0 and n2>0):\n if(n2>=n1):\n n2-=2\n count+=1\n n1+=1\n else:\n n1-=2\n count+=1\n n2+=1\n\n print(count)\n", "a1, a2 = list(map(int, input().split()))\r\n\r\nmins = 0\r\nwhile a1 + a2 >= 3 and min((a1, a2))>=1:\r\n #print(a1, a2)\r\n mins += 1\r\n if a1 < a2:\r\n a1 += 1\r\n a2 -= 2\r\n else:\r\n a2 += 1\r\n a1 -= 2\r\n \r\nprint(mins)", "a,b=map(int,input().split())\r\nminu=0\r\nwhile max(a,b)>1 and min(a,b)>0:\r\n if a>b:a-=2;b+=1\r\n else:b-=2;a+=1\r\n minu+=1\r\nprint(minu)", "a1, a2 = list(map(int, input().split()))\r\nif a1 == 1 and a2 == 1:\r\n print(0)\r\nelse:\r\n i = 0\r\n while a1 > 1 or a2 > 1:\r\n i += 1\r\n #print(a1, a2)\r\n if min(a1, a2) == a1:\r\n a1 += 1\r\n a2 -= 2\r\n else:\r\n a2 += 1\r\n a1 -= 2\r\n print(i-1)\r\n", "a,b = map(int,input().split())\r\nc = 0\r\nwhile (a >= 2 or b >= 2) and a>0 and b>0:\r\n a,b = min(a,b),max(a,b)\r\n a+=1\r\n b-=2\r\n c+=1\r\nprint(c)", "from collections import deque, defaultdict, Counter\r\nfrom itertools import product, groupby, permutations, combinations, accumulate, zip_longest, \\\r\n combinations_with_replacement\r\nfrom math import gcd, floor, inf, log2, sqrt, log10, factorial\r\nfrom bisect import bisect_right, bisect_left\r\nfrom statistics import mode\r\nfrom string import ascii_lowercase, ascii_uppercase\r\nfrom heapq import heapify, heappop, heappush, heappushpop, heapreplace, nlargest, nsmallest, \\\r\n merge\r\nfrom copy import deepcopy\r\n\r\na, b = map(int, input().split())\r\n\r\ncount = 0\r\n\r\nwhile True:\r\n if max(a, b) < 2 or min(a,b) == 0:\r\n break\r\n else:\r\n count += 1\r\n if a >= b:\r\n a -=2\r\n b += 1\r\n else:\r\n b -= 2\r\n a += 1\r\n\r\n\r\nprint(count)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "a, b = map(int, input().split())\n\ndef calc(a, b):\n if a > b:\n a, b = b, a\n if a == 0 or b == 1:\n return 0\n if b == 2:\n return 1\n k = (b-1)//2\n return k + calc(a+k, b-2*k)\n\nans = calc(a, b)\nprint(ans)\n", "m1,m2=map(int,input().split())\ncount=0\nwhile m1>0 and m2>0:\n if m1==1 and m2==1:\n break\n count+=1\n if m1>m2:\n m1,m2=m2,m1\n m1+=1\n m2-=2\nprint(count)\n\t\t\t\t\t \t \t \t \t \t \t \t \t \t\t \t\t", "import time\n\nvals = [*map(int, input().split())]\nvals.sort()\n\na = vals[0]\nb = vals[1]\n\ntimes = 0\nwhile True:\n if a == b == 1: break\n\n a += 1\n b -= 2\n\n if a == 0 or b == 0:\n times += 1\n break\n if a < 0 or b < 0: break\n\n times += 1\n \n if b <= 2: a, b = b, a\n \nprint(times)\n", "a,b=map(int,input().split())\nc=0\nwhile(a>0 and b>0):\n\tif(a==1 and b==1):\n\t\tbreak\n\tif(a>b):\n\t\ta-=2\n\t\tb+=1\n\t\tc+=1\n\telse:\n\t\ta+=1\n\t\tb-=2\n\t\tc+=1\nprint(c)\n \t\t\t\t \t \t \t\t\t \t \t \t\t", "x,y = map(int,input().split())\nc = 0\nwhile x>0 and y>0:\n if x < y:\n x+=1\n y-=2\n else:\n x -=2\n y +=1\n if x <0 or y<0 :\n # c-=1\n break\n c+=1\nprint(c)", "a,b = map(int,input().split())\r\nt = 0\r\nwhile a and b:\r\n if a == b == 1:\r\n break\r\n if a < b:\r\n a += 1\r\n b -= 2\r\n else:\r\n a -= 2\r\n b += 1\r\n t += 1\r\nprint(t)", "a, b = map(int, input().split())\n\nc = 0\n\nwhile (a >= 1 and b > 1) or (a > 1 and b >= 1):\n if a == b:\n a += 1\n b -= 2\n c += 1\n\n elif a > b:\n b += 1\n a -= 2\n c += 1\n\n elif a<b:\n a += 1\n b -= 2\n c += 1\n\nprint(c)\n \t \t \t \t\t\t \t\t \t \t\t", "x, y = map(int,input().split())\r\nt = 0\r\n\r\nwhile x*y>0 and (x > 1 or y > 1):\r\n if x > y:\r\n y += 1\r\n x -= 2\r\n t += 1\r\n elif x <= y:\r\n x += 1\r\n y -= 2\r\n t += 1\r\nprint(t)", "inputting = list(map(int, input().split()))\r\nx = inputting[0]\r\ny = inputting[1]\r\ncounter = 0\r\nwhile x > 0 and y > 0:\r\n if x > y:\r\n y += 1\r\n x -= 2\r\n elif x == 1 and y == 1 and counter == 0:\r\n print(0)\r\n exit()\r\n else:\r\n y -= 2\r\n x += 1\r\n counter += 1\r\nprint(counter)\r\n", "a,b=map(int,input().split());c=abs(a-b)\r\nprint([c//3+(min(a,b)+c//3-1)*2+c%3-(c%3==0),0][max(a,b)<2])\r\n", "arr=[int(i) for i in input().split()]\r\na =arr[0]\r\nb=arr[1]\r\ncount=0\r\nif a<=1 and b<=1:\r\n\tcount=0\r\nelse:\r\n\twhile (a > 0 and b > 0):\r\n\r\n\t\tif a <= b:\r\n\t\t\ta = a + 1\r\n\t\t\tb = b - 2\r\n\t\telse:\r\n\t\t\ta = a - 2\r\n\t\t\tb = b + 1\r\n\r\n\t\tcount = count + 1\r\n\r\nprint(count)\r\n", "x,y=map(int,input().split())\r\nm=0\r\nif x==1 and y==1:\r\n print(0)\r\nelse: \r\n while x!=0 and y!=0:\r\n if x<y:\r\n x+=1\r\n y-=2\r\n m+=1\r\n else:\r\n y+=1\r\n x-=2\r\n m+=1\r\n print(m) ", "a,b = tuple(int(x) for x in input().split())\r\nminute = 0\r\nif a>=2 or b>=2:\r\n while a > 0 and b> 0:\r\n if a > b:\r\n a -= 2\r\n b += 1\r\n else:\r\n b -= 2\r\n a += 1\r\n minute += 1\r\n print(minute)\r\nelse:\r\n print(0)", "a,b=sorted(list(map(int,input().split())))\r\ni=0\r\nwhile(a!=0 and b!=0):\r\n\tif(a<b):\r\n\t\tif(b>=2):\r\n\t\t\ta+=1\r\n\t\t\tb-=2\r\n\r\n\t\telif(b==1):\r\n\t\t\tb=0\r\n\t\t\tcontinue\r\n\t\telse:\r\n\t\t\tb=0\r\n\t\t\ta+=1\r\n\telse:\r\n\t\tif(a>=2):\r\n\t\t\tb+=1 \r\n\t\t\ta-=2\r\n\t\telif(a==1):\r\n\t\t\ta=0\r\n\t\t\tcontinue\r\n\t\telse:\r\n\t\t\ta=0\r\n\t\t\tb+=1\r\n\ti+=1\r\nprint(i)\r\n\r\n", "a1,a2 = map(int,input().split())\r\n\r\nmn = min(a1,a2)\r\nmx = max(a1,a2)\r\ntime = 0\r\nif a1 == 1 and a2 == 1 :\r\n print(0)\r\nelse :\r\n while mn > 0 and mx > 0 :\r\n time += 1\r\n mn += 1\r\n mx -= 2\r\n x = min(mn,mx)\r\n y = max(mn,mx)\r\n mn = x\r\n mx = y\r\n print(time)\r\n", "a, b = list(map(int,input().split()))\r\ncount = 0\r\nwhile a > 0 and b > 0 :\r\n count += 1\r\n if a > b:\r\n a,b = b,a\r\n a += 1\r\n b -= 2\r\n if a < 0 or b < 0:\r\n count -= 1\r\n break\r\nprint(count)", "a=[[-3,-1,0],[-1,-1,1],[0,1,1]]\r\nt=[int(i) for i in input().split()]\r\nif (t[0]*t[1]==1):\r\n\tprint(0)\r\nelse:\r\n\tprint(t[0]//3*3+t[1]//3*3+a[t[0]%3][t[1]%3])", "a,b=list(map(int,input().split()))\r\ns=0\r\nwhile a!=0 and b!=0:\r\n if (a==1 and b<=1) or (a<=1 and b==1):\r\n break\r\n else: \r\n if (a>=b):\r\n b+=1\r\n a-=2\r\n s+=1\r\n else:\r\n a+=1\r\n b-=2\r\n s+=1 \r\nprint(s)", "m1,m2 = list(map(int,input().split()))\r\nminutes=0\r\nwhile min(m1,m2)>=1 and max(m1,m2)>=2:\r\n if m1>m2:\r\n m1-=2\r\n m2+=1\r\n else:\r\n m2-=2\r\n m1+=1\r\n minutes+=1\r\nprint(minutes)", "p,q=map(int,input().split())\nc=0\nwhile(p>0 and q>0):\n if p==1 and q==1:\n break\n if p>q:\n p,q=q,p\n p+=1\n q-=2\n else:\n p,q=q,p\n q+=1\n p-=2\n c+=1\nprint(c)\n\n\n\t\t \t \t\t \t \t\t\t\t\t\t\t \t\t \t\t\t\t", "a, b = map(int, input().split())\r\nprint(max(a + b - 2 - ((b - a) % 3 is 0), 0))\r\n", "a1,a2=map(int,input().split())\r\nif a1==1 and a2==1:\r\n\tprint(0)\r\nelif (a1-a2)%3==0:\r\n\tprint(a1+a2-3)\r\nelse:\r\n\tprint(a1+a2-2)\r\n\t\r\n", "# @author Matheus Alves dos Santos\n\ndef charge_discharge(x, y):\n return x + 1, y - 2\n\np1, p2 = map(int, input().split())\nminutes = 0\n\nwhile ((p1 > 0) and (p2 > 0) and not ((p1 == 1) and (p2 == 1))):\n minutes += 1\n\n if (p1 == 1):\n p1, p2 = charge_discharge(p1, p2) \n elif (p2 == 1):\n p2, p1 = charge_discharge(p2, p1)\n elif (p1 < p2):\n p1, p2 = charge_discharge(p1, p2)\n else:\n p2, p1 = charge_discharge(p2, p1)\n \nprint(minutes)\n", "a,b= map(int,input().split())\r\nc=0\r\nwhile (a>0 and b>0) and ((a,b)!=(1,1)):\r\n if a<b:a+=1;b-=2\r\n else:a-=2;b+=1\r\n c+=1\r\n\r\nprint(c)\r\n", "import sys\ncharges = []\ncharges_line = sys.stdin.readline().split()\nfor charge in charges_line:\n charges.append(int(charge))\n\ndef max_minutes(x, y):\n if (x == 0 or y == 0):\n return 0\n if (x == 1 and y == 1):\n return 0\n if (x >= y):\n return 1 + max_minutes(x - 2, y + 1)\n return 1 + max_minutes(x + 1, y - 2)\n\nsys.stdout.write(str(max_minutes(charges[0], charges[1])) + \"\\n\")\n\t\t\t\t \t \t\t\t\t\t\t\t\t\t \t\t\t\t \t\t", "a1,a2=map(int,input().split())\r\nx=abs(a1-a2)\r\ns=a1+a2\r\nif s<3:\r\n print(0)\r\n\r\nelif x%3==0:\r\n print(s-3)\r\nelse:\r\n print(s-2)\r\n\r\n \r\n \r\n\r\n \r\n \r\n \r\n\r\n\r\n", "def solve(x, y):\r\n if x == 1 and y == 1:\r\n return 0\r\n c = 0\r\n while (x > 0 and y > 0):\r\n if y > x:\r\n x += 1\r\n y -= 2\r\n else:\r\n y += 1\r\n x -= 2\r\n c += 1\r\n return c\r\n\r\n\r\nx, y = map(int, input().split())\r\nprint(solve(x, y))\r\n", "a, b = map(int, input(). split())\nc= 0\nwhile a>0 and b>0:\n if a<b : a,b=b,a\n if a<2: break\n a -= 2\n b += 1\n c += 1\nprint(c)\n\t \t \t \t\t\t \t \t\t\t\t\t\t \t", "import sys\r\ninput=sys.stdin.readline\r\n\r\nn,m = map(int,input().split())\r\nans = 0\r\nwhile n>0 and m>0:\r\n if(n<m):\r\n n+=1\r\n m-=2\r\n else:\r\n m+=1\r\n n-=2\r\n if n>=0 and m>=0: ans+=1\r\nprint(ans)", "a,b = map(int,input().split())\r\n\r\ncn=0\r\n\r\nwhile(a>0 and b>0):\r\n a,b = min(a,b)+1,max(a,b)-2\r\n if(a<0 or b<0):\r\n cn = cn\r\n else:\r\n cn+=1\r\n \r\nprint(cn)", "n,m = map(int,input().split())\r\nprint(max((n+m)-3+((m-n)%3>0),0))", "a,b=map(int,input().split())\r\nc=0\r\nwhile(1):\r\n if a<=0 or b<=0:\r\n break\r\n if (a == 1 and b == 1) or (a==0 and b==1) or (a==1 and b==0):\r\n break\r\n if a<=b:\r\n a+=1\r\n b-=2\r\n c+=1\r\n else:\r\n b+=1\r\n a-=2\r\n c+=1\r\nprint(c)", "a,b=map(int,input().split())\nc=0\nwhile((a>1 and b>=1) or (a>=1 and b>1)):\n if(a<b):\n a=a+1\n b=b-2\n c=c+1\n else:\n a=a-2\n b=b+1\n c=c+1\nprint(c)", "def joystick(a,b):\r\n if a==0 or b==0:\r\n return 0\r\n if a==1:\r\n if b==1:\r\n return 0\r\n else:\r\n return 1+joystick(a+1,b-2)\r\n if b==1:\r\n if a==1:\r\n return 0\r\n else :\r\n return 1+joystick(a-2,b+1)\r\n else :\r\n if a<=b:\r\n return 1+joystick(a+1,b-2)\r\n if a>b:\r\n return 1+joystick(a-2,b+1)\r\n\r\na,b=map(int,input().split(\" \"))\r\nprint(joystick(a,b))\r\n", "a,b = map(int,input().split())\r\nz =0\r\nwhile min(a,b)>0 and max(a,b)>1:\r\n\tif a>=b:a-=2;b+=1\r\n\telse:b-=2;a+=1\r\n\tz+=1\r\nprint(z)", "\r\n\r\ndef to_be_charged(a1, a2):\r\n t=1\r\n while t>0:\r\n if (a1==0 or a2==0) or (a1==1 and a2==1):\r\n break\r\n elif a1 <= a2:\r\n a1+=1\r\n a2-=2\r\n t+=1\r\n else:\r\n a2+=1\r\n a1-=2\r\n t+=1\r\n return t-1\r\n\r\n[a1, a2] = [int(a) for a in input().split(\" \")]\r\nprint(to_be_charged(a1, a2))\r\n\r\n\r\n\r\n \r\n\r\n \r\n \r\n\r\n", "a1,a2 = list(map(int,input().split()))\r\ncnt = 0 \r\nwhile a1 > 0 and a2> 0:\r\n if a1 == 1 and a2 == 1:\r\n break \r\n if a1 > a2:\r\n a1-=2 \r\n a2+=1 \r\n else:\r\n a1+=1 \r\n a2-=2 \r\n cnt+=1 \r\nprint(cnt)\r\n ", "a, b = map(int, input().split())\r\nprint(max(a + b - 3 + bool((b - a) % 3), 0))\r\n", "n,m=map(int,input().split())\nc=0\nwhile(n>0 and m>0 and (n,m)!=(1,1)):\n if n>m:\n m+=1\n n-=2\n else:\n m-=2\n n+=1\n c+=1\nprint(c)\n\n \t\t \t \t\t\t \t\t \t\t\t\t \t \t", "a1,a2= [int(x)for x in input().split()]\r\ncounter = 0\r\nwhile a1 > 0 and a2 > 0:\r\n\ta1,a2 = min(a1,a2)+1,max(a1,a2)-2\r\n\tcounter+=1\r\nprint(counter-int(a1<0 or a2 < 0))", "a1,a2=[int(i) for i in input().split()]\r\ncnt=0\r\nwhile a1>0 and a2>0:\r\n if a1<=a2:\r\n a1+=1\r\n a2-=2\r\n else :\r\n a2+=1\r\n a1-=2\r\n cnt+=1\r\nprint(cnt+min(a1,a2))", "a1,a2=map(int,input().split())\nc=0\nwhile(a1>0 and a2>0):\n if a1==1 and a2==1:\n break\n if a1>a2:\n a1,a2=a2,a1\n a1=a1+1\n a2=a2-2\n else:\n a1,a2=a2,a1\n a2=a2+1\n a1=a1-2\n c=c+1\nprint(c)\n\n\t \t \t \t \t\t \t\t\t\t \t \t \t\t \t", "a1,a2=[int(x) for x in input().split()]\r\ncount=0\r\nwhile(a1!=0 and a2!=0 and (a1!=1 or a2!=1)):\r\n if a1<a2:\r\n a1+=1\r\n a2-=2\r\n else:\r\n a1-=2\r\n a2+=1\r\n count+=1\r\nprint(count)", "def main():\n a1, a2 = map(int, input().split())\n chargers2max_play_time = {}\n print(get_max_play_time(a1, a2, chargers2max_play_time))\n\n\ndef get_max_play_time(a1, a2, chargers2max_play_time):\n if a1 < a2:\n return get_max_play_time(a2, a1, chargers2max_play_time)\n elif str(a1) + ' ' + str(a2) in chargers2max_play_time: # base case\n return chargers2max_play_time[str(a1) + ' ' + str(a2)]\n elif a1 == 0 or a2 == 0: # stop case\n return 0\n else:\n # charge left, if possible\n if a2 > 1:\n max_lvl_left = get_max_play_time(a1 + 1, a2 - 2, chargers2max_play_time) + 1\n else:\n max_lvl_left = 0\n\n # charge right, if possible\n if a1 > 1:\n max_lvl_right = get_max_play_time(a1 - 2, a2 + 1, chargers2max_play_time) + 1\n else:\n max_lvl_right = 0\n\n max_lvl = max(max_lvl_left, max_lvl_right)\n key = str(a1) + ' ' + str(a2)\n chargers2max_play_time[key] = max_lvl\n return max_lvl\n\n\nif __name__ == '__main__':\n main()\n", "import math\r\n\r\ndef solve():\r\n charge1,charge2=[int(x) for x in input().split()]\r\n time=0\r\n while(max(charge1,charge2)>=2 and min(charge1,charge2)!=0):\r\n #print(charge1,charge2)\r\n time+=1\r\n if charge1<=charge2:\r\n charge1+=1\r\n charge2-=2\r\n else:\r\n charge2+=1\r\n charge1-=2\r\n return time\r\n \r\n \r\nif __name__==\"__main__\":\r\n print(solve())\r\n ", "m, n = map(int, input().split())\nctr = 0\nif(m == 1 and n == 1):\n\tm = 0\n\tn = 0\n\t# print(0)\nwhile(m >= 1 and n >= 1):\n\t# print(m, n)\n\tif(m > n):\n\t\tm-=2\n\t\tn+=1\n\telse:\n\t\tm+=1\n\t\tn-=2\n\tctr+=1\nprint(ctr)\n\n", "a,b=map(int,input().split())\r\nc=0\r\n\r\nif a<2 and b<2:\r\n print(0)\r\nelif a<=2 and b<=2:\r\n print(1)\r\nelse:\r\n if a<=2 and b>2:\r\n while a>2 or b>2:\r\n if a>=b:\r\n a=a-2\r\n b=b+1\r\n c=c+1\r\n elif b>a:\r\n b=b-2\r\n a=a+1\r\n c=c+1\r\n elif b<=2 and a>2:\r\n while a>2 or b>2:\r\n if a>=b:\r\n a=a-2\r\n b=b+1\r\n c=c+1\r\n elif b>a:\r\n b=b-2\r\n a=a+1\r\n c=c+1\r\n elif a>2 and b>2:\r\n while a>2 or b>2:\r\n if a>=b:\r\n a=a-2\r\n b=b+1\r\n c=c+1\r\n #print(a,b)\r\n elif b>a:\r\n b=b-2\r\n a=a+1\r\n c=c+1\r\n #print(a,b) \r\n print(c+1)", "n,m=map(int,input().split())\r\ns=0\r\nif n==1 and m==1:\r\n print(0)\r\n exit()\r\nwhile n>0 and m>0:\r\n if m>=n:\r\n m-=2\r\n n+=1\r\n elif m<n:\r\n m+=1\r\n n-=2\r\n s+=1\r\nprint(s)", "a, b = map(int, input().split())\r\nres = 0\r\nwhile True:\r\n while a > 2: a, b, res = a - 2, b + 1, res + 1\r\n while b > 2: a, b, res = a + 1, b - 2, res + 1\r\n if a <= 2 and b <= 2: break\r\nprint(res) if a < 2 and b < 2 else print(res + 1)", "def solve(p,q):\r\n ans=0\r\n while p>0 and q>0:\r\n ans+=1\r\n if p>q:\r\n p,q=q,p\r\n p+=1\r\n q-=2\r\n if p<0 or q<0:\r\n ans-=1\r\n break\r\n return ans\r\n\r\n\r\np,q=map(int,input().split())\r\nprint(solve(p,q))\r\n", "def solve(a1, a2):\r\n if a1 == 1 and a2 == 1:\r\n return 0\r\n ans = 0\r\n while a1 > 0 and a2 > 0:\r\n ans += 1\r\n if a1 <= a2:\r\n a1 += 1\r\n a2 -= 2\r\n else:\r\n a1 -= 2\r\n a2 += 1\r\n return ans\r\n\r\na1, a2 = [int(s) for s in input().split()]\r\nprint(solve(a1, a2))\r\n", "\"\"\"\r\nhttps://codeforces.com/problemset/problem/651/A\r\n\"\"\"\r\n\r\na = [int(x) for x in input().split(\" \")]\r\n\r\nminutes = 0\r\n\r\nwhile a[0] > 0 and a[1] > 0:\r\n if a[0] > a[1]:\r\n a[1] += 1\r\n a[0] -= 2\r\n else:\r\n a[0] += 1\r\n a[1] -= 2\r\n\r\n minutes += 1\r\n\r\nif a[0] < 0 or a[1] < 0:\r\n print(minutes-1)\r\nelse:\r\n print(minutes)", "a,b=map(int,input().split())\r\nm=0\r\nif a==1 and b==1:\r\n print(\"0\")\r\nelse:\r\n while a>0 and b>0:\r\n if a==b:\r\n a+=1\r\n b-=2\r\n m+=1\r\n elif a==1:\r\n a+=1\r\n b-=2\r\n m+=1\r\n elif b==1:\r\n b+=1\r\n a-=2\r\n m+=1\r\n elif a>b:\r\n b+=1\r\n a-=2\r\n m+=1\r\n else:\r\n a+=1\r\n b-=2\r\n m+=1\r\n print(m)", "def solve():\r\n a1,a2=map(int,input().strip().split())\r\n c=0\r\n if a1==1 and a2==1:\r\n print(0)\r\n else:\r\n while a1>0 and a2>0:\r\n a1,a2=max(a1,a2)-2,min(a1,a2)+1\r\n c+=1\r\n #print(a1,a2)\r\n #print(c)\r\n print(c)\r\n \r\nif __name__==\"__main__\":\r\n solve()\r\n", "a1,a2=[int(x) for x in input().split()]\r\nk=0\r\nflag=0\r\nif a1==a2==1:\r\n\tflag=1\r\nelse:\r\n\twhile a1>0 and a2>0:\r\n\t\tif a1>=a2:\r\n\t\t\ta2+=1\r\n\t\t\ta1-=2\r\n\t\telse:\r\n\t\t\ta2-=2\r\n\t\t\ta1+=1\r\n\t\tk+=1\r\nif flag==1:\r\n\tprint(0)\r\nelse:\r\n\tprint(k)", "\"A.Joysticks\"\r\nal=input().split()\r\nm = list(map(int, al))\r\na=m[0]\r\nb=m[1]\r\nc=0\r\nwhile (a>0) and (b>0):\r\n c+=1\r\n if a>b:\r\n a=a-2\r\n b=b+1\r\n else:\r\n a=a+1\r\n b=b-2\r\n if a<0 or b<0:\r\n c=c-1 \r\nprint(c)\r\n", "n1,n2=map(int, input().split())\nc=0\nwhile(n1>0 and n2>0):\n if n1==1 and n2==1:\n break\n c+=1\n if n1>n2:\n n1,n2=n2,n1\n n1+=1\n n2-=2\nprint(c)\n\t\t\t \t \t \t\t\t \t \t \t\t\t\t \t\t\t", "t=0\r\na1,a2=(map(int,input().split()))\r\nwhile a1>0 and a2>0:\r\n\tif a1<=a2:\r\n\t\ta1+=1\r\n\t\ta2-=2\r\n\telse:\r\n\t\ta1-=2\r\n\t\ta2+=1\r\n\t\r\n\tif a1<0 or a2<0:\r\n\t\tbreak\r\n\telse:\r\n\t\tt+=1\r\n\r\nprint(t)\r\n\t\r\n\t", "n1,m1=map(int,input().split())\nc1=0\nwhile(n1>0 and m1>0):\n if n1==1 and m1==1:\n break\n if n1>m1:\n n1,m1=m1,n1\n n1+=1\n m1-=2\n else:\n n1,m1=m1,n1\n m1+=1\n n1-=2\n c1+=1\nprint(c1)\n\t\t \t \t\t\t\t\t \t\t\t\t \t\t\t \t \t", "from time import sleep\r\n\r\n\r\ndef main():\r\n a, b = list(map(int, input().split()))\r\n\r\n counter = 0\r\n while a > 1 or b > 1:\r\n a, b = max(a, b), min(a, b)\r\n if a % 2 == 0:\r\n factor = a - 2\r\n a = 2\r\n else:\r\n factor = a - 1\r\n a = 1\r\n \r\n if factor > 0:\r\n counter += factor // 2\r\n b += factor // 2\r\n elif factor == 0:\r\n counter += 1 \r\n break\r\n\r\n print(counter)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "a1,a2=map(int,input().split())\r\nif(abs(a1-a2)%3):print(max(a1+a2-2,0))\r\nelse:print(max(a1+a2-3,0))", "n,m=map(int,input().split())\r\nc=0\r\nwhile max(n,m)>2:\r\n if min(m,n)==m:m,n,c=m+1,n-2,c+1\r\n else:m,n,c=m-2,n+1,c+1\r\nif (n==2 or m==2) and (n!=0 or m!=0):c=c+1\r\nprint(c)", "import math\r\nimport sys\r\n#from collections import deque, Counter, OrderedDict, defaultdict\r\n#import heapq\r\n#ceil,floor,log,sqrt,factorial,pow,pi,gcd\r\n#import bisect\r\n#from bisect import bisect_left,bisect_right\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\nl=inlt()\r\nl.sort()\r\na,b=l\r\ncnt=0\r\nwhile(max(a,b)>=2):\r\n if max(a,b)==2:\r\n cnt+=1\r\n break\r\n if b>a:\r\n cnt+=(b-1)//2\r\n a+=(b-1)//2\r\n b=1 if b%2 else 2\r\n else:\r\n cnt+=(a-1)//2\r\n b+=(a-1)//2\r\n a=1 if a%2 else 2\r\nprint(cnt)", "# cf 651 A 1100\na1, a2 = map(int, input().split())\n# charges 1%\n# discharges 2%\nmin_ = 0\nwhile a1 > 0 and a2 > 0:\n if a2 > 2:\n n = a2 // 2\n if a2 % 2 == 0:\n n -= 1\n min_ += n\n a1 += n\n a2 -= (2 * n)\n elif a1 > 2:\n n = a1 // 2\n if a1 % 2 == 0:\n n -= 1\n min_ += n\n a2 += n\n a1 -= (2 * n)\n else:\n if a1 == 2 or a2 == 2:\n min_ += 1\n a1 -= 2\n a2 -= 2\nprint(min_)\n\n# 3 5\n# 4 3\n# 5 1\n# 3 2\n# 1 3\n# 2 1\n# 0 2\n", "a1,a2=map(int,input().split())\r\ncount=0\r\nsp=0\r\nif a1==1 and a2==1:\r\n sp+=1\r\n print(0)\r\nwhile a1>0 and a2>0:\r\n if a1>1 and a2>1:\r\n if a1<a2:\r\n a1+=1\r\n a2-=2\r\n count+=1\r\n else:\r\n a2+=1\r\n a1-=2\r\n count+=1\r\n else:\r\n t=a1\r\n a1=a2\r\n a2=t\r\n if a1<a2:\r\n a1+=1\r\n a2-=2\r\n count+=1\r\n else:\r\n a2+=1\r\n a1-=2\r\n count+=1\r\nif sp==0:\r\n print(count)", "\r\n\r\na1, a2 = map(int,input().split(' '))\r\ncnt = 0\r\n\r\nwhile(a1 >=1) and (a2 >=1 ):\r\n if (a1 ==1 and a2 == 1):\r\n break\r\n if a1 > a2:\r\n a1 -= 2\r\n a2 += 1\r\n cnt +=1\r\n else:\r\n a2 -= 2\r\n a1 += 1\r\n cnt +=1\r\n \r\nprint(cnt)\r\n", "# cook your dish here\r\na,b=map(int,input().split())\r\na1=a;a2=b;ans=0\r\nwhile(a1*a2>=2):\r\n t1=a1;t2=a2\r\n a1=min(t1,t2)+1\r\n a2=max(t1,t2)-2\r\n # print(t1,t2)\r\n ans+=1\r\nprint(ans) \r\n ", "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", "a,A=map(int,input().split())\nc=0\nwhile(a>0 and A>0):\n if a==1 and A==1:\n break\n if a>A:\n a,A=A,a\n a+=1\n A-=2\n else:\n a,A=A,a\n A+=1\n a-=2\n c+=1\nprint(c)\n \t \t\t\t\t \t \t\t \t \t\t\t \t", "c1,c2=map(int,input().split())\r\nans=0\r\nif(c1<2 and c2<2):\r\n print(0)\r\nelse:\r\n while(c1>0 and c2>0):\r\n if(c1<c2):\r\n c1+=1\r\n c2-=2\r\n else:\r\n c1-=2\r\n c2+=1\r\n ans+=1\r\n print(ans)\r\n \r\n", "#651A\r\na,b=map(int,input().split())\r\nn=0\r\nwhile (a>1 or b>1) and a*b>0:\r\n if a>b:\r\n a-=2\r\n b+=1\r\n n+=1\r\n else:\r\n a+=1\r\n b-=2\r\n n+=1\r\n \r\nprint(n)", "a1, a2 = list(map(int, input().split()))\r\nprint(max(0, a1 + a2 - 2 - (abs(a1 - a2) % 3 == 0)))", "a,b =map(int,input().split())\r\nres=0\r\nif a ==1 and b==1 :\r\n res = 0\r\nelse:\r\n while(a>0 and b>0):\r\n if a>b:\r\n b+=1\r\n a-=2\r\n res+=1\r\n else:\r\n a+=1\r\n b-=2\r\n res+=1\r\nprint(res)\r\n \r\n", "inp=input().split()\r\na=int(inp[0])\r\nb=int(inp[1])\r\nsteps=0\r\nif a==1 and b==1:\r\n print(0)\r\nelse:\r\n while a>0 and b>0:\r\n if a>b:\r\n a=a-2\r\n b=b+1\r\n else:\r\n b=b-2\r\n a=a+1\r\n steps+=1\r\n print(steps)", "b,a=sorted(map(int,input().split()))\r\nc=0\r\nwhile b>0:\r\n if a==b==1:break\r\n b,a=sorted([a-2,b+1])\r\n c+=1\r\nprint(c)", "def counter(a1,a2):\r\n mins=0\r\n while a1!=0 and a2!=0:\r\n if a1==1 and a2<=1:\r\n break\r\n if a2==1 and a1<=1:\r\n break\r\n if a1<a2:\r\n a1+=1\r\n a2-=2\r\n elif a2<a1:\r\n a1-=2\r\n a2+=1\r\n else:\r\n a1+=1\r\n a2-=2\r\n mins+=1\r\n return mins\r\na1,a2=list(map(int,input().split(\" \")))\r\nprint(counter(a1,a2))", "n,m=map(int,input().split())\r\nc=0\r\nwhile(1):\r\n if n<=0 or m<=0:\r\n break\r\n if n==1 and m==1:\r\n break\r\n if n>m:\r\n n,m=m,n\r\n n+=1\r\n m-=2\r\n c+=1\r\nprint(c)", "a1,a2=map(int,input().split())\nif a1<=1 and a2<=1:\n\tprint(0)\n\texit()\nans=0\nwhile a1!=0 and a2!=0:\n\tif a1<a2:\n\t\ta1+=1\n\t\ta2-=2\n\t\tans+=1\n\telse:\n\t\ta2+=1\n\t\ta1-=2\n\t\tans+=1\nprint(ans)\n \t\t\t \t\t \t\t\t \t\t \t\t\t \t \t \t \t \t" ]
{"inputs": ["3 5", "4 4", "100 100", "1 100", "100 1", "1 4", "1 1", "8 8", "7 2", "24 15", "19 30", "15 31", "14 15", "58 33", "15 25", "59 45", "3 73", "48 1", "100 25", "40 49", "85 73", "29 1", "74 25", "24 57", "23 12", "2 99", "98 2", "2 97", "30 54", "32 53", "32 54", "1 2", "2 1", "2 2", "1 3", "3 1", "1 4", "2 3", "3 2"], "outputs": ["6", "5", "197", "98", "98", "2", "0", "13", "7", "36", "47", "44", "27", "89", "38", "102", "74", "47", "122", "86", "155", "28", "97", "78", "33", "99", "97", "97", "81", "82", "84", "1", "1", "1", "2", "2", "2", "3", "3"]}
UNKNOWN
PYTHON3
CODEFORCES
202
e5403e11236a1d22e81c748ae35e1b9f
Soldier and Cards
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. First line contains a single integer *n* (2<=≤<=*n*<=≤<=10), the number of cards. Second line contains integer *k*1 (1<=≤<=*k*1<=≤<=*n*<=-<=1), the number of the first soldier's cards. Then follow *k*1 integers that are the values on the first soldier's cards, from top to bottom of his stack. Third line contains integer *k*2 (*k*1<=+<=*k*2<==<=*n*), the number of the second soldier's cards. Then follow *k*2 integers that are the values on the second soldier's cards, from top to bottom of his stack. All card values are different. 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 <=-<=1. Sample Input 4 2 1 3 2 4 2 3 1 2 2 1 3 Sample Output 6 2-1
[ "from collections import deque\r\nfrom os import path\r\nfrom sys import stdin, stdout\r\n\r\n\r\nfilename = \"../templates/input.txt\"\r\nif path.exists(filename):\r\n stdin = open(filename, 'r')\r\n\r\n\r\ndef input():\r\n return stdin.readline().rstrip()\r\n\r\n\r\ndef print(*args, sep=' ', end='\\n'):\r\n stdout.write(sep.join(map(str, args)))\r\n stdout.write(end)\r\n\r\n\r\ndef solution():\r\n n = int(input())\r\n n, *nums = (int(num) for num in input().split())\r\n a = deque(nums)\r\n m, *nums = (int(num) for num in input().split())\r\n b = deque(nums)\r\n seen1 = set()\r\n seen1.add(tuple(a))\r\n seen2 = set()\r\n seen2.add(tuple(b))\r\n ans = 0\r\n while a and b:\r\n x = a.popleft()\r\n y = b.popleft()\r\n if x > y:\r\n a.append(y)\r\n a.append(x)\r\n else:\r\n b.append(x)\r\n b.append(y)\r\n if tuple(a) in seen1 and tuple(b) in seen2:\r\n print(-1)\r\n return\r\n seen1.add(tuple(a))\r\n seen2.add(tuple(b))\r\n ans += 1\r\n print(ans, end=' ')\r\n print(1 if a else 2)\r\n\r\n\r\n\r\ndef main():\r\n t = 1\r\n while t:\r\n solution()\r\n t -= 1\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "import collections\r\nimport sys\r\nfrom os import path\r\ndef input():\r\n return sys.stdin.readline().strip()\r\n\r\ndef solve(sol1, sol2):\r\n sol1.popleft()\r\n sol2.popleft()\r\n states = {\"s\": 1}\r\n cur = \"s\"\r\n while states[cur] <= 1:\r\n num1 = sol1.popleft()\r\n num2 = sol2.popleft()\r\n if num1 > num2:\r\n sol1.append(num2)\r\n sol1.append(num1)\r\n else:\r\n sol2.append(num1)\r\n sol2.append(num2)\r\n cur = ''.join(map(str, sol1))+','+''.join(map(str, sol2))\r\n states[cur] = states.get(cur, 0)+1\r\n if len(sol1) == 0:\r\n print(f\"{len(states)-1} {2}\")\r\n return\r\n if len(sol2) == 0:\r\n print(f\"{len(states)-1} {1}\")\r\n return\r\n print(-1)\r\n\r\ndef main():\r\n n = int(input())\r\n sol1 = collections.deque(map(int, input().split()))\r\n sol2 = collections.deque(map(int, input().split()))\r\n solve(sol1, sol2)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n if (path.exists('input.txt')):\r\n sys.stdin = open(\"input.txt\", \"r\")\r\n sys.stdout = open(\"output.txt\", \"w\")\r\n main()", "from collections import deque\r\nimport sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))[1:]\r\nb = list(map(int, input().split()))[1:]\r\na, b = deque(a), deque(b)\r\nc = 0\r\ninf = pow(10, 6) + 5\r\nwhile min(len(a), len(b)) and c < inf:\r\n c += 1\r\n u, v = a.popleft(), b.popleft()\r\n if u > v:\r\n a.append(v)\r\n a.append(u)\r\n else:\r\n b.append(u)\r\n b.append(v)\r\nif not len(b):\r\n ans = [c, 1]\r\nelif not len(a):\r\n ans = [c, 2]\r\nelse:\r\n ans = [-1]\r\nsys.stdout.write(\" \".join(map(str, ans)))" ]
{"inputs": ["4\n2 1 3\n2 4 2", "3\n1 2\n2 1 3", "5\n4 5 3 2 4\n1 1", "6\n2 6 5\n4 1 2 3 4", "7\n6 6 5 2 7 4 1\n1 3", "8\n7 2 3 1 5 6 4 8\n1 7", "9\n2 3 6\n7 9 7 8 5 2 1 4", "10\n3 7 10 8\n7 4 6 9 2 5 1 3", "3\n2 2 1\n1 3", "3\n2 3 2\n1 1", "3\n1 3\n2 2 1", "3\n1 1\n2 3 2", "3\n1 2\n2 3 1", "3\n2 3 1\n1 2", "3\n1 3\n2 1 2", "3\n2 1 3\n1 2", "3\n2 1 2\n1 3", "2\n1 1\n1 2", "4\n2 2 1\n2 4 3", "4\n1 2\n3 3 4 1", "4\n3 3 2 1\n1 4", "4\n3 2 3 1\n1 4", "4\n3 1 4 2\n1 3", "4\n3 1 3 2\n1 4", "5\n2 2 1\n3 4 5 3", "5\n1 4\n4 5 2 3 1", "5\n1 2\n4 5 1 4 3", "5\n2 2 4\n3 3 1 5", "5\n4 2 4 3 1\n1 5", "5\n4 1 3 4 2\n1 5", "5\n4 3 2 5 1\n1 4", "5\n1 4\n4 3 2 5 1", "5\n4 4 1 3 2\n1 5", "5\n4 1 4 3 2\n1 5", "5\n4 1 5 3 2\n1 4", "6\n3 2 4 1\n3 3 6 5", "6\n1 4\n5 2 5 6 3 1", "6\n5 1 5 4 6 2\n1 3", "6\n2 4 6\n4 1 3 2 5", "6\n4 2 1 6 4\n2 5 3", "6\n1 6\n5 1 3 2 5 4", "6\n5 4 6 3 2 1\n1 5", "6\n1 5\n5 4 6 3 2 1", "6\n5 1 5 4 3 2\n1 6", "6\n5 1 4 3 5 2\n1 6", "6\n5 1 4 2 5 3\n1 6", "6\n5 1 3 4 5 2\n1 6", "7\n1 1\n6 5 6 3 2 7 4", "7\n6 5 1 2 6 4 3\n1 7", "7\n6 3 5 2 1 6 4\n1 7", "7\n1 6\n6 1 2 5 4 7 3", "8\n1 4\n7 3 8 6 1 5 7 2", "8\n7 3 1 5 4 7 6 2\n1 8", "9\n8 3 1 4 5 2 6 9 8\n1 7", "9\n7 6 5 9 2 1 3 8\n2 7 4", "9\n8 7 4 3 1 6 5 9 2\n1 8", "9\n8 4 8 5 6 3 2 7 1\n1 9", "10\n2 9 3\n8 10 4 1 8 6 2 7 5", "10\n2 7 1\n8 8 2 4 3 5 6 10 9", "10\n1 5\n9 3 2 8 7 1 9 10 6 4", "10\n9 6 2 1 4 8 7 3 10 5\n1 9", "10\n1 10\n9 9 4 7 8 5 2 6 3 1", "10\n5 1 2 7 9 6\n5 3 4 10 8 5", "10\n9 8 7 6 2 3 5 4 9 1\n1 10", "10\n1 10\n9 5 7 6 1 2 3 9 8 4", "10\n9 8 7 6 2 3 5 4 10 1\n1 9", "10\n9 4 6 5 3 1 8 9 7 2\n1 10", "10\n9 4 6 5 3 1 8 10 7 2\n1 9", "10\n9 4 9 6 5 8 3 2 7 1\n1 10", "10\n3 8 4 10\n7 1 2 6 7 3 9 5", "10\n4 6 2 7 1\n6 3 8 10 9 5 4", "10\n2 7 8\n8 3 5 2 10 4 9 1 6", "10\n2 7 5\n8 9 3 2 4 6 8 1 10", "10\n3 4 9 2\n7 5 1 6 8 3 7 10", "10\n5 4 9 1 8 7\n5 6 10 3 5 2", "10\n3 4 5 1\n7 9 10 3 2 6 7 8", "10\n3 5 9 8\n7 2 3 7 10 1 6 4", "10\n1 5\n9 4 9 1 7 2 6 10 3 8", "10\n4 3 10 8 7\n6 4 2 5 6 1 9", "10\n8 1 6 5 3 8 7 10 4\n2 9 2", "2\n1 2\n1 1"], "outputs": ["6 2", "-1", "1 1", "6 1", "1 1", "15 1", "2 2", "25 1", "2 2", "1 1", "2 1", "1 2", "1 2", "1 1", "-1", "-1", "-1", "1 2", "2 2", "1 2", "3 2", "7 2", "7 1", "5 2", "2 2", "1 2", "1 2", "-1", "-1", "-1", "7 1", "7 2", "6 2", "-1", "-1", "3 2", "3 2", "3 1", "-1", "-1", "-1", "19 1", "19 2", "17 2", "-1", "-1", "-1", "1 2", "-1", "14 2", "-1", "3 2", "41 2", "11 1", "-1", "25 1", "-1", "2 2", "2 2", "7 2", "-1", "-1", "-1", "105 2", "105 1", "103 1", "-1", "-1", "-1", "37 1", "10 2", "12 2", "10 2", "7 2", "21 2", "3 2", "19 2", "7 2", "8 1", "40 1", "1 1"]}
UNKNOWN
PYTHON3
CODEFORCES
3
e5433904b208cad09a5947d4ae338fcb
Goats and Wolves
Once Vasya needed to transport *m* goats and *m* wolves from riverbank to the other as quickly as possible. The boat can hold *n* animals and Vasya, in addition, he is permitted to put less than *n* animals in the boat. If in one place (on one of the banks or in the boat) the wolves happen to strictly outnumber the goats, then the wolves eat the goats and Vasya gets upset. When Vasya swims on the boat from one shore to the other, he must take at least one animal to accompany him, otherwise he will get bored and he will, yet again, feel upset. When the boat reaches the bank, first all the animals get off simultaneously, and then the animals chosen by Vasya simultaneously get on the boat. That means that at the moment when the animals that have just arrived have already got off and the animals that are going to leave haven't yet got on, somebody might eat someone. Vasya needs to transport all the animals from one river bank to the other so that nobody eats anyone and Vasya doesn't get upset. What is the minimal number of times he will have to cross the river? The first line contains two space-separated numbers *m* and *n* (1<=≤<=*m*,<=*n*<=≤<=105) — the number of animals and the boat's capacity. If it is impossible to transport all the animals so that no one got upset, and all the goats survived, print -1. Otherwise print the single number — how many times Vasya will have to cross the river. Sample Input 3 2 33 3 Sample Output 11 -1
[ "m, n = map(int, input().split())\n\n\ndef solve():\n global m\n global n\n f = 0\n res = 0\n if n == 1:\n print(-1)\n return\n # 特判\n if (m == 3 and n == 2) or (m == 5 and n == 3):\n print(11)\n return\n while True:\n if n >= 2*m:\n print(res+1)\n return\n elif n >= m:\n if n == m:\n print(res+5)\n else:\n print(res+3)\n return\n elif not f:\n m -= n-2\n res = 4\n f = 1\n else:\n if n//2 == 1:\n print(-1)\n return\n else:\n m -= n//2-1\n res += 2\n\nsolve()\n \n \n\n" ]
{"inputs": ["3 2", "33 3", "2 3", "100000 100000", "100000 4", "1 3", "97351 58063", "76652 89696", "2 1", "2 2", "2 4", "39600 21330", "3 1", "3 3", "3 4", "18900 52964", "4 1", "4 2", "4 3", "4 4", "4 5", "5 1", "5 2", "5 3", "5 4", "5 5", "6 6", "6 1", "6 2", "6 3", "6 4", "6 5", "99998 99998", "99998 99999", "99998 100000", "99998 99998", "99998 99999", "99998 100000", "100000 99998", "100000 99999", "1 1", "47208 14997", "32633 78581", "34411 58517", "19836 22101", "5262 85685", "7039 49269", "92464 29205", "77890 92789", "79667 56373", "11840 63975", "25810 46413", "56133 28851", "70104 94938", "427 77376", "14398 59815", "44721 42253", "58692 8339", "89015 90778", "2986 73216", "76450 12277", "70357 77208", "47912 58491", "41819 23422", "35726 4704", "29633 69635", "23540 50918", "1095 32200", "95002 97131", "88909 78414", "99999 3", "100000 1", "1 100000", "2 100000", "1 99999", "2 99999", "41061 60580", "98552 24355", "56043 88130", "13534 68257", "1 2", "100000 5", "100000 6", "100000 7", "100000 8", "100000 100", "100000 999", "100000 1000", "100000 77", "99999 5", "99999 6", "99999 7", "99999 8", "99999 100", "99999 999", "99999 1000", "99999 77", "99999 4", "99999 3", "100000 3", "10000 5", "1000 5", "100 5", "10 5"], "outputs": ["11", "-1", "3", "5", "199997", "1", "7", "3", "-1", "5", "1", "7", "-1", "5", "3", "1", "-1", "-1", "9", "5", "3", "-1", "-1", "11", "7", "5", "5", "-1", "-1", "-1", "9", "7", "5", "3", "3", "5", "3", "3", "5", "5", "-1", "13", "1", "3", "3", "1", "1", "13", "3", "5", "1", "3", "7", "3", "1", "1", "5", "29", "3", "1", "25", "3", "3", "7", "31", "1", "1", "1", "3", "5", "-1", "-1", "1", "1", "1", "1", "3", "17", "3", "1", "1", "199993", "99999", "99997", "66665", "4081", "401", "401", "5405", "199991", "99997", "99995", "66665", "4081", "401", "401", "5405", "199995", "-1", "-1", "19993", "1993", "193", "13"]}
UNKNOWN
PYTHON3
CODEFORCES
1
e55e1d85467875f389fff5bfc8e13913
Spreadsheet
In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. After ZZ there follow three-letter numbers, etc. The rows are marked by integer numbers starting with 1. The cell name is the concatenation of the column and the row numbers. For example, BC23 is the name for the cell that is in column 55, row 23. Sometimes another numeration system is used: RXCY, where X and Y are integer numbers, showing the column and the row numbers respectfully. For instance, R23C55 is the cell from the previous example. Your task is to write a program that reads the given sequence of cell coordinates and produce each item written according to the rules of another numeration system. The first line of the input contains integer number *n* (1<=≤<=*n*<=≤<=105), the number of coordinates in the test. Then there follow *n* lines, each of them contains coordinates. All the coordinates are correct, there are no cells with the column and/or the row numbers larger than 106 . Write *n* lines, each line should contain a cell coordinates in the other numeration system. Sample Input 2 R23C55 BC23 Sample Output BC23 R23C55
[ "import math\r\n\r\ndef sys_split(sstr):\r\n\r\n nums = []\r\n ind = []\r\n\r\n n = ''\r\n c = ''\r\n for i in range(len(sstr)):\r\n\r\n if sstr[i].isdigit():\r\n if len(c):\r\n ind.append(c)\r\n c = ''\r\n n += sstr[i].lower()\r\n\r\n else:\r\n if len(n):\r\n nums.append(int(n))\r\n n = ''\r\n c += sstr[i].lower()\r\n if len(n):\r\n nums.append(int(n))\r\n elif len(c):\r\n ind.append(c)\r\n\r\n return ind, nums\r\n\r\nret = [chr(i) for i in range(ord('a'), ord('z') + 1)]\r\nmret = {ch: i + 1 for i, ch in enumerate(ret)}\r\n\r\nt = int(input())\r\n\r\nfor _ in range(t):\r\n\r\n sstr = input()\r\n\r\n ind, nums = sys_split(sstr)\r\n\r\n if len(nums) == 2:\r\n\r\n n = nums[-1]\r\n c = ''\r\n while n > 26:\r\n a = n % 26\r\n a = a - 1 if a else 25\r\n c += ret[a].upper()\r\n n = (n - a) // 26\r\n\r\n c += ret[n - 1].upper()\r\n c = c[::-1]\r\n\r\n print('{}{}'.format(c, nums[0]))\r\n\r\n else:\r\n ind = ind[0][::-1]\r\n\r\n n = 0\r\n for i in range(len(ind)):\r\n n += mret[ind[i]] * (26**i)\r\n\r\n print('R{}C{}'.format(nums[0], n))\r\n", "\r\nimport time\r\nimport sys\r\nfrom collections import *\r\nfrom bisect import *\r\nfrom heapq import *\r\n\r\ninput = sys.stdin.readline\r\n\r\nis_debug = '_local_debug_' in globals()\r\n\r\n#int input\r\ndef inp():\r\n return(int(input()))\r\n\r\n#list input\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\n\r\n#string input\r\ndef insr():\r\n return input()[:-1]\r\n\r\n#strings input\r\ndef inss(n):\r\n return [insr() for _ in range(n)]\r\n\r\n#variables input\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\n#matrix input\r\ndef inmt(n):\r\n return [inlt() for _ in range(n)]\r\n\r\nclass Solution(object):\r\n def input(self):\r\n # 读入数据,返回一个参数列表\r\n # 例如:读取一个整数n和一个字符串s\r\n # return (n, s)\r\n s = insr()\r\n return (s,)\r\n\r\n def solve(self, s):\r\n ans = \"\"\r\n def is_rc(s):\r\n #如果是RNCM类型\r\n if s[0] == 'R' and s[1].isdigit():\r\n for i in range(2, len(s)):\r\n if s[i] == 'C':\r\n return True\r\n return False\r\n def rc2abc(s):\r\n #R23C55\r\n #BC23\r\n r = int(s[1:s.index('C')])\r\n c = int(s[s.index('C') + 1:])\r\n ans = \"\"\r\n while c > 0:\r\n c -= 1\r\n ans = chr(ord('A') + c % 26) + ans\r\n c //= 26\r\n ans += str(r)\r\n return ans\r\n def abc2rc(s):\r\n #BC23\r\n #R23C55\r\n r = \"\"\r\n c = \"\"\r\n for i in range(len(s)):\r\n if s[i].isdigit():\r\n r = s[i:]\r\n c = s[:i]\r\n break\r\n ans = \"R\" + r + \"C\"\r\n #将ABC格式转为数字\r\n cc = 0\r\n for i in range(len(c)):\r\n cc = cc * 26 + ord(c[i]) - ord('A') + 1\r\n ans += str(cc)\r\n return ans\r\n \r\n if is_rc(s):\r\n ans = rc2abc(s)\r\n else:\r\n ans = abc2rc(s)\r\n return ans\r\n\r\n def output(self,ans):\r\n print(ans)\r\n\r\ndef solve(i):\r\n sol = Solution()\r\n param = sol.input()\r\n if is_debug: start = time.time()\r\n ans = sol.solve(*param)\r\n sol.output(ans)\r\n if is_debug:\r\n end = time.time()\r\n print(f'Case{i} Time: {(end - start) * 1000} ms')\r\n\r\n#对于只有一个样例的题目,将inp()改为1\r\nt = inp() \r\n#t = 1\r\nif is_debug: start = time.time()\r\nfor i in range(1, t + 1):\r\n solve(i)\r\nif is_debug:\r\n end = time.time()\r\n print(f'Total Time: {(end - start) * 1000} ms')", "import re\r\nfor _ in range(int(input())):\r\n i = input()\r\n r = re.match(r\"R(\\d+)C(\\d+)\", i)\r\n if r is None:\r\n r = re.match(r\"([A-Z]+)(\\d+)\", i)\r\n n = 0\r\n for char in r.group(1):\r\n n *= 26\r\n n += ord(char) - ord('A') + 1\r\n print(f\"R{r.group(2)}C{n}\")\r\n else:\r\n row = r.group(1)\r\n col = int(r.group(2))\r\n c = \"\"\r\n while col > 26:\r\n n = (col - 1) % 26\r\n c = chr(n + ord('A')) + c\r\n col = (col - n - 1) // 26\r\n print(chr(col - 1 + ord('A')) + c + row)", "coordinates = []\r\n\r\ninput1 = int(input())\r\nfor i in range(input1):\r\n coordinates.append(input())\r\n\r\nfor i in coordinates:\r\n input2 = i\r\n excel = True\r\n x1 = [] # original input but seperated\r\n y1 = [] # contains the column part of the excel coordinates\r\n rowNumber = [] # contains row number of coordinates\r\n colNumber = \"\" # contains col number of coordinates\r\n totalColNumber = 0 # same as above but not a string\r\n totalRowNumber = \"\"\r\n colLetters = [] # column number in letters\r\n counter = 0 # shows how many letters there are\r\n\r\n for i in input2:\r\n x1.append(str(i))\r\n\r\n temp = list(x1)\r\n temp2 = list(temp)\r\n\r\n for i in temp:\r\n if i.isalpha():\r\n y1.append(i)\r\n temp2.remove(i)\r\n else:\r\n break\r\n\r\n for i in temp2:\r\n if i.isalpha():\r\n excel = False\r\n rowNumber.clear()\r\n break\r\n rowNumber.append(i)\r\n\r\n if excel == True:\r\n # need to change y1 into col numbers (for ex: ABC)\r\n maximumPower = len(y1) - 1\r\n for i in range(len(y1)):\r\n aNumber = (ord(y1[i]) - 64) * (26**(maximumPower - i))\r\n totalColNumber += aNumber\r\n\r\n for i in rowNumber:\r\n totalRowNumber = totalRowNumber + i\r\n\r\n print(\"R\" + totalRowNumber + \"C\" + str(totalColNumber))\r\n\r\n if excel == False:\r\n temp = list(x1)\r\n temp2 = list(temp)\r\n for i in temp[1:len(temp)]:\r\n if i == \"C\":\r\n break\r\n rowNumber.append(i)\r\n temp2.remove(i) # x1 starts to be emptied\r\n for i in temp2[2:len(temp2)]: # 2 because there is an R and a C left\r\n colNumber = colNumber + str(i)\r\n colNumber = int(colNumber)\r\n while colNumber >= 1:\r\n letter = chr(colNumber % 26 + 64)\r\n if letter == \"@\":\r\n letter = \"Z\"\r\n colNumber -= 1\r\n colLetters.append(letter) # still need to convert to letters!!!!!\r\n colNumber = colNumber//26\r\n\r\n colLetters.reverse()\r\n\r\n for i in colLetters:\r\n print(i, end=\"\")\r\n for i in rowNumber:\r\n print(i, end=\"\")\r\n print(\"\")", "from sys import stdin\r\nimport string\r\ninput = stdin.readline \r\n\r\nn = int(input())\r\n\r\nch_by_val = {i + 1: ch for i, ch in enumerate(string.ascii_uppercase)}; ch_by_val[0] = 'Z'\r\nval_by_ch = {ch: i + 1 for i, ch in enumerate(string.ascii_uppercase)}; val_by_ch['Z'] = 0\r\n\r\n# print(val_by_ch)\r\n# print(ch_by_val)\r\n\r\nfor line in range(n):\r\n word = input()[:-1]\r\n r_pos = None; c_pos = None\r\n for ind, ch in enumerate(word):\r\n if ch == 'R' and r_pos is None:\r\n r_pos = ind\r\n if ch == 'C' and r_pos is not None and c_pos is None:\r\n c_pos = ind\r\n\r\n if r_pos is not None and c_pos is not None and c_pos > r_pos + 1 and word[r_pos + 1] in '0123456789':\r\n row_num = int(word[r_pos + 1: c_pos]); col_num = int(word[c_pos + 1:])\r\n prefix = []\r\n while col_num > 0:\r\n rem = col_num % 26\r\n prefix.append(ch_by_val[rem])\r\n if rem == 0:\r\n col_num -= 26\r\n else:\r\n col_num -= rem\r\n col_num //= 26\r\n\r\n prefix = prefix[::-1]\r\n prefix = ''.join(prefix)\r\n print(prefix + str(row_num))\r\n else:\r\n first_num_ind = None\r\n for ind, ch in enumerate(word):\r\n if ch in '01233456789':\r\n first_num_ind = ind; break\r\n\r\n row_num = word[first_num_ind:]\r\n col_num = 0; exp = 0\r\n for i in range(first_num_ind - 1, -1, -1):\r\n coef = val_by_ch[word[i]]\r\n if coef == 0: coef = 26\r\n col_num += coef * 26 ** exp; exp += 1\r\n\r\n print('R' + str(row_num) + 'C' + str(col_num))", "def solve():\r\n s=input()\r\n n=len(s)\r\n flag=False\r\n for i in range(n-1):\r\n if '0'<=s[i]<='9' and 'A'<=s[i+1]<='Z':\r\n flag=True\r\n if flag:\r\n a,b=map(int,s[1:].split('C'))\r\n x=[]\r\n while b:\r\n c=(b-1)%26\r\n x.append(chr(65+c))\r\n if b%26==0:\r\n b//=26\r\n b-=1\r\n else:\r\n b//=26\r\n print(''.join(x[::-1])+str(a))\r\n\r\n else:\r\n s=list(s)\r\n r=[]\r\n while '0'<=s[-1]<='9':\r\n r.append(s.pop())\r\n c=0\r\n tmp=0\r\n while s:\r\n x=s.pop()\r\n c+=26**tmp*(ord(x)-64)\r\n tmp+=1\r\n print('R'+''.join(r[::-1])+'C'+str(c))\r\n\r\nfor _ in range(int(input())):\r\n solve()\r\n", "# import sys\r\n# sys.stdin = open(\"input01.txt\")\r\n\r\nt = int(input())\r\n\r\nfor _ in range(t):\r\n input_str = input()\r\n idx_R = input_str.find('R')\r\n idx_C = input_str.find('C')\r\n if idx_C > 1 and input_str[idx_C - 1].isnumeric():\r\n # type 2\r\n row = int(input_str[1:idx_C])\r\n col = int(input_str[idx_C + 1:])\r\n stack = []\r\n while col:\r\n stack.append(chr((col - 1) % 26 + ord('A')))\r\n\r\n col, mod_r = divmod(col, 26)\r\n if mod_r == 0:\r\n col -= 1\r\n while stack:\r\n print(stack.pop(), end=\"\")\r\n print(f\"{row}\")\r\n else:\r\n # type 1\r\n col_end_idx = 0\r\n\r\n while input_str[col_end_idx].isalpha():\r\n col_end_idx += 1\r\n col = input_str[:col_end_idx]\r\n row = int(input_str[col_end_idx:])\r\n col_num = 0\r\n for p, c in enumerate(reversed(col)):\r\n col_num += (ord(c) - ord('A') + 1) * 26 ** p\r\n print(f\"R{row}C{col_num}\")\r\n", "# so what I could do is I can first check to see what type of numeration system is used, (using like if statements).\r\n#if im changing from the integer system to the letter system. first, i'm going to check the integers after the R and after the C. For the R, i'm going to calculate what it wouuld be in terms of the letter. then I'll.\r\n#but how? ummm well I nkow A is 1, and B is 2. Z is 26. \r\ndef convert_to_numeric(input):\r\n output = 0\r\n alpha_size = 26\r\n for c in input:\r\n output = alpha_size * output + (ord(c) - ord('A') + 1)\r\n return output\r\n\r\ndef convert_to_alpha(input):\r\n alpha_size = 26\r\n output = \"\"\r\n while input > 0:\r\n letter = 'Z'\r\n input_mod = input % alpha_size\r\n if input_mod > 0:\r\n letter = chr(ord('A') + input_mod - 1)\r\n else:\r\n input -= alpha_size\r\n input //= alpha_size\r\n output = letter + output\r\n return output\r\n\r\nn = int(input())\r\nfor i in range(n):\r\n line = input().strip()\r\n if line[0] == 'R' and '0' <= line[1] <= '9' and 1 < line.find('C') < len(line) - 1:\r\n # Line contains coordinates\r\n c_pos = line.find('C')\r\n row_string = line[1:c_pos]\r\n col_string = line[c_pos + 1:]\r\n col = int(col_string)\r\n print(convert_to_alpha(col) + row_string)\r\n else:\r\n # Line contains row and column indices\r\n row_string = \"\"\r\n col_string = \"\"\r\n for c in line:\r\n if '0' <= c <= '9':\r\n col_string += c\r\n else:\r\n row_string += c\r\n print(\"R\" + col_string + \"C\" + str(convert_to_numeric(row_string)))\r\n", "hashnum = {i: chr(ord('A') + i) for i in range(26)}\r\n\r\ndef num_to_alpha(num):\r\n output = ''\r\n while num > 0:\r\n num -= 1\r\n output = hashnum[(num)%26] + output\r\n num = num // 26\r\n return output\r\n\r\nhashchar = {chr(ord('A')+i): i for i in range(26)}\r\n\r\ndef alpha_to_num(s):\r\n n = len(s)-1\r\n i = 0\r\n output = 0\r\n while n > -1:\r\n output = output + (hashchar[s[n]]+1) * 26**i\r\n n -= 1\r\n i += 1\r\n return output\r\n\r\ndef type1(s):\r\n l = s.split('C')\r\n return num_to_alpha(int(l[1]))+l[0][1:]\r\n\r\ndef type2(s):\r\n i = 0\r\n while i < len(s):\r\n if s[i] <= '9':\r\n break\r\n i += 1\r\n return 'R' + s[i:] + 'C' + str(alpha_to_num(s[:i]))\r\n\r\n\r\nfor _ in range(int(input())):\r\n s = input()\r\n if 'R' in s and s[s.index('R')+1] <= '9' and 'C' in s and s[s.index('C')+1] <= '9':\r\n res = type1(s)\r\n else:\r\n res = type2(s)\r\n print(res)", "from cmath import inf\nimport math\nimport sys\nfrom os import path\n#import bisect\n#import math\nfrom functools import reduce\nimport collections\n\nif (path.exists('CP/input.txt')):\n sys.stdout = open('CP/output.txt', 'w')\n sys.stdin = open('CP/input.txt', 'r')\n \ndef reverse_string(input_string):\n return input_string[::-1]\n\ndef getseq(x):\n ctr=0\n ans = \"\"\n while(x>0):\n x-=1\n cur = chr(ord('A') + ((x)%26))\n #print(cur)\n #print(x)\n ans+=(cur)\n x= x//26\n #print(ans)\n \n return reverse_string(ans)\n\n \n \ndef answer():\n s = input()\n \n stype=True\n met = False\n \n for i in range(len(s)-1,-1,-1):\n if(s[i]>='A' and s[i]<='Z'):\n met = True\n if(met and s[i]>='0' and s[i]<='9'):\n stype=False\n \n if(stype):\n num = \"\"\n ctr=0\n col_num=0\n for i in range(len(s)-1,-1,-1):\n if(s[i]>='A' and s[i]<='Z'):\n cur = ord(s[i])-ord('A')+1\n col_num+= (cur * (26**ctr))\n ctr+=1\n else:\n num+=(s[i])\n num = reverse_string(num)\n \n print(f\"R{num}C{col_num}\")\n #print(col_num)\n \n else:\n num = \"\"\n col_seq = \"\"\n for i in range(len(s)-1,-1,-1):\n if(s[i]=='R'):\n num = reverse_string(num)\n break\n elif(s[i]=='C'):\n num = reverse_string(num)\n col_seq = getseq(int(num))\n num=\"\"\n \n \n else: num+=s[i]\n \n print(f\"{col_seq}{num}\")\n \n \n \n \n \n \n\n\nt = int(input())\n#t=1\nfor _ in range(t):\n\tanswer()\n \n \n ", "import re\r\nimport sys\r\nfrom collections import *\r\nfrom functools import *\r\nfrom itertools import *\r\nfrom math import *\r\n\r\n# Fast IO\r\ninput = lambda: sys.stdin.readline().strip()\r\nprint = lambda *args: sys.stdout.write(' '.join(map(str, args)) + '\\n')\r\ndbg = lambda *args: sys.stderr.write(' '.join(map(str, args)) + '\\n')\r\n\r\n\r\ndef spf(n):\r\n spf = [0] * (n + 1)\r\n for i in range(2, n + 1):\r\n if spf[i] == 0:\r\n spf[i] = i\r\n for j in range(i * i, n + 1, i):\r\n if spf[j] == 0:\r\n spf[j] = i\r\n return spf\r\n\r\n\r\n\r\nT = int(input())\r\nrcre = re.compile(\"^R(\\d+)C(\\d+)$\")\r\nanre = re.compile(\"^([A-Z]+)(\\d+)$\")\r\nfor _ in range(T):\r\n c = input()\r\n m = rcre.match(c)\r\n if m:\r\n r, c = int(m.group(1)), int(m.group(2))\r\n ans = \"\"\r\n while c:\r\n c -= 1\r\n ans = chr(ord('A') + c % 26) + ans\r\n c //= 26\r\n print(ans + str(r))\r\n continue\r\n m = anre.match(c)\r\n if m:\r\n r, c = int(m.group(2)), 0\r\n for i, ch in enumerate(m.group(1)):\r\n c = c * 26 + ord(ch) - ord('A') + 1\r\n print(\"R\" + str(r) + \"C\" + str(c))\r\n \r\n", "def main():\r\n n = int(input())\r\n for _ in range(n):\r\n ch = input().strip()\r\n m = len(ch)\r\n C = 1\r\n while C < m and ch[C].isdigit():\r\n C += 1\r\n \r\n if 1 < C < m:\r\n col = 0\r\n for i in range(C + 1, m):\r\n col = col * 10 + int(ch[i])\r\n\r\n pow = 26\r\n while col > pow:\r\n col -= pow\r\n pow *= 26\r\n\r\n col -= 1\r\n while pow != 1:\r\n pow //= 26\r\n print(chr(col // pow + ord('A')), end='')\r\n col %= pow\r\n\r\n ch = ch[:C]\r\n print(ch[1:])\r\n else:\r\n col, val, pow = 0, 0, 1\r\n i = 0\r\n while ch[i].isalpha():\r\n col += pow\r\n pow *= 26\r\n val = val * 26 + ord(ch[i]) - ord('A')\r\n i += 1\r\n col += val\r\n print(f\"R{ch[i:]}C{col}\")\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "\"\"\"\r\n## NOTE\r\n- quotient and remainder\r\n- not easy\r\n\r\n## INFO\r\n1_B_Spreadsheets\r\nhttps://codeforces.com/problemset/problem/1/B\r\n\r\n## TAGS\r\n- implementation\r\n- math\r\n- *1600\r\n\r\n## TESTS\r\n-in:\r\n2\r\nR23C55\r\nBC23\r\n-out:\r\nBC23\r\nR23C55\r\n\r\n-failed test\r\n2\r\nR4C25\r\nR90C35\r\n-out\r\nY4\r\nAI90\r\n\"\"\"\r\n\r\n#%%\r\n\r\nimport re\r\nimport sys\r\nimport time\r\n\r\nstart_time = time.time()\r\nFILE = False\r\n\r\n# ---------------------- HELPER INPUT FUNCTIONS ----------------------#\r\n\r\n\r\ndef get_int():\r\n return int(sys.stdin.readline())\r\n\r\n\r\ndef get_str():\r\n return sys.stdin.readline().strip()\r\n\r\n\r\ndef get_list_int():\r\n return list(map(int, sys.stdin.readline().split()))\r\n\r\n\r\ndef get_list_str():\r\n return list(sys.stdin.readline().split())\r\n\r\n\r\n# -------------------------- SOLVE FUNCTION --------------------------#\r\n\r\n\r\ndef solve():\r\n \"\"\"\r\n https://codeforces.com/contest/1/submission/48441268\r\n \"\"\"\r\n\r\n def is_RxCy(s):\r\n return s[1:].split(\"C\")[0].isnumeric() and \"C\" in s\r\n\r\n n = get_int()\r\n for _ in range(n):\r\n s = get_str()\r\n if is_RxCy(s):\r\n # RxCy format\r\n r, c = map(int, s[1:].split('C'))\r\n # from num to chars\r\n res = \"\"\r\n while c > 0:\r\n res = chr((c - 1) % 26 + ord(\"A\")) + res\r\n c = (c - 1) // 26\r\n print(f\"{res}{r}\")\r\n else:\r\n idx = 0\r\n while not s[idx].isdigit():\r\n idx += 1\r\n cs = s[:idx]\r\n r = s[idx:]\r\n res = 0\r\n for c in cs:\r\n res = res * 26\r\n res += ord(c) - ord(\"A\") + 1\r\n print(f\"R{r}C{res}\")\r\n\r\n\r\n# -------------------------- MAIN FUNCTION --------------------------#\r\n\r\n\r\ndef main():\r\n if FILE:\r\n sys.stdin = open(\"./src/codeforces/input.txt\", \"r\")\r\n\r\n solve()\r\n\r\n if FILE:\r\n print(\"\\033[95m\" + \"> time elapsed: \", (time.time() - start_time) * 1000.0, \"ms\")\r\n\r\n\r\nmain()\r\n", "import re\r\ndef f(x):\r\n lista=\"\"\r\n if x>=26:\r\n return f(int(x/26)-1)+chr(x%26+65)\r\n else:\r\n return chr(x%26+65)\r\ndef f_2(x):\r\n num=0\r\n n=len(x)\r\n for i in x:\r\n num+=(26**(n-1))*(ord(i)-64)\r\n n=n-1\r\n return num\r\n\r\n\r\nn = int(input())\r\nfor i in range(n):\r\n data=input()\r\n resultado= re.findall(r'R(\\d+)C(\\d+)', data)\r\n if resultado:\r\n print(f(int(resultado[0][1])-1)+resultado[0][0])\r\n else:\r\n resultado = re.findall(r'([A-Za-z]+)(\\d+)', data)\r\n print(\"R\"+resultado[0][1]+\"C\"+str(+f_2(resultado[0][0])))", "import re\nimport sys\n\n\ndef f1(col):\n col = int(col)\n res = \"\"\n while col:\n m = (col - 1) % 26\n col = (col - 1) // 26\n res = chr(65 + m) + res\n return res\n\n\ndef f2(col):\n res = 0\n for d in col:\n res = 26 * res + ord(d) - 64\n return res\n\n\nfor line in sys.stdin.read().split()[1:]:\n if len(re.findall(r\"\\d+\", line)) == 2:\n row, col = re.findall(r\"(\\d+)\", line)\n print(f\"{f1(col)}{row}\")\n else:\n col, row = re.fullmatch(r\"([A-Z]+)(\\d+)\", line).groups()\n print(f\"R{row}C{f2(col)}\")\n", "# LUOGU_RID: 101874291\nimport re\r\nfor _ in range(int(input())):\r\n s = input()\r\n if re.match('R\\d+C\\d+', s):\r\n r = s[1:s.find('C')]\r\n c = int(s[s.find('C')+1:])\r\n t = ''\r\n while c:\r\n c -= 1\r\n t += chr(c % 26 + ord('A'))\r\n c //= 26\r\n print(t[::-1] + r)\r\n else:\r\n p = 0\r\n while s[p].isalpha():\r\n p += 1\r\n t = 0\r\n for c in s[:p]:\r\n t = t * 26 + ord(c) - ord('A') + 1\r\n print(f'R{s[p:]}C{t}')", "from bisect import bisect_left, bisect_right\r\nfrom collections import Counter, deque\r\nfrom functools import lru_cache\r\nfrom math import factorial, comb, sqrt, gcd\r\nfrom copy import deepcopy\r\nimport heapq\r\n\r\ndef nts(n):\r\n ys = (n - 1) % 26\r\n cs = (n - 1) // 26\r\n if cs == 0:\r\n return chr(ys + ord('A'))\r\n else:\r\n return nts(cs) + chr(ys + ord('A'))\r\n\r\n\r\ndef stn(n):\r\n a = 0\r\n i = 0\r\n for x in range(len(n) - 1, -1, -1):\r\n a += (ord(s[x]) - ord('A')+ 1 ) * 26 ** i\r\n i += 1\r\n \r\n return a\r\n\r\ndef w1(rn, cn):\r\n cs = nts(cn)\r\n print(cs + str(rn))\r\n \r\ndef w2(s):\r\n for i in range(len(s)):\r\n if s[i].isdigit():\r\n break\r\n cn = stn(s[:i])\r\n print(f\"R{s[i:]}C{str(cn)}\")\r\n \r\n \r\nc = int(input())\r\nfor _ in range(c):\r\n s = input()\r\n if \"R\" in s and \"C\" in s:\r\n i1 = s.index(\"R\")\r\n i2 = s.index(\"C\")\r\n if i2 > i1 + 1:\r\n try:\r\n rn = int(s[i1 + 1: i2])\r\n cn = int(s[i2 + 1:])\r\n w1(rn, cn)\r\n except:\r\n w2(s)\r\n else:\r\n w2(s)\r\n else:\r\n w2(s)\r\n ", "n = int(input())\r\n\r\n\r\ndef rcSplit(s):\r\n for i in range(len(s) - 1):\r\n if s[i].isnumeric() and s[i + 1].isalpha():\r\n return i\r\n return -1\r\n\r\n\r\nfor _ in range(n):\r\n s = input()\r\n rcs = rcSplit(s)\r\n if rcs == -1:\r\n col = 0\r\n row = 0\r\n for i in range(len(s)):\r\n if s[i].isalpha():\r\n col = col * 26 + ord(s[i]) - 64\r\n else:\r\n row = s[i:]\r\n break\r\n print(f\"R{row}C{col}\")\r\n else:\r\n col = int(s[rcs + 2 :])\r\n # acc = chr(64 + col%27) + acc if col != 27 else 'A' + acc\r\n acc = \"\"\r\n while col > 0:\r\n # if col > 26 and col % 26 != 0:\r\n # acc = chr(64 + col % 26) + acc\r\n if col % 26 != 0:\r\n acc = chr(64 + col % 26) + acc\r\n else:\r\n acc = \"Z\" + acc\r\n if col % 26 == 0 and col // 26 == 1:\r\n break\r\n col = col // 26 if col % 26 != 0 else col // 26 - 1\r\n\r\n print(f\"{acc}{s[1 : rcs + 1]}\")\r\n", "\r\ndef a_to_b(s):\r\n # R23C55 to BC23\r\n q,col = s.split(\"C\")\r\n col = int(col)\r\n row = int(q.split(\"R\")[1])\r\n\r\n # convertir row en base26\r\n\r\n s_col = \"\"\r\n while col > 0:\r\n col -= 1\r\n s_col = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"[col % 26] + s_col\r\n col //= 26\r\n\r\n return f\"{s_col}{row}\"\r\n\r\ndef b_to_a(s):\r\n s_col = \"\"\r\n s_row = \"\"\r\n for e in s:\r\n if e in \"0123456789\":\r\n s_row += e\r\n else:\r\n s_col += e\r\n row = int(s_row)\r\n col = 0\r\n while s_col != \"\":\r\n col *= 26\r\n col += (ord(s_col[0])-ord('A')+1)\r\n s_col = s_col[1:]\r\n\r\n return f\"R{row}C{col}\"\r\n\r\ndef solve(s):\r\n x = s.split(\"C\")\r\n if len(x) != 2:\r\n return b_to_a(s)\r\n y = x[0].split(\"R\")\r\n if len(y) != 2 or y[0]!='':\r\n return b_to_a(s)\r\n if not set(y[1]).issubset(set(\"0123456789\")) or y[1]==\"\":\r\n return b_to_a(s)\r\n return a_to_b(s)\r\n\r\n\r\nfor i in range(int(input())):\r\n s = input()\r\n print(solve(s))\r\n\r\n\"\"\"\r\nimport random\r\nfor i in range(100000):\r\n c = random.randint(1,10**6+1)\r\n r = random.randint(1,10**6+1)\r\n a = f\"R{r}C{c}\"\r\n b = solve(a)\r\n a_2 = solve(b)\r\n if a!= a_2:\r\n print (a,b,a_2)\r\n\"\"\"", "\r\ndef jdg(ss):\r\n flag=0\r\n if ss[0]=='R':\r\n for i in range(1,len(ss)-1):\r\n if (flag==0 and (ss[i]>='0' and ss[i]<='9')):\r\n flag=1\r\n continue\r\n if (flag==1 and ss[i]=='C'):\r\n return 0\r\n return 1\r\nn=int(input())\r\nfor k in range(n):\r\n c=0\r\n r=0\r\n s=input()\r\n if(jdg(s)):\r\n for j in range(len(s)):\r\n if(s[j]>='A' and s[j]<='Z'):\r\n c*=26\r\n c+=ord(s[j])-ord('A')+1\r\n if(s[j]>='0' and s[j]<='9'):\r\n r*=10\r\n r+=int(s[j])\r\n print(\"R\"+str(r)+\"C\"+str(c))\r\n else:\r\n j=1\r\n while(s[j]!='C'):\r\n r*=10\r\n r+=int(s[j])\r\n j+=1\r\n j+=1\r\n while(j<len(s)):\r\n c*=10\r\n c+=int(s[j])\r\n j+=1\r\n ans=\"\"\r\n ans1=\"\"\r\n while(c):\r\n ans1+=chr((c-1)%26+ord('A'))\r\n c=(c-1)//26\r\n m=len(ans1)\r\n ans=ans1[::-1]\r\n ans+=str(r)\r\n print(ans)\r\n", "for n in range(int(input())):\r\n x=input();a=b=0\r\n for c in x:\r\n if '0'<=c<='9':b=b*10+int(c)\r\n elif b:\r\n a,b=x[1:].split('C');b=int(b);v=''\r\n while b:b-=1;v=chr(65+b%26)+v;b//=26\r\n print(v+a);break\r\n else:a=26*a+ord(c)-64\r\n else:print(\"R%dC%d\" % (b,a))\r\n", "# LUOGU_RID: 128113068\nimport typing\r\ndef to_int(s: str):\r\n sLen = len(s)\r\n out = 0\r\n beishu = 1\r\n for i in range(sLen):\r\n out += (ord(s[sLen-1-i] ) - ord('A') + 1) * beishu\r\n beishu *= 26\r\n return out \r\n\r\ndef to_str(s: str):\r\n num = int(s)\r\n out = \"\"\r\n while num > 0:\r\n num -= 1\r\n yu = num % 26\r\n num = num // 26\r\n out = chr(yu + ord('A')) + out\r\n return out\r\n\r\n\r\ndef fun():\r\n n = int(input())\r\n for i in range(n):\r\n Coord = input()\r\n Length = len(Coord)\r\n idx1 = 0\r\n CType = 1\r\n while not (Coord[idx1] >= '0' and Coord[idx1] <='9'):\r\n idx1 += 1\r\n \r\n idx2 = idx1\r\n while (idx2 < Length and Coord[idx2] >= '0' and Coord[idx2] <='9'):\r\n idx2+= 1\r\n\r\n # 如果CType为2,表示形式为 BC23 这种\r\n if idx2 == Length :\r\n CType = 2\r\n\r\n if CType == 1:\r\n num1 = Coord[1:idx2]\r\n num2 = Coord[idx2+1:]\r\n colum = to_str(num2)\r\n print(colum+num1)\r\n else:\r\n num1 = Coord[idx1:]\r\n strcolum = Coord[:idx1]\r\n colum = to_int(strcolum)\r\n print(\"R\"+num1+\"C\"+str(colum))\r\n\r\n\r\nif __name__ == \"__main__\":\r\n fun()", "# LUOGU_RID: 105945841\n# LC168\r\ndef num2title(n: int) -> str:\r\n s = \"\"\r\n while n:\r\n n -= 1\r\n s = chr(n % 26 + 65) + s\r\n n //= 26\r\n return s\r\n\r\n# LC171\r\ndef title2num(s: str) -> int:\r\n n = 0\r\n for c in s:\r\n n = n * 26 + ord(c) - 64\r\n return n\r\n\r\n# RxxCxx -> AAxx\r\ndef r2e(s: str) -> str:\r\n r, c = map(int, s[1:].split('C'))\r\n return num2title(c) + str(r)\r\n\r\n# AAxx -> RxxCxx\r\ndef e2r(s: str) -> str:\r\n i = 0\r\n while s[i].isalpha(): i += 1\r\n return \"R%sC%d\" % (s[i:], title2num(s[:i]))\r\n\r\n# whether is RxxCxx format\r\ndef rc(s: str) -> bool:\r\n if s[0] == 'R':\r\n i = s.rfind('C')\r\n if i > 0 and s[i - 1].isdigit():\r\n return True\r\n return False\r\n\r\n# __main__\r\nfor _ in range(int(input())):\r\n s = input()\r\n # if s[0] == 'R': # wrong, title can be started with R\r\n if rc(s):\r\n print(r2e(s))\r\n else:\r\n print(e2r(s))", "import re\r\n\r\ntcase = int(input())\r\nfor _ in range(tcase):\r\n s = input()\r\n m = re.match(r'R(\\d+)C(\\d+)', s)\r\n if m is None:\r\n m = re.match(r'([A-Z]+)(\\d+)', s)\r\n col = 0\r\n for c in m.group(1):\r\n col = col * 26 + ord(c) - ord('A') + 1\r\n print('R%sC%d' % (m.group(2), col))\r\n else:\r\n col = int(m.group(2))\r\n ans = ''\r\n while col > 0:\r\n col -= 1\r\n ans += chr(col % 26 + ord('A'))\r\n col = col // 26\r\n print('%s%s' % (ans[::-1], m.group(1)))\r\n", "import re\r\nimport math\r\n\r\nn = int(input())\r\nresult = []\r\n\r\ndef NumToR1C1(Num):\r\n BASE = 26\r\n d, m = 0, 0\r\n result = ''\r\n\r\n while Num > 0:\r\n d = Num // BASE\r\n m = Num % BASE\r\n\r\n if (d > 0) and (m == 0):\r\n d -= 1\r\n m = BASE\r\n\r\n Num = d\r\n result = chr(m + ord('A') - 1) + result\r\n \r\n return result\r\n\r\ndef R1C1ToNum(Num):\r\n BASE = 26\r\n j = 0\r\n #c: Char;\r\n\r\n i = 1\r\n result = 0\r\n Len = len(Num)\r\n\r\n while Num != '':\r\n c = Num[Len-i]\r\n j = ord(c) - 64\r\n\r\n result = result + j * math.trunc(BASE**(i-1))\r\n \r\n i += 1\r\n Num = Num[0:len(Num)-1:1]\r\n\r\n return str(result)\r\n\r\nfor _ in range(n):\r\n s = input()\r\n \r\n if re.search(r'R\\d+C\\d+', s):\r\n R, C = map(int, re.findall(r'R(\\d+)C(\\d+)', s)[0])\r\n print(NumToR1C1(C) + str(R))\r\n else:\r\n C, R = re.findall(r'(\\D+)(\\d+)', s)[0]\r\n print('R' + R + 'C' + R1C1ToNum(C))\r\n \r\n", "import re\r\n\r\ndef trans_two_letter(coordinate):\r\n matches = re.match(r'(R)(\\d+)(C)(\\d+)', coordinate)\r\n row = int(matches.group(2))\r\n col = int(matches.group(4))\r\n\r\n col_char = ''\r\n while col > 0:\r\n remainder = col % 26\r\n col_char = chr((remainder + 26 - 1) % 26 + ord('A')) + col_char\r\n col = (col // 26 - 1) if col_char[0] == 'Z' else (col // 26)\r\n\r\n return '{}{}'.format(col_char, row)\r\n\r\ndef trans_normal(coordinate):\r\n matches = re.match(r'([A-Z]+)(\\d+)', coordinate)\r\n col_char = matches.group(1)\r\n row = matches.group(2)\r\n\r\n col = 0\r\n k = 0\r\n while len(col_char) > 0:\r\n col += (ord(col_char[-1]) - ord('A') + 1) * (26 ** k)\r\n k += 1\r\n col_char = col_char[:-1]\r\n \r\n return 'R{}C{}'.format(row, col)\r\n \r\nn = int(input())\r\n\r\nfor _ in range(n):\r\n coordinate = input()\r\n if re.match('^([A-Z]+)(\\d+)$', coordinate):\r\n print(trans_normal(coordinate))\r\n else:\r\n print(trans_two_letter(coordinate))", "import math\r\nimport copy\r\nimport itertools\r\nimport bisect\r\nimport sys\r\n\r\ninput = sys.stdin.readline\r\n\r\ndef ilst():\r\n return list(map(int,input().split()))\r\n \r\ndef islst():\r\n return list(map(str,input().split()))\r\n \r\ndef inum():\r\n return map(int,input().split())\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 issub(s1,s2): #s2 is a sub of s1\r\n j = 0\r\n for i in range(len(s1)):\r\n if s1[i] == s2[j]:\r\n j += 1\r\n if j == len(s2):\r\n return True\r\n return False\r\n\r\ndef foo(s):\r\n return ord(s)-64\r\n\r\ndef foo2(n):\r\n return chr(65+n)\r\n \r\nt = int(input())\r\n\r\nfor _ in range(t):\r\n s = input()\r\n if s[-1] == '\\n':\r\n s = s[:-1]\r\n \r\n f = True\r\n c = 0\r\n for i in range(1,len(s)):\r\n if s[i].isalpha() and not f:\r\n c += 1\r\n f = True\r\n elif s[i].isdigit() and f:\r\n c += 1\r\n f = False\r\n \r\n if c == 1:\r\n for i in range(len(s)):\r\n if s[i].isdigit():\r\n cols = s[:i]\r\n rows = s[i:]\r\n break\r\n col = 0\r\n p = 0\r\n for i in cols[::-1]:\r\n col += foo(i)*(26**p)\r\n p += 1\r\n print('R'+rows+'C'+str(col))\r\n \r\n else:\r\n rows,cols = '',''\r\n f = False\r\n for i in range(1,len(s)):\r\n if s[i].isalpha():\r\n f = True\r\n continue\r\n if not f:\r\n rows += s[i]\r\n else:\r\n cols += s[i]\r\n col = int(cols)\r\n cols = ''\r\n \r\n while col:\r\n col -= 1\r\n cols += foo2(col%26)\r\n col //= 26\r\n print(cols[::-1]+rows)", "from sys import stdin,stdout\nfrom re import match\n# from bisect import bisect_left,bisect\n# from sys import setrecursionlimit\n# from collections import defaultdict\n# from math import gcd,ceil,sqrt\n# setrecursionlimit(int(1e5))\ninput,print = stdin.readline,stdout.write\n# t = 1\nalpha = \"zabcdefghijklmnopqrstuvwxy\".upper()\nnum = \"0123456789\"\n\n\nt = int(input())\nfor _ in range(t):\n\ts = input()\n\tm = match('R(\\d+)C(\\d+)',s)\n\tif m is not None:\n\t\trow = \"\"\n\t\tx = int(m.group(2))\n\t\twhile x!=0:\n\t\t\tx-=1\n\t\t\trow+=chr(x%26+65)\n\t\t\tx//=26\n\t\tprint(row[::-1]+str(m.group(1))+\"\\n\")\n\n\telse:\n\t\tm = match('([A-Z]+)(\\d+)',s)\n\t\tk = 0\n\t\tfor i in m.group(1):\n\t\t\tk = k*26+(ord(i)-64)\n\t\tprint(\"R\"+m.group(2)+\"C\"+str(k)+\"\\n\")\n\n\t\t\t \t\t\t\t \t\t\t\t \t\t\t \t \t \t\t", "import re\r\n\r\nnum = int(input())\r\nfor i in range(num):\r\n s = input()\r\n if re.match(\"R\\d+C\\d+\", s):\r\n row = re.search(\"R(\\d+)C(\\d+)\", s).group(1)\r\n col = int(re.search(\"R(\\d+)C(\\d+)\", s).group(2))\r\n coltemp = col\r\n lens = 0\r\n while coltemp > 0:\r\n lens += 1\r\n coltemp = coltemp - 26**lens\r\n coltemp += 26**lens\r\n coll = []\r\n for j in range(lens):\r\n if coltemp == 0:\r\n coll.append(\"A\")\r\n continue\r\n coll.append(chr(ord(\"A\") + (coltemp - 1) // 26**(lens - j - 1)))\r\n coltemp = (coltemp - 1) % 26**(lens - j - 1) + 1\r\n cols = \"\".join(coll)\r\n print(cols + row)\r\n\r\n else:\r\n boundary = re.search(\"\\d\", s).span()[0]\r\n row = int(s[boundary:])\r\n cols = s[:boundary]\r\n col = 0\r\n for j in range(len(cols)):\r\n col += 26**j\r\n diff = 0\r\n for j in range(len(cols)):\r\n diff *= 26\r\n diff += ord(cols[j]) - ord('A')\r\n col += diff\r\n print(f\"R{row}C{col}\")\r\n", "def convert_to_numerical(string):\r\n output = 0\r\n alphabet_size = 26\r\n for i in range(len(string)):\r\n output = alphabet_size * output + (ord(string[i]) - ord('A') + 1)\r\n\r\n return str(output)\r\n\r\n\r\ndef convert_to_alphabetic(number):\r\n alphabet_size = 26\r\n output = \"\"\r\n\r\n while(number > 0):\r\n letter = 'Z'\r\n number_mod = number % alphabet_size\r\n if number_mod > 0:\r\n letter = chr(ord('A') + number_mod - 1)\r\n else:\r\n number -= alphabet_size\r\n\r\n number //= alphabet_size\r\n output = letter + output\r\n\r\n return output\r\n\r\n\r\nn = int(input())\r\n\r\nwhile(n):\r\n n -= 1\r\n\r\n coordinates = input()\r\n variation = False\r\n\r\n if coordinates[0] == 'R' and (coordinates[1] >= '0' and coordinates[1] <= '9') and coordinates.find('C') > 1 and coordinates.find('C') < (len(coordinates)-1):\r\n variation = True\r\n\r\n if variation:\r\n c_pos = coordinates.find('C')\r\n row_string = coordinates[1: c_pos]\r\n col_string = coordinates[c_pos+1:]\r\n col = int(col_string)\r\n print(convert_to_alphabetic(col)+row_string)\r\n else:\r\n row_string = \"\"\r\n col_string = \"\"\r\n\r\n for i in range(len(coordinates)):\r\n if coordinates[i] >= '0' and coordinates[i] <= '9':\r\n row_string = coordinates[i:]\r\n break\r\n else:\r\n col_string += coordinates[i]\r\n print('R' + str(row_string) + 'C' + convert_to_numerical(col_string))\r\n", "def convert_to_numeric(input_str):\r\n output = 0\r\n alpha_size = 26\r\n for char in input_str:\r\n output = alpha_size * output + (ord(char) - ord('A') + 1)\r\n return output\r\n\r\ndef convert_to_alpha(input_num):\r\n alpha_size = 26\r\n output = \"\"\r\n\r\n while input_num > 0:\r\n letter = 'Z'\r\n input_mod = input_num % alpha_size\r\n if input_mod > 0:\r\n letter = chr(ord('A') + input_mod - 1)\r\n else:\r\n input_num -= alpha_size\r\n input_num = input_num // alpha_size\r\n output = letter + output\r\n\r\n return output\r\n\r\ndef main():\r\n n = int(input())\r\n for _ in range(n):\r\n line = input()\r\n\r\n coordinates = False\r\n if line[0] == 'R' and '0' <= line[1] <= '9' and 1 < line.find('C') < len(line) - 1:\r\n coordinates = True\r\n\r\n if coordinates:\r\n c_pos = line.find('C')\r\n row_string = line[1:c_pos]\r\n col_string = line[c_pos + 1:]\r\n col = int(col_string)\r\n print(convert_to_alpha(col) + row_string)\r\n else:\r\n row_string = \"\"\r\n col_string = \"\"\r\n\r\n for char in line:\r\n if '0' <= char <= '9':\r\n col_string = line[line.index(char):]\r\n break\r\n else:\r\n row_string += char\r\n print(\"R\" + col_string + \"C\" + str(convert_to_numeric(row_string)))\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n\r\n\t\t\t \r\n\t\t\t ", "import re\n\ndef to_number(S):\n base = ord(\"Z\") - ord(\"A\") + 1\n pos_value = 1\n N = 0\n for c in S[::-1]:\n N += (ord(c) - ord(\"A\") + 1) * pos_value\n pos_value *= base\n return N\n\ndef to_letter(N):\n base = ord(\"Z\") - ord(\"A\") + 1\n S = \"\"\n while N > 0:\n S += chr(ord(\"A\") + (N - 1) % base)\n N = (N-1) // base\n return S[::-1]\n\nfor _ in range(int(input())):\n coords = input()\n match = re.fullmatch(\"R(\\d+)C(\\d+)\", coords)\n if match is None:\n match = re.fullmatch(\"([A-Z]+)(\\d+)\", coords)\n r = match.group(2)\n c = to_number(match.group(1))\n print(f\"R{r}C{c}\")\n else:\n r = match.group(1)\n c = to_letter(int(match.group(2)))\n print(f\"{c}{r}\")\n", "\r\ndef convert_to_alpha(input):\r\n res = \"\"\r\n input = int(input)\r\n while (input > 0):\r\n letter = 'Z'\r\n c = int(input % 26)\r\n if c > 0:\r\n letter = chr(ord('A') + c - 1)\r\n else:\r\n input -= 26\r\n input = int(input / 26)\r\n res = letter + res\r\n\r\n return res\r\n\r\n\r\ndef convert_to_numeric(row_string):\r\n res = 0\r\n for c in row_string:\r\n res = res * 26 + ord(c) - ord('A') + 1\r\n return res\r\nif __name__ == '__main__':\r\n n = int(input())\r\n for i in range (0, n):\r\n s = input()\r\n coordinate = False\r\n if s[0] == 'R' and '0' <= s[1] and s[1] <= '9' and 1 < s.find('C') and s.find('C') < len(s):\r\n coordinate = True\r\n if coordinate:\r\n c_pos = s.find('C')\r\n row_str = s[1 : c_pos]\r\n col_str = s[c_pos + 1 : ]\r\n col = int(col_str)\r\n print(convert_to_alpha(col) + row_str)\r\n else:\r\n row_str = \"\"\r\n col_str = \"\"\r\n for char in range (len(s)):\r\n if (ord(s[char]) >= ord('0') and ord(s[char]) <= ord('9')):\r\n col_str = col_str + s[char : ]\r\n break\r\n else:\r\n row_str = row_str + s[char]\r\n print('R' + col_str + 'C' + str(convert_to_numeric(row_str)))", "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\n\r\nnums = '01234567890'\r\n\r\ndef c1(S):\r\n parts = []\r\n for i,c in enumerate(S):\r\n if i>0 and c in nums and S[i-1] not in nums:\r\n parts = [S[:i],S[i:]]\r\n s = [c for c in parts[0]]\r\n cols = 0\r\n idx = 1\r\n while s:\r\n t = s.pop()\r\n tmp = (ord(t)-ord('A')+1)*idx\r\n cols += tmp\r\n idx*=26\r\n \r\n return 'R'+parts[1]+'C'+str(cols)\r\n\r\ndef c2(row, col):\r\n pre = ''\r\n while col>0:\r\n col-=1\r\n t = col%26\r\n #print('col', t)\r\n pre+=chr(ord('A')+t)\r\n col//=26\r\n \r\n return pre[::-1]+row\r\n \r\n\r\nfor _ in range(int(input())):\r\n S = input()\r\n parts = [S]\r\n for i,c in enumerate(S):\r\n if i>0 and c not in nums and S[i-1] in nums:\r\n parts = [S[1:i], S[i+1:]]\r\n break\r\n \r\n if len(parts)==1:\r\n print(c1(parts[0]))\r\n else:\r\n print(c2(parts[0], int(parts[1])))\r\n", "import sys\r\n#a,b,c = map(int, sys.stdin.readline().split())\r\nimport re\r\n# case 1, Row... Col...\r\natoz = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')\r\n\r\n\r\ndef decimal_to_radix26(n):\r\n alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\r\n if n <= 26:\r\n return alphabet[n - 1] # Subtract 1 because indexing in Python starts at 0\r\n else:\r\n return decimal_to_radix26((n - 1) // 26) + alphabet[\r\n (n - 1) % 26] # Subtract 1 because Z should be equivalent to 26, not 0\r\n\r\n\r\ndef rowcol(sts):\r\n sts = sts.replace(\"\\n\",'')\r\n a = sts[1:]\r\n b = a.split(\"C\")\r\n num =int(b[1])\r\n s = (decimal_to_radix26(num)) # Should return AB\r\n #s+=(atoz[num-1])\r\n print(s+b[0])\r\n\r\ndef exc(sts):\r\n sts = sts.replace(\"\\n\",'')\r\n num = re.search(r\"\\d+\", sts).group()\r\n let = sts.replace(num,'')[::-1]\r\n i = 1\r\n v = 0\r\n while i<=len(let):\r\n v+=(atoz.index(let[i-1])+1)*(26**(i-1))\r\n i+=1\r\n print(\"R\"+num+\"C\"+str(v))\r\na = int(sys.stdin.readline())\r\nfor i in range(a):\r\n q = sys.stdin.readline().replace('\\n','')\r\n if q[0]!=\"R\":\r\n exc(q)\r\n else:\r\n if q[1] in atoz:\r\n exc(q)\r\n else:\r\n try:\r\n v = int(q[1:])\r\n exc(q)\r\n except:\r\n rowcol(q)\r\n #print(i)", "digits = \"0123456789\"\n\ndef descriptive_to_letters(cell):\n row, col = [int(x) for x in cell[1:].split(\"C\")]\n letters = \"\"\n while col != 0:\n col -= 1\n letters = letters+ str(chr((col)%26+65))\n col = col//26\n \n print(f\"{letters[::-1]}{row}\")\n \n\ndef letters_to_descriptive(cell):\n row = 0\n col = 0\n letters = \"\"\n for i in cell:\n if i not in digits:\n letters += i\n else:\n break\n \n row = int(cell.replace(letters, ''))\n letters = letters[::-1]\n for i, c in enumerate(letters):\n col += (26**i)*(ord(c)-64)\n \n print(f\"R{row}C{col}\")\n\n\ndef discerner(cell):\n if cell[1] in digits and \"C\" in cell[2:]:\n descriptive_to_letters(cell)\n return\n \n letters_to_descriptive(cell)\n\nt = int(input())\nfor _a in range(t):\n cell = input()\n discerner(cell)", "for _ in range(int(input())):\r\n x=input()\r\n if x[0]=='R' and x[1]>='0' and x[1]<='9' and 'C' in x:\r\n i = x.index('C')\r\n r=int(x[1:i])\r\n c=int(x[i+1:])\r\n z=[]\r\n while c>26:\r\n c-=1\r\n z.insert(0,chr(65 + c%26))\r\n c=c//26\r\n \r\n c-=1\r\n z.insert(0,chr(65 + c%26))\r\n z.append(str(r))\r\n else:\r\n c=0\r\n for i in range(len(x)):\r\n if x[i]>='A' and x[i]<='Z':\r\n c= c * 26 + ord(x[i]) - 64\r\n # print(c)\r\n else:\r\n r=x[i:]\r\n break\r\n z=['R',r,'C',str(c)]\r\n \r\n print(''.join(z))\r\n \r\n ", "for n in range(int(input())):\r\n x=input();a=b=0\r\n for c in x:\r\n if'0'<=c<='9':b=10*b+int(c)\r\n elif b:\r\n a,b=x[1:].split('C');b=int(b);v=\"\"\r\n while b:b-=1;v=chr(65+b%26)+v;b//=26\r\n print(v+a);break\r\n else:a=26*a+ord(c)-64\r\n else:print(\"R%dC%d\"%(b,a))", "\r\nfrom collections import Counter\r\nfrom math import *\r\nfrom sys import *\r\nimport re\r\n\r\ndef iii():\r\n return [int(iii) for iii in input().split()]\r\ndef fff():\r\n return [float(fff) for fff in input.split()]\r\n\r\ndef ii():\r\n return int(input())\r\ndef ff():\r\n return int(input())\r\n\r\ndef count(l):\r\n return dict(Counter(l))\r\n\r\n\r\ndef S1(n):\r\n return n*(n+1)//2\r\n\r\n\r\ndef S3(n):\r\n return pow(S1(n), 2)\r\n\r\nalpha = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\n\r\ndef toalpha(n: int) -> str:\r\n p = 1\r\n c1 = []\r\n while n != 0:\r\n index = n % int(pow(26, p))\r\n c1 += alpha[index - 1]\r\n if alpha[index-1] == 'Z':\r\n n -= 1\r\n n //= 26\r\n c1.reverse()\r\n return \"\".join(c1)\r\n\r\n\r\ndef todigit(n: str) -> int:\r\n s = list(n)\r\n s.reverse()\r\n total = 0\r\n p = 0\r\n for c in s:\r\n total += (alpha.index(c)+1) * pow(26, p)\r\n p += 1\r\n return int(total)\r\n\r\n\r\nfor _ in range(ii()):\r\n line = input()\r\n if re.match(\"R[0-9]+C[0-9]+\", line):\r\n r, c = [int(x) for x in line.replace(\"R\", \"\").replace(\"C\", \" \").split()]\r\n print(toalpha(c)+str(r))\r\n else:\r\n m = re.match(\"([A-Z]+)([0-9]+)\", line)\r\n c = m.group(1)\r\n r = int(m.group(2))\r\n print(f'R{r}C{todigit(c)}')\r\n", "#import math\r\nfrom sys import stdin,stdout\r\n#from heapq import heappop,heappush\r\ninput,print = stdin.readline,stdout.write\r\n\r\n#--------------LinkedList--------------#\r\n'''\r\nclass Node:\r\n def __init__(self, data):\r\n self.data = data \r\n self.next = None \r\n\r\nclass LinkedList:\r\n def __init__(self):\r\n self.head = None\r\n'''\r\n\r\n#--------------data--------------#\r\n#mod=10**9+7\r\n\r\n#--------------Alphabets--------------#\r\n#alphabets='abcdefghijklmnopqrstuvwxyz'\r\nalphabets='ABCDEFGHIJKLMNOPQRSTUVWXYZ'\r\n\r\na=[0]*26\r\nalphadic={}\r\nfor i in range(26):\r\n alphadic[alphabets[i]]=i+1\r\n\r\n\r\n#--------------Functions--------------#\r\n'''\r\ndef gcd(a,b):\r\n if not b:\r\n return a\r\n return hcf(b,a%b)\r\n'''\r\n'''\r\ndef gcdExtended(a, b):\r\n if a == 0 :\r\n return b,0,1\r\n gcd,x1,y1 = gcdExtended(b%a, a)\r\n x = y1 - (b//a) * x1\r\n y = x1\r\n return gcd,x,y\r\n'''\r\n\r\ndef ntoa(n):\r\n s=''\r\n while n>0:\r\n n-=1\r\n s=alphabets[n%26]+s\r\n n//=26\r\n return s\r\n\r\ndef aton(s):\r\n n=0\r\n l=len(s)\r\n ex=1\r\n for i in range(l):\r\n n+=alphadic[s[l-1-i]]*ex\r\n ex*=26\r\n return n\r\n\r\n#--------------Input--------------#\r\n#for _ in range(1):\r\nfor _ in range(int(input())):\r\n #n=int(input())\r\n s=input()\r\n #n,k=map(int,input().split())\r\n #arr=list(map(int,input().split()))\r\n\r\n#--------------Main--------------#\r\n if s[0]=='R' and s[1] not in alphabets and 'C' in s:\r\n for i in range(len(s)-1,-1,-1):\r\n if s[i]=='C':\r\n a=s[1:i]\r\n b=s[i+1:]\r\n break\r\n print(ntoa(int(b))+a+'\\n')\r\n else:\r\n for i in range(len(s)):\r\n if s[i] not in alphabets:\r\n a=s[:i]\r\n b=s[i:]\r\n break\r\n if b[-1]=='\\n':\r\n b=b[:-1]\r\n print('R'+b+'C'+str(aton(a))+'\\n')", "mylist = []\r\nfor n in range(int(input())):\r\n inp = input()\r\n row=col=0\r\n for x in inp:\r\n if '0'<=x<='9':\r\n R = 'R'\r\n row = row*10+int(x)\r\n R = R + str(row)\r\n elif row:\r\n a,b = map(int, inp[1:].split('C'))\r\n col = ''\r\n while b:\r\n b-=1\r\n col = chr(b%26+65)+col\r\n b//=26\r\n output = col+str(a)\r\n mylist.append(output)\r\n break \r\n else:\r\n C = 'C'\r\n col=col*26+(ord(x)-64)\r\n C = C+str(col)\r\n else:\r\n output=R+C\r\n mylist.append(output)\r\nfor out in mylist:\r\n print(out) ", "import math\r\nimport os\r\nimport re\r\nimport sys\r\n\r\n\r\ndef read():\r\n return sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n\r\nletter_map = {\r\n \"A\": 1, \"B\": 2, \"C\": 3, \"D\": 4, \"E\": 5, \"F\": 6, \"G\": 7,\r\n \"H\": 8, \"I\": 9, \"J\": 10, \"K\": 11, \"L\": 12, \"M\": 13, \"N\": 14,\r\n \"O\": 15, \"P\": 16, \"Q\": 17, \"R\": 18, \"S\": 19, \"T\": 20,\r\n \"U\": 21, \"V\": 22, \"W\": 23, \"X\": 24, \"Y\": 25, \"Z\": 26\r\n}\r\n\r\nletter_list = [\"Z\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\", \"K\",\r\n \"L\", \"M\", \"N\", \"O\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\"]\r\n\r\n\r\ndef convert_column_num_to_letter(col):\r\n res = []\r\n while col != 0:\r\n t = col % 26\r\n col = col // 26\r\n if t == 0:\r\n col -= 1\r\n res.insert(0, letter_list[t])\r\n\r\n return \"\".join(res)\r\n\r\n\r\ndef convert_column_letter_to_num(col):\r\n res = 0\r\n t = 1\r\n for i in range(len(col) - 1, -1, -1):\r\n res += t * letter_map[col[i]]\r\n t *= 26\r\n\r\n return res\r\n\r\n\r\nn = int(read())\r\n\r\nfor i in range(0, n):\r\n coor = read()\r\n m = re.match(\"R(\\d+)C(\\d+)\", coor)\r\n if m:\r\n row = m.group(1)\r\n column = m.group(2)\r\n print(\"{}{}\".format(convert_column_num_to_letter(int(column)), row))\r\n else:\r\n m = re.match(\"(\\w+?)(\\d+)\", coor)\r\n if m:\r\n column = m.group(1)\r\n row = m.group(2)\r\n print(\"R{}C{}\".format(row, convert_column_letter_to_num(column)))\r\n", "\r\nfrom re import split\r\n\r\n\r\ndef solution(T):\r\n\ts=str(input())\r\n\talp=0\r\n\tfor i in s:\r\n\t\tif i.isalpha():\r\n\t\t\talp+=1\r\n\tif alp==2 and s.count('R')==1 and s.count('C')==1 and s.index('R')+2<=s.index('C'):\r\n\t\tt=list(s.split('C'))\r\n\t\tc=int(t[-1])\r\n\t\tr=int(t[0][1:])\r\n\t\tt=str()\r\n\t\twhile c:\r\n\t\t\tcar=c%26\r\n\t\t\tc//=26\r\n\t\t\tif car!=0:\r\n\t\t\t\tt=chr(64+car)+t\r\n\t\t\telse:\r\n\t\t\t\tt='Z'+t\r\n\t\t\t\tc-=1\r\n\t\tprint(t,end='')\r\n\t\tprint(r)\r\n\telse:\r\n\t\tc=str()\r\n\t\tfor i in range(len(s)):\r\n\t\t\tif not s[i].isalpha():\r\n\t\t\t\tc=s[:i]\r\n\t\t\t\tr=int(s[i:])\r\n\t\t\t\tbreak\r\n\t\tj=len(c)\r\n\t\tcol=0\r\n\t\tfor i in range(len(c)):\r\n\t\t\tcol+=pow(26,i)*(ord(c[j-i-1])-64)\r\n\t\tprint('R',end='')\r\n\t\tprint(r,end='')\r\n\t\tprint('C',end='')\r\n\t\tprint(col)\r\n\r\n\r\n\r\nTT=1\r\nTT=int(input())\r\nfor T in range(1,TT+1):\r\n\tsolution(T)\r\n\r\n\r\n\"\"\"\r\n\t10/2 0\r\n\t5/2 1\r\n\t2/2 0\r\n\t1/2 1\r\n\r\n\r\n\r\n\"\"\"", "for _ in range(int(input())):\r\n x = input()\r\n a = b = 0\r\n for c in x:\r\n if '0' <= c <= '9':\r\n b = 10 * b + int(c)\r\n elif b:\r\n a, b = x[1:].split('C')\r\n b = int(b)\r\n v = \"\"\r\n while b:\r\n b -= 1\r\n e = b % 26\r\n v = chr(65 + e) + v\r\n b //= 26\r\n print(v + a)\r\n break\r\n else:\r\n g = ord(c)\r\n a = 26 * a + g - 64\r\n else:\r\n print(\"R%dC%d\" % (b, a))\r\n", "n = int(input())\r\n\r\nfor _ in range(n):\r\n x = input()\r\n if x[0] == \"R\" and \"C\" in x and x[1].isdigit():\r\n r = int(x[1:x.index(\"C\")])\r\n c = int(x[x.index(\"C\") + 1:])\r\n s = \"\"\r\n while c:\r\n if c % 26 == 0:\r\n s += \"Z\"\r\n c //= 26\r\n c -= 1\r\n else:\r\n s += chr(ord(\"A\") + c % 26 - 1)\r\n c //= 26\r\n print(f\"{s[::-1]}{r}\")\r\n else:\r\n c = 0\r\n s = \"\"\r\n r = \"\"\r\n for i in x:\r\n if i.isalpha():\r\n s += i\r\n else:\r\n r += i\r\n for j, k in enumerate(s[::-1]):\r\n c += (ord(k) - ord(\"A\") + 1) * 26 ** j\r\n print(f\"R{r}C{c}\")", "for x in range(int(input())):\r\n y = input()\r\n c=d=0\r\n for j in y:\r\n if '0' <= j <= '9':\r\n d=10*d+int(j)\r\n elif d:\r\n c, d = y[1:].split('C')\r\n d = int(d)\r\n v = \"\"\r\n while d:\r\n d-=1\r\n v=chr(65+d%26) + v\r\n d//=26\r\n print(v+c)\r\n break\r\n else:\r\n c=26*c+ord(j)-64\r\n else:\r\n print(\"R%dC%d\" % (d, c))", "n = int(input())\r\nfor _ in range(n):\r\n s = input()\r\n check = s[1:].split('C')\r\n if s[0]=='R' and len(check)==2 and check[0] and check[1] and check[0].isnumeric() and check[1].isnumeric():\r\n col = int(check[1])\r\n newcol = []\r\n while col:\r\n if col%26==0:\r\n newcol.append(26)\r\n col = (col//26) - 1\r\n else:\r\n newcol.append(col%26)\r\n col //= 26\r\n newcol = \"\".join([chr(i-1+ord('A')) for i in newcol[::-1]])\r\n print(newcol + check[0])\r\n else:\r\n i = -1\r\n while s[i]<='9':\r\n i -= 1\r\n row = s[(i+1):]\r\n col = s[:(i+1)]\r\n newcol = [ord(c)-ord('A')+1 for c in col]\r\n col = 0\r\n for c in newcol:\r\n col *= 26\r\n col += c\r\n print('R'+row+'C'+str(col))\r\n", "import re\r\nimport string\r\n\r\nvalue = dict(zip(string.ascii_uppercase, range(26)))\r\nletter = dict(zip(range(0, 26), string.ascii_uppercase))\r\n\r\ndef convert_from_alpha(s):\r\n\r\n out = 0\r\n for c in s:\r\n out = 26*out + (value[c] + 1)\r\n\r\n return out\r\n\r\ndef convert_to_alpha(v):\r\n\r\n out = \"\"\r\n\r\n while v:\r\n v, d = divmod(v - 1, 26)\r\n out = letter[d] + out\r\n\r\n return out\r\n\r\nfor _ in range(int(input())):\r\n\r\n s = input()\r\n if (m := re.match(r\"^(\\D+)(\\d+)$\", s)):\r\n\r\n col = convert_from_alpha(m.group(1))\r\n\r\n print(f\"R{m.group(2)}C{col}\")\r\n\r\n elif (m := re.match(r\"^R(\\d+)C(\\d+)$\", s)):\r\n\r\n col = convert_to_alpha(int(m.group(2)))\r\n\r\n print(f\"{col}{m.group(1)}\")\r\n else:\r\n print(s, \"ERROR\")\r\n\r\n\r\n\r\n\r\n", "n=int(input());d={};dd={}\r\na=[input()for i in range(n)]\r\nfor m in a:\r\n if m[0]==\"R\"and m[1]in\"1234567890\"and m.count('C')==1:\r\n mm=int(m[m.find(\"C\")+1:]);b=''\r\n while mm>0:\r\n if mm%26!=0:\r\n b+=chr(mm%26+64);mm//=26\r\n else:\r\n b+='Z';mm//=26;mm-=1\r\n print(b[::-1]+m[1:m.find(\"C\")])\r\n else:\r\n q_1=str(\"\".join(list(filter(lambda a:ord(a)in range(48,58),m))))\r\n q_0=m.rstrip(q_1);p=[];pp=0\r\n q_0=q_0[::-1]\r\n for x in range(len(q_0)):\r\n pp+=(ord(q_0[x])-64)*(26**x)\r\n print('R'+q_1+'C'+str(pp))", "n=int(input())\r\nfor _ in range(n):\r\n s=input()\r\n if s[0]==\"R\" and s[1].isdigit() and \"C\" in s:\r\n num=int(s[s.index(\"C\")+1:])\r\n out=\"\"\r\n while(num>0):\r\n count=(num-1)%26\r\n out=chr(65+count)+out\r\n num=(num-1)//26\r\n print(out+s[s.index(\"R\")+1:s.index(\"C\")])\r\n else:\r\n out=\"R\"\r\n h=\"\"\r\n for i in s:\r\n if not i.isdigit():\r\n h=i+h\r\n else:\r\n out=out+i\r\n l=0\r\n count=0\r\n for i in h:\r\n l=l+(ord(i)-65+1)*(26**count)\r\n count+=1\r\n out=out+\"C\"+str(l)\r\n print(out)\r\n \r\n \r\n \r\n \r\n \r\n \r\n", "# 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\n# sys.setrecursionlimit(10**6)\r\n\r\n#Input forms\r\n\r\ndef imap(): # Multiple numbers input\r\n return map(int,input().split())\r\n\r\ndef ilist(): # List input \r\n return list(map(int,input().split()))\r\n\r\ndef ilgraph(n,m): # Graph input as Adjacency List\r\n\r\n l = [[]for i in range(n+1)]\r\n for i in range(m):\r\n x,y = imap()\r\n l[x].append(y)\r\n l[y].append(x)\r\n return l\r\n\r\ndef iagraph(n,m): # Graph input as Adjacency Matrix\r\n l = [[0 for i in range(n+1)]for i in range(n+1)]\r\n for i in range(m):\r\n x,y = imap()\r\n l[x][y] = 1\r\n l[y][x] = 1\r\n return l\r\n\r\n# Common functions\r\n\r\ndef freq(l): # Returns count of a number in a list/string // O(nlog(n)) //\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\n# Math and number Theory :\r\n\r\ndef is_pow2(x): #Checks if a number is a power of 2 // O(1) //\r\n return max(1-(x&(x-1)),0)\r\n\r\ndef lgcd(l): # Returns gcd of a list // O(nlog(n)) //\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): # Returns an array with Prime numbers upto num // O(nlog(log(n))) //\r\n prime = [True for i in range(num+1)]\r\n Highest_Prime = [0 for i in range(num+1)] # Returns an array with the highest prime factor of each i between 0 and Num \r\n Lowest_Prime = [0 for i in range(num+1)] # Returns an array with the lowest prime factor of each i between 0 and Num\r\n prime[0] = prime[1] = False\r\n p = 2\r\n while (p <= num):\r\n if (prime[p] == True):\r\n Lowest_Prime[p] = p\r\n Highest_Prime[p] = p\r\n for i in range(2*p, num+1, p):\r\n prime[i] = False\r\n Highest_Prime[i] = p\r\n if Lowest_Prime[i] == 0:\r\n Lowest_Prime[i] = p\r\n p += 1\r\n # print(prime,'\\n',Highest_Prime,'\\n',Lowest_Prime) #Checker\r\n # return Lowest_Prime\r\n # return Highest_Prime\r\n return prime\r\n\r\ndef PrimeFactors(num,Prime_array):# Returns a dictionary with prime factors mapped with their respective powers // O(nlogn) //\r\n \r\n # COmplexity is O(logn) for this code, but this requires that u have a Prime array which could be highest or lowest prime which can be calculated from the prev Sieve of Erastothenes) hence over complexity is O(nlogn)\r\n \r\n d = {}\r\n while num != 1: \r\n x = Prime_array[num]\r\n d[x] = d.get(x,0)+1\r\n num//=x\r\n return d\r\n\r\n# Binary Arithmetic \r\n\r\ndef bin_left(p,x): #Returns the index of max element less than x and -1 if all elements r greater than x // O(logn) //\r\n n = len(p)\r\n l,r = 0,n-1\r\n if p[0]>x:\r\n return -1\r\n while l<=r:\r\n mid = (l+r)//2\r\n if p[mid] <= x:\r\n if mid != n-1:\r\n if p[mid+1]>x:\r\n break\r\n else:\r\n l = mid+1\r\n else:\r\n mid = n-1\r\n break\r\n else:\r\n r = mid-1\r\n return mid\r\n\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\ndef bin_right(p,x): #Returns the index of min element greater than x and n if all elements r less than x // O(logn) //\r\n n = len(p)\r\n l,r = 0,n-1\r\n if p[-1]<x:\r\n return n\r\n\r\n while l<=r:\r\n mid = (l+r)//2\r\n if p[mid] >= x:\r\n if mid != 0:\r\n if p[mid-1]<x:\r\n break\r\n else:\r\n r = mid-1\r\n else:\r\n mid = 0\r\n break\r\n else:\r\n l = mid+1\r\n return mid\r\n\r\ndef bin_sqrt(x): # Returns floor of sqrt // O(logx) //\r\n if x == 0 or x == 1:\r\n return x\r\n l = 1\r\n r = x\r\n while l<=r:\r\n mid = (l+r)/2\r\n y = mid*mid\r\n if y>x:\r\n r = mid-1\r\n elif y == x:\r\n return mid\r\n else:\r\n if ((mid+1)*(mid+1))>x:\r\n return mid\r\n else:\r\n l = mid+1\r\n \r\ndef bin_exp(a,b,mod): #Returns (a^b) mod m where 0 <= a,b <= 10^18 // O(log(b)) //\r\n ans = 1\r\n while b>0:\r\n if b&1:\r\n ans = (ans*a)% mod\r\n a = (a*a)%mod\r\n b >>= 1\r\n return ans\r\n\r\ndef bin_to_dec(s): # Takes a binary string and returns its decimal value\r\n\r\n x = 0\r\n n = len(s)\r\n for i in range(n):\r\n x += int(s[n-i-1])*(2**i)\r\n return x\r\n\r\n# Graph Algos\r\n\r\ndef dfs(graph,ver,vis): # DFS on a graph\r\n vis[ver] = True\r\n print(ver,end = ' ')\r\n for child in graph[ver]:\r\n if vis[child]:\r\n continue\r\n dfs(graph,child,vis)\r\n \r\n\r\n\r\n# Starting off; \r\n\r\nt = int(input())\r\nfor _ in range(t):\r\n s = input()\r\n n = len(s)\r\n if s[0] != 'R':\r\n r = 0\r\n for i in range(n):\r\n if s[i].isalpha():\r\n r *= 26\r\n r += ord(s[i])-ord('A')+1\r\n else:\r\n break\r\n print('R'+str(s[i:])+'C'+str(r))\r\n else:\r\n c = 0\r\n for i in range(n-1):\r\n if s[i].isalpha() and s[i+1].isdigit():\r\n c += 1\r\n if c == 1:\r\n r = 0\r\n for i in range(n):\r\n if s[i].isalpha():\r\n r *= 26\r\n r += ord(s[i])-ord('A')+1\r\n else:\r\n break\r\n print('R'+str(s[i:])+'C'+str(r))\r\n else:\r\n l = s[1:].split('C')\r\n # print(l)\r\n r,t = int(l[1]),l[0]\r\n q = ''\r\n while (r>0):\r\n x = (r%26)+ord('A')-1\r\n if r%26 == 0:\r\n r = r//26-1\r\n x += 26\r\n else:\r\n r//=26\r\n q+=chr(x)\r\n print(q[::-1]+t)\r\n\r\n\r\n\r\n###################################################### By Shri ##############################################################\r\n", "\r\n# Online Python - IDE, Editor, Compiler, Interpreter\r\nimport re\r\ndef check_excel_type(txt):\r\n if re.search(\"^R\\d+C\\d+\", txt):\r\n return 1\r\n elif re.search(\"^[A-Z]+\\d+$\", txt):\r\n return 2\r\n else:\r\n return 0\r\n\r\ndef convert_base(num, to_base=10, from_base=10):\r\n # first convert to decimal number\r\n n = int(num, from_base) if isinstance(num, str) else num\r\n # now convert decimal to 'to_base' base\r\n alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\n res = \"\"\r\n while n > 0:\r\n n,m = divmod(n, to_base)\r\n #print(n, m)\r\n if m == 0:\r\n n = n - 1\r\n res += alphabet[m - 1]\r\n return res[::-1]\r\n \r\ndef convert(syll):\r\n return int(syll, 36) - 9\r\n \r\n \r\ndef convert_reverse(alph_num):\r\n sum = i = 0\r\n for part in map(convert, (reversed(list(alph_num)))):\r\n sum += part * pow(26, i)\r\n i += 1\r\n return sum\r\n\r\ndef conver_to_the_other(txt):\r\n curr_type = check_excel_type(txt)\r\n if curr_type == 1:\r\n print(convert_base(re.search(\"C\\d+\", txt).group(0)[1:], 26) + re.search(\"R\\d+\", txt).group(0)[1:])\r\n if curr_type == 2:\r\n print(\"R\" + re.search(\"\\d+\", txt).group(0) + \"C\" + str(convert_reverse(re.search(\"^[A-Z]+\", txt).group(0))))\r\n\r\n\r\namount = int(input())\r\nlst = []\r\nfor i in range(0, amount):\r\n ele = input()\r\n lst.append(ele) \r\n \r\nfor object in map(str, lst):\r\n conver_to_the_other(object)\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\n# from math import gcd as gcd, isqrt\r\n# from collections import deque\r\n# import bisect #-->For bisect.bisect_left=lower_bound and bisect_right=upper_bound\r\n\r\nt = 1\r\nt = int(input())\r\nfor _ in range(t):\r\n s = input().strip()\r\n if (s[1].isdigit() and 'R' in s and 'C' in s):\r\n start = end = \"\"\r\n i = 1\r\n while (s[i] != 'C'):\r\n i += 1\r\n end = s[1:i]\r\n col = int(s[i+1:])\r\n while (col > 0):\r\n x = col % 26\r\n if (x): \r\n start = chr(x + 64) + start\r\n else: \r\n start = 'Z' + start\r\n col -= 26\r\n col //= 26\r\n print(start + end)\r\n else:\r\n start = \"R\"\r\n col = 0\r\n s1 = \"\"\r\n for i in s:\r\n if (i.isdigit()):\r\n start += i\r\n else:\r\n s1 += i\r\n for i in s1:\r\n col *= 26\r\n col += ord(i) - 64\r\n print(start + \"C\" + str(col))", "import re\n\n\ndef encode2(num):\n result = \"\"\n num -= len(str(num)) - 1\n while num > 0:\n if num % 26 == 0:\n resu\n result += chr((num + 25) % 26 + ord('A'))\n num //= 26\n return result\n\ndef encode(num):\n if num == 0:\n return \"\"\n if num % 26 == 0:\n return encode(num // 26 - 1) + \"Z\"\n return encode(num // 26) + chr(num % 26 + ord('A') - 1)\n\ndef decode(colstr):\n return sum([(ord(a) - ord('A') + 1) * (26 ** i) for i, a in enumerate(reversed(colstr))])\n\nn = int(input())\n\nfor _ in range(n):\n text = input()\n m = re.search('R(\\d+)C(\\d+)', text)\n if m:\n row = m.group(1)\n col = int(m.group(2))\n print(f'{encode(col)}{row}')\n else:\n m = re.search('([A-Z]+)(\\d+)', text)\n if m:\n col = m.group(1)\n row = m.group(2)\n col = decode(col)\n\n print(f'R{row}C{col}')\n", "import sys\r\n \r\n# Fast input\r\ninput = sys.stdin.readline\r\n \r\n# Fast output\r\ndef print(*args, **kwargs):\r\n sep = kwargs.get('sep', ' ')\r\n end = kwargs.get('end', '')\r\n file = kwargs.get('file', sys.stdout)\r\n flush = kwargs.get('flush', False)\r\n output = sep.join(map(str, args)) + end\r\n file.write(output)\r\n if flush:\r\n file.flush()\r\ndef calculate(x):\r\n x=x[::-1]\r\n r=0\r\n c=0\r\n for i in x:\r\n r+=(ord(i)-ord('A')+1)*26**c\r\n c+=1\r\n return r\r\ndef calc(x):\r\n s=\"\"\r\n while x!=0:\r\n if x%26==0:\r\n s+='Z'\r\n x=(x-1)//26\r\n else:\r\n s+=chr(x%26+ord('A')-1)\r\n x=x//26\r\n return s[::-1]\r\nfor _ in range(int(input())):\r\n s=input()\r\n if s[0]=='R' and ord(s[1])-ord('0') in range(0,10) and \"C\" in s:\r\n y=s.index('C')\r\n ret=calc(int(s[y+1:]))+s[1:y]\r\n print(ret,end=\"\\n\")\r\n else:\r\n z=0\r\n for i in s:\r\n if ord(s[z])-ord('0') in range(0,10):\r\n break\r\n else:\r\n z+=1\r\n ret='R'+s[z:-1]+'C'+str(calculate(s[0:z]))\r\n print(ret,end=\"\\n\")", "from itertools import permutations\r\nimport math\r\n\r\n\r\ndef fs(string):\r\n alpha = []\r\n num = []\r\n for x in string:\r\n if x.isalpha():\r\n alpha.append(x)\r\n else:\r\n num.append(x)\r\n if num[-1] == '\\n':\r\n num.pop()\r\n summ = 0\r\n for x in range(len(alpha)):\r\n summ += (26 ** (len(alpha) - x - 1)) * (ord(alpha[x]) - ord('A') + 1)\r\n ans = \"R\" + \"\".join(num) + \"C\" + str(summ)\r\n print(ans)\r\n\r\n\r\ndef sf(string):\r\n string = list(string)\r\n if string[-1] == '\\n':\r\n string.pop()\r\n num = []\r\n while string[-1] != 'C':\r\n num.append(string[-1])\r\n string.pop()\r\n string.pop()\r\n num = int(\"\".join(reversed(num)))\r\n # print(num)\r\n string = \"\".join(string[1:])\r\n val = \"\"\r\n while num:\r\n num -= 1\r\n val = chr(65 + num % 26) + val\r\n num //= 26\r\n ans = val + string\r\n print(ans)\r\n\r\n\r\ndef solve():\r\n s = input()\r\n a = []\r\n for x in s:\r\n if x.isalpha():\r\n a.append(x)\r\n if \"\".join(a) == \"RC\" and \"RC\" not in s:\r\n sf(s)\r\n else:\r\n fs(s)\r\n\r\n\r\nif __name__ == '__main__':\r\n for _ in range(int(input())):\r\n solve()", "# LUOGU_RID: 119110710\nimport re\r\n\r\ndef solve(s):\r\n if re.match(r'R(\\d+)C(\\d+)', s):\r\n r, c = map(int, re.findall(r'\\d+', s))\r\n res = ''\r\n while c:\r\n c -= 1\r\n res = chr(c % 26 + ord('A')) + res\r\n c //= 26\r\n return res + str(r)\r\n else:\r\n r = re.findall(r'\\d+', s)[0]\r\n c = re.findall(r'[A-Z]+', s)[0]\r\n res = 0\r\n for i in c:\r\n res = res * 26 + ord(i) - ord('A') + 1\r\n return 'R' + r + 'C' + str(res)\r\n\r\nn = int(input().strip())\r\nfor _ in range(n):\r\n s = input().strip()\r\n print(solve(s))\r\n", "alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\nfor i in range(int(input())):\r\n a = input()\r\n if \"R\" in a and \"C\" in a and a[1] in \"1234567890\":\r\n col = int(a[a.find(\"C\") + 1:])\r\n row = a[1:a.find(\"C\")]\r\n res = \"\"\r\n while col != 0:\r\n res += alphabet[col % 26 - 1]\r\n col -= 1\r\n col //= 26\r\n print(res[::-1] + row)\r\n else:\r\n col = \"\"\r\n row = \"\"\r\n for j in a:\r\n if j in alphabet:\r\n col += j\r\n else:\r\n row += j\r\n res = 0\r\n for k, j in enumerate(col[::-1]):\r\n res += (alphabet.find(j) + 1) * 26 ** k\r\n print('R' + row + \"C\" + str(res))\r\n", "n = int (input ())\r\nalpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\r\nfor i in range (n):\r\n initial = input ()\r\n alphapos = []\r\n for i, char in enumerate (list (initial)):\r\n if char.isalpha ():\r\n alphapos.append (i)\r\n if len (alphapos) == 2 and alphapos [0] + 1 != alphapos [1]:\r\n rpos = initial.find ('R')\r\n cpos = initial.find ('C')\r\n xi = int (initial [cpos + 1 : ]) - 1\r\n y = int (initial [rpos + 1 : cpos])\r\n xf = ''\r\n while xi >= 0:\r\n xf = alpha [xi % 26] + xf\r\n xi = int (xi / 26) - 1\r\n final = xf + str (y)\r\n else:\r\n xi = initial [ : alphapos [-1] + 1]\r\n y = int (initial [alphapos [-1] + 1 : ])\r\n xf = 0\r\n for char in xi:\r\n xf *= 26\r\n xf += alpha.find (char) + 1\r\n final = 'R' + str (y) + 'C' + str (xf)\r\n print (final)", "import sys\r\n\r\n\r\nisdigit = lambda c: ord( '0') <= ord(c) <= ord( '9')\r\nisualpha = lambda c: ord( 'A') <= ord(c) <= ord( 'Z')\r\n\r\ndef splitDA( str ):\r\n\r\n for i in range( len(str) - 1 ):\r\n if ( True == isdigit( str[i] )\r\n and True == isualpha( str[i+1] ) ):\r\n return [ str[0:i+1], str[i+1: ] ]\r\n else:\r\n return [str]\r\n\r\ndef splitAD( str ):\r\n\r\n for i in range( len(str) - 1 ):\r\n if ( True == isualpha( str[i] )\r\n and True == isdigit( str[i+1] ) ):\r\n return [ str[0:i+1], str[i+1: ] ]\r\n else:\r\n return [str]\r\n\r\n\r\ndef NumberToExcelNumSystem(n):\r\n\r\n b = ord( 'Z' ) - ord( 'A') + 1\r\n\r\n letters = ''\r\n while n:\r\n m = (n - 1) % b;\r\n letters += chr( ord( 'A' ) + m )\r\n n = ( n - m )//b\r\n\r\n return letters[::-1]\r\n\r\ndef ExcelNumSystemToNumber(s):\r\n\r\n b = ord( 'Z' ) - ord( 'A') + 1\r\n\r\n num = 0\r\n for i in range( len(s) ):\r\n letter = s[i]\r\n num = num*26 + ord( letter ) - ord( 'A' ) + 1\r\n\r\n return num\r\n\r\n \r\ndef main():\r\n\r\n input = sys.stdin\r\n #input = open( 'SampleInput.txt', 'r' )\r\n\r\n ln = input.readline().strip()\r\n n = int( ln )\r\n for i in range( n ):\r\n ln = input.readline().strip()\r\n groups = splitDA( ln )\r\n #print( ln, groups )\r\n if len( groups) == 1:\r\n colStr, rowNumber = splitAD( groups[0] )\r\n res = 'R' + rowNumber + 'C' + str( ExcelNumSystemToNumber( colStr ) ) \r\n else:\r\n res = NumberToExcelNumSystem( int( groups[1][1:] ) ) + groups[0][1:]\r\n print( res )\r\n\r\nif __name__ == \"__main__\":\r\n main() \r\n \r\n\r\n\r\n \r\n", "n = int(input()) \r\n\r\ndef convert1(col):\r\n l = len(col) \r\n val = 0 \r\n for i in range(l):\r\n val += (ord(col[i]) - ord('A') + 1) * (26 ** (l - i - 1)) \r\n return val \r\ndef convert2(col):\r\n ans = ''\r\n col = int(col)\r\n while col != 0:\r\n x = col % 26\r\n if x==0:\r\n col //= 26\r\n col -= 1\r\n ans += \"Z\"\r\n else:\r\n ans += chr(64+x)\r\n col //= 26\r\n return ans[::-1]\r\n\r\nfor _ in range(n):\r\n s = input()\r\n r = s.find('R') \r\n c = s.find('C') \r\n type = 0 \r\n if r != -1 and c != -1:\r\n for i in range(r, c + 1):\r\n if s[i].isdigit():\r\n type = 1 \r\n break \r\n col = ''\r\n row = ''\r\n if not type:\r\n for c in s:\r\n if c.isalpha():\r\n col += c \r\n else:\r\n row += c \r\n print(\"R\"+row+\"C\"+str(convert1(col)))\r\n else:\r\n row = s[r + 1: c] \r\n col = s[c + 1:] \r\n print(convert2(col) + row) ", "import re\r\nimport math\r\n\r\nnumbersMatch = \"R[0-9]+C[0-9]+\"\r\nlettersMatch = \"[A-Z]+[0-9]+\"\r\nnumOfChars = 26\r\n\r\ndef value(c):\r\n return ord(c) - ord('A') + 1\r\n\r\ndef letter(v):\r\n return chr( ord('A') - 1 + v)\r\n\r\ndef fromLettersToNumber(s):\r\n m = re.search(\"[A-Z]+\", s)\r\n cols = m.group()\r\n m = re.search(\"[0-9]+\", s)\r\n rows = m.group()\r\n\r\n sum = 0\r\n index = len(cols)\r\n for c in cols:\r\n index -= 1\r\n v = value(c)\r\n sum += v * (numOfChars ** index)\r\n\r\n return 'R{}C{}'.format(rows, sum)\r\n\r\ndef fromNumberToLetters(s):\r\n m = re.search(\"C[0-9]+\", s)\r\n cols = m.group()[1:]\r\n m = re.search(\"R[0-9]+\", s)\r\n rows = m.group()[1:]\r\n\r\n v = int(cols)\r\n ret = \"\"\r\n while v > 0:\r\n r = v % numOfChars\r\n v = v // numOfChars\r\n if r == 0:\r\n v -= 1\r\n r = 26\r\n ret = letter(r) + ret\r\n\r\n return '{}{}'.format(ret, rows)\r\n\r\nn = int(input())\r\n\r\nfor i in range(n):\r\n new = input()\r\n if re.search(numbersMatch, new):\r\n print(fromNumberToLetters(new))\r\n else:\r\n print(fromLettersToNumber(new))\r\n", "n = int(input())\nalpha = \"ZABCDEFGHIJKLMNOPQRSTUVWXY\"\nfor _ in range(n):\n s = input()\n ft = 1 if s[0] == \"R\" and s[1].isdigit() and \"C\" in s else 2\n\n if ft == 1:\n idx = s.index(\"C\")\n r = (s[1:idx])\n c = int(s[idx+1:])\n cs = \"\"\n while c > 0:\n cs = alpha[c % 26] + cs\n if c % 26 == 0: c-=1\n c = c//26\n print(cs+r)\n else:\n for i in range(len(s)):\n if s[i].isdigit():\n break\n cs = s[:i]\n r = s[i:]\n csi = 0\n for c in cs:\n idx = alpha.index(c)\n idx = idx if idx != 0 else 26\n csi *= 26\n csi+=idx\n print(\"R\"+r+\"C\"+str(csi))\n\t \t \t\t\t\t \t\t\t \t \t\t\t\t\t\t\t\t\t \t \t\t\t", "from itertools import groupby\r\n\r\ndef fun(num):\r\n\tif isinstance(num, int):\r\n\t\tresult = \"\"\r\n\t\tn = num\r\n\t\tr = num\r\n\t\twhile(True):\r\n\t\t\tn = r\r\n\t\t\tm = n%26\r\n\t\t\tr = n//26\r\n\t\t\tif(m==0):\r\n\t\t\t\tm = 26\r\n\t\t\t\tr = r-1\r\n\t\t\tresult = ''.join([chr(m+64), result])\r\n\t\t\tif r == 0:\r\n\t\t\t\tbreak\r\n\t\treturn result\r\n\telif isinstance(num, str):\r\n\t\tresult = 0\r\n\t\tx = 0\r\n\t\tfor i in num[::-1]:\r\n\t\t\tresult += (ord(i) - 64)*(26**x)\r\n\t\t\tx += 1\r\n\t\treturn result\r\n\telse:\r\n\t\treturn None\r\n\r\nn = int(input())\r\nB = '[A-Z]+[0-9]+'\r\n\r\nfor i in range(n):\r\n\tm = input()\r\n\tA = [''.join(list(g)) for k, g in groupby(m, key=lambda x: x.isdigit())]\r\n\tif len(A) == 4:\r\n\t\tprint(\"%s%s\" % (fun(int(A[3])),A[1]))\r\n\telif len(A) == 2:\r\n\t\tprint(\"R%sC%s\" % (A[1],fun(A[0])))\r\n\r\n\r\n\r\n", "import sys\r\ninput=sys.stdin.readline\r\ninf=float(\"inf\")\r\nfrom itertools import permutations\r\nfrom collections import defaultdict as dd\r\nfrom bisect import bisect_left,bisect_right\r\nfrom math import comb as C\r\nMOD=10**9+7\r\n\r\nfor _ in range(int(input())):\r\n x=str(input()).strip();n=len(x);L=\"ZABCDEFGHIJKLMNOPQRSTUVWXY\";type=1;found_number=False\r\n for ch in x:\r\n if found_number and not ch.isdigit():type=2;break\r\n if ch.isdigit():found_number=True\r\n if type==1:\r\n r=\"\";c=0;\r\n for ch in x:\r\n if \"0\"<=ch<=\"9\":r+=ch\r\n else:c=(c*26)+(ord(ch)-ord(\"A\")+1)\r\n print(\"R\"+r+\"C\"+str(c))\r\n # for ch in x:\r\n # if ch.isdigit():r=r*10+int(ch)\r\n # else:c+=ch\r\n # power=0;c=c[::-1]\r\n # for ch in c:\r\n # col+=(ord(ch)-ord('A')+1)*(26**power);power+=1\r\n # print(\"R\"+str(r)+\"C\"+str(col))\r\n else:\r\n r=0;c=0;isrow=False;col=\"\"\r\n for ch in x:\r\n if ch==\"R\":isrow=True\r\n if ch==\"C\":isrow=False\r\n if ch.isdigit():\r\n if isrow:r=r*10+int(ch)\r\n else:c=c*10+int(ch)\r\n while c>0:\r\n x=(c-1)%26\r\n col=chr(ord(\"A\")+x)+col\r\n c=(c-1)//26\r\n print(col+str(r))", "import re\r\nalphabet_list = [\"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\nspread_sheet_list = []\r\nnumber_input = int(input())\r\nfor i in range(0, number_input):\r\n temp = input()\r\n spread_sheet_list.append(temp)\r\nfor i in range(0, number_input):\r\n if re.findall(\"[0-9]C[0-9]\", spread_sheet_list[i]):\r\n temp = spread_sheet_list[i].split(\"C\")\r\n row_part = temp[0][1:len(temp[0])]\r\n column_part = int(temp[1])\r\n column_part_string = \"\"\r\n while column_part > 0:\r\n temp_column_part = column_part % 26\r\n if temp_column_part == 0:\r\n column_part_string += \"Z\"\r\n column_part -= 26\r\n else:\r\n column_part_string += alphabet_list[temp_column_part - 1]\r\n column_part -= temp_column_part\r\n column_part = column_part // 26\r\n column_string = column_part_string[::-1]\r\n print(column_string + row_part)\r\n else:\r\n column_list = [char for char in spread_sheet_list[i] if char.isalpha()]\r\n column_string = \"\".join(column_list)\r\n row_list = [char for char in spread_sheet_list[i] if char.isdigit()]\r\n row_string = \"R\" + \"\".join(row_list)\r\n column_value = 0\r\n j = 0\r\n for item in column_string:\r\n column_value += (alphabet_list.index(item) + 1) * (26 ** (len(column_string) - j - 1))\r\n j += 1\r\n column_value = \"C\" + str(column_value)\r\n print(row_string + column_value)\r\n \r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n", "# LUOGU_RID: 97342928\nn=int(input().strip())\r\ndef col_to_num(col):\r\n carry=0\r\n res=0\r\n while col:\r\n cur=col[-1]\r\n res+=(ord(cur)-64)*26**carry\r\n col=col[:-1]\r\n carry+=1\r\n return str(res)\r\n \r\ndef num_to_col(num):\r\n num=int(num)\r\n res=''\r\n while num:\r\n mod=num%26\r\n if mod==0:\r\n res='Z'+res\r\n num=num // 26 - 1\r\n else:\r\n num //= 26\r\n res = chr(mod+64) + res\r\n return res\r\ndef xy_to_excel(string):\r\n y = string.split('C')[-1]\r\n x = string.split('C')[0].split('R')[-1]\r\n return num_to_col(y)+x\r\ndef excel_to_xy(string):\r\n for i in range(len(string)):\r\n if '1'<=string[i]<='9':\r\n break\r\n col=string[:i]\r\n row=string[i:]\r\n return 'R'+row+'C'+col_to_num(col)\r\ndef is_xy(string):\r\n if string[0]=='R' and '1'<=string[1]<='9':\r\n for s in string[2:]:\r\n if s=='C':\r\n return True\r\n return False\r\n \r\nfor _ in range(n):\r\n string=input().strip()\r\n if is_xy(string):\r\n print(xy_to_excel(string))\r\n else:\r\n print(excel_to_xy(string))", "import re\n\n\ndef number_to_letter(number):\n number -= 1\n i = 1\n while 26**i <= number:\n number -= 26**i\n i += 1\n a = []\n for i in range(i):\n a.append(number % 26)\n number //= 26\n return \"\".join(chr(ord(\"A\") + x) for x in reversed(a))\n\n\ndef letter_to_number(letter):\n base = sum(26**i for i in range(1, len(letter)))\n number = 0\n for x in letter:\n number = number * 26 + ord(x) - ord(\"A\")\n return base + number + 1\n\n\nn = int(input())\nfor _ in range(n):\n s = input()\n m = re.fullmatch(r\"R(\\d+)C(\\d+)\", s)\n if m is not None:\n print(number_to_letter(int(m.groups()[1])) + m.groups()[0])\n continue\n m = re.fullmatch(r\"(\\D+)(\\d+)\", s)\n print(\"R\" + m.groups()[1] + \"C\" + str(letter_to_number(m.groups()[0])))\n", "import re\r\n\r\ndef get_column_representation(column):\r\n result = ''\r\n while column > 0:\r\n rem = (column - 1) % 26\r\n result = chr(rem + 65) + result\r\n column = (column - 1) // 26\r\n return result\r\n\r\ndef get_column_number(column):\r\n result = 0\r\n for char in column:\r\n result = result * 26 + (ord(char) - 64)\r\n return result\r\n\r\nn = int(input())\r\nresults = []\r\n\r\nfor _ in range(n):\r\n coordinates = input()\r\n\r\n if re.match(r'^[A-Z]+\\d+$', coordinates):\r\n # Convert Excel column representation to RXCY\r\n column_rep, row = re.findall(r'[A-Z]+|\\d+', coordinates)\r\n column = get_column_number(column_rep)\r\n results.append(f\"R{row}C{column}\")\r\n else:\r\n # Convert RXCY to Excel column representation\r\n row, column = re.findall(r'\\d+', coordinates)\r\n column = int(column)\r\n column_rep = get_column_representation(column)\r\n results.append(column_rep + row)\r\n\r\nprint('\\n'.join(results))", "for _ in range(int(input())):\r\n flag = False\r\n R = 0\r\n C = 0\r\n t = 1\r\n for x in input():\r\n if x.isalpha():\r\n if flag:\r\n t = 2\r\n C = 0\r\n continue\r\n \r\n C = C * 26 + ord(x) - ord('A') + 1\r\n \r\n elif x.isdigit:\r\n flag = True\r\n if t == 1:\r\n R = R * 10 + ord(x) - ord('0')\r\n else:\r\n C = C * 10 + ord(x) - ord('0')\r\n \r\n if t == 1:\r\n print(f'R{R}C{C}')\r\n else:\r\n s = ''\r\n C -= 1\r\n while C >= 0:\r\n s += chr(C%26 + ord('A'))\r\n C //= 26\r\n C -= 1\r\n print(s[::-1]+str(R))", "import re\r\n\r\n\r\nPATTERN_1 = re.compile(r\"([A-Z]+)([0-9]+)\")\r\nPATTERN_2 = re.compile(r\"R(\\d+)C(\\d+)\")\r\n\r\n\r\ndef char_value(char: str) -> int:\r\n return ord(char) - ord(\"A\") + 1\r\n\r\n\r\ndef column_label_to_index(label: str) -> int:\r\n result = 0\r\n for index, char in enumerate(reversed(label)):\r\n result += pow(26, index) * char_value(char)\r\n\r\n return result\r\n\r\n\r\ndef to_char(value: int) -> str:\r\n if value == 0:\r\n return \"Z\"\r\n\r\n return chr(value + ord(\"A\") - 1) # 1 -> A\r\n\r\n\r\ndef index_to_column_label(index: int) -> str:\r\n result = \"\"\r\n while index > 0:\r\n last = index % 26\r\n result = to_char(last) + result\r\n index //= 26\r\n if last == 0:\r\n index -= 1\r\n\r\n return result\r\n\r\n\r\nresults = []\r\nfor _ in range(int(input())):\r\n coordinates = input()\r\n if match := PATTERN_1.fullmatch(coordinates):\r\n column = column_label_to_index(match.group(1))\r\n row = match.group(2)\r\n results.append(f\"R{row}C{column}\")\r\n\r\n elif match := PATTERN_2.fullmatch(coordinates):\r\n row = match.group(1)\r\n column = index_to_column_label(int(match.group(2)))\r\n results.append(column + row)\r\n\r\n else:\r\n raise ValueError(f\"Invalid coordinates {coordinates}\")\r\n\r\n\r\nprint(\"\\n\".join(results))\r\n", "import re\r\ndef Turn_to_number(let):\r\n answer=0\r\n numbers={\r\n \"A\":1 ,\r\n \"B\":2 ,\r\n \"C\":3 ,\r\n \"D\":4 ,\r\n \"E\":5 ,\r\n \"F\":6 ,\r\n \"G\":7 ,\r\n \"H\":8 ,\r\n \"I\":9 ,\r\n \"J\":10 ,\r\n \"K\":11 ,\r\n \"L\":12 ,\r\n \"M\":13 ,\r\n \"N\":14 ,\r\n \"O\":15 ,\r\n \"P\":16 ,\r\n \"Q\":17 ,\r\n \"R\":18 ,\r\n \"S\":19 ,\r\n \"T\":20 ,\r\n \"U\":21 ,\r\n \"V\":22 ,\r\n \"W\":23 ,\r\n \"X\":24 ,\r\n \"Y\":25 ,\r\n \"Z\":26}\r\n z=len(let)-1\r\n for i in let:\r\n answer=answer+numbers[i]*(26**(z))\r\n z-=1\r\n return answer\r\n######################################################################### \r\ndef Turn_to_letters(num):\r\n letters={\r\n 1:\"A\" ,\r\n 2:\"B\" ,\r\n 3:\"C\" ,\r\n 4:\"D\" ,\r\n 5:\"E\" ,\r\n 6:\"F\" ,\r\n 7:\"G\" ,\r\n 8:\"H\" ,\r\n 9:\"I\" ,\r\n 10:\"J\" ,\r\n 11:\"K\" ,\r\n 12:\"L\" ,\r\n 13:\"M\" ,\r\n 14:\"N\" ,\r\n 15:\"O\" ,\r\n 16:\"P\" ,\r\n 17:\"Q\" ,\r\n 18:\"R\" ,\r\n 19:\"S\" ,\r\n 20:\"T\" ,\r\n 21:\"U\" ,\r\n 22:\"V\" ,\r\n 23:\"W\" ,\r\n 24:\"X\" ,\r\n 25:\"Y\" ,\r\n 26:\"Z\" }\r\n answer=\"\"\r\n sys_let=[]\r\n while num!=0:\r\n sys_let.append(num%26)\r\n num=num//26\r\n sys_let.reverse()\r\n\r\n\r\n while sys_let.count(0)!=0 and sys_let[0]!=0:\r\n var=sys_let.index(0)\r\n sys_let[var]=26\r\n sys_let[var-1]-=1\r\n if sys_let[0]==0:\r\n sys_let.remove(0)\r\n\r\n \r\n for i in sys_let :\r\n if i!=0:\r\n answer=answer+letters[i]\r\n return answer \r\n####################################### \r\nn=int(input())\r\nfor i in range(n):\r\n\ts=input()\r\n\tm=re.match('R(\\d+)C(\\d+)',s)\r\n\r\n\tif m is not None:\r\n\t\tprint('%s%s'%(Turn_to_letters(int(m.group(2))),m.group(1)))\r\n\telse:\r\n\t\tm=re.match('([A-Z]+)(\\d+)',s)\r\n\t\tprint('R%dC%d'%(int(m.group(2)),Turn_to_number(m.group(1))))", "def firstDigitIndex(s):\r\n\tindex = -1\r\n\tfor i in range(len(s)):\r\n\t\tif ((s[i]).isdigit()):\r\n\t\t\tindex = i\r\n\t\t\tbreak\r\n\treturn index\r\n\r\ndef base26ToBase10(base26):\r\n\tbase10 = 0\r\n\tfor i in range(len(base26)):\r\n\t\tbase10 += (ord(base26[i]) - 64) * (26 ** (len(base26) - i - 1))\r\n\treturn base10\r\n\r\ndef base10ToBase26(base10):\r\n\tbase26 = \"\"\r\n\twhile (base10 > 0):\r\n\t\tbase26 = chr((base10 - 1) % 26 + 65) + base26\r\n\t\tbase10 = (base10 - 1) // 26\r\n\treturn base26\r\n\r\nfor _ in range(int(input())):\r\n\ts = input()\r\n\tif s[0] == 'R' and s[1].isdigit() and 'C' in s:\r\n\t\t# R23C55 format\r\n\t\tc_index = s.find('C')\r\n\t\tr = int(s[1:c_index])\r\n\t\tc = int(s[(c_index + 1):])\r\n\t\tprint(base10ToBase26(c) + str(r))\r\n\telse:\r\n\t\t# Letters in base 26 + integer\r\n\t\tint_start_index = firstDigitIndex(s)\r\n\t\tbase_26_column = s[:int_start_index]\r\n\t\trow = s[int_start_index:]\r\n\t\tbase_10_column = base26ToBase10(base_26_column)\r\n\t\tprint('R' + row + 'C' + str(base_10_column))", "def to_number(s: str) -> int:\r\n res = sum(pr[i] for i in range(len(s)))\r\n for i, c in enumerate(reversed(s)):\r\n res += (ord(c)-ord('A')) * 26**i\r\n return res\r\n\r\ndef to_alpha(n: int) -> str:\r\n res = ''\r\n for i, s in enumerate(pr):\r\n if s <= n:\r\n n -= s\r\n else:\r\n res = ''.join(chr(ord('A') + n%26**(j+1)//26**j) for j in range(i-1, -1, -1))\r\n return res\r\n\r\n\r\npr = [1, 26, 26**2, 26**3, 26**4, 26**5]\r\nt = int(input())\r\nfor _ in range(t):\r\n s = input()\r\n da = []\r\n ad = []\r\n for i, c in enumerate(s[1:], 1):\r\n if (s[i-1].isdigit() and s[i].isalpha()):\r\n da.append(i)\r\n elif (s[i-1].isalpha() and s[i].isdigit()):\r\n ad.append(i)\r\n\r\n if len(ad) == 1:\r\n print(F\"R{s[ad[0]:]}C{to_number(s[:ad[0]])}\")\r\n elif len(ad) == 2:\r\n print(F\"{to_alpha(int(s[ad[1]:]))}{s[ad[0]:ad[1]-1]}\")\r\n else:\r\n a = 1//0", "\r\nimport math\r\nimport re\r\n\r\n\r\ndef iteracion(num, base):\r\n if num % base == 0:\r\n residuo = base\r\n else:\r\n residuo = num % base\r\n cociente = (num-residuo)/base\r\n return int(cociente), int(residuo)\r\n\r\n\r\ndef tranformar_letter(num, base):\r\n lista = []\r\n while (True):\r\n num, residuo = iteracion(num, base)\r\n lista = [residuo]+lista\r\n if num < base:\r\n lista = [num]+lista\r\n break\r\n letters = \"0ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\n letter = \"\"\r\n for i in lista:\r\n if i != 0:\r\n letter = letter+letters[i]\r\n return letter\r\n\r\n\r\ndef tranformar_num(text, base):\r\n letters = \"0ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\n n = len(text)\r\n num = 0\r\n for i in text:\r\n a = letters.index(str(i))\r\n num = num+a*(base**(n-1))\r\n n = n-1\r\n return str(num)\r\n\r\n\r\nn = int(input())\r\n\r\ndata = []\r\nfor i in range(n):\r\n data.append(input())\r\n\r\n\r\nfor i in data:\r\n resultado = re.findall(r'R(\\d+)C(\\d+)', i)\r\n if resultado:\r\n print(tranformar_letter(int(resultado[0][1]), 26)+resultado[0][0])\r\n else:\r\n resultado = re.findall(r'([A-Za-z]+)(\\d+)', i)\r\n num = tranformar_num(resultado[0][0], 26)\r\n print(\"R\"+resultado[0][1]+\"C\"+num)", "# Submitted using https://github.com/Nirlep5252/codeforces-cli\n# >.<\n\nimport re\nlol = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\ndef num_to_alph(n: int) -> str:\n ans = \"\"\n a, b = divmod(n, 26)\n while int(a) != 0:\n # print(a, b, lol[int(b) - 1])\n ans += lol[int(b) - 1]\n n /= 26\n n = int(n)\n if int(b) == 0:\n n -= 1\n a, b = divmod(n, 26)\n if b:\n # print(b, lol[int(b) - 1])\n ans += lol[int(b) - 1]\n return ans[::-1]\n\ndef alph_to_num(s: str) -> int:\n ans = 0\n for i, ch in enumerate(s[::-1]):\n ans += (lol.find(ch) + 1) * (26 ** i)\n return ans\n\nfor _ in range(int(input())):\n s = input()\n m1 = re.fullmatch(r\"[A-Z]+[0-9]+\", s)\n\n if m1 is None:\n coords = re.findall(r\"[0-9]+\", s)\n if s.startswith(\"R\"):\n r = int(coords[0])\n c = int(coords[1])\n else:\n r = int(coords[1])\n c = int(coords[0])\n\n print(num_to_alph(c), r, sep=\"\")\n else:\n r = re.match(r\"[A-Z]+\", s)\n p = r.end()\n c = s[:p]\n r = s[p:]\n # print(r.pos, r.end(), r.lastindex, sep=\"\\n\")\n\n print(\"R\", r, \"C\", alph_to_num(c), sep=\"\")\n", "n = int(input())\n\ndef convert_letter_rep_to_dec_rep(s):\n res = 0\n for i in s:\n res *= 26\n res += (ord(i) - ord('A') + 1)\n\n return res\n\ndef convert_dec_rep_to_let_rep(n):\n res = ''\n k = 0\n i = 0\n while n > 0:\n n -= 1\n t = n % 26\n res = chr(ord('A') + t) + res\n n //= 26\n\n return res\n\n \n\nfor i in range(n):\n s = input()\n if s[0] == 'R':\n if s[1].isalpha(): # R smth in radix_z ROW\n column = 'R'\n i = 1\n while s[i].isalpha():\n column += s[i]\n i += 1\n\n row = int(s[i:])\n\n print(f'R{row}C{convert_letter_rep_to_dec_rep(column)}')\n\n elif s[1:].isnumeric():\n print(f'R{s[1:]}C{convert_letter_rep_to_dec_rep(s[0])}')\n else:\n i = 1\n row = 0\n while s[i] != 'C':\n row *= 10\n row += int(s[i])\n i += 1\n \n column = int(s[i+1:])\n print(f'{convert_dec_rep_to_let_rep(column)}{row}')\n\n\n else:\n column = ''\n i = 0\n while s[i].isalpha():\n column += s[i]\n i += 1\n \n row = int(s[i:])\n \n # print(column, row)\n \n print(f'R{row}C{convert_letter_rep_to_dec_rep(column)}')\n", "import re\r\n\r\nfor _ in range(int(input())):\r\n coordinates = input().strip()\r\n if coordinates[0] == 'R' and coordinates[1].isdigit() and 'C' in coordinates:\r\n row, column = coordinates.split('R')[1].split('C')\r\n column = int(column)\r\n column_letters = \"\"\r\n while column:\r\n column -= 1\r\n column_letters = chr(column % 26 + 65) + column_letters\r\n column //= 26\r\n print(column_letters + row)\r\n else:\r\n column_letters, row = re.match(r'([A-Z]+)(\\d+)', coordinates).groups()\r\n column = 0\r\n for letter in column_letters:\r\n column = column * 26 + ord(letter) - 64\r\n print(f'R{row}C{column}')", "for C in range(int(input())):\r\n word = input()\r\n lock = 0\r\n hold = 26\r\n a = 0\r\n b = 0\r\n def excel_column_number(name):\r\n \"\"\"Excel-style column name to number, e.g., A = 1, Z = 26, AA = 27, AAA = 703.\"\"\"\r\n n = 0\r\n for c in name:\r\n n = n * 26 + 1 + ord(c) - ord('A')\r\n return n\r\n def excel_column_name(n):\r\n name = ''\r\n while n > 0:\r\n n, r = divmod (n - 1, 26)\r\n name = chr(r + ord('A')) + name\r\n return name\r\n if word[0] == \"R\" and word[1].isdigit():\r\n for c in range(len(word)-2):\r\n if word[c+2] == \"C\":\r\n lock = 1\r\n if lock == 1:\r\n lock = 0\r\n for c in range(len(word)-1):\r\n if word[c+1] == \"C\":\r\n lock = 1\r\n else:\r\n if lock == 0:\r\n a = a * 10\r\n a = a + int(word[c+1])\r\n else:\r\n b = b * 10\r\n b = b + int(word[c+1])\r\n hold = excel_column_name(b)\r\n print(hold + str(a))\r\n hold = 69420\r\n if not(hold == 69420):\r\n b = \"\"\r\n for c in range(len(word)):\r\n if word[c].isdigit():\r\n a = a*10\r\n a = a + int(word[c])\r\n else:\r\n b = b + word[c]\r\n print(\"R\" + str(a) + \"C\" + str(excel_column_number(b)))", "import bisect\r\nimport heapq\r\nimport sys\r\nfrom types import GeneratorType\r\nfrom functools import cmp_to_key\r\nfrom collections import defaultdict, Counter, deque\r\nimport math\r\nfrom functools import lru_cache\r\nfrom heapq import nlargest\r\n\r\n\r\ninf = float(\"inf\")\r\n\r\n\r\nclass FastIO:\r\n def __init__(self):\r\n return\r\n\r\n @staticmethod\r\n def _read():\r\n return sys.stdin.readline().strip()\r\n\r\n def read_int(self):\r\n return int(self._read())\r\n\r\n def read_float(self):\r\n return float(self._read())\r\n\r\n def read_ints(self):\r\n return map(int, self._read().split())\r\n\r\n def read_floats(self):\r\n return map(float, self._read().split())\r\n\r\n def read_ints_minus_one(self):\r\n return map(lambda x: int(x) - 1, self._read().split())\r\n\r\n def read_list_ints(self):\r\n return list(map(int, self._read().split()))\r\n\r\n def read_list_floats(self):\r\n return list(map(float, self._read().split()))\r\n\r\n def read_list_ints_minus_one(self):\r\n return list(map(lambda x: int(x) - 1, self._read().split()))\r\n\r\n def read_str(self):\r\n return self._read()\r\n\r\n def read_list_strs(self):\r\n return self._read().split()\r\n\r\n def read_list_str(self):\r\n return list(self._read())\r\n\r\n @staticmethod\r\n def st(x):\r\n return sys.stdout.write(str(x) + '\\n')\r\n\r\n @staticmethod\r\n def lst(x):\r\n return sys.stdout.write(\" \".join(str(w) for w in x) + '\\n')\r\n\r\n @staticmethod\r\n def round_5(f):\r\n res = int(f)\r\n if f - res >= 0.5:\r\n res += 1\r\n return res\r\n\r\n @staticmethod\r\n def max(a, b):\r\n return a if a > b else b\r\n\r\n @staticmethod\r\n def min(a, b):\r\n return a if a < b else b\r\n\r\n @staticmethod\r\n def bootstrap(f, queue=[]):\r\n def wrappedfunc(*args, **kwargs):\r\n if queue:\r\n return f(*args, **kwargs)\r\n else:\r\n to = f(*args, **kwargs)\r\n while True:\r\n if isinstance(to, GeneratorType):\r\n queue.append(to)\r\n to = next(to)\r\n else:\r\n queue.pop()\r\n if not queue:\r\n break\r\n to = queue[-1].send(to)\r\n return to\r\n return wrappedfunc\r\n\r\n\r\ndef num_to_loc(num):\r\n loc = \"\"\r\n while num:\r\n x = num % 26\r\n if x == 0:\r\n loc += \"Z\"\r\n num = (num-1)//26\r\n else:\r\n loc += chr(x+ord(\"A\")-1)\r\n num //= 26\r\n return loc[::-1]\r\n\r\n\r\ndef loc_to_num(loc):\r\n ans = 0\r\n for w in loc:\r\n ans *= 26\r\n ans += ord(w)-ord(\"A\") + 1\r\n return ans\r\n\r\n\r\ndef main(ac=FastIO()):\r\n for _ in range(ac.read_int()):\r\n s = ac.read_str()\r\n i = s.find(\"R\")\r\n j = s.find(\"C\")\r\n n = len(s)\r\n if i != -1 and j != - 1 and i == 0 and s[1:j].isnumeric() and s[j + 1:].isnumeric():\r\n col = s[1:j]\r\n row = s[j + 1:]\r\n row = num_to_loc(int(row))\r\n ans = f\"{row}{col}\"\r\n else:\r\n row = col = \"\"\r\n for i in range(n):\r\n if s[i].isnumeric():\r\n row = s[:i]\r\n col = s[i:]\r\n break\r\n row = loc_to_num(row)\r\n ans = f\"R{col}C{row}\"\r\n ac.st(ans)\r\n return\r\n\r\n\r\nmain()\r\n", "n = int(input().strip())\r\n\r\ndef col_to_num(col):\r\n carry = 0\r\n res = 0\r\n while col:\r\n cur = col[-1]\r\n res += (ord(cur) - 64) * 26 ** carry\r\n col = col[:-1]\r\n carry += 1\r\n return str(res)\r\n \r\ndef num_to_col(num):\r\n num = int(num)\r\n res = ''\r\n while num:\r\n mod = num % 26\r\n if mod == 0:\r\n res = 'Z' + res\r\n num = num // 26 - 1\r\n else:\r\n num //= 26\r\n res = chr(mod+64) + res\r\n return res\r\n \r\ndef xy_to_excel(string):\r\n y = string.split('C')[-1]\r\n x = string.split('C')[0].split('R')[-1]\r\n return num_to_col(y)+x\r\n\r\ndef excel_to_xy(string):\r\n for i in range(len(string)):\r\n if '1' <= string[i] <= '9':\r\n break\r\n col = string[:i]\r\n row = string[i:]\r\n return 'R'+row+'C'+col_to_num(col)\r\n \r\ndef is_xy(string):\r\n if string[0] == 'R' and '1' <= string[1] <= '9':\r\n for s in string[2:]:\r\n if s == 'C':\r\n return True\r\n return False\r\n \r\nfor _ in range(n):\r\n string = input().strip()\r\n if is_xy(string):\r\n print(xy_to_excel(string))\r\n else:\r\n print(excel_to_xy(string))\r\n", "i=input()\r\nfor j in range(int(i)):\r\n a=b=0\r\n coord=input()\r\n for c in coord:\r\n if \"0\"<=c<=\"9\": #RXCY的X与Y\r\n b=b*10+int(c)\r\n elif b: #b不为0且出现字母,说明为RXCY型\r\n a,b=coord[1:].split('C')\r\n b=int(b)\r\n v=\"\"\r\n while b: #b转化为字母,按每一位考虑\r\n b-=1\r\n v=chr(65+b%26)+v #不用管位数,算就能算了\r\n b//=26\r\n print(v+a)\r\n break\r\n else: #把26进制的字母化成十进制数\r\n a=26*a+ord(c)-64\r\n else:\r\n print(f'R{b}C{a}')", "import collections\r\nfrom collections import defaultdict\r\nfrom platform import java_ver\r\nfrom sys import setrecursionlimit, stdin, stdout, stderr\r\nfrom bisect import bisect_left, bisect_right\r\nfrom collections import defaultdict, deque, Counter\r\nfrom itertools import accumulate, combinations, permutations, product\r\nfrom functools import lru_cache, cmp_to_key, reduce\r\nfrom heapq import heapify, heappush, heappop, heappushpop, heapreplace\r\nimport math\r\nimport copy\r\nimport os,sys,io,math,copy\r\nfrom io import BytesIO, IOBase\r\n# list(map(int,input().split()))\r\n# s = input().strip()\r\n# n = int(input())\r\n \r\ndef main():\r\n n = int(input())\r\n \r\n for _ in range(n):\r\n \r\n s = input()\r\n \r\n if ord(s[1]) < 60 and s.count(\"C\") > 0 and s.count(\"R\") > 0:\r\n row = s[1:s.index(\"C\")]\r\n col = int(s[s.index(\"C\")+1:])\r\n ans = []\r\n while col > 0:\r\n if col % 26 == 0:\r\n ans.append(\"Z\")\r\n col //= 26\r\n col -= 1\r\n else:\r\n ans.append(chr(ord(\"A\") + col % 26 - 1))\r\n col //= 26\r\n print(\"\".join(ans[::-1]) + row)\r\n \r\n else:\r\n x = 0\r\n for i, c in enumerate(s):\r\n if ord(c) < 60:\r\n x = i\r\n break\r\n\r\n row = s[x:]\r\n col = s[:x]\r\n\r\n co = 0\r\n\r\n for i, c in enumerate(col[::-1]):\r\n co += (ord(c) - 64)*26**i\r\n\r\n print(f\"R{row}C{co}\")\r\n\r\n \r\n \r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\r\n\r\n# Fast input\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# input = sys.stdin.readline\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n\r\n\r\n\r\n\r\n\r\n" ]
{"inputs": ["2\nR23C55\nBC23", "1\nA1", "5\nR8C3\nD1\nR7C2\nR8C9\nR8C9", "4\nR4C25\nR90C35\nAP55\nX83", "10\nR50C12\nR23C47\nY96\nR44C13\nR19C21\nR95C73\nBK12\nR51C74\nAY34\nR63C25"], "outputs": ["BC23\nR23C55", "R1C1", "C8\nR1C4\nB7\nI8\nI8", "Y4\nAI90\nR55C42\nR83C24", "L50\nAU23\nR96C25\nM44\nU19\nBU95\nR12C63\nBV51\nR34C51\nY63"]}
UNKNOWN
PYTHON3
CODEFORCES
83
e56214dc9f144c4a71c86dfcd4bd0a70
Basketball Team
As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC). A team is to be formed of *n* players, all of which are GUC students. However, the team might have players belonging to different departments. There are *m* departments in GUC, numbered from 1 to *m*. Herr Wafa's department has number *h*. For each department *i*, Herr Wafa knows number *s**i* — how many students who play basketball belong to this department. Herr Wafa was also able to guarantee a spot on the team, using his special powers. But since he hates floating-point numbers, he needs your help at finding the probability that he will have at least one teammate belonging to his department. Note that every possible team containing Herr Wafa is equally probable. Consider all the students different from each other. The first line contains three integers *n*, *m* and *h* (1<=≤<=*n*<=≤<=100,<=1<=≤<=*m*<=≤<=1000,<=1<=≤<=*h*<=≤<=*m*) — the number of players on the team, the number of departments in GUC and Herr Wafa's department, correspondingly. The second line contains a single-space-separated list of *m* integers *s**i* (1<=≤<=*s**i*<=≤<=100), denoting the number of students in the *i*-th department. Note that *s**h* includes Herr Wafa. Print the probability that Herr Wafa will have at least one teammate from his department. If there is not enough basketball players in GUC to participate in ABC, print -1. The answer will be accepted if it has absolute or relative error not exceeding 10<=-<=6. Sample Input 3 2 1 2 1 3 2 1 1 1 3 2 1 2 2 Sample Output 1 -1 0.666667
[ "import math\r\nn, m, h = map(int,input().split())\r\nls = list(map(int,input().split()))\r\nif sum(ls) < n :\r\n print(-1)\r\nelse :\r\n print(\"{:.9f}\".format(1 - math.comb(sum(ls)-ls[h-1], n-1)/math.comb(sum(ls)-1, n-1)))", "\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#dirs = [[1,0],[0,1],[-1,0],[0,-1]]\r\n#from math import factorial as fact\r\n#a,b = [int(x) for x in input().split()]\r\n#sarr = [x for x in input().strip().split()]\r\n#import math\r\n#from math import *\r\n\r\nimport sys\r\ninput=sys.stdin.readline\r\n#sys.setrecursionlimit(2**30)\r\n#MOD = 10**9+7\r\ndef solve():\r\n n,m,h = [int(x) for x in input().split()]\r\n arr = [int(x) for x in input().split()]\r\n s = sum(arr)\r\n if s<n:\r\n print(-1)\r\n return\r\n nk = s-arr[h-1]\r\n if nk<n-1:\r\n print(1)\r\n return\r\n p1 = 1\r\n for i in range(1,n):\r\n p1*=(nk)/(s-i)\r\n nk-=1\r\n p = 1-p1\r\n print(p)\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", "import bisect\r\nimport collections\r\nimport copy\r\nimport enum\r\nimport functools\r\nimport heapq\r\nimport itertools\r\nimport math\r\nimport queue\r\nimport random\r\nimport re\r\nimport sys\r\nimport time\r\nimport string\r\nimport datetime\r\nfrom typing import List\r\n\r\n\r\nn, m, h = map(int, input().split())\r\narr = list(map(int, input().split()))\r\nsa = sum(arr)\r\nif(sa < n):\r\n print(\"-1\")\r\n exit()\r\n\r\nh -= 1\r\nc1 = math.comb(sa-1, n-1)\r\nc2 = math.comb(sa-arr[h], n-1)\r\n\r\nprint((c1-c2)/c1)\r\n", "n, m, h = tuple(map(int, input().strip().split())) \narr = list(map(int, input().strip().split())) \n\ntot = 0 \n\nfor x in arr: \n tot = tot+x \n \nif(tot<n):\n print(-1)\nelse:\n arr[h-1] = arr[h-1]-1\n tot = tot-1 \n n = n-1 \n other = tot-arr[h-1]\n \n ans = 1.0 \n iter = range(n)\n \n for i in iter:\n ans = ans*(other-i)/(tot-i)\n \n print(1-ans)\n\t \t \t\t\t\t\t \t \t\t\t \t\t \t \t\t\t", "n,m,h=map(int,input().split())\r\narray=list(map(int,input().split()))\r\ntotal=sum(array)\r\nothers=total-array[h-1]\r\nif total<n:\r\n print(-1)\r\nelif others<n-1:\r\n print(1)\r\nelse:\r\n p=1\r\n for i in range(1,array[h-1]):\r\n p*=(total-n+1-i)/(total-i)\r\n print(\"{0:.6f}\".format(1-p))", "import math\r\n\r\nx=input().split()\r\nn=int(x[0])\r\nm=int(x[1])\r\nh=int(x[2])\r\nsum=0\r\nx=input().split()\r\ns=[]\r\nfor i in range (m):\r\n s.append(int(x[i]))\r\n sum+=int(x[i])\r\nif(sum<n):\r\n print(-1)\r\nelif(n==1):\r\n print(0)\r\nelif(m==1):\r\n print(1)\r\nelse:\r\n result=0\r\n minim = min(s[h-1],n)\r\n for l in range(1,minim):\r\n result+=math.comb(minim-1,l)*math.comb(sum-minim,n-(l+1))\r\n print(result/math.comb(sum-1,n-1))", "n, m, h = map(int, input().split())\r\nn -= 1\r\nans = 1\r\n*a, = map(int ,input().split())\r\nk = sum(a) - 1\r\ns = k - a[h - 1] + 1\r\nif k < n:\r\n exit(print(-1))\r\nfor _ in range(n):\r\n if not s:\r\n exit(print(1))\r\n ans *= s / k\r\n s -= 1\r\n k -= 1\r\nprint(1 - ans)", "n, m, h=[int(k) for k in input().split()]\r\nw=[int(k) for k in input().split()]\r\n#from math import factorial\r\n\r\nif sum(w)<n:\r\n print(-1)\r\nelif sum(w)-w[h-1]<n-1:\r\n print(1)\r\nelse:\r\n x=w[h-1]-1\r\n y=sum(w)-1\r\n delta1, delta2=1, 1\r\n for j in range(y-n+2, y+1):\r\n delta1*=j\r\n for j in range(y-x-n+2, y-x+1):\r\n delta2*=j\r\n z=delta1 #factorial(y)//factorial(y-n+1)\r\n v=delta2 #factorial(y-x)//factorial(y-x-n+1)\r\n print(1-v/z)\r\n #print(factorial(50667)//(factorial(99)*factorial(50566)))", "def nck(n, k):\n if(n < k):\n return 0\n nu = 1\n d = 1\n if(k > n-k):\n k = n-k\n for i in range(k):\n nu *= (n - i)\n d *= (i + 1)\n return nu//d\n\n\nl = input().split()\nn = int(l[0])\nm = int(l[1])\nh = int(l[2])\ns = [int(i) for i in input().split()]\ntotal = sum(s)\nif(total < n):\n print(-1)\nelse:\n print(1-(nck(total-s[h-1], n-1)/nck(total-1, n-1)))\n", "n, m, h = map(int, input().split())\r\ns = list(map(int, input().split()))\r\na = 1\r\nS = sum(s)\r\nfor i in range(S - 1, S - s[h - 1], -1):\r\n\ta *= (i - n + 1) / i \r\nprint (1 - a if S >= n else -1)", "n,m,k = map(int,input().split())\r\nli=list(map(int,input().split()))\r\nli[k-1]-=1\r\nsum=0\r\nfor i in li:\r\n sum+=i\r\nn-=1\r\nden=1\r\nnum=1\r\ntemp=sum\r\nif sum<n:\r\n print(-1)\r\nelse:\r\n while temp!= sum-li[k-1]:\r\n den*=temp\r\n temp-=1\r\n sum-=n\r\n temp=sum\r\n while temp!=sum-li[k-1]:\r\n num*=temp\r\n temp-=1\r\n print(1-(num/den))\r\n", "from collections import deque\r\n\r\n\r\ndef main():\r\n n, m, h = [int(i) for i in input().split()]\r\n s = [int(i) for i in input().split()]\r\n mas = s[:h - 1] + s[h:] if h < len(s) else s[:-1]\r\n s1 = sum(mas)\r\n s2 = sum(s) - 1\r\n if s2 < n - 1:\r\n print(-1)\r\n return\r\n if s1 < n - 1:\r\n print(1)\r\n return\r\n\r\n p1 = 1\r\n p2 = 1\r\n for i in range(n - 1):\r\n p1 *= (s1 - i)\r\n p2 *= (s2 - i)\r\n\r\n print(1 - p1 / p2)\r\n\r\n\r\nif __name__ == '__main__':\r\n main()", "n,m,h = map(int,input().split())\r\nlis = list(map(int,input().split()))\r\nif sum(lis)<n:\r\n print(-1)\r\nelse:\r\n s=sum(lis)\r\n ans=1\r\n for i in range(n-1):\r\n ans*=(s-lis[h-1]-i)\r\n ans/=(s-i-1)\r\n print(1-ans) ", "def put(): return map(int, input().split())\r\ndef ncr(x,y,r):\r\n a= b = 1\r\n for i in range(x-r+1, x+1):\r\n a*= i\r\n for i in range(y-r+1, y+1):\r\n b*= i\r\n return 1 - (a/b)\r\n\r\n\r\nn,m,h = put()\r\nl = list(put())\r\ns = sum(l)\r\nx = l[h-1]\r\n\r\nif s<n:\r\n print(-1)\r\nelif s-x < n-1:\r\n print(1)\r\nelse:\r\n print(ncr(s-x, s-1, n-1))\r\n", "def nck(n, k):\r\n if n<k:\r\n return 0\r\n nu = 1\r\n d = 1\r\n if k>n-k:\r\n k = n-k\r\n for i in range(k):\r\n nu *= (n - i)\r\n d *= (i + 1)\r\n return nu//d\r\n\r\nl = input().split()\r\nn = int(l[0])\r\nm = int(l[1])\r\nh = int(l[2])\r\ns = [int(i) for i in input().split()]\r\ntotal = sum(s)\r\nif total<n:\r\n print(-1)\r\nelse:\r\n print(1-(nck(total-s[h-1], n-1)/nck(total-1, n-1)))", "# Thank God that I'm not you.\r\nfrom itertools import permutations, combinations;\r\nimport heapq;\r\nfrom collections import Counter, deque;\r\nimport math;\r\nimport sys;\r\nfrom functools import lru_cache;\r\n\r\n\r\ninput = sys.stdin.readline;\r\n\r\nn, m, k = map(int, input().split())\r\n\r\narray = list(map(int, input().split()))\r\n\r\ndef solve():\r\n if sum(array) < n:\r\n return -1;\r\n\r\n array[k - 1] -= 1;\r\n\r\n if not array[k - 1]:\r\n return 0;\r\n\r\n p = 1;\r\n currSum = sum(array) - array[k - 1];\r\n totalSum = sum(array)\r\n for i in range(1, n):\r\n p *= (currSum / totalSum)\r\n currSum -= 1;\r\n totalSum -= 1;\r\n\r\n return 1 - p;\r\n\r\n\r\n\r\n\r\nprint(solve())\r\n", "import math\r\nn, m, h = map(int,input().split())\r\ns = list(map(int,input().split()))\r\n\r\nSum = sum(s)\r\n\r\nsum1 = Sum - 1\r\nsum2 = Sum - s[h - 1]\r\n\r\nif (n - 1 > sum1):\r\n\tprint(-1)\r\n\r\nelif (n - 1 > sum2):\r\n\tprint(1)\r\nelse:\r\n\t#ans = 1 - C(sum2,n - 1)/C(sum1,n - 1)\r\n\t# math.log\r\n\tans = 0\r\n\tfor i in range(sum2 - n + 2,sum2 + 1):\r\n\t\tans += math.log(i)\r\n\t\r\n\tfor i in range(sum1 - n + 2,sum1 + 1):\r\n\t\tans -= math.log(i)\r\n\t\r\n\tans = 1 - math.exp(ans)\r\n\tprint(round(ans,8))\r\n", "import math\r\n\r\ndef binom(k, n):\r\n ret = 1\r\n for i in range(0, k):\r\n ret = ret * (n-i) // (i+1)\r\n return ret\r\n\r\n[n, m, h] = map(int, input().split())\r\nl = list(map(int, input().split()))\r\nt = sum(l) - 1\r\nn = n - 1\r\nl[h-1] = l[h-1] - 1\r\np = t - l[h-1]\r\n\r\nif n > t:\r\n print(\"{}\".format(-1))\r\nelse:\r\n print(\"{}\".format(1 - (binom(n, p) / binom(n, t))))\r\n", "n, m, h = map(int, input().split())\r\ns = list(map(int, input().split()))\r\nsum = 0\r\nfor i in range(0, m):\r\n sum += s[i]\r\nif sum < n:\r\n print(-1)\r\nelse :\r\n ans = 1\r\n for i in range(0, n - 1):\r\n ans *= (sum - s[h - 1] - i) / (sum- 1 - i)\r\n print(1 - ans)\r\n", "import sys\r\nimport math\r\n\r\n\r\nn,m,h = [int(x) for x in input().split()] \r\narr = [int(x) for x in input().split()]\r\n\r\ntotal = sum(arr)\r\n\r\nif (total < n):\r\n\tprint (\"-1\")\r\n\tsys.exit()\r\n\r\ntotal1 = total - arr[h-1]\r\nrem = total - total1-1\r\ntotal = total - 1\r\nans = 1\r\n'''\r\n#start = total - (n-1)\r\n#print (start)\r\nx = start\r\n#print (rem)\r\nfor i in range(rem-1):\r\n\tstart = float(float(start) * float(x-(i+1)))\r\n\r\nprint (start)\r\n'''\r\nfor i in range(n-1):\r\n\tx = float(total1 - i)\r\n\ty = float(total - i)\r\n\t#print (i,x,y)\r\n\tans = float(ans * float(x/y))\r\n\r\n#print (ans)\r\n\r\nans = float(ans) \r\n\r\nprint(\"{0:.10f}\".format(round(1-ans,10)))\r\n", "n, m, h = map(int, input().split())\r\n\r\ns = list(map(int, input().split()))\r\nsm = sum(s)\r\n\r\nif(n > sm):\r\n\tprint(-1)\r\nelif(sm - s[h-1] + 1 < n-1 ):\r\n\tprint(1)\r\nelif(s[h-1] == 1):\r\n\tprint(0)\r\nelse:\r\n\ta = sum(s) - s[h-1]\r\n\tsm = sum(s)\r\n\tans = 1\r\n\tfor j in range(n-1):\r\n\t\tans *= (a-j)/(sm-j-1)\r\n\r\n\tprint(1 - ans)\r\n\r\n", "from math import factorial as f\r\ndef ncr(n, r):\r\n\treturn f(n) / (f(r) * f(n - r)) if n >= r else 0\r\nn, m, h = map(int, input().split())\r\ns = list(map(int, input().split()))\r\na = sum(s) - s[h - 1]\r\nb = n - 1\r\nc = sum(s) - 1\r\nans = 1\r\nfor i in range(c, a, -1):\r\n\tans *= (i - b) / i \r\nprint ((1 - ans) if sum(s) >= n else -1)", "from math import comb\r\nif __name__ == '__main__':\r\n n, m, h = map(int, input().split())\r\n h -= 1\r\n\r\n arr = [int(i) for i in input().split()]\r\n arr[h] -= 1\r\n n -= 1\r\n\r\n total = sum(arr)\r\n if total < n:\r\n print(-1)\r\n exit(0)\r\n ans = comb(total - arr[h], n) / comb(total, n)\r\n print(1 - ans)", "\r\ndef nCk(n, k):\r\n res = 1\r\n for i in range(1, k + 1):\r\n res = res * (n - i + 1) // i\r\n return res\r\n\r\n\r\nn, _, me = map(int, input().split())\r\na = [0] + list(map(int, input().split()))\r\n\r\ns = sum(a)\r\nif n > s:\r\n print(-1)\r\n exit()\r\n\r\nallWays = nCk(s - 1, n - 1)\r\naa=nCk(s-a[me],n-1)\r\nprint(1-aa/allWays)", "from math import lgamma, exp\r\nn, m, h = map(int, input().split())\r\nds = list(map(int, input().split()))\r\ns, d = sum(ds), ds[h - 1]\r\nif s < n:\r\n\tprint(-1)\r\nelif s + 1 < n + d:\r\n\tprint(1)\r\nelse:\r\n\tprint(1 - exp(lgamma(s - d + 1) + lgamma(s - n + 1) - lgamma(s) - lgamma(s - d - n + 2)))", "import math\r\n\r\nn,m,h = map(int,input().split())\r\ns = list(map(int,input().split()))\r\n\r\nif sum(s) < n:\r\n print(-1)\r\nelse:\r\n A = math.comb(sum(s) - s[h - 1], n - 1)\r\n B = math.comb(sum(s) - 1, n - 1)\r\n print(1 - A/B)# 1691237684.1318727", "n,m,h=map(int,input().split())\ns=list(map(int,input().split()))\na=1\nS=sum(s)\nfor i in range(S-s[h-1]+1,S):\n\ta*=(i-n+1)/i\nprint(-1 if S<n else 1-a)\n \t\t\t\t\t\t\t \t\t \t \t\t\t \t\t \t", "def int_space() :\r\n return list(map(int, input().split()))\r\n\r\ndef multxy(x, y) :\r\n res = 1\r\n for i in range(y, x, -1) :\r\n res = res * i\r\n return res\r\n\r\ndef main() :\r\n n, m, h = int_space()\r\n sum = hx = mx = ind = 0\r\n a = int_space()\r\n for i in a :\r\n sum = sum + i\r\n ind = ind + 1\r\n if(ind == h) :\r\n hx = i\r\n if(sum < n) :\r\n print(-1)\r\n exit(0)\r\n elif(hx == 1) :\r\n print(0)\r\n exit(0)\r\n mx = sum - hx\r\n sum = sum - 1\r\n hx = hx - 1\r\n n = n - 1\r\n res = multxy(mx - n, sum - n) /multxy(mx, sum)\r\n print(1 - res)\r\n\r\nmain()", "from functools import reduce\r\n\r\ndef F(s,x,n):\r\n\tans=1\r\n\tz=s-n\r\n\tfor i in range(1,x):\r\n\t\tans*=(z-i+1)/(s-i)\r\n\treturn ans\r\n\r\n\r\n\r\n\r\n\r\nnmh=input().split()\r\nn=int(nmh[0])\r\nm=int(nmh[1])\r\nh=int(nmh[2])\r\nL=list(map(int,input().split()))\r\ns=reduce(lambda x,y:x+y,L)\r\nif(s<n):\r\n\tprint(-1)\r\nelse:\r\n\tx=L[h-1]\r\n\tans=F(s,x,n)\t\r\n\tpro=1-ans\r\n\tprint(pro)", "def nCk(n, k):\r\n res = 1\r\n for i in range(1, k + 1):\r\n res = res * (n - i + 1) // i\r\n return res\r\n\r\nn, _, me = map(int, input().split())\r\na = [0] + list(map(int, input().split()))\r\n\r\ns = sum(a)\r\nif n > s:\r\n print(-1)\r\n exit()\r\n\r\nallWays = nCk(s - 1, n - 1)\r\ngood = 0\r\nfor k in range(1, min(a[me], n)):\r\n good += nCk(a[me] - 1, k) * nCk(s - a[me], n - k - 1)\r\nprint(good / allWays)", "n, m, h = map(int, input().split())\r\ns = list(map(int, input().split()))\r\na = 1\r\nS = sum(s)\r\nfor i in range(S - s[h - 1] + 1, S):\r\n\ta *= (i - n + 1) / i \r\nprint (-1 if S < n else 1 - a)", "n, m, h = map(int, input().split())\r\ns = list(map(int, input().split()))\r\ns[h-1] = s[h-1] - 1\r\ntotal = sum(s)\r\ntot_withoutwafadep = total - s[h-1]\r\nn = n - 1\r\nif total<n:\r\n print(-1)\r\n exit()\r\nresult = 1\r\nres_two = 1\r\nfor i in range(n):\r\n result = result * (tot_withoutwafadep - i)\r\n res_two = res_two * (total - i)\r\nprint(1 - result/res_two)\r\n", "n, m, h=map(int, input().split())\r\ntot=0\r\narr=list(map(int, input().split()))\r\nfor i in range(m):\r\n\ttot+=arr[i]\r\nif tot<n:\r\n\tprint(-1)\r\nelse:\r\n\tyo, f, hi=1, 0, tot-1\r\n\tfor i in range(m):\r\n\t\tif i!=h-1:\r\n\t\t\tf+=arr[i]\r\n\tfor i in range(n-1):\r\n\t\tyo*=f/hi\r\n\t\tf-=1\r\n\t\thi-=1\r\n\tyo=1.0-yo\r\n\t'{:0.20f}'.format(yo)\r\n\tprint(yo)", "def ii(): return int(input())\r\ndef si(): return input()\r\ndef mi(): return map(int,input().split())\r\ndef msi(): return map(str,input().split())\r\ndef li(): return list(mi())\r\ndef ncr(n,k):\r\n C = [[0 for x in range(k+1)] for x in range(n+1)]\r\n \r\n # Calculate value of Binomial\r\n # Coefficient in bottom up manner\r\n for i in range(n+1):\r\n for j in range(min(i, k)+1):\r\n # Base Cases\r\n if j == 0 or j == i:\r\n C[i][j] = 1\r\n \r\n # Calculate value using\r\n # previously stored values\r\n else:\r\n C[i][j] = C[i-1][j-1] + C[i-1][j]\r\n \r\n return C[n][k]\r\n \r\nn,m,h=mi()\r\ns=[0]+li()\r\nif sum(s)<n:\r\n print(-1)\r\n \r\nelse:\r\n av=sum(s)-1\r\n dav=sum(s)-s[h]\r\n req=n-1\r\n \r\n prob=1\r\n for i in range(req):\r\n prob = prob*((dav-i)/(av-i))\r\n \r\n print(1-prob)", "n, m, h = map(int, input().split())\r\ns = list(map(int, input().split()))\r\nt = sum(s)\r\nif n > t: print(-1)\r\nelif s[h-1] == 1: print(0)\r\nelif t - s[h-1] + 1 < n: print(1)\r\nelse:\r\n\ta = t-s[h-1]\r\n\tb = t-1\r\n\tc = b-n+1\r\n\td = a-n+1\r\n\tz = 1\r\n\tfor i in range(a+1,b+1):\r\n\t\tz *= i\r\n\ty = 1\r\n\tfor i in range(d+1,c+1):\r\n\t\ty *= i\r\n\tprint(1-(y/z))", "n,m,h=list(map(int,input().split()))\r\ns=list(map(int,input().split()))\r\na=sum(s)\r\nif a<n:\r\n print(-1)\r\nelif a-s[h-1]<n-1:\r\n print(1)\r\nelse:\r\n d=1\r\n for j in range(a-s[h-1]-n+2,a-s[h-1]+1):\r\n d*=j\r\n e=1\r\n for j in range(a-n+1,a):\r\n e*=j\r\n print(1-d/e)", "from sys import stdin,stdout\r\ninput = stdin.readline\r\nfrom math import gcd\r\n# from collections import Counter\r\n# from heapq import heapify,heappop,heappush\r\n# from time import time\r\n# from bisect import bisect, bisect_left\r\n\r\n\r\ndef NcR(n,r):\r\n\tp = 1\r\n\tk = 1\r\n\tif (n - r < r):\r\n\t\tr = n - r\r\n \r\n\tif (r != 0):\r\n\t\twhile (r):\r\n\t\t\tp *= n\r\n\t\t\tk *= r\r\n\t\t\tm = gcd(p, k)\r\n\t\t\tp //= m\r\n\t\t\tk //= m\r\n \r\n\t\t\tn -= 1\r\n\t\t\tr -= 1\r\n\t\t\tp = p \r\n\telse:\r\n\t\tp = 1\r\n\treturn(p)\r\nn,m,h = map(int,input().split())\r\na = list(map(int,input().split()))\r\nif sum(a) < n:\r\n print(-1)\r\nelse:\r\n n -= 1\r\n a[h-1] -= 1\r\n p = sum(a)\r\n if p - a[h-1] < n:\r\n print(1)\r\n else:\r\n k = p-a[h-1]\r\n op = NcR(k,n)/NcR(p,n)\r\n print(1-op)\r\n\r\n", "n, m, h = map(int, input().split())\na = list(map(int, input().split()))\ny, n, ah = sum(a) - 1, n-1, a[h-1]-1\nif y < n:\n print(-1)\nelif y - ah < n:\n print(1)\nelse:\n ans = float(1.0)\n for i in range(1, n+1):\n ans *= (y - ah - n + i) / (y - n + i)\n ans = 1.0 - ans\n print(f'{ans:.15f}')\n\n\n\n\t\t\t \t \t \t \t \t\t\t\t \t\t\t", "n,m,h =map(int,input().split())\r\nl=list(map(int,input().split()))\r\nl[h-1]-=1\r\nif l[h-1]==-1 :\r\n print(-1)\r\n exit()\r\nsu=sum(l)\r\nif su<n-1 :\r\n print(-1)\r\n exit()\r\nv=1\r\nv1=1\r\nn-=1\r\n\r\nfor i in range(su-l[h-1]-n+1,su+1-l[h-1]) :\r\n v*=i\r\nfor i in range(su-n+1,su+1) :\r\n v1*=i\r\nch=v/v1\r\nprint(1-ch)\r\n\r\n\r\n \r\n", "import math\r\n\r\nn, m, h = map(int, input().split())\r\ns = list(map(int, input().split()))\r\nif sum(s) < n:\r\n print(-1)\r\nelse:\r\n fr = math.comb(sum(s) - s[h - 1], n - 1)\r\n sc = math.comb(sum(s) - 1, n - 1)\r\n print(1 - fr / sc)\r\n", "def nck(n,k):\r\n if(n<k):\r\n return 0\r\n num=1\r\n den=1\r\n if(k>n-k):\r\n return nck(n,n-k)\r\n for i in range(k):\r\n num=num*(n-i)\r\n den=den*(i+1)\r\n return num//den\r\nl=input().split()\r\nn=int(l[0])\r\nm=int(l[1])\r\nh=int(l[2])\r\nl=input().split()\r\nli=[int(i) for i in l]\r\nposs=sum(li)-1\r\nif(poss<n-1):\r\n print(-1)\r\nelse:\r\n ki=li[h-1]-1\r\n print(1-(nck(poss-ki,n-1)/nck(poss,n-1)))\r\n", "\"\"\"\r\natleast 1 =1- zero of them (only wafa)\r\n\"\"\"\r\nn,m,h=map(int,input().split())\r\nM=[int(x) for x in input().split()]\r\nM=[0]+M\r\ntot=sum(M)\r\nif tot<n:\r\n print(-1)\r\nelse:\r\n tot-=1\r\n M[h]-=1\r\n ans=1.0\r\n others=tot-M[h]\r\n for i in range(0,n-1):\r\n ans*=(others-i)/(tot-i)#if i is in ..wt abt others\r\n print(1.0-ans)\r\n \r\n \r\n \r\n", "n, m, h = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\n\ns = sum(a)\n\np = s - a[h - 1]\n\nif s < n:\n print(-1)\nelif p < n - 1:\n print(1)\nelse:\n k = 1\n for i in range(p - n + 2, p + 1):\n k *= i\n \n e = 1\n for i in range(s - n + 1, s):\n e *= i\n \n print(1 - k / e)\n# Tue Sep 28 2021 19:09:39 GMT+0300 (Москва, стандартное время)\n", "n,m,h=map(int,input().split())\r\ns=list(map(int,input().split()))\r\na=1\r\nS=sum(s)\r\nfor i in range(S-s[h-1]+1,S):\r\n\ta*=(i-n+1)/i\r\nprint(-1 if S<n else 1-a)", "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\nimport math\r\n\r\nN,M,H = map(int, input().split())\r\nA = list(map(int, input().split()))\r\n\r\ntotal = sum(A)\r\nif total<N:\r\n exit(print(-1))\r\n\r\ntotal-=1\r\nt1 = math.comb(total,N-1)\r\n\r\ntotal=sum(A)-A[H-1]\r\nt2 = math.comb(total,N-1)\r\nprint(1-t2/t1)\r\n\r\n", "R = lambda: map(int, input().split())\r\n\r\ndef cnt(n, k):\r\n res = 1\r\n for i in range(k):\r\n res = res * (n - i) / (k + 1)\r\n return res\r\n\r\nn, m, h = R()\r\nh -= 1\r\nps = list(R())\r\ntot = sum(ps)\r\nif tot < n:\r\n print(-1)\r\n exit(0)\r\nif tot <= 1 or n <= 1 or ps[h] <= 1:\r\n print(0)\r\n exit(0)\r\nif tot == n:\r\n print(1)\r\n exit(0)\r\nac = cnt(tot - 1, n - 1)\r\nrem = cnt(tot - ps[h], n - 1)\r\nprint((ac - rem) / ac)", "#!/usr/bin/env python3\n\nfrom functools import reduce\nfrom operator import mul\nfrom fractions import Fraction\n\n\ndef nCk(n,k):\n return int( reduce(mul, (Fraction(n-i, i+1) for i in range(k)), 1) )\n\ndef divide(a, b):\n return float(Fraction(a, b))\n\ndef main():\n n, _, h = list(map(int, input().split()))\n s = list(map(int, input().split()))\n\n s_sum = sum(s)\n\n if s_sum < n:\n print(-1)\n else:\n print(1 - divide(nCk(s_sum - s[h - 1], n - 1), nCk(s_sum - 1, n - 1)))\n\nif __name__ == '__main__':\n main()\n", "import sys\r\ninput = sys.stdin.readline\r\nfrom math import comb\r\n\r\nn, m, h = map(int, input().split())\r\nw = list(map(int, input().split()))\r\nn -= 1\r\nw[h-1] -= 1\r\nx = sum(w)\r\nif n > x:\r\n print(-1)\r\nelse:\r\n print((comb(x, n) - comb(x-w[h-1], n))/comb(x, n))", "\r\ndef solve(_tc):\r\n n, m, h = map(int, input().split())\r\n a = list(map(int, input().split()))\r\n\r\n if(sum(a) < n):\r\n print(-1)\r\n return\r\n \r\n n -= 1\r\n a[h - 1] -= 1\r\n\r\n t = a[h - 1]\r\n sm = sum(a)\r\n res = 1.0\r\n\r\n for i in range(t):\r\n res = res * (sm - n - i) / (sm - i)\r\n \r\n print(1 - res)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nt = 1\r\n# t = int(input())\r\n\r\nfor _tc in range(1, t+1):\r\n # print(\"Case {}: \".format(_tc), end=\"\")\r\n solve(_tc)\r\n" ]
{"inputs": ["3 2 1\n2 1", "3 2 1\n1 1", "3 2 1\n2 2", "3 2 1\n1 2", "6 5 3\n5 2 3 10 5", "7 10 6\n9 10 2 3 3 6 9 9 3 7", "17 5 1\n10 4 9 6 2", "5 8 3\n9 7 2 5 2 10 3 4", "14 8 4\n6 2 10 6 2 8 4 2", "14 9 9\n9 4 7 2 1 2 4 3 9", "46 73 68\n4 2 6 4 1 9 8 10 7 8 7 2 6 4 7 9 7 9 9 1 5 1 5 1 8 2 10 2 1 7 10 2 8 3 5 3 8 9 10 5 3 4 10 4 9 6 8 1 1 6 3 1 9 6 9 4 4 3 4 5 8 1 6 2 4 10 5 7 2 6 7 4 2", "24 55 54\n8 3 6 4 8 9 10 2 2 6 6 8 3 4 5 6 6 6 10 4 8 2 3 2 2 2 10 7 10 1 6 1 6 8 10 9 2 8 9 6 6 4 1 2 7 2 2 9 3 7 3 7 6 8 4", "63 25 24\n6 7 7 1 2 5 5 9 9 1 9 8 1 2 10 10 5 10 2 9 5 4 9 5 7", "44 94 2\n2 4 10 9 5 1 9 8 1 3 6 5 5 9 4 6 6 2 6 2 4 5 7 3 8 6 5 10 2 1 1 9 1 9 3 1 9 6 2 4 9 7 4 6 1 4 5 2 7 8 2 1 1 1 4 2 5 5 5 8 2 8 2 1 1 8 1 7 7 7 1 2 5 3 8 9 8 7 2 10 5 2 2 8 9 1 4 7 7 2 6 2 8 5", "44 35 7\n10 2 2 6 4 2 8 3 10 1 9 9 7 9 10 6 6 1 4 5 7 4 9 7 10 10 7 9 6 1 7 7 2 10 7", "27 47 44\n8 5 2 5 10 6 7 9 5 10 8 5 9 5 10 5 10 8 5 1 1 2 2 10 3 2 5 9 6 3 3 1 5 4 10 5 2 2 4 4 4 4 4 1 1 3 7", "21 67 49\n4 4 3 5 7 5 10 2 8 5 2 2 6 3 6 2 8 6 2 6 2 9 3 3 4 1 9 9 3 3 6 3 6 7 8 9 10 6 10 5 1 5 2 3 3 9 10 5 10 7 1 6 4 5 4 7 8 5 4 2 9 3 3 5 7 1 10", "42 71 67\n2 1 4 1 10 5 1 8 8 5 2 1 1 7 2 2 8 10 8 2 10 8 2 2 9 6 5 10 7 1 7 2 10 3 5 6 10 10 4 6 10 5 6 6 9 4 1 6 1 8 10 6 1 5 3 2 4 1 8 5 10 10 9 3 10 7 5 9 1 9 3", "50 93 28\n2 5 9 5 5 8 1 3 9 2 7 10 3 1 10 10 8 5 2 7 5 4 3 9 5 2 8 9 10 8 2 7 8 9 8 1 9 8 4 3 3 6 10 10 1 2 10 1 8 10 5 8 5 2 4 1 5 6 9 8 6 7 4 6 6 1 5 1 4 6 8 4 1 7 2 8 7 5 1 3 3 7 4 2 1 5 7 5 8 3 8 7 2", "33 90 4\n5 10 2 3 9 6 9 3 3 8 6 4 8 4 9 3 5 9 5 6 4 1 10 6 4 5 4 5 9 5 7 1 3 9 6 6 5 6 2 4 8 7 8 5 4 5 10 9 3 1 1 8 6 9 5 1 5 9 4 6 6 4 9 4 5 7 3 7 9 1 5 6 4 1 1 4 2 4 4 2 6 4 5 5 4 9 1 10 2 2", "65 173 136\n26 18 8 11 1 22 44 6 15 22 13 49 30 36 37 41 25 27 9 36 36 1 45 20 7 47 28 30 30 21 33 32 9 11 16 5 19 12 44 40 25 40 32 36 15 34 4 43 28 19 29 33 7 11 18 13 40 18 10 26 1 48 20 38 1 20 34 8 46 8 32 35 16 49 26 36 11 16 4 29 35 44 14 21 22 42 10 1 3 12 35 30 14 45 2 24 32 15 2 28 35 17 48 31 7 26 44 43 37 4 14 26 25 41 18 40 15 32 16 7 40 22 43 8 25 21 35 21 47 45 7 21 50 38 23 13 4 49 10 27 31 38 43 40 10 24 39 35 31 33 9 6 15 18 2 14 20 14 12 12 29 47 9 49 25 17 41 35 9 40 19 50 34", "77 155 26\n15 18 38 46 13 15 43 37 36 28 22 26 9 46 14 32 20 11 8 28 20 42 38 40 31 20 2 43 1 42 25 28 40 47 6 50 42 45 36 28 38 43 31 14 9 22 49 4 41 9 24 35 38 40 19 31 4 9 13 19 15 48 2 34 46 49 41 15 13 29 15 24 15 50 8 26 10 23 24 15 2 46 47 46 25 36 41 29 44 36 24 22 41 7 48 17 42 41 4 46 15 26 48 27 35 19 35 22 47 7 40 1 15 46 6 34 44 6 9 5 29 24 5 25 12 38 46 10 35 12 8 15 1 9 1 16 2 12 24 31 37 49 27 41 33 5 26 48 42 37 20 18 49 40 16", "67 108 14\n33 40 13 10 26 31 27 24 48 1 42 28 38 29 9 28 48 41 12 19 27 50 6 45 46 7 34 47 8 18 40 27 42 4 33 3 10 25 10 29 39 3 5 39 1 17 40 10 6 8 41 50 27 43 40 42 43 25 18 34 6 15 5 9 11 37 13 4 16 25 49 33 14 40 13 16 50 24 4 43 45 12 31 38 40 36 3 4 4 19 18 12 20 44 4 44 8 50 21 5 44 34 9 9 6 39 43 21", "82 135 73\n22 18 8 45 35 8 19 46 40 6 30 40 10 41 43 38 41 40 1 43 19 23 5 13 29 16 30 9 4 42 42 3 24 16 21 26 5 4 24 24 31 30 1 10 45 50 33 21 21 47 42 37 47 15 30 23 4 2 28 15 38 33 45 30 31 32 6 14 6 4 39 12 50 29 26 45 19 12 40 4 33 9 16 12 44 36 47 42 43 17 18 12 12 42 45 38 6 10 19 10 14 31 6 21 2 15 21 26 5 3 3 6 6 22 44 48 9 11 33 31 34 43 39 40 48 26 1 29 48 11 22 38 23 11 20", "73 121 102\n11 21 12 1 48 30 22 42 42 35 33 12 23 11 27 15 50 49 24 2 48 2 21 32 16 48 36 26 32 13 38 46 36 15 27 24 7 21 43 49 19 13 3 41 35 17 5 22 42 19 37 20 40 42 11 31 48 16 21 5 42 23 29 44 9 30 46 21 44 27 9 17 39 24 30 33 48 3 43 18 16 18 17 46 19 26 37 5 24 36 42 12 18 29 7 49 1 9 27 12 21 29 19 38 6 19 43 46 33 42 9 30 19 38 25 10 44 23 50 25 46", "50 113 86\n2 17 43 22 48 40 42 47 32 29 10 4 9 14 20 50 8 29 12 11 50 41 3 22 30 4 48 37 27 19 50 50 23 34 13 21 3 36 31 39 22 27 7 21 31 21 14 18 36 19 27 42 19 8 5 41 7 8 22 40 38 32 44 25 21 48 4 12 10 16 23 30 25 41 16 45 3 26 19 34 34 25 26 6 9 21 46 33 36 45 3 13 28 44 30 29 22 41 20 1 20 38 4 33 36 15 41 18 13 11 13 18 6", "74 146 112\n10 31 40 32 9 17 31 26 32 7 20 18 50 10 15 28 6 41 21 27 11 5 14 36 48 45 10 42 45 40 4 11 41 23 47 31 34 4 42 49 48 9 37 34 25 27 30 27 44 33 30 25 22 13 25 41 8 34 32 22 11 12 32 9 37 9 42 7 37 13 20 40 28 26 2 6 2 49 41 46 11 9 32 18 43 28 39 48 45 36 18 10 28 35 26 5 20 12 16 2 34 28 31 13 18 39 40 1 39 12 33 31 1 31 46 1 47 38 39 49 32 12 2 8 16 27 48 41 16 27 38 42 21 27 26 8 31 41 20 43 47 5 39 25 47 34", "78 124 41\n5 28 46 46 13 48 36 2 28 31 31 12 9 28 40 35 34 50 50 30 17 11 6 36 16 30 29 8 18 16 21 8 15 30 29 20 12 5 29 20 11 44 12 42 49 10 11 7 25 15 2 38 30 29 17 34 4 5 44 49 25 15 16 33 26 8 8 34 21 9 33 16 14 8 43 50 45 17 15 43 44 22 37 36 22 47 6 13 49 48 37 44 50 9 35 13 38 31 15 6 35 48 22 14 18 8 40 18 4 23 2 26 41 41 27 40 43 33 2 17 11 40 42 32", "51 153 26\n19 32 28 7 25 50 22 31 29 39 5 4 28 26 24 1 19 23 36 2 50 50 33 28 15 17 31 35 10 40 16 7 6 43 50 29 20 25 31 37 10 18 38 38 44 30 36 47 37 6 16 48 41 49 14 16 30 7 29 42 36 8 31 37 26 15 43 42 32 3 46 12 16 37 33 12 18 16 15 14 46 11 2 50 34 34 34 32 28 24 44 12 9 38 35 12 11 15 2 6 28 35 14 46 25 30 9 1 26 5 35 26 4 32 2 30 36 29 22 4 5 1 44 38 6 48 48 6 43 45 24 19 44 18 37 18 40 45 25 35 20 27 21 29 43 18 26 46 22 39 29 41 1", "100 10 5\n10 8 7 5 8 1 2 4 3 10", "100 10 8\n1 8 9 7 6 4 4 6 8 5", "1 1 1\n1", "1 1 1\n2", "1 1 1\n100", "100 1 1\n100", "99 1 1\n100", "100 2 1\n100 1"], "outputs": ["1", "-1", "0.666667", "0.000000", "0.380435", "0.420946", "0.999860", "0.097561", "0.885750", "0.971132", "0.525158", "0.433479", "0.891560", "0.259627", "0.793743", "0.000000", "0.414860", "0.362240", "0.563739", "0.132213", "0.165731", "0.299854", "0.504558", "0.706768", "0.470538", "0.298885", "0.437111", "0.218709", "0.183488", "-1", "-1", "0.000000", "0.000000", "0.000000", "1", "1", "1"]}
UNKNOWN
PYTHON3
CODEFORCES
49
e56de7aaa165df18e9b6695e795b6e28
Helpful Maths
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. The first line contains a non-empty string *s* — 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. Print the new sum that Xenia can count. Sample Input 3+2+1 1+1+3+1+3 2 Sample Output 1+2+3 1+1+1+3+3 2
[ "list = input().split(\"+\")\r\nlist.sort()\r\noutput = \"+\".join(list)\r\nprint(output)", "nums = [int(x) for x in input().split(\"+\")]\n\nnums.sort()\n\n\nstring = \"\"\n\nfor x in nums:\n string += f\"{str(x)}+\"\nstring = string[:len(string)-1]\n\nprint(string)", "n = input()\r\nn = n.split('+')\r\nn = sorted(n)\r\nk = '+'\r\nprint(k.join(n))", "n = input()\r\na = b = c = 0\r\nfor i in range(0, len(n), 2):\r\n if n[i] == '1':\r\n a += 1\r\n elif n[i] == '2':\r\n b += 1\r\n else:\r\n c += 1\r\nd = \"1+\" * a + \"2+\" * b + \"3+\" * c\r\nprint(d[:-1])\r\n\r\n \r\n\r\n", "from math import floor\r\ninp = list(input())\r\ninp1 = []\r\nout = \"\"\r\nfor i in inp:\r\n if i != \"+\":\r\n inp1.append(i)\r\ninp = sorted(inp1)\r\nfor item in inp:\r\n out = out + item + \"+\"\r\nprint(out[:-1])\r\n", "s1 = input()\r\nnums=[]\r\nfor i in s1 :\r\n if i.isdigit():\r\n nums.append((\"+\"+i))\r\nnums.sort()\r\nx=(\"\".join(nums[0:]))\r\nprint(x.replace(\"+\",\"\",1))\r\n", "a=input()\r\nb=[]\r\nfor i in range(0,len(a),2):\r\n b.append(a[i])\r\nb.sort()\r\nb=\"+\".join(b)\r\nprint(b)\r\n\r\n \r\n", "s = str(input())\r\n\r\ns1 = s.split('+')\r\nprint('+'.join(sorted(s1)))", "nums = input().split('+')\r\nnums.sort()\r\nnums = '+'.join(nums)\r\nprint(nums)", "lst=input().split(\"+\")\r\nlst.sort()\r\nprint(\"+\".join(lst))", "arr = input().split(\"+\")\n\narr.sort()\n\nprint('+'.join(arr))", "# Helpful Maths\r\nformula = input()\r\nnumber = list(formula.split('+'))\r\nnumber.sort()\r\nprint('+'.join(number))\r\n", "s=input().split(\"+\")\r\nsort=sorted(s)\r\nnew=\"+\".join(sort)\r\nprint(new)", "s=input(\"\")\nl=s.split(\"+\")\nv=sorted(l)\nq=\"+\".join(v)\nprint(q)", "# import sys\r\n# sys.stdout=open('output.txt','w')\r\n# sys.stdin=open('input.txt','r')\r\n\r\ns=input()\r\nn1=n2=n3=0\r\nfor i in range(0,len(s),2):\r\n if s[i]=='1':\r\n n1+=1\r\n elif s[i]=='2':\r\n n2+=1\r\n else :\r\n n3+=1\r\nss=\"1+\"*n1 + \"2+\"*n2 + \"3+\"*n3\r\n# `print (ss[:-1])` is printing the string `ss` without the last character.\r\nprint (ss[:-1])", "str = input().split(\"+\")\r\nfor i in range(len(str)):\r\n for j in range(0,len(str)-i-1):\r\n if str[j]>str[j+1]:\r\n t=str[j]\r\n str[j]=str[j+1]\r\n str[j+1]=t\r\nfstr='';\r\ni=0;\r\nwhile(i!=len(str)):\r\n if i<len(str)-1:\r\n fstr+=str[i]+'+'\r\n i+=1\r\n else:\r\n fstr+=str[i]\r\n break\r\nprint(fstr)", "# Helpful maths\r\n\r\ns = input().split(\"+\")\r\ns.sort()\r\nresult = \"\"\r\n\r\nfor i in range(len(s)):\r\n if (i == (len(s) - 1)):\r\n result += s[i]\r\n else :\r\n result += f\"{s[i]}+\"\r\n\r\nprint(result)", "lst = input().split('+')\r\na = ''\r\nfor i in range(0, len(lst)):\r\n for j in range(i, len(lst)):\r\n if int(lst[i]) >= int(lst[j]):\r\n lst[i], lst[j] = lst[j], lst[i]\r\nfor k in range(len(lst)):\r\n if k == len(lst)-1:\r\n a = a + lst[k]\r\n else:\r\n a = a + lst[k] + '+'\r\nprint(a)", "s= input()\r\nnumbers= s.split('+')\r\nnum_l= [int(num) for num in numbers]\r\nnum_l.sort()\r\nnum_s=[str(num) for num in num_l]\r\noutput= '+'.join(num_s)\r\nprint(output)", "x=input()\r\n\r\n\r\nl=list(map(str,x))\r\nq=[]\r\n\r\n\r\nfor i in range(len(l)):\r\n if l[i]!=\"+\":\r\n q.append(int(l[i]))\r\n \r\nq.sort()\r\n\r\nprint(*q,sep=\"+\")\r\n", "str = input()\r\n# str.replace(\"+\",\"\")\r\nlis = str.split(\"+\")\r\nfor i in range(len(lis)):\r\n lis[i] = int(lis[i])\r\nlis = sorted(lis)\r\nfor i in range(len(lis)-1):\r\n print(f\"{lis[i]}+\",end=\"\")\r\n \r\n \r\nprint(lis[-1])", "a = str(input())\r\nb = a.split(\"+\")\r\n\r\nc = [int(x) for x in b]\r\n\r\nc.sort()\r\n\r\nd = '+'.join(map(str, c))\r\nprint(d)", "inStr = input()\r\n\r\nnums = [int(num) for num in inStr.split('+')]\r\nnums.sort()\r\n\r\nres_str = '+'.join(map(str, nums))\r\n\r\nprint(res_str)", "expression = input()\r\n\r\n# Split the expression using '+'\r\nnumbers = expression.split('+')\r\n\r\n# Convert the numbers to integers\r\nnumbers = [int(num) for num in numbers]\r\n\r\n# Sort the numbers in ascending order\r\nnumbers.sort()\r\n\r\n# Convert the numbers back to strings\r\nnumbers_str = [str(num) for num in numbers]\r\n\r\n# Convert the list of numbers to a single string\r\nrearranged_expression = '+'.join(numbers_str)\r\n\r\nprint(rearranged_expression)", "input_string = input()\ninput_string_array = input_string.split(\"+\")\nnum_arr = []\n\nfor num in input_string_array:\n num_arr.append(int(num))\n\nnum_arr.sort()\nstring = \"\"\n\nfor num in num_arr:\n string += str(num)\n string += \"+\"\n\nstring = string[:-1]\nprint(string)", "l = [int(x) for x in input().split('+')]\r\nl.sort()\r\nprint(*l,sep=\"+\")\r\n", "s = input()\r\na = [int(i) for i in s.split('+')]\r\na.sort()\r\na = list(map(str,a))\r\nprint('+'.join(a))", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Oct 3 23:26:20 2023\r\n\r\n@author: 袁兆瑞\r\n\"\"\"\r\n\r\nstr = input()\r\nlist = ['1'] * str.count('1')+ ['2'] * str.count('2') + ['3'] * str.count('3')\r\nprint('+'.join(list))", "def addOrder():\r\n x = str(input())\r\n firstL = x.replace(\"+\",\"\")\r\n secondL = list(firstL)\r\n secondL.sort()\r\n thirdL = \"+\".join(secondL)\r\n\r\n return thirdL\r\n\r\nprint(addOrder())\r\n", "lst=list(map(int,input().split(\"+\")))\r\nlst.sort()\r\nanswer = '+'.join(map(str,lst))\r\nprint(answer)\r\n", "v = list(map(int, input().split('+')))\r\n\r\nv = sorted(v)\r\n\r\nprint(\"+\".join(map(str,v)))\r\n", "s = input()\r\nnumbers = s.split(\"+\")\r\nnumbers.sort()\r\nnumbers=\"+\".join(numbers)\r\nprint(numbers)\r\n", "# Step 1: Parse the input string\r\ns = input().split('+')\r\n\r\n# Convert the string numbers to integers\r\nnumbers = [int(x) for x in s]\r\n\r\n# Step 2: Sort the list in non-decreasing order\r\nnumbers.sort()\r\n\r\n# Step 3: Build the new sum string\r\nnew_sum = '+'.join(map(str, numbers))\r\n\r\n# Step 4: Print the new sum string\r\nprint(new_sum)\r\n", "s = input()\r\n\r\nsummands = []\r\n\r\nfor char in s:\r\n if char.isdigit():\r\n summands.append(char)\r\n\r\n\r\nsummands.sort()\r\n\r\nnew_sum = '+'.join(summands)\r\nprint(new_sum)\r\n", "formula = input()\r\nnew_arr = formula.split('+')\r\nfor i in range(len(new_arr)):\r\n new_arr[i] = int(new_arr[i])\r\n\r\nnew_arr.sort()\r\nfor i in range(len(new_arr)):\r\n if i != len(new_arr) - 1:\r\n new_arr[i] = str(new_arr[i]) + '+'\r\n else:\r\n new_arr[i] = str(new_arr[i])\r\n\r\nprint(''.join(new_arr))", "store = []\r\nstring = input()\r\n\r\nfor i in string:\r\n if i != '+':\r\n store.append(i)\r\n\r\nstore.sort()\r\nprint('+'.join(store))", "n=input()\r\na=sorted(n.split('+'))\r\nc = '+'.join(a)\r\nprint(c)\r\n", "s = input()\r\nl = []\r\n\r\nfor i in s:\r\n if i.isdigit():\r\n l.append(i)\r\n\r\nl.sort()\r\n\r\nfor i in range(len(l)):\r\n print(l[i], end=\"\")\r\n if i != len(l) - 1:\r\n print(\"+\", end=\"\")", "l=input().split(\"+\")\r\nl.sort()\r\nn=len(l)\r\nfor i in range(n):\r\n if(i!=(n-1)):\r\n print(l[i],end=\"+\")\r\n else:\r\n print(l[i])", "s = input()\r\nfq = 4*[0] # the first is no use.\r\nfor i in range(0, len(s), 2):\r\n fq[int(s[i])] += 1\r\nns = ''\r\nfor i in range(1,4) :\r\n while fq[i]>0 :\r\n fq[i] -= 1\r\n ns += str(i)\r\nprint('+'.join(ns))", "'''\nA. Helpful Maths\nhttps://codeforces.com/problemset/problem/339/A\n'''\nimport math\nfrom collections import defaultdict, deque\n\ndef input_str():\n return input()\n\ndef input_int():\n return int(input())\n\ndef input_ints(sep=' '):\n return list(map(int, input().split(sep)))\n\ndef input_strs(sep=' '):\n return input().split(sep)\n\ndef main():\n ints = input_strs('+')\n ints.sort()\n print('+'.join(ints))\n\nif __name__ == '__main__':\n main()\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Oct 2 20:24:30 2023\r\n\r\n@author: 苏柔德 2300011012\r\n\"\"\"\r\nop=input().split('+')\r\nop=sorted(op)\r\nprint('+'.join(op))", "import heapq\r\ns=input()\r\nl=s.split(\"+\")\r\nd={}\r\nfor i in l:\r\n d[i]=d.get(i,0)+1\r\nnew_list=[[i,d[i]]for i in d]\r\nheapq.heapify(new_list)\r\nans=\"\"\r\nfor i in range(len(new_list)):\r\n t=heapq.heappop(new_list)\r\n for i in range(t[1]):\r\n ans+=t[0]+\"+\"\r\nprint(ans[0:-1])\r\n \r\n \r\n\r\n\r\n\r\n\r\n", "str1=str(input())\r\nnumbers = str1.split(\"+\")\r\nnumbers.sort()\r\noutput_str = \"+\".join(numbers)\r\nprint(output_str)", "# Input\r\ns = input()\r\n\r\n# Split the input string by '+', convert the parts to integers, and sort them\r\nsummands = sorted(map(int, s.split('+')))\r\n\r\n# Convert the sorted summands back to strings and join them with '+'\r\nnew_sum = '+'.join(map(str, summands))\r\n\r\n# Output the rearranged sum\r\nprint(new_sum)\r\n", "s = input()\r\n\r\nprint('+'.join(sorted([letter for letter in s if letter == '1' or letter == '2' or letter == '3'])))", "def rearrange_summands(sum_string):\r\n summands = sum_string.split(\"+\")\r\n summands.sort()\r\n return \"+\".join(summands)\r\n\r\n\r\n\r\nsum_string = str(input())\r\nrearranged_sum = rearrange_summands(sum_string)\r\nprint(rearranged_sum)\r\n", "inp=input().split(\"+\")\r\ninp.sort()\r\n\r\noutput=\"\"\r\n\r\nfor i in inp:\r\n output=output +i + \"+\"\r\n\r\nprint(output[:-1])", "# Read the input string\r\ns = input()\r\n\r\n# Split the string by '+', convert to integers, and sort them\r\nsummands = sorted(map(int, s.split('+')))\r\n\r\n# Join the sorted summands back into a string with '+' as separators\r\nnew_sum = '+'.join(map(str, summands))\r\n\r\n# Print the new sum that Xenia can count\r\nprint(new_sum)\r\n", "s = input().strip()\r\n \r\nnumbers = [int(ch) for ch in s if ch.isdigit()]\r\nnumbers.sort()\r\n \r\nnew_sum = '+'.join(str(num) for num in numbers)\r\n \r\nprint(new_sum)", "a=input()\r\nl=[]\r\ns=\"\"\r\nfor i in range (0,(len(a)//2)+1):\r\n l.append(int(a[i*2]))\r\nleng=len(l)\r\nfor j in range (0,len(l)):\r\n x=str(min(l))\r\n l.remove(min(l))\r\n if (j+1<leng):\r\n s=s+(x+\"+\")\r\n else:\r\n s=s+x\r\nprint(s)", "s = input()\r\nc = s[::2] \r\nc = sorted(c) \r\nresult = \"+\".join(c) \r\nprint(result)\r\n", "str1=list(map(str,input()))\r\nls=[]\r\nfor i in range(0,len(str1),2):\r\n ls.append(str1[i])\r\nstr2=\"\"\r\nls.sort()\r\nfor i in range(len(ls)-1):\r\n str2=str2+str(ls[i])+'+'\r\nstr2=str2+str(ls[-1])\r\nprint(str2)\r\n", "s = input().split(\"+\")\r\nfor number in range(len(s)):\r\n s[number] = int(s[number])\r\ns.sort()\r\nfor number in range(len(s)):\r\n s[number] = str(s[number])\r\nnew_sum = '+'.join(s) \r\nprint(new_sum)", "str = input()\r\nnum = list(map(int, str.split(\"+\")))\r\nnum.sort()\r\nfor i,n in enumerate(num): \r\n print(n, end='')\r\n if((i+1)!=len(num)):\r\n print('+', end='')", "s=input()\nans=''\nfor i in s :\n if i!= '+':\n ans +=i\nans='+'.join(sorted(ans))\nprint(ans)\n\t\t\t \t\t \t \t\t \t\t \t \t\t \t\t", "\r\nmath = input()\r\nsymbol = \"+\"\r\nmathstr = []\r\nfor char in math:\r\n if char not in symbol:\r\n mathstr += char\r\n mathstr.sort()\r\n mathstr2 = ''.join(mathstr)\r\n ans = \"+\".join(mathstr2)\r\nprint(ans)", "\r\nexpression = input()\r\n\r\n\r\nnumbers = [int(x) for x in expression.split(\"+\")]\r\n\r\n\r\nnumbers.sort()\r\n\r\n\r\nsorted_expression = \"+\".join(map(str, numbers))\r\n\r\n\r\nprint(sorted_expression)", "s=input()\r\nl=[]\r\nfor i in s:\r\n if (i.isdigit()==True):\r\n l.append(int(i))\r\n \r\nl.sort()\r\nfor i in range(0,(len(l)-1)):\r\n print(l[i],\"+\",end=\"\",sep=\"\")\r\nprint(l[len(l)-1])", "expression = input()\r\nexpression = expression.strip()\r\noutput = \"\"\r\nsplit_terms = expression.split(\"+\")\r\nsplit_terms.sort()\r\nfor i, num in enumerate(split_terms):\r\n if i == 0:\r\n output = output + num\r\n else:\r\n output = output + \"+\" + num\r\n\r\nprint(output)\r\n\r\n", "s = input()\r\n\r\ncounts = {1:0, 2:0, 3:0}\r\noutput = \"\";\r\nfor item in s:\r\n if item != \"+\":\r\n counts[int(item)] += 1\r\n\r\nfor i in range(1,4):\r\n number = counts.get(i)\r\n for num in range(1,number+1):\r\n output += f\"+{i}\"\r\n\r\nprint(output[1:])", "line = input().split(\"+\")\nstring = \"\"\nfor i in range(len(line)):\n line[i] = int(line[i])\n\nline = sorted(line)\n\nfor i in range(len(line)):\n if i != 0:\n string = string + \"+\" + str(line[i])\n else:\n string = string + str(line[i])\nprint(string)\n", "a=input().split('+')\r\na.sort()\r\nnew='+'.join(a)#py特有\r\nprint(new)", "task = input()\r\nnewList = []\r\nnewWord = \"\"\r\nfor i in range(len(task)):\r\n if task[i] != \"+\":\r\n newList.append(task[i])\r\nnewList = sorted(newList)\r\n\r\nfor i in range(len(newList)):\r\n newWord = newWord + str(newList[i] + \"+\")\r\nprint(newWord[:-1])", "s = input()\r\nn = sorted(list(map(int, s.split(\"+\"))))\r\nfinal = \"\"\r\nfor i in n:\r\n final = final + \"+\" + str(i)\r\nprint(final[1:])", "x=input()\r\nf=[]\r\nfor i in x:\r\n if i != '+':\r\n f.append(i)\r\nf.sort()\r\n\r\n \r\nprint(*f,sep=\"+\")", "def main():\n summands = list(input().split(\"+\"))\n\n for i in range(len(summands)):\n summands[i] = int(summands[i])\n\n summands.sort()\n\n final_message = \"\" + str(summands[0])\n for summand in summands[1:]:\n final_message = final_message + \"+\" + str(summand)\n \n return final_message\n\nif __name__ == \"__main__\":\n print(main())", "l = input().split(\"+\")\r\nl.sort()\r\nk = l[0]\r\nl2 = l[1:]\r\nfor item in l2:\r\n k += \"+\"\r\n k += item\r\nprint(k)", "n = list(map(int, input().split('+')))\r\nn.sort()\r\nn = list(map(str, n))\r\ns = '+'.join(n)\r\nprint(s)", "str1=input(\"\")\r\nl=list(str1)\r\nl1=[]\r\nfor i in range(0,len(l),2):\r\n l1.append(l[i])\r\nl1.sort()\r\nfor i in range(0,len(l),2):\r\n l[i]=l1[int(i/2)]\r\nx=''.join(l)\r\nprint(x)", "import sys\r\n\r\ns = sys.stdin.readline().split()[0].split(\"+\")\r\ns.sort()\r\nprint(\"+\".join(s))", "ch=input()\r\ns=sorted(list(map(int,ch.split(\"+\"))))\r\ns1=map(str,s)\r\nseparator=\"+\"\r\nch = separator.join(s1)\r\nprint(ch)\r\n\r\n", "x= input()\r\nz = x.split(\"+\")\r\nfor i in z :\r\n i = int(i)\r\nz.sort()\r\nfor j in range(len(z)):\r\n if(j == len(z)-1):\r\n print(z[j])\r\n elif(j < len(z)):\r\n print(z[j]+\"+\",end=\"\")", "number = input().split(\"+\")\r\ncount_1 = 0\r\ncount_2 = 0\r\ncount_3 = 0\r\nfor i in range(len(number)):\r\n if number[i] == \"1\":\r\n count_1 += 1\r\n elif number[i] == \"2\":\r\n count_2 += 1\r\n else:\r\n count_3 += 1\r\n\r\nif count_3 != 0:\r\n print(\"1+\" * count_1 + \"2+\" * count_2 + \"3+\" * (count_3 - 1) + \"3\")\r\nelif count_2 != 0:\r\n print(\"1+\" * count_1 + \"2+\" * (count_2 - 1) + \"2\")\r\nelse:\r\n print(\"1+\" * (count_1 - 1) + \"1\")", "# Taking input\r\ns = input().split('+') # Split the string into individual numbers\r\ns.sort() # Sort the numbers\r\n\r\n# Reconstruct the sorted sum\r\nsorted_sum = '+'.join(s)\r\nprint(sorted_sum)\r\n", "s=input()\r\nsum=list(map(int,s.split('+')))\r\nsum.sort()\r\nsum='+'.join((map(str,sum)))\r\nprint(sum)", "a=str(input())\r\nb=a.split(\"+\")\r\nb.sort()\r\nc=str(b[0])\r\nfor i in range(1,len(b)):\r\n c=c+\"+\"+str(b[i])\r\nprint(c)\r\n\r\n", "a = input().split(\"+\")\r\nfor i in range(len(a)):\r\n a[i] = int(a[i])\r\na.sort()\r\ns = \"\"\r\nfor i in range(len(a)-1):\r\n s += f'{a[i]}+'\r\ns += str(a[-1])\r\nprint(s)", "'''程文奇 2100015898'''\r\ns=input().split('+')\r\ns.sort()\r\nprint('+'.join(s))", "num=input().split(\"+\")\r\nnum.sort()\r\nprint(\"+\".join(num))", "a=sorted(input())\r\ns=\"\".join(a)\r\nt=\"\"\r\nfor i in s:\r\n if i.isdigit()==True:\r\n t+=i\r\nb=\"+\".join(t)\r\nprint(b)\r\n", "l=[]\ns=input()\nfor i in s:\n if i=='+':\n continue\n else:\n l.append(i)\n\nl.sort()\nc=0\nfor i in l:\n if c==len(l)-1:\n print(i)\n break\n else:\n print(i+'+',end='')\n c+=1\n\t\t \t\t \t\t \t\t\t\t \t \t\t \t\t \t", "n = (input())\r\nm = list(n.strip(\"\"))\r\nlenth = len(n)\r\n\r\nfor i in range(0, lenth -1, 2):\r\n for j in range(i + 2, lenth, 2):\r\n if ((m[i]) > (m[j])):\r\n tmp = m[i]\r\n m[i] = m[j]\r\n m[j] = tmp\r\nprint(''.join(m))", "#3-5\r\nsummans=[int(x) for x in input().split('+')]\r\nsummans.sort()\r\nprint('+'.join([str(y) for y in summans]))\r\n", "mylist = list(input())\r\nfor i in mylist:\r\n if i == \"+\":\r\n mylist.remove(i)\r\nmylist.sort()\r\noutput = \"\"\r\nq = 0\r\nfor n in mylist:\r\n output = output + n\r\n q += 1\r\n if q == len(mylist):\r\n break\r\n output += \"+\"\r\nprint(output)\r\n", "numbers = input().split('+')\r\namount = len(numbers)\r\n\r\nfor i in range(amount):\r\n for j in range(i, amount):\r\n if numbers[i] > numbers[j]:\r\n c = numbers[i]\r\n numbers[i] = numbers[j]\r\n numbers[j] = c\r\n\r\nans = ''\r\nprint(*numbers, sep = '+')", "es=list(map(int,input().split('+')))\r\nes.sort()\r\nprint(es[0],end=\"\")\r\nfor i in es[1:]:print(\"+\",i,sep=\"\",end=\"\")", "s=input()\r\ns=sorted(s)\r\nwhile \"+\" in s:\r\n s.remove(\"+\")\r\nnew_str=\"\"\r\nfor i in range(len(s)):\r\n new_str+=s[i]\r\n if i in range(len(s)-1):\r\n new_str+=\"+\"\r\nprint(new_str)", "s = input().split('+')\r\nprint(\"+\".join(sorted(s)))\r\n\r\n\r\n\r\n", "s = input()\r\ncount = [0, 0, 0]\r\nfor digit in s:\r\n if digit.isdigit():\r\n count[int(digit) - 1] += 1\r\nnew_sum = '+'.join(['1']*count[0] + ['2']*count[1] + ['3']*count[2])\r\nprint(new_sum)", "s = input()\r\nnum = []\r\nfor char in s:\r\n if char in '123':\r\n num.append(int(char))\r\nnum.sort()\r\nresult = '+'.join(map(str, num))\r\nprint(result)", "calculation = input()\nlist_of_summands = calculation.split(\"+\")\nfor i in range(len(list_of_summands)):\n list_of_summands[i] = int(list_of_summands[i])\nlist_of_summands.sort()\noutput_calculation = \"\"\nfor i in range(len(list_of_summands)-1):\n output_calculation += str(list_of_summands[i]) + \"+\"\noutput_calculation += str(list_of_summands[len(list_of_summands)-1])\nprint(output_calculation)", "s = input() \r\nnumbers = s.split('+')\r\nnumbers = sorted(numbers)\r\nresult = \"+\".join(numbers)\r\nprint(result)", "temp1 = str(input())\r\ntemp = temp1.split('+')\r\ntemp.sort()\r\nprint('+'.join(temp))", "a=input()\r\nb=[]\r\nfor i in a:\r\n\tif i!='+':\r\n\t\tb.append(i)\r\nb.sort()\t\r\nc=''\r\nfor i in b:\r\n\tc=c+i+'+'\r\nprint(c[0:-1])\r\n", "n = input()\r\nstrr = []\r\nif n.count('1') != 0 :\r\n for i in range(len(n)):\r\n if n[i] == '1':\r\n strr.append('1')\r\nif n.count('2') != 0 :\r\n for i in range(len(n)):\r\n if n[i] == '2':\r\n strr.append('2')\r\nif n.count('3') != 0 :\r\n for i in range(len(n)):\r\n if n[i] == '3':\r\n strr.append('3')\r\nprint('+'.join(strr))", "input1 = list(map(int,input().split(\"+\")))\r\ninput1.sort()\r\nstring = \"\"\r\nfor i in range(len(input1)):\r\n string += str(input1[i])\r\n if i != len(input1)-1:\r\n string += \"+\"\r\nprint(string)", "def rearrange_sum(s):\n summands = [int(char) for char in s if char.isdigit()] # Extract the summands as integers\n summands.sort() # Sort the summands in non-decreasing order\n new_sum = '+'.join(str(summand) for summand in summands) # Join the summands back into a string\n return new_sum\n\n\ns = input()\nnew_sum = rearrange_sum(s)\nprint(new_sum)\n \t \t \t\t\t \t \t\t\t \t \t \t\t \t \t\t \t", "s=input()\r\nl=s.split(\"+\")\r\nl.sort()\r\nprint(l[0],end=\"\")\r\nfor i in l[1:]:\r\n print(\"+\",i,end=\"\",sep=\"\")\r\n", "n_values = input()\r\nlongitud=len(n_values)\r\n#print(longitud)\r\ns=[x for x in range(longitud)]\r\na=0\r\nb=0\r\nc=0\r\nfor i in range(longitud):\r\n if n_values[i]==\"+\":\r\n continue\r\n elif n_values[i]==\"1\":\r\n a=a+1\r\n elif n_values[i]==\"2\":\r\n b=b+1\r\n elif n_values[i]==\"3\":\r\n c=c+1\r\n#print(\"a\", a)\r\n#print(\"b\", b)\r\n#print(\"c\", c)\r\nfor i in range(longitud):\r\n if i%2!=0:\r\n s[i]=\"+\"\r\n else:\r\n if a!=0:\r\n s[i]=\"1\"\r\n a=a-1\r\n else:\r\n if b!=0:\r\n s[i]=\"2\"\r\n b=b-1\r\n else:\r\n if c!=0:\r\n s[i]=\"3\"\r\n c=c-1\r\n #print(s[i])\r\nresultado=\"\"\r\nfor elemento in s:\r\n resultado += elemento\r\nprint(resultado)", "a=input().split(\"+\")\r\nb=[]\r\nfor i in range(len(a)):\r\n if int(a[i])==1:\r\n b.append(\"1\")\r\n b.append(\"+\")\r\nfor i in range(len(a)):\r\n if int(a[i])==2:\r\n b.append(\"2\")\r\n b.append(\"+\")\r\nfor i in range(len(a)):\r\n if int(a[i])==3:\r\n b.append(\"3\")\r\n b.append(\"+\")\r\nprint(''.join([str(b[i]) for i in range(len(b)-1)]))", "n=input().split(\"+\")\r\nn.sort()\r\nstring='+'.join([i for i in n])\r\nprint(string)", "nums = input()\r\n\r\nnums_ = nums.split('+')\r\nnums_.sort()\r\n\r\nprint('+'.join(nums_))", "a=list(map(int,input().split('+')))\r\na.sort()\r\nprint(a[0],end=\"\")\r\nif len(a)>1:\r\n for i in range(1,len(a)):\r\n print(\"+\",a[i],sep=\"\",end=\"\")\r\n", "s = input()\r\n\r\ncount_1 = s.count('1')\r\ncount_2 = s.count('2')\r\ncount_3 = s.count('3')\r\n\r\nnew_sum = '1+' * count_1 + '2+' * count_2 + '3+' * count_3\r\n\r\nnew_sum = new_sum.rstrip('+')\r\n\r\nprint(new_sum)\r\n", "n=input()\r\nnumbers=['1','2','3']\r\nexpression=[]\r\nfor i in range(len(n)):\r\n if n[i] in numbers:\r\n expression.append(n[i])\r\nexpression.sort()\r\nfor i in range(len(expression)):\r\n if i==len(expression)-1:\r\n print(expression[i])\r\n else:\r\n print(\"{}+\".format(expression[i]),end='')\r\n\r\n\r\n\r\n\r\n", "nums = list(map(int, input().split('+')))\nnums.sort()\nprint(*nums, sep='+')\n", "a=input()\r\nb=a.split(\"+\")\r\nb.sort()\r\nfor i in range(len(b)):\r\n if(i!=len(b)-1):\r\n print(str(b[i])+\"+\",end=\"\")\r\n else:\r\n print(str(b[i]))", "x=list(input().split('+'))\r\nx.sort()\r\ny=''\r\nfor i in x:\r\n if y=='':\r\n y+=i\r\n else:\r\n y+='+'+i\r\nprint(y)\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Sep 29 20:41:56 2023\r\n\r\n@author: HXY\r\n\"\"\"\r\nimport re\r\n\r\ns = input().strip() + \"+\"\r\nnums = []\r\nfor num in re.findall(r'\\d+', s):\r\n nums.append(int(num))\r\nnums.sort()\r\nres = '+'.join(str(num) for num in nums)\r\nprint(res)\r\n", "s = list(map(int,input().replace('+',' ').split()))\r\nfor i in range(len(s)):\r\n for j in range(i,len(s)):\r\n if s[i]>s[j]:\r\n c=s[i]\r\n s[i]=s[j]\r\n s[j]=c\r\ns = str(s).replace(\", \",\"+\")\r\ns = s.replace(\"[\",\"\")\r\nprint(s.replace(\"]\",\"\"))\r\n", "r = input().split(\"+\")\r\n\r\nfor i in range(len(r)):\r\n r[i] = int(r[i])\r\n \r\nr.sort(reverse = False)\r\n\r\nfor i in range(len(r)):\r\n if i == len(r)-1:print(r[i], end=\"\")\r\n else:print(r[i], end=\"+\")", "t=list(map(int,input().split(\"+\")))\r\nt.sort()\r\nfor i in range(len(t)-1):\r\n print(t[i],end=\"+\")\r\nprint(t[-1])", "st = input().split('+')\r\nst.sort()\r\nprint(*st, sep='+')\r\n", "L = input().split('+')\r\nL.sort()\r\nans = \"\"\r\nfor i in range(len(L)):\r\n if i!=len(L)-1:\r\n ans+=L[i]\r\n ans+='+'\r\n else:\r\n ans+=L[i]\r\nprint(ans)", "a = list(input())\ncount_1 = count_2 = count_3 = 0\nb = c = \"\"\n\nfor i in range(0, len(a), 2):\n if a[i] == \"1\":\n count_1 += 1\n elif a[i] == \"2\":\n count_2 += 1\n elif a[i] == \"3\":\n count_3 += 1\n\nfor i in range(count_1):\n b += \"1+\"\n\nfor i in range(count_2):\n b += \"2+\"\n\nfor i in range(count_3):\n b += \"3+\"\n\nc = b[0:-1]\nprint(c)", "add = input()\nnums = []\n\nfor i in range (len(add)):\n txt = add[i:i+1]\n if txt.isnumeric():\n nums.append(int(txt))\n\nnums.sort()\n\nfor j in range (len(nums)):\n if j == len(nums)-1:\n print (nums[j], end = \"\")\n else:\n print (nums[j], end = \"+\")\n \t \t\t \t\t \t \t \t \t\t \t \t \t \t \t\t", "s = input().split('+')\r\ns = sorted(map(int, s))\r\nprint('+'.join(map(str, s)))", "def remove(string):\r\n return string.replace(\" \",\"\")\r\n\r\na = input()\r\na = remove(a)\r\nmy_list = []\r\n\r\njavab = \"\"\r\n\r\nfor i in a:\r\n if i != '+':\r\n my_list.append(int(i))\r\n my_list.sort()\r\nfor i in my_list:\r\n javab = javab + str(i) + '+'\r\nprint(javab[:len(javab)-1])", "ex = input()\ncount_1 = ex.count(\"1\")\ncount_2 = ex.count(\"2\")\ncount_3 = ex.count(\"3\")\noutput = \"1\"*count_1+\"2\"*count_2+\"3\"*count_3\nfor i in range(len(output)):\n if i < len(output)-1:\n print(output[i]+\"+\", end=\"\")\n else:\n print(output[i])\n \n", "line=list(map(int,input().split('+')))\r\nline.sort()\r\nfor i in range(len(line)):\r\n if not i:\r\n print(line[0],end='')\r\n else:\r\n print(f'+{line[i]}',end='')", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Oct 2 18:04:15 2023\r\n\r\n@author: masiyu004\r\n\"\"\"\r\n\r\ny=list(input())\r\na=b=c=0\r\nfor i in range(len(y)):\r\n if y[i]=='1':\r\n a+=1\r\n if y[i]=='2':\r\n b+=1\r\n if y[i]=='3':\r\n c+=1\r\nx=[0]*(a+b+c) \r\nn=[0,a,a+b,a+b+c]\r\nfor i in range(3):\r\n for j in range(n[i],n[i+1]):\r\n x[j]=i+1\r\n if j!=a+b+c-1:\r\n print(x[j],end='+')\r\n else:\r\n print(x[j])\r\n ", "number = input()\r\nnumbers = number.split(\"+\")\r\n\r\nnumbers.sort()\r\n\r\nfinal = numbers.pop()\r\n\r\nfor i in numbers:\r\n print(i, end=\"+\")\r\n \r\nprint(final)", "s=input();l=[]\r\nfor i in s:\r\n if i.isnumeric():\r\n l.append(i)\r\nl.sort()\r\nprint('+'.join(l))", "s = input()\r\nnumbers = []\r\nfor char in s:\r\n if char == '1':\r\n numbers.append(char)\r\nfor char in s:\r\n if char == '2':\r\n numbers.append(char)\r\nfor char in s:\r\n if char == '3':\r\n numbers.append(char)\r\nresult = '+'.join(numbers)\r\nprint(result) \r\n", "input_sum = input()\r\nsummands = list(map(int, input_sum.split('+')))\r\nsummands.sort()\r\nnew_sum = '+'.join(map(str, summands))\r\nprint(new_sum)\r\n", "#赵语涵2300012254\r\nnums = input().split(sep='+')\r\nnums.sort()\r\nprint('+'.join(nums))", "import sys\r\ninput= sys.stdin.readline\r\ngi= lambda: list(map(int, input().split()))\r\ngs= lambda: list(input().split())\r\nprob=gs()[0]\r\nb=[]\r\n\r\nfor i in range(int(len(prob)/2)+1):\r\n b.append(int(prob[2*i]))\r\nb.sort()\r\nres=str(b[0])\r\nfor i in range(len(b)-1):\r\n res=res+\"+\"+str(b[i+1])\r\nprint(res)\r\n \r\n\r\n\r\n \r\n\r\n\r\n \r\n\r\n\r\n", "'''\r\n2300015897\r\n吴杰稀\r\n光华管理学院\r\n'''\r\n\r\nequation = input()\r\nequ_list = [_ for _ in equation if _ != \"+\"]\r\nequ_list.sort()\r\nnew_equation = '+'.join(equ_list)\r\nprint(new_equation)", "n=input()\r\nnbs=(len(n)+1)//2\r\nc=n.split(\"+\")\r\nfor i in range(nbs):\r\n c[i]=int(c[i])\r\npermutation = True\r\npassage = 0\r\nwhile permutation == True:\r\n permutation = False\r\n passage = passage + 1\r\n for i in range(0, len(c) - passage):\r\n if c[i] > c[i + 1]:\r\n permutation = True\r\n c[i], c[i + 1] = c[i + 1],c[i]\r\nch=str(c[0])\r\nfor i in range(1,nbs):\r\n ch=ch+\"+\"+str(c[i])\r\nprint(ch)", "s=input()\r\nnum=sorted(map(int,s.split('+')))\r\nnew_num='+'.join(map(str,num))\r\nprint(new_num)\r\n", "s = input()\r\non = s.count(\"1\")\r\ntw = s.count(\"2\")\r\nth = s.count(\"3\")\r\ns2 = \"1+\" * on + \"2+\" * tw + \"3+\" * th\r\nprint(s2[:-1:])", "s = input().replace(\"+\",\"\")\r\nlis =[]\r\n\r\nfor i in s:\r\n lis.append(int(i))\r\n\r\nlis.sort()\r\n\r\nfor i in range(len(lis)):\r\n print(lis[i],end=\"\")\r\n if i < len(lis)-1:\r\n print (\"+\",end=\"\")", "b = list(input())\nx = \"\"\nfor i in range(0, len(b), 2):\n x = x + str(b[i])\nx = list(x)\nx.sort()\nb = '+'.join(x)\nprint(b)\n \t\t\t \t \t \t\t\t\t\t\t\t \t\t\t\t", "\r\na=input()\r\na=a.split('+')\r\na.sort()\r\na='+'.join(a)\r\nprint(a)", "# Input the sum as a string\r\ns = input().split('+')\r\n\r\n# Convert the string to a list of integers and sort it\r\nsummands = [int(x) for x in s]\r\nsummands.sort()\r\n\r\n# Convert the list of integers back to a string\r\nresult = '+'.join(map(str, summands))\r\n\r\n# Print the new sum that Xenia can count\r\nprint(result)\r\n", "r=input()\r\na=r.split(\"+\")\r\nb=[]\r\ni=0\r\nfor i in a:\r\n b.append(int(i))\r\ni=0\r\nwhile i<len(b):\r\n j=0\r\n while j<len(b)-1:\r\n if b[j]>b[j+1]:\r\n t=b[j]\r\n b[j]=b[j+1]\r\n b[j+1]=t\r\n j+=1\r\n i+=1\r\nprint(b[0],end=\"\")\r\ni=1\r\nwhile i<len(b):\r\n print(\"+\",end=\"\")\r\n print(b[i],end=\"\")\r\n i+=1", "s = input()\r\nt = s.split('+')\r\nsort_t = sorted(t)\r\nnewsumma = '+'.join(sort_t)\r\nprint(newsumma)", "x=input()\r\nm=list(map(int,x.split(\"+\")))\r\nm.sort()\r\ns='+'.join(map(str,m))\r\nprint(s)", "toPrint = \"\"\r\nip = input()\r\ntoSort = ip.split(\"+\")\r\nfor i in range(len(toSort)):\r\n toSort[i] = int(toSort[i])\r\ntoSort.sort()\r\nfor i in range(len(toSort)):\r\n toSort[i] = str(toSort[i])\r\nfor i in range(len(toSort)):\r\n toPrint += toSort[i]\r\n toPrint += \"+\"\r\nprint(toPrint[0:-1])", "a = input().split(\"+\")\r\nl = list(a)\r\nl. sort()\r\nprint(*l, sep=\"+\")", "s = input()\r\nlst = []\r\nfor i in range(0,len(s),2):\r\n lst.append(int(s[i]))\r\nlst.sort()\r\n#print(str(lst)[1:-1].replace(\", \",\"+\"))\r\nres = ''\r\nfor x in lst:\r\n res+=str(x)+'+'\r\nprint(res[:-1])\r\n\r\n\r\n'''\r\ndef str_to_lst(s: str):\r\n lst = [int(s[i]) for i in range(0, len(s), 2)]\r\n lst.sort()\r\n return str(lst)[1:-1].replace(\", \",\"+\")\r\n\r\n\r\nasd = input()\r\nprint(str_to_lst(asd))'''", "a = list(input().split(\"+\"))\r\na.sort()\r\n\r\nb = len(a)\r\n\r\nans = \"\"\r\nfor i in range(b):\r\n ans = ans + a[i] + \"+\"\r\n\r\nprint(ans[:-1])", "n = list(map(int,input().split('+')))\r\n \r\nn.sort()\r\n \r\nm = \"+\".join(list(map(str,n)))\r\n \r\nprint(m)", "s = input().split('+')\r\nc = sorted(s)\r\np = c[0]\r\nfor i in range(len(c)):\r\n if i == 0:\r\n continue\r\n else:\r\n p += f\"+{c[i]}\"\r\nprint(p)\r\n", "s=input()\r\ns=s.replace('+',\"\")\r\ns=list(s)\r\ns.sort()\r\nfor i in range(len(s)-1):\r\n print(s[i],end=\"+\")\r\nprint(s[-1])", "s = list(map(int, input().split('+')))\r\ns.sort()\r\n\r\ninteger_list = list(map(str, s))\r\nreordered_nums = '+'.join(integer_list)\r\n\r\nprint(reordered_nums)", "arr = input().split(\"+\")\r\narr2 = sorted(arr)\r\nprint(\"+\".join(arr2))", "def inp(single_testcase=True):\r\n return 1 if single_testcase else int(input())\r\ndef intlist() -> list:\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 intmap():\r\n return(map(int,input().split()))\r\n\r\nt = inp()\r\n\r\ndef solve():\r\n nums = input().split('+')\r\n nums.sort()\r\n \r\n return '+'.join(nums)\r\n\r\nfor _ in range(t):\r\n print(solve())", "nums=list(map(int,input().split('+')))\r\nfor l in range(0,len(nums)-1):\r\n for i in range(0,len(nums)-1):\r\n if nums[i]>nums[i+1]:\r\n a=nums[i]\r\n b=nums[i+1]\r\n nums[i+1]=a\r\n nums[i]=b\r\nfor k in range(0,len(nums)-1):\r\n print(nums[k],end='+')\r\nprint(nums[len(nums)-1])", "l=list(map(int,input().split(\"+\")))\r\nl.sort()\r\ns=''\r\nfor i in l:\r\n\ts+=str(i)+'+'\r\ns=s[0:len(s)-1]\r\nprint(s)\r\n", "s = input()\r\narr= s.split(\"+\")\r\narr.sort()\r\nprint(\"+\".join(arr))", "sentence = input()\r\nsplited = sentence.split(\"+\")\r\nsplited.sort()\r\nresult_str = \"\"\r\nfor i in range(len(splited)):\r\n result_str += f\"{splited[i]}+\"\r\nprint(result_str[:-1])", "l = input().split(\"+\")\r\nnewl = []\r\nfor n in l:\r\n newl.append(int(n))\r\n\r\nnewl.sort()\r\nfor i in range(len(newl)-1):\r\n print(f\"{newl[i]}+\", end = \"\")\r\nprint(newl[-1])", "print('+'.join(sorted(list(input().split('+')))))", "s = input().strip()\r\nx= s.split('+')\r\nx = sorted(map(int, x))\r\nresult = '+'.join(map(str, x))\r\nprint(result)\r\n", "s = input().split('+')\r\ns = [int(j) for j in s]\r\ns.sort()\r\ns1 = ''\r\nfor i in range(0, len(s)):\r\n if i != len(s) - 1:\r\n s1 = s1 + str(s[i]) + '+'\r\n else:\r\n s1 = s1 + str(s[i])\r\nprint(s1)\r\n", "def Result(InputSum):\r\n numericValues = InputSum.split(\"+\")\r\n numbers = [int(num) for num in numericValues]\r\n numbers.sort()\r\n for i in range(len(numericValues)):\r\n numericValues[i] = str(numbers[i])\r\n result = \"+\".join(numericValues)\r\n return result\r\n\r\nnewSum = input(\"\")\r\nresult = Result(newSum)\r\nprint (result)", "#Coder_1_neel\r\na=input()\r\nc=\"\"\r\na=a.replace('+',\"\")\r\nl=list(a)\r\nl.sort()\r\nfor num in l:\r\n c=c+num+\"+\"\r\nprint(c[:-1]) \r\n ", "# Read the input string\r\ns = input()\r\n\r\n# Count the occurrences of each digit (1, 2, and 3)\r\ncount = [0, 0, 0]\r\nfor digit in s:\r\n if digit == '1':\r\n count[0] += 1\r\n elif digit == '2':\r\n count[1] += 1\r\n elif digit == '3':\r\n count[2] += 1\r\n\r\n# Create the new sum in non-decreasing order\r\nnew_sum = '+'.join(['1'] * count[0] + ['2'] * count[1] + ['3'] * count[2])\r\n\r\n# Print the new sum\r\nprint(new_sum)\r\n", "a=input()\r\nx=[]\r\ns=''\r\nfor i in range(0,len(a)+1,2):\r\n x.append(int(a[i]))\r\n x.sort()\r\nfor j in x:\r\n s+=str(j)+\"+\"\r\nprint(s[:-1])\r\n", "formula=input().split('+')\r\nn=len(formula)\r\nformula.sort()\r\nfor i in range(n-1):\r\n formula.insert((2*i+1),'+')\r\nprint(''.join(formula))\r\n\r\n", "def rearrange_sum(sum_str):\r\n # 将字符串转换为整数列表并按非递减顺序排序\r\n numbers = sorted([int(char) for char in sum_str if char.isdigit()])\r\n\r\n # 构建新的加法表达式\r\n new_sum = \"+\".join(map(str, numbers))\r\n return new_sum\r\n\r\n# 读取输入的加法表达式\r\nsum_str = input()\r\n\r\n# 重新排列加法表达式并打印结果\r\nnew_sum = rearrange_sum(sum_str)\r\nprint(new_sum)", "# -*- coding: utf-8 -*-\n\"\"\"A. TeamWright.ipynb\n\nAutomatically generated by Colaboratory.\n\nOriginal file is located at\n https://colab.research.google.com/drive/1As7MbHYFOhi8eMcGihWR39YUpjP319n9\n\"\"\"\n\nequation = input().split(\"+\")\nequation.sort()\nprint(\"+\".join(equation))", "number = input().split(\"+\")\r\nnumber.sort()\r\nprint(\"+\".join(number))", "# CF_Problem: 339A_Helpful_Maths\r\n\r\ns = input().split('+')\r\ns.sort()\r\ns = ' '.join(s)\r\ns = s.replace(\" \", \"+\")\r\nprint(s)\r\n", "from sys import stdin\r\n#\r\ndef main():\r\n string = [x for x in stdin.readline().strip().split(\"+\")]\r\n string.sort()\r\n print(\"+\".join(string))\r\nmain()", "inp = list(input())\r\nl = len(inp)\r\nopc = 0\r\nnums = []\r\nans = []\r\nf = True\r\nfor i in inp:\r\n\tif i == \"+\":\r\n\t\topc += 1\r\n\telse:\r\n\t\tnums.append(i)\r\nnums.sort()\r\nnums.reverse()\r\nj = len(nums)-1\r\nfor i in range(l):\r\n\tif f is True:\r\n\t\tans.append(str(nums[j]))\r\n\t\tj -= 1\r\n\t\tf = False\r\n\telse:\r\n\t\tans.append(\"+\")\r\n\t\tf = True\r\nfor i in ans:\r\n\tprint(i, end=\"\")\r\n", "input_string = input().strip()\r\nnumbers = list(map(int, input_string.split('+')))\r\nnumbers.sort()\r\noutput_string = '+'.join(map(str, numbers))\r\nprint(output_string)", "numbers = list(map(int, input().split('+')))\r\nnumbers.sort()\r\nnew_sum = '+'.join(map(str, numbers))\r\nprint(new_sum)", "n= input().split('+')\r\n\r\n'''if len(n)==1:\r\n print(n)'''\r\n\r\nfor i in range(len(n)-1):\r\n if n[i]==n[i+1]:\r\n pass\r\n for i in range(len(n)-1):\r\n if n[i]>n[i+1]:\r\n n[i],n[i+1]=n[i+1],n[i]\r\n\r\nfor i in range(len(n)-1):\r\n print(n[i]+'+',end='')\r\nprint(n[-1])", "n = sorted([int(i) for i in input().split('+')])\r\nfor i in range(len(n)):\r\n n[i] = str(n[i])\r\nprint('+'.join(n))\r\n\r\n", "exp = input()\r\nparts = exp.split('+')\r\nsorted_parts = sorted(parts)\r\nnewexp = '+'.join(sorted_parts)\r\nprint(newexp)\r\n", "if __name__=='__main__':\r\n\tarr = input().split('+')\r\n\tprint('+'.join(sorted(arr)))", "str = [*map(int, input().split(\"+\"))]\r\nstr.sort()\r\n\r\nc = 0\r\nfor i in str:\r\n if c == len(str)-1:\r\n print(f\"{i}\", end=\"\")\r\n else:\r\n print(f\"{i}+\", end=\"\")\r\n c += 1", "str = input()\r\nlst = []\r\nfor i in range(len(str)):\r\n if str[i] != '+':\r\n lst.append(str[i])\r\nlst.sort()\r\nstr1 = ''\r\nfor i in range(len(lst)):\r\n str1 += lst[i]\r\n if (i!= (len(lst)-1)):\r\n str1 += '+'\r\nprint(str1)", "a=input().split(\"+\")\r\nb=list(map(int, a))\r\nb.sort()\r\nfor i in range(len(b)-1):\r\n print(b[i], \"+\", end=\"\", sep=\"\")\r\nprint(b[len(b)-1])", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Oct 3 21:28:14 2023\r\n\r\n@author: huozi\r\n\"\"\"\r\n\r\ns = input().split(\"+\")\r\n\r\n# 对列表进行排序\r\ns.sort()\r\n\r\n# 将排序后的列表转换回字符串\r\nresult = \"+\".join(s)\r\n\r\n# 输出结果\r\nprint(result)", "s = input()\r\nparts = s.split('+')\r\nparts.sort()\r\nnew_sum = '+'.join(parts)\r\nprint(new_sum)", "sum_x = input()\n\nnumbers = sum_x.split(\"+\")\n\nnum = sorted(numbers)\n\nnumus = \"+\".join(num)\n\nprint(numus)\n\n\n", "s = input()\r\ndigit = s.split(\"+\")\r\nsorted_digits = sorted(digit)\r\nresult = \"\"\r\nfor num in sorted_digits:\r\n result = result + num + \"+\"\r\nprint(result[:len(result)-1])", "n = input()\r\nlst = n.split(\"+\")\r\nans = []\r\not = ''\r\nfor i in lst:\r\n ans.append(int(i))\r\nans.sort()\r\nfor i in ans[:len(ans) - 1]:\r\n ot += str(i) + \"+\"\r\not += str(ans[len(ans) - 1])\r\nprint(ot)\r\n", "def arrange(sum):\r\n split = sum.split(\"+\")\r\n split.sort()\r\n arranged_sum = \"+\".join(split)\r\n return arranged_sum\r\nsum = input()\r\nprint(arrange(sum))", "n=list(map(int,input().split('+')))\r\nn.sort()\r\nk=len(n)\r\ns=''\r\n\r\nfor i in range(k-1):\r\n s+=str(n[i])\r\n s+='+'\r\ns+=str(n[k-1])\r\nprint(s)", "x=input().split(\"+\")\r\nn=[]\r\nx.sort(reverse=False)\r\nfor i in x:\r\n n.append(i)\r\n n.append(\"+\")\r\nn.pop(-1)\r\nfor j in n:\r\n print(j,end=\"\")", "s = input()\r\nt = s.split(\"+\")\r\nt.sort()\r\nprint('+'.join(t))", "palabra = str(input())\n\nlista = []\n\nfor i in range(len(palabra)):\n if palabra[i] != \"+\":\n lista.append(int(palabra[i]))\n \nlista.sort()\n\nsalida = \" \"\nfor i in range(len(lista)):\n if salida == \" \":\n salida = str(lista[i])\n else:\n salida = salida+\"+\"+str(lista[i])\n\nprint(salida)\n\t \t \t \t \t \t \t\t \t\t\t\t \t \t\t", "s = str(input())\r\nterms = list(map(int, s.split(\"+\")))\r\nterms.sort()\r\nprint('+'.join(map(str, terms)))\r\n", "m = input()\r\nm = list(map(int,m.split('+')))\r\nm.sort()\r\nm = map(str,m)\r\nmm='+'\r\nprint (mm.join(m))", "s = str(input())\r\nln = len(s)\r\ni = 0\r\ncount = 0\r\nwhile i < ln:\r\n if s[i] == \"+\":\r\n count = count + 1\r\n i = i + 1\r\ni = 0\r\nwhile i < ln:\r\n if s[i] == \"1\":\r\n print(1,end=\"\")\r\n if count > 0:\r\n print(\"+\",end=\"\")\r\n count = count - 1\r\n i = i + 1\r\ni = 0\r\nwhile i < ln:\r\n if s[i] == \"2\":\r\n print(2,end=\"\")\r\n if count > 0:\r\n print(\"+\",end=\"\")\r\n count = count - 1\r\n i = i + 1\r\ni = 0\r\nwhile i < ln:\r\n if s[i] == \"3\":\r\n print(3,end=\"\")\r\n if count > 0:\r\n print(\"+\",end=\"\")\r\n count = count - 1\r\n i = i + 1", "st = input().split('+')\r\n\r\nst.sort()\r\nprint('+'.join(st))\r\n", "s=input().split(\"+\")\r\ns.sort()\r\nout=\"\"\r\nfor i in s:\r\n out=out+i+\"+\"\r\nprint(out[:-1])\r\n", "s = input(\"\")\r\n\r\nnumbers = s[0::2]\r\n\r\nto_int = sorted([int(num) for num in numbers])\r\n\r\nresult = \"+\".join(map(str, to_int))\r\n\r\nprint(result)", "def function(operation):\r\n numbers = [int(a) for a in operation.split(\"+\")]\r\n\r\n numbers.sort()\r\n return numbers\r\n\r\nif __name__ == \"__main__\":\r\n operation = input()\r\n\r\n sortedArray = function(operation)\r\n helpfulOperation = \"\"\r\n for idx, x in enumerate(sortedArray):\r\n if(idx == 0):\r\n helpfulOperation = str(x)\r\n else:\r\n helpfulOperation = helpfulOperation + \"+\" + str(x)\r\n\r\n print(helpfulOperation)", "x = input().split(\"+\")\r\nx.sort()\r\nfinal = \"\"\r\nfor i in range(len(x)-1):\r\n final += x[i] + \"+\"\r\nfinal += x[-1]\r\nprint(final)", "import sys\r\ninput=sys.stdin.readline\r\ns=input().strip(\"\\n\").split(\"+\")\r\ns.sort()\r\nfor i in range(len(s)-1):\r\n print(s[i],end=\"+\")\r\nprint(s[len(s)-1])", "inp = input().split(\"+\")\r\nout = \"\"\r\n\r\nfor i in range(0, len(inp)):\r\n inp[i] = int(inp[i])\r\n\r\ninp.sort()\r\n\r\nfor i in range(0, len(inp)):\r\n if i == len(inp) - 1:\r\n out+=str(inp[i])\r\n else:\r\n out+=str(inp[i])+\"+\"\r\nprint(out)", "list1 = sorted(list(map(int,input().split('+'))))\r\n\r\nfor i in range(len(list1)):\r\n if i==len(list1)-1:\r\n print(list1[i])\r\n else:\r\n print(list1[i],end='+')", "s = input()\r\nlst = []\r\nfor i in s:\r\n if i != \"+\":\r\n lst.append(int(i))\r\nlst.sort()\r\nans = \"\"\r\nfor i in lst:\r\n ans = ans + str(i) + \"+\"\r\nprint(ans[:-1:])", "sumup = list(map(int, input().split(\"+\")))\r\nfor i in range(len(sumup)-1):\r\n mini = i\r\n for j in range(i+1, len(sumup)):\r\n if sumup[j] <= sumup[mini]:\r\n mini = j\r\n sumup[mini], sumup[i] = sumup[i], sumup[mini]\r\nprint(\"+\".join(list(map(str, sumup))))\r\n", "inp = input().split('+')\r\n\r\ninp.sort()\r\n\r\nprint('+'.join(inp))", "def invr():\r\n return(map(int,input().split(\"+\")))\r\n\r\ndef main():\r\n numbers = sorted(list(invr()))\r\n print(\"+\".join(map(str, numbers)))\r\n\r\nif __name__ == '__main__':\r\n main()", "a = input()\r\nb = a.split('+')\r\nb.sort()\r\ns = ''\r\nif len(b) > 1:\r\n for x in b:\r\n s += x + '+'\r\n s = s[:-1]\r\nelse:\r\n s = a\r\nprint(s)", "x=input()\r\n\r\nz=x.split(\"+\")\r\nl=[]\r\nfor i in z:\r\n l.append(i)\r\nl.sort()\r\nresult=\"+\".join(map(str,l))\r\nprint(result)", "s = input()\r\n\r\nn = len(s)\r\n\r\nb = []\r\nfor i in range(n):\r\n if i % 2 != 0:\r\n continue\r\n\r\n b += [int(s[i])]\r\n\r\nb.sort()\r\n\r\nres = \"\"\r\n\r\nfor i in b:\r\n res += f\"{i}+\"\r\n\r\nprint(res[:-1])", "a=list(input())\r\nl=len(a)\r\nfor i in range(l):\r\n for j in range(l-2):\r\n if a[j]>a[j+2]:\r\n a[j],a[j+2]=a[j+2],a[j]\r\nfor i in range(l):\r\n print(a[i],end=\"\")", "x=input()\r\ny=0\r\nl=[]\r\ns=\"\"\r\nfor i in x:\r\n if i==\"+\":\r\n pass\r\n\r\n else:\r\n y=i\r\n l.append(y)\r\nl.sort()\r\ns1=\"\"\r\nfor i in l:\r\n s1+=i+\"+\"\r\nprint(s1[:-1])", "line=input()\r\nc1,c2,c3=0,0,0\r\nfor i in line:\r\n if i==\"1\":\r\n c1+=1\r\n if i==\"2\":\r\n c2+=1\r\n if i==\"3\":\r\n c3+=1\r\ns=\"1+\"*c1+\"2+\"*c2+\"3+\"*c3\r\nprint(s[:-1])\r\n", "import sys\r\n# sys.stdin = open(\"input.txt\", \"r\")\r\n# sys.stdout = open(\"output.txt\", \"w\")\r\n# sys.stderr = open(\"error.txt\", \"w\")\r\n# # your remaining code\r\n\r\n\r\na = list(map(int,input().split(\"+\")))\r\na.sort()\r\nres = \"\"\r\nfor i,n in enumerate(a) :\r\n\tres += (str(n)+\"+\")\r\nprint(res[:-1])\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "def fg():\r\n return int(input())\r\ndef fgh():\r\n return[int(xx) for xx in input().split()]\r\ndef fgt():\r\n return map(int,input().split())\r\ndef fgs():\r\n return input()\r\ns=fgs()\r\na=[]\r\nfor i in range(0,len(s),2):\r\n a.append(int(s[i]))\r\na.sort()\r\nfor i in range(len(a)-1):\r\n print(a[i],end='+')\r\nprint(a[-1])", "s = input()\r\nsummands = sorted(s.split(\"+\"))\r\nprint(\"+\".join(summands))", "nums = [int(x) for x in input().split(\"+\")]\r\nnums.sort()\r\nnums = '+'.join(map(str, nums))\r\nprint(nums)", "operation_input = input()\r\noperations = operation_input.split(\"+\")\r\noperations.sort()\r\nlenght = len(operations)\r\nnew_s = \"\"\r\n\r\nfor _ in range(lenght):\r\n if _ != lenght-1:\r\n new_s += operations[_] + \"+\"\r\n else:\r\n new_s += operations[_]\r\n\r\nprint(new_s)", "s = input()\r\n\r\nnumbers = [int(char) for char in s if char.isdigit()]\r\nnumbers.sort()\r\nnew_sum = \"+\".join(str(num) for num in numbers)\r\n\r\nprint(new_sum)\r\n", "expression=list(map(int,input().split('+')))\nexpression.sort()\nexpression=list(map(str,expression))\nprint(\"+\".join(expression))\n\t \t\t\t \t\t\t \t\t\t \t \t \t \t \t\t\t\t", "n=input()\r\nprint('+'.join(sorted(n[::2])))", "a = input().split('+')\r\nb = ''\r\nfor i in range(len(a)):\r\n a[i] = int(a[i])\r\na.sort()\r\nfor i in a:\r\n b= b+str(i)+'+'\r\nprint(b[0:len(b)-1:])", "# Helpful Maths\r\nformula = input()\r\nnumber = list(formula.split('+'))\r\nnumber.sort()\r\nfor i in range(len(number)):\r\n if i < len(number)-1:\r\n print(number[i], end='+')\r\n else:\r\n print(number[i])", "s=str(input())\r\na=0\r\nb=0\r\nc=0\r\nstring=\"\"\r\nfor i in range(len(s)):\r\n if s[i]=='1':\r\n a+=1\r\n elif s[i]=='2':\r\n b+=1\r\n elif s[i]=='3':\r\n c+=1\r\nfor j in range(a):\r\n string+='1+'\r\nfor j in range(b):\r\n string+='2+'\r\nfor j in range(c):\r\n string+='3+'\r\nprint(string[:(len(string)-1)])", "s = input()\r\nw = []\r\nif len(s) == 1:\r\n print(s)\r\n exit()\r\nfor i in range(len(s)):\r\n if s[i] != '+':\r\n w.append(s[i])\r\nw.sort()\r\nfor i in range(len(w) - 1):\r\n print(str(w[i]) + '+', end='')\r\nprint(w[len(w) - 1])", "s=input()\r\na=[]\r\nfor i in s:\r\n if(i!='+'):\r\n a.append(int(i))\r\na.sort()\r\nk=\"\"\r\nfor j in a:\r\n k=k+str(j)+\"+\"\r\nprint(k[:-1])", "numbers = list(map(int, input().split('+')))\r\nnumbers.sort()\r\nprint( \"+\".join(str(number) for number in numbers))", "S=list(map(int,input().split('+')))\r\nm=k=n=0\r\nfor i in range(len(S)):\r\n if(S[i]==1):\r\n m+=1\r\n elif(S[i]==2):\r\n k+=1\r\n elif(S[i]==3):\r\n n+=1\r\nN=list()\r\nfor i in range(m):\r\n N.append('1')\r\nfor i in range(k):\r\n N.append('2')\r\nfor i in range(n):\r\n N.append('3')\r\nprint('+'.join(N))", "if __name__==\"__main__\":\r\n a=[int(x) for x in input().split(\"+\")]\r\n a.sort()\r\n for i in range(0,len(a)):\r\n if(i==len(a)-1):\r\n print(f\"{a[i]}\",end='')\r\n else:\r\n print(f\"{a[i]}+\",end='')", "l=sorted(input().split('+'))\r\nprint('+'.join(i for i in l))\r\n# for i in l:\r\n# \tif i==l[len(l)-1]:\r\n# \t\tprint(i)\r\n# \telse:\r\n# \t\tprint(i+'+',end='')\r\n\t\r\n", "def sort_nos(inp):\r\n numbers=inp.split(\"+\")\r\n \r\n sortn= sorted(map(int, numbers))\r\n \r\n sortans=\"+\".join(map(str,sortn))\r\n \r\n return sortans\r\n \r\ninp=input()\r\noutput=sort_nos(inp)\r\nprint(output)", "s = input()\r\narr = []\r\nfor char in s:\r\n if char != '+':\r\n arr.append(int(char))\r\n\r\narr.sort()\r\n\r\nfor i in range(len(arr) - 1):\r\n print(arr[i], end='+')\r\n\r\nprint(arr[-1])\r\n", "#石芯洁 2300090102\r\n\r\ns=input()\r\ncounts={\"1\":0,\"2\":0,\"3\":0}\r\n\r\nfor n in s:\r\n if n!=\"+\":\r\n counts[n]+=1\r\n \r\nnew_sum=\"+\".join([\"1\"]*counts[\"1\"]+[\"2\"]*counts[\"2\"]+[\"3\"]*counts[\"3\"]) \r\n\r\nprint(new_sum)\r\n ", "s = input().strip()\r\n\r\n# Разделяем строку на слагаемые, сортируем их и объединяем обратно\r\nsummands = s.split('+')\r\nsorted_summands = sorted(summands)\r\nresult = '+'.join(sorted_summands)\r\n\r\n# Выводим новую сумму\r\nprint(result)", "def sumStr(s):\r\n ans = []\r\n for val in s:\r\n if val!='+':\r\n ans.append(val)\r\n ans = [int(x) for x in ans]\r\n ans.sort()\r\n ans = [str(x) for x in ans]\r\n str1 = \"+\".join(ans)\r\n return str1\r\n \r\n \r\n \r\n \r\n\r\ns = input()\r\nprint(sumStr(s))", "s = input().strip()\r\nsummands = list(map(int, s.split('+')))\r\nsorted_summands = sorted(summands)\r\nnew_sum = '+'.join(map(str, sorted_summands))\r\nprint(new_sum)", "a=input()\r\nnum=[int(n) for n in a.split('+')]\r\nnum.sort()\r\ns='+'.join(map(str,num))\r\nprint(s)", "user_input = input()\r\n\r\nuser_input = user_input.split(\"+\")\r\n\r\nuser_input.sort()\r\n\r\nprint('+'.join(user_input))", "a = input()\r\na = a.replace('+', '')\r\na = sorted(a)\r\nfor i in range(len(a) - 1):\r\n print(a[i] + '+', end='')\r\nprint(a[len(a) - 1])", "summans = input().split(\"+\")\r\nsummans.sort()\r\n\r\nprint('+'.join(summans))", "def sort_sum(s):\r\n numbers = [int(char) for char in s if char.isdigit()]\r\n\r\n sorted_numbers = sorted(numbers)\r\n\r\n result = '+'.join(map(str, sorted_numbers))\r\n\r\n return result\r\n\r\ns = input()\r\nprint(sort_sum(s))", "import sys\r\n\r\ns=[int(i) for i in sys.stdin.readline().split('+')]\r\n\r\ns.sort()\r\n\r\nnew_sum=\"\"\r\n\r\nfor i in s:\r\n new_sum+=str(i) + '+'\r\n\r\nnew_sum=new_sum[:-1]\r\n\r\nprint(new_sum)", "S = input()\r\n\r\na = S.split(\"+\")\r\n\r\na.sort()\r\n\r\nsorted_string = \"+\".join(a)\r\nprint(sorted_string)", "def solve():\r\n inp = input().split(\"+\")\r\n inp.sort()\r\n return \"+\".join(inp)\r\n\r\nprint(solve())", "n=input().split('+')\r\nprint('+'.join(sorted(n)))", "s = input()\r\n\r\nk=s.split()\r\nsum=\"\"\r\nfor i in range(len(s)):\r\n if s[i] == \"1\":\r\n sum= sum+\"1\"+\"+\"\r\n \r\nfor i in range(len(s)):\r\n if s[i] == \"2\":\r\n sum = sum+\"2\"+\"+\"\r\n\r\nfor i in range(len(s)):\r\n if s[i] == \"3\":\r\n sum = sum+\"3\"+\"+\"\r\nans = \"\" \r\nif sum[-1] == \"+\":\r\n for i in range(0,len(sum)-1):\r\n ans=ans+sum[i]\r\n \r\nelse:\r\n ans = sum\r\n \r\nprint(ans)\r\n", "sm = input()\r\nsml = sm.split('+')\r\nsml.sort()\r\nprint(*sml, sep = '+')", "a=input()\r\nw=sorted(a)\r\nfor u in range(int((len(w)-1)/2),len(w)):\r\n print(f\"{w[u]}\",end=\"\")\r\n if(u<len(w)-1):\r\n print(f\"+\",end=\"\")\r\n\r\n \r\n \r\n", "inp= [int(i) for i in input().split('+')]\r\nans=[str(i) for i in sorted(inp)]\r\nprint(\"+\".join(ans))", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Sep 29 11:38:37 2023\r\n\r\n@author: ZHAO XUDI\r\n\"\"\"\r\n\r\na = input().split(\"+\")\r\nn = sorted(a)\r\nprint(\"+\".join(n))", "q=input().split(\"+\")\r\nq.sort()\r\n#for i in range(1,len(2*q)-1,2):\r\n # q.insert(i,'+')\r\nfor i in range(len(q)):\r\n if i != len(q)-1: print(q[i], end='+')\r\n else: print(q[i])", "s=input()\r\na=s.split(\"+\")\r\na.sort()\r\nsi=''\r\nfor i in a:\r\n si+=str(i)+'+'\r\nprint(si[:-1])", "s = input()\r\ncounts = [0, 0, 0]\r\nfor char in s:\r\n if char == '1':\r\n counts[0] += 1\r\n elif char == '2':\r\n counts[1] += 1\r\n elif char == '3':\r\n counts[2] += 1\r\nnew_sum = \"+\".join([str(digit) for digit in [1, 2, 3] for _ in range(counts[digit - 1])])\r\nprint(new_sum)", "equation = input()\r\nterms = equation.split('+')\r\nterms.sort()\r\nsorted_equation = '+'.join(terms)\r\nprint(sorted_equation)", "s = list(map(int,input().split('+')))\r\ns.sort()\r\nprint('+'.join(list(map(str,s))))", "given_sum = input()\ncount1, count2, count3 = 0, 0, 0\nreadable_sum = \"\"\nfor num in given_sum:\n\tif num == \"+\":\n\t\tpass\n\telse:\n\t\tif num == '1':\n\t\t\tcount1+=1\n\t\telif num == '2':\n\t\t\tcount2 += 1\n\t\telse:\n\t\t\tcount3 += 1\n\nreadable_sum += \"1+\"*count1\nreadable_sum += \"2+\"*count2\nreadable_sum += \"3+\"*count3\n# last element is '+'\nprint(readable_sum[:-1]) # displays upto second last character", "t = input().split(\"+\")\r\nt.sort()\r\nprint(\"+\".join(t))", "i = list(map(int,input().split(\"+\")))\r\ni.sort()\r\nans = \"\"\r\nfor j in i:\r\n ans += str(j)\r\n ans += \"+\"\r\nprint(ans[:-1])", "#https://codeforces.com/problemset/problem/339/A\r\ns=list(map(int,input().split(\"+\")))\r\nssort=sorted(s)\r\nstri=\"\"\r\nfor i in range(len(ssort)):\r\n if i==(len(ssort)-1):\r\n stri+=str(ssort[i])\r\n else:\r\n stri+=str(ssort[i])+\"+\"\r\nprint(stri)", "s=input()\nans=''\nfor i in s:\n if i!='+':\n ans+=i\n\nans='+'.join(sorted(ans))\n\nprint(ans)\n \t \t \t \t \t \t\t\t\t \t \t\t\t \t \t \t", "num=input()\r\na,b,c=0,0,0\r\nfor i in num:\r\n if(i=='1'):\r\n a+=1\r\n elif(i=='2'):\r\n \r\n b+=1\r\n elif(i=='3'):\r\n c+=1\r\nsum='1+'*a+'2+'*b+'3+'*c \r\nprint(sum[:-1])\r\n \r\n \r\n \r\n \r\n\r\n", "s = input()\r\ncount_1 = s.count(\"1\")\r\ncount_2 = s.count(\"2\")\r\ncount_3 = s.count(\"3\")\r\nnew_sum = \"1+\" * count_1 + \"2+\" * count_2 + \"3+\" * count_3\r\nnew_sum = new_sum[:-1]\r\nprint(new_sum)", "l = input().split(\"+\")\r\nl.sort()\r\ns = \"+\".join(l)\r\nprint(s)", "a = input()\r\nlista = []\r\nku = ['+']\r\nfor i in a:\r\n if i not in ku:\r\n lista.append(i)\r\nlista.sort()\r\n\r\nprint('+'.join(lista))\r\n", "s=input()\r\nl=list(map(int, s.split(\"+\")))\r\nl=sorted(l)\r\nl=map(str, l)\r\ns1=\"+\".join(l)\r\nprint(s1)", "l=x=input().split('+')\r\nl.sort()\r\nfor x in range(0,len(l),+1):\r\n if x!=len(l)-1:\r\n print(l[x],end=''+'+'),\r\n else:\r\n print(l[x],end=''),\r\n", "\r\nn= input()\r\nnn=[]\r\nfor i in n :\r\n if i== \"+\":\r\n continue\r\n else:\r\n \r\n nn.append(i)\r\n nn=sorted(nn)\r\nprint(\"+\".join(nn))\r\n\r\n", "s = input()\r\nsu = list(map(int, s.split('+')))\r\nsu.sort()\r\nnew_sum = '+'.join(map(str, su))\r\nprint(new_sum)", "expression = input()\r\nnumbs = []\r\n\r\nfor i in range(0, len(expression)):\r\n if expression[i] != '+':\r\n numbs.append(int(expression[i]))\r\n\r\nfor i in range(0, len(numbs)):\r\n for j in range(i, len(numbs)):\r\n numbToTest = numbs[i]\r\n \r\n possibleSmallerNumb = numbs[j]\r\n\r\n if possibleSmallerNumb < numbToTest:\r\n numbs[i] = possibleSmallerNumb\r\n numbs[j] = numbToTest\r\n\r\n\r\nnewExpression = \"\"\r\n\r\nfor i in range(0, len(numbs)):\r\n newExpression += f'{numbs[i]}'\r\n\r\n if i != len(numbs)-1:\r\n newExpression += '+'\r\n\r\nprint(newExpression)", "s = input()\r\ns = s.replace('+','')\r\narr = []\r\n\r\nfor i in s:\r\n arr.append(int(i))\r\n\r\narr.sort()\r\nresult = '+'.join(map(str,arr))\r\nprint(result)", "n = input()\r\ndigits = [c for c in n if c in '123']\r\nprint('+'.join(sorted(digits)))", "#2300015804\r\nn=[int(x) for x in input().split(\"+\")]\r\nn.sort()\r\nprint(\"+\".join(str(i) for i in n))", "s=input()\r\ns=[int(_) for _ in s.split('+')]\r\ndef sortsuperfast(a):\r\n if len(a)<=1:\r\n return a\r\n m=a[0]\r\n left=list(filter(lambda x:x<m,a))\r\n mid=[m]*a.count(m)\r\n right=list(filter(lambda x:x>m,a))\r\n return sortsuperfast(left)+mid+sortsuperfast(right)\r\nif len(s)==1:\r\n print(s[0])\r\nelse:\r\n s=sortsuperfast(s)\r\n d=''\r\n for i in range(len(s)):\r\n d+='+'+str(s[i])\r\n print(d[1:])\r\n", "user_input = str(input())\r\nlist_of_numbers = user_input.split(\"+\")\r\nsorted_numbers = sorted(list_of_numbers)\r\n\r\nfor i in range(len(sorted_numbers)):\r\n if i != (len(sorted_numbers) - 1):\r\n print(sorted_numbers[i], end = \"+\")\r\n else:\r\n print(sorted_numbers[i])", "#罗景轩2300012610\r\ns = input().split(\"+\") \r\ns.sort() \r\nresult = \"+\".join(s) \r\nprint(result)\r\n", "sum_in = input()\r\nsum_in = sum_in.replace('+', ' ')\r\nnumbers = sum_in.split()\r\nnumbers.sort()\r\nsum_out = '+'.join(numbers)\r\nprint(sum_out)\r\n# 化院 荆屹然 2300011884\r\n", "s = input()\r\nl = []\r\nfor i in s:\r\n if i == '1':\r\n l.append(i)\r\n l.append('+')\r\nfor j in s:\r\n if j == '2':\r\n l.append(j)\r\n l.append('+')\r\nfor k in s:\r\n if k == '3':\r\n l.append(k)\r\n l.append('+')\r\na = l.pop()\r\nprint(''.join(l))", "s=input()\r\nt=[]\r\nfor i in s:\r\n if i!='+':\r\n t.append(i)\r\nt.sort()\r\nprint('+'.join(t))\r\n", "s=input()\r\nk=s.split(\"+\")\r\nl=[]\r\nfor i in k:\r\n l.append(int(i))\r\nl.sort()\r\nx=[]\r\nfor i in l:\r\n x.append(str(i))\r\nprint(\"+\".join(x))", "numbers = list(map(int, input().split(\"+\")))\r\nnumbers.sort()\r\nnumbers = list(map(str, numbers))\r\nprint(\"+\".join(numbers))\r\n", "s=input()\r\nli=[]\r\nfor i in range(0,len(s),2):\r\n li.append(s[i])\r\nli.sort()\r\nfor i in range(len(li)):\r\n if i==len(li)-1:\r\n print(li[i])\r\n else:\r\n print(li[i],end=\"\")\r\n print(\"+\",end=\"\")", "n=sorted(list(input().split('+')))\r\nprint('+'.join(n))", "n = input()\r\na = []\r\nfor i in n:\r\n if '0' < i < '4':\r\n a.append(int(i))\r\na.sort()\r\nif len(a) > 1:\r\n result = \"+\".join(map(str, a))\r\n print(result)\r\nelse:\r\n for h in a:\r\n print(h)", "s = input()\ns = list(s)\nx = \"\"\nfor i in range(0, len(s), 2):\n x = x + str(s[i])\nx = list(x)\nx.sort()\ns = '+'.join(x)\nprint(s)\n\t\t\t \t\t \t \t \t \t \t\t\t \t", "a = input() \nnum = [int(x) for x in a.split('+')]\nnum.sort()\nsorted_a = '+'.join(str(x) for x in num)\nprint(sorted_a) \n", "equation = input()\r\nnumbers = equation.split(\"+\")\r\noutput = \"\"\r\nsort = sorted(numbers)\r\nfor _ in sort:\r\n output += _ + \"+\"\r\nprint(output[0:-1])", "def bubbleSort(lista):\r\n for _ in range(len(lista)):\r\n for i in range(len(lista)):\r\n if i+1<len(lista):\r\n if lista[i]>lista[i+1]:\r\n temp= lista[i]\r\n lista[i]=lista[i+1]\r\n lista[i+1]=temp\r\n return lista\r\n\r\nword=input()\r\nword1=word.replace(\"+\",\" \")\r\n#print(word1)\r\nlista=[int(x) for x in word1.split()]\r\nsorted=bubbleSort(lista)\r\n#print(sorted)\r\nfor i in range(len(sorted)):\r\n sorted[i]=str(sorted[i])\r\n#print(sorted)\r\nstop=(2*len(sorted))-1\r\n\r\nfor i in range(1,stop,2):\r\n sorted.insert(i,\"+\")\r\n\r\n#print(sorted)\r\ntext=''\r\n\r\nfor i in range(len(sorted)):\r\n text+=sorted[i]\r\nprint(text)", "n=[int(x) for x in input().split(\"+\")]\r\nn.sort()\r\nfor i in range(len(n)-1): print(n[i],end=\"+\")\r\nprint(n[-1])", "s=input()\r\nl=[]\r\nfor i in s:\r\n if(ord(i)<58 and ord(i)>47):\r\n l.append(i)\r\nl.sort()\r\nfor i in range(len(l)):\r\n if(i<len(l)-1):\r\n print(l[i]+\"+\",end=(\"\"))\r\n else:\r\n print(l[i],end=(\"\"))", "numbers = input().split(\"+\")\r\nnumbers = sorted(numbers)\r\nrezultats = numbers[0]\r\nfor i in range(1,len(numbers)):\r\n rezultats = rezultats + f\"+{numbers[i]}\"\r\nprint(rezultats)", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Sep 18 15:40:44 2023\r\n\r\n@author: josea\r\n\"\"\"\r\ntoSum = input()\r\ntoSumSp = toSum.split(\"+\")\r\ntoSumNum = [int(i) for i in toSumSp]\r\ntoSumNum.sort()\r\ntoSumList = [str(i) for i in toSumNum]\r\ntoSumSt = '+'.join(toSumList)\r\nprint(toSumSt)", "s=input()\r\nl=s.split(\"+\")\r\nl.sort()\r\nprint(\"+\".join(l))", "# Read the input\r\ns = input()\r\n\r\n# Split the input string into a list of integers\r\nnumbers = [int(char) for char in s.split('+')]\r\n\r\n# Sort the list in non-decreasing order\r\nnumbers.sort()\r\n\r\n# Create a new string with the sorted numbers and '+' signs\r\nsorted_sum = '+'.join(map(str, numbers))\r\n\r\n# Print the result\r\nprint(sorted_sum)\r\n", "#党梓元 2300012107\r\nm=[int(x) for x in input().split(\"+\")]\r\nd=len(m)\r\na=0\r\nb=0\r\nc=0\r\nfor i in range(d):\r\n if m[i]==1:\r\n a+=1\r\n elif m[i]==2:\r\n b+=1\r\n else:\r\n c+=1\r\nif a!=0:\r\n k=\"1\"\r\n for i in range(a-1):\r\n k+=\"+1\"\r\n for i in range(b):\r\n k+=\"+2\"\r\n for i in range(c):\r\n k+=\"+3\"\r\nelse:\r\n if b!=0:\r\n k=\"2\"\r\n for i in range(b-1):\r\n k+=\"+2\"\r\n for i in range(c):\r\n k+=\"+3\"\r\n else:\r\n k=\"3\"\r\n for i in range(c-1):\r\n k+=\"+3\" \r\nprint(k)", "print('+'.join(sorted(input().replace('+', ''))))", "s = input().strip()\r\nsummands = list(map(int, s.split('+')))\r\nsummands.sort()\r\nsorted_s = '+'.join(map(str, summands))\r\nprint(sorted_s)", "s=input().split('+')\r\nd=sorted(s)\r\nprint(*d,sep='+')\r\n", "s = input()\r\na = s.split(sep='+')\r\nc= list(a)\r\nc.sort()\r\nfor i in c[0:-1]:\r\n print(int(i),end='+')\r\nprint(int(c[-1]))", "s = sorted(input().split('+'))\r\nprint(*s, sep='+')", "s = input()\r\n\r\nif len(s) == 1:\r\n print(s)\r\nelse:\r\n summnds = []\r\n for i in range(len(s)):\r\n if s[i] == '+':\r\n continue\r\n else:\r\n summnds.append(s[i])\r\n summnds.sort()\r\n\r\n for i in range(len(summnds)-1):\r\n print(str(summnds[i]) + \"+\", end=\"\")\r\n print(summnds[len(summnds)-1])\r\n\r\n\r\n", "s = input() \n\nnumbers = sorted(s.split('+')) \n\nnew_sum = '+'.join(numbers) \n\nprint(new_sum)\n \t\t \t \t\t\t \t \t\t \t", "\r\ns = input()\r\ns\r\nnumbers = list(map(int, s.split('+')))\r\n\r\nnumbers.sort()\r\n\r\nnew_sum = '+'.join(map(str, numbers))\r\n\r\nprint(new_sum)\r\n", "list1=[int(x) for x in input().split('+')]\r\nlist1.sort()\r\nn=len(list1)\r\nfor i in list1[0:n-1]:\r\n print(i,'+',sep='',end='')\r\nprint(list1[-1])", "a=input()\r\nlst=[]\r\nfor i in range(len(a)):\r\n if a[i].isdigit():\r\n lst.append(a[i])\r\nlst.sort()\r\nfor i in range(len(lst)):\r\n if i!=(len(lst)-1):\r\n print(f\"{lst[i]}+\",end='')\r\n else:\r\n print(lst[i])", "numbers=input().split(\"+\")\r\nnumbers.sort()\r\noutput=\"\"\r\nfor number in numbers:\r\n output=output+number+\"+\"\r\nprint(output[:-1])", "s_input = input()\r\nnums = s_input.split('+')\r\nnums.sort()\r\noutput_one = '+'.join(nums)\r\nprint(output_one)", "s = input()\r\ns = s.split('+')\r\ns.sort()\r\n\r\nout = ''\r\nfor i in range(len(s)):\r\n if i != len(s)-1:\r\n out += s[i]+'+'\r\n else:\r\n out += s[i]\r\nprint(out) ", "s=input()\r\nsum=list(map(int,s.split('+')))\r\nsum.sort()\r\nnewsum='+'.join(map(str,sum))\r\nprint(newsum)", "a = list(map(int, input().split(\"+\"))) \r\na.sort()\r\nans = str(a[0])\r\nfor i in range(1, len(a)):\r\n ans += \"+\"\r\n ans += str(a[i])\r\nprint(ans)", "#2300012302 张惠雯 \r\na=input()\r\nlist1=[]\r\nfor x in a:\r\n if x!=\"+\":\r\n list1.append(x)\r\n else:\r\n continue\r\nlist1.sort()\r\nprint('+'.join(list1))", "p = input()\r\nc = \"\"\r\nif len(p) == 1:\r\n print(p)\r\n exit()\r\nl = p.split('+')\r\nl = sorted(l)\r\nfor i in l:\r\n c += i+'+'\r\nprint(c[0:len(c)-1])\r\n", "s=input()\r\nl=[s]\r\na=[]\r\nfor i in s:\r\n if i!='+':\r\n a.append(int(i))\r\na.sort()\r\np=a[::-1]\r\nS=''\r\nfor i in a:\r\n S+=str(i)+'+'\r\nprint(S[:len(S)-1])", "# Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.\n\n# 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.\n\n# 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.\n# Input\n\n# The first line contains a non-empty string s — 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.\n# Output\n\n# Print the new sum that Xenia can count.\n\n# Examples\n# Input\n\n\n# 3+2+1\n\n# Output\n\n\n# 1+2+3\n\n# Input\n\n\n# 1+1+3+1+3\n\n# Output\n\n\n# 1+1+1+3+3\n\n# Input\n\n\n# 2\n\n# Output\n\n\n# 2\n\nstring = list(map(int, input().split('+')))\nfor i in range(len(string)-1):\n for j in range(i+1, len(string)):\n while string[i] > string[j]:\n string[i], string[j] = string[j], string[i]\n\nprint('+'.join(map(str, string)))\n", "n=input().split(\"+\")\r\nn.sort()\r\nplus=\"\"\r\nfor x in n:\r\n plus+=x+\"+\"\r\n\r\nprint(plus[:-1])\r\n\r\n", "y=\"\"\r\n\r\nx=input(\"\").split(\"+\")\r\nx.sort()\r\nfor i in x:\r\n y=y+i+\"+\"\r\nprint(y[0:-1])", "A=list(map(int,input().split('+')))\r\nA.sort()\r\nprint('+'.join(str(x) for x in A))", "input_str = input()\r\nnumber_list = []\r\ncount_var = 0\r\nfor char_var in input_str:\r\n if char_var == '+':\r\n continue\r\n else:\r\n number_list.append(int(char_var))\r\nnumber_list.sort()\r\nfor i_var in range(len(number_list)):\r\n print(number_list[i_var], end='')\r\n if i_var == len(number_list) - 1:\r\n break\r\n print('+', end='')\r\n", "sums = list(map(int, input().split('+')))\r\nsums.sort()\r\nans = ''\r\nfor i in sums:\r\n ans +=str(i) + '+'\r\nprint(ans[:-1])", "string = input().split('+')\r\nst = [int(i) for i in string]\r\nst.sort()\r\nout = str(st[0])\r\nfor i in range(1, len(st)):\r\n\tout += '+' + str(st[i]) \r\nprint(out)\r\n", "nums=input()\r\nfor i in nums:\r\n if i==\"+\":\r\n nums.replace(\"+\",\"\")\r\nres=sorted(nums)\r\nres=\"+\".join(res)\r\nres=res.lstrip(\"+\")\r\nprint(res)", "numbers = input()\r\nfor a in numbers:\r\n if a == '+':\r\n numbers = numbers.replace('+', '')\r\nresult = sorted(numbers)\r\nresult = '+'.join(result)\r\nprint(result)", "def help_math():\n # Get input as str\n s = input()\n \n # Break into list, turn into int list\n num_list = s.split(\"+\")\n for i in range(len(num_list)):\n num_list[i] = int(num_list[i])\n \n # Rearrange elements\n num_list.sort()\n \n # Print almost all with +\n for k in range(len(num_list)-1):\n print(num_list[k], end=\"+\")\n print(num_list[len(num_list)-1])\n\nhelp_math()\n \t \t \t\t \t \t\t\t\t\t\t\t\t\t\t\t\t\t \t", "a=input()\r\nb=[]\r\nfor j in range(len(a)):\r\n b.append(a[j])\r\nfor i in range(len(a)):\r\n if '+' in b:\r\n b.remove('+')\r\na=sorted(b)\r\nprint(*a, sep='+')", "string = input()\r\nsplitWords = string.split(\"+\")\r\n#print(splitWords)\r\nsplitWords.sort()\r\nans = \"+\".join(splitWords)\r\nprint(ans)", "s=input()\r\na1=a2=a3=0\r\nfor i in range(0,len(s),2):\r\n if(s[i]=='1'):\r\n a1+=1\r\n elif(s[i]=='2'):\r\n a2+=1\r\n else:\r\n a3+=1\r\nb=\"1+\"*a1+\"2+\"*a2+\"3+\"*a3\r\nprint(b[:-1])", "s=input()\r\nm=\"+1\"*s.count(\"1\")+\"+2\"*s.count(\"2\")+\"+3\"*s.count(\"3\")\r\nif m!=\"\":\r\n m=m[1::]\r\nprint(m)", "l=[int(i) for i in input().split('+')]\r\nl.sort()\r\nch=str(l[0])\r\nfor i in range(1,len(l)):\r\n ch+='+'+str(l[i])\r\nprint(ch)", "n=input()\r\nl=[]\r\nfor i in n:\r\n if i!='+':\r\n l.append(i)\r\nl=sorted(l)\r\nfor i in range(len(l)):\r\n if i==len(l)-1:\r\n print(l[i],end=\"\")\r\n else:\r\n print(l[i]+'+',end=\"\")\r\n", "x = list(int(i) for i in input().split(\"+\"))\r\nx.sort()\r\nx = [str(i) for i in x]\r\nprint(\"+\".join(x))", "a=input().split('+')\r\na.sort()\r\nq=''\r\nfor i in range(len(a)):\r\n q=q+a[i]\r\n if i!=len(a)-1:\r\n q=q+'+'\r\nprint(q)", "inputs = input().split('+')\r\ninputs.sort()\r\n\r\nfor i in range(len(inputs)):\r\n if i == len(inputs) - 1:\r\n print(inputs[i])\r\n else:\r\n print(inputs[i], '+', end='', sep='')", "a=list(map(int,input().split('+')))\r\na.sort()\r\nb=[]\r\ns=''\r\nc=''\r\nfor i in a:\r\n s+=str(i)+'+'\r\nfor i in range(len(s)):\r\n b.append(s[i])\r\nb.pop(-1)\r\nfor i in b:\r\n c+=i\r\nprint(c)\r\n", "s = input().split('+')\r\nl = list(map(int, s))\r\nl.sort()\r\nprint('+'.join(str(el) for el in l))", "a=input()\r\ns=\"\"\r\nfor i in a:\r\n if(i!=\"+\"):\r\n s=s+i\r\ns = sorted(s)\r\nprint(s[0],end = \"\")\r\nfor i in s[1:]:\r\n print(\"+\"+str(i),end=\"\")\r\n ", "# Get input as a string and split it by '+'\r\n_input = input().split('+')\r\n\r\n# Convert each element to an integer and sort them\r\nmath = sorted(map(int, _input))\r\n#print(math)\r\n\r\n# Convert each integer to a string and join them with '+'\r\nresult = \"+\".join(map(str, math))\r\n\r\nprint(result)\r\n", "st=input()\r\nif \"+\" in st:\r\n l=list(map(int,st.split(\"+\")))\r\n print(*sorted(l),sep=\"+\")\r\nelse:\r\n print(st)", "a=input()\r\nl=[]\r\nfor i in range(0,len(a),2):\r\n l.append(a[i])\r\nl.sort()\r\nfor i in range(len(l)):\r\n if(i!=len(l)-1):\r\n print(l[i]+\"+\",end='')\r\n else:\r\n print(l[i])\r\n ", "s=input().strip()\r\nc1=s.count('1')\r\nc2=s.count('2')\r\nc3=s.count('3')\r\nsum=\"1+\"*c1 + \"2+\"*c2 + \"3+\"*c3\r\nsum=sum[:-1]\r\nprint(sum)", "s = input()\r\n\r\nterms = s.split('+')\r\nterms.sort()\r\n\r\nnew_sum = '+'.join(terms)\r\n\r\nprint(new_sum)\r\n", "n = list(map(str, input().replace('+','')))\r\nn.sort()\r\nprint('+'.join(n))", "n = input().split()\r\nli = []\r\neven = []\r\nans = []\r\nfor i in n:\r\n for j in i:\r\n li.append(j)\r\nfor k in range(len(li)):\r\n if k % 2 == 0:\r\n even.append(int(li[k]))\r\neven.sort()\r\nfor i in range(len(even)):\r\n ans.append(even[i])\r\n ans.append('+')\r\ndel(ans[-1])\r\nfor i in ans:\r\n print(i, end='')", "s = input()\r\nl = len(s)\r\n\r\none, two, three = 0,0,0\r\n\r\nfor i in range(0, l, 2):\r\n if s[i] == \"1\":\r\n one += 1\r\n elif s[i] == \"2\":\r\n two += 1\r\n else:\r\n three += 1\r\n\r\nif one != 0:\r\n for i in range(0, one):\r\n print(\"1\", end=\"\")\r\n l -= 2\r\n\r\n if l >= 0:\r\n print(\"+\", end=\"\")\r\n\r\nif two != 0:\r\n for i in range(0, two):\r\n print(\"2\", end=\"\")\r\n l -= 2\r\n\r\n if l >= 0:\r\n print(\"+\", end=\"\")\r\n\r\nif three != 0:\r\n for i in range(0, three):\r\n print(\"3\", end=\"\")\r\n l -= 2\r\n\r\n if l >= 0:\r\n print(\"+\", end=\"\")", "summation = input()\r\none_count, two_count, three_count = summation.count(\"1\"), summation.count(\"2\"), summation.count(\"3\")\r\nnum_list = [\"1\"] * one_count + [\"2\"] * two_count + [\"3\"] * three_count\r\nnew_sum = \"+\".join(num_list)\r\nprint(new_sum)", "given = input() \r\n\r\nans = \"\" \r\n\r\nnumbers = []\r\n\r\nfor i in range(0,len(given)):\r\n if(given[i] == '+'):\r\n continue\r\n else:\r\n numbers.append(int(given[i]))\r\n\r\nnumbers.sort() \r\n\r\nfor i in range(0,len(numbers)):\r\n if(i!=len(numbers)-1):\r\n ans = ans + str(numbers[i])+\"+\"\r\n else:\r\n ans = ans + str(numbers[i])\r\n\r\nprint(ans)\r\n ", "st=input()\r\nls=[]\r\nfor i in st:\r\n if(i !=\"+\"):\r\n ls.append(i)\r\nls.sort()\r\nnew=\"\"\r\nfor i in range(len(ls)):\r\n if(i==len(ls)-1):\r\n new+=str(ls[i])\r\n else: \r\n new+=str(ls[i])+'+'\r\nprint(new)\r\n", "# Read the input string\r\ns = input()\r\n\r\n# Split the input string into a list of numbers\r\nnumbers = list(map(int, s.split(\"+\")))\r\n\r\n# Sort the list of numbers\r\nnumbers.sort()\r\n\r\n# Convert the sorted numbers back to strings\r\nsorted_sum = \"+\".join(map(str, numbers))\r\n\r\n# Print the new sum\r\nprint(sorted_sum)", "s=input()\r\nnumbers=list(map(int,s.split('+')))\r\nnumbers.sort()\r\n\r\nsorted_sum='+'.join(map(str,numbers))\r\nprint(sorted_sum)\r\n\r\n", "s = input()\r\nl = s.split('+')\r\nl.sort()\r\n# print(l)\r\nfor i in l[:-1]:\r\n print(i, end='+')\r\nprint(l[-1])", "item=list(map(int,input().split(\"+\")))\r\nitem.sort()\r\ns='+'.join(str(x) for x in item)\r\nprint(s)\r\n", "numbers = list(map(str, input().split('+')))\r\nnumbers.sort()\r\nresult = \"\"\r\n\r\nfor i in range(1, len(numbers) * 2, 2):\r\n numbers.insert(i, \"+\")\r\nnumbers.pop()\r\n\r\nfor character in numbers:\r\n result += character\r\nprint(result)", "input_str = input()\r\n\r\nnums = [int(num) for num in input_str.split('+')]\r\nnums.sort()\r\n\r\nres_str = '+'.join(map(str, nums))\r\n\r\nprint(res_str)", "problem = input()\r\narr = list(problem.split(\"+\"))\r\narr = sorted(arr)\r\nproblemSimplified = \"+\".join(arr)\r\nprint(problemSimplified)", "s=input()\r\nl=[]\r\nfor i in s:\r\n if i!='+':\r\n l.append(int(i))\r\nl.sort()\r\nfor j in range(len(l)):\r\n if j==len(l)-1:\r\n print(l[j])\r\n else:\r\n print(l[j],end='')\r\n print(\"+\",end='')", "#黄靖涵 2300098604 工学院 2023秋\r\n\r\nnum_str = input()\r\ntoremove = \"+\"\r\nnew_str = []\r\n\r\nfor char in num_str:\r\n if char not in toremove:\r\n new_str += char\r\n \r\n new_str.sort()\r\n new_str2 = ''.join(new_str)\r\n ans = \"+\".join(new_str2)\r\n \r\nprint(ans)", "s = input()\r\nnumbers = s.split('+')\r\nnumbers.sort()\r\nnew_s = '+'.join(numbers)\r\nprint(new_s)", "l=input().split('+')\r\ndef InsertionSort(l):\r\n for i in range(len(l)):\r\n m=i\r\n for j in range(i-1,-1,-1):\r\n a,b=int(l[m]),int(l[j])\r\n if a<b:\r\n l[m],l[j]=l[j],l[m]\r\n m-=1\r\n else:\r\n break\r\n return '+'.join(l)\r\nans=InsertionSort(l)\r\nprint(ans)", "str = input().split(\"+\")\r\nstr.sort()\r\nfor i in range (0,len(str)):\r\n if (i != len(str)-1):\r\n print(str[i],end=\"+\")\r\n else:\r\n print(str[i],end=\"\")", "s=list(input())\r\nfor i in s:\r\n if i=='+':\r\n s.remove(i)\r\ns=sorted(s)\r\nprint('+'.join(s))\r\n\r\n", "n=input()\r\na=[]\r\nfor i in n:\r\n if i!='+':\r\n a.append(i)\r\na.sort()\r\nfor i in range(len(a)):\r\n print(a[i],end=\"\")\r\n if i<len(a)-1:\r\n print(\"+\",end=\"\")\r\n ", "a=input()\r\nq=[]\r\ns=''\r\nif len(a)==1:\r\n print(a)\r\n exit()\r\nfor j in a:\r\n if j.isnumeric():\r\n q.append(j)\r\nq=sorted(q)\r\nfor i in q:\r\n if i.isnumeric():\r\n s+=i+\"+\"\r\nprint(s[:-1])", "def eval (s):\r\n a = s.split ('+')\r\n x = [int (i) for i in a]\r\n x.sort()\r\n p = [str(i) for i in x]\r\n p = '+'.join(p)\r\n return p\r\n\r\nif __name__ == \"__main__\":\r\n s = input ()\r\n print(eval(s))", "def part(n,low,high):\r\n i = low - 1\r\n pivot = n[high]\r\n for j in range(low,high):\r\n if n[j] < pivot:\r\n i += 1\r\n n[i],n[j] = n[j],n[i]\r\n n[i + 1],n[high] = n[high],n[i + 1]\r\n return i + 1\r\ndef qSort(n,low,high):\r\n if high > low:\r\n pi = part(n,low,high)\r\n qSort(n,low,pi - 1)\r\n qSort(n,pi + 1,high)\r\ns = input()\r\np = 0\r\nnum = []\r\nfor i in range(len(s)):\r\n if ord(s[i]) >= 48 and ord(s[i]) <= 57:\r\n num.append(int(s[i]))\r\n if ord(s[i]) == 43:\r\n p += 1\r\nqSort(num,0,len(num) - 1)\r\nfor i in range(len(num)):\r\n print(num[i],end=\"\")\r\n if p:\r\n print(\"+\",end=\"\")\r\n p -= 1", "s= input()\r\ni=0\r\nl=[]\r\nwhile(i<len(s)):\r\n l.append(int(s[i]))\r\n i+=2\r\nl.sort()\r\nfor i in range(len(l)-1):\r\n print(str(l[i])+\"+\",end='')\r\nprint(str(l[len(l)-1]))", "s = input()\r\ns = s.strip('+')\r\nA = []\r\nfor i in range(0, len(s), 2):\r\n A.append(int(s[i]))\r\nA.sort()\r\nfor u in range(len(A)-1):\r\n print(str(A[u]) + '+', end = '')\r\nprint(A[len(A)-1])", "n=input()\r\nnum=sorted(map(int,n.split('+')))\r\nsorted_n='+'.join(map(str,num))\r\nprint(sorted_n)\r\n", "#王奕欢 2300012285\r\na=input().split(\"+\")\r\na.sort()\r\nprint(\"+\".join(a))", "import sys\r\ns = [int(i) for i in sys.stdin.readline().split('+')]\r\ns.sort()\r\nns=\"\"\r\nfor i in s:\r\n ns+=str(i)+'+'\r\nns=ns[:-1]\r\nprint(ns)", "s = input().split('+')\r\ns.sort()\r\nresult = '+'.join(s)\r\nprint(result)\r\n", "s = input()\r\nn1 = n2 = n3 = 0\r\nfor i in range(0,len(s)):\r\n if s[i] == \"1\":\r\n n1 += 1\r\n elif s[i] == \"2\":\r\n n2 += 1\r\n elif s[i] == \"3\":\r\n n3 += 1\r\n\r\nans = (\"1+\"*n1) + (\"2+\"*n2) + (\"3+\"*n3)\r\nprint(ans[:-1])", "\"\"\"\r\ncompleted by 乔俊杰,ghglxy\r\n\"\"\"\r\nprint(\"+\".join(str(i) for i in sorted(list(map(int,input().split(\"+\"))))))", "sp = list(map(int, input().split(\"+\")))\r\nsp.sort()\r\nprint(\"+\".join(list(map(str, sp))))", "num = list(input().split(\"+\"))\r\nnum.sort()\r\nprint(\"+\".join(n for n in num))", "string = input()\r\ns = \"\"\r\nL = []\r\n\r\nfor char in string:\r\n if char.isdigit():\r\n L.append(char)\r\n\r\nL.sort()\r\n\r\nif L:\r\n s = '+'.join(L)\r\n \r\nprint(s)", "s=input()\r\nsummands=list(map(int,s.split('+')))\r\nsummands.sort()\r\nsum='+'.join((map(str,summands)))\r\nprint(sum)", "s=str(input())\r\nalist=list(s)\r\nfor i in range(len(alist)-1,-1,-1):\r\n if alist[i] ==\"+\":\r\n alist.remove(\"+\") \r\nalist.sort()\r\nn=\"+\".join(alist)\r\nprint(n)\r\n", "s=input().split(\"+\")\r\none=[]\r\ntwo=[]\r\nthree=[]\r\nout=\"\"\r\nfor i in range(len(s)):\r\n if s[i]=='1':\r\n one.append(s[i])\r\n elif s[i]=='2':\r\n two.append(s[i])\r\n elif s[i]=='3':\r\n three.append(s[i])\r\nnew = one + two + three\r\nfor i in range(len(new)):\r\n out+=new[i]\r\n if i!=len(new)-1:\r\n out+='+'\r\nprint(out)", "s=input()\nl=s.split('+')\nl.sort()\ni=0\nwhile i<len(l)-1:\n print(l[i],end='+')\n i=i+1\nprint(l[len(l)-1])", "n = str(input())\r\n\r\nlst = n.split('+')\r\nsrt = sorted(lst)\r\n\r\nx = ''\r\n\r\nfor i in srt:\r\n x += f'{i}+'\r\n\r\nprint(x[:-1])", "lst = []\r\ns = str(input(\"\"))\r\nfor num in s[::2]:\r\n lst.append(num)\r\n lst.sort()\r\nresult = '+'.join(lst)\r\nprint(result)", "s = input()\r\n\r\nr = []\r\n\r\nl = 0\r\n\r\nfor i in s:\r\n if i == '+':\r\n continue\r\n else:\r\n r.append(i)\r\nr.sort()\r\nprint('+'.join(r))", "s=input()\r\nnum=sorted([int(c) for c in s if c.isdigit()])\r\nss=\"+\".join(str(c) for c in num)\r\nprint(ss)", "def partition(nums,start=0,end=None):\r\n if end is None:\r\n end = len(nums)-1\r\n l, r = start,end - 1\r\n while l<r:\r\n if nums[l] <= nums[end]:\r\n l+=1\r\n elif nums[r] > nums[end]:\r\n r-=1\r\n else:\r\n nums[l],nums[r] = nums[r],nums[l]\r\n \r\n if nums[l] > nums[end]:\r\n nums[l],nums[end] = nums[end],nums[l]\r\n return l\r\n else:\r\n return end\r\n \r\ndef quickSort(nums,start=0,end=None):\r\n if end is None:\r\n end = len(nums) - 1\r\n if start < end:\r\n pivot = partition(nums,start,end)\r\n quickSort(nums,start,pivot-1)\r\n quickSort(nums,pivot+1,end)\r\n return nums\r\ns = str(input())\r\nc = []\r\nfor i in range(len(s)):\r\n if i % 2 == 0:\r\n c.append(s[i])\r\nc=quickSort(c,0,len(c)-1) \r\nfor i in range(len(c)):\r\n print(c[i],end='')\r\n if i < len(c)-1:\r\n print('+',end='')", "string = input()\r\nls = []\r\nfor i in string.split(\"+\"):\r\n ls.append(int(i))\r\nls.sort()\r\ni=1\r\nwhile i<=(len(ls)-1):\r\n print(ls[i-1],end=\"+\")\r\n i+=1\r\nprint(ls[i-1])\r\n", "string=list(input())\r\nk=0\r\nstring.sort()\r\nfor i in range(len(string)):\r\n if (ord(string[i])>=49) and (ord(string[i])<=57):\r\n if k>0 and k<=len(string):\r\n print(\"+\",end=\"\")\r\n k+=1\r\n print(string[i],end=\"\")\r\n \r\n", "string1=input()\r\nlist1=string1.split(\"+\")\r\nnumbers_as_integer = [int(x) for x in list1]\r\nnumbers_as_integer.sort()\r\nnumbers_as_string = [str(i) for i in numbers_as_integer]\r\nfinal_string1 = '+'.join(numbers_as_string)\r\nprint(final_string1)", "n=input()\r\nl=list(n.split('+'))\r\nl.sort()\r\nl='+'.join(l)\r\nprint(l)", "def main():\r\n Numbers = input()\r\n \r\n if len(Numbers) == 1:\r\n print(Numbers)\r\n return\r\n \r\n Numbers = Numbers.split(\"+\")\r\n Numbers.sort()\r\n Length = len(Numbers)\r\n\r\n s = ''\r\n for i, Num in enumerate(Numbers):\r\n s += Num\r\n if i < Length-1:\r\n s += \"+\"\r\n print(s)\r\n\r\nmain()", "n = input()\r\nlist = []\r\nfor i in n:\r\n if i != \"+\":\r\n i = int(i)\r\n list.append(i)\r\nlist.sort()\r\nfin = \"\"\r\nfor i in range(len(list)):\r\n k = str(list[i])\r\n fin = fin + k\r\n if i != (len(list)-1):\r\n fin += \"+\"\r\n\r\nprint(fin)\r\n", "equation = input().split(\"+\")\r\nequation.sort()\r\n\r\nresult = \"+\".join([x for x in equation])\r\nprint(result)\r\n", "n = input()\r\n\r\narr = n.split('+')\r\narr.sort()\r\nprint(\"+\".join(arr))\r\n", "x = input()\nvalues = x.split('+')\nvalues = '+'.join(sorted(values))\nprint(values)", "s = input()\r\n\r\none = ''\r\n\r\ntwo = ''\r\n\r\ntre = ''\r\n\r\nfor i in range(len(s)):\r\n if s[i] == '1':\r\n one += '1+'\r\n if s[i] == '2':\r\n two += '2+'\r\n if s[i] == '3':\r\n tre += '3+'\r\notv = one + two + tre\r\nprint(otv[:-1])", "n=list(map(int,input().split(\"+\")))\r\nfor i in range(len(n)-1):\r\n for j in range(i,len(n)):\r\n if n[i]>n[j]:\r\n n[j],n[i]=n[i],n[j]\r\n \r\nprint(\"+\".join(str(i) for i in n))\r\n\r\n", "a = str(input()).split('+')\r\nf = sorted(a)\r\nc = '+'.join(f)\r\nprint(c)", "equation = input()\r\nequationArr = equation.split(\"+\")\r\nequationArr.sort()\r\nx=\"\"\r\nfor num in equationArr:\r\n x = \"+\".join(map(str, equationArr)) \r\nprint(x)", "a = input()\r\nx = []\r\nfor i in a:\r\n if i in '123':\r\n z = int(i)\r\n \r\n x.append(z)\r\nx.sort()\r\ny = '+'.join(map(str,x))\r\n\r\nprint(y)\r\n\r\n", "s=input()\r\na=[]\r\nfor i in s:\r\n if i!=\"+\":\r\n a.append(i)\r\na.sort()\r\nfor i in a[0:-1]:\r\n print(i,end=\"+\")\r\nprint(a[-1])\r\n ", "#王铭健,工学院 2300011118\r\nsum_list = list(input())\r\nfor i in range(sum_list.count('+')):\r\n sum_list.remove('+')\r\nsum_list.sort()\r\nfor j in range(len(sum_list)-1):\r\n print(sum_list[j], end=\"+\")\r\nprint(sum_list[-1])\r\n", "#339a\r\n#2300011863 张骏逸\r\ns=input();l=list();ans=list()\r\nfor i in s:\r\n if i.isdigit():#判断1234567890,不录入加号\r\n l.append(i);\r\nl.sort()#进行排序\r\nfor i in l:\r\n ans.append(i)\r\n ans.append('+')\r\nans.pop()#把多的那个加号删除\r\nfor i in ans:\r\n print(i,end='')", "#Author 索林格 2200013317\r\na = input().split(\"+\")\r\na.sort()\r\nb = \"+\".join(a)\r\nprint(b)\r\n", "sentence = input()\r\nlist = []\r\nfor word in sentence:\r\n if word != \"+\":\r\n list.append(word)\r\nlist.sort()\r\nprint(\"+\".join(list))", "string = input().split('+')\r\n\r\nstring.sort()\r\nfor ele in range(len(string)-1):\r\n print(f'{string[ele]}+', end= '')\r\nprint(string[len(string)-1])\r\n", "s=input()\r\nl=[]\r\nfor i in s:\r\n if i.isdigit():\r\n l.append(int(i))\r\nl.sort()\r\na=\"\"\r\nfor i in l:\r\n a+=str(i)+\"+\"\r\na=a.rstrip(a[-1])\r\nprint(a)", "print(*sorted([int(i) for i in input().split(\"+\")]), sep=\"+\")", "n = input()\n\nnumbers = list(map(int, n.split('+')))\nnumbers.sort()\nresult = '+'.join(map(str, numbers))\nprint(result)\n\t \t\t\t \t\t\t \t \t\t \t \t\t \t\t\t", "s = input()\r\ns = sorted(s)\r\n\r\nt = []\r\n\r\nfor i in s:\r\n if i in '123':\r\n t.append(i)\r\nres = '+'.join(t)\r\nprint(res)\r\n ", "l=input().split(\"+\")\r\nl.sort()\r\ns=\"\"\r\nfor x in l :\r\n s+=x+\"+\"\r\ns.rstrip(\"+\")\r\nprint(s[:-1])", "s = input()\r\n\r\ns = s.split('+')\r\n\r\ns = list(map(int,s))\r\n\r\ns.sort() \r\n\r\ns = list(map(str,s))\r\nprint('+'.join(s))", "s = input()\r\nn1 = n2 = n3 = 0\r\nfor i in range(0, len(s), 2):\r\n if s[i] == '1':\r\n n1 += 1\r\n elif s[i] == '2':\r\n n2 += 1\r\n else:\r\n n3 += 1\r\nss = \"1+\" * n1 + \"2+\" * n2 + \"3+\" * n3\r\nprint(ss[:-1])", "lst = list(map(int, input().split('+')))\r\nlst.sort()\r\nprint(\"+\".join([str(i) for i in lst]))", "eqn = input().split(\"+\")\r\neqn.sort()\r\n\r\nprint(\"+\".join(eqn))", "#2300011725\r\nraw=input().split('+')\r\nraw.sort()\r\nprint('+'.join(raw))", "a=input()\nz=list(a.split('+'))\nz.sort()\ns=''\nfor i in range(0,len(z)):\n if i<len(z)-1:\n s+=z[i]+'+'\n else:\n s+=z[i]\nprint(s)", "s=input().split(\"+\")\r\ns.sort()\r\nfor i in range(len(s)-1):\r\n print(s[i],end=\"+\")\r\nprint(s[len(s)-1])", "# Read the input string containing the sum\r\ns = input()\r\n\r\n# Split the input string by '+' and convert to integers\r\nsummands = list(map(int, s.split('+')))\r\n\r\n# Sort the summands in non-decreasing order\r\nsummands.sort()\r\n\r\n# Create a new string by joining the sorted summands with '+'\r\nnew_sum = '+'.join(map(str, summands))\r\n\r\n# Print the new sum\r\nprint(new_sum)\r\n", "\r\nx = input().split(\"+\")\r\ny = []\r\nfor i in x:\r\n y.append(int(i))\r\ny.sort()\r\n\r\nfor i in range(0, len(y) - 1):\r\n print(y[i], end=\"+\")\r\nprint(y[len(y) - 1])\r\n", "a = list(str(input()).split('+'))\r\nb = sorted(a, reverse=False)\r\nh = str(b[0])\r\nfor i in range(1, len(b)):\r\n h += '+' + b[i]\r\nprint(h)", "# Read the input sum\r\ns = input()\r\n\r\n# Split the input sum by '+' and convert to integers\r\nsummands = list(map(int, s.split('+')))\r\n\r\n# Sort the summands in non-decreasing order\r\nsummands.sort()\r\n\r\n# Convert the sorted summands back to strings and join them with '+'\r\nresult = '+'.join(map(str, summands))\r\n\r\n# Print the rearranged sum\r\nprint(result)\r\n", "nourinz=input()\r\nnn=nourinz.split('+')\r\nnn.sort()\r\nprint('+'.join(nn))\r\n", "ch=input()\r\nL=sorted([int(ch[i]) for i in range(len(ch)) if ch[i]!=\"+\"])\r\ns=str(L[0])\r\nfor i in range(1,len(L)):\r\n s=s+'+'+str(L[i])\r\nprint(s)", "from sys import stdin\ndef input(): return stdin.readline()[:-1]\n\n\ndef solve():\n ans = \"\"\n x = [int(x) for x in input().split('+')]\n x.sort()\n ans += str(x[0])\n for i in range(1, len(x)):\n ans += f\"+{x[i]}\"\n\n return ans\n\n\nprint(solve())\n", "print(*(sorted(input()[::2])),sep=\"+\")\r\n", "ans=('+'.join(sorted(input()[::2])))\r\nprint(ans)", "a = input().split(sep = \"+\")\r\nb = sorted(a)\r\nprint(\"+\".join(b))", "n=list(map(int,input().split('+')))\r\nn.sort()\r\ns=''\r\nfor i in range(len(n)):\r\n if i!=len(n)-1:\r\n s+=str(n[i])+\"+\"\r\n else:\r\n s+=str(n[i])\r\nprint(s)\r\n", "string = list(int(x) for x in input().split('+'))\r\nadd_to = str()\r\nwhile len(string) != 0:\r\n min_find = min(string) \r\n if 1 >= len(string):\r\n add_to += str(min_find)\r\n else:\r\n add_to += str(min_find) + '+'\r\n string.remove(min_find)\r\nprint(add_to)", "def rearrange_sum(s):\r\n \"\"\"Rearranges the summands in a sum so that Xenia can calculate it.\r\n Args:\r\n s: A string representing the sum.\r\n Returns:\r\n A string representing the rearranged sum.\r\n \"\"\"\r\n # Split the sum into summands.\r\n summands = s.split(\"+\")\r\n # Sort the summands in non-decreasing order.\r\n summands.sort()\r\n # Join the summands back into a string.\r\n return \"+\".join(summands)\r\nif __name__ == \"__main__\":\r\n s = input()\r\n print(rearrange_sum(s))", "Str = input().split(\"+\")\r\nStr = list(map(int, Str))\r\nStr.sort()\r\nStr = list(map(str, Str))\r\nprint(\"+\".join(Str))", "L=input().split(\"+\")\r\nL.sort()\r\ns=\"\"\r\nfor x in L:\r\n s+=x+\"+\" #1+2+3+\r\nprint(s[:-1])", "s = input()\r\narr = sorted( s.split('+'))\r\nprint ('+'.join(arr))\r\n \r\n", "print('+'.join((sorted(input().split('+')))))", "s = input().split('+')\r\n\r\ncounts = [0, 0, 0]\r\nfor num in s:\r\n counts[int(num) - 1] += 1\r\n\r\nnew_sum = '+'.join(['1'] * counts[0] + ['2'] * counts[1] + ['3'] * counts[2])\r\n\r\nprint(new_sum)\r\n", "s = input()\r\nl = s.split(\"+\")\r\n\r\nl.sort()\r\n\r\ns = \"+\".join(l)\r\nprint(s)", "s=input()\r\nl=s.split('+')\r\n\r\n \r\nl.sort()\r\nw='+'.join(l)\r\nprint(w)", "a = list(input().split('+'))\r\n# a = ['12', '13', '5', '6', '3', '8']\r\na = list(map(int, a))\r\na.sort()\r\na = list(map(str, a))\r\nlength = len(a)\r\n# print(a)\r\nfor i in range(length):\r\n if i != length - 1:\r\n print(a[i], end='+')\r\n else:\r\n print(a[i])\r\n", "num = input()\r\na = []\r\nfor i in num:\r\n if i.isdigit():\r\n a.append(i)\r\na.sort()\r\nb = \"+\".join(a)\r\nprint(b)\r\n", "s=input()\nn=len(s)\nl=[]\nfor i in range(0,n,2):\n l.append(s[i])\nl.sort()\nfor i in range(0,n//2):\n print(f\"{l[i]}+\",end=\"\")\nprint(l[n//2])\n\n", "# Read the input string and split it by '+'\r\ninput_str = input()\r\nnumbers = list(map(int, input_str.split('+')))\r\n\r\n# Sort the list in non-decreasing order\r\nnumbers.sort()\r\n\r\n# Create a new string by joining the sorted numbers with '+'\r\nresult_str = '+'.join(map(str, numbers))\r\n\r\n# Print the new string\r\nprint(result_str)\r\n", "n = input()\r\narr = list(map(int, n.split('+')))\r\narr.sort()\r\nif len(arr) == 1:\r\n print(arr[0])\r\nelse:\r\n s = \"\"\r\n for i in arr:\r\n s += str(i) + '+'\r\n print(s[:-1])", "x=list(input(\"\"))\r\nc=0\r\nfor i in range(len(x)):\r\n if x[i] == \"+\":\r\n x[i]=\"\"\r\n c+=1\r\nx.sort()\r\nx=x[c:]\r\nprint(\"+\".join(x))\r\n", "s=input() \r\nnumbers=s.split('+')\r\ncount={1:0,2:0,3:0}\r\nfor num in numbers:\r\n count[int(num)]+=1\r\nnew_numbers=[]\r\nfor num in range(1,4):\r\n new_numbers.extend([str(num)]*count[num])\r\nnew_sum=\"+\".join(new_numbers)\r\nprint(new_sum)", "a = input()\r\nnewa = a.replace('+', '')\r\nnewa = sorted(newa)\r\nprint('+'.join(newa))", "b=list(input().split(sep='+'))\r\nb.sort()\r\nprint('+'.join(b))", "numbers=input().split('+')\r\nnumbers.sort()\r\nout=\"+\".join(numbers)\r\nprint(out)", "list1 = list(input().split(\"+\"))\r\n\r\nif len(list1) == 1:\r\n print(list1[0])\r\n\r\nelse:\r\n list1.sort()\r\n finalstr = \"\"\r\n\r\n for i in list1:\r\n finalstr += str(i) + \"+\"\r\n\r\n print(finalstr[:-1])", "str1=input().split(\"+\")\r\nstr1.sort()\r\nfor i in range(len(str1)):\r\n if i==len(str1)-1:\r\n print(str1[i])\r\n else:\r\n print(str1[i],end=\"+\")", "operation = input()\r\narranged_operation = \"\"\r\nnumbers = []\r\n\r\nfor number in operation:\r\n\r\n if number != \"+\":\r\n numbers.append(int(number))\r\n\r\nnumbers.sort()\r\n\r\nfor i in range(0, len(numbers)):\r\n\r\n if i < len(numbers) - 1:\r\n arranged_operation += str(numbers[i]) + \"+\"\r\n\r\n else: arranged_operation += str(numbers[i])\r\n\r\nprint(arranged_operation)", "arr = list(map(int, input().split(\"+\")))\r\narr.sort()\r\nres = ''.join(str(i) + \"+\" for i in arr)\r\n\r\nprint(res[:-1])\r\n", "S=list(input().split('+'))\r\n\r\nS.sort()\r\nfor i in range(len(S)):\r\n if i<len(S)-1:\r\n print(S[i]+'+',end='')\r\n else:\r\n print(S[i])\r\n", "numlist = list(map(int, input().split('+')))\r\n\r\ndef insertionSort(list):\r\n for i in range(1, len(numlist)):\r\n key = numlist[i]\r\n\r\n j = i-1\r\n while j>=0 and numlist[j] > key:\r\n numlist[j+1] = numlist[j]\r\n j = j - 1\r\n numlist[j+1] = key\r\n \r\ninsertionSort(numlist)\r\nprintline = ''\r\nfor i in range(len(numlist)):\r\n if i == len(numlist)-1:\r\n printline = printline + str(numlist[i])\r\n else:\r\n printline = printline + str(numlist[i]) + '+'\r\n\r\nprint(printline)\r\n\r\n\r\n ", "# Read the input string\r\ns = input()\r\n\r\n# Split the input string by '+' and convert to integers\r\nnumbers = list(map(int, s.split('+')))\r\n\r\n# Sort the list in non-decreasing order\r\nnumbers.sort()\r\n\r\n# Convert the sorted list of numbers back to strings\r\nsorted_summands = [str(num) for num in numbers]\r\n\r\n# Join the sorted list with '+' to create the new sum\r\nnew_sum = '+'.join(sorted_summands)\r\n\r\n# Output the new sum\r\nprint(new_sum)\r\n", "x = input()\r\ny = []\r\nfor caracter in x:\r\n if caracter != '+':\r\n y.append(caracter)\r\n\r\ny.sort()\r\n\r\nfor index,caracter in enumerate(y):\r\n print(caracter, end='')\r\n if index != len(y)-1:\r\n print('+', end='')\r\n\r\n", "def insr():\n return(input().strip())\n\ndef solve(s) :\n print('+'.join(list(sorted(s.replace('+', '')))))\n return\n\ninp = insr()\nsolve(inp)", "numb = input().split(\"+\") #split()不输入间隔符时默认为空格,不输入次数时默认为无限\r\n\r\nnumb.sort() #sort()默认为字母由a到z,数字由小到大;\r\na=0 #也可以在括号内加reverse=True,key=...等函数\r\ncal=\"\"\r\nwhile a<len(numb):\r\n\tcal+=f\"{numb[a]}+\" #\r\n\ta+=1\r\n\r\nprint(cal[0:-1])", "counting = list(input().split(\"+\"))\r\ncounting.sort()\r\nprint('+'.join(counting))", "s=input().split('+')\r\ns.sort()\r\nans=\"\"\r\nfor i in s:\r\n ans+=i+\"+\"\r\nprint(ans[0:len(ans)-1])", "#PIDE Y DIVIDE\nsum = input().split(\"+\")\n#ORDENA\nsum.sort()\n#JUNTA\nsum = \"+\".join(sum)\n#IMPRIME\nprint(sum)\n\n \t \t \t \t\t\t \t\t\t \t\t\t", "s = list(map(int,input().split('+')))\r\ns.sort()\r\nans=\"\"\r\nfor i in s:\r\n ans += str(i)\r\n ans += '+'\r\n\r\nans = ans[0:-1]\r\nprint(ans)", "s = input()\r\nlst = s.split(\"+\")\r\nlst.sort()\r\nfinal = \"\"\r\nfor i in range(len(lst)- 1):\r\n final = final + lst[i] + \"+\"\r\nfinal += lst[-1]\r\nprint(final)", "x=list(map(int,input().split('+')))\r\nx.sort()\r\nfor i in range(len(x)-1):\r\n print(f'{x[i]}+',end='')\r\nprint(x[len(x)-1])", "s=input()\r\nl=[]\r\n#t=s.split()\r\n#print(t)\r\nfor i in range(0,len(s),2):\r\n l.append(s[i])\r\nl.sort()\r\nf=l[0]\r\nfor i in range(1,len(l)):\r\n f=f+\"+\"+str(l[i])\r\nprint(f)", "#梁慧婷 2300012153 生命科学学院\r\nsum = sorted(input().split('+'))\r\nprint('+'.join(sum))", "print('+'.join(map(str,sorted(list(map(int,input().split('+')))))))", "s = list(map(int,input().split('+')))\r\ns.sort()\r\na = len(s)\r\nfor i in range(a):\r\n if (i != a - 1): print(s[i],\"+\",sep=\"\",end=\"\")\r\n else: print(s[i])", "string = str(input())\r\nl = 0\r\ntot = [0] * 3\r\n\r\nwhile l in range(len(string)):\r\n tot[int(string[l]) - int('1')] += 1\r\n l += 2\r\n\r\nfor j in range(3):\r\n for k in range(tot[j]):\r\n l -= 2\r\n if l == 0:\r\n print(j + 1)\r\n break\r\n print(j + 1, end = '+')", "\r\ns = input()\r\nsummands = list(map(int, s.split(\"+\")))\r\nsummands.sort()\r\nnew_sum = \"+\".join(map(str, summands))\r\n\r\nprint(new_sum)\r\n", "summands = list(map(int,input().split('+')))\r\nsummands.sort()\r\nfor i in range(len(summands)):\r\n if i != len(summands) - 1:\r\n print(summands[i], end='+')\r\n else:\r\n print(summands[i])", "n = input()\r\nn = list(n)\r\nk = []\r\nfor value in n:\r\n if value != \"+\":\r\n k.append(int(value))\r\nk.sort()\r\nk = \"+\".join(map(str, k))\r\nprint(k)\r\n", "s = input()\r\nsummands = s.split(\"+\")\r\nsorted_summands = sorted([int(x) for x in summands])\r\nnew_sum = \"+\".join(map(str, sorted_summands))\r\nprint(new_sum)\r\n", "l=[*input()]\r\na=[];b=[]\r\nfor x in l:\r\n try:a.append(int(x))\r\n except:b.append(x)\r\na.sort()\r\nb.append('+')\r\nq=[]\r\nz=[* zip(a,b)]\r\nfor x,y in z:\r\n q.append('{}{}'.format(x,y))\r\nw=''.join(q)\r\nprint(w[:-1])\r\n", "s = input()\r\nnumbers = sorted(s.split('+'))\r\nresults = '+'.join(numbers)\r\nprint(results)", "sumnum = input()\r\nsumnum1 = sumnum.split(\"+\")\r\nsumnum2 = [int(a) for a in sumnum1]\r\nsumnum3 = sorted(sumnum2)\r\nsumnum4 = [str(a) for a in sumnum3]\r\ncount = \"+\".join(sumnum4)\r\nprint(count)\r\n", "OneTwoThree=[\"1\",\"2\",\"3\"]\r\ncalculation=input()\r\nnumber=[]\r\n\r\nfor char in calculation:\r\n if char in OneTwoThree:\r\n number.append(int(char))\r\nnumber.sort()\r\nprint(*number,sep=\"+\")", "a=input()\r\ns=[]\r\nfor i in range(len(a)):\r\n if i%2==0:\r\n s.append(int(a[i]))\r\n else:\r\n s=s\r\n s.sort()\r\nprint(*s,sep='+')", "s=input()\r\nl=s.split('+')\r\nl.sort()\r\nfor i in range(len(l)):\r\n if i!=(len(l)-1):\r\n print(l[i],end='+')\r\n elif i==(len(l)-1):\r\n print(l[i])\r\n else:\r\n pass\r\n", "input_string = input()\r\nnew_sum = '+'.join(sorted(input_string.split('+')))\r\nprint(new_sum)", "# -*- coding: utf-8 -*-\n\"\"\"Untitled10.ipynb\n\nAutomatically generated by Colaboratory.\n\nOriginal file is located at\n https://colab.research.google.com/drive/1Y76e7LeXWvCIjIdSAW7klJvgCVNmBhzq\n\"\"\"\n\ns = input().split('+')\ns.sort()\nintss = \"\"\nfor i in s:\n intss += f\"{i}+\"\nprint(intss[:-1])", "# Read the input sum as a string\r\ns = input()\r\n\r\n# Split the input string using '+' as the delimiter and convert the substrings to integers\r\nnumbers = list(map(int, s.split('+')))\r\n\r\n# Sort the numbers in non-decreasing order\r\nnumbers.sort()\r\n\r\n# Convert the sorted numbers back to strings and join them with '+'\r\nnew_sum = '+'.join(map(str, numbers))\r\n\r\n# Print the new sum that Xenia can count\r\nprint(new_sum)\r\n", "s=input()\r\ns=s.split(\"+\")\r\ns.sort()\r\nprint(\"+\".join(s))", "s = ''\r\na = list(map(int,input().split('+')))\r\na.sort()\r\nfor i in range(len(a)-1):\r\n s += str(a[i])+ \"+\"\r\ns+= str(a[len(a)-1])\r\nprint(s)\r\n", "s=str(input())\r\none=0\r\ntwo=0\r\nthree=0\r\nfor i in range(len(s)):\r\n if s[i]==\"+\":\r\n continue;\r\n elif s[i]==\"1\":\r\n one=one+1\r\n elif s[i]==\"2\":\r\n two=two+1\r\n elif s[i]==\"3\":\r\n three=three+1\r\ns2=\"\"\r\nl=[]\r\nfor i in range(len(s)):\r\n if i%2==1:\r\n l.insert(i,\"+\")\r\nfor i in range(0,one):\r\n l.insert(i*2,\"1\")\r\nfor i in range(one,one+two):\r\n l.insert(i*2,\"2\")\r\nfor i in range(one+two,one+two+three):\r\n l.insert(i*2,\"3\")\r\nprint(s2.join(l))", "sentence = input()\r\nsplited = sentence.split(\"+\")\r\n# O(n log n)\r\nsplited.sort()\r\n# O(n)\r\nresult_str = \"+\".join(splited)\r\nprint(result_str)", "a=input()\r\nb=list(map(str,a.split(\"+\")))\r\nb.sort()\r\nc=\"+\".join(b)\r\nprint(c)\r\n\r\n ", "s = input().split('+')\r\nss = sorted(s, key=lambda x: int(x))\r\n\r\nprint('+'.join(ss))\r\n", "# Read the input string\r\ns = input()\r\n\r\n# Split the string by '+', convert to integers, and sort them\r\nsummands = list(map(int, s.split('+')))\r\nsummands.sort()\r\n\r\n# Convert the sorted summands back to strings and join them with '+'\r\nnew_sum = '+'.join(map(str, summands))\r\n\r\n# Print the new sum that Xenia can count\r\nprint(new_sum)\r\n", "a=input()\r\nc=[a.count(str(i)) for i in range(1,4)]\r\nk=[]\r\nfor i in range(1,4):\r\n k.extend([str(i)]*c[i-1])\r\ny='+'.join(k)\r\nprint(y)\r\n ", "s=(input()).split(\"+\")\r\ns.sort()\r\nns=\"+\".join(s)\r\nprint(ns)", "ka=input().split(\"+\")\r\nka.sort()\r\na=\"+\".join(ka)\r\nprint(a)", "s=list(map(int,input().split(\"+\")))\r\ns.sort()\r\nfor i in range(len(s)):\r\n if i!=len(s)-1:\r\n print(s[i],end='+')\r\n else:\r\n print(s[i])", "a = input()\r\na_list= a.split('+')#以“+”符号将其分离形成一个列表\r\na_list.sort()\r\nnew_a_list = '+'.join(a_list)\r\nprint(new_a_list)", "s=input()\r\nfor i in s:\r\n if i=='+':\r\n s=s.replace(i,'')\r\nx=[]\r\nfor k in s:\r\n if k=='1':\r\n x.append(k)\r\nfor k in s:\r\n if k=='2':\r\n x.append(k)\r\nfor k in s:\r\n if k=='3':\r\n x.append(k)\r\ny=[]\r\nfor j in range(len(x)):\r\n y.append(x[j])\r\n y.append('+')\r\ny.pop()\r\nz=''.join(y)\r\nprint(z)", "l=list(input())\r\nl=sorted(l)\r\nc=0\r\nfor ch in l:\r\n if ch!='+':\r\n print(ch,end=\"\")\r\n c+=1\r\n if c<len(l)-len(l)//2:\r\n print('+',end=\"\")", "num1 = input()\r\nnum2 = []\r\nfor i in range(len(num1)):\r\n if i % 2 == 0:\r\n num2.append(num1[i])\r\nnum3 = sorted(num2)\r\nnum4 = '+'.join(num3)\r\nprint(num4)", "s = input()\r\nnumbers = sorted([int(char) for char in s if char.isdigit()])\r\nnew_sum = '+'.join([str(num) for num in numbers])\r\nprint(new_sum)", "l1 = list(str(input()))\nl2 = []\nfor i in range(0,len(l1),2):\n l2.append(l1[i])\n\nl2.sort()\nfor j in range(len(l2)-1):\n print(l2[j],\"+\",sep = \"\",end = \"\")\n\nprint(l2[-1])", "data = sorted([int(x) for x in input().split('+')])\r\n\r\nprint('+'.join([str(x) for x in data]))\r\n\r\n", "# n,k=list(map(int,input().split()))\r\ns=input().split(\"+\")\r\n# print(s)\r\narr=[0 for i in range(len(s))]\r\nfor i in range(len(s)):\r\n arr[i]=s[i]\r\narr.sort()\r\nfor i in range(len(s)):\r\n if i==len(s)-1:\r\n print(arr[i])\r\n else:\r\n print(f\"{arr[i]}+\",end=\"\")\r\n\r\n\r\n", "import sys\r\ndef I(): return int(sys.stdin.readline().rstrip())\r\ndef LI(): return list(map(int, sys.stdin.readline().rstrip().split()))\r\ndef MI(): return map(int, sys.stdin.readline().rstrip().split())\r\ndef SI(): return sys.stdin.readline().rstrip()\r\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\r\n\r\ndef main():\r\n a = SI()\r\n n = len(a)\r\n arr = []\r\n for i in range(n):\r\n if a[i].isdigit():\r\n arr.append(int(a[i]))\r\n\r\n arr.sort()\r\n\r\n ans = \"\"\r\n for i in range(len(arr)):\r\n ans += str(arr[i])\r\n ans += \"+\"\r\n print(ans[:-1])\r\nif __name__ == \"__main__\":\r\n main()", "a= input()\r\nb=[]\r\nc=\"\"\r\nfor i in range(0,len(a),2):\r\n if a[i]=='1':\r\n b.append('1+')\r\nfor i in range(0,len(a),2):\r\n if a[i]=='2':\r\n b.append('2+')\r\nfor i in range(0,len(a),2):\r\n if a[i]=='3':\r\n b.append('3+')\r\nfor i in b:\r\n c+=i\r\nprint(c[0:len(c)-1])", "a=input().split(\"+\");a.sort(); print(\"\".join([x+\"+\" for x in a])[:-1])", "line=list(map(int, input().split(\"+\")))\r\nline.sort()\r\ns=\"\"\r\nfor i in line:\r\n s=s+str(i)+\"+\"\r\n\r\nprint(s[0:-1])\r\n", "maths=input()\r\nl=[]\r\nfor i in range(len(maths)):\r\n if(maths[i]!='+'):\r\n l.append(maths[i])\r\nl.sort()\r\nres=''\r\nfor i in range(len(l)-1):\r\n res+=(l[i]+\"+\")\r\nres+=l[len(l)-1]\r\nprint(res)", "s=list(map(int,input().split('+')))\r\ns.sort()\r\nprint(s[0],end=\"\")\r\nfor i in s[1:]:print(\"+\",i,sep=\"\",end=\"\")", "s=input()\r\nlst=s.split(\"+\")\r\nlst = [int(num) for num in lst]\r\nlst.sort()\r\nsorted_str = '+'.join(map(str, lst))\r\nprint(sorted_str)", "string = list(map(int,input().split('+')))\r\nstring.sort()\r\nprint('+'.join(map(str,string)))", "s= input()\ns=[int(i) for i in s.split(\"+\")]\nfor i in range (0,len(s)):\n s.sort()\n print (s[i],end=\"\")\n if (i+1 <len(s)):\n print(\"+\",end=\"\")\n\t\t\t \t \t \t\t\t \t \t\t \t \t\t", "\"\"\"\r\nCreated on Sep 27 2023\r\n@author: 施广熠 2300012143\r\n\"\"\"\r\nstr1=input().split(\"+\")\r\nstr1.sort()\r\nfor i in range(len(str1)):\r\n if i==len(str1)-1:\r\n print(str1[i])\r\n else:\r\n print(str1[i],end=\"+\")", "print(\"+\".join(sorted(input().split(\"+\"),key=int)))", "arr = list(map(int, input().split('+')))\n\narr.sort()\nfor i in range(len(arr)): \n print(arr[i], end = '')\n if i != len(arr)-1: \n print('+', end = '')\n\nprint()\n", "arr = input()\r\nl = arr.split('+')\r\nl.sort()\r\nans = \"\"\r\nfor i in l:\r\n ans += i + \"+\"\r\nprint(ans[:len(ans)-1])", "jumlah = [int(x) for x in input().split(\"+\")]\nprinted = False\n\nsatu = 0\ndua = 0\ntiga = 0\n\nfor itr in jumlah:\n if itr == 1:\n satu += 1\n elif itr == 2:\n dua += 1\n else:\n tiga += 1\n \nfor rep1 in range(0,satu):\n if printed == True:\n print(\"+1\", end = \"\")\n else:\n print(\"1\", end = \"\")\n printed = True\nfor rep2 in range(0,dua):\n if printed == True:\n print(\"+2\", end = \"\")\n else:\n print(\"2\", end = \"\")\n printed = True\nfor rep3 in range(0,tiga):\n if printed == True:\n print(\"+3\", end = \"\")\n else:\n print(\"3\", end = \"\")\n printed = True\n\t\t\t \t\t \t\t \t\t\t \t \t \t \t \t \t", "s = input()\ns = sorted([int(i) for i in s if i!='+'])\n\nprint(*s, sep='+')\n \t \t\t\t\t\t \t \t \t\t \t\t\t", "mylist=[]\r\ns=str(input())\r\nl=len(s)\r\nfor i in range(l):\r\n \r\n if (s[i]!=\"+\"):\r\n \r\n mylist.append(s[i])\r\n \r\n \r\n\r\nmylist.sort()\r\n\r\na=mylist[0]\r\nfor i in range(1,len(mylist)):\r\n a+=\"+\"+mylist[i]\r\n\r\nprint(a)", "a = input()\r\nl = []\r\nfor i in a:\r\n if i in \"123\":\r\n l.append(i)\r\nl.sort()\r\nb = \"+\".join(l)\r\nprint(b)", "s = sorted(input().split('+'))\r\n\r\nprint(''.join([s[i // 2] if i % 2 == 0 else '+' for i in range(len(s) * 2 - 1)]))\r\n", "l=[x for x in input().split('+')]\r\nl.sort()\r\nprint('+'.join(l))\r\n", "s = list(map(int,input().split('+')))\r\nras = sorted(s)\r\nprint(*ras,sep = '+')", "l1=list(input().split(\"+\"))\r\nl1.sort()\r\nprint(\"+\".join(l1))", "def transform(s):\r\n values = [int(i) for i in s.split(\"+\")]\r\n values.sort()\r\n return \"+\".join([str(i) for i in values])\r\n\r\n\r\ns = input()\r\nprint(transform(s))", "a=sorted([str(i) for i in input().split(\"+\")])\r\nprint(\"+\".join(a))", "nums = list(map(int, input().split(\"+\")))\r\nnums = sorted(nums)\r\nnums = map(str, nums)\r\nprint(\"+\".join(nums))", "s = input().split('+')\r\n\r\nfor i in range(len(s)):\r\n s[i] = int(s[i])\r\n\r\ns.sort()\r\n\r\nfor i in range(len(s)-1):\r\n print(s[i] , end = '+')\r\n\r\nprint(s[len(s)-1])", "x=list(map(int,input().split('+')));x.sort();print(*x,sep=\"+\")", "x=input()\r\nl=[]\r\nfor i in range(len(x)):\r\n if(x[i] in \"123\"):\r\n l.append(x[i])\r\n\r\nif(len(l)>1):\r\n l.sort()\r\n s=\"\"\r\n for j in range(len(l)-1):\r\n s=s+l[j]+\"+\"\r\n s=s+l[len(l)-1]\r\n\r\n print(s)\r\n\r\nelse:\r\n s=l[0]\r\n print(s)", "a=input()\r\nlist=[]\r\nstr=\"\"\r\nfor i in a[0::2]:\r\n list.append(i)\r\nlist.sort()\r\nfor i in list[0:len(list)-1:1]:\r\n str=str+i+\"+\"\r\nprint(str+list[-1])", "s = input().split('+')\nfor i in range(1, len(s)):\n key = s[i]\n j = i-1\n while j >= 0 and s[j] > key:\n s[j+1] = s[j]\n j -= 1\n s[j+1] = key\nprint(\"+\".join(s))\n", "n: list = list(map(int, input().split('+'))) \r\nprint(*sorted(n), sep=\"+\")", "s = input()\n\nl = s.split(\"+\")\nl.sort()\nprint('+'.join(l))\n", "x = list(map(int,input().split(\"+\")))\r\nx.sort()\r\nprint(*x,sep =\"+\")\r\n\r\n", "inut=input()\r\nnumbers=[]\r\nfor char in inut:\r\n if char.isdigit():\r\n numbers.append(int(char))\r\n\r\nnumbers.sort()\r\nnew='+'.join(map(str,numbers))\r\nprint(new)", "#2300012142 林烨\r\na=sorted(input().split('+'))\r\nn=a[0]\r\nfor i in range(len(a)-1):\r\n n+='+'+a[i+1]\r\nprint(n)", "a=list(input().split('+'))\r\na.sort()\r\nprint('+'.join(a))", "string = input()\r\n\r\nstring = string.split(\"+\")\r\n\r\nstring.sort()\r\n\r\nstring = \"+\".join(string)\r\n\r\nprint(string)", "def sort_ls(ls):\r\n for empty in range(len(ls)):\r\n for i in range(len(ls)-1):\r\n if l[i] > l[i+1]:\r\n l[i], l[i+1] = l[i+1], l[i]\r\n return ls\r\n\r\nl = input().split(\"+\")\r\nprint(\"+\".join(sort_ls(l)))", "# Read input\r\ns = input()\r\ncount = [0, 0, 0] \r\nfor char in s:\r\n if char == '1':\r\n count[0] += 1\r\n elif char == '2':\r\n count[1] += 1\r\n elif char == '3':\r\n count[2] += 1\r\nsum = '+'.join(['1'] * count[0] + ['2'] * count[1] + ['3'] * count[2])\r\nprint(sum)\r\n", "s=input()\r\narr=s.split('+')#[i for i in ]\r\narr.sort()\r\nprint(\"+\".join(arr))", "x1=input()\r\nz=[int(x) for x in x1.split('+')]\r\nz.sort()\r\nb='+'.join(map(str, z))\r\nprint(b)", "n=list(input().split('+'))\r\nn.sort()\r\nw=''\r\nfor i in range(len(n)-1):\r\n w+=n[i]+'+'\r\nw+=n[len(n)-1]\r\nprint(w)\r\n", "# la complejidad es O(N log N), ya que la complejidad mas grande es generada por la a operación de ordenar (.sort())\ns = input()\n\nn = [int(char) for char in s if char.isdigit()]\n\nn.sort()\n\norden = '+'.join(map(str, n))\n\nprint(orden)\n \t \t\t\t \t\t\t \t \t\t\t\t \t\t\t \t", "s = input()\r\n\r\n# Extract the individual numbers from the input string\r\nnumbers = [int(ch) for ch in s if ch.isdigit()]\r\n\r\n# Sort the numbers in non-decreasing order\r\nnumbers.sort()\r\n\r\n# Construct the new sum string\r\nnew_sum = '+'.join(map(str, numbers))\r\n\r\nprint(new_sum)\r\n", "data = list(map(int,input().split('+')))\r\n\r\ndata.sort()\r\n\r\nfor i in range(0,len(data) - 1):\r\n print(data[i],end='+')\r\nprint(data[len(data) - 1])", "sum = input().split(\"+\")\r\nsum.sort()\r\nlist = []\r\nfor element in sum:\r\n list.append(element)\r\n list.append(\"+\")\r\ndel list[-1]\r\nfor all_things in list:\r\n print(all_things,end=\"\")", "s=input().split(\"+\")\r\ns=sorted(s)\r\no=\"\"\r\nfor i in s:\r\n o=o+i+\"+\"\r\nprint(o[:-1])", "s = input()\r\nL = []\r\nfor i in range(int((len(s)+1)/2)):\r\n L.append(s[2*i])\r\nprint('+'.join(sorted(L)))\r\n#complied by 陈睿阳 2300011406", "sums = input()\r\nsums= sums.split(\"+\")\r\nsums.sort()\r\nnew = \"\"\r\nfor i in range(len(sums)):\r\n new= new + f'{sums[i]}+'\r\nnew= new[:-1]\r\nprint(new)", "s = input()\r\nif len(s) == 1:\r\n print(s)\r\nelse:\r\n a = list(map(int, s.split('+')))\r\n a.sort()\r\n s1 = ''\r\n for i in range(len(a)):\r\n if i != len(a) - 1:\r\n s1 += str(a[i]) + '+'\r\n else:\r\n s1 += str(a[i])\r\n print(s1)\r\n", "aRR = sorted([_ for _ in map(int, input().split('+'))])\r\narr = [_ for item in aRR for _ in (item, '+')][:-1]\r\nfor _ in arr:\r\n print(_, end = '')", "x = sorted([i for i in input().split(\"+\")])\r\nprint('+'.join(x))\r\n", "s = input().split('+')\r\nnumbers = [int(el) for el in s]\r\nnumbers.sort()\r\nans = ''\r\nfor i in range(len(numbers)):\r\n ans += str(numbers[i])\r\n if i != len(numbers) - 1:\r\n ans += '+'\r\nprint(ans)", "s = input()\r\na = s.count('1')\r\nb = s.count('2')\r\nc = s.count('3')\r\nans = '1+' * a + '2+' * b + '3+' * c\r\nprint(ans[:-1])\r\n", "word = input()\r\n\r\nif len(word) > 1:\r\n znak = word[1]\r\n word = word.replace(znak,'')\r\n s=[]\r\n for i in range(len(word)):\r\n s.append(word[i])\r\n s = sorted(s)\r\n print(*s,sep=znak)\r\nelif len(word) == 1:\r\n print(word)", "x = input()\r\ny=x.split(\"+\")\r\n\r\ny.sort()\r\nprint(\"+\".join(y))", "# CF339A_戴正宇_2300011451\r\nnum_list = list(map(int, input().split('+')))\r\nnum_list.sort()\r\nprint('+'.join(map(str, num_list)))", "numbers=sorted([x for x in input()[::2]])\r\nprint('+'.join(numbers))", "lst1 = list(map(int,input().split(\"+\")))\r\nsrt = sorted(lst1)\r\nnew = (str(num) for num in srt)\r\nres1 = '+'.join(new)\r\nprint(res1)\r\n", "s = sorted(input().split(\"+\"))\r\nprint(\"+\".join(s))\r\n", "num_list = list(map(int, input().split('+')))\r\nnum_list.sort()\r\nlast = num_list.pop()\r\nfor i in num_list:\r\n print(i, end = '+')\r\nprint(last)", "x = input().split('+')\r\nx.sort()\r\nprint('+'.join(x))", "nums = [i for i in input().split('+')]\r\nnums.sort()\r\nprint('+'.join(nums))", "l = sorted(list(map(int,input().split(\"+\"))))\r\nfor i in range(len(l)-1):print(l[i],end=\"+\")\r\nprint(l[len(l)-1])\r\n", "word = str(input())\r\n\r\nres = [i for i in word if i != \"+\"]\r\nresult = sorted(res)\r\nlastarr = []\r\noddev = False\r\nfor i in result:\r\n if oddev:\r\n lastarr.append(\"+\")\r\n oddev= False\r\n lastarr.append(i)\r\n oddev = True\r\nprint(\"\".join(lastarr))", "s=input()\r\na=s.split('+')\r\nprint('+'.join(sorted(a)))\r\n", "\r\ns = input()\r\nsummands = s.split(\"+\")\r\nsummands = sorted(map(int, summands))\r\nnew_sum = \"+\".join(map(str, summands))\r\nprint(new_sum)\r\n", "str1=input(\"\")\r\nstr1=str1.split('+')\r\nstr1.sort()\r\nstr1='+'.join(str1)\r\nprint(str1)", "exp = input().split('+')\r\nexp.sort()\r\nresult = ''\r\nfor i in exp:\r\n result += i + '+'\r\n \r\nprint(result[:-1:])\r\n", "op = input().split(\"+\")\nop.sort()\nnewop = \"\"\nfor i in op:\n newop += i+\"+\"\nprint(newop[:-1])\n \t\t\t\t \t\t\t \t \t\t\t \t \t \t\t\t \t", "\r\nl = input()\r\nans = []\r\nfor i in l:\r\n if i == '1' or i == '2' or i == '3':\r\n ans.append(i)\r\nans.sort()\r\nresult = \"\"\r\nfor i in ans:\r\n result += i + '+'\r\nprint(result[:len(result) - 1])", "a=list(input())\r\nx=[]\r\nif len(a)<=1:\r\n print(a[0])\r\nelse:\r\n q=[i for i in a if i!=\"+\"]\r\n w=[j for j in a if j==\"+\"]\r\n q=sorted(q)\r\n \r\n for u in range(len(q)):\r\n x.append(q[u])\r\n if u!=len(q)-1:\r\n x.append(w[u])\r\n print(\"\".join(x))\r\n \r\n ", "a = list(map(int, input().split(\"+\")))\r\na.sort()\r\no=\"\"\r\nfor i in a:\r\n\to+=str(i)+\"+\"\r\nprint(o[:-1])", "s=input().split('+')\r\ns.sort()\r\nans='+'.join(s)\r\nprint(ans)", "n = input()\narr = list(map(int, n.split('+')))\nx = arr.sort()\nx = '+'.join(map(str, arr))\nprint(x)\n\t\t\t \t\t\t\t\t \t\t\t\t\t\t\t\t \t \t \t\t \t", "input = input()\r\n\r\nnumbersButStrings = input.split(\"+\")\r\nnumbers = []\r\n\r\nfor numberButStr in numbersButStrings:\r\n numbers.append(int(numberButStr))\r\n\r\nnumbers.sort()\r\n\r\nresult = \"\"\r\n\r\nfor i in range(len(numbers)):\r\n currentNumber = numbers[i]\r\n lastNumber = numbers[-1]\r\n\r\n if i == 0:\r\n result = currentNumber\r\n continue\r\n \r\n result = f\"{result}+{currentNumber}\"\r\n \r\n \r\nprint(result)\r\n\r\n\r\n\r\n", "s = input()\r\nlis = []\r\nfor i in range(len(s)):\r\n if i % 2 == 0:\r\n lis.append(s[i])\r\nlis.sort()\r\nfor i in range(len(lis)-1):\r\n if len(lis) > 1:\r\n print(lis[i], end='+')\r\nelse:\r\n print(lis[-1])\r\n", "calc = input()\r\n\r\nif \"+\" in calc:\r\n nums = [int(n) for n in calc.split(\"+\")]\r\n nums.sort()\r\n print(\"+\".join(map(str, nums)))\r\n\r\nelse:\r\n print(calc)", "eq = input().split('+')\r\neq.sort()\r\nfor i in range(len(eq)):\r\n if i == len(eq) - 1:\r\n print(eq[i])\r\n else:\r\n print(eq[i], end='+')\r\n", "s=input()\nn=[]\nfor i in s:\n if i !=\"+\":\n n.append(int(i))\nn.sort()\na=\"\"\nfor i in range(len(n)):\n a=a+str(n[i])\n if i+1<len(n):\n a=a+\"+\"\nprint(a)\n\t\t\t\t \t\t \t \t\t \t\t\t\t \t", "a=sorted(input().split(\"+\"))\r\ns = len(a)\r\nfor i in range(s-1):\r\n print(a[i]+'+',end='')\r\nprint(a[-1])", "number_sum = input()\r\nnumber = []\r\n\r\n\r\nfor i in number_sum:\r\n if i == '1' or i == '2' or i == '3':\r\n number.append(int(i))\r\nnumber.sort()\r\n\r\nresult = []\r\nfor j in number:\r\n result.append(str(j))\r\n\r\nprint(\"+\".join(result))", "x=str(input())\r\narray=[]\r\nfor z in x:\r\n if z != '+':\r\n array.append(z)\r\narray=sorted(array)\r\nm=''\r\nfor k in array:\r\n m+=k\r\n m+='+'\r\n \r\nprint(m[:-1])\r\n\r\n\r\n ", "str1 = input()\r\nl1=[]\r\n# print(str1[0])\r\nfor i in str1:\r\n if i!='+':\r\n l1.append(i)\r\nl1.sort()\r\n# print(l1)\r\nfor i in range(len(l1)):\r\n if(i==0):\r\n print(l1[i],end=\"\")\r\n else:\r\n print(\"+\"+l1[i],end=\"\")", "a=str(input())\r\nb=[]\r\nfor i in range(len(a)):\r\n if(i%2==0):\r\n b.append(a[i])\r\nb.sort()\r\nfor j in range(len(b)):\r\n if(j==(len(b)-1)):\r\n print(b[j])\r\n else:\r\n print(b[j],end='+')", "numbers = input()\r\n\r\nnumbers = numbers.split('+')\r\nnumbers.sort()\r\n\r\nnew = ''\r\nfor number in numbers:\r\n new += f'{number}+'\r\n\r\nnew = new[:len(new)-1]\r\nprint(new)\r\n", "s = input()\r\n\r\na = []\r\n\r\nb = 0\r\nfor char in s:\r\n if char.isdigit():\r\n b = b * 10 + int(char)\r\n elif char == '+':\r\n a.append(b)\r\n b = 0\r\n\r\na.append(b)\r\n\r\na.sort()\r\n\r\nnew = '+'.join(map(str, a))\r\n\r\nprint(new)\r\n", "n = input()\r\nif len(n) == 1:\r\n print(n)\r\nelse:\r\n numbers = []\r\n c = \"\"\r\n\r\n for char in n:\r\n if char != '+':\r\n c += char\r\n else:\r\n numbers.append(c)\r\n c = \"\"\r\n\r\n numbers.append(c)\r\n numbers.sort()\r\n\r\n result = \"+\".join(numbers)\r\n print(result)\r\n", "array = input().split('+')\r\narray.sort()\r\narray = '+'.join(array)\r\nprint(array)", "a = input()\r\nb = list(a[0:len(a):2])\r\n\r\nb = sorted(b) \r\nfor i in range(len(b) - 1):\r\n print(b[i] + '+', end='')\r\n\r\nprint(b[-1])\r\n", "# LUOGU_RID: 131803204\nlis = list(map(str, input().split('+')))\r\nlis.sort()\r\nprint('+'.join(lis))\r\n# sdfsdf", "s=input().split('+')\r\nsortedlist=sorted(s)\r\nsortedlist1='+'.join(sortedlist)\r\nprint(sortedlist1)", "numbers = [int(x) for x in input().split(\"+\")]\r\nnumbers.sort()\r\n\r\nprint(\"+\".join(map(lambda x: str(x), numbers)))", "operation = list(input())\r\n\r\nif len(operation) == 1:\r\n print(\"\".join(operation))\r\nelse:\r\n numbers = [i for i in operation if i != \"+\"]\r\n numbers.sort()\r\n final = []\r\n for num in numbers:\r\n final.extend([num, \"+\"])\r\n del final[len(final) - 1]\r\n final = \"\".join([i for i in final])\r\n print(final)", "s=input().split(\"+\") #hàm split(\"+\") sẽ tách chuỗi thành một danh sách dựa vào dấu \"+\"\r\n#print(s)\r\ns.sort()\r\n#print(s)\r\n#1+2+5+6\r\nfor i in range(len(s)): #i=0,1,2,3\r\n if i!=len(s)-1: #nếu không phải kí tự cuối cùng\r\n print(f\"{s[i]}\",end=\"+\")\r\n else: #nếu là kí tự cuối cùng\r\n print(f\"{s[i]}\")", "# eliminate single digit\r\nnum = input()\r\nif len(num)!= 1:\r\n num = sorted(num.split(\"+\"))\r\n new_num =\"+\".join(num)\r\n print(new_num)\r\nelse:\r\n print(num)\r\n", "s=input()\r\ny=s.replace(\"+\",\"\")\r\ny1=list(y)\r\nx=sorted(y1)\r\nprint(\"+\".join(x))\r\n", "n=input()\r\nl=[]\r\nfor i in range(len(n)):\r\n if i%2==0:\r\n l.append(int(n[i]))\r\n\r\nl.sort()\r\ns=''\r\nfor i in range(len(l)-1):\r\n s+=(str(l[i])+\"+\")\r\n\r\ns+=str(l[len(l)-1])\r\n\r\nprint(s)\r\n\r\n ", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Sep 22 12:28:21 2023\r\n\r\n@author: 25419\r\n\"\"\"\r\n\r\nlist1=input().split('+')\r\nlist1.sort()\r\nn=len(list1)\r\nstr1=''\r\nfor i in range(n):\r\n str1=str1+str(list1[i])\r\nprint('+'.join(str1))", "a=input()\r\nc=0\r\nx=[]\r\nfor i in a:\r\n if i==\"+\":\r\n pass\r\n else:\r\n c=i\r\n x.append(c)\r\nx.sort()\r\ns=\"\"\r\nfor i in x:\r\n s+=i+\"+\"\r\nprint(s[:-1])", "num = list(map(str,input().split('+')))\r\nnum = sorted(num)\r\nnum = '+'.join(num)\r\nprint(num) ", "def solve():\r\n s = input()\r\n l = s.split('+')\r\n l.sort()\r\n print('+'.join(l))\r\n\r\n\r\n# t = int(input())\r\nt = 1\r\nwhile t:\r\n solve()\r\n t -= 1\r\n", "a=list(input())\r\nb=[]\r\nc=[\"1\",\"2\",\"3\"]\r\nfor i in range(len(a)):\r\n if a[i]!=\"+\":\r\n b.append(a[i])\r\nb=sorted(b,key=lambda x:c.index(x))\r\nprint(\"+\".join(b))", "w=input().split(\"+\")\r\nfor i in range(len(w)):\r\n w[i]=int(w[i])\r\nw.sort()\r\nprint('+'.join(map(str, w)))", "s = input().split(\"+\")\r\ns.sort()\r\nfor i in range(len(s) - 1):\r\n if len(s) != 1:\r\n print(s[i] + \"+\",end =\"\")\r\nprint(s[-1])", "num=input()\r\nlist_num = list(num)\r\nwhile \"+\" in list_num:\r\n list_num.remove(\"+\")\r\nlist_num=sorted(list_num)#整理后的列表,形如 1 1 2 3 4 4\r\nlist_result=[]#储存 1+ 的列表\r\ni=0\r\nwhile True:\r\n if i <= len(list_num)-2:\r\n result= str(list_num[i])+\"+\"\r\n list_result.append(result)\r\n i+=1\r\n elif i == len(list_num)-1:\r\n result = str(list_num[i])\r\n list_result.append(result)\r\n break\r\n else:\r\n break\r\nprint(\"\".join(list_result))\r\n\r\n", "sum = input()\r\n \r\nints = {}\r\n\r\nfor char in sum:\r\n if char != \"+\":\r\n key = int(char)\r\n current_item = ints.get(key, 0)\r\n ints[key] = current_item + 1\r\n\r\nones = \"\"\r\ntwos = \"\"\r\nthrees = \"\"\r\nfor num in ints:\r\n for n_count in range(ints[num]):\r\n if num == 1:\r\n ones += \"\".join(\"1+\")\r\n elif num == 2:\r\n twos += \"\".join(\"2+\")\r\n else:\r\n threes += \"\".join(\"3+\")\r\n \r\n\r\nresult = ones + twos + threes\r\nprint(result[0:-1])\r\n ", "sum = input()\r\nsplited = sum.split(\"+\")\r\nsplited.sort()\r\nsum = \"\"\r\nfor i in splited:\r\n sum = sum + i + \"+\" \r\nprint(sum[:-1])", "s = input()\r\nL = []\r\nfor i in s:\r\n if i!='+':\r\n L.append(i)\r\nL.sort()\r\nans = \"\"\r\nfor i in range(len(L)):\r\n if i!=len(L)-1:\r\n ans+=L[i]\r\n ans+='+'\r\n else:\r\n ans+=L[i]\r\nprint(ans)", "unsorted_numbers = []\r\nunsorted_numbers = input().split(\"+\")\r\nunsorted_numbers.sort()\r\nx = 0\r\ns = \"\"\r\nwhile x in range(len(unsorted_numbers)):\r\n s += unsorted_numbers[x] + \"+\"\r\n x += 1\r\n \r\nprint(s[:(len(s) - 1)])", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sat Sep 30 11:15:48 2023\r\n\r\n@author: 刘婉婷 2300012258\r\n\"\"\"\r\n\r\nk=''\r\ns=input()\r\ns_1=s.split(\"+\")\r\ns_1.sort()\r\nfor i in s_1:\r\n k+=i+\"+\"\r\nprint(k.rstrip('+'))", "a = input()\r\nlst = []\r\n \r\nif len(a) == 1:\r\n print(a)\r\nelse:\r\n for i in range(0, len(a), 2):\r\n lst.append(int(a[i]))\r\n lst.sort()\r\nprint('+'.join(map(str, lst)))", "print('+'.join(list(sorted(''.join(input().split('+'))))))", "input_string = input()\r\nsorted_characters = '+'.join(sorted(input_string[::2]))\r\nprint(sorted_characters)\r\n", "if __name__ == '__main__':\r\n input_str = input()\r\n input_values = input_str.split('+')\r\n input_values = tuple(sorted(input_values))\r\n output_str = ''\r\n for i in range(len(input_values)):\r\n if i != len(input_values)-1:\r\n output_str += input_values[i] + '+'\r\n else:\r\n output_str += input_values[i]\r\n print(output_str)", "a = input()\r\n\r\nb = a.replace(\"+\",\" \").split()\r\nb.sort()\r\nc = '+'.join(b)\r\nprint(c)", "a=input()\r\nl1=[]\r\nfor i in a:\r\n if i==\"+\":\r\n continue\r\n else:\r\n l1.append(int(i))\r\nl1.sort()\r\nprint(*l1,sep=\"+\")", "#A. Helpful Maths\r\na = input().split(\"+\")\r\na.sort()\r\nb = tuple(a)\r\nx = \"+\".join(b)\r\nprint(x)", "s = input().strip() \r\nnumbers = [int(char) for char in s if char.isdigit()]\r\nnumbers.sort()\r\nnew_sum = '+'.join(map(str, numbers))\r\n\r\nprint(new_sum)", "firstline = input().split('+')\r\nnumber_list = []\r\n\r\nfor i in range(len(firstline)):\r\n number_list.append(int(firstline[i]))\r\n\r\n\r\nnumber_list.sort()\r\n# 1 2 3 \r\nlen(number_list)-1\r\nfor i in range(len(number_list)):\r\n print(number_list[i],end='')\r\n if i!=len(number_list)-1: print('+',end='')\r\n\r\n\r\n\r\n", "s=input()\r\na=s.split(\"+\")\r\na.sort()\r\nfor i in range(len(a)-1):\r\n print(a[i], end=\"+\")\r\nprint(a[len(a)-1])", "y=input()\r\ns=[]\r\nfor i in y:\r\n if i!='+':\r\n s.append(i)\r\n \r\ns.sort()\r\ntxt=''\r\nfor i in range(len(s)):\r\n if i<len(s)-1:\r\n txt=txt+str(s[i])+'+'\r\n else :\r\n txt=txt+str(s[i])\r\n \r\n \r\nprint(txt)", "def solve(word):\r\n word = word.split('+')\r\n word = [int(i) for i in word] \r\n word.sort() \r\n res = \"+\".join(str(i) for i in word) \r\n return res\r\n\r\n\r\n \r\n\r\ndef main():\r\n # Reading multiple test cases\r\n word = input().strip() # string values\r\n # Call the solve function\r\n print(solve(word))\r\n\r\nif __name__ == \"__main__\":\r\n main()", "arr = list(map(int, input().split('+')))\r\narr.sort()\r\nres = '+'.join(str(i) for i in arr)\r\nprint(res)", "s=input()\r\nx=len(s)\r\ny=x//2\r\nz=[]\r\nfor i in s:\r\n if(i!=\"+\"):\r\n z.append(int(i))\r\nz.sort()\r\nk=str(z[0])\r\nz.remove(z[0])\r\nfor i in z:\r\n k=k+\"+\"+str(i)\r\nprint(k)\r\n \r\n\r\n \r\n \r\n\r\n", "\r\n\r\nL = sorted([int(i) for i in input().split(\"+\")])\r\nch = str(L[0])\r\nfor i in range(1,len(L)):\r\n ch += \"+\"+str(L[i])\r\n\r\nprint(ch)\r\n\r\n", "s = list(map(int, input().split(\"+\")))\r\ns.sort()\r\nfor i in range(len(s)):\r\n if i != len(s) - 1:\r\n print(s[i], end='+')\r\n else:\r\n print(s[i])\r\n", "# yje游敬恩,2300012555\r\nnum_list = sorted(list(map(int, input().split(\"+\"))))\r\nfor i in range(len(num_list)-1):\r\n print(num_list[i], end = \"+\")\r\nprint(num_list[len(num_list)-1])", "def helpfulMaths(expression):\r\n numbers = expression.split(\"+\")\r\n numbers.sort()\r\n result = \"+\".join(numbers)\r\n return result\r\n\r\nexpression = input()\r\nresult = helpfulMaths(expression)\r\nprint(result)", "def mergeSort(arr):\r\n if len(arr) > 1:\r\n \r\n # Create sub_array2 ← A[start..mid] and sub_array2 ← A[mid+1..end]\r\n mid = len(arr)//2\r\n sub_array1 = arr[:mid]\r\n sub_array2 = arr[mid:]\r\n \r\n # Sort the two halves\r\n mergeSort(sub_array1)\r\n mergeSort(sub_array2)\r\n \r\n # Initial values for pointers that we use to keep track of where we are in each array\r\n i = j = k = 0\r\n \r\n # Until we reach the end of either start or end, pick larger among\r\n # elements start and end and place them in the correct position in the sorted array\r\n while i < len(sub_array1) and j < len(sub_array2):\r\n if sub_array1[i] < sub_array2[j]:\r\n arr[k] = sub_array1[i]\r\n i += 1\r\n else:\r\n arr[k] = sub_array2[j]\r\n j += 1\r\n k += 1\r\n \r\n # When all elements are traversed in either arr1 or arr2,\r\n # pick up the remaining elements and put in sorted array\r\n while i < len(sub_array1):\r\n arr[k] = sub_array1[i]\r\n i += 1\r\n k += 1\r\n \r\n while j < len(sub_array2):\r\n arr[k] = sub_array2[j]\r\n j += 1\r\n k += 1\r\n\r\n\r\na = input()\r\nb = [a[i] for i in range(0,len(a),2)]\r\nmergeSort(b)\r\nprint(\"+\".join(b))\r\n", "a = input()\r\n\r\nletter_array = a.split(\"+\")\r\nletter_array.sort()\r\n\r\nprint(\"+\".join(letter_array))", "st = input().split(\"+\")\nst = sorted(st)\nst_new = \"\"\nk = 0\nfor i in st:\n if k != 0:\n st_new += \"+\"\n st_new += str(i)\n k+=1\nprint(st_new)\n", "def rearrange():\r\n numbers=list(map(int,input().split(\"+\")))\r\n numbers.sort()\r\n s=map(str,numbers)\r\n return \"+\".join(s)\r\nprint(rearrange())", "s=map(int, input().split(\"+\"))\r\na=sorted(s)\r\nlength=len(a)\r\nfor i in range(length):\r\n if i!=length-1:\r\n print(a[i],end=\"+\")\r\n if i==length-1:\r\n print(a[i],end=\" \")", "s = input()\r\narr = []\r\nfor x in s:\r\n if(x != '+'):\r\n arr.append(int(x))\r\n\r\narr.sort()\r\n\r\nres = ''\r\n\r\nfor i in range(len(arr)-1):\r\n res+=str(arr[i])\r\n res+='+'\r\nres+=str(arr[len(arr)-1])\r\nprint(res)\r\n ", "str_list = input().split(\"+\")\r\nstr_list.sort()\r\n\r\nresult = \"\"\r\nfor num in str_list:\r\n result += num \r\n result += \"+\"\r\nlist1 = list(result)\r\nlist1.pop()\r\n\r\nresult = \"\"\r\nfor ele in list1:\r\n result += ele\r\nprint(result)", "string = input()\nchars = string.split(\"+\")\nfor i in range(len(chars)):\n chars[i] = int(chars[i])\n\nchars.sort()\nstring = \"\"\nfor i in chars:\n string += (str(i) + '+')\nprint(string[:-1])", "s = input()\r\n\r\ndigits = [] \r\nnon_digits = [] \r\n\r\nfor char in s:\r\n if char.isdigit():\r\n digits.append(int(char))\r\n elif char == '+':\r\n non_digits.append(char)\r\n\r\nsorted_digits = sorted(digits)\r\n\r\nresult = str(sorted_digits[0]) + ''.join('+' + str(digit) for digit in sorted_digits[1:])\r\n\r\nprint(result)\r\n", "lst=list(map(int,input().split('+')))\r\nlst.sort()\r\nfor i in range(len(lst)):\r\n\tif i==len(lst)-1:\r\n\t\tprint(lst[i])\r\n\telse:\r\n\t\tprint(lst[i],end='+')", "# Input\r\ns = input()\r\n\r\n# Parse the input string and extract numbers\r\nnumbers = list(map(int, s.split('+')))\r\n\r\n# Sort the numbers in non-decreasing order\r\nnumbers.sort()\r\n\r\n# Construct the new sum as a string\r\nnew_sum = '+'.join(map(str, numbers))\r\n\r\n# Output the new sum\r\nprint(new_sum)\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Thu Oct 26 20:08:18 2023\r\n\r\n@author: Siddhartha\r\n\"\"\"\r\n\r\ninp=sorted(list(input().split('+')))\r\n\r\nlst=[]\r\nfor i in range(0,len(inp)):\r\n if(i!=len(inp)-1):\r\n lst.append(inp[i])\r\n lst.append('+')\r\n else:\r\n lst.append(inp[i])\r\n \r\n\r\nout=lst[0]\r\nfor i in range (1,len(lst)):\r\n out=out+lst[i]\r\n \r\n \r\n \r\nprint(out) ", "n = [int(x)for x in input().split(\"+\")]\r\nn = sorted(n)\r\nn = [str(y)for y in n]\r\nprint(\"+\".join(n))", "resultaat = \"\"\r\nlijst = sorted(list(map(int, input().split(\"+\"))))\r\nfor x in range(0,len(lijst),1):\r\n if x == 0:\r\n resultaat += str(lijst[x])\r\n else:\r\n resultaat += \"+\"+str(lijst[x])\r\nprint(resultaat)", "import re\r\n\r\ns = input()\r\n\r\nnumbers = sorted(re.findall(r'\\d+', s))\r\ns = re.sub(r'\\d+', lambda x : numbers.pop(0), s)\r\n\r\nprint(s)\r\n", "# Read the input sum as a string\r\ns = input()\r\n\r\n# Split the string by '+' and convert the parts to integers\r\nnumbers = list(map(int, s.split('+')))\r\n\r\n# Sort the list of numbers in ascending order\r\nnumbers.sort()\r\n\r\n# Convert the sorted numbers back to strings\r\nsorted_sum = '+'.join(map(str, numbers))\r\n\r\n# Print the sorted sum\r\nprint(sorted_sum)\r\n", "#339A. Helpful Maths\r\ns=input()\r\nl=[]\r\nfor char in s:\r\n if char!=\"+\":\r\n l.append(char)\r\nl.sort()\r\nfor i in range(len(l)):\r\n print(l[i],end=\"\")\r\n if i!=len(l)-1:\r\n print(\"+\",end=\"\")", "inp = input()\r\n\r\ninp = inp.split('+')\r\ninp.sort()\r\nprint('+'.join(inp))", "question = input()\r\nquestion = list(map(int, question.split(\"+\")))\r\nquestion.sort()\r\nprint(\"+\".join(list(map(str, question))))", "s = input()\r\nx=0\r\ny=0\r\nz=0\r\nfor i in range(0, len(s), 2):\r\n if s[i]=='1':\r\n x+=1\r\n elif s[i]=='2':\r\n y+=1\r\n else:\r\n z+=1\r\ns1=\"1+\"*x+\"2+\"*y+\"3+\"*z\r\nprint(s1[:-1])", "x=input()\r\nlist=[]\r\nfor i in x.split(\"+\"):\r\n list.append(int(i))\r\n\r\nf=sorted(list)\r\nh=\"+\".join(map(str,f))\r\nprint(h)\r\n ", "def reorder_expression(expression):\r\n numbers = [int(x) for x in expression.split('+')]\r\n sorted_numbers = sorted(numbers)\r\n reordered_expression = '+'.join(map(str, sorted_numbers))\r\n \r\n return reordered_expression\r\n\r\n# Example usage:\r\nexpression = input()\r\nreordered = reorder_expression(expression)\r\nprint(reordered) \r\n", "L=list(map(int,input().split(\"+\")))\r\nL.sort()\r\nn=len(L)\r\nfor i in range(n-1):\r\n print(str(L[i]),end='+')\r\nprint(str(L[n-1]))\r\n", "n=input().split('+')\r\nn.sort()\r\nprint('+'.join(n))", "s = input()\r\n\r\nnumbers_array = s.split(\"+\")\r\nnumbers_array.sort()\r\nnew_string = \"+\".join(numbers_array)\r\nprint(new_string)\r\n", "def d_s():\r\n\r\n\r\n\r\n\r\n p = sorted(k)\r\n print(*p, sep='+')\r\n\r\nk = map(int, input().split('+'))\r\nd_s()\r\n", "s=input()\r\n\r\nl=[]\r\nfor i in s:\r\n if i==\"+\":\r\n continue\r\n else:\r\n l.append(i)\r\nl.sort()\r\nsum=\"\"\r\nfor i in range (len(l)):\r\n \r\n if i==0:\r\n sum=sum+str(l[i])\r\n else:\r\n sum=sum+\"+\"+ str(l[i])\r\n\r\nprint(sum)\r\n\r\n\r\n", "suma = input()\ncount_1 = suma.count('1')\ncount_2 = suma.count('2')\ncount_3 = suma.count('3')\nnueva_suma = '1+' * count_1 + '2+' * count_2 + '3+' * count_3\nnueva_suma = nueva_suma[:-1]\nprint(nueva_suma)\n\n\t\t\t\t \t\t\t \t \t\t\t\t \t\t \t\t \t \t\t", "print(*(sorted(map(int,input().split('+')))),sep=\"+\")", "b=list(map(str,input().split('+')))\r\nb.sort(reverse=False)\r\nprint('+'.join(b))", "a = str(input()).split(\"+\")\r\na = \"+\".join(sorted(a))\r\nprint(a)", "s = input()\r\ns = s.split(\"+\")\r\ns.sort()\r\n\r\nfor i in range(len(s)):\r\n print(s[i], end = \"\")\r\n\r\n if i != (len(s)-1):\r\n print(\"+\", end = \"\")", "s=input()\r\nt=s.split('+');\r\nt.sort()\r\nprint('+'.join(t));\r\n", "a = input().split(\"+\")\r\nx = sorted(a)\r\nprint(*x, sep=\"+\")\r\n", "init = list(map(int,input().split(\"+\")))\r\ninit.sort()\r\ninit = [str(i) for i in init]\r\nprint (\"+\".join(init))", "s = input()\r\n\r\nlst = []\r\nresult = []\r\n\r\nfor j in s:\r\n if j == \"1\" or j == \"2\" or j == \"3\":\r\n lst.append(j)\r\n\r\nlst.sort()\r\nfor i in lst:\r\n result.append(i)\r\n result.append(\"+\")\r\nresult = result[:-1]\r\n\r\nfor i in result:\r\n print(i,end=\"\")", "# Input the sum as a string\r\ns = input()\r\n\r\n# Split the string by '+' and convert to a list of integers\r\nsummands = list(map(int, s.split('+')))\r\n\r\n# Sort the summands in non-decreasing order\r\nsummands.sort()\r\n\r\n# Convert the sorted summands back to strings\r\nsorted_s = '+'.join(map(str, summands))\r\n\r\n# Output the new sum\r\nprint(sorted_s)\r\n", "inp = input().split('+')\r\nintinp = []\r\n\r\nfor i in inp:\r\n intinp.append(eval(i))\r\n\r\nsortedplused = \"\"\r\nloop = 0\r\n\r\nfor x in sorted(intinp):\r\n loop = loop + 1\r\n if loop == len(intinp):\r\n sortedplused = f'{sortedplused}{x}'\r\n else:\r\n sortedplused = f'{sortedplused}{x}+'\r\n \r\n\r\nprint(sortedplused)", "s=input()\r\ns1=\"\"\r\nl=[]\r\nfor i in s:\r\n if i!='+':\r\n l.append(i)\r\nl.sort()\r\nfor i in l:\r\n s1=s1+str(i)+'+'\r\nprint(s1[0:len(s1)-1])", "a=sorted(input()[::2])\r\nprint(\"+\".join(a))\r\n\r\n \r\n", "string = input().split('+')\r\nstring.sort()\r\nprint('+'.join(string))", "'''\r\n刘思瑞 2100017810\r\n'''\r\nelement = list(map(int,input().split('+')))\r\nelement.sort()\r\nm = element[-1]\r\ndel element[-1]\r\nfor i in element:\r\n print(i,end='+')\r\nprint(m)\r\n", "a=[]\r\ns=(input())\r\nfor i in range(len(s)):\r\n if s[i]!=\"+\":\r\n a.append(s[i])\r\na.sort()\r\nfor j in range(len(a)):\r\n print(a[j], end=\"\")\r\n if j!=len(a)-1:\r\n print(\"+\", end=\"\")", "cal = input().split(\"+\")\r\ncal.sort()\r\nadd_symbol ='+'.join(cal)\r\nprint(add_symbol)\r\n", "x = str(input())\r\ny = x.split(\"+\")\r\ny.sort()\r\nr = 1\r\nc = 2\r\no = 0\r\nfor i in range(len(y)):\r\n y.insert(int(r) , \"+\")\r\n r = r ++ c\r\ny.pop()\r\no = ''.join(y)\r\nprint(o)", "l=list(map(int,input().split(\"+\")));l.sort();o=\"\"\r\nfor i in l:\r\n o=o+str(i)+\"+\"\r\nprint(o[:len(o)-1])", "a = input().split(\"+\")\r\nif len(a)==1:\r\n print(str(a[0]))\r\nelse:\r\n a.sort()\r\n print(\"+\".join(a))", "s = input().split('+')\r\ns = sorted([int(i) for i in s])\r\ns = [str(i) for i in s]\r\nprint('+'.join(s))\r\n", "\"\"\"\r\ncompleted by 乔俊杰,ghglxy\r\n\"\"\"\r\nnumlist = sorted(list(map(int,input().split(\"+\"))))\r\nnumlist2 = [str(i) for i in numlist]\r\nprint(\"+\".join(numlist2))\r\n", "x = [int(i) for i in input().split(\"+\")]\r\nx.sort()\r\nx= \"+\".join([str(i) for i in x])\r\nprint(x)", "a=input()\r\nz=len(a)\r\nc=[]\r\nfor i in a:\r\n if i.isdigit():\r\n c=c+[i]\r\nc.sort()\r\nm=\"\"\r\nfor j in c:\r\n m=m+str(j)+\"+\"\r\nprint(m.strip(\"+\"))", "s = input()\r\nv = []\r\n\r\nfor char in s:\r\n if char == '+':\r\n continue\r\n else:\r\n v.append(int(char))\r\n\r\nv.sort()\r\n\r\nfor i in range(len(v)):\r\n print(v[i], end=\"\")\r\n if i == len(v) - 1:\r\n break\r\n else:\r\n print(\"+\", end=\"\")\r\n\r\nprint()\r\n", "import sys\n\n\nif __name__ == '__main__':\n s = sys.stdin.readline().strip()\n nums = [int(i) for i in s.split(\"+\")]\n nums.sort()\n print(\"+\".join([str(i) for i in nums]))\n", "s=input()\r\nl=[]\r\nfor i in range(0,len(s),2):\r\n l.append(s[i])\r\n\r\n\r\nl.sort()\r\n\r\ns1=''\r\nfor i in l:\r\n s1+= (f\"{i}+\")\r\nprint(s1[:len(s1)-1])", "a=list(map(int,input().split('+')))\r\na.sort()\r\ns=''\r\nfor i in range(len(a)):\r\n if i!=len(a)-1:\r\n s+=str(a[i])+'+'\r\n else:\r\n s+=str(a[i])\r\nprint(s)\r\n", "original=input()\r\nnums=list(map(int,original.split('+')))\r\nnums.sort()\r\nnum=list(map(str,nums))\r\nprint('+'.join(num))", "s = [int(x) for x in input().split('+')]\r\nfor i in range(len(s)):\r\n for j in range(i, len(s)):\r\n if s[i] > s[j]:\r\n s[i], s[j] = s[j], s[i]\r\nprint(*s, sep='+')", "s=input()\r\nb=[]\r\nfor i in s:\r\n if i!='+':\r\n b+=i\r\nb.sort()\r\nc=[]\r\nfor j in b:\r\n c+=j\r\n c+='+'\r\nfor k in range(0,len(c)-1):\r\n print(c[k],end='',sep='')", "q=input()\r\nq1=[]\r\nq2=''\r\nfor i in q.split('+'):\r\n q1.append(int(i))\r\nq1.sort()\r\nfor i in q1:\r\n q2=q2+str(i)+'+'\r\nprint(q2[:-1])\r\n", "s = input()\r\ns = sorted(s)\r\nr = \"\"\r\nfor i in s:\r\n if i.isdigit():\r\n r+=i\r\nr = \"+\".join(r)\r\nprint(r)", "a=list(map(int,input().split(\"+\")))\r\na.sort()\r\nfor i in range(len(a)):\r\n if i==len(a)-1:\r\n print(a[i])\r\n break\r\n\r\n print(a[i],\"+\",sep=\"\",end=\"\")\r\n", "string = input()\r\n\r\n# Will return all string values except for the + sign.\r\n# This problem assumes only strings 1, 2, 3, and + are used.\r\naddSign = [i for i in string if i != \"+\"]\r\n\r\n# Sort the numbers after removing + signs.\r\naddSign.sort()\r\n\r\nfor n in range(len(addSign)):\r\n\r\n # for the index values, except the last, concatinate \"+\"\r\n if n < len(addSign) - 1: # makes sure we don't add + to last index\r\n addSign[n] = str(addSign[n]) + \"+\"\r\n\r\naddSign = \"\".join(addSign) # converts List to String\r\n\r\nprint(addSign)\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Oct 2 20:26:31 2023\r\n\r\n@author: 王天齐\r\n\"\"\"\r\n\r\nl1=list(input())\r\nn=l1.count('+')\r\nfor a in range(n):\r\n l1.remove('+')\r\nl1.sort()\r\nprint('+'.join(l1))", "s = input()\r\nn1 = n2 = n3 = 0\r\n\r\nfor i in s:\r\n if i == '1':\r\n n1 += 1\r\n elif i == '2':\r\n n2 += 1\r\n else:\r\n n3 += 1\r\nres = \"1+\"*n1+\"2+\"*n2+\"3+\"*n3\r\nprint(res[:len(s)])", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Sep 26 22:37:20 2023\r\n\r\n@author: 2300011794\r\n\"\"\"\r\nq=input()\r\nqq=[]\r\nfor i in q:\r\n if i==\"+\":\r\n continue\r\n qq.append(int(i))\r\nqq.sort()\r\nfor i in range(len(qq)-1):\r\n print(qq[i],end=\"+\")\r\nprint(qq[-1])", "s = ''\r\nt = input().split('+')\r\nt = sorted(t)\r\ns += \"+\".join(t)\r\nprint(s)\r\n", "def i():\r\n return(int(input()))\r\ndef l():\r\n return(list(map(int,input().split())))\r\ndef s():\r\n \r\n return(input())\r\ndef m():\r\n return(map(int,input().split()))\r\n\r\n \r\na = s()\r\na = a.split('+')\r\na.sort()\r\na = '+'.join(a)\r\nprint(a)\r\n\r\n\r\n", "#罗誉城 化学与分子工程学院 2300011776\r\na=list(input())\r\na1=a.count('1')\r\nb1=a.count('2')\r\nc1=a.count('3')\r\nn1=['1' for i in range(a1)]\r\nn2=['2' for i in range(b1)]\r\nn3=['3' for i in range(c1)]\r\nn=n1+n2+n3\r\nm=[]\r\nfor i in n:\r\n m.append(i)\r\n m.append('+')\r\ndel m[-1]\r\nprint(''.join(m))", "numlist = sorted(list(map(int,input().split(\"+\"))))\r\nnumlist2 = [str(i) for i in numlist]\r\nprint(\"+\".join(numlist2))", "s = input()\r\nn = [0, 0, 0]\r\n\r\nfor i in range(0, len(s), 2):\r\n if s[i] == '1':\r\n n[0] += 1\r\n elif s[i] == '2':\r\n n[1] += 1\r\n else:\r\n n[2] += 1\r\n\r\nss = '+'.join([str(i) for i in range(1, 4) for j in range(n[i - 1])])\r\nprint(ss)\r\n", "#覃文献 2300017727\r\nstr_list = input().split(\"+\")\r\nstr_list.sort()\r\nprint('+'.join(str_list))", "a = list(map(int, input().split(\"+\")))\r\na.sort()\r\nresult = \"\"\r\nx = 0\r\nfor i in a:\r\n result = result + str(i)\r\n if x < len(a) - 1:\r\n result = result + \"+\"\r\n x = x + 1\r\nprint(result)", "a = input().split(\"+\")\r\nA = []\r\nfor i in range(len(a)):\r\n a[i] = int(a[i])\r\n A.append(a[i])\r\n\r\ndef bubble(arr):\r\n size = len(arr)\r\n for i in range(size):\r\n swapped = False\r\n for k in range(size-i-1):\r\n if arr[k]>arr[k+1]:\r\n arr[k], arr[k+1] = arr[k+1], arr[k]\r\n swapped = True\r\n if not swapped:\r\n break\r\n\r\n\r\narr = A\r\nbubble(arr)\r\nsum=\"\"\r\nfor i in range(len(arr)-1):\r\n sum += str(arr[i]) + \"+\"\r\nprint(sum+str(arr[-1]))", "s = sorted(list(map(int, input().split('+'))))\nres = []\nfor i in s:\n\tres.append(str(i))\nprint(\"+\".join(res))", "def rearrange_sum(s):\r\n numbers = sorted([int(ch) for ch in s if ch.isdigit()])\r\n return ''.join(str(numbers.pop(0)) if ch.isdigit() else ch for ch in s)\r\n\r\ns = input()\r\n\r\nresult = rearrange_sum(s)\r\n\r\nprint(result)", "# Compiled by pku phy zhou_tian 2300011538\r\n\r\na = input()\r\nli = []\r\n\r\nfor i in range(int((len(a)+1)/2)):\r\n li.append(a[2*i])\r\n \r\nli.sort()\r\n\r\nprint(li[0], end='')\r\nfor j in range(1, len(li)):\r\n print(f'+{li[j]}', end='')", "x = [a for a in input().split('+')]\r\ns = \"\"\r\nx = sorted(x)\r\nfor i in x:\r\n s += i + '+'\r\nprint(s[:-1])", "def helpfulMaths():\r\n unsortedEq = input()\r\n unsortedEq = unsortedEq.split(\"+\")\r\n unsortedEq = [int(x) for x in unsortedEq]\r\n unsortedEq = sorted(unsortedEq)\r\n finalEquation = \"\"\r\n for i in range(len(unsortedEq)):\r\n if i == len(unsortedEq)-1:\r\n finalEquation = finalEquation + str(unsortedEq[i])\r\n else:\r\n finalEquation = finalEquation + str(unsortedEq[i]) + \"+\"\r\n print(finalEquation)\r\n \r\nhelpfulMaths()", "numbers = list(input().split('+'))\r\nnewNumbers = sorted(numbers)\r\ncorrectString = ''\r\n\r\nfor number in newNumbers:\r\n correctString += number + '+'\r\nprint(correctString[:-1])", "tx = input().strip()\r\nsumm = tx.split('+')\r\nsumm2 = sorted(summ)\r\nresult = '+'.join(summ2)\r\nprint(result)", "s=input()\r\nn1=n2=n3=0\r\nfor i in range(0,len(s),2):\r\n if s[i]==\"1\":\r\n n1+=1\r\n elif s[i]==\"2\":\r\n n2+=1\r\n else:\r\n n3+=1\r\nss=\"1+\"*n1+\"2+\"*n2+\"3+\"*n3\r\nprint(ss[:-1])", "s = input()\r\nss=\"\"\r\nl=[]\r\nfor i in s:\r\n if i!='+':\r\n l.append(i)\r\nl.sort()\r\nfor i in l:\r\n ss+=i+'+'\r\nprint(ss[:-1])", "problem=str(input())\r\nsatured_problem=[]\r\nfor a in range(0,len(problem)):\r\n if a%2==0:\r\n satured_problem.append(problem[a])\r\nsatured_problem.sort()\r\nfor a in range(0,len(problem)):\r\n if a%2==1:\r\n satured_problem.insert(a,\"+\")\r\nprint(''.join(satured_problem))", "\"\"\"\r\nCreated on Tue Oct 3 23:27:19 2023\r\n\r\n@author: 2300011376\r\n\"\"\"\r\n\r\nA=list(input())\r\nB=[]\r\nfor i in A:\r\n if i!='+':\r\n B.append(i)\r\nB.sort()\r\nprint('+'.join(B))", "s1 = input().split('+')\r\ns1.sort()\r\ns1 = \"+\".join(s1)\r\nprint(s1)", "def firstdef(s):\n y = [int(char) for char in s if char.isdigit()]\n y.sort()\n y1 = '+'.join(map(str, y))\n return y1\n\n\nx = input()\nx1 = firstdef(x)\nprint(x1)\n\t \t\t\t \t\t \t\t\t\t \t \t\t\t \t\t\t \t\t\t", "def main():\r\n s = input()\r\n\r\n string = \"\"\r\n if \"+\" in s:\r\n number_list = list_sort([int(i) for i in s.split(\"+\")])\r\n for i in range(len(number_list)):\r\n string += str(number_list[i])\r\n string += \"+\" if i+1!=len(number_list) else \"\"\r\n else:\r\n string = s\r\n \r\n print(string)\r\n\r\ndef list_sort(input_list):\r\n while True:\r\n flag = True\r\n for i in range(len(input_list)-1):\r\n if input_list[i]>input_list[i+1]:\r\n input_list[i], input_list[i+1] = input_list[i+1], input_list[i]\r\n flag = False\r\n if flag:\r\n return input_list\r\n\r\n\r\nmain()", "s = str(input())\r\nnew = s.split(\"+\")\r\nnew.sort()\r\nf = \"+\".join(new)\r\nprint(f)\r\n", "s = list(map(int, input().split(\"+\")))\r\n\r\ns.sort()\r\nprint(\"+\".join([str(ss) for ss in s]))", "a = input()\r\nb = []\r\n\r\nfor i in a:\r\n if i.isdigit():\r\n b.append(int(i))\r\n\r\nc = sorted(b)\r\n\r\nfor index, j in enumerate(c):\r\n if index < len(c) - 1:\r\n print(j, end='+')\r\n else:\r\n print(j)", "initial_sum = str(input())\r\nspaced_sum = initial_sum.replace('+',' ')\r\nlist_sum = spaced_sum.split()\r\n\r\nlist_sum = [int(num) for num in list_sum]\r\n\r\nlist_sum.sort()\r\n\r\nlist_sum = [str(num) for num in list_sum]\r\nfinal_sum = '+'.join(list_sum)\r\nprint(final_sum)", "s=input()\r\nn=s.split('+')\r\nn.sort()\r\nif len(s)>1:\r\n st=\"+\".join(n)\r\n print(st)\r\nelse:\r\n print(s)", "n = sorted(list(input().split('+')))\r\nk = ''\r\nfor i in range(len(n)):\r\n k += str(n[i]) + '+'\r\nprint(k[:-1])", "s = input().split('+')\r\nn = ''\r\nfor i in sorted(s):\r\n n += i + '+'\r\nprint(n[:-1])", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sat Sep 30 09:35:45 2023\r\n\r\n@author: 程卓 2300011733\r\n\"\"\"\r\n\r\nnumbers = sorted(input().split('+'))\r\nfor i in range(len(numbers)-1):\r\n print(numbers[i],end = '+')\r\nprint(numbers[-1])", "thelist = list(map(int,input().split(\"+\")))\r\nnewlist = sorted(thelist)\r\nanswer = '+'.join(map(str,newlist))\r\nprint(answer)", "equ = input()\r\nnums = equ.split(\"+\")\r\nnums.sort() # sort them\r\nprint(\"+\".join(nums))", "x=list(input().split('+'))\r\ny=list(x)\r\ny.sort()\r\ns=''\r\nfor i in y:\r\n s += '+' + i\r\nprint(s[1:])\r\n \r\n\r\n\r\n", "#339A: Helpful Maths\r\nnums = input().split(\"+\")\r\nnums.sort()\r\nprint(nums[0], end = '')\r\nfor i in range(len(nums)-1):\r\n print(\"+\", end = nums[i+1])", "l= input().split('+')\r\nprint('+'.join(sorted(l[::-1])))", "a=input().split('+')\r\na.sort()\r\nfor i in range(0,len(a)-1):\r\n print(a[i],end='+')\r\nprint(a[len(a)-1])", "s=input()\r\nsn=s.replace(\"+\",\"\")\r\nlst=list(sn)\r\nlst2=sorted(lst)\r\nprint(\"+\".join(lst2))", "input_s = input()\r\nnum = list(map(int, input_s.split('+')))\r\nnum.sort()\r\nnew_sum = '+'.join(map(str,num))\r\nprint(new_sum)", "text0 = input()\r\ntext1 = text0.split('+')\r\ntext2 = sorted(text1)\r\nlast = text2.pop()\r\nfor num in text2:\r\n print(num, end='+')\r\nprint(last)", "if __name__ == '__main__':\r\n string = input()\r\n numbers = string.split('+')\r\n numbers.sort()\r\n fsum = '+'.join(numbers)\r\n print(fsum)\r\n", "k = input().split(\"+\")\r\np = sorted(k)\r\nprint('+'.join(str(x) for x in p))", "# Read the sum from input\r\ns = input()\r\n\r\n# Convert the string into a list of integers\r\nsummands = list(map(int, s.split('+')))\r\n\r\n# Sort the list in non-decreasing order\r\nsorted_summands = sorted(summands)\r\n\r\n# Join the integers back into a string with '+' characters\r\nnew_sum = '+'.join(map(str, sorted_summands))\r\n\r\nprint(new_sum)", "n = list(input())\r\nfor i in range(len(n)//2):\r\n n.remove(\"+\")\r\nn.sort()\r\nprint(\"+\".join(n))", "s = input()\r\n\r\noperands = [int(operand) for operand in s.split('+')]\r\n\r\noperands.sort()\r\n\r\nsorted_sum = '+'.join(map(str, operands))\r\n\r\nprint(sorted_sum)\r\n", "a = input()\r\nletters = []\r\nfor letter in a:\r\n\tletters.append(letter)\r\nb = letters.count(\"+\")\r\nfor i in range(b):\r\n\tletters.remove(\"+\")\r\nc = letters.count(\"1\")\r\nd = letters.count(\"2\")\r\ne = letters.count(\"3\")\r\nanswer = []\r\nfor i in range(c):\r\n\tanswer.append(\"1\")\r\nfor i in range(d):\r\n\tanswer.append(\"2\")\r\nfor i in range(e):\r\n\tanswer.append(\"3\")\r\nprint(\"+\".join(answer))\r\n", "# Read the input string\r\ns = input()\r\n\r\n# Split the string into individual digits\r\ndigits = [int(char) for char in s if char.isdigit()]\r\n\r\n# Sort the digits in non-decreasing order\r\nsorted_digits = sorted(digits)\r\n\r\n# Create a new string with the sorted digits and '+' signs\r\nsorted_sum = '+'.join(map(str, sorted_digits))\r\n\r\n# Print the rearranged sum\r\nprint(sorted_sum)\r\n\r\n\r\n\r\n\r\n \r\n", "sumInp = sorted(list(map(int,input().split(\"+\"))))\r\nprint(\"+\".join(map(str,sumInp)))", "s = input().strip().split('+')\r\ns.sort()\r\nprint('+'.join(s))", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Oct 2 20:51:16 2023\r\n\r\n@author: 雷雨松\r\n\"\"\"\r\ns=input()\r\nn=len(s)\r\nans=[]\r\nfor i in range(0,n):\r\n if(s[i]=='+'):\r\n continue\r\n else:\r\n ans.append(s[i])\r\nans.sort()\r\nprint(\"+\".join(ans))\r\n \r\n", "s1=0\r\ns2=0\r\ns3=0\r\nc=input()\r\nfor i in c:\r\n if i=='+':\r\n continue\r\n elif i=='1':\r\n s1=s1+1\r\n elif i=='2':\r\n s2=s2+1\r\n else:\r\n s3=s3+1\r\nif s1!=0:\r\n print('1'+\"+1\"*(s1-1),\"+2\"*s2,\"+3\"*s3,sep=\"\")\r\nelif s2!=0:\r\n print(\"2\"+\"+2\"*(s2-1),\"+3\"*s3,sep=\"\")\r\nelse:\r\n print(\"3\"+\"+3\"*(s3-1))", "l=input().split(\"+\")\r\nl.sort()\r\nprint('+'.join(l))", "numbers=list(map(int,input().split(\"+\")))\r\nnumbers_sorted=sorted(numbers)\r\nstring=\"\"\r\nfor number in numbers_sorted:\r\n string=string+\"+\"+str(number)\r\nstring=string[1:]\r\nprint(string)", "s = input()\r\ncount = [0, 0, 0] \r\nfor c in s:\r\n if c == '1':\r\n count[0] += 1\r\n elif c == '2':\r\n count[1] += 1\r\n elif c == '3':\r\n count[2] += 1\r\nnew_s = '1' * count[0] + '2' * count[1] + '3' * count[2] # construct the new sum\r\nprint('+'.join(new_s)) ", "entry=list(map(int, input().split(\"+\")))\nentry=sorted(entry)\nmaxlength=len(entry)\nfor i in range(maxlength):\n if i!=maxlength-1:\n print(entry[i],end='+')\n if i==maxlength-1:\n print(entry[i],end='')\n\n\n", "sum = input()\r\n\r\narr = []\r\nturn = True\r\nfor i in sum:\r\n if turn:\r\n arr.append(int(i))\r\n turn = False\r\n else:\r\n turn = True\r\narr.sort()\r\nturn = True\r\nans = \"\"\r\nl = 0\r\nfor i in range(len(sum)):\r\n if turn:\r\n ans += str(arr[l])\r\n l += 1\r\n turn = False\r\n else:\r\n ans+= \"+\"\r\n turn = True\r\nprint(ans)", "line = input()\r\nsummand = line.split('+')\r\nsummand.sort()\r\nans = '+'.join(summand)\r\nprint(ans)", "ques = input().split('+')\r\nques.sort()\r\nprint(\"+\".join(ques))", "# Read the sum as a string\r\ns = input()\r\n\r\n# Split the string by '+' to get the summands as a list\r\nsummands = s.split('+')\r\n\r\n# Sort the summands in non-decreasing order as integers\r\nsummands = sorted(map(int, summands))\r\n\r\n# Reconstruct the new sum string by joining the sorted summands with '+'\r\nnew_sum = '+'.join(map(str, summands))\r\n\r\n# Print the new sum that Xenia can count\r\nprint(new_sum)\r\n", "a=list(input())\r\na.sort()\r\nwhile (\"+\"in a):\r\n a.remove(\"+\")\r\ns=(\"+\").join(a)\r\nprint(s)\r\n", "a=str(input())\r\nl=[]\r\nfor i in range(0,len(a),2):\r\n l.append(a[i])\r\nl.sort()\r\nnew=''\r\nfor i in l:\r\n new+=i\r\n new+='+'\r\nprint(new[0:len(a):1])", "line = list(map(int, input().split('+')))\r\n\r\ni = 0\r\n\r\nfor i in range(len(line)):\r\n for j in range(0, len(line) - i - 1):\r\n tmp = line[j]\r\n if(j == len(line) - 1):\r\n break\r\n if(line[j] > line[j+1]):\r\n line[j] = line[j+1]\r\n line[j+1] = tmp\r\n\r\nline = map(str,line)\r\n\r\nprint('+'.join(line))\r\n\r\n\r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n", "nums = [i for i in input() if i.isnumeric()]\r\nnums1 = sorted(nums, reverse=True)\r\noperations = []\r\nfor i in nums1:\r\n operations.insert(0, i + '+')\r\n\r\na, b = operations[-1]\r\nif b == '+':\r\n operations.remove(operations[-1])\r\n operations.append(a)\r\n\r\nprint(*operations, sep='')\r\n", "\r\nnums = input().split('+') # taking the input\r\nnums.sort() # sorting the input\r\nresult = \"\"\r\n\r\nfor num in nums: # making the right sum\r\n result += f\"{num}+\"\r\n\r\nresult = result[:-1] # removing the last extra '+'\r\n\r\nprint(result) # printing the result to the terminal\r\n", "s = input()\r\nsp = []\r\nsps = \"\"\r\nfor i in range(len(s) // 2 + 1):\r\n sp.append(int(s[i * 2]))\r\nsp.sort()\r\nfor el in sp:\r\n sps += str(el) + \"+\"\r\nprint(sps[:-1])", "a = input().split('+')\r\na.sort()\r\nfor ii,i in enumerate(a):\r\n if ii != len(a) -1:\r\n print(i+'+',end = '')\r\n else:\r\n print(i)\r\n", "li=[i for i in input().split(\"+\")]\r\nli.sort()\r\nprint(\"+\".join(li))", "s1 = input()\r\nlst = s1.split('+')\r\nlst.sort()\r\ns2 = '+'.join(lst)\r\nprint(s2)", "print(\"+\".join(sorted(map(str,input().split(\"+\")))))", "a=list(map(int,input().split('+')))\r\na.sort()\r\nk=''\r\nfor i in range (len(a)-1):\r\n k+=str(a[i])+\"+\"\r\nk+=str(a[len(a)-1])\r\nprint(k)\r\n \r\n", "a = input()\r\nnums = list()\r\nfor i in range(len(a)):\r\n if a[i] != \"+\":\r\n nums.append(int(a[i]))\r\nnums.sort()\r\nfor i in range(len(nums)):\r\n if i != 0:\r\n print(\"+\", nums[i], sep='', end='')\r\n else:\r\n print(nums[i], end='')\r\n", "a = input()\n\nb = ((sorted(a[::2])))\n\nprint(\"+\".join(b))\n\n#print(\"+\".join(sorted(input()[::2])))", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[14]:\n\n\ns = input()\n\n# Split the input string by '+' and convert to integers\nnumbers = list(map(int, s.split('+')))\n\n# Sort the numbers in non-decreasing order\nnumbers.sort()\n\n# Convert the sorted numbers back to strings and join them with '+'\nnew_sum = '+'.join(map(str, numbers))\n\n# Print the new sum that Xenia can count\nprint(new_sum)\n\n\n\n# In[ ]:\n\n\n\n\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Thu Sep 21 19:50:41 2023\r\n\r\n@author: 余汶青\r\n\"\"\"\r\ns=[int(i) for i in input().split('+')]\r\ns.sort()\r\ns=[str(i) for i in s]\r\nb=\"+\".join(s)\r\nprint(b)", "string = input()\r\nnew_str = \"\"\r\nlst = []\r\nfor i in string:\r\n if i != \"+\":\r\n lst.append(i)\r\nlst = sorted(lst)\r\nfor i in lst:\r\n new_str += i\r\n \r\n new_str += \"+\"\r\n \r\nprint(new_str[:-1])", "s = input()\r\nll = list(map(str, s.split('+')))\r\nll.sort()\r\ns = '+'.join(ll)\r\nprint(s)\r\n\r\n\r\n", "input_string = input()\r\n\r\n\r\ndef solve(string):\r\n\r\n numbers = string.split('+')\r\n\r\n numbers.sort()\r\n\r\n answer = ''\r\n\r\n for number in numbers:\r\n answer += number + '+'\r\n\r\n answer = answer[0:-1]\r\n\r\n print(answer)\r\n\r\n\r\nsolve(input_string)\r\n", "s = input()\r\nnums = s.split(\"+\")\r\nnums.sort()\r\nprint(\"+\".join(nums))", "s=input()\r\nnumbers=[int(x) for x in s.split('+')]\r\nnumbers.sort()\r\nsortedSum='+'.join(map(str,numbers))\r\nprint(sortedSum)", "l=list(input())\r\na=l.count(\"1\")\r\nb=l.count(\"2\")\r\nc=l.count(\"3\")\r\nm=[]\r\nfor i in range(a):\r\n m.append(\"1+\")\r\nfor i in range(b):\r\n m.append(\"2+\")\r\nfor i in range(c):\r\n m.append(\"3+\")\r\nstring=\"\"\r\nfor i in range(len(m)):\r\n string+=m[i]\r\nresult=\"\"\r\nfor i in range(len(string)-1):\r\n result+=string[i]\r\nprint(result)\r\n", "s = input()\r\nun_s = list()\r\nfor e in s:\r\n if not e == \"+\":\r\n un_s.append(int(e))\r\n\r\ns_s = sorted(un_s)\r\nfor n in range(len(s_s)):\r\n if n == len(s_s) - 1:\r\n print(s_s[n], end=\"\")\r\n else:\r\n print(s_s[n], end=\"+\")", "def reorder_sum(s):\r\n numbers = [int(char) for char in s if char.isdigit()]\r\n numbers.sort()\r\n new_sum = '+'.join(map(str, numbers))\r\n return new_sum\r\ns = input()\r\nnew_sum = reorder_sum(s)\r\nprint(new_sum)\r\n", "expression = input()\r\n\r\n# Split the expression into numbers and operators\r\nnumbers = [int(x) for x in expression.split(\"+\")]\r\n\r\n# Sort the numbers in ascending order\r\nnumbers.sort()\r\n\r\n# Reconstruct the expression with the sorted numbers\r\nsorted_expression = \"+\".join(map(str, numbers))\r\n\r\n# Print the sorted expression\r\nprint(sorted_expression)", "s = input()\r\nh = s.split('+')\r\np = ''\r\nlist.sort(h)\r\nfor i in range(len(h)-1):\r\n p = p + h[i] + '+'\r\np = p + h[len(h) - 1]\r\nprint(p)", "s = input().strip()\r\nsum = list(map(int, s.split('+')))\r\nsum.sort()\r\nresult = '+'.join(map(str, sum))\r\nprint(result)\r\n", "a=input()\r\ne=0\r\nd=0\r\nt=0\r\nfor i in range(0,len(a)):\r\n if a[i] == '1':\r\n e+=1\r\n elif a[i] == '2':\r\n d+=1\r\n elif a[i] == '3':\r\n t+=1\r\ns='1+'*e + '2+'*d + '3+'*t\r\nprint(s[:-1:])", "list_s = input().split(sep=\"+\")\r\nlist_s.sort()\r\nprint(str(list_s).replace(\"', '\", \"+\").replace(\"['\", \"\").replace(\"']\", \"\"))", "s = input()\r\n\r\nnumbers = s.split('+')\r\n\r\nnumbers = [int(x) for x in numbers]\r\nnumbers.sort()\r\n\r\nnew_sum = '+'.join(map(str, numbers))\r\n\r\nprint(new_sum)\r\n", "a=sorted([int(i) for i in input().split(\"+\")])\r\nprint(\"+\".join(str(x) for x in a))", "s=input()\r\ns=s.split(\"+\")\r\n\r\nfor i in range (len(s)):\r\n s[i]=int(s[i])\r\n\r\ns=sorted(s)\r\nx=''\r\nj=0\r\n\r\nfor i in s:\r\n if (j<len(s)-1):\r\n x+=str(i)+'+' \r\n else: \r\n x+=str(i)\r\n j+=1\r\nprint(x) ", "numbers=list(map(int,input().split('+')))\r\nnumbers.sort()\r\nfor i,ele in enumerate(numbers):\r\n print(ele,end='')\r\n if i!=len(numbers)-1:\r\n print('+',end='')", "n = list(map(str, input().split('+')))\r\nn.sort()\r\nprint('+'.join(n))", "s = list(map(int, input().split('+')))\r\ns.sort()\r\nprint(*s, sep='+')", "numberc = input().split('+')\r\nnumberc.sort()\r\nprint('+'.join(numberc))", "arr = input().split('+')\r\narr = [int(i) for i in arr]\r\narr.sort()\r\n\r\nfor i in range(len(arr)):\r\n if i != (len(arr) - 1):\r\n print(arr[i] , end= '+')\r\n elif i == (len(arr) - 1):\r\n print(arr[i])\r\n\r\n", "\r\ns = input()\r\n\r\nnumbers = s.split(\"+\")\r\n\r\n\r\nnumbers = sorted(map(int, numbers))\r\n\r\n\r\nresult = \"+\".join(map(str, numbers))\r\n\r\nprint(result)\r\n", "s=input()\r\ns=list(s)\r\nk=[]\r\nfor i in range(0,len(s),2):\r\n k.append(int(s[i]))\r\nk.sort()\r\nl=0\r\nfor i in range(len(s)):\r\n if i%2==0:\r\n s[i]=k[l]\r\n l+=1\r\n print(s[i],end=\"\")\r\n ", "s = input().split(\"+\")\ns.sort()\nfor i in range(len(s)):\n print(s[i], end=\"+\") if i!=len(s)-1 else print(s[i])", "s=input().split(\"+\")\nsort=sorted(s)\nnew=\"+\".join(sort)\nprint(new)", "import string\r\n\r\ndef print_formula(n, c):\r\n s =''\r\n for i in range(n):\r\n s = s + c + '+'\r\n return s\r\n\r\ns = input()\r\nn = len(s)\r\none = 0\r\ntwo = 0\r\nthree = 0\r\n\r\nfor i in range(n):\r\n if s[i] == '1':\r\n one +=1\r\n elif s[i] == '2':\r\n two +=1\r\n elif s[i] == '3':\r\n three +=1\r\nres = print_formula(one, '1')\r\nres = res + print_formula(two, '2')\r\nres = res + print_formula(three, '3')\r\nprint(res[:-1])\r\n \r\n \r\n\r\n\r\n\r\n", "n=list(input().split('+'))\r\na=sorted(n)\r\nprint('+'.join(a))", "num = input().split(\"+\")\r\n\r\nnum.sort()\r\noutput = \"\"\r\n\r\nfor i in num:\r\n output = output + i + \"+\"\r\n\r\nprint (output[:-1])\r\n \r\n", "str = input()\r\nlst = []\r\nfor i in range(0, len(str)):\r\n if '1'<=str[i]<='9':\r\n lst.append(str[i])\r\nlst.sort()\r\nfor k in range(0, len(lst)-1):\r\n print(lst[k], end=\"+\")\r\nprint(lst[-1])\r\n", "sum1 = input()\nlen2 = len(sum1)\nlen1 = len(sum1)//2\nsorted = sorted(sum1)\nfor i in range(len1,len2-1):\n print(sorted[i]+\"+\", end=\"\")\n\nprint(sorted[len2-1])\n", "n = input().split(\"+\")\r\nn.sort()\r\ni=0\r\nresult=\"\"\r\nwhile i <= len(n)-1:\r\n if result == \"\":\r\n result = n[i]\r\n else:\r\n result = result + \"+\" + n[i]\r\n i+=1\r\nprint(result)", "str = input()\r\nlis = list(str.split(\"+\"))\r\nlis.sort()\r\nstr1 = \"\"\r\nfor i in range(len(lis)):\r\n str1= str1+lis[i]+\"+\"\r\nstr1 = str1[:-1]\r\nprint(str1)", "n = input().split(\"+\")\r\nm = sorted(n)\r\nl = \"\"\r\nfor i in m:\r\n l += str(i)\r\nl = l.replace('','+')\r\nprint(l[1:-1])", "n = list(input())\r\n\r\nfor _ in range(len(n)):\r\n for i in range(0, len(n)-2):\r\n if n[i] > n[i+2]:\r\n n[i], n[i+2] = n[i+2], n[i]\r\n\r\nprint(''.join(n))", "s = sorted(list(map(int, input().split('+'))))\r\nans = str()\r\nfor i in range(len(s)):\r\n ans = ans + str(s[i])\r\n\r\nans = \"+\".join(ans)\r\nprint(ans)", "st=input()\nlst=st.split(\"+\")\nnlst=[]\nfor n in lst:\n nlst.append(int(n))\n\nnlst=sorted(nlst)\n\nfor i in range(len(nlst)-1):\n print(str(nlst[i]), end = \"+\")\n\nprint(nlst[len(lst)-1])\n ", "lis=list(map(str,input().split(\"+\")))\r\nlis.sort()\r\nprint(lis[0],end=\"\")\r\nfor i in range(1,len(lis)):\r\n print('+'+lis[i],end=\"\")", "s = input()\r\na1 = a2 = a3 = 0\r\nfor i in range(0, len(s), 2):\r\n if s[i] == '1':\r\n a1 += 1\r\n elif s[i] == '2':\r\n a2 += 1\r\n else:\r\n a3 += 1\r\nss = \"1+\" * a1 + \"2+\" * a2 + \"3+\" * a3\r\nprint(ss[:-1])", "s = input().split(\"+\")\r\ns.sort()\r\nans = \"\"\r\nfor i in s:\r\n ans += i\r\n ans += \"+\"\r\nprint(ans[:-1])", "s = input()\r\ncounts = {\"1\": 0, \"2\": 0, \"3\": 0}\r\n\r\nfor n in s:\r\n if n != \"+\":\r\n counts[n] += 1\r\n\r\nnew_sum = \"+\".join([\"1\"] * counts[\"1\"] + [\"2\"] * counts[\"2\"] + [\"3\"] * counts[\"3\"])\r\n\r\nprint(new_sum)", "def helpful_maths():\r\n initial_sum = input()\r\n \r\n if len(initial_sum) == 1:\r\n print(initial_sum)\r\n return\r\n \r\n result_list = initial_sum.split(\"+\")\r\n result_list.sort()\r\n \r\n result = \"+\".join(result_list)\r\n \r\n print(result)\r\n\r\nhelpful_maths()", "x = input().split(\"+\")\r\nx.sort()\r\nfor i, v in enumerate(x):\r\n print(str(v), end=\"\")\r\n if i != len(x) - 1:\r\n print(\"+\", end=\"\")", "x = input(\"\").split(\"+\")\r\nfor i in range(0 , len(x)):\r\n x[i] = int(x[i])\r\n\r\ncompleted = 0\r\nfor i in range(0 , len(x)):\r\n if x[i] == 1:\r\n print(\"1\",end = \"\")\r\n completed = completed + 1\r\n if completed == len(x):\r\n break\r\n if x[i] == 1:\r\n\r\n print(\"+\",end = \"\")\r\n\r\nfor i in range(0 , len(x)):\r\n if x[i] == 2:\r\n print(\"2\",end = \"\")\r\n completed = completed + 1\r\n if completed == len(x):\r\n break\r\n if x[i] == 2:\r\n\r\n print(\"+\",end = \"\")\r\n\r\nfor i in range(0 , len(x)):\r\n if x[i] == 3:\r\n print(\"3\",end = \"\")\r\n completed = completed + 1\r\n if completed == len(x):\r\n break\r\n if x[i] == 3:\r\n print(\"+\",end = \"\")", "s=input()\r\nlst=[]\r\nfor i in range(0,len(s)):\r\n if i%2==0:\r\n lst.append(s[i])\r\nlst.sort()\r\nprint(\"+\".join(lst))\r\n", "x = input()\r\nn = sorted([x[i] for i in range(0,len(x),2)])\r\nprint(\"+\".join(n))\r\n\r\n", "print('+'.join(sorted(input()[::2]))) ", "added = input().split(\"+\")\r\nadded = [int(x) for x in added]\r\nadded.sort()\r\nadded = [str(x) for x in added]\r\nrearranged = \"+\".join(added)\r\nprint(rearranged)", "a = input()\r\na = list(a)\r\n\r\nfor c in range(0, len(a), 2):\r\n for d in range(0, len(a) - 1, 2):\r\n if a[d] > a[d + 2]:\r\n a[d], a[d + 2] = a[d + 2], a[d]\r\n\r\nresult = ''.join(a)\r\nprint(result)", "operation = input().split('+')\r\noperation.sort()\r\nprint('+'.join(operation)) ", "x=str(input())\r\na=0\r\nb=0\r\nc=0\r\nfor i in x:\r\n if i=='1':\r\n a+=1\r\n if i=='2':\r\n b+=1\r\n if i=='3':\r\n c+=1\r\nif a==0 and c==0:\r\n print((b-1)*'2+'+'2')\r\nelif b==0 and c==0:\r\n print((a-1)*'1+'+'1')\r\nelif c==0:\r\n print(a*'1+'+(b-1)*'2+'+'2')\r\nelse:\r\n print(a*'1+'+b*'2+'+(c-1)*'3+'+'3')\r\n\r\n", "a = map(int,input().split(\"+\"))\r\nb = sorted(a)\r\nc = len(b)\r\n\r\nfor i,j in enumerate(b):\r\n print(j,end=\"\")\r\n if(i<c-1):\r\n print(\"+\",end=\"\")\r\n else:\r\n break", "n = input().split(\"+\")\r\nn.sort()\r\nj = \"\"\r\nfor i in n:\r\n j += f\"{i}+\"\r\nprint(j[0:-1])", "#2300012105 刘乐天 生命科学学院\r\na=input()\r\nc=[]\r\nf=[]\r\nfor b in a :\r\n if b.isdigit():\r\n c.append(b)\r\nc.sort()\r\nfor d in c:\r\n f.append(d)\r\n f.append(\"+\")\r\nf.pop()\r\nf=''.join(f)\r\nprint(f)\r\n", "strinng = input()\r\n\r\nlist1 = []\r\n\r\nfor i in strinng:\r\n if i.isdigit():\r\n list1.append(i)\r\n\r\nlist1.sort()\r\n\r\nnew_list1 = '+'.join(map(str, list1))\r\n\r\n\r\nprint(new_list1)", "a =input().split(\"+\")\r\n\r\na.sort()\r\nb =\"+\".join(a)\r\nprint(b)", "s = input()\r\n\r\n# Extract numbers from the input string\r\nnumbers = [int(x) for x in s.split(\"+\")]\r\n\r\n# Sort the numbers\r\nnumbers.sort()\r\n\r\n# Print the rearranged sum\r\nresult = \"+\".join(map(str, numbers))\r\nprint(result)\r\n", "line = input('')\r\n\r\nlist = line.split('+')\r\nsorted = sorted(list)\r\nprint('+'.join(sorted))", "n=input()\r\na=n.split(\"+\")\r\nb=sorted(a)\r\nprint('+'.join(b))", "# Read the input sum as a string\r\ns = input()\r\n\r\n# Split the input string into individual summands using the \"+\" character as a delimiter\r\nsummands = s.split(\"+\")\r\n\r\n# Sort the summands in non-decreasing order\r\nsummands.sort()\r\n\r\n# Join the sorted summands back into a new sum string\r\nnew_sum = \"+\".join(summands)\r\n\r\n# Print the new sum\r\nprint(new_sum)\r\n", "\r\ns = input()\r\n\r\nsummands = list(map(int, s.split('+')))\r\n\r\nsummands.sort()\r\n\r\nsorted_summands = [str(x) for x in summands]\r\n\r\nnew_sum = '+'.join(sorted_summands)\r\n\r\nprint(new_sum)\r\n", "print('+'.join(sorted(input('').split('+'))))", "s = input()\r\nnumbers = s.split(\"+\")\r\nsorted_numbers = sorted(map(int, numbers))\r\nresult = \"+\".join(map(str, sorted_numbers))\r\nprint(result)\r\n", "#author 沈天健 2300011417\r\na=input().split('+')\r\na.sort()\r\nprint('+'.join(map(str,a)))\r\n", "list1=input().split(\"+\")\nprint(\"+\".join(sorted(list1)))", "a = list(map(int,input().split(\"+\")))\r\nans = \"\"\r\na.sort()\r\nfor i in range(len(a)):\r\n ans += \"+\"+str(a[i])\r\nprint(ans[1:])\r\n", "firstline = input().split('+')\r\nnumber_list = []\r\n\r\nfor i in range(len(firstline)):\r\n number_list.append(int(firstline[i]))\r\n\r\n\r\nnumber_list.sort()\r\n# 1 2 3 \r\nfor i in range(len(number_list)):\r\n print(number_list[i],end='')\r\n if i != len(number_list)-1:\r\n print('+',end='')", "q=input()\r\nif q.count(\"+\")==0:\r\n print(q)\r\nelse:\r\n a=q.split(\"+\")\r\n for i in range(0,len(a)):\r\n a[i]=int(a[i])\r\n a.sort()\r\n print(a[0], end=\"\")\r\n for i in range(1, len(a)):\r\n print(\"+\", a[i], sep=\"\", end=\"\")", "exp = input()\r\nnum_list = list()\r\nfor i in range(len(exp)):\r\n if exp[i] != '+':\r\n num_list.append(exp[i])\r\n\r\nnum_list.sort()\r\n\r\nfor j in range(len(num_list)):\r\n if j != len(num_list) - 1:\r\n print(num_list[j], end='+')\r\n else:\r\n print(num_list[j])", "a = input()\r\nb = [a[i] for i in range(0,len(a),2)]\r\nb.sort()\r\nprint(\"+\".join(b))\r\n", "print('+'.join(list(str(i) for i in sorted(list(map(int,input().split('+')))))))\r\n\r\n", "line = input()\r\nif '+' in line:\r\n nums = sorted(line.split('+'))\r\n line = '+'.join(num for num in nums)\r\nprint(line)", "m = input().split('+')\r\nans = ''\r\nfor i in sorted(m):\r\n ans += str(i) + '+'\r\nprint(ans[:len(ans) - 1])", "s = input()\r\n\r\nstring = \"\"\r\nif \"+\" in s:\r\n number_list = sorted([int(i) for i in s.split(\"+\")])\r\n for i in range(len(number_list)):\r\n string += str(number_list[i])\r\n string += \"+\" if i+1!=len(number_list) else \"\"\r\nelse:\r\n string = s\r\n\r\nprint(string)", "#https://codeforces.com/problemset/problem/339/A\n\nimport math\n#import numpy as np\n\nif __name__==\"__main__\":\n n = input()\n s = [int(x) for x in n.split(\"+\")]\n s.sort()\n print(\"+\".join([str(x) for x in s]))\n\n", "mat = list(map(int, input().split('+')))\r\n\r\nmat.sort()\r\n\r\nfor i in range(len(mat)):\r\n if i == len(mat) - 1:\r\n print(mat[i])\r\n else:\r\n print(str(mat[i]), end=\"+\")", "x=list(map(int,input().split('+')))\r\nx.sort()\r\nif len(x)==1:\r\n print(x[0])\r\nelse:\r\n for i in range(len(x)-1):\r\n print(x[i],end=\"\")\r\n print('+',end=\"\")\r\n print(x[len(x)-1])", "s = input()\n\nans =''\n\nfor i in s:\n if i !=\"+\":\n ans +=i\n\nans = \"+\".join(sorted(ans))\nprint(ans)\n \t\t \t \t \t \t\t\t\t \t\t \t\t \t", "str = input()\r\nstr=str.replace(\"+\",\"\")\r\nstr = '+'.join(sorted(str))\r\nprint(str)", "sums = input()\nnums = []\ni = 0\nwhile i < len(sums):\n if sums[i] != \"+\":\n nums.append(int(sums[i]))\n i += 1\nnums.sort()\nans = \"\"\nfor i in nums:\n ans += str(i)\n ans += \"+\"\nprint(ans[:-1])\n", "x = str(input())\r\narr = []\r\nfor i in range(len(x)):\r\n if x[i]!=\"+\":\r\n arr.append(int(x[i]))\r\narr.sort()\r\nfor i in range(0,len(arr)):\r\n if i==len(arr)-1:\r\n print(arr[i],end='') \r\n else:\r\n print(str(arr[i])+str(\"+\"),end='')\r\n \r\n ", "sum = input().split(\"+\")\nsum.sort()\nsum = \"+\".join(sum)\nprint(sum)\n\n \t \t \t \t \t\t\t\t \t\t\t\t \t\t\t \t\t\t", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sat Sep 30 12:27:36 2023\r\n\r\n@author: 陈亚偲2300011106\r\n\"\"\"\r\nsum1=[int(i) for i in input().split('+')]\r\nsum1.sort()\r\na=len(sum1)\r\nsum2=str(sum1[0])\r\nfor i in range(1,a):\r\n sum2=sum2 + '+' + str(sum1[i])\r\nprint(sum2)\r\n", "lstInt = [int(i) for i in input().split(\"+\")]\r\nlstInt.sort()\r\n\r\nif(len(lstInt) > 1):\r\n ans = \"\"\r\n for no in lstInt:\r\n ans += str(no)+\"+\"\r\n print(ans[0:len(ans)-1])\r\nelse:\r\n print(lstInt[0])\r\n # //bye\r\n", "def operands(problem):\r\n nop = list(problem.replace('+', ''))\r\n nop.sort()\r\n \r\n easy = '+'.join(nop)\r\n return (easy)\r\n\r\nprob = input()\r\n\r\nprint (operands(prob))", "s=input()\r\ns1=[]\r\ns2=[]\r\nfor i in range(len(s)):\r\n if s[i]!='+':\r\n s1.append(s[i])\r\nfor i in range(len(s1)):\r\n key=s1[i]\r\n j=i-1\r\n while j>=0 and key<s1[j]:\r\n s1[j+1]=s1[j]\r\n j-=1\r\n s1[j+1]=key\r\nfor i in range(len(s1)):\r\n s2.append(s1[i])\r\n s2.append('+')\r\ns2.pop(-1)\r\nfor i in s2:\r\n print(i,end=\"\")", "a = input().split('+')\n\nordered = []\n\nfor i in range(len(a)):\n ordered.append(int(a[i]))\n\nordered.sort()\n\ns = ''\nfor i in range(len(ordered)):\n s+=str(ordered[i])\n if not(i==len(ordered)-1):\n s+='+'\n\nprint(s)\n \n\n \t \t \t \t \t \t\t\t \t\t\t \t\t\t\t\t", "input1=input()\r\nstr1=input1.split(\"+\")\r\nstr1=sorted(str1)\r\nplus=\"+\"\r\nresult=plus.join(map(str,str1))\r\nprint(result)", "a=input()\nj=0\nlength=len(a)\nx=0\nwhile x < length:\n while j<length:\n i=2+j\n while i < length :\n if a[j]>a[i]:\n temp=a[j]\n temp1=a[i]\n a=a[:j]+temp1+a[j+1:]\n a=a[:i]+temp+a[i+1:]\n i+=2\n j+=2\n x+=1\nprint(a)\n\n", "sum = input()\r\nsum = sum.split(\"+\")\r\nsum = sorted(sum)\r\nsum = \"+\".join(sum)\r\nprint(sum)", "my_array = input().split('+')\r\n\r\n\r\nfor i in range(len(my_array)):\r\n for j in range(i+1,len(my_array)):\r\n if int(my_array[i])> int(my_array[j]):\r\n temp = my_array[i]\r\n my_array[i] = my_array[j]\r\n my_array[j] = temp\r\nprint('+'.join(my_array))", "x = list(map(int, input().split('+')))\r\nx.sort()\r\nprint('+'.join(map(str, x)))", "s = input()\r\ncount_1 = s.count('1')\r\ncount_2 = s.count('2')\r\ncount_3 = s.count('3')\r\nsorted_digits = [str(i) for i in [1, 2, 3] for _ in range(eval(f'count_{i}'))]\r\nrearranged_sum = '+'.join(sorted_digits)\r\nprint(rearranged_sum)", "a=list(map(int, input().split('+')))\r\na.sort()\r\nprint(*a,sep='+')", "math = input()\r\nb = []\r\na = math.split(\"+\")\r\nfor i in range(0, len(a)):\r\n if int(a[i]) == 1:\r\n b.append(1)\r\n elif int(a[i]) == 2:\r\n b.append(2)\r\n else:\r\n b.append(3)\r\nb.sort()\r\nd = \"\"\r\nfor i in range(len(b)):\r\n if i != len(b)-1:\r\n d += f\"{b[i]}\" + \"+\"\r\n else:\r\n d += f\"{b[i]}\"\r\n\r\nprint(d)\r\n\r\n", "start = sorted(str(input()).split(\"+\"))\r\nfinal = str()\r\nfor i in start:\r\n final += str(i) + \"+\"\r\nprint(final[:-1])\r\n\r\n", "s=input()\r\nli=[]\r\nfor i in range(0,len(s),2):\r\n li.append(int(s[i]))\r\nli.sort()\r\nstring=\"\"\r\nfor i in li:\r\n string+=str(i)\r\n string+=\"+\"\r\n\r\nprint(string[0:len(string)-1])", "\r\nstatment = input()\r\n\r\nif len(statment) < 2:\r\n print(statment)\r\nelse :\r\n nums = statment.split(\"+\")\r\n int_nums = []\r\n for i in nums:\r\n int_nums.append(int(i))\r\n\r\n for i in range(len(int_nums)):\r\n temp = 0\r\n for j in range(len(int_nums) - 1):\r\n if int_nums[j] > int_nums[j + 1]:\r\n temp = int_nums[j]\r\n int_nums[j] = int_nums[j + 1]\r\n int_nums[j + 1] = temp\r\n\r\n result = \"\"\r\n for i in range(len(int_nums)):\r\n if i != len(int_nums) - 1:\r\n result += str(int_nums[i]) + \"+\"\r\n else :\r\n result += str(int_nums[i])\r\n\r\n print(result)\r\n", "x = input().split(\"+\")\r\nx.sort()\r\nn = \"\"\r\nfor i in x:\r\n n = n+i+\"+\"\r\nprint(n[0:-1])", "s = input().split(\"+\")\r\ns.sort()\r\nresult = \"\"\r\n\r\nfor i in s:\r\n result = result + i + \"+\"\r\n\r\nprint(result[:-1])\r\n\r\n", "s = input()\r\na = list(map(int, s.split('+')))\r\na.sort()\r\nprint('+'.join(map(str, a)))\r\n", "import sys\n\ninput = sys.stdin.readline\n\nstring = input()\nnew_string = string[:-1:2]\n\nnew_list = list(new_string)\nnew_list.sort()\n\nresult = \"+\".join(new_list)\nsys.stdout.write(f\"{result}\")\n", "s = input().replace('+', '')\r\nk = [int(g) for g in s]\r\nk.sort()\r\nif len(k) <= 100:\r\n j = '+'.join([str(h) for h in k])\r\n b =j.replace(',', '+')\r\n print(b)", "a = list(map(int, input().split(\"+\")))\r\n\r\na.sort()\r\nfor v in range(len(a)):\r\n print(a[v], end='')\r\n if v != len(a) - 1:\r\n print(\"+\", end='')\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sat Sep 30 11:31:03 2023\r\n\r\n@author: 20311\r\n\"\"\"\r\n\r\norder=list(map(str,input().split('+')))\r\norder.sort()\r\n \r\nprint('+'.join(order))", "s=input()\r\nl=[]\r\nfor i in s:\r\n if i.isdigit():\r\n l.append(i)\r\nl.sort()\r\nprint('+'.join(l))", "broj = input()\n\nlista = broj.split(\"+\")\n\nlistaintova=[]\nfor el in lista:\n listaintova.append(int(el))\n\n\n\nlistaintova.sort()\n\ng = len(listaintova)\ng-=1\nfor i in range(len(listaintova)):\n if i == g:\n print(f\"{listaintova[i]}\")\n break \n print(f\"{listaintova[i]}+\",end=\"\")\n ", "problem = input()\r\nsorted_problem = sorted(problem.split(\"+\"))\r\n\r\na = \"+\".join(sorted_problem)\r\nprint(a)\r\n", "#removes plus signs then orders numbers in ascending order\r\nnumbers = input().split('+')\r\nnumbers.sort()\r\n\r\n#adds each number with a plus sign, then ticks up until the last number is printed without the sign.\r\nsummation = \" \"\r\ntick = 0\r\nfor number in numbers:\r\n if tick == (len(numbers)-1):\r\n summation += f'{number}'\r\n tick += 1\r\n else:\r\n summation += f'{number}+'\r\n tick += 1\r\n \r\n#prints final output\r\nprint(summation)", "l = list(map(int, input().split('+')))\nl.sort();\nans = ''\nfor i in range(len(l)):\n if len(l) - 1 == i:\n ans += str(l[i])\n else:\n ans += str(l[i]) + '+'\n\nprint(ans)", "word = input()\r\nnos = []\r\nfor each in word:\r\n if each != \"+\":\r\n nos.append(int(each))\r\n \r\nnos.sort()\r\n \r\nans = \"\"\r\nfor no in nos:\r\n ans += str(no)+\"+\"\r\n \r\nprint(ans[:-1])", "m=input()\r\nl=m.split('+')\r\nl.sort()\r\nm=''\r\nfor x in l:\r\n m+=f'{x}'\r\nprint('+'.join(m))", "inSum = input().split(\"+\")\r\ninSum = sorted(inSum)\r\noutSum = \"+\".join(inSum)\r\nprint(outSum)", "a = input().split(\"+\")\r\na.sort()\r\nc = \"\"\r\nfor i in a:\r\n c =c+\"+\"+ i \r\nprint(c[1:])", "def InsertionSort(a, n):\r\n for i in range(1, n):\r\n x = a[i]\r\n j = i - 1\r\n while j >= 0 and a[j] > x:\r\n a[j+1] = a[j]\r\n j -= 1\r\n a[j+1] = x\r\n\r\ns = input()\r\na = []\r\nfor ch in s:\r\n if ch >= '0' and ch <= '9':\r\n a.append(ord(ch) - ord('0'))\r\n\r\nk = len(a)\r\nInsertionSort(a, k)\r\nfor i in range(k):\r\n print(a[i], end='')\r\n if i != k-1: print('+', end='')", "n=list(input())\nnum=[]\nfor i in range(len(n)):\n if n[i]!=\"+\":\n num.append(int(n[i]))\nnum.sort()\nans=''\nfor i in range(len(num)-1):\n ans+=str(num[i])+'+'\nans+=str(num[len(num)-1])\nprint(ans)", "s=input()\nl=s.split(\"+\")\nl.sort()\ns=\"\"\nstr2=\"\"\nfor i in l:\n str1=i+\"+\"\n str2+=str1\nstr2=str2[:-1]\nprint(str2)\n\n", "s=str(input())\r\nl=[]\r\nfor i in range(len(s)):\r\n if(i%2==0):\r\n l.append(s[i])\r\n\r\nfor i in range(len(l)-1):\r\n for j in range(len(l)-1):\r\n if(l[j]>l[j+1]):\r\n l[j],l[j+1] = l[j+1],l[j]\r\n\r\na = ''\r\nfor i in range(len(l)):\r\n a += l[i]+\"+\"\r\nprint(a[:-1: 1])", "numbers = list(map(int,input().split(\"+\")))\r\nnumbers.sort()\r\nans = str(\"\")\r\nfor i in range(len(numbers)):\r\n ans += str(numbers[i]) + str(\"+\")\r\nprint(ans[:-1])", "str1 = input()\r\nL = sorted(str1.split(\"+\"))\r\nprint('+'.join(L))\r\n", "s = input().split(\"+\")\r\n\r\n# 对列表进行排序\r\ns.sort()\r\n\r\n# 将排序后的列表转换回字符串\r\nresult = \"+\".join(s)\r\n\r\n# 输出结果\r\nprint(result)", "s = input(\"\").split(\"+\")\r\n\r\nfor x in range(len(s)):\r\n for y in range(1,len(s)):\r\n if int(s[y-1]) > int(s[y]):\r\n s[y-1],s[y] = s[y],s[y-1]\r\nprint(\"+\".join(s))", "a = sorted(list(map(str,input().split(\"+\"))))\r\nprint(\"+\".join(a))", "numbers=input().split(\"+\")\r\n\r\nnumbers.sort()\r\n\r\noutput= \"\"\r\n\r\nfor number in numbers:\r\n output= output + number + \"+\"\r\nprint(output[:-1])", "my_string = input().split('+')\r\nmy_string.sort()\r\noutput = \"\"\r\nfor index in my_string :\r\n output = output + f\"{index}\" + '+'\r\nprint(output[0:-1])\r\n", "res = ''\r\nl = input().split('+')\r\nl.sort()\r\nfor c in l:\r\n res += c + '+'\r\nres = res.rstrip('+')\r\nprint(res)", "s = input()\r\na = s.split('+')\r\na.sort()\r\ns = '+'.join(a)\r\nprint(s)", "string = input()\noutput_string = str()\nlist1 = string.split('+')\nlist2 = sorted(list1)\nfor item in list2 :\n output_string += item + '+'\nprint(output_string.strip('+'))\n\t \t\t\t\t \t \t \t\t\t\t\t \t \t \t\t\t", "a=list(input())\r\nb=a[::2]\r\nb.sort()\r\nn=b[0]\r\nfor i in b[1:]:\r\n n += '+'+i\r\n \r\nprint(n)\r\n", "a = list(map(str,input().split(\"+\")))\r\na.sort()\r\n\r\nif len(a) == 1:\r\n print(\"\".join(a))\r\nelse:\r\n b = \"+\".join(a)\r\n print(b)\r\n ", "from sys import stdin, stdout\r\nfrom bisect import bisect_left, bisect_right\r\nfrom collections import Counter, deque\r\nfrom queue import Queue\r\nimport heapq\r\nimport math\r\nfrom itertools import permutations, combinations, islice\r\n\r\ns = stdin.readline().strip()\r\n\r\nn = []\r\nfor i in range(len(s)):\r\n if s[i] != \"+\": n.append(s[i]) \r\n\r\nheapq.heapify(n)\r\n\r\nwhile n:\r\n stdout.write(f\"{heapq.heappop(n)}\")\r\n if n:\r\n stdout.write(\"+\")", "# November 6, 2023\r\n# Task's Link – https://codeforces.com/problemset/problem/339/A\r\n\r\nstring = input().split('+')\r\nans = \"+\".join( sorted(string) )\r\nprint(ans)\r\n", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[7]:\n\n\nn=input()\ns=[int(i) for i in n.split(\"+\")]\ns.sort()\np=\"+\".join([str(i) for i in s])\nprint(p)\n \n \n \n\n\n# In[ ]:\n\n\n\n\n\n# In[ ]:\n\n\n\n \n\n", "# Read input\ns = input().strip()\n\n# Split the input string into individual numbers\nnumbers = list(map(int, s.split('+')))\n\n# Sort the numbers in non-decreasing order\nnumbers.sort()\n\n# Join the sorted numbers with '+' signs\nnew_sum = '+'.join(map(str, numbers))\n\n# Print the new sum\nprint(new_sum)\n", "s = input()\r\n \r\nnumbers = s.split('+')\r\n\r\nnumbers.sort()\r\n\r\nnew_sum = '+'.join(numbers)\r\n\r\nprint(new_sum) \r\n\r\n\r\n", "s=(input(\"\").split(\"+\"))\r\ns.sort()\r\ns=\"+\".join(s)\r\nprint(s)\r\n", "l = list(map(int,input().split(\"+\")))\r\n\r\nl.sort()\r\n\r\na=\"\"\r\n\r\nfor i in l:\r\n\ta=a+str(i)\r\n\ta=a+\"+\"\r\n\r\nn=len(a)\r\n\r\nprint(a[0:n-1])", "import sys\r\n\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 return input().strip()\r\n\r\n\r\ndef out(x):\r\n sys.stdout.write(str(x) + \"\\n\")\r\n\r\n\r\n\r\ndef main():\r\n input_statement = insr()\r\n numbers = input_statement.split('+')\r\n numbers.sort()\r\n out(\"+\".join(numbers))\r\n \r\n \r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "s = list(map(int, input().split('+')))\r\nprint('+'.join(map(str,sorted(s))))\r\n", "s = input().split(\"+\")\r\ns = sorted(s)\r\nprint(\"+\".join(s))", "sr=input()\r\nl1=[int(x) for x in sr.split('+')]\r\nl1.sort()\r\ns=''\r\nfor i in range(len(l1)):\r\n if i==len(l1)-1:\r\n s=s+str(l1[i])\r\n else:\r\n s=s+str(l1[i])+'+'\r\nprint(s)", "b=input().split('+')\r\nc=''\r\nb.sort()\r\nfor i in range(0,len(b)*2,2):\r\n b.insert(i,'+')\r\nfor i in range(0,len(b)):\r\n c+=str(b[i])\r\nb = c.replace('+','',1)\r\nprint(b)", "l=list(map(int,input().split('+')))\r\nl=sorted(l)\r\nl=[str(i) for i in l]\r\nc='+'\r\nprint(c.join(l))", "a=input()\r\ns=[]\r\ncnt=0\r\nfor i in range(len(a)):\r\n if i%2==0:\r\n s.append(int(a[i]))\r\n cnt+=1\r\ns.sort()\r\nfor i in range(cnt):\r\n print(s[i],end=\"\")\r\n if i!=cnt-1:\r\n print(\"+\",end=\"\")", "# Read the input sum string\r\ns = input().strip()\r\n\r\n# Extract the numbers from the string\r\nnumbers = list(map(int, s.split('+')))\r\n\r\n# Sort the numbers in non-decreasing order\r\nnumbers.sort()\r\n\r\n# Construct the new sum string\r\nnew_sum = '+'.join(map(str, numbers))\r\n\r\n# Print the new sum\r\nprint(new_sum)\r\n", "s = list(input().split('+'))\r\n\r\nn = sorted(s)\r\ntotal = ''\r\n\r\nfor i in n:\r\n\r\n\r\n i = str(i)\r\n total += i+'+'\r\n\r\n\r\n\r\nprint(total[:-1])\r\n\r\n\r\n\r\n\r\n", "\r\ns = input() \r\ns=s.split(\"+\")\r\nnumbers = sorted(s)\r\n\r\n#连接成新的算式\r\nnew_sum = \"+\".join(map(str, numbers))\r\n\r\nprint(new_sum)", "s = [int(x) for x in input().split(\"+\")]\r\ns.sort()\r\nl = []\r\nfor i in s:\r\n l.append(str(i)+\"+\")\r\nl[len(l)-1]=l[len(l)-1][:-1]\r\nfor j in l:\r\n print(j,end='')", "summa = input().split(\"+\")\r\nsumma.sort()\r\nprint(\"+\".join(summa))", "inp = list(map(int, input().split(\"+\")))\r\ninp.sort()\r\nans=\"\"\r\nfor i in range(len(inp)):\r\n if i== len(inp)-1:\r\n ans=ans+str(inp[i])\r\n else:\r\n ans=ans+str(inp[i])+\"+\"\r\n \r\n\r\nprint(ans)", "ch = input()\r\na = ch.count(\"1\")\r\nb = ch.count(\"2\")\r\nc = ch.count(\"3\")\r\n\r\nch1 = \"1+\" * a + \"2+\" * b + \"3+\" * c\r\nch1 = ch1[:-1] \r\nprint(ch1)", "sum = input()\nnumbers = list(map(int, sum.split('+')))\nnumbers.sort()\nprint('+'.join(map(str, numbers)))", "s=input()\r\nA=\"\"\r\nB=\"\"\r\nC=\"\"\r\nS=\"\"\r\nfor i in s:\r\n if i==\"1\":\r\n A=\"1+\"+A\r\n if i==\"3\":\r\n B=B+\"+3\"\r\n if i==\"2\":\r\n C=\"+2\"+C\r\nif C==\"\" :\r\n B=B[1:]\r\nif C==\"\" and B==\"\" :\r\n A=A[:len(A)-1]\r\n\r\nC=C[1:]\r\nS=A+C+B\r\nprint(S)\r\n", "s=input()\r\nl=[]\r\nfor i in s:\r\n if i.isnumeric():\r\n l.append(int(i))\r\nl.sort()\r\nt=''\r\nt+=str(l[0])\r\nfor i in range(1,len(l)):\r\n t=t+\"+\"+str(l[i])\r\nprint(t)", "s = input() \r\nnumbers = []\r\nresult = \"\"\r\nfor char in s:\r\n if char.isdigit():\r\n numbers.append(char)\r\nnumbers.sort()\r\nresult = \"+\".join(numbers)\r\nprint(result) ", "number_sum = input().split(\"+\")\r\nnumber_sum.sort()\r\nsymbol = \"+\"\r\nprint(symbol.join(number_sum))", "math=input()\r\nezm=('')\r\nloose=math.split('+')\r\nfor i in range(1,4):\r\n for j in range(len(loose)):\r\n if loose[j]==str(i):\r\n ezm+=str(i)+'+'\r\nprint(ezm[:-1:])", "s = input().strip().split('+')\r\nn = [int(num) for num in s]\r\nn.sort()\r\nnew_sum = '+'.join(map(str,n))\r\nprint(new_sum)", "n=input()\r\nh=['0','1','2','3','4','5','6','7','8','9']\r\ng=[]\r\nx=\"\"\r\nfor i in n:\r\n if i in h:\r\n x += i\r\n else:\r\n g.append(int(x))\r\n x=\"\"\r\ng.append(int(x))\r\ng.sort()\r\nans = \"\"\r\nfor i in g:\r\n ans += str(i)+\"+\"\r\nans = ans[:-1]\r\nprint(ans)", "s = (input(\"\")).split('+')\r\ns.sort()\r\nprint(\"+\".join(s))\r\n", "s = input()\r\nnumbers = sorted(map(int, s.split('+')))\r\nsorted_s = '+'.join(map(str, numbers))\r\nprint(sorted_s)", "print(*sorted(input().split('+')),sep='+')", "print('+'.join([str(i) for i in sorted([int(i) for i in input().split('+')])]))", "x = list(map(int, input().split(\"+\")))\r\nx = sorted(x)\r\nlenght = len(x)\r\n\r\nfor i in range(lenght):\r\n if i+1 == lenght:\r\n print(x[i])\r\n else:\r\n print(f\"{x[i]}+\", end=\"\")", "a = input().split(\"+\")\r\n\r\nprint(\"+\".join(sorted(a)))", "string = str(input())\r\n\r\nstring_list = string.split('+')\r\n\r\nfor i in range(len(string_list)):\r\n string_list[i] = int(string_list[i])\r\n \r\nstring_list.sort()\r\n\r\nprint(str(string_list).replace(', ', '+').replace('[','').replace(']',''))", "s=input().split('+')\r\ns.sort()\r\nstring=\"\"\r\nfor i in s:\r\n string+=i+\"+\"\r\nprint(string[:-1]) ", "list_1 = input().split('+'); list_1.sort()\r\nprint(\"+\".join(list_1))", "a = input()\r\nson = [int(a[i]) for i in range(0, len(a), 2)]\r\nson.sort()\r\nprint(*son, sep='+')", "s = input()\r\ncnt1 = 0\r\ncnt2 = 0\r\ncnt3 = 0\r\nfor i in range(0, len(s), 2):\r\n if s[i] == '1':\r\n cnt1 += 1\r\n elif s[i] == '2':\r\n cnt2 += 1\r\n else:\r\n cnt3 += 1\r\nans = '1+' * cnt1 + '2+' * cnt2 + '3+' * cnt3\r\nprint(ans[:-1])", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Sep 25 16:38:46 2023\r\n\r\n@author: zinc 2300012115\r\n\"\"\"\r\n\r\ns = [int(x) for x in input().split('+')]\r\ns.sort()\r\nprint('+'.join(str(x) for x in s))", "a=list(map(int,input().split('+')))\na.sort()\nn=len(a)\nfor i in range(n-1):\n print(a[i],end='+')\nprint(a[n-1])", "string= input()\r\nlist = string.split(\"+\")\r\n\r\nlist.sort() # modifies the original list list = list.sort()\r\n\r\noutput = \"+\".join(list)\r\n\r\nprint(output)", "s = input()\r\narr =[]\r\ncount=0\r\nfor i in range(len(s)):\r\n if i%2==0:\r\n arr.append(int(s[i]))\r\n count+=1\r\nfor m in range(1,count+1):\r\n for n in range(0,count-m):\r\n if (arr[n] > arr[n + 1]):\r\n temp = arr[n];\r\n arr[n] = arr[n + 1];\r\n arr[n + 1] = temp;\r\nst=[]\r\nfor i in range(len(arr)):\r\n st.append(arr[i])\r\n if len(st) == len(s):\r\n break\r\n else:\r\n st.append(\"+\")\r\nfor i in st:\r\n print(i,end=\"\")\r\n ", "from typing import List\n\nnumbers = list(map(int, input().split(\"+\")))\n\n\ndef merge_sort(numbers: List[int]) -> List[int]:\n if len(numbers) <= 1:\n return numbers\n middle = len(numbers) // 2\n left = numbers[:middle]\n right = numbers[middle:]\n left = merge_sort(left)\n right = merge_sort(right)\n i = j = k = 0\n while i < len(left) and j < len(right):\n if left[i] <= right[j]:\n numbers[k] = left[i]\n i += 1\n else:\n numbers[k] = right[j]\n j += 1\n k += 1\n while i < len(left):\n numbers[k] = left[i]\n i += 1\n k += 1\n while j < len(right):\n numbers[k] = right[j]\n j += 1\n k += 1\n return numbers\nsorted_numbers = merge_sort(numbers)\n\n# Join the sorted numbers with '+' and print as a single string.\nresult_str = '+'.join(map(str, sorted_numbers))\nprint(result_str)", "add = list(input())\r\nadd_output = []\r\nfor i in range(len(add)):\r\n if ord(add[i]) in range(48,58):\r\n add_output.append(add[i])\r\nprint('+'.join(sorted(add_output)))\r\n", "s = [int(n) for n in input().split('+')]\r\ns.sort()\r\nprint('+'.join(str(i) for i in s))", "nums = input().split('+')\nnums.sort() \nstr =\"\"\nfor i in range(len(nums)):\n if i != len(nums)-1:\n str += nums[i]+'+'\n else:\n str += nums[i]\nprint(str) ", "s=input()\r\nl=s.split('+')\r\nl.sort()\r\nif len(l)==1:\r\n print(s)\r\nelse:\r\n s='+'.join(l)\r\n print(s)", "numbers = input().split(\"+\")\r\nnumbers.sort()\r\noutput = \"\"\r\n\r\nfor number in numbers:\r\n output = output + number + \"+\"\r\n \r\nprint(output[:-1]) \r\n", "one = list(map(int, input().split(\"+\")))\r\none.sort()\r\nfull_data = ''\r\nfor index, i in enumerate(one):\r\n if index == 0:\r\n full_data += ''.join(str(i))\r\n else:\r\n full_data += '+' + ''.join(str(i))\r\nprint(full_data)", "s1=list(input())\r\ns2=s1[0::2]\r\ns3=sorted(s2)\r\n\r\nprint(\"+\".join(s3))\r\n \r\n \r\n ", "operator=list(input())\r\noutput=\"\"\r\nX=int((len(operator)-1)/2)\r\nfor i in range(X):\r\n operator.remove('+')\r\noperator.sort()\r\nfor i in range(len(operator)-1):\r\n output+=operator[i]+\"+\"\r\noutput+=operator[-1]\r\nprint(output)\r\n ", "nums = sorted(list(map(int, input().split('+'))))\nres = \"\"\nfor num in nums:\n res += f\"{num}+\"\nprint(res[:-1])\n", "print(\"+\".join(map(str , sorted(map(int , input().split(\"+\"))))))", "listNum = list(input().split('+'))\r\nlistNum.sort()\r\nresult = listNum[0]\r\nfor i in range(1,len(listNum)):\r\n result += f\"+{listNum[i]}\"\r\nprint(result)", "string = input()\r\nm1 = m2 = m3 = 0\r\nfor i in range(0, len(string), 2):\r\n if string[i] == '1':\r\n m1 += 1\r\n elif string[i] == '2':\r\n m2 += 1\r\n else:\r\n m3 += 1\r\ns = \"1+\" * m1 + \"2+\" * m2 + \"3+\" * m3\r\nprint(s[:-1])", "s = input()\r\nlst = []\r\nfor i in s:\r\n if(i!=\"+\"):\r\n lst.append(i)\r\nlst.sort()\r\no = \"\"\r\nfor i in range(len(lst)-1):\r\n o = o + str(lst[i]) + \"+\"\r\no = o + str(lst[len(lst)-1])\r\nprint(o)", "s=input()\r\ns1=[]\r\nfor i in s:\r\n if i!='+':\r\n s1.append(i)\r\ns1.sort()\r\n#print(s1)\r\ns2=[]\r\nl=len(s1)\r\nfor i in range(0,l):\r\n if i!=l-1:\r\n s2.append(s1[i])\r\n s2.append('+')\r\n else:\r\n s2.append(s1[i])\r\nans=''.join(s2)\r\nprint(ans)", "s,l= input(),[]\r\nfor i in range(0,len(s),2): l.append(s[i])\r\nl.sort()\r\nprint(l[0],end=\"\")\r\nfor e in l[1:]: print(f\"+{e}\" , end=\"\")", "s = input().split(\"+\") # Split the string into numbers and \"+\" signs\r\nnumbers = [int(x) for x in s] # Convert numbers to integers\r\nnumbers.sort() # Sort numbers in non-decreasing order\r\nresult = \"+\".join(map(str, numbers)) # Join numbers into a string with \"+\" signs\r\n\r\nprint(result)", "s=str(input())\r\nls=[]\r\nfor i in range(len(s)):\r\n\tif s[i].isnumeric():\r\n\t\tls.append(int(s[i]))\r\n\r\nls.sort()\r\nans=\"\"\r\nfor i in range(len(ls)):\r\n\tif i!=len(ls)-1:\r\n\t\tans+=str(ls[i])\r\n\t\tans+=\"+\"\r\n\telse:\r\n\t\tans+=str(ls[i])\r\nprint(ans)", "a = [x for x in input().split('+')]\r\na.sort()\r\nprint('+'.join(a))", "list1=list(map(int,input().split('+')))\r\nlist1.sort()\r\nprint(list1[0],end='')\r\nfor i in list1[1:]:\r\n print(end='+'+str(i))", "# Read the input sum as a string\r\ns = input()\r\n\r\n# Split the input sum by '+', convert the parts to integers, and sort them\r\nsummands = sorted(map(int, s.split('+')))\r\n\r\n# Create the new sum as a string by joining the sorted summands with '+'\r\nnew_sum = '+'.join(map(str, summands))\r\n\r\n# Print the new sum\r\nprint(new_sum)\r\n" ]
{"inputs": ["3+2+1", "1+1+3+1+3", "2", "2+2+1+1+3", "2+1+2+2+2+3+1+3+1+2", "1+2+1+2+2+2+2+1+3+3", "2+3+3+1+2+2+2+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1", "1", "2+1+2+2+1+3+2+3+1+1+2+1+2+2+3+1+1+3+3+3+2+2+3+2+2+2+1+2+1+2+3+2+2+2+1+3+1+3+3+3+1+2+1+2+2+2+2+3+1+1", "2+2+1+1+1+3+1+1+3+3+2+3+1+3+1+1+3+1+1+2+2+2+2+1+2+1+2+1+1+1+3+1+3+2+3+2+3+3+1+1+1+2+3+2+1+3+1+3+2+2", "3+2+3+3+2+2+1+2+1+2+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+2+2+2+2+3+3+2+2+3+3+1+1+2+3+3+2+3+3+3", "3", "1+1", "1+2", "1+3", "2+1", "2+2", "2+3", "3+1", "3+2", "3+3"], "outputs": ["1+2+3", "1+1+1+3+3", "2", "1+1+2+2+3", "1+1+1+2+2+2+2+2+3+3", "1+1+1+2+2+2+2+2+3+3", "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3", "1", "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3", "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3", "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3", "3", "1+1", "1+2", "1+3", "1+2", "2+2", "2+3", "1+3", "2+3", "3+3"]}
UNKNOWN
PYTHON3
CODEFORCES
952
e57fcb4b4002133ee853323ff082131c
Tablecity
There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves. Tablecity can be represented as 1000<=×<=2 grid, where every cell represents one district. Each district has its own unique name “(*X*,<=*Y*)”, where *X* and *Y* are the coordinates of the district in the grid. The thief’s movement is as Every hour the thief will leave the district (*X*,<=*Y*) he is currently hiding in, and move to one of the districts: (*X*<=-<=1,<=*Y*), (*X*<=+<=1,<=*Y*), (*X*<=-<=1,<=*Y*<=-<=1), (*X*<=-<=1,<=*Y*<=+<=1), (*X*<=+<=1,<=*Y*<=-<=1), (*X*<=+<=1,<=*Y*<=+<=1) as long as it exists in Tablecity. Below is an example of thief’s possible movements if he is located in district (7,1): Albert has enough people so that every hour he can pick any two districts in Tablecity and fully investigate them, making sure that if the thief is located in one of them, he will get caught. Albert promised the President that the thief will be caught in no more than 2015 hours and needs your help in order to achieve that. There is no input for this problem. The first line of output contains integer *N* – duration of police search in hours. Each of the following *N* lines contains exactly 4 integers *X**i*1, *Y**i*1, *X**i*2, *Y**i*2 separated by spaces, that represent 2 districts (*X**i*1, *Y**i*1), (*X**i*2, *Y**i*2) which got investigated during i-th hour. Output is given in chronological order (i-th line contains districts investigated during i-th hour) and should guarantee that the thief is caught in no more than 2015 hours, regardless of thief’s initial position and movement. - *N*<=≤<=2015 - 1<=≤<=*X*<=≤<=1000 - 1<=≤<=*Y*<=≤<=2 Sample Input В этой задаче нет примеров ввода-вывода. This problem doesn't have sample input and output. Sample Output Смотрите замечание ниже. See the note below.
[ "print(1999)\r\nfor i in range(1, 1001):\r\n print(i, 1, i, 2)\r\np = 1000\r\nwhile p != 1:\r\n print(p, 1, p, 2)\r\n p-=1", "N = 1000\r\nprint(2 * N)\r\nfor i in range(1, N + 1):\r\n print(i, 1, i, 2)\r\nfor i in range(N, 0, -1):\r\n print(i, 1, i, 2)", "print(2000)\r\n\r\nfor i in range(1, 1001):\r\n print(i, 1, i, 2)\r\n \r\nfor i in range(1000, 0, -1):\r\n print(i, 1, i, 2)", "print(2000)\r\nfor j in range(1000):\r\n print(j+1,1,j+1,2)\r\nfor j in range(1001,1,-1):\r\n print(j-1,1,j-1,2)", "print(1999)\r\nfor i in range(1,1001):print(i,1,i,2)\r\nfor i in range(2,1001):print(i,1,i,2)", "print('2000')\r\na = 1\r\nb = 1000\r\nfor i in range(1000):\r\n print(a, 1, a, 2)\r\n a += 1\r\nfor i in range(1000):\r\n print(b, 1, b, 2)\r\n b -= 1\r\n\r\n", "print(1999)\r\nfor i in range(1, 1001):\r\n print(i, 1, i, 2)\r\nfor i in range(2, 1001):\r\n print(i, 1, i, 2)\r\n", "print(1999)\r\nfor i in range(1,1001):\r\n print(i,1,i,2)\r\nfor i in range(2,1001):\r\n print(i,1,i,2) ", "ans = []\nfor i in range(1, 1001):\n ans.append(' '.join((str(i), '1', str(i), '2')))\nans.append('1 1 1 2')\nfor i in range(1, 1001):\n ans.append(' '.join((str(i), '1', str(i), '2')))\n\nprint(len(ans))\nprint('\\n'.join(ans))\n", "print(2001)\r\nfor i in range(1000):\r\n print(i + 1, 1, i + 1, 2)\r\nprint(1, 1, 1, 2)\r\nfor i in range(1000):\r\n print(i + 1, 1, i + 1, 2)\r\n", "print(1998)\r\n\r\nfor k in range(2):\r\n for i in range(1, 1000):\r\n print(i, 1, i, 2)", "print(2000)\r\nfor i in range(1000):\r\n print(i + 1, 1, i + 1, 2)\r\nfor j in range(1000):\r\n print(1000 - j, 1, 1000 - j, 2)", "print(2000)\r\nfor i in range(1, 1001):\r\n print(i, 1, i, 2)\r\nfor i in range(1000, 0, -1):\r\n print(i, 1, i, 2)", "\r\nimport math\r\nfrom decimal import Decimal\r\nimport sys\r\n\r\ndef rek(a,b,n):\r\n \r\n if a==n and b==n:\r\n return 1\r\n if a==n:\r\n return 1+rek(a,b+1,n)\r\n if b==n:\r\n return 1+rek(a+1,b,n)\r\n return 1+rek(a+1,b,n)+rek(a,b+1,n)\r\n \r\nprint(2000)\r\nfor i in range(1,1001):\r\n print(str(i) + \" 1 \" + str(i) + \" 2\")\r\nfor i in range(1,1001):\r\n print(str(1001-i) + \" 1 \" + str(1001-i) + \" 2\")\r\n\r\n", "print(1998); f = lambda: [print(i, 1, i, 2) for i in range(1, 1000)]\r\nf(); f()", "if __name__ == '__main__':\r\n print(2001)\r\n for i in range(1000):\r\n print(str(i + 1) + ' ' + str(1) + ' ' + str(i + 1) + ' ' +str(2))\r\n print(str(1) + \" \" + str(1) + \" \" +str(1) + \" \" + str(2))\r\n for i in range(1000):\r\n print(str(i + 1) + ' ' + str(1) + ' ' + str(i + 1) + ' ' +str(2))\r\n", "N = 1000\n\nprint(2 * (N - 1))\n\nfor k in range(2):\n for i in range(1, N):\n print(i, 1, i, 2)\n", "print(1998)\r\n[print(i,1,i,2) for _ in '12' for i in range(1, 1000)]\r\n" ]
{"inputs": ["dummy"], "outputs": ["2000\n1 1 1 2\n2 1 2 2\n3 1 3 2\n4 1 4 2\n5 1 5 2\n6 1 6 2\n7 1 7 2\n8 1 8 2\n9 1 9 2\n10 1 10 2\n11 1 11 2\n12 1 12 2\n13 1 13 2\n14 1 14 2\n15 1 15 2\n16 1 16 2\n17 1 17 2\n18 1 18 2\n19 1 19 2\n20 1 20 2\n21 1 21 2\n22 1 22 2\n23 1 23 2\n24 1 24 2\n25 1 25 2\n26 1 26 2\n27 1 27 2\n28 1 28 2\n29 1 29 2\n30 1 30 2\n31 1 31 2\n32 1 32 2\n33 1 33 2\n34 1 34 2\n35 1 35 2\n36 1 36 2\n37 1 37 2\n38 1 38 2\n39 1 39 2\n40 1 40 2\n41 1 41 2\n42 1 42 2\n43 1 43 2\n44 1 44 2\n45 1 45 2\n46 1 46 2\n47 1 47 2\n48 1 4..."]}
UNKNOWN
PYTHON3
CODEFORCES
18
e58e3db9d467bc1c9e9645c70d5958ed
Double Cola
Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, drinks it and gets to the end of the queue as two Leonards, and so on. This process continues ad infinitum. For example, Penny drinks the third can of cola and the queue will look like this: Rajesh, Howard, Sheldon, Sheldon, Leonard, Leonard, Penny, Penny. Write a program that will print the name of a man who will drink the *n*-th can. Note that in the very beginning the queue looks like that: Sheldon, Leonard, Penny, Rajesh, Howard. The first person is Sheldon. The input data consist of a single integer *n* (1<=≤<=*n*<=≤<=109). It is guaranteed that the pretests check the spelling of all the five names, that is, that they contain all the five possible answers. Print the single line — the name of the person who drinks the *n*-th can of cola. The cans are numbered starting from 1. Please note that you should spell the names like this: "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" (without the quotes). In that order precisely the friends are in the queue initially. Sample Input 1 6 1802 Sample Output Sheldon Sheldon Penny
[ "n=int(input())\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nR=1\nwhile(R*5<n):\n n-=R*5\n R*=2\nprint(a[(n-1)//R])\n\t\t\t \t \t\t \t \t \t \t\t\t \t\t\t \t\t", "x = int(input())\r\n\r\nn=1\r\nlvl_arr = [0]\r\ndef LvL(n):\r\n lvl_arr.append(2**(n-1)*5 + lvl_arr[n-1])\r\n return lvl_arr[n]\r\n\r\nwhile(x > LvL(n)):\r\n n = n+1\r\n\r\np = ((x - lvl_arr[n-1] - 1) // 2**(n-1)) + 1\r\n\r\nif(p == 1):\r\n print(\"Sheldon\")\r\nelif(p == 2):\r\n print(\"Leonard\")\r\nelif(p == 3):\r\n print(\"Penny\")\r\nelif(p == 4):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "import math\r\nn=int(input())\r\nna= [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ne=(int(math.log(math.ceil(n/5),2)))\r\nlo = int(math.ceil((n - 5*(pow(2, e) - 1))/pow(2, e)))\r\nprint(na[lo-1])", "names = ['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn = 5\r\nprev = 0\r\ninp = int(input())\r\ni = 1\r\nwhile n < 10**10:\r\n\tif inp <= n:\r\n\t\tbreak\r\n\tprev = n\r\n\tn = n+5*2**i\r\n\ti += 1\r\n\t\r\nincr = (n-prev)/5\r\nresInd = 0\r\nwhile True:\r\n\tprev += incr\r\n\tif inp <= prev:\r\n\t\tbreak\r\n\tresInd += 1\r\nprint(names[resInd])", "n = int(input())\n\npeople= [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\nj = 0\nit = 1\n\nwhile(n > 0):\n n -= it\n if n <= 0:\n break\n j += 1\n if j == 5:\n j = 0\n it *= 2\n\nprint(people[j])\n", "from math import *\r\nn = int(input())\r\nk = floor(log(n/5+1, 2))\r\nr = (n-5*(2**k-1))/(2**k)\r\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][ceil(r)-1])", "from math import *\r\nu=int(input())\r\nque=[ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ni=0\r\nj=0\r\nwhile True:\r\n if j>=u:\r\n break\r\n j+=5*2**i\r\n i+=1\r\nk=5*(2**(i-1)-1)\r\nl=int((u-k)/2**(i-1)-0.0001)\r\nprint(que[l])\r\n", "n=int(input())\r\nr=1\r\nwhile(r*5<n):\r\n n-=r*5\r\n r*=2\r\ns=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(s[(n-1)//r])\r\n ", "n=int(input())-1\r\nqueue=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile n>4:\r\n n-=5\r\n n//=2\r\nprint(queue[n])", "n=int(input())\r\nwhile n>5:\r\n n = n - 4\r\n s=n%2\r\n n=(n-s)/2\r\nif n==1:\r\n\tprint('Sheldon')\r\nif n==2:\r\n\tprint('Leonard')\r\nif n==3:\r\n\tprint('Penny') \r\nif n==4:\r\n\tprint('Rajesh')\r\nif n==5:print('Howard')", "n=int(input())\r\nif n==1:\r\n print('Sheldon')\r\nelif n==2:\r\n print('Leonard')\r\nelif n==3:\r\n print('Penny')\r\nelif n==4:\r\n print('Rajesh')\r\nelif n==5:\r\n print('Howard')\r\nelse:\r\n s=5\r\n i=1\r\n while True:\r\n m=2**i\r\n if n<=s+m:\r\n print('Sheldon')\r\n break\r\n elif n<=s+m*2:\r\n print('Leonard')\r\n break\r\n elif n<=s+m*3:\r\n print('Penny')\r\n break\r\n elif n<=s+m*4:\r\n print('Rajesh')\r\n break\r\n elif n<=s+m*5:\r\n print('Howard')\r\n break\r\n s=s+5*2**i\r\n i=i+1", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Oct 19 13:52:28 2018\r\n\r\n@author: Quaint Sun\r\n\"\"\"\r\n\r\n\r\n'''\r\nn=int(input())\r\n\r\nqueue=['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\r\nt=0\r\nwhile t<n:\r\n queue.append(queue[0])\r\n queue.append(queue[0])\r\n del queue[0]\r\n t=t+1\r\n\r\nprint(queue[-1])'''\r\n\r\nn=int(input())\r\nqueue=['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\r\nnum=0\r\nfor i in range(n):\r\n if n>num:\r\n num=num+5*(2**i)\r\n else:\r\n break\r\n\r\nif n<6:\r\n print(queue[n-1])\r\nelse:\r\n numpast=num-5*(2**(i-1))\r\n name=(n-numpast)//(2**(i-1))\r\n print(queue[name])\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n=int(input())\nj=0\nwhile n>5*2**j:\n\tn=n-5*2**j\n\tj+=1\nk=1\nr=2**j\nfor l in range(1,5):\n\tif n>r*l:\n\t\tk+=1\n\nif k==1:\n\tprint(\"Sheldon\")\nelif k==2:\n\tprint(\"Leonard\")\nelif k==3:\n\tprint(\"Penny\")\nelif k==4:\n\tprint(\"Rajesh\")\nelif k==5:\n\t print(\"Howard\")\n\n\t \t \t \t \t\t \t \t \t \t\t\t\t\t\t", "import math\r\n# This is a sample Python script.\r\n\r\n# Press Shift+F10 to execute it or replace it with your code.\r\n# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.\r\n\r\n\r\nn=int(input())\r\nL=[ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nk=math.floor(math.log2(n/5+1))\r\nn-=(5*(2**k-1))\r\nans=(n-1)//((2**k))\r\nprint(L[ans])\r\n\r\n#01234 0011223344 00001111222233334444 0000000011111111222222223333333344444444\r\n\r\n#5 10 20 40 80\r\n#5 15 35 75\r\n#5( 1 2 4 8 16 )\r\n#s=1 2 4 8 16 + 2^(n-1)\r\n#2s=2 4 8 16 +2^n\r\n#s=5(2^n-1)\r\n#(2^k)<=n/5+1\r\n", "n=int(input())\ncou=1\ns = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nwhile(cou*5<n):\n n=n-(cou*5)\n cou*=2\nn=n-1\nn=n//cou\nprint(s[n])\n \t\t \t \t \t\t \t \t\t\t \t \t \t\t\t\t", "s=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\na=int(input())\r\na=a-1\r\nwhile a>=5:\r\n a=a-5\r\n a=a//2\r\nprint(s[a])", "def f(v):\n\tif v <= 5:\n\t\treturn v\n\telse:\n\t\treturn f((v - 4) // 2)\n\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][f(int(input())) - 1])\n", "i=0\r\nsum = 0\r\nn = int(input())\r\nwhile sum < n:\r\n sum += 5*(2**i)\r\n i += 1\r\nsum = sum - 5*(2**(i-1))\r\nfor j in range(5):\r\n sum = sum + 2**(i-1)\r\n if n<=sum:\r\n if j==0:\r\n print(\"Sheldon\")\r\n break\r\n elif j==1:\r\n print(\"Leonard\")\r\n break\r\n elif j==2:\r\n print(\"Penny\")\r\n break\r\n elif j==3:\r\n print(\"Rajesh\")\r\n break\r\n else:\r\n print(\"Howard\")\r\n break", "D = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn = int(input())\n\nif n < 6:\n print(D[n-1])\n exit()\n\ni = 0\nwhile (1 << i) * 5 < n:\n n -= (1 << i) * 5\n i += 1\n\nprint(D[n // (1 << i)])", "n = int(input())\r\na1 = 'Sheldon'\r\na2 = 'Leonard'\r\na3 = 'Penny'\r\na4 = 'Rajesh'\r\na5 = 'Howard'\r\nt = 0\r\nk = 0\r\np = 1\r\nf = 0\r\nwhile t - 4 <= n: \r\n p = 5 * 2 ** k\r\n k = k + 1\r\n t = p\r\n if t - 4 == n:\r\n p = t - 4\r\n break\r\n elif t - 4 > n:\r\n p = p / 2 - 4\r\n k = k - 1\r\n break\r\ncnt_a = 2 ** (k - 1)\r\nwhile n - p >= 0:\r\n f += 1\r\n p = p + cnt_a\r\nif f == 1:\r\n print(a1)\r\nelif f == 2:\r\n print(a2)\r\nelif f == 3:\r\n print(a3)\r\nelif f == 4:\r\n print(a4)\r\nelif f == 5:\r\n print(a5)", "given_position = int(input())\n\nsheldon = [1,1]\nleonard = [2,2]\npenny = [3,3]\nrajesh = [4,4]\nhoward = [5,5]\n\n#Nth-position\nn = 0\n#6th-position\nnext_element = sheldon[0] + 5*2**n\n\nwhile True:\n\n\tif sheldon[0]<=given_position<=sheldon[1]:\n\t\tprint ('Sheldon')\n\t\tbreak\n\n\tif leonard[0]<=given_position<=leonard[1]:\n\t\tprint('Leonard')\n\t\tbreak\n\n\tif penny[0]<=given_position<=penny[1]:\n\t\tprint('Penny')\n\t\tbreak\n\n\tif rajesh[0]<=given_position<=rajesh[1]:\n\t\tprint('Rajesh')\n\t\tbreak\n\n\tif howard[0]<=given_position<=howard[1]:\n\t\tprint('Howard')\n\t\tbreak\n\n\t#Sheldon\n\tprimeira_instancia = next_element\n\tultima_instancia = primeira_instancia + 2**(n+1)-1\n\tsheldon = [primeira_instancia, ultima_instancia]\n\n\t#Leonard\n\tprimeira_instancia = ultima_instancia+1\n\tultima_instancia = primeira_instancia + 2**(n+1)-1\n\tleonard = [primeira_instancia, ultima_instancia]\n\n\t#Penny\n\tprimeira_instancia = ultima_instancia+1\n\tultima_instancia = primeira_instancia + 2**(n+1)-1\n\tpenny = [primeira_instancia, ultima_instancia]\n\n\t#Rajesh\n\tprimeira_instancia = ultima_instancia+1 \n\tultima_instancia = primeira_instancia + 2**(n+1)-1\n\trajesh = [primeira_instancia, ultima_instancia]\n\n\t#Howard\n\tprimeira_instancia = ultima_instancia+1\n\tultima_instancia = primeira_instancia + 2**(n+1)-1\n\thoward = [primeira_instancia, ultima_instancia]\n\n\tnext_element = howard[1]+1\n\tn+=1\n \t \t \t\t\t\t \t \t \t\t \t \t \t\t\t \t\t", "import sys\r\nimport math\r\n#for _ in range(int(input())):\r\nn = int(input())\r\narr =[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif(n <= 5):\r\n print(arr[n-1])\r\nelse:\r\n r = int(1+math.log(n//5+1)/math.log(2))\r\n #print(r)\r\n chances = 5*(pow(2,r-1)-1)\r\n left = n - chances\r\n '''print(\"chances \" ,chances)\r\n print(\"left \",left)'''\r\n if(left == 0):\r\n print(arr[4])\r\n else:\r\n pair = pow(2,r-1)\r\n #print(\"pair : \",pair)\r\n print(arr[math.ceil(left/pair)-1])\r\n \r\n ", "n=int(input())\nn=n-1\nnames=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nwhile(n>=5):\n n=n-5\n n=n//2\nprint(names[n])\n \t\t\t\t \t\t \t \t \t\t\t \t", "n=int(input())\r\nwhile n>5:\r\n n=-((5-n)//2)\r\nprint(\"SLPRHheeaoeonjwlnneadaysror hdnd\"[n-1::5])", "import math\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\ndef iseven(n):\r\n\treturn n%2==0\r\na = n//5\r\na+=1\r\n\r\nb = math.floor(math.log2(a))\r\n\r\n\r\n\r\nif n>=5:\r\n\tn = n - 5*(2**b)+5\r\na = 2**b\r\nprint(names[math.ceil(n/a)-1])\r\n", "p=int(input())\nn=1\nli=[\"Sheldon\",\"Leonard\",\"Penny\", \"Rajesh\", \"Howard\"]\nwhile(n*5<p):\n\tp-=n*5\n\tn*=2\np=p-1\np=p//n\nprint(li[p])\n\t \t\t\t\t\t\t\t\t\t\t\t\t\t \t \t\t\t\t \t\t \t \t", "n=int(input())\r\nlist=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\ni=0\r\ns=0\r\nwhile s<n:\r\n s+=5*(2**i)\r\n i+=1\r\ns=s-5*(2**(i-1))\r\nnumber=n-s\r\nif n>5:\r\n if number%(2**(i-1))==0:\r\n index=(number//(2**(i-1)))-1\r\n else:\r\n index=number//2**(i-1)\r\n print(list[index])\r\nelse:\r\n print(list[n-1])", "def ii(): return int(input())\r\ndef fi(): return float(input())\r\ndef si(): return input()\r\ndef mi(): return map(int,input().split())\r\ndef li(): return list(mi())\r\n \r\nn=ii()\r\ns=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn-=1 \r\nwhile n>4:\r\n n=(n-5)//2\r\nprint (s[n])", "t=int(input())-1\r\nl=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nwhile t > 4:\r\n t=(t-5)//2\r\n\r\nprint(l[t])", "n = int(input())\nm = 1\nnms = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\n\nwhile (m*5) < n:\n n -= m * 5\n m *= 2\n\nprint(nms[(n-1)//m])\n", "n=int(input())\r\ns=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nfor k in range(n):\r\n gauche=5*(2**k-1)+1\r\n droit=5*(2**(k+1)-1)+1\r\n if gauche<=n and n<droit:\r\n c=(n-gauche)//(2**k)\r\n break\r\nprint(s[c])\r\n\r\n# for i in range(n-1):\r\n# temp=s[0]\r\n# s.remove(s[0])\r\n# s.append(temp)\r\n# s.append(temp)\r\n# print(s[0])\r\n", "#82A\r\n\r\nnames=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn=int(input())\r\nx=1\r\nwhile n>=x*5:\r\n n-=x*5\r\n x*=2\r\nn=n-1\r\nn=n//x\r\nprint(names[n])\r\n", "import math\na=[\"\",\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn = int(input())\norg=dig=0\nfor i in range(1,30):\n org=dig\n dig=(dig+1)*2-1\n if(5*org < n <= 5*dig):\n print(a[math.ceil((n-5*org)/pow(2,i-1))])\n", "import math\n\nnames = [\"\", \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\nn = int(input())\n\ni = 0\nsum = 0\n\nwhile(True):\n\tsum += 5*(2**i)\n\tif sum >=n:\n\t\tsum -= 5*(2**i)\n\t\tbreak\n\ti += 1\n\t\nnumPerPerson = 2**i\n\nidx = math.ceil((n-sum)/numPerPerson)\nprint(names[idx])\n \t \t\t \t \t \t\t \t \t\t \t\t\t\t", "n = \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"\nx = int(input())\nr = x\ni = 1\nwhile r > i*5:\n r = r-(i*5)\n i *= 2\nif r % i == 0:\n print(n[(r//i)-1])\nelse:\n print(n[(r//i)])\n\n\t \t\t \t \t \t\t \t \t\t\t \t \t \t\t\t \t", "\"\"\" https://codeforces.com/problemset/problem/82/A \"\"\"\r\n\r\nnames = [ 'Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard' ]\r\n\r\n\r\nn = int ( input () ) - 1\r\n\r\n\r\ndups = 0\r\nmultiplier = 1\r\np_counter = 0\r\ncounter = 5\r\nwhile ( counter <= n ):\r\n dups += 1\r\n multiplier *= 2\r\n p_counter = counter\r\n counter += multiplier * 5\r\n\r\nsteps_count = n - p_counter\r\nans = names [ int ( steps_count / 2 ** dups ) ]\r\n\r\n\r\nprint ( ans )\r\n", "def f(n):\n return n if n < 5 else f(n - 5 >> 1)\n\n\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][f(int(input()) - 1)])\n", "import math\r\na = int(input())\r\nf = 5\r\nsumm = 5\r\nc = 1\r\npre = 0\r\nwhile summ<=a:\r\n pre = summ\r\n summ += 5 * 2**c\r\n c+=1 \r\nres = math.ceil((a-pre)/((summ-pre)/5))\r\nif res == 1:\r\n print(\"Sheldon\")\r\nelif res == 2:\r\n print(\"Leonard\")\r\nelif res == 3:\r\n print(\"Penny\")\r\nelif res == 4:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "p=int(input())-1\r\nwhile p>4:\r\n p=p-5>>1\r\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][p])\r\n", "n = int(input())\r\nx = 1\r\nwhile 5 * x < n :\r\n n -= 5 * x\r\n x *= 2\r\nn = (n - 1) // x\r\nname = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(name[n])\r\n", "q = 5\r\ne = 0\r\ni = 1\r\nn = int(input())\r\n\r\nwhile e < n:\r\n e += q\r\n q = 2*q\r\n i += 1\r\n# group = i - 1\r\n# members in the group = q\r\n# doppelgangers in the group (including the person): 2**(i-2)\r\n\r\nc = n-(e-q//2)\r\n# the count starting from the last group\r\n\r\nz = 1\r\n# identifier\r\nx = 2**(i - 2)\r\n# number of duplicates\r\nv = 0\r\n# acc\r\nwhile v < c:\r\n v += x\r\n z += 1\r\n\r\n#print(z-1) \r\n\r\nif (z - 1) == 1 :\r\n print(\"Sheldon\")\r\nelif (z - 1) == 2:\r\n print(\"Leonard\")\r\nelif (z - 1) == 3:\r\n print(\"Penny\")\r\nelif (z - 1) == 4:\r\n print(\"Rajesh\")\r\nelse :\r\n print(\"Howard\")", "z=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\na=int(input())\r\nd=a//5\r\nb=list(-1+2**i for i in range(50))\r\nc=max(b[i] for i in range(50) if b[i]<=d)\r\ne=a-(c*5)\r\nprint(z[(e//(c+1))+(1 if e%(c+1)>0 else 0)-1])", "n = int(input())\r\n\r\nLT3 = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nBBT = 1\r\nwhile n > 5 * BBT:\r\n n -= 5 * BBT\r\n BBT *= 2\r\n\r\nindex = (n - 1) // BBT\r\nprint(LT3[index])", "n = int(input())\r\nw = ['Sheldon' , 'Leonard' , 'Penny' , 'Rajesh' , 'Howard']\r\nc = 1 \r\n\r\nwhile c*5 < n:\r\n n-= c*5\r\n c *= 2\r\n \r\n\r\nv = int((n-1)/c)\r\n\r\nprint(w[v])", "from collections import deque\n\n\ndef main():\n n = int(input())\n options = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n num_distinct = len(options)\n subtracted = num_distinct\n remaining = n\n\n # subtract out until the remaining portion can be used to find the quantile the object is in\n num_doublings = 0\n while remaining > subtracted:\n remaining -= subtracted\n subtracted *= 2\n num_doublings += 1\n\n # find the quantile the object is in\n num_objects = 2 ** num_doublings\n quantile = -1\n for i in range(1, num_distinct+1):\n if remaining <= i * num_objects:\n quantile = i\n break\n\n # print the quantile\n print(options[quantile-1])\n\n\nif __name__ == '__main__':\n main()\n", "import math as m\r\ndef f(n): return m.ceil((n+5)/(2**m.ceil(m.log2((n+5)/10))))-5\r\nn = f(int(input()))\r\nif n == 1: print('Sheldon')\r\nelif n == 2: print('Leonard')\r\nelif n == 3: print('Penny')\r\nelif n == 4: print('Rajesh')\r\nelif n == 5: print('Howard')\r\n", "from math import log2\r\nn=int(input())\r\ns=int(log2((n+4)/5))\r\nA=(n-5*(2**s-1))/(2**s)\r\nprint(['Sheldon','Leonard','Penny','Rajesh','Howard'][(A>1)+(A>2)+(A>3)+(A>4)])\r\n", "n = int(input())\r\n\r\nwhile(n>5):\r\n if n&1:\r\n n-=5\r\n n//=2\r\n else:\r\n n-=4\r\n n//=2\r\n\r\n\r\nif n==1:\r\n print('Sheldon')\r\nelif n==2:\r\n print('Leonard')\r\nelif n==3:\r\n print('Penny')\r\nelif n==4:\r\n print('Rajesh')\r\nelse:\r\n print('Howard')", "x = int(input())\ni = 0\na = (\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\")\nif x<=5:\n print(a[x-1])\nelse:\n while True:\n if(x>=5*(2**i)):\n x-=5*(2**i)\n i+=1\n else:\n print(a[(x-1)//(2**i)])\n break", "n = int(input())\r\na = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nwhile n>5:\r\n n=int(n/2)\r\n n =int(n-2)\r\n\r\n\r\nprint(a[n-1])", "ar =[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn = int(input())\nn -= 1\nc = 0\nnxt = 5\nh = 1\nwhile c + nxt <= n:\n c += nxt\n nxt *= 2\n h *= 2\nrem = n - c\n#print(c,rem, rem // (h))\nprint(ar[rem // (h)])\n", "names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nn = int(input())-1\r\ncurr = 1\r\nwhile n-curr*5 >= 0:\r\n n -= curr*5\r\n curr *= 2\r\n\r\nprint(names[n//curr])", "n = int(input())\r\n\r\npeople = ('Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard')\r\nkol = 1\r\n\r\nwhile kol * 5 < n:\r\n n -= kol * 5\r\n kol *= 2\r\n\r\nn -= 1\r\n\r\nprint(people[n // kol])\r\n\r\n", "import math\r\nn = int(input())\r\nk = int(math.log2((n-1)//5 + 1)) \r\n# print(k)\r\nif k != 0:\r\n number = n - 5*(2**(k) - 1)\r\n # print(number)\r\n remainder = (number-1)//(2**k)\r\n # print(remainder)\r\nelse:\r\n remainder = n-1\r\nif remainder == 0:\r\n print(\"Sheldon\")\r\nelif remainder == 1:\r\n print(\"Leonard\")\r\nelif remainder == 2:\r\n print(\"Penny\")\r\nelif remainder == 3:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "t = int(input())\r\ni = 1\r\nlst = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile(i*5<t):\r\n\tt -= (i*5)\r\n\ti *= 2\r\nprint(lst[(t-1)//i])", "\r\na = [\"Sheldon\",\"Leonard\",\"Penny\", \"Rajesh\",\"Howard\"]\r\nn = int(input())-1\r\nwhile n>=5:\r\n n-=5\r\n n = n//2\r\nprint(a[n])\r\n", "n=int(input())\r\ni=0\r\nwhile n>0:\r\n n=n-(5*(2**(i)))\r\n i+=1\r\nn=n+5*(2**(i-1))\r\n\r\nif n/(2**(i-1))<=1:\r\n print('Sheldon')\r\nif n/(2**(i-1))>1 and n/(2**(i-1))<=2:\r\n print('Leonard')\r\nif n/(2**(i-1))>2 and n/(2**(i-1))<=3:\r\n print('Penny')\r\nif n/(2**(i-1))>3 and n/(2**(i-1))<=4:\r\n print('Rajesh')\r\nif n/(2**(i-1))>4 and n/(2**(i-1))<=5:\r\n print('Howard')", "names = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\r\nn = int(input())\r\n\r\nif n <= 5: print(names[n-1])\r\nelse:\r\n s = 5\r\n p = 1\r\n while s + 5*2**p < n:\r\n s += 5*2**p\r\n p += 1\r\n \r\n n -= s\r\n\r\n print(names[(n//2**(p))%5])\r\n\r\n ", "def get_Sn(n):\r\n return 5*(2**n-1)\r\n\r\nif __name__ == '__main__':\r\n n = int(input().strip('\\n\\r\\t '))\r\n i = 0\r\n Sn = get_Sn(i)\r\n while n > Sn:\r\n i += 1\r\n Sn = get_Sn(i)\r\n diff = n - get_Sn(i-1)\r\n sz = 2**(i-1)\r\n \r\n # [1..sz], [sz+1,2*sz], [2*sz+1, 3*sz], [3*sz+1, 4*sz], [4*sz+1,5*sz]\r\n if 1 <= diff <= sz:\r\n print('Sheldon')\r\n if sz+1 <= diff <= 2*sz:\r\n print('Leonard')\r\n if 2*sz+1 <= diff <= 3*sz:\r\n print('Penny')\r\n if 3*sz+1 <= diff <= 4*sz:\r\n print('Rajesh')\r\n if 4*sz+1 <= diff <= 5*sz:\r\n print('Howard')\r\n", "def solve(n):\n can = 0\n step = 1\n queue_order = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\n while True:\n for person in queue_order:\n can += step\n # print(person, can, step)\n if can >= n:\n return person\n \n step *= 2\n\nprint(solve(int(input())))\n\t\t\t\t\t\t\t \t \t \t\t \t\t \t \t\t", "s=['Sheldon','Leonard','Penny','Rajesh','Howard']\na=int(input())\na=a-1\nwhile a>=5:\n a=a-5\n a=a//2\nprint(s[a])\n\n\t \t\t\t\t \t \t \t \t\t\t \t\t\t", "from collections import deque, Counter, OrderedDict\r\nfrom heapq import nsmallest, nlargest\r\nfrom math import ceil,floor,log,log2,sqrt,gcd,factorial,pow\r\ndef binNumber(n,size=4):\r\n return bin(n)[2:].zfill(size)\r\n\r\ndef iar():\r\n return list(map(int,input().split()))\r\n\r\ndef ini():\r\n return int(input())\r\n\r\ndef isp():\r\n return map(int,input().split())\r\n\r\ndef sti():\r\n return str(input())\r\n\r\ndef par(a):\r\n return ' '.join(list(map(str,a)))\r\n\r\ndef tdl(outerListSize,innerListSize,defaultValue = 0):\r\n return [[defaultValue]*innerListSize for i in range(outerListSize)]\r\n\r\nclass pair:\r\n def __init__(self,f,s):\r\n self.fi = f\r\n self.se = s\r\n def __lt__(self,other):\r\n return (self.fi,self.se) < (other.fi,other.se)\r\n\r\n# ========= /\\ /| |====/|\r\n# | / \\ | | / |\r\n# | /____\\ | | / |\r\n# | / \\ | | / |\r\n# ========= / \\ ===== |/====| \r\n# code\r\n\r\nif __name__ == \"__main__\":\r\n n = ini()\r\n p = 0\r\n while 5*(2**p) < n:\r\n n -= 5*(2**p)\r\n p += 1\r\n x = (n-1)//(2**p)\r\n y = ['Sheldon','Leonard','Penny','Rajesh','Howard']\r\n print(y[x])", "n = int(input())\r\n\r\ndef f(n):\r\n count = 1\r\n set = 5\r\n while n > set:\r\n n = n - set\r\n count = count + 1\r\n set = set * 2\r\n a = set // 5\r\n fifth = 1\r\n while n > a:\r\n n = n - a\r\n fifth = fifth + 1\r\n if fifth == 1:\r\n return(\"Sheldon\")\r\n if fifth == 2:\r\n return(\"Leonard\")\r\n if fifth == 3:\r\n return(\"Penny\")\r\n if fifth == 4:\r\n return(\"Rajesh\")\r\n if fifth == 5:\r\n return(\"Howard\")\r\n\r\nprint(f(n))", "n =int(input())\r\nk=0\r\nif n<6:\r\n if n==1: print(\"Sheldon\")\r\n elif n==2:print(\"Leonard\")\r\n elif n==3:print(\"Penny\")\r\n elif n==4:print(\"Rajesh\")\r\n elif n==5:print(\"Howard\")\r\nelse:\r\n while n>0:\r\n n-=5*(1<<k)\r\n k+=1\r\n if n==0:\r\n print(\"Howard\")\r\n else:\r\n n+=5*(1<<(k-1))\r\n n=n//(1<<(k-1))\r\n if n==0: print(\"Sheldon\")\r\n elif n==1:print(\"Leonard\")\r\n elif n==2:print(\"Penny\")\r\n elif n==3:print(\"Rajesh\")\r\n elif n==4:print(\"Howard\")", "n=int(input())\r\nx=1\r\na=5\r\nc=1\r\nwhile(x<=n):\r\n if(n==x+a or n==1):\r\n print(\"Sheldon\")\r\n break\r\n elif(n>=x and n<x+a):\r\n if(n>=x and n<x+c):\r\n print(\"Sheldon\")\r\n break\r\n elif(n>=x+c and n<x+2*c):\r\n print(\"Leonard\")\r\n break\r\n elif(n>=x+2*c and n<x+3*c):\r\n print(\"Penny\")\r\n break\r\n elif(n>=x+3*c and n<x+4*c):\r\n print(\"Rajesh\")\r\n break\r\n elif(n>=x+4*c and n<x+5*c):\r\n print(\"Howard\")\r\n break\r\n c=c*2 \r\n x=x+a \r\n a=a*2", "import math\r\nn =int(input())\r\na=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nif n<=5:\r\n print(a[n-1])\r\nelse:\r\n sum=5\r\n z=0\r\n while(sum<n):\r\n z+=1\r\n sum+=2**z*5\r\n # # print(z) \r\n # if(n>=2**(z)*5):\r\n \r\n # else:\r\n # k=n-2**(z-1)*5\r\n # print(sum,z)\r\n k=n-sum+(2**(z)*5)\r\n # print(k) \r\n l=math.ceil(k/2**(z))\r\n # print(l)\r\n print(a[l-1])", "s=int(input())\r\nn=1\r\nnames=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile(n*5<s):\r\n\ts=s-n*5\r\n\tn=n*2\r\nprint(names[(s-1)//n])", "from collections import Counter\r\nfrom collections import defaultdict as dfd\r\nfrom bisect import bisect, bisect_left\r\nfrom math import sqrt, gcd, ceil, factorial\r\nfrom heapq import heapify, heappush, heappop\r\n\r\n\r\nMOD = 998244353\r\ninf = float(\"inf\")\r\nans_ = []\r\n\r\ndef nin():return int(input())\r\ndef ninf():return int(file.readline())\r\n\r\ndef st():return (input().strip())\r\ndef stf():return (file.readline().strip())\r\n\r\ndef read(): return list(map(int, input().strip().split()))\r\ndef readf():return list(map(int, file.readline().strip().split()))\r\n\r\n\r\n\r\n# file = open(\"input.txt\", \"r\")\r\n\r\ndef solve():\r\n arr = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n n = nin()\r\n x = 0\r\n while n > 5*(2**x):\r\n# print(n, 2**x, 5*(2**x))\r\n n -= 5*(2**x);\r\n x += 1; \r\n# print(n ,2**x, n/(2**x))\r\n ans_.append(arr[ceil(n/(2**x))-1])\r\n \r\n \r\nsolve()\r\n\r\nfor i in ans_:print(i)\r\n ", "import math\r\n \r\nn = int(input())\r\n \r\nans=[\"\",\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n \r\ni= int(math.log(math.ceil(n*1.0/5),2))\r\n \r\nans_index= int(math.ceil((n-(2**i -1)*5 )/(2**i*1.0)))\r\n \r\nprint(ans[ans_index])", "N = int(input())\r\n\r\nqueue = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\ni = 1\r\n\r\nwhile i * 5 < N:\r\n N -= i * 5\r\n i *= 2\r\n \r\nprint(queue[(N-1)//i])\r\n", "import math\r\nn = int(input())\r\ni=5\r\nwhile n-i>0:\r\n n = n-i\r\n i = i*2\r\nx = i//5\r\ny = math.ceil(n/x)\r\nl = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(l[y-1])", "n = int(input())\nm = 5\nwhile n > m:\n n -= m\n m *= 2\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nprint(names[5*(n-1)//m])\n\n", "#AKS Input\r\n\r\n#x,y=map(int,input().split())\r\n \r\n#l=list(map(int,input().split()))\r\n \r\n#for _ in range(int(input())):\r\nn=int(input())\r\nl=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif n<6:\r\n print(l[n-1])\r\nelse:\r\n p=0\r\n q=1\r\n r=0\r\n while r<n:\r\n r+=5*q\r\n p+=1\r\n q*=2\r\n q//=2\r\n p-=1\r\n n-=(2**(p) -1 )*5\r\n \r\n print(l[n//(q)])\r\n \r\n \r\n\r\n\r\n", "l=['Sheldon', 'Leonard', 'Penny' ,'Rajesh','Howard']\nn=int(input())\nk=1\nwhile(k*5<n):\n n-=k*5\n k*=2\nprint(l[(n-1)//k])\n \t\t \t\t \t\t \t\t\t\t \t\t\t \t\t\t", "n = int(input())\r\n\r\ni = 1\r\n\r\nwhile n > 5 * i:\r\n n -= 5 * i\r\n\r\n i *= 2\r\n\r\ncnt = 1\r\n\r\nwhile n > i:\r\n n -= i\r\n cnt += 1\r\n\r\nif cnt == 1:\r\n print(\"Sheldon\")\r\nelif cnt == 2:\r\n print(\"Leonard\")\r\nelif cnt == 3:\r\n print(\"Penny\")\r\nelif cnt == 4:\r\n print(\"Rajesh\")\r\nelif cnt == 5:\r\n print(\"Howard\")\r\n", "n=int(input())\nm=n\nwhile(n>4):\n n=(n-5)//2\na=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nif m<=5:\n print(a[m-1])\nelse:\n print(a[n])\n \t\t \t \t\t \t\t \t \t\t", "n = int(input())\r\nname = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\ni = 1\r\nwhile(i * 5 < n):\r\n n = n - (i * 5)\r\n i = i * 2\r\nprint(name[(n-1) // i])", "n=int(input())\narr=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nval=1\nwhile val*5<n:\n n=n-val*5\n val=val*2\nprint(arr[(n-1)//val])\n \t \t \t\t\t\t\t\t\t \t\t \t\t \t\t", "def who_will_drink(n):\r\n names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n k = 1\r\n while n > len(names) * k:\r\n n -= len(names) * k\r\n k *= 2\r\n return names[(n - 1) // k]\r\n\r\n# Вводим n\r\nn = int(input())\r\n\r\n# Выводим имя человека, который выпьет n-ую банку\r\nprint(who_will_drink(n))\r\n", "n = int(input())\r\ncur_turn = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nif n <= 5:\r\n print(cur_turn[n-1])\r\n exit()\r\ns = lambda x: 5 * (2**x - 1)\r\nupper_index = next(x for x in range(1, n) if s(x) > n)\r\nupper_bounder = s(upper_index)\r\nlower_bounder = s(upper_index-1)\r\nratio = float((n - lower_bounder)) / (upper_bounder - lower_bounder)\r\nif ratio >= 0.8:\r\n print(cur_turn[4])\r\nelif ratio >= 0.6:\r\n print(cur_turn[3])\r\nelif ratio >= 0.4:\r\n print(cur_turn[2])\r\nelif ratio >= 0.2:\r\n print(cur_turn[1])\r\nelse:\r\n print(cur_turn[0])", "n=int(input())\r\ns=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nl=n-1\r\nwhile l>=5:\r\n l=l-5\r\n l=l//2\r\nprint(s[l])\r\n", "m=int(input())\nc=1\ns = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nwhile(c*5<m):\n m=m-(c*5)\n c*=2\nm=m-1\nm=m//c\nprint(s[m])\n \t \t \t\t \t \t \t\t\t \t \t\t \t", "from math import log2, ceil\r\n\r\nx = int(input())\r\nif x > 10:\r\n a = int(log2(x/5))\r\n b = 5*(2**a - 1)\r\n x = ceil((x-b)/(2**a))\r\nelif x == 10:\r\n x = 3\r\nelif x > 7:\r\n x = 2\r\nelif x > 5:\r\n x = 1\r\n\r\nl = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(l[x - 1])\r\n", "n = int(input()) - 1\n\nwhile n > 4:\n n = n-5 >> 1\n\nprint(\"SLPRHheeaoeonjwlnneadaysror hdnd\"[n::5])\n \t\t\t\t\t\t\t \t\t \t\t \t \t\t\t\t", "n=int(input())-1\r\nl=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nwhile n>4:\r\n n=(n-5)//2\r\nprint(l[n])\r\n", "import math\r\na = int(input())\r\nb = 0\r\nc = 0\r\nd = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile True:\r\n\tb += 5 * 2 ** c\r\n\tif b >= a:\r\n\t\tt = a - (b - 5 * 2 ** c)\r\n\t\tf = math.ceil(t / 2 ** c)\r\n\t\tprint(d[f - 1])\r\n\t\tbreak\r\n\tc += 1", "import math\r\n\r\nn = int(input())\r\nqueue = [\"\", \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nrounds = math.ceil(math.log2(0.2 * n + 1))\r\nexclude = int(5 * (2 ** (rounds - 1) - 1))\r\nnum = n - exclude\r\nindex = math.ceil(num / (2 ** (rounds - 1)))\r\nans = queue[index]\r\nprint(ans)", "l=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn= int(input())\r\nx=0\r\nwhile True:\r\n if (5*2**x)>=n:\r\n #x-=1\r\n for i in range(5):\r\n if (n-2**x) <= 0:\r\n print(l[i])\r\n break\r\n else:\r\n n-=2**x\r\n break\r\n else:\r\n n-=5*2**x\r\n x+=1", "\n# Online Python - IDE, Editor, Compiler, Interpreter\nimport math\nbbt=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nn=int(input())\nif(n>5):\n while(n>5):\n n=n-5\n n=math.ceil(n/2)\n print(bbt[n-1])\nelse:\n print(bbt[n-1])\n", "a = int(input())\r\ni = 1\r\nwhile True:\r\n if a > i*5:\r\n a -= i*5\r\n i *= 2\r\n else:\r\n if a <= i:\r\n print(\"Sheldon\")\r\n elif a <= 2*i:\r\n print(\"Leonard\")\r\n elif a <= 3*i:\r\n print(\"Penny\")\r\n elif a <= 4*i:\r\n print(\"Rajesh\")\r\n else:\r\n print(\"Howard\")\r\n exit(0)", "n=int(input())\r\nlst=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nl=[1]\r\nu=[5]\r\nfor i in range(1,29):\r\n l.append(l[i-1]+5*(2**(i-1)))\r\n u.append(u[i-1]+5*(2**(i)))\r\nans=0\r\nfor i in range(len(l)):\r\n if l[i]<=n<=u[i]:\r\n x=(u[i]-l[i]+1)//5\r\n ans=(abs(l[i]-n)//x)+1\r\n break\r\nprint(lst[ans-1])\r\n\r\n", "import math\n\nobj = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\nn = int(input())\n\nm = math.log(n/5.0 + 1.0, 2)\ns = pow(2, int(m))\nt = n - 5 * (s - 1)\n\nif n > 5:\n if t % s:\n index = t // s + 1\n else:\n index = t // s\nelse:\n index = n\n\nprint(obj[index - 1])\n\n\t\t \t \t \t\t \t \t \t\t\t\t \t \t", "n = int(input())\ni= 1\nans = 1\njmp = 1\nnames = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nwhile (i<n):\n i+=jmp\n ans+=1\n if (ans==6):\n ans= 1\n i+=jmp\n jmp*=2\nprint(names[ans-1]) \n \t\t \t \t \t \t\t \t \t\t \t\t\t", "import math\r\nn = int(input())\r\nt = int(math.log((n/5 + 1),2))\r\n# print(\"t = \", t)\r\ns = n - 5*(2**t - 1)\r\n# print(s)\r\nif(s==0): print(\"Howard\")\r\nelse:\r\n i=1\r\n while(i<=5):\r\n s = s-(2**(t))\r\n if(s<=0): break;\r\n else: i = i+1\r\n if (i == 1): print( \"Sheldon\")\r\n elif (i == 2): print(\"Leonard\")\r\n elif (i == 3): print(\"Penny\")\r\n elif (i == 4): print(\"Rajesh\")\r\n elif (i == 5): print(\"Howard\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Sep 18 00:48:08 2020\r\n82A Double Cola\r\n@author: RACHIT\r\n\"\"\"\r\n\r\n\r\nif __name__==\"__main__\":\r\n n=int(input())\r\n l=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n k=0\r\n while n>5*(2**k):\r\n n-=5*(2**k)\r\n k+=1\r\n print(l[(n-1)//(2**k)])", "n = int(input())\r\nwhile n>5:\r\n n = (n-4)//2\r\nif n==1: print(\"Sheldon\")\r\nelif n==2: print(\"Leonard\")\r\nelif n==3: print(\"Penny\")\r\nelif n==4: print(\"Rajesh\")\r\nelif n==5: print(\"Howard\")", "# A. Double Cola\r\nn=int(input())\r\ndic={\"1\":\"Sheldon\",\"2\":\"Leonard\",\"3\":\"Penny\",\"4\":\"Rajesh\",\"5\":\"Howard\"}\r\ni=0\r\nk=5\r\nwhile k<n :\r\n n-=k\r\n k*=2\r\n i+=1\r\n\r\nc=n//pow(2,i)\r\nif n%pow(2,i)!=0:\r\n c+=1\r\nprint(dic[str(c)])\r\n", "n=int(input())\r\n\r\nnames=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\ni=0\r\na=0\r\nwhile 1:\r\n x=pow(2,i)\r\n i+=1\r\n\r\n b=a+x*5\r\n\r\n if a+1<=n and n<=b:\r\n a=a+1\r\n break\r\n \r\n a+=x*5\r\nfor i in range(5):\r\n rb=a+x-1\r\n if a<=n and n<=rb:\r\n print(names[i])\r\n exit(0)\r\n\r\n a=rb+1\r\n", "n=int(input())\ns=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nr=1 \nwhile(r*5<n):\n n-=r*5\n r=r*2\nprint(s[(n-1)//r])\n\n\t\t \t \t \t\t\t\t \t \t \t \t\t", "l=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn=int(input())-1\r\nwhile(n>=5):\r\n n=(n-5)//2\r\nprint(l[n])\r\n", "n = int(input())\r\nq = 1\r\nwhile n > 5 * q:\r\n n -= 5 * q\r\n q *= 2\r\nif n <= q:\r\n print('Sheldon')\r\nelif n <= 2 * q:\r\n print('Leonard')\r\nelif n <= 3 * q:\r\n print('Penny')\r\nelif n <= 4 * q:\r\n print('Rajesh')\r\nelif n <= 5 * q:\r\n print('Howard')", "import sys\r\ndef input(): return sys.stdin.readline().strip()\r\ndef getints(): return map(int,sys.stdin.readline().strip().split())\r\nfrom math import log2\r\n\r\nl = ['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn = int(input())\r\nans = int((n-1 - 5*(2**int(log2(1+(n-1)/5))-1))//(2**int(log2(1+(n-1)/5))))\r\nprint(l[ans])\r\n", "n, deti = int(input()), 1\r\nmena = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nwhile True:\r\n for i in range(5):\r\n n -= deti\r\n if n <= 0:\r\n print(mena[i])\r\n break\r\n\r\n if n <= 0:\r\n break\r\n deti *= 2\r\n", "n = int(input())\r\nx =1\r\ni=1\r\nwhile x < n:\r\n x += 5 *i\r\n i*=2\r\nif i !=1 :\r\n i //= 2\r\nif x != n:\r\n x -= 5*i\r\nx = (n - x)// i\r\nif x == 0:\r\n print('Sheldon')\r\nelif x == 1:\r\n print('Leonard')\r\nelif x== 2:\r\n print('Penny')\r\nelif x == 3:\r\n print('Rajesh')\r\nelif x == 4:\r\n print('Howard')", "n = int(input())\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nqueue_size = len(names)\r\ndrinks = 0\r\n\r\nwhile n > queue_size:\r\n n -= queue_size\r\n queue_size *= 2\r\n drinks += 1\r\n\r\nindex = (n - 1) // (2 ** drinks)\r\nprint(names[index])", "import math\r\nn = int(input())\r\nl=5\r\npic = {0:'Sheldon', 1:'Leonard', 2:'Penny', 3:'Rajesh', 4:'Howard' }\r\nif n<=5: \r\n print(pic[n-1])\r\nelse:\r\n \r\n j = 1\r\n sum = 5\r\n presum = 5\r\n while sum < n:\r\n j=j+1\r\n l=l*2\r\n presum=sum\r\n sum=sum+l\r\n # print(presum,j)\r\n sum = n - presum\r\n sum = sum / pow(2,j-1)\r\n print(pic[math.floor(sum)])", "import math\n\nN = int(input())\nn = math.floor(math.log2(N / 5 + 1))\npast = (2 ** n - 1) * 5\nremain = N - past\nevery = 2 ** n\n\nif remain == 0:\n result = 4\nelse:\n result = ((remain - 1) // every) % 5\n\nname = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nprint(name[result])\n", "Cola = int(input())\nLiterallyTheBigBangCast = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nCurrentCount = 0\nMultiplier = 1\n\nwhile(CurrentCount + len(LiterallyTheBigBangCast) * Multiplier < Cola):\n CurrentCount += len(LiterallyTheBigBangCast) * Multiplier\n Multiplier *= 2\n\nprint(LiterallyTheBigBangCast[((Cola - CurrentCount - 1 ) // Multiplier)])\n\t\t \t \t\t \t\t \t\t\t\t\t \t \t \t \t", "'''\r\nCreated on ٠٥‏/١٢‏/٢٠١٤\r\n\r\n@author: mohamed265\r\n'''\r\n#for n in range(1, 1803):\r\nn = int(input()) + 5\r\nx = 5\r\nwhile x < n :\r\n x = (x * 2)\r\n if x >= n:\r\n break \r\n #print(x)\r\ntemp = 0\r\nif x > 5 :\r\n x //= 2\r\n temp = x // 5\r\nelse:\r\n x = 0\r\n temp = 1\r\n # x+=5\r\n \r\ntemp2 = n - x\r\n #print(n , \" \" , temp , temp2 , x)\r\nif temp + x >= n:\r\n print(\"Sheldon\")\r\nelif 2 * temp + x >= n:\r\n print(\"Leonard\")\r\nelif 3 * temp + x >= n:\r\n print(\"Penny\")\r\nelif 4 * temp + x >= n:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "inp = int(input())\r\nr = 1\r\nwhile(r * 5 < inp):\r\n inp -= (r * 5)\r\n r *= 2\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(names[(inp - 1) // r])", "n=int(input())\r\nlistnames=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\ni=0\r\nt=False\r\nc=5\r\nlistcount=[1,1,1,1,1]\r\nif(1<=n<=5):\r\n print(listnames[n-1])\r\nelif(n==6):\r\n print(\"Sheldon\")\r\nelse:\r\n while(t==False):\r\n while(i<5):\r\n listcount[i]=listcount[i]*2\r\n c = c + listcount[i]\r\n i=i+1\r\n if(c>=n):\r\n print(listnames[i-1])\r\n t=True\r\n break\r\n i=0\r\n", "n=int(input())\r\np=0\r\nif n<=5:\r\n if n==1:\r\n print(\"Sheldon\")\r\n elif n==2:\r\n print(\"Leonard\")\r\n elif n==3:\r\n print(\"Penny\")\r\n elif n==4:\r\n print(\"Rajesh\")\r\n else:\r\n print(\"Howard\")\r\nelse:\r\n m=n\r\n while 5*2**p<=n:\r\n n-=5*2**p\r\n p+=1\r\n #print(n)\r\n r=int(n/(2**p))\r\n #print(p,r)\r\n if r==0:\r\n print(\"Sheldon\")\r\n elif r==1:\r\n print(\"Leonard\")\r\n elif r==2:\r\n print(\"Penny\")\r\n elif r==3:\r\n print(\"Rajesh\")\r\n elif r==4:\r\n print(\"Howard\")\r\n", "k=int(input())\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nR=1\nwhile(R*5<k):\n k-=R*5\n R*=2\nprint(a[(k-1)//R])\n \t\t\t \t \t\t \t\t \t\t\t \t \t\t", "import math\r\n\r\nn = int(input())\r\n\r\nN = math.floor(math.log2(n/5 + 1))\r\nO = 5 * (2 ** N - 1)\r\nl = n - O\r\n\r\nif l == 0:\r\n print(\"Howard\")\r\nelse:\r\n pI = (l - 1) // (2 ** N)\r\n print([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][pI])", "def solve(n):\r\n\r\n p = 0\r\n\r\n m = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\n while 5 * (2**p) < n:\r\n n -= 5 * (2**p)\r\n p += 1\r\n\r\n\r\n idx = int((n - 1) // (2**p))\r\n\r\n print(m[idx])\r\n\r\n\r\nn = int(input())\r\nsolve(n)\r\n", "import math\r\n\r\ndef S(k):\r\n return 1 + 5 * (2 ** (k - 1) - 1)\r\ndef L(k):\r\n return 2 ** (k - 1)\r\n\r\nn = int(input())\r\nk = int(math.log2((n + 4) / 5) + 1)\r\ni = (n - S(k)) // L(k)\r\n\r\nif i == 0:\r\n print('Sheldon')\r\nelif i == 1:\r\n print('Leonard')\r\nelif i == 2:\r\n print('Penny')\r\nelif i == 3:\r\n print('Rajesh')\r\nelse:\r\n print('Howard')", "n=int(input())\nr=1\nnames=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nwhile r*5 < n:\n\tn=n-r*5\n\tr=r*2\nprint(names[(n-1)//r])\n \t \t \t \t \t\t\t\t\t\t \t \t\t \t", "n = int(input())\r\nname = ['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nr=1\r\nwhile(r*5 < n):\r\n n-=(r*5)\r\n r*=2\r\nprint(name[(n-1)//r])\r\n", "import math\r\nname=[ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn=int(input())\r\nk=math.log((n/5)+1,2)\r\nk1=(int)(k)\r\nif k!=k1:\r\n k=k1+1\r\nelse:\r\n k=k1\r\nstart=5*(pow(2,k-1)-1)+1\r\nd=(n-start)/pow(2,k-1)\r\nd=(int)(d)\r\nprint(name[d])", "import math\r\n\r\ndef GetX(k):\r\n return(5*(2**k - 1))\r\n\r\ndef GetNameId(n, k):\r\n a = GetX(math.ceil(k) - 1)\r\n b = GetX(math.ceil(k))\r\n dx = b - a\r\n return(math.ceil((n - a)/dx/0.2) - 1)\r\n\r\ndef GetK(x):\r\n return(math.log(x/5 + 1, 2))\r\n\r\nname = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\r\nn = int(input())\r\nk = GetK(n)\r\nprint(name[GetNameId(n, k)])\r\n\r\n", "#S= 1,6,7,16,17,18,19,36,37,38,39,40,41,42,43\r\n#L= 2,8,9,20,21,22,23,44,45,46,47,48,49,50,51\r\n#P= 3,10,11,24,25,26,27,52,53,54,55,56,57,58,59,60\r\n#R= 4,12,13,28,29,30,31,61,62,63,64,65,66,67,68\r\n#H= 5,14,15,32,33,34,35,69,70,71,72,73,74,75,76\r\n\r\n\r\n\r\n\r\nN=int(input())\r\ncounter=0\r\nwhile 5*2**counter<N:\r\n\tN-=5*2**counter\r\n\tcounter+=1\r\ncounter2=0\r\nchecker=0\r\nwhile checker<N:\r\n\tchecker+=2**counter\r\n\tcounter2+=1\r\nif counter2==1:\r\n\tprint(\"Sheldon\")\r\nif counter2==2:\r\n\tprint(\"Leonard\")\r\n\texit()\t\r\nif counter2==3:\r\n\tprint(\"Penny\")\r\n\texit()\r\nif counter2==4:\r\n\tprint(\"Rajesh\")\r\n\texit()\t\r\nif counter2==5:\r\n\tprint(\"Howard\")\r\n\texit()", "n=int(input())\nar=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\",\"\"]\nr=1\nwhile(r*5<n):\n n-=r*5\n r*=2\nprint(ar[(n-1)//r])\n \t \t \t \t\t\t\t\t \t\t\t\t\t\t", "n=int(input())\r\nL=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\ni=1\r\nwhile 2**(i-1)*5<n:\r\n n-=2**(i-1)*5\r\n i+=1\r\nk=1\r\nwhile 2**(i-1)<n:\r\n n-=2**(i-1)\r\n k+=1\r\nprint(L[k-1])", "n = int(input())\r\na = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nn=n-1\r\nwhile n > len(a) - 1:\r\n n=n-5\r\n n=n//2\r\nprint(a[n])", "import math\r\na=5\r\nn=int(input())\r\ni=1\r\nwhile n-a*i>0:\r\n n=n-a*i\r\n i=i*2\r\nn=math.ceil((n/i))\r\nif n==5:\r\n print('Howard')\r\nif n==1:\r\n print('Sheldon')\r\nif n==2:\r\n print('Leonard')\r\nif n==3:\r\n print('Penny')\r\nif n==4:\r\n print('Rajesh')", "#coded by gautham on 25/6\r\nimport math\r\nn=int(input())\r\nif n==1:\r\n print(\"Sheldon\")\r\nelse:\r\n l=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n k=1\r\n while n>k*5:\r\n n=n-5*k\r\n k=k*2\r\n s=math.ceil(n/k)\r\n print(l[s-1])", "def find(n):\r\n L = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n queue = len(L)\r\n while n > queue:\r\n n -= queue\r\n queue *= 2\r\n index = (n - 1) // (queue // len(L))\r\n return L[index]\r\n\r\n\r\nn = int(input())\r\nresult = find(n)\r\nprint(result)\r\n", "import math\r\na = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nn = int(input())\r\np = 0\r\nwhile 5 * 2**p < n:\r\n n -= 5 * 2**p\r\n p += 1\r\nx = math.ceil(n / 2**p)\r\nprint(a[x-1])\r\n", "import sys\r\n\r\nn = int(sys.stdin.readline())\r\n\r\niterations = 0\r\nprev_idx = 0\r\nidx = 1\r\n\r\nstep = 5\r\nwidth = 1\r\n\r\nwhile idx <= n:\r\n prev_idx = idx\r\n idx += step\r\n step *= 2\r\n width *= 2\r\n\r\nstep //= 2\r\nwidth //= 2\r\n\r\nassert n >= prev_idx\r\nif n < prev_idx + width:\r\n print(\"Sheldon\")\r\nelif n < prev_idx + 2 * width:\r\n print(\"Leonard\")\r\nelif n < prev_idx + 3 * width:\r\n print(\"Penny\")\r\nelif n < prev_idx + 4 * width:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "n = int(input())\r\na = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = n - 1\r\nwhile n > len(a) - 1:\r\n n = n - 5\r\n n = n // 2\r\nprint(a[n])\r\n", "a=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn=int(input())-1\nwhile (n>4):n=n-5>>1\nprint(a[n])\n\t \t\t \t\t \t \t \t\t \t \t\t\t\t\t\t\t \t", "n=int(input())\r\na=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nr=1\r\nwhile(r*5<n):\r\n n=n-(r*5)\r\n r=r*2\r\nk=(n-1)//r\r\nprint(a[k])", "n=int(input())\n\ncycle=5\nnum=5\nwhile(num<n):\n cycle*=2\n num+=(cycle)\n\nrequired=n-(num-cycle)\nif(required<=cycle//5):\n print(\"Sheldon\")\nelif(required<=(cycle*2)//5):\n print(\"Leonard\")\nelif(required<=((cycle*3)//5)):\n print(\"Penny\")\nelif(required<=((cycle*4)//5)):\n print(\"Rajesh\")\nelif(required<=cycle):\n print(\"Howard\")\n \n\n\n\n\n\n \n", "n = int(input())\r\nlst = [1,1,1,1,1,1]\r\nname = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ni=0\r\nwhile n>0:\r\n if i==5: i=0\r\n if n>lst[i]:\r\n n-=lst[i]\r\n lst[i]*=2\r\n \r\n else:\r\n print(name[i])\r\n break\r\n i+=1", "n = int(input()); l = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']; i = 1\r\nwhile True:\r\n if n > i*5 : n -= i*5; i *= 2\r\n else:\r\n import math\r\n print(l[math.ceil(n/i) -1 ])\r\n break", "# Double Cola\ndef tbbt(n):\n f = {0: \"IDK\", 1: \"Sheldon\", 2: \"Leonard\", 3: \"Penny\", 4: \"Rajesh\", 5: \"Howard\"}\n if n in f:\n return f[n]\n i = 2\n start_val = 5\n while True:\n if start_val >= n:\n break\n start_val += (i * 5)\n i *= 2\n i = i//2\n start_val = start_val - (i * 5)\n ite = 1\n while True:\n if n in range(start_val+1, start_val+i+1):\n return f[ite]\n start_val += i\n ite += 1\n\n \n\nn = int(input())\nprint(tbbt(n))\n\n", "from math import log2\nnames = 'Sheldon Leonard Penny Rajesh Howard'.split()\nn = int(input())\ni = int(log2(n//5+1))\nnum = 2**i\nn -= 5*(2**i-1)+1\nprint(names[n // num])\n", "n = int(input())-1\r\nl = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nwhile n > 4:\r\n n = (n-5)//2\r\nprint(l[n])", "L=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nn=int(input(\"\"))\r\nsuma=0\r\nj=1\r\nwhile(n>suma+5*j):\r\n suma+=5*j\r\n j=j*2\r\nsuma+=1\r\nk=0\r\nwhile(k<5):\r\n if(suma<=n<=suma+j-1):\r\n print(L[k])\r\n break\r\n suma+=j\r\n k+=1\r\n", "names = ['Sheldon','Leonard','Penny','Rajesh','Howard']\r\ni=1\r\nc = int(input())\r\nc1=0\r\nd=1\r\nwhile(c>0):\r\n c-=d\r\n c1+=1\r\n if(c1==5):\r\n c1=0\r\n d*=2\r\nprint(names[c1-1])", "n=int(input())\r\ni=0\r\narr=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nj=0\r\nk=1\r\nwhile i<n:\r\n j=k\r\n p=i\r\n i=i+k*5\r\n k*=2\r\nneed=n-p\r\nindex=need//j\r\nif need%j!=0:\r\n print(arr[need//j])\r\nelse:\r\n print(arr[need//j-1])", "a=int(input())\nif a>5:\t\n\tk=1\n\twhile True:\n\t\tb=a//(5*((2**k)-1))\n\t\tif b==0:\n\n\t\t\t\n\t\t\tbreak\n\t\telse:\n\t\t\tk+=1\n\t\t\tcontinue\n\tc=a-5*((2**(k-1)-1))\t\t\n\td=c//(2**(k-1))\n\tif d==0:\n\t\tprint('Sheldon')\n\tif d==1:\n\t\tprint(\"Leonard\")\n\tif d==2:\n\t\tprint(\"Penny\")\n\tif d==3:\n\t\tprint(\"Rajesh\")\n\tif d==4:\n\t\tprint(\"Howard\")\t\nelse:\n\tif a==1:\n\t\tprint('Sheldon')\n\n\telif a==2:\n\t\tprint(\"Leonard\")\n\telif a==3:\n\t\tprint(\"Penny\")\n\telif a==5:\n\t\tprint(\"Howard\")\t\t\n\telif a==4:\n\t\tprint(\"Rajesh\")\t\n", "n=int(input())\r\nlist1=['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nfor i in range(1000):\r\n if n<=5*(2**i-1):\r\n break\r\nb=n-5*(2**(i-1)-1)\r\na=int((b-1)//(2**(i-1)))\r\nprint(list1[a])", "l=['Sheldon', 'Leonard', 'Penny' ,'Rajesh','Howard']\na=int(input())\nb=1\nwhile (b*5<a):\n a=a-b*5\n b*=2\nans=(a-1)//b\nprint(l[ans])\n \t\t\t\t\t\t \t\t \t \t\t \t\t\t \t\t", "import math\r\n\r\ndef round(pos):\r\n r = -1\r\n c = 0\r\n while pos > c:\r\n c += (2**(r+1))*5\r\n r += 1\r\n check((r-1 , c , pos))\r\n\r\ndef check(tup):\r\n t = 2**(tup[0]+1)*5\r\n starting = tup[1]-t\r\n div = t/5\r\n answer = math.ceil(((tup[2]-starting)/div))\r\n if answer == 1:\r\n print('Sheldon')\r\n elif answer == 2:\r\n print('Leonard')\r\n elif answer == 3:\r\n print('Penny')\r\n elif answer == 4:\r\n print('Rajesh')\r\n elif answer == 5:\r\n print('Howard')\r\n \r\n\r\nround(int(input()))", "c, r, *arr = [0, 5, 0, \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\nwhile n > r:\r\n n -= r\r\n c += 1\r\n r <<= 1\r\nprint(arr[(n//(1<<c))+(1 if n%(1<<c) else 0)])", "n = int(input())\r\ni = 0\r\nnames = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nwhile n-(2**i)*5 > 0:\r\n n -= (2**i)*5\r\n i += 1\r\nb = 2**i\r\nfor k in range(5):\r\n if k<4 and k*b<n and n<=(k+1)*b:\r\n break\r\nprint(names[k])", "import math\r\n\r\npessoas = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nn = int(input()) - 1\r\n\r\nrodada = int(math.log(n/5 + 1, 2))\r\ntam_blocos = 2**(rodada)\r\nfalta = n - (2**rodada - 1)*5\r\npessoa = falta // tam_blocos\r\n\r\nprint(pessoas[pessoa])\r\n", "import math\r\nk = {'s':'Sheldon' , 'l' : 'Leonard' , 'p' :'Penny' , 'r' : \"Rajesh\" , 'h' :'Howard'}\r\nh = \"\"\r\nst = \"slprh\"\r\ng = int(input())\r\nh = int(math.log(g/5 + 1 , 2))\r\nsu = 5*(2**h - 1)\r\ndiff = g - su\r\np = 2**h\r\nind = math.ceil(diff/p)\r\nprint( k[st[ind-1]])\r\n\r\n \r\n", "n = int(input())\nm = 5\nwhile n > m:\n n -= m\n m *= 2\nif n > 0 and n <= m/5:\n print(\"Sheldon\")\nif n > m/5 and n <= 2*m/5:\n print(\"Leonard\")\nif n > 2*m/5 and n <= 3*m/5:\n print(\"Penny\")\nif n > 3*m/5 and n <= 4*m/5:\n print(\"Rajesh\")\nif n > 4*m/5 and n <= m:\n print(\"Howard\")\n\t \t\t \t \t\t \t\t\t\t \t \t\t \t \t\t\t", "\r\nvalue = int(input())\r\n\r\nx = 5\r\ni = 1\r\nwhile(x < value):\r\n x = x + 10 * i\r\n i = i * 2\r\n\r\ntmp = value\r\nif(x > 5):\r\n x = x - 10 * (int(i/2))\r\n tmp = value - x\r\n\r\n\r\nif(tmp <= i * 1 ):\r\n print(\"Sheldon\")\r\nelif(tmp <= i * 2 ):\r\n print(\"Leonard\")\r\nelif(tmp <= i * 3 ): \r\n print(\"Penny\")\r\nelif(tmp <= i * 4 ):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "l=['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\nn=int(input())\nc=0\nt=0\nwhile True:\n x=(2**t)*5\n if x>=n:\n break\n n-=x\n t+=1\nwhile n>0:\n n-=2**t\n c+=1\nprint(l[c-1])\n \t \t\t\t \t\t \t\t\t \t\t\t \t\t\t \t", "def finddiv(n):\r\n div=0\r\n before=0\r\n while n>0:\r\n div+=1\r\n before=n\r\n n-= 2**(div-1)*5\r\n return [div,before]\r\nimport math\r\nn=int(input())\r\ndiv,before=finddiv(n)\r\nlst=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nprint(lst[math.ceil(before/(2**(div-1)))-1])\r\n", "n = int(input())\np = 0\nwhile (5 * (2**p) - 5) < n:\n p += 1\np -= 1\nx = n - (5 * (2**p) - 5)\nif x > 0 and x <= 2**p:\n print('Sheldon')\nelif x > 2**p and x <= 2*2**p:\n print('Leonard')\nelif x > 2*2**p and x <= 3*2**p:\n print('Penny')\nelif x > 3*2**p and x <= 4*2**p:\n print('Rajesh')\nelif x > 4*2**p and x <= 5*2**p:\n print('Howard')", "n = int(input())\r\nwhile n > 5:\r\n if n&1:\r\n n-=5\r\n n//=2\r\n elif n %2 == 0:\r\n n-=4\r\n n//=2\r\nif n == 1:\r\n print('Sheldon')\r\nelif n == 2:\r\n print('Leonard')\r\nelif n == 3:\r\n print('Penny')\r\nelif n == 4:\r\n print('Rajesh')\r\nelif n == 5:\r\n print('Howard')\r\n\r\n\r\n\r\n", "import math\r\n##Double Colas\r\nn = int(input())\r\nc = (n/5)+1\r\nz = math.floor(math.log(c,2))\r\nLB = 5*((2**z)-1)\r\nif (n == LB):\r\n z -= 1\r\n LB = 5*((2**z)-1)\r\nn -= LB\r\ncount = 0\r\nwhile (n > 2**z):\r\n n -= 2**z\r\n count += 1\r\n\r\nif (count == 0):\r\n print('Sheldon')\r\nelif(count == 1):\r\n print(\"Leonard\")\r\nelif(count == 2):\r\n print(\"Penny\")\r\nelif(count == 3):\r\n print('Rajesh')\r\nelse:\r\n print('Howard')\r\n \r\n \r\n", "cola=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nf=int(input())\r\nfor i in range(f):\r\n if 5*(2**i-1)>f:\r\n break\r\n m=5*(2**i-1)\r\nprint(cola[int((f-m-1)//(2**(i-1)))])\r\n\r\n", "l=['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nn=int(input())\r\nc=0\r\nt=0\r\nwhile True:\r\n x=(2**t)*5\r\n if x>=n:\r\n break\r\n n-=x\r\n t+=1\r\nwhile n>0:\r\n n-=2**t\r\n c+=1\r\nprint(l[c-1])", "\nn = int(input())\nlst = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nrate = 1\nwhile (5 * rate) <= n:\n n -= (5 * rate)\n rate *= 2\n\nprint(lst[(n-1)//rate])\n", "a = int(input()) - 1\r\ns = 5\r\nwhile a - s >= 0:\r\n a -= s\r\n s *= 2\r\n\r\nprint((\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\")[a // (s // 5)])", "def main():\r\n n=int(input())\r\n a = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n while n>5:\r\n n=n//2 - 2\r\n print(a[n-1])\r\nmain()", "import math\r\n\r\nn = int(input()) # 7\r\n\r\narr = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nsm = n + 4\r\n\r\npr = 5\r\nwhile True:\r\n\tif pr > sm:\r\n\t\tpr //= 2\r\n\t\tbreak\r\n\r\n\tpr *= 2\r\n\r\n\r\nstart = pr #6\r\n\r\nrep = start // 5\r\n\r\nstep = n - (start - 4) \r\n\r\nans = math.floor((step / rep) + 1)\r\n\r\n\"\"\"\r\nprint(\"SM: \", sm)\r\nprint(\"PR: \", pr)\r\nprint(\"Start: \", start)\r\nprint(\"REP: \", rep)\r\nprint(\"Step: \", step)\r\n\"\"\"\r\n\r\nprint(arr[ans-1])\r\n\r\n", "# cook your dish here\r\n# cook your dish here\r\n\r\nn=int(input())\r\nl=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nc=1;\r\nif(n<=5):\r\n print(l[n-1])\r\nelse:\r\n while(n>5*c):\r\n n-=5*c\r\n c*=2\r\n x=n//c\r\n print(l[x]) ", "import math\r\nque = int(input())\r\n\r\nname = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nn=0\r\nwhile que - 5*math.pow(2,n) > 0 :\r\n que -= 5*math.pow(2,n)\r\n n += 1\r\n\r\nprint(name[math.ceil(que/math.pow(2,n))-1])", "from math import ceil\nn = int(input())\ntest = n\nppl = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\ni = 0\nwhile n > 5*ceil(pow(2,i)): #finding the number that appears in the closest in the series of 5,10,20 and so on\n n -= 5*ceil(pow(2,i))\n i += 1\nans = (n-1)/ceil(pow(2,i)) #ceil(pow(2,i)) is now the number of colas that each person purchases in the list\nprint(ppl[int(ans)])", "\r\ndef lenOfG(a, x, n):\r\n return a * ((1 - pow(x, n + 1)) / (1 - x))\r\n\r\ndef getAn(a, x, n):\r\n return a * pow(x, n)\r\n\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nposition = int(input())\r\n\r\n\r\n\r\na = 5\r\nx = 2\r\ncounter = 0\r\n\r\nlenOfQueue = lenOfG(a, x, counter)\r\nwhile lenOfQueue < position:\r\n counter += 1\r\n lenOfQueue = lenOfG(a, x, counter)\r\n\r\nposition = position - lenOfG(a, x, counter - 1);\r\nqueue = getAn(a, x, counter);\r\n\r\ndelta = queue // 5;\r\n\r\ncounter = 0;\r\nwhile delta < position:\r\n counter += 1;\r\n delta += queue // 5;\r\n\r\nprint(names[counter])\r\n", "n = int(input())\r\np = 0\r\nwhile n - 5 * 2**p > 0:\r\n n -= 5 * 2**p\r\n p += 1\r\nif n <= 2**p:\r\n print('Sheldon')\r\nelif n <= 2 * 2**p:\r\n print('Leonard')\r\nelif n <= 3 * 2**p:\r\n print('Penny')\r\nelif n <= 4 * 2**p:\r\n print('Rajesh')\r\nelse:\r\n print('Howard')", "n = int(input())\r\nx = 5\r\nn1=n\r\nwhile x<n1:\r\n n1-=x\r\n x*=2\r\na = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nif n>5:\r\n print(a[n1//(x//5)])\r\nelse:\r\n print(a[(n+4)%5])", "from math import ceil\r\nn = int(input())\r\ni = 0\r\nwhile n > 5 * ceil(2 ** i):\r\n n -= 5 * ceil(2 ** i)\r\n i += 1\r\n\r\nans = (n - 1) // ceil((2 ** i))\r\n\r\nif ans == 0:\r\n print(\"Sheldon\")\r\n \r\nelif ans == 1:\r\n print(\"Leonard\")\r\n \r\nelif ans == 2:\r\n print(\"Penny\")\r\n \r\nelif ans == 3:\r\n print(\"Rajesh\")\r\n \r\nelif ans == 4:\r\n print(\"Howard\")\r\n", "n = int(input())\r\nl = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nc = 5\r\nr = 1\r\nwhile n > c:\r\n n = n - c\r\n c = c * 2\r\n r = r*2\r\nh = (n-1)//r\r\nprint(l[h])", "n=int(input())\r\nl=0\r\ni=0\r\nwhile l<n:\r\n\tl+=5*(2**(i))\r\n\ti+=1\r\na=n-l+5*(2**(i-1))\r\n\r\nif(n==1):\r\n\tprint('Sheldon')\r\nelif(n==2):\r\n\tprint('Leonard')\r\nelif(n==3):\r\n\tprint('Penny')\r\nelif(n==4):\r\n\tprint('Rajesh')\r\nelif(n==5):\r\n\tprint('Howard')\r\nelif(a>=1 and a<=2**(i-1)):\r\n\tprint('Sheldon')\r\nelif(a>=1+2**(i-1) and a<=2**(i)):\r\n\tprint('Leonard')\r\nelif(a>=1+2**(i) and a<=3*(2**(i-1))):\r\n\tprint('Penny')\r\nelif(a>=1+3*(2**(i-1)) and a<=4*(2**(i-1))):\r\n\tprint('Rajesh')\r\nelif(a>=1+4*(2**(i-1)) and a<=5*(2**(i-1))):\r\n\tprint('Howard')", "a=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn=int(input())-1\r\ni= 5\r\nwhile n>=i:\r\n n-=i\r\n i*= 2\r\nprint(a[int(n/(i/5))])", "# your code goes here\nlist=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard \"]\nn=int(input())\nc=1\nwhile (c*5)<n:\n\tn=n-(c*5)\n\tc=c*2\nn=(n-1)//c\nprint(list[n])\n\t\t \t \t \t \t\t\t\t \t\t\t\t\t\t\t \t\t \t", "a =[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\" ,\"Howard\"]\r\nt = int(input())\r\nif(t<=5):\r\n print(a[t-1])\r\nelse :\r\n t+=1\r\n cnt = 0\r\n i = 1\r\n while(t>0):\r\n t-=i\r\n if(t<=0):\r\n print(a[cnt%5])\r\n \r\n \r\n if(cnt%5==4):\r\n i*=2\r\n cnt+=1\r\n \r\n", "import sys\r\n \r\ndef read_strings():\r\n return list(sys.stdin.readline().split())\r\n \r\ndef read_inline_ints():\r\n return list(map(int, sys.stdin.readline().split()))\r\n \r\ndef read_multiline_ints():\r\n return list(map(int, ' '.join(sys.stdin.readlines()).split()))\r\n \r\ndef convert_2d(L, cols):\r\n return [L[k:k+cols] for k in range(0, len(L), 2)]\r\n \r\nyes, no = \"YES\", \"NO\"\r\n \r\n# -------------------- solution code below --------------------\r\n \r\nn, = read_inline_ints()\r\ndouble_cola = 'Sheldon Leonard Penny Rajesh Howard'.split()\r\nmultiplier = 1\r\nmembers = 5\r\nwhile n > members * multiplier:\r\n n -= members * multiplier\r\n multiplier *= 2\r\nbin = 0\r\nwhile n > multiplier:\r\n n -= multiplier\r\n bin += 1\r\nprint(double_cola[bin])", "n = int(input())\r\n\r\nqueue =[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nif n <= 5:\r\n print(queue[n-1])\r\n\r\nelse:\r\n\r\n a = 0\r\n b = n\r\n c = 5\r\n d = 1\r\n \r\n while a + c <= n :\r\n a += c #cola khorde shode dar har marhale\r\n c *= 2 #azayi ke marhale bad ezafe mishan\r\n d *= 2 #tedad har esm dar marhale\r\n b = n - a #tedade cola haye mande dar har marhale\r\n \r\n e = (b // d)\r\n if(b // d == b / d):\r\n e -= 1\r\n print(queue[e])", "# DIDN'T FIGURE THIS OUT ON MY OWN\r\n\r\n\r\n# While loop for testing purposes; allows testing until end of input\r\nwhile True:\r\n try:\r\n n=int(input())-1 # Takes input and subtracts it by 1 since array indices begin at 0\r\n\r\n # Array of friends\r\n friends=['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\r\n # Integer variable storing the number of friends\r\n numFriends=len(friends)\r\n\r\n # Runs while n is greater than the max index of the array\r\n while n>(numFriends-1):\r\n n=(n-numFriends)# First substracts the total number of friends from n...\r\n n=(n//2) # ...then divides the difference by 2, and floors the result\r\n\r\n print(friends[n]) # Prints the friend at index n\r\n except (EOFError, ValueError):\r\n exit()\r\n", "n=int(input())\r\ns=1\r\ne=5\r\ng=1\r\nl=5\r\nwhile n>e:\r\n g*=2\r\n e=e+5*g\r\n l=l*2\r\n\r\nc=l//5\r\nr=[\"Howard\",\"Rajesh\",\"Penny\",\"Leonard\",\"Sheldon\"]\r\nv=e-c+1\r\nj=0\r\nwhile True:\r\n \r\n \r\n if n<=e and n>=v:\r\n print(r[j])\r\n break\r\n elif j>=4:\r\n j=0\r\n else:\r\n j+=1\r\n \r\n v=v-c\r\n e=e-c", "a = [0, 5, 15, 35, 75, 155, 315, 635, 1275, 2555, 5115, 10235, 20475, 40955, 81915, 163835, 327675, 655355, 1310715, 2621435, 5242875, 10485755, 20971515, 41943035, 83886075, 167772155, 335544315, 671088635, 1342177275]\r\nn=int(input())\r\ni=0\r\nwhile a[i]<n:\r\n i+=1\r\ni-=1\r\nb=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(b[(n-a[i])//((a[i+1]-a[i])//5)-(n<=5)])", "from math import ceil,floor,log2\nans=['Sheldon','Leonard','Penny', 'Rajesh', 'Howard']\nn=int(input())\nk=floor(log2((n+4)/5))\nturn=n-(5*(2**k-1))\nprint(ans[ceil(turn/2**k)-1])\n", "x = int(input()) - 1\r\nx2 = 5\r\nwhile x - x2 >= 0:\r\n x -= x2\r\n x2 *= 2\r\nprint((\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\")[x // (x2 // 5)])", "import math\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\ni = -1\r\ns = 0\r\nwhile s < n:\r\n i = i + 1\r\n s = s + 5 * pow(2,i)\r\ns = n - s + 5 * pow(2,i)\r\nprint(names[math.ceil(s / (pow(2,i)))-1])", "arr = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn = int(input())\ni = 1\nwhile i * 5 < n:\n n -= i * 5\n i *= 2\nprint(arr[(n - 1) // i])\n", "import sys\r\nimport math\r\ndef doublecola(n):\r\n names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n i = 0\r\n if n > 5:\r\n n += 5\r\n if n <= 5:\r\n interval = 5\r\n else:\r\n while n > (2**i)*5:\r\n i += 1\r\n \r\n interval1 = (2**(i-1))*5\r\n\r\n\r\n\r\n if n <= 5:\r\n if n <= 1:\r\n print(names[0])\r\n return\r\n if n <= 2:\r\n print(names[1])\r\n return\r\n if n <= 3:\r\n print(names[2])\r\n return\r\n if n <= 4:\r\n print(names[3])\r\n return\r\n if n <= 5:\r\n print(names[4])\r\n return\r\n else:\r\n if n <= interval1+(interval1/5)*1:\r\n print(names[0])\r\n return\r\n if n <= interval1+(interval1/5)*2:\r\n print(names[1])\r\n return\r\n if n <= interval1+(interval1/5)*3:\r\n print(names[2])\r\n return\r\n if n <= interval1+(interval1/5)*4:\r\n print(names[3])\r\n return\r\n if n <= interval1+(interval1/5)*5:\r\n print(names[4])\r\n return\r\n\r\n \r\ndoublecola(int(input()))", "n = int(input())\r\nn-=1\r\n\r\nwhile n>=5:\r\n\tn -= 5\r\n\tn //= 2\r\n\r\narr = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nprint(arr[n])\r\n", "#!/usr/bin/env python3\n\n\ndef main():\n n = int(input()) - 1\n p = 0\n while 5*2**p <= n:\n n -= 5*2**p\n p += 1\n\n people = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n print(people[n // 2**p])\n\n\nif __name__ == '__main__':\n main()\n", "import math\r\nn=int(input())\r\n\r\na=['Sheldon','Sheldon','Leonard','Penny','Rajesh','Howard']\r\nc=1\r\nfor i in range(1*pow(10,9)):\r\n if c+5*pow(2,i)<=n:\r\n c=c+5*pow(2,i)\r\n else:\r\n c=(n-c+1)\r\n c=math.ceil(c/(pow(2,i-1)*2))\r\n break\r\nprint(a[c])\r\n ", "p=['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\nn = int(input())-1\nwhile (n>4):n = n-5>>1\nprint(p[n])\n \t\t \t\t\t\t\t\t\t \t \t\t \t \t", "import math\n\nn = int(input())\n\ns = \"Sheldon\"\nl = \"Leonard\"\np = \"Penny\"\nr = \"Rajesh\"\nh = \"Howard\"\n\n\n# r = math.floor(math.log(n, 5))\n#\n# print(n % r)\n\nnums = [0, 5]\nnew_num = 5\nwhile True:\n new_num *= 2\n if new_num >= 10e9:\n nums.append(nums[-1] + new_num)\n break\n nums.append(nums[-1] + new_num)\n\n\ndef bin(x, l, r):\n if l > r:\n return l\n\n m = (l + r) // 2\n if x < nums[m]:\n return bin(x, l, m - 1)\n elif x > nums[m]:\n return bin(x, m + 1, r)\n else:\n return m\n\n\nif True:\n# for n in range(1, 120):\n# print(nums)\n i = bin(n, 0, len(nums))\n\n # print(\"i\", i)\n\n left = nums[i - 1]\n right = nums[i]\n range = right - left\n\n # print(\"left\", left)\n # print(\"right\", right)\n # print(\"range\", range)\n\n result = (n - left) / range\n # print(\"\\tn =\", n, \"result =\", result)\n # print(\"\\t\\t\", end=\"\")\n if result <= 0.2:\n print(s)\n elif result <= 0.4:\n print(l)\n elif result <= 0.6:\n print(p)\n elif result <= 0.8:\n print(r)\n else:\n print(h)\n", "n=int(input())-1\r\nwhile n>4:\r\n n=n-5>>1\r\nprint([\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"][n])", "import math\n\n\ndef solution():\n names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n rank = int(input())\n\n accum, name_count, prev_accum, power = 0, len(names), 0, 1\n while True:\n accum += name_count\n if rank > accum:\n prev_accum = accum\n name_count += name_count\n power += 1\n continue\n\n name_index = (rank - prev_accum - 1) // int(math.ceil(math.pow(2.0, power - 1)))\n print(names[name_index])\n break\n\n\nif __name__ == \"__main__\":\n solution()\n", "a = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nx = 0\r\nk = 1\r\nn = int(input())\r\nwhile(x + len(a) * k < n):\r\n x += len(a) * k\r\n k *= 2\r\nprint(a[((n - x - 1) // k)])", "#82A doubel cola\r\n#['Sheldon','Leonard','Penny','Rajesh','Howard']\r\n\r\na=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn= input()\r\nn=int(n)\r\nn=(n-1)\r\ni= 5\r\nwhile n>=i:\r\n n-=i\r\n i*= 2\r\np=(i/5)\r\np=(n/p)\r\np=int(p)\r\n\r\nprint (a[p])", "a=int(input())\r\nd=0\r\ni=0\r\nwhile d<a:\r\n\tb=d\r\n\td+=5*(2**i)\r\n\ti+=1\r\ni=i-1\r\nc=0\r\nwhile (b<a):\r\n\tb+=2**(i)\r\n\tc+=1\r\n\r\nif c==0 or c==5:\r\n\tprint(\"Howard\")\r\nelif c==1:\r\n\tprint(\"Sheldon\")\r\nelif c==2:\r\n\tprint(\"Leonard\")\r\nelif c==3:\r\n\tprint(\"Penny\")\r\nelse:\r\n\tprint(\"Rajesh\")", "names = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nn = int(input())\r\ni = 1\r\nn -= 1\r\nwhile i*5 <= n:\r\n\tn -= i*5\r\n\ti *= 2\r\nprint(names[n//i])", "n = int(input())\r\nout = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"];\r\n\r\ni = 1;\r\nwhile 5*(i-1) < n:\r\n\ti*=2\r\n\r\ni//=2\r\nn -= 5*(i-1)\r\nprint(out[(n-1) // i]);\r\n", "n = int(input())\r\nb = 0\r\na = 0\r\nwhile n > 0:\r\n a = 5 * 2**b\r\n b += 1\r\n n -= a\r\n\r\nn += a\r\n\r\nif n / a <= 0.2:\r\n print(\"Sheldon\")\r\nelif n / a <= 0.4:\r\n print(\"Leonard\")\r\nelif n / a <= 0.6:\r\n print(\"Penny\")\r\nelif n / a <= 0.8:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "n=int(input())\r\nnames=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\" ]\r\ninc=1\r\n\r\nwhile 5*inc<n:\r\n n=n-5*inc\r\n inc=inc*2\r\nprint(names[int((n-1)/inc)])\r\n", "import sys\r\nfrom functools import lru_cache, cmp_to_key\r\nfrom heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max\r\nfrom math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log\r\nfrom collections import defaultdict as dd, deque, Counter as c\r\nfrom itertools import combinations as comb, permutations as perm\r\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\r\nfrom fractions import Fraction\r\n# sys.setrecursionlimit(2*pow(10, 6))\r\n# sys.stdin = open(\"input.txt\", \"r\")\r\n# sys.stdout = open(\"output.txt\", \"w\")\r\nmod = pow(10, 9) + 7\r\nmod2 = 998244353\r\ndef data(): return sys.stdin.readline().strip()\r\ndef out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var))+end)\r\ndef l(): return list(sp())\r\ndef sl(): return list(ssp())\r\ndef sp(): return map(int, data().split())\r\ndef ssp(): return map(str, data().split())\r\ndef l1d(n, val=0): return [val for i in range(n)]\r\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\r\n\r\n\r\ndp = [0] * 30\r\ni = 0\r\nwhile True:\r\n # print(pow(2, i) * 5)\r\n dp[i+1] = pow(2, i) * 5 + dp[i]\r\n if dp[i] > mod:\r\n break\r\n i += 1\r\narr = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(data())\r\ntemp = bl(dp, n)-1\r\nif temp:\r\n n -= dp[temp]\r\n temp = pow(2, temp)\r\n out(arr[ceil(n / temp) - 1])\r\nelse:\r\n out(arr[n-1])\r\n", "def find_interval(n):\n t = 0\n end = 5 * (2 ** t)\n while end < n:\n t += 1\n end += 5 * (2 ** t)\n \n start = 1 + end - 5 * (2 ** t)\n\n return (start, end)\n\n\ndef find_grp_num(s, e):\n return (e - s + 1) // 5\n\n\nnames = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\nn = int(input())\n\n(s, e) = find_interval(n)\ngrp = find_grp_num(s, e)\n\nfor name in names:\n if s <= n <= (s + grp - 1):\n print(name)\n break\n s += grp", "n = int(input()) - 1\r\n\r\narr = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\r\nwhile n > 4:\r\n n = n-5 >> 1\r\n\r\nprint(arr[n])", "import math\r\nn = int(input())\r\nif math.log((n/5+1),2) % 1 == 0:\r\n print('Howard')\r\nelse:\r\n x = 1\r\n while 5*(2**x-1) < n:\r\n x += 1\r\n x = x-1\r\n p = 5*(2**x-1)\r\n d = n-p\r\n if d <= 2**x:\r\n print('Sheldon')\r\n elif 2**x < d <= (2**x)*2:\r\n print('Leonard')\r\n elif (2**x)*2 < d <= (2**x)*3:\r\n print('Penny')\r\n elif (2**x)*3 < d <= (2**x)*4:\r\n print('Rajesh')\r\n else:\r\n print('Howard')", "x = 0\r\nglobal q\r\nb = int(input())\r\nfor q in range(0, 100000):\r\n x += 5*2**q\r\n if x>= b:\r\n break\r\nprev = x - 5*2**q\r\n\r\nserial = b - prev\r\n\r\nz = serial/(2**q)\r\nif z<=1:\r\n print(\"Sheldon\")\r\nelif z<=2:\r\n print(\"Leonard\")\r\nelif z<=3:\r\n print(\"Penny\")\r\nelif z<=4:\r\n print(\"Rajesh\")\r\nelif z<=5:\r\n print(\"Howard\")\r\n\r\n", "names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn = int(input())\nr = 1\nif n<=5:\n print(names[n-1])\nelse:\n while r * 5 < n:\n n = n - (r*5)\n r = r * 2\n k = n//r\n\n\n print(names[k])", "def cycle_find(i: int):\n\n cycle = 0\n sum = 5 * (2 ** cycle)\n prev_sum = 0\n while sum < i:\n prev_sum = sum\n cycle += 1\n res = 5 * (2 ** cycle)\n sum += res\n\n return cycle, prev_sum\n\n\ndef main():\n\n f_map = {1: \"Sheldon\", 2: \"Leonard\", 3: \"Penny\", 4: \"Rajesh\", 5: \"Howard\"}\n integer = int(input())\n\n cycle_n = cycle_find(integer)[0]\n prev_sum_n = cycle_find(integer)[1]\n\n f_per_q = 2 ** cycle_n\n\n remainder = integer - prev_sum_n\n\n ans = -(-remainder // (2 ** cycle_n))\n\n return f_map[ans]\n\n\nif __name__ == '__main__':\n print(main())\n", "import math\r\nn=int(input())\r\nte=n\r\nn=(n/5)+1\r\nm=math.ceil((math.log(n,2)))\r\nm=m-1\r\nk=(5*(2**(m+1)-1))-(5*2**m)\r\nl=5*2**m\r\n \r\nmo=int(l/5)\r\np=math.ceil((te-k)/mo)\r\n\r\nif(p==1):\r\n print(\"Sheldon\")\r\nelif(p==2):\r\n print(\"Leonard\")\r\nelif(p==3):\r\n print(\"Penny\")\r\nelif(p==4):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "n = int(input())\r\nqueue = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\ntotal_sum = 5\r\nprevious_sum = 5\r\ndouble_number = 1\r\nfor i in range(1, n+ 1):\r\n if n < 6:\r\n total_sum = n\r\n elif total_sum < n:\r\n m = 2 * previous_sum\r\n double_number = int(previous_sum * 2 / 5)\r\n if m + total_sum > n:\r\n break\r\n total_sum = m + total_sum\r\n previous_sum = previous_sum * 2\r\n\r\nif n < 6:\r\n print(queue[n-1])\r\nelse:\r\n final_index = n - total_sum - 1\r\n for i in range(1, len(queue) + 1):\r\n if double_number * i > final_index:\r\n print(queue[i-1])\r\n break", "l=['Sheldon', 'Leonard', 'Penny', 'Rajesh','Howard']\r\nn=int(input())-1\r\nwhile n>4:\r\n n=n-5>>1\r\nprint(l[n])\r\n", "a=int(input())\r\nb=5\r\nc=5\r\nwhile b<a:\r\n\tc=2*c\r\n\tb+=c\r\nd=(b-(b-c))//5\r\nif a==5 or (a<=b and a>(b-d)):\r\n\tprint('Howard')\r\nelif a==4 or (a<=(b-d) and a>(b-(2*d))):\r\n\tprint('Rajesh')\r\nelif a==3 or (a<=(b-(2*d)) and a>(b-(3*d))):\r\n\tprint('Penny')\r\nelif a==2 or (a<=(b-(3*d)) and a>(b-(4*d))):\r\n\tprint('Leonard')\r\nelse:\r\n\tprint('Sheldon')", "def main():\r\n dic = {0: 'Sheldon', 1: 'Leonard', 2: 'Penny', 3: 'Rajesh', 4: 'Howard'}\r\n n = int(input())\r\n n -= 1\r\n while n >= 5:\r\n n -= 5\r\n n = n // 2\r\n print(dic[n])\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "\r\nfrom math import ceil\r\n\r\nimport io, os, sys\r\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\nprint = lambda x: sys.stdout.write(str(x) + \"\\n\")\r\n \r\nII = lambda: int(input())\r\nMII = lambda: map(int, input().split())\r\nLMII = lambda: list(MII())\r\n#SLMII = lambda: sorted(LMII())\r\n\r\nnames = {1: \"Sheldon\", 2: \"Leonard\", 3: \"Penny\", 4: \"Rajesh\", 5: \"Howard\"}\r\nn = II()\r\n\r\nt = 5\r\nk = 0 \r\nwhile 2*t < n+5:\r\n t *= 2\r\n k += 1\r\n \r\nans = ceil((n+5-t)/(t//5))\r\nprint(names[ans])\r\n\r\n", "import math\nn=int(input())\narr=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn-=1\nwhile n>=5:\n n-=5\n n=n//2\nprint(arr[n])", "n=int(input())-1\nwhile n>4:n=n-5>>1\nprint([\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"][n])\n \t \t \t\t\t \t\t \t \t\t\t\t \t\t \t \t", "from math import log2\nx = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\nn = int(input())\ny = int(log2(n / 5 + 1))\nprint(x[(n - 5 * (2 ** y - 1) - 1) // (2 ** y)])", "m=int(input())\nar=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\ng=1\nwhile(g*5<m):\n m-=g*5\n g*=2\nprint(ar[(m-1)//g])\n \t \t\t \t\t \t\t\t\t\t\t \t \t\t \t", "import sys\r\nimport math\r\nfrom sys import stdin, stdout\r\n \r\n# TAKE INPUT\r\ndef get_ints_in_variables():\r\n return map(int, sys.stdin.readline().strip().split())\r\ndef get_int(): return int(input())\r\ndef get_ints_in_list(): return list(\r\n map(int, sys.stdin.readline().strip().split()))\r\ndef get_list_of_list(n): return [list(\r\n map(int, sys.stdin.readline().strip().split())) for _ in range(n)]\r\ndef get_string(): return sys.stdin.readline().strip()\r\n \r\ndef main():\r\n n = int(input())\r\n arr = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n if n <= 5:\r\n print(arr[n-1])\r\n return\r\n x = 0\r\n for i in range(0, 5):\r\n a = 5\r\n b = a+x\r\n c = 2\r\n y = 2\r\n while True:\r\n # print(i, b, b+c)\r\n if n > b and n <= b+c:\r\n print(arr[i])\r\n return\r\n elif b+c > n:\r\n break\r\n else:\r\n a = a+a\r\n b = b + a + (i*y)\r\n y = y*2\r\n c += c\r\n x += 2\r\n \r\n \r\n\r\n\r\n\r\n\r\n \r\n# calling main Function\r\nif __name__ == \"__main__\":\r\n main()", "\r\nn = int(input())\r\np = 0\r\nwhile 5 * (2 ** p) < n:\r\n n = n - 5*(2**p)\r\n p += 1\r\nx = (n - 1)//(2**p)\r\ny = ['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nprint(y[x])\r\n\r\n ", "a,b=int(input()),5\r\nwhile a>b:a-=b;b*=2\r\nprint(['Sheldon','Leonard','Penny','Rajesh','Howard'][(5*a-1)//b])", "from math import floor, log2\n\nn = int(input())\nn -= 1\n# Sn = a1 * (1-rn) / (1-r) = n\n# 5 * (1 - 2^k) / (1 - 2) = n\n# 2^k - 1 = n / 5\n# k = log2(n / 5 + 1)\nk = floor(log2(n / 5 + 1))\nn -= 5 * (1 - 2 ** k) // (1 - 2)\nres = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][n // (2 ** k)]\nprint(res)\n", "import math\r\nfrom collections import defaultdict, Counter, deque\r\n\r\nINF = float('inf')\r\n\r\ndef gcd(a, b):\r\n\twhile b:\r\n\t\ta, b = b, a%b\r\n\treturn a\r\n\r\ndef isPrime(n):\r\n\tif (n <= 1): \r\n\t\treturn False\r\n\ti = 2\r\n\twhile i ** 2 <= 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\r\ndef vars():\r\n\treturn map(int, input().split())\r\n\r\ndef array():\r\n\treturn list(map(int, input().split()))\r\n\r\n\r\ndef main():\r\n\tn = int(input())\r\n\tqueue = [ 'Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\tif n <= 5:\r\n\t\tprint(queue[n - 1])\r\n\telse:\r\n\t\tp = 0\r\n\t\tprev = None\r\n\t\tnum = ((2 ** p) * 5)\r\n\t\twhile num < n:\r\n\t\t\tp += 1\r\n\t\t\tprev = (num, p)\r\n\t\t\tnum += ((2 ** p) * 5)\r\n\t\t# print(prev)\r\n\t\tn -= prev[0]\r\n\t\tn = (n // (2 ** (prev[1])))\r\n\t\tprint(queue[n])\r\n\r\n\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n\t# t = int(input())\r\n\tt = 1\r\n\tfor _ in range(t):\r\n\t\tmain()\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n = int(input())\ni = 0\nnames = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nwhile n-(2**i)*5 > 0:\n n -= (2**i)*5\n i += 1\nb = 2**i\nfor k in range(5):\n if k<4 and k*b<n and n<=(k+1)*b:\n break\nprint(names[k]) ", "def find_person_name(n):\r\n queue_size = 5 \r\n round = 0\r\n\r\n while n > queue_size:\r\n n -= queue_size\r\n queue_size *= 2\r\n round += 1\r\n\r\n position_in_round = (n - 1) // (2 ** round)\r\n people = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n return people[position_in_round]\r\n\r\nn = int(input())\r\nresult = find_person_name(n)\r\nprint(result)\r\n\r\n", "n = int(input())\nx = 5\nm = 5\ni = 1\nq = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nwhile(m < n):\n\tx *= 2\n\tm += x\n\ti *= 2\nm -= x\nif (n <= 5):\n\tprint(q[n-1])\nelse:\n\ttemp = n-(m)-1\n\tprint(q[temp//(i)])\n \t \t \t \t \t\t\t \t \t \t \t\t", "n=int(input())\ncc=1\ns = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nwhile(cc*5<n):\n n=n-(cc*5)\n cc*=2\nn=n-1\nn=n//cc\nprint(s[n])\n \t\t \t\t\t \t\t\t \t \t\t\t\t \t\t \t", "import math\r\nn = int(input())\r\nch = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nx = int(math.log(n//5 + 1, 2))\r\nn = n - 5*(2**x - 1)\r\nband = 2**x\r\n\r\nif n%band==0:\r\n\tc = n//band\r\nelse:\r\n\tc = n//band + 1\r\n\r\nprint(ch[c-1])", "import sys\r\n\r\nn = int(sys.stdin.readline())\r\n\r\n\r\ni = 1\r\nsum = 0\r\nwhile(n > sum):\r\n sum += 5 * i\r\n i *= 2\r\n\r\nmin = sum - (i / 2) * 5\r\nmn = i / 2\r\n\r\nif(n > min and n <= min + (1 * mn)):\r\n print(\"Sheldon\")\r\nelif(n > min + (1 * mn) and n <= min + (2 * mn)):\r\n print(\"Leonard\")\r\nelif(n > min + (2 * mn) and n <= min + (3 * mn)):\r\n print(\"Penny\")\r\nelif(n > min + (3 * mn) and n <= min + (4 * mn)):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n \r\n \r\n \r\n \r\n\r\n", "n = int(input())\r\narr = [ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ncurr = 5\r\ns = 0\r\nwhile s+curr<n:\r\n s+=curr\r\n curr = curr*2\r\n\r\nn -=s\r\nmod = curr//5\r\nidx = n//mod\r\nif n%mod==0:\r\n print(arr[n//mod-1])\r\nelse:\r\n print(arr[n//mod])\r\n", "# 0082A - Double Cola\r\n# https://codeforces.com/problemset/problem/82/A\r\ndef multiple_game(x: int, p: int, A):\r\n \"\"\"\r\n Compute x-th element in a game that \r\n each in A increases by p times in next turn.\r\n \r\n e.g., ab aabb aaabbb aaaabbbb\r\n \r\n Args: A (list, tuple, str)\r\n Return: (str, int)\r\n \"\"\"\r\n length = len(A)\r\n x -= 1\r\n i = 1\r\n while x >= i * length:\r\n x -= i * length\r\n i *= p\r\n return A[x // i]\r\n\r\ndef main():\r\n n = int(input())\r\n A = \"Sheldon, Leonard, Penny, Rajesh, Howard\".split(\", \")\r\n ans = multiple_game(n, 2, A)\r\n print(ans)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()", "initial = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nn = int(input())\r\nif n >5:\r\n ans = n\r\n rem = 5\r\n times_exec = 0\r\n while True:\r\n if (ans-rem)>=0:\r\n #print('ans',ans)\r\n times_exec+=1\r\n #print('rem',rem)\r\n ans -= rem\r\n #print('Newans',ans)\r\n rem=2*rem\r\n\r\n else:\r\n total_rem = n - ans\r\n break\r\n new_set = 2**times_exec\r\n print(initial[int(ans/new_set) + (ans%new_set>0)-1])\r\nelse:\r\n print(initial[n-1])", "n = int(input())\r\ni = 1\r\nans = 1\r\nvzs = 1\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile(i < n):\r\n i += vzs\r\n ans += 1\r\n if(ans == 6):\r\n ans = 1\r\n i += vzs\r\n vzs *= 2\r\nprint(names[ans-1])", "n = int(input()) - 1\nq = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nwhile n >= 5:\n n = n - 5\n n = n // 2\nprint (q[n])\n \t \t \t\t\t\t\t\t \t\t\t\t\t \t", "people = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\n\r\nfor i in range(0, 32):\r\n if n > 5 * 2 ** i:\r\n n -= 5 * 2 ** i\r\n else:\r\n for k in range(0, 5):\r\n if n > 2 ** i:\r\n n -= 2 ** i\r\n else:\r\n print(people[k])\r\n break\r\n break", "import math\r\nn=int(input())\r\ns=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\ni=1\r\nsum=5\r\nwhile sum<n:\r\n i*=2\r\n sum+=i*5\r\nsum-=i*5\r\nprint(s[math.ceil((n-sum)/i)-1])", "A=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn=int(input())-1\nwhile (n>4):n=n-5>>1\nprint(A[n])\n \t\t \t\t\t \t \t\t\t \t \t \t \t \t", "import math\r\nn=int(input())\r\ni=0\r\nwhile(n>5*pow(2,i)):\r\n n-=5*pow(2,i)\r\n i+=1\r\na=math.ceil(n/(pow(2,i)))\r\nif(a==1):\r\n print(\"Sheldon\")\r\nelif(a==2):\r\n print(\"Leonard\")\r\nelif(a==3):\r\n print(\"Penny\")\r\nelif(a==4):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "a = int(input())\r\ni = 1\r\ntemp = a / 5\r\nwhile temp > i:\r\n i = i * 2 + 1\r\ni = (i - 1) // 2\r\na = a - (5 * i)\r\ni += 1\r\nif (a - 1) // i == 0:\r\n print(\"Sheldon\")\r\nelif (a - 1) // i == 1:\r\n print(\"Leonard\")\r\nelif (a - 1) // i == 2:\r\n print(\"Penny\")\r\nelif (a - 1) // i == 3:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "n = int(input())\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nr = 1\r\n\r\nwhile r * 5 < n:\r\n n -= r * 5\r\n r *= 2\r\n\r\ndiv = (n - 1) // r\r\n\r\nprint(names[div])", "a = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\nx = 0\r\nn -= 1\r\nwhile 5 * (2 ** x - 1) <= n:\r\n x += 1\r\nx -= 1\r\npart = 2 ** x\r\np = 5 * (2 ** x - 1)\r\nn -= p\r\nprint(a[n // part])\r\n\r\n'''\r\n3\r\n4 1\r\n4 2\r\n6 3\r\n''' ", "n = int(input())\nnames = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nx = 1\nwhile(x*5<n):\n n= n-(x*5)\n x = x*2\nprint(names[(n-1)//x]) \n \t \t\t \t \t \t\t\t\t\t\t \t \t \t\t\t \t", "row1 = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ncount = int(input())\r\ndef foobar(n,row):\r\n now_in_row = 0\r\n m = 1\r\n while (now_in_row + m * 5 < n):\r\n now_in_row += 5 * m\r\n m *= 2\r\n to_find = n - now_in_row - 1\r\n ind = to_find // m\r\n name = row[ind]\r\n return name\r\n\r\nprint(foobar(count,row1))", "n,p=int(input()),0\r\na,b=[1,2,3,4,5],[0,1,2,3,4]\r\nc=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nif n<=5:\r\n d=a.index(n)\r\n print(c[d])\r\nelse:\r\n m=n\r\n while 5*2**p<=n:\r\n n-=5*2**p\r\n p+=1\r\n r=int(n/(2**p))\r\n d=b.index(r)\r\n print(c[d])", "import math\r\n\r\nn = int(input())\r\nx = 1\r\ncans = 5\r\noldCans = 0\r\n\r\nwhile cans < n:\r\n oldCans = cans\r\n x *= 2\r\n cans += 5 * x\r\n\r\nn -= oldCans\r\nresult = math.ceil(n * 1.0 / x)\r\n\r\nprint([\"\", \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][result])", "import math\n\n\ndef solve(n):\n i = math.ceil(math.log2(n / 5 + 1) - 1)\n amount = 2 ** i\n y = 5 * amount - 4\n normal_n = n - y\n if normal_n < amount:\n print(\"Sheldon\")\n elif normal_n < 2 * amount:\n print(\"Leonard\")\n elif normal_n < 3 * amount:\n print(\"Penny\")\n elif normal_n < 4 * amount:\n print(\"Rajesh\")\n else:\n print(\"Howard\")\n\n\nn = int(input())\nsolve(n)\n", "n = int(input())\r\nz, res = -1, 0\r\na = [1, 1, 1, 1, 1]\r\nb = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile res <= n:\r\n\tif res == n:\r\n\t\tbreak\r\n\tz = (z + 1) % 5\r\n\tres += a[z]\r\n\ta[z] *= 2\r\n\r\nprint(b[z])", "# Brute Force Method was used!\r\n\r\nn = int(input())\r\nN = n\r\npersons = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nbatch_size = 1\r\ngroup_size = 5\r\ngroup_number = 1\r\n\r\nwhile not n < group_size:\r\n n -= group_size\r\n group_size *= 2\r\n group_number += 1\r\n batch_size *= 2\r\n\r\nprevious_end = 0\r\ngroup_number -= 1\r\nwhile group_number:\r\n previous_end = previous_end*2 + 5\r\n group_number -= 1\r\n\r\n# print(\"n = {}\\ngroup size = {}\\nbatch size = {}\\nprevious end = {}\".format(n, group_size, batch_size, previous_end))\r\n\r\nindex = 0\r\nbatch_end = previous_end\r\nwhile not (N <= batch_end):\r\n batch_end += batch_size\r\n index += 1\r\n\r\n# print(\"batch end = {}\\nindex = {}\".format(batch_end, index))\r\n\r\nindex -= 1\r\nprint(persons[index])", "# Double_Cola.py\nimport math\nn,sum,index = int(input()),1,1\nwhile(5*sum<n):\n sum = sum + (2*index)\n index = 2*index\nsum_old = sum - (2*(index/2))\nfinal_number =int(n-(5*sum_old))\ndecision = math.ceil(final_number/index)\nif decision == 1:\n print(\"Sheldon\")\nelif decision == 2:\n print(\"Leonard\")\nelif decision == 3:\n print(\"Penny\")\nelif decision == 4:\n print(\"Rajesh \")\nelse:\n print(\"Howard \")", "def who_is_next(names, r):\r\n calculation = True\r\n start, end, i = 1, 0, 0.5\r\n while calculation:\r\n i *= 2\r\n end += i * len(names)\r\n if r <= end:\r\n step_back = (i * len(names)) // len(names)\r\n for index in range(len(names)):\r\n end -= step_back\r\n if r > end:\r\n return names[-(index + 1)]\r\n calculation = False\r\n return None\r\n\r\n\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\nprint(who_is_next(names, n))", "a=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn=int(input())-1\r\ni=5\r\nwhile n>=i:\r\n n-=i\r\n i*=2\r\nprint(a[n//(i//5)])", "x = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\r\nn = int(input())\r\nn -= 1\r\n\r\nwhile n >= 5 :\r\n n -= 5\r\n n //= 2\r\n\r\nprint(x[n])", "'''\r\nYandex 2011 kval 2\r\n@Yergali B\r\n'''\r\na=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\" ]\r\nn=int(input())-1\r\nwhile n>4:\r\n n=n-5>>1\r\nprint(a[n])", "import math\n\nfriends = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\n\nclass Solution82A:\n def __init__(self):\n self.result = \"\"\n self.n = 0\n\n def parse_input(self):\n self.n = int(input())\n\n def solve(self):\n self.result = friends[self.get_friend_position(self.n - 1)]\n\n @staticmethod\n def get_friend_position(n, base=len(friends)):\n if n < base:\n return math.floor(n * len(friends) / base)\n return Solution82A.get_friend_position(n - base, 2 * base)\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n solution = Solution82A()\n solution.parse_input()\n solution.solve()\n print(solution.get_result())\n", "def chuck (n):\r\n q_size = 5\r\n drank = 0\r\n times = 0\r\n while drank + q_size < n :\r\n drank += q_size\r\n q_size *= 2\r\n times += 1\r\n\r\n each = 2**times\r\n left = n - drank\r\n if left%each == 0:\r\n return left//each -1\r\n else:\r\n return left//each\r\n\r\n\r\nref = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\n\r\nn = int(input())\r\nprint (ref[chuck(n)])\r\n \r\n \r\n \r\n \r\n\r\n \r\n", "a=int(input())\r\nc=0\r\nfor i in range(30):\r\n d=c\r\n c+=2**i*5\r\n if a<=c:\r\n ans=0--(a-d)//2**i\r\n print(['Sheldon','Leonard','Penny','Rajesh','Howard'][ans-1])\r\n break", "a = ['Sheldon','Leonard','Penny','Rajesh','Howard']\ninp = int(input())\nn = inp - 1\ni = 5;\nwhile n >= i:\n n -= i\n i *= 2\nprint(a[int(n / (i / 5))]);\n\n\t \t \t\t\t\t\t \t \t \t\t\t\t\t \t \t", "from math import *\nimport sys\n\np=int(input())\ndec=1\nper=1\n\nwhile(p>0):\n p-=dec\n if (per==5):\n dec*=2\n per=1\n else:\n per+=1\n\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][per-2])\n\n\t\t \t \t\t \t\t \t \t\t \t\t\t\t\t\t \t", "n = int(input())\r\ns = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\np = 0\r\na = 5*2**p\r\nwhile a<n:\r\n\tp+=1\r\n\ta+=5*2**p\r\nif p==0:\r\n\tb=0\r\nelse:\r\n\tb = a-5*2**p\r\n\r\nr = (a-b)//5\r\n\r\nd = [0]*5+[a+1]\r\nd[0]=b+1\r\nfor i in range(1,5):\r\n\td[i]=d[i-1]+r\r\n\r\nfor i in range(5):\r\n\tif d[i]<=n<d[i+1]:\r\n\t\tprint(s[i])\r\n\t\tbreak", "import math\r\nqueue = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\nval = (n+5)//5\r\ni = 0\r\nwhile 2**i <= val:\r\n\ti+=1\r\ni-=1\r\nind = math.ceil((n - 5*(2**i-1)) / (2**i))\r\nprint(queue[ind-1])\r\n", "import math\nnum = int(input())\nif num > 5:\n n = math.log(num/5+1, 2)\n n = math.ceil(n)\n #print(n)\n p_csum = 5*(2**(n-1)-1)\n #print(p_csum)\n res = (num-p_csum)//(2**(n-1)) + 1\n #print(\"RES:\", res)\nelse:\n res = num\nif res == 1:\n print(\"Sheldon\")\nelif res == 2:\n print(\"Leonard\")\nelif res == 3:\n print(\"Penny\")\nelif res == 4:\n print(\"Rajesh\")\nelif res == 5:\n print(\"Howard\")", "queue=['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\nn=int(input())\n\nj=0\n\nv=0\nv2=0\nwhile (True):\n v2=v\n\n v+=5*2**(j)\n if v>=n:\n break\n j+=1\n\n\nh=n-v2\n#print(h,'aa',v2,'ll',j)\n\nr=h/(5*2**j)\n#print(5*2**j)\n#print(r,'-')\nif r==0:\n print(queue[4])\nelif r<=1/5:\n print(queue[0])\nelif r<=2/5:\n print(queue[1])\nelif r<=3/5:\n print(queue[2])\nelif r<=4/5:\n print(queue[3])\nelse:\n print(queue[4])\n\n\n\n\n# q=[1,1,1,1,1]\n\n\n# n=int(input())\n\n# j=0\n# temp=1\n# for i in range (2,n+1): \n# temp-=1\n# if temp==0:\n# q[j]*=2\n# j+=1\n# if j>4:\n# j=0\n# temp=q[j]\n \n\n# print(queue[j])\n \n\n \n ", "m=int(input())\narr=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nr=1\nwhile(r*5<m):\n m-=r*5\n r*=2\nprint(arr[(m-1)//r])\n \t\t \t \t \t\t\t \t\t\t\t \t \t \t\t \t", "__author__ = 'Utena'\r\nimport math\r\nn=int(input())\r\nt=5\r\nm=5\r\nwhile t<n:\r\n n-=t\r\n t=t*2\r\nl=math.ceil(5*n/t)\r\nif l==1:print(\"Sheldon\")\r\nif l==2:print(\"Leonard\")\r\nif l==3:print(\"Penny\")\r\nif l==4:print(\"Rajesh\")\r\nif l==5:print(\"Howard\")", "n = int(input())\r\nk = 1\r\npeople = [0, \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile 5 * (2 ** k - 1) <= n:\r\n k += 1\r\n\r\nl = 5 * (2 ** (k - 1) - 1)\r\nt = 5 * (2 ** k - 1)\r\nres = 0\r\nfor i in range(l, t + 1, 2 ** (k-1)):\r\n if i >= n:\r\n break\r\n else:\r\n res += 1\r\nif res != 0:\r\n print(people[res])\r\nelse:\r\n print(people[-1])", "import math\r\nn=int(input())\r\ns=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\ni=1\r\ncnt=1\r\np=5\r\nwhile(n>p):\r\n cnt*=2\r\n p+=(5*cnt)\r\nk=p-cnt*5\r\nn-=k\r\nprint(s[int(math.ceil(n/cnt))-1])", "\r\nimport math\r\n\r\nn = int(input())\r\ncurrent_queue = int(math.log1p(((n + 5)/ 5) - 1) / math.log1p(2 - 1)) + 1\r\nif current_queue == math.log1p(((n + 5)/ 5) - 1) / math.log1p(2 - 1) + 1:\r\n current_queue -= 1 # index gives accurate int element \r\nplaces_behind = 5 * ((1 - pow(2,current_queue - 1)) / -1)\r\nn -= places_behind\r\nx = pow(2,current_queue - 1) # starting from 0 \r\nif n <= x: print(\"Sheldon\")\r\nelif n <= 2 * x: print(\"Leonard\")\r\nelif n <= 3 * x: print(\"Penny\")\r\nelif n <= 4 * x: print(\"Rajesh\")\r\nelif n <= 5 * x: print(\"Howard\")\r\n\r\n# last problem: on the last place of every queue. \r\n# current queue is equal to exactly \r\n# the (number of places behind + current queue places) so there is no need\r\n# to add + 1 after\r\n\r\n# the idea of the solution from math is that:\r\n# 1.try to calculate the number of full queues behind your actual one (DONE)\r\n# 2.Calculate how many places there are on these full queues behind together (DONE)\r\n# 3.Substract: X = Index -= places behind you (on these last queues without current)\r\n# 4.calculate how many \"persons\" are on every single one: (2^(current_number_of_queue - 1))\r\n# 5. Check one by one if this value X is greater than amount of appereance of every\r\n# person on this stage. if X is <= person_number * (2 ^(current_queue - 1)) write name\r\n", "m=int(input())\nar=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nr=1\nwhile(r*5<m):\n m-=r*5\n r*=2\nprint(ar[(m-1)//r])\n\t \t\t \t \t \t\t \t\t\t \t \t \t\t\t\t", "n=int(input())\r\nt=0\r\nj=5\r\ni=1\r\nwhile True:\r\n\tif (t+j)>=n:\r\n\t\tbreak\r\n\telse:\r\n\t\tt+=j\r\n\t\tj+=j\r\n\t\ti+=i\r\nl=n-t\r\nans=l//i\r\nif l%i!=0:\r\n\tans+=1\r\nif ans==1:\r\n\tprint(\"Sheldon\")\r\nelif ans==2:\r\n\tprint(\"Leonard\")\r\nelif ans==3:\r\n\tprint(\"Penny\")\r\nelif ans==4:\r\n\tprint(\"Rajesh\")\r\nelse:\r\n\tprint(\"Howard\")", "#coded by gautham on 25/6\r\nimport math\r\nn=int(input())\r\nl=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nk=1\r\nwhile n>k*5:\r\n n=n-5*k\r\n k=k*2\r\ns=math.ceil(n/k)\r\nprint(l[s-1])\r\n", "n=int(input())\r\nnames=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\ncount=0\r\nj=1\r\ni=0\r\nwhile count<n:\r\n if i==len(names):\r\n i=0\r\n j*=2\r\n count+=j\r\n i+=1\r\nprint(names[i-1])", "n=int(input())\r\ni=1\r\nwhile n>0:\r\n n-=5*i\r\n i*=2\r\ni/=2\r\nn+=5*i\r\na=int((n-1)/i)\r\nif a==0:\r\n print(\"Sheldon\")\r\nelif a==1:\r\n print(\"Leonard\")\r\nelif a==2:\r\n print(\"Penny\")\r\nelif a==3:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "n=int(input())-1\r\na=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile(n>=5):\r\n n=(n-5)//2\r\nprint(a[n])", "def start_positions(initial):\n\tcurrent = initial\n\twhile True:\n\t\tyield current\n\t\tcurrent = (current << 1) + 4\n\nn = int(input())\nnames = [\"\", \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\nfor i in range(1, 6):\n\tloops = 0\n\tcurr = i\n\tfor j in start_positions(i):\n\t\tif j > n:\n\t\t\tbreak\n\t\tcurr = j\n\t\tloops = loops + 1\n\t\n\tif curr <= n < curr + (1 << (loops - 1)):\n\t\tprint(names[i])\n\t\tbreak\n", "\nn=int(input())-1\nwhile n>4:\n n=n-5>>1\nprint([\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"][n])", "n=int(input())\nname=['Sheldon','Leonard','Penny','Rajesh','Howard']\ni=1\nwhile n>0:\n n-=i*5\n i*=2\ni=i//2\nn+=i*5\nprint(name[-((-n)//i)-1])", "def log2(v):\r\n if v == 1:\r\n return 0\r\n return 1 + log2(v >> 1)\r\n\r\nn = int(input()) - 1\r\nn5 = n // 5 + 1\r\n\r\nn_round = log2(n5)\r\n\r\nif n_round:\r\n q1 = n - ((5 << n_round) - 5)\r\n q = q1 // (1 << n_round) \r\nelse:\r\n q = n\r\n\r\nprint((\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\" )[q])\r\n\r\n", "def nthPerson(n):\r\n queue = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n rate = 1\r\n while len(queue) * rate <= n:\r\n n = n - len(queue) * rate\r\n rate *= 2\r\n return queue[(n - 1) // rate]\r\n\r\nprint(nthPerson(int(input())))", "from math import log\nt = ('Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard')\nn = int(input()) - 1\nx = int(log(n / 5 + 1, 2))\nprint(t[int((n - (2 ** x - 1) * 5) / 2 ** x)])\n", "def find(n,p,m):\r\n x=(((n-1)*(m-1))//p)+1\r\n c=0\r\n while x>0:\r\n x = x//m\r\n c += 1\r\n x=p*(((m**(c-1))-1)//(m-1))\r\n n = n-x\r\n size=(m**(c-1))\r\n ans = ((n-1)//size)+1\r\n return ans\r\n\r\nnames=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn=int(input())\r\nprint(names[find(n,len(names),2)-1])", "g=int(input())\ns=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\ny=1\nwhile(y*5<g):\n g=g-y*5\n y=y*2\nprint(s[(g-1)//y])\n \n \t \t \t\t \t \t\t \t\t\t\t \t \t\t\t \t\t \t\t\t\t", "n = int(input())\n\nlength = 5\ntwo = 1\n\nwhile n > length:\n n -= length\n length *= 2\n two *= 2\n\nindex = [n//two, (n//two)-1][n % two == 0]\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][index])\n\n", "import math\r\nn = int(input())\r\nr = math.log(((n+4)/5), 2.0)\r\ni, d = divmod(r, 1)\r\ni += 1\r\nrangeBegin = 5 * (2**(i-1)) - 4\r\nrangeEnd = 5 * (2**(i)) - 4\r\ninterval = (rangeEnd -rangeBegin)/5\r\nif rangeBegin <= n < rangeBegin + interval:\r\n print(\"Sheldon\")\r\nelif rangeBegin + interval <= n < rangeBegin + 2*interval:\r\n print(\"Leonard\")\r\nelif rangeBegin + 2*interval <= n < rangeBegin + 3*interval:\r\n print(\"Penny\")\r\nelif rangeBegin + 3*interval <= n < rangeBegin + 4*interval:\r\n print(\"Rajesh\")\r\nelif rangeBegin + 3*interval <= n < rangeBegin + 5*interval:\r\n print(\"Howard\") ", "n=int(input())\nm=5\ni=1\nq=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nwhile(m*i<n):\n n-=m*i\n i*=2\nprint(q[(n-1)//(i)])\n\t\t\t \t\t \t \t\t\t\t\t\t\t \t\t\t \t\t\t \t\t\t\t", "import sys\nfrom math import ceil\n \nnames = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n \nn = int(sys.stdin.readline())\n \ni = 0\nj = 1\nk = len(names)\n \nwhile i <= n:\n i += k\n k += k\n j += j\n \nprint (names[int(ceil((n - (i - k * 0.5)) / (j * 0.5)) - 1)])", "n=int(input())\r\ns=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nr=1\r\nwhile(r*5<n):\r\n n-=r*5\r\n r*=2\r\nn=n-1\r\nn=n//r\r\nprint(s[n])", "n = int(input())\r\nd = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nlength = len(d)\r\na = 1\r\n\r\nwhile length * a < n:\r\n n -= a * length\r\n a *= 2\r\n \r\nprint(d[(n - 1) // a])\r\n", "# https://codeforces.com/problemset/problem/82/A\r\n\r\ndef main():\r\n n = int(input())\r\n q = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n \r\n i = 1\r\n while n > i*5:\r\n n -= i*5\r\n i *= 2\r\n \r\n print(q[(n-1)//i])\r\n \r\nif __name__ == '__main__':\r\n main() ", "import math \n\nif __name__ == \"__main__\":\n\tn = int(input())\n\ti = 0\n\tli =[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\twhile (n-5*(2**i)) > 0:\n\t\tn-=5*(2**i)\n\t\ti+=1\n\tprint(li[(n-1)//(2**i)])\n", "import sys\r\n#import bisect\r\nimport math\r\n#import itertools\r\ndef get_line(): return list(map(int,sys.stdin.readline().strip().split()))\r\ndef in1(): return int(input())\r\n\r\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nn=in1()\r\nc=5\r\ni=0\r\nt1=5\r\nif n<=5:\r\n print(a[n-1])\r\nelse:\r\n while c<n:\r\n t1=t1*2\r\n c+=t1\r\n i+=1\r\n c-=t1\r\n t1=int(math.pow(2,i))\r\n t5=int(math.pow(2,i+1))\r\n t2=n-c\r\n t3=t2//(t1)\r\n if t2%t1==0:\r\n print(a[t3-1])\r\n else:\r\n print(a[t3])\r\n\r\n\r\n\r\n\r\n", "\r\narr= [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\" ]\r\n\r\nn = int(input())\r\nc=1\r\nprev_v = 1\r\nv=6\r\ni=5\r\nmult = 1\r\nif n == 6:\r\n print(arr[0])\r\nelse:\r\n while v < n:\r\n i+=4*mult\r\n c*=2\r\n mult*=2\r\n prev_v = v\r\n v+=c-1+i\r\n\r\n if n <= 5:\r\n print(arr[n-1]) \r\n else:\r\n print(arr[(n-prev_v) // c])\r\n", "n = int(input())\r\n\r\ni = 1\r\nwhile (5 * i < n):\r\n n -= 5 * i\r\n i *= 2\r\n\r\nn -= 1\r\n# print(n,i)\r\nif n // i == 0:\r\n print('Sheldon')\r\nelif n // i == 1:\r\n print('Leonard')\r\nelif n // i == 2:\r\n print('Penny')\r\nelif n // i == 3:\r\n print('Rajesh')\r\nelse:\r\n print('Howard')", "n = int(input())\n\ncount = 5\nwhile n > count:\n n -= count\n count *= 2\n\nindex = (n - 1) // (count // 5)\nname = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][index]\nprint(name)\n\t\t \t\t \t\t\t\t \t\t\t \t\t\t \t\t \t\t", "n = int(input())\r\nx = 1\r\nwhile n > 0 :\r\n Sheldon=1\r\n n-=1\r\n if n <=0 :\r\n print(\"Sheldon\")\r\n break\r\n Leonard=1\r\n n-=1\r\n if n<= 0:\r\n print(\"Leonard\")\r\n break\r\n Penny = 1\r\n n-=1\r\n if n<= 0:\r\n print(\"Penny\")\r\n break\r\n Rajesh=1\r\n n-=1\r\n if n <=0 :\r\n print(\"Rajesh\")\r\n break\r\n Howard=1\r\n n-=1\r\n if n <=0:\r\n print(\"Howard\")\r\n break\r\n if n >0 :\r\n while n >0 :\r\n n = n - (x)*2\r\n if n <= 0 :\r\n print(\"Sheldon\")\r\n break\r\n \r\n Leonard +=2\r\n n = n - (x)*2\r\n if n <= 0 :\r\n print(\"Leonard\")\r\n break\r\n \r\n Penny +=1 \r\n n = n - (x)*2\r\n if n <=0 :\r\n print(\"Penny\")\r\n break\r\n \r\n Rajesh +=1\r\n n = n - (x)*2\r\n if n <=0 :\r\n print(\"Rajesh\")\r\n break\r\n \r\n Howard +=1\r\n n = n - (x)*2\r\n if n <=0 :\r\n print(\"Howard\")\r\n break\r\n x = (x)*2", "import math\r\nn= int(input())\r\n\r\nctl=0\r\nwhile(5*(2**(ctl) -1) < n):\r\n ctl+=1\r\nif n<6:\r\n cycle = n\r\nelse:\r\n cycle = n - 5*(2**(ctl-1)-1)\r\nans = math.ceil(cycle/2**(ctl-1))\r\n\r\nif ans==1:\r\n print('Sheldon')\r\nelif ans==2:\r\n print('Leonard')\r\nelif ans==3:\r\n print('Penny')\r\nelif ans==4:\r\n print('Rajesh')\r\nelif ans==5:\r\n print('Howard')\r\nelse:\r\n print('weird')", "f = int(input())\nn = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\ng = 1\nwhile g*5 < f :\n\tf -= g*5\n\tg *= 2\nprint (n[int((f - 1) / g)])\n \t\t \t \t\t\t \t \t \t \t \t \t\t", "\r\nn= int(input())\r\n\r\nr=1\r\nwhile(5*r<n):\r\n n-=5*r\r\n r*=2\r\n\r\nans = (n-1)//r + 1\r\n\r\nif ans==1:\r\n print('Sheldon')\r\nelif ans==2:\r\n print('Leonard')\r\nelif ans==3:\r\n print('Penny')\r\nelif ans==4:\r\n print('Rajesh')\r\nelif ans==5:\r\n print('Howard')\r\nelse:\r\n print('weird')", "n = int(input())\r\nn=n-1\r\nwhile n>=5:\r\n n =n- 5\r\n n =n/ 2\r\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nprint (a[int(n)])\r\n", "names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ngroups = [[name, 1] for name in names]\r\n\r\nn = int(input())\r\nidx = 0\r\nwhile n > 0:\r\n n -= groups[idx % len(groups)][1]\r\n if n <= 0:\r\n print(groups[idx % len(groups)][0])\r\n break\r\n groups[idx % len(groups)][1] *= 2\r\n idx += 1\r\n", "arr = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\nx=1\r\nwhile n>5*x:\r\n n-=5*x\r\n x*=2\r\nn = (n-1)//x\r\nprint(arr[n])", "n = int(input())\r\n\r\nr,t = 0,0\r\nwhile t < n:\r\n r += 1\r\n t += 5*(2**(r-1))\r\n \r\np = n-t+5*(2**(r-1))\r\n \r\nselv = 2**(r-1)\r\n\r\nif p <= selv:\r\n print('Sheldon')\r\nelif selv < p and p <= 2*selv:\r\n print('Leonard')\r\nelif 2*selv < p and p <= 3*selv:\r\n print('Penny')\r\nelif 3*selv < p and p <= 4*selv:\r\n print('Rajesh')\r\nelif 4*selv < p and p <= 5*selv:\r\n print('Howard')", "n = int(input())\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nit = 1\r\nj = 0\r\nwhile n > 0:\r\n n -= it\r\n if n <= 0:\r\n break\r\n j += 1\r\n if j == 5:\r\n j = 0\r\n it *= 2\r\nprint(names[j])", "start = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nni = int(input())\r\nn = 0\r\nc = 0\r\nln= [0] \r\nwhile True:\r\n\r\n\tn = 5*(2**(c+1)-1)\r\n\r\n\tif n <= ni:\r\n\t\tln.append(n)\r\n\t\tc += 1\r\n\telse:\r\n\t\tbreak\r\n\r\nn = ln[-1]\r\n\r\nstep = 2**(c)\r\n\r\ndiff = (ni - n)/step\r\n\r\nif diff - int(diff) == 0:\r\n\r\n\tdiff = int(diff)\r\n\r\n\tprint(start[diff-1])\r\nelse:\r\n\r\n\tprint(start[int(diff)])\r\n\r\n\r\n", "n = int(input())\n\nname_dict = {1:\"Sheldon\", 2:\"Leonard\", 3:\"Penny\", 4:\"Rajesh\", 5:\"Howard\"}\nq = {}\nfor i in range(1, 6):\n if i != 5:\n q[i] = i + 1\n else:\n q[i] = 1\n\njump = 1\nval = 1\nwhile True:\n if n == 1:\n break\n\n prev_val = val\n val = q[val]\n n -= jump\n if n < 1:\n val = prev_val\n break\n\n if val == 1:\n jump *= 2\n\nans = name_dict[val]\nprint(ans)\n", "x = int(input())-1\r\nname = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nbase = 1\r\nwhile x-base*5 >= 0:\r\n x -= base*5\r\n base *= 2\r\nprint(name[x//base])", "import bisect, math\r\n\r\ndef foo(n):\r\n p = 1\r\n while 5*p<n:\r\n n-=5*p\r\n p<<=1\r\n return [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\",\"Howard\"][(n-1)//p]\r\n\r\n \r\n# t = int(input())\r\nfor _ in range(1):\r\n n = int(input())\r\n # arr = list(map(int, input().split()))\r\n # arr.sort()\r\n # n = int(input())\r\n # for _ in range(n):\r\n # q=int(input())\r\n # print(bisect.bisect(arr, q))\r\n # x, y = map(int, input().split())\r\n # a, b = map(int, input().split())\r\n print(foo(n))\r\n # print(\" \".join(map(str, foo(n, m))))", "from math import ceil\r\ndef double_cola(n):\r\n\tbig_bang = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\ti = 0\r\n\tj = 1\r\n\tk = len(big_bang)\r\n\t \r\n\twhile i <= n:\r\n\t\ti += k\r\n\t\tk += k\r\n\t\tj += j\r\n\treturn big_bang[int(ceil((n - (i - k * 0.5)) / (j * 0.5)) - 1)]\r\n# --------------------------------------------------------------\r\nif __name__ == '__main__':\r\n n = int(input())\r\n print(double_cola(n))", "try:\r\n n = int(input())-1\r\n while n>4:\r\n n=(n-5)//2\r\n print([\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"][n])\r\nexcept:\r\n pass", "n=int(input())\r\nn-=1\r\nwhile n >= 5 :\r\n n = n - 5\r\n n = n // 2\r\npos=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nprint(pos[n])", "count = int(input())\ndata = {1: \"Sheldon\", 2: \"Leonard\", 3: \"Penny\", 4: \"Rajesh\", 5: \"Howard\"}\nposition = 1\nstepin = 0\nk = 1\nwhile True:\n if count >= position and count < position + 2**stepin:\n print(data[k])\n break\n position += 2**stepin\n if k == 5:\n stepin += 1\n k = 1\n else:\n k += 1\n", "t = int(input())\n# 0 = \"Sheldon\", 1 = \"Leonard\", 2 = \"Penny\", 3 = \"Rajesh\", 4 = \"Howard\"\n#0,1,2,3,4,0,0,1,1,2,2,3,3,4,4,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,\n\n#1->5 = Cy1 = 0 + 5\n#6->15 = Cy2 = Cy1 + 10\n#16->35 = Cy3 \n#36->75 = Cy4\n#76->155 = Cy5\n\nCyArray = [0, 5, 15, 35, 75, 155, 315, 635, 1275, 2555, 5115, 10235, 20475, 40955, 81915, 163835, 327675, 655355, 1310715, 2621435, 5242875, 10485755, 20971515, 41943035, 83886075, 167772155, 335544315, 671088635, 1342177275]\n\nCyIndex = -1\nLoopedIndex = 1\nCyFrom = -1\nCyTo = -1\nwhile CyIndex == -1:\n if(CyArray[LoopedIndex] >= t):\n CyIndex = LoopedIndex\n CyFrom = CyArray[LoopedIndex-1]\n CyTo = CyArray[CyIndex]\n LoopedIndex += 1\n#print(CyIndex,CyFrom,CyTo)\nCyRange = CyTo - CyFrom\nt -= CyFrom\nIncrementDelay = int(CyRange / 5)\n#print(IncrementDelay)\nif(t <= IncrementDelay):\n print(\"Sheldon\")\nelif (t <= IncrementDelay * 2):\n print(\"Leonard\")\nelif (t <= IncrementDelay * 3):\n print(\"Penny\")\nelif (t <= IncrementDelay * 4):\n print(\"Rajesh\")\nelif (t <= IncrementDelay * 5):\n print(\"Howard\")\n\n", "from sys import stdin\r\ninput = stdin.readline\r\npersn = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\ndef cola(n, r = 1):\r\n while r * 5 < n:\r\n n -= r * 5\r\n r <<= 1\r\n return persn[(n - 1) // r]\r\nprint(cola(int(input())))\r\n", "n = int(input())\n\nbig_bang = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\nif n < 6:\n print(big_bang[n - 1])\nelse:\n i = 0\n while n >= 5 * (2 ** i):\n n -= 5 * (2 ** i)\n i += 1\n\n idx = int((n - 1) / 2 ** i)\n print(big_bang[idx])\n", "n = int(input())\ni = 5\nwhile(i<n):\n\tn = n-i\n\ti = i*2\n\nc = n/(i/5)\nif c<=1:\n\tprint('Sheldon')\nelif c<=2:\n\tprint('Leonard')\nelif c<=3:\n\tprint('Penny')\nelif c<=4:\n\tprint('Rajesh')\nelse:\n\tprint('Howard')\n", "n=int(input())\r\np=1\r\nnames=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile 5*p<n:\r\n n-=p*5\r\n p*=2\r\nprint(names[(n-1)//p])\r\n", "n=int(input())\r\n\r\n\r\nr=1\r\nwhile((r*5)<n):\r\n n-=(r*5)\r\n r*=2\r\n \r\nname=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\n\r\nprint(name[(n-1)//r])\r\n \r\n", "# Problem: A. Double Cola\r\n# Contest: Codeforces - Yandex.Algorithm 2011: Qualification 2\r\n# URL: https://codeforces.com/problemset/problem/82/A\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\nimport math\r\nn=int(input())\r\n\r\nans=((n-5*(2**(int(math.log(n/5+1,2)))-1))-1)//(2**(int(math.log(n/5+1,2))))\r\n\r\nif ans==0:\r\n\tprint(\"Sheldon\")\r\nelif ans==1:\r\n\tprint(\"Leonard\")\r\nelif ans==2:\r\n\tprint(\"Penny\")\r\nelif ans==3:\r\n\tprint(\"Rajesh\")\r\nelse:\r\n\tprint(\"Howard\")", "ans = ['Howard', 'Rajesh', 'Penny', 'Leonard', 'Sheldon']\n\nwhile True:\n try:\n n = int(input())\n a = pos = 0\n for i in range(1, 120):\n a = int(pow(2, i)-1)*5\n if a >= n:\n pos = i-1\n break\n id = (a-n)//(pow(2, pos))\n print(ans[id])\n except EOFError:\n break\n\n\t \t\t\t\t \t \t\t \t \t \t \t \t\t\t", "from sys import stdin ,stdout \r\ninput=stdin.readline\r\ndef print(*args, end='\\n', sep=' ') -> None:\r\n stdout.write(sep.join(map(str, args)) + end)\r\nn=int(input()) ; names=['Sheldon', 'Leonard',' Penny', 'Rajesh', 'Howard'] ; summ=0 ; a=1\r\nwhile summ<n:\r\n for i in range(5):\r\n summ+=a\r\n if summ>=n:\r\n print(names[i])\r\n break\r\n a*=2\r\n", "a=int(input())-1\r\nwhile a>4:\r\n\ta=(a-5)>>1\r\nprint([ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][a])", "li=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nimport math\r\nn=int(input())\r\nif n==1:\r\n print(li[0])\r\nelse:\r\n S=0\r\n i=1\r\n while S*5<n:\r\n S=S+i\r\n i=i*2\r\n N=n-(S-i/2)*5\r\n k=N%(i/2)\r\n if k==0:\r\n print(li[int(N//(i/2))-1])\r\n else:\r\n print(li[int(N//(i/2))])\r\n", "n = int(input())-1\nnames = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\nwhile n > 4:\n n = int((n-5)/2)\n\nprint(names[n])\n\n\t \t \t \t\t\t \t \t \t \t\t \t", "import math\r\nn = int(input())\r\nk = math.floor(math.log2((n + 5) // 5))\r\nstart = (2**k-1)*5+1\r\nend = (2**(k+1)-1)*5\r\nprint(['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard'][math.floor((n - start)/(end-start+1)*5)])\r\n\r\n", "n = int(input())\r\ndoubleTime = 0\r\ni = 0\r\nwhile i < n:\r\n i += 5*(2**doubleTime)\r\n doubleTime += 1\r\ndrinker = ((i-n)//2**(doubleTime-1))%5\r\n\r\nprint([\"Howard\",\"Rajesh\",\"Penny\",\"Leonard\",\"Sheldon\"][drinker])", "\r\nn = int(input())\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\ndef cola(r):\r\n r = r-1\r\n while len(names) <= r:\r\n r = (r - (len(names))) // 2\r\n return names[r]\r\n\r\nprint(cola(n))", "import math\r\n\r\n\r\n\r\nn = int(input())\r\narr = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif n <= 5:\r\n print(arr[n - 1])\r\nelse:\r\n itr_done = int(math.floor(math.log2(n / 5.0 + 1)))\r\n nrem = int(n - 5 * (pow(2, itr_done) - 1))\r\n count = int(nrem / pow(2, itr_done))\r\n print(arr[count])\r\n", "n = int(input())\r\nlst = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ns = 1\r\nflag = True\r\nwhile flag:\r\n for name in lst:\r\n n -= s\r\n if n <= 0:\r\n print(name)\r\n flag = False\r\n break\r\n s*=2\r\n \r\n \r\n", "\r\n\r\nn = int(input())\r\nres = \"\"\r\n\r\np = 1\r\nt = 0\r\nwhile t < n:\r\n t += 5*(pow(2, p-1))\r\n p += 1\r\ntn = t - (5*(pow(2, p-2)))\r\np = p-2\r\nc = int((n-(tn+1))/pow(2,p)) + 1\r\n\r\nif c == 1:\r\n res = \"Sheldon\"\r\nelif c == 2:\r\n res = \"Leonard\"\r\nelif c == 3:\r\n res = \"Penny\"\r\nelif c == 4:\r\n res = \"Rajesh\"\r\nelif c == 5:\r\n res = \"Howard\"\r\n\r\nprint(res)\r\n", "a=int(input())\r\na-=1\r\nx=5\r\nb=1\r\nk=1\r\np=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile a>=x:\r\n b+=1\r\n k*=2\r\n a-=x\r\n x*=2\r\nn=a//k\r\nprint(p[n])\r\n", "n=int(input())\r\nif n<6:\r\n n-=1\r\nk,r=1,0\r\nwhile n>=5*k:\r\n n-=5*k\r\n k*=2\r\n r+=1\r\no=[ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\" ]\r\nprint(o[n//k])", "names = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nn = int(input()) - 1\r\nk = 1\r\nwhile n >= (5 * k):\r\n\tn -= 5 * k\r\n\tk *= 2\r\nprint(names[int(n / k)])", "from math import ceil\nn=int(input())\ns=0\nh=0\nk=0\np=0\nwhile s<n:\n s+=5*2**k\n k+=1\nnum=ceil((n-(s-5*2**(k-1)))/2**(k-1))\n\n \nif num==1:\n print('Sheldon')\nif num==2:\n print('Leonard')\nif num==3:\n print('Penny')\nif num==4:\n print('Rajesh')\nif num==5:\n print('Howard')\n \n", "from math import log\n\nl = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\nn = int(input())\n\na = n // 5\n\ngr = 0\naux = 5\ntotal = 5\nwhile True:\n if total >= n:\n total -= aux\n break\n gr += 1\n aux = aux * 2\n total += aux\n\nppgr = 2 ** gr\n\npos = n - total\nv, r = pos // ppgr, pos % ppgr\n\nif r == 0:\n print(l[v-1])\nelse:\n print(l[v])\n\n\t \t\t \t\t \t\t \t \t\t \t \t\t\t \t \t", "def find_person(n):\n names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n num_people = len(names)\n cans_per_person = 1\n\n while n > cans_per_person * num_people:\n n -= cans_per_person * num_people\n cans_per_person *= 2\n\n index = (n - 1) // cans_per_person\n\n return names[index]\n\n# Read input\nn = int(input())\n\n# Find the person who drinks the n-th can\nperson = find_person(n)\n\n# Print the result\nprint(person)\n\n \t\t \t\t\t\t\t\t\t \t \t \t \t\t\t\t\t\t\t\t\t\t", "import sys\n\n\ndef get_iter_num(nth, dnum):\n inum = 0\n mult = 1\n border = dnum\n while border < nth:\n inum += 1\n mult <<= 1\n border += mult * dnum\n\n return inum, mult, border\n \n\ndef nth_drinker(nth, dnum):\n iter_num, mult, border = get_iter_num(nth, dnum)\n low_border = border - dnum * mult\n return (nth - low_border) // mult + bool((nth - low_border) % mult)\n \n\ndef main():\n drinkers = (\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\")\n nth = int(sys.stdin.readline())\n\n print(drinkers[nth_drinker(nth, len(drinkers)) - 1])\n\nif __name__ == '__main__':\n main()", "#@sorcerer_21\r\nimport math\r\nn=int(input())\r\na=['Howard','Sheldon','Leonard','Penny','Rajesh','Howard']\r\nx=0;z=5;i=0\r\nwhile z+x<=n:\r\n x+=z\r\n z*=2;i+=1\r\nprint(a[math.ceil((n-x)/(2**i))])", "def solve(n):\r\n\r\n map = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\n rate = 1\r\n\r\n #estimating the row\r\n while (5 * rate) < n:\r\n n -= (5 * rate)\r\n rate *= 2\r\n\r\n #estimating the column in that row\r\n return map[int((n-1)/rate)]\r\n\r\n\r\nif __name__ == \"__main__\":\r\n n = int(input())\r\n print (solve(n))", "import math\n\nn = int(input())\n\nqueue = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\ndef verify_drinker(n):\n p = 0\n\n while (n - 5*2**p > 0):\n n -= 5*(2**p)\n p += 1 \n\n threshold = 2**p\n\n for i in range(1, 6):\n if n <= i*2**p:\n print(queue[i-1])\n return\n\n\nverify_drinker(n)\n", "l=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"] \r\nn=int(input())\r\nt=1 \r\nwhile(t*5<n):\r\n n-=t*5 \r\n t=t*2 \r\nn=n-1 \r\nprint(l[n//t])", "import math\r\n\r\nn = int(input())\r\nx = math.ceil(math.log(n / 5 + 1) / math.log(2))\r\ny = math.ceil((n - 5 * (pow(2, x - 1) - 1)) / 2 ** (x - 1))\r\nif y == 1:\r\n print(\"Sheldon\")\r\nelif y == 2:\r\n print(\"Leonard\")\r\nelif y == 3:\r\n print(\"Penny\")\r\nelif y == 4:\r\n print(\"Rajesh\")\r\nelif y == 5:\r\n print(\"Howard\")\r\n", "sn=int(input())\r\nn=1\r\nwhile(True):\r\n if 2**n>=sn/5+1:\r\n break\r\n else:\r\n n+=1\r\nn_pos=sn-(5*2**(n-1)-5)\r\nn_times=2**(n-1)\r\nn_person=n_pos//n_times\r\nif n_times==1:\r\n n_person=n_pos-1\r\nif n_person==0:\r\n print ('Sheldon')\r\nif n_person==1:\r\n print('Leonard')\r\nif n_person==2:\r\n print ('Penny')\r\nif n_person==3:\r\n print ('Rajesh')\r\nif n_person==4:\r\n print ('Howard')", "n=int(input())\r\nr = 1\r\nwhile (r * 5 < n):\r\n n -= r * 5;\r\n r *= 2;\r\n\r\nnames= [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(names[(n - 1) // r])", "n = int(input())\nn -= 1\n\nq = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\np = 5\nwhile n >= p:\n n -= p\n p *= 2\n\nprint(q[int(n / (p / 5))])\n", "x = int(input())\r\ny = 5\r\np =1\r\nwhile True:\r\n\tif x>y:\r\n\t\tx-=y\r\n\t\ty*=2\r\n\t\tp*=2\r\n\telse:\r\n\t\tif x/p <=1:\r\n\t\t\tprint('Sheldon')\r\n\t\telif x/p <=2:\r\n\t\t\tprint('Leonard')\r\n\t\telif x/p <=3:\r\n\t\t\tprint('Penny')\r\n\t\telif x/p <=4:\r\n\t\t\tprint('Rajesh')\r\n\t\telif x/p <=5:\r\n\t\t\tprint('Howard')\r\n\t\tbreak", "import math\r\n\r\ndef pri(n):\r\n if(n==1): print(\"Sheldon\")\r\n elif(n==2): print(\"Leonard\")\r\n elif(n==3): print(\"Penny\")\r\n elif(n==4): print(\"Rajesh\")\r\n elif(n==5): print(\"Howard\")\r\n\r\nn = int(input(\"\"))\r\nval = 5\r\nwhile(val < n):\r\n n -= val\r\n val *= 2\r\n\r\nval/=5; val = int(val)\r\nk = int(math.log2(val))\r\n\r\nk = pow(2,k)\r\nn = int(math.ceil(n/k))\r\npri(n)", "names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn = int(input().strip())\nn -= 1\nwhile n >= 5:\n\tn -= 5\n\tn //= 2\nprint(names[n])", "n = int(input())\n\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\ni = 1\nq = 5\n\nwhile n > q:\n n -= q\n i += 1\n q *= 2\n # print(\"i\", i, \"n\", n, \"q\", q)\n\nl = 2 ** (i - 1)\nii = (n + l - 1) // l - 1\n# print(\"i\", i, \"n\", n, \"ii\", ii)\n\nprint(names[ii])\n", "list_ = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nquantidades = [0, 5]\r\ntarget = int(input())\r\n\r\nx = 0\r\nwhile quantidades[-1] < target:\r\n x += 1\r\n quantidades.append(quantidades[-1] + 5 * 2 ** x)\r\n\r\nprint(list_[(target-1 - quantidades[-2])//2**x])\r\n", "from time import sleep as sle\r\nfrom math import *\r\nfrom random import randint as ri\r\n\r\ndef solve():\r\n\tn = int(input())\r\n\ta = 1\r\n\tb = 5\r\n\tp = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\n\tbr = False\r\n\twhile True:\r\n\t\tc = b/5\r\n\t\t# s = []\r\n\t\tfor i in range(5):\r\n\t\t\tq1 = a+(c*i)\r\n\t\t\tq2 = a+(c*i)+c-1\r\n\t\t\tif q1 <= n <= q2:\r\n\t\t\t\tprint(p[i])\r\n\t\t\t\tbr = True\r\n\t\t\t\tbreak\r\n\t\t\t# c1 = c+1\r\n\t\t\t# q = (a+(c*i),c-1,a+(c*(i+1))-1)\r\n\t\t\t# s += ['%d(+%d)%d'%q]\r\n\t\tif br:\r\n\t\t\tbreak\r\n\t\t# s = ' | '.join(s)\r\n\t\t# for i in range(len(s)):\r\n\t\t# \tprint(s[:i],end='\\r')\r\n\t\t# \tsle(.1)\r\n\t\t# print(s)\t\t\r\n\t\ta += b\r\n\t\tb *= 2\r\n\r\nsolve()", "n=int(input())\r\nnames=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ni=5\r\nwhile i<n:\r\n n-=i\r\n i*=2\r\nprint(names[(n-1)//(i//5)])", "import math\r\nn=int(input())\r\nx=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\np=int(math.log2(n/5+1))\r\nif p==0:\r\n q=n\r\nelif (n-5*(2**p-1))%(2**p)==0:\r\n q=int((n-5*(2**p-1))/(2**p))\r\nelse:\r\n q=int((n-5*(2**p-1))/(2**p)+1)\r\nprint(x[q-1],end='')\r\n\r\n", "\r\n\r\nn = int(input())\r\n\r\ni = 1\r\n\r\nwhile n > 5*i:\r\n\r\n n -= 5*i\r\n\r\n i *= 2\r\n\r\n\r\n\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\n\r\n\r\nfor name in names:\r\n\r\n if n <= i:\r\n print(name)\r\n break\r\n \r\n else:\r\n\r\n n -= i\r\n", "n=int(input())\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nr=1\nwhile(r*5<n):\n n-=r*5\n r*=2\nprint(a[(n-1)//r])\n\t\t \t \t \t \t\t \t \t\t \t\t \t\t\t\t", "def geometricSum(a, r, n):\r\n return (a * ((r ** n) - 1)) // (r - 1)\r\n\r\n\r\ndef geometricTerm(a, r, n):\r\n return a * (r ** (n - 1))\r\n\r\nn = int(input())\r\ncheck = 0\r\nwhile geometricSum(5, 2, check) <= n:\r\n check += 1\r\nans = (n - geometricSum(5, 2, check - 1)) / (2**(check - 1))\r\n\r\nif 0 < ans <= 1:\r\n print(\"Sheldon\")\r\nelif 1 < ans <= 2:\r\n print(\"Leonard\")\r\nelif 2 < ans <= 3:\r\n print(\"Penny\")\r\nelif 3 < ans <= 4:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "import math\n\nn = int(input())\np = 5\npessoas = {\n 1:\"Sheldon\",\n 2:\"Leonard\", \n 3:\"Penny\", \n 4:\"Rajesh\", \n 5:\"Howard\"\n}\n\nwhile n>p:\n n -= p\n p += p\n \nfulano = math.ceil(n/(p//5))\n\nprint(pessoas[fulano])", "n=int(input())\ni=x=1\nwhile x<=n:\n x+=i*5\n i*=2\ni//=2\nx-=i*5\nprint((\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\")[(n-x)//i])\n\n", "n=int(input())\r\nqueue =['Sheldon','Leonard','Penny','Rajesh','Howard']\r\ni=1\r\nwhile n>5*(2**i-1):\r\n\ti+=1\r\n\r\nprevious=5*(2**(i-1)-1)\r\nprint(queue[int(( (n-previous)-1 )//(2**(i-1)))])", "# DEFINING SOME GOOD STUFF\nfrom math import *\nimport threading\nimport sys\nfrom collections import *\n\nmod = 10 ** 9\ninf = 10**15\nyes = 'YES'\nno = 'NO'\n\n# _______________________________________________________________#\n\ndef npr(n, r):\n return factorial(n) // factorial(n - r) if n >= r else 0\ndef ncr(n,r):\n return factorial(n)// ( factorial(r) * factorial(n-r)) if n >= r else 0\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\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\ndef abs(x):\n return x if x >= 0 else -x\ndef binary_search(li, val, lb, ub):\n # print(lb, ub, li)\n ans = -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\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\ndef pref(li):\n pref_sum = [0]\n for i in li:\n pref_sum.append(pref_sum[-1] + i)\n return pref_sum\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\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\ndef prod(li):\n ans = 1\n for i in li:\n ans *= i\n return ans\ndef dist(a,b):\n d = abs(a[1]-b[1]) + abs(a[2]-b[2])\n return d\ndef power_of_n(x, n):\n cnt = 0\n while(x%n == 0):\n cnt += 1\n x //= n\n return cnt\ndef ask(l,r):\n if l == r:\n return -1\n print(\"?\",l,r)\n sys.stdout.flush()\n return int(input())\n# _______________________________________________________________#\n\nimport itertools\n\nsys.setrecursionlimit(300000)\n# threading.stack_size(10**5) # remember it cause mle\n# def main():\n\nfor _ in range(1):\n# for _ in range(int(input()) if True else 1):\n n = int(input())\n # n, k = map(int, input().split())\n # a = list(map(int, input().split()))\n # b = list(map(int, input().split()))\n #c = list(map(int, input().split()))\n # s = list(input())\n # c = list(map(int,input().split()))\n # adj = graph(n,m)\n # d = defaultdict(int)\n ans = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n if n <= 5:\n print(ans[n-1])\n else:\n now = 5\n while n >= now:\n n -= now\n now *= 2\n\n group = now//5\n print(ans[n//group])\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\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\nt = threading.Thread(target=main)\nt.start()\nt.join()\n'''", "n = int(input())\r\nli = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif n <= 5:\r\n print(li[n-1])\r\nelse:\r\n while n >= 5:\r\n n -= 5\r\n n //= 2\r\n print(li[n])", "n=int(input())\r\nar=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\ns=1\r\nwhile(s*5<n):\r\n n-=s*5\r\n s*=2\r\nprint(ar[(n-1)//s])", "l = ['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn = int(input())\r\n\r\ni = 0\r\nwhile n>(len(l)*2**i):\r\n n -= len(l)* (2**i)\r\n i += 1\r\n\r\nindex = int((n-1)/(2**i ))\r\n\r\nprint(l[index])", "import math\n\nn = int(input())\n\nqueue = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\ndef verify_drinker(n):\n p = 0\n\n while (n - 5*2**p > 0):\n n = n - 5*2**p\n p += 1\n\n threshold = 5*2**p\n\n if n <= threshold//5:\n print(\"Sheldon\")\n elif n <= 2*(threshold//5):\n print(\"Leonard\")\n elif n <= 3*(threshold//5):\n print(\"Penny\")\n elif n <= 4*threshold//5:\n print(\"Rajesh\")\n elif n <= 5*threshold//5:\n print(\"Howard\")\n \n\n\nverify_drinker(n)\n", "n=int(input())\r\ns=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nif n<=5:\r\n print(s[n-1])\r\nelse:\r\n less=0\r\n k=0\r\n powerno=0\r\n for i in range(0,1000000000):\r\n k+=pow(2 ,i)*5\r\n if n>k:\r\n less=k\r\n powerno=i\r\n if n<k:\r\n k-=pow(2,i)*5\r\n less+=1\r\n break\r\n \r\n elem_count=pow(2,powerno+1)*5\r\n left=(n-k)\r\n \r\n elem_count=int(elem_count/5)\r\n \r\n\r\n for i in range(1,6):\r\n\r\n if i*elem_count>=left:\r\n print(s[i-1])\r\n break\r\n\r\n \r\n\r\n\r\n\r\n", "import math \r\nn=int(input())\r\nd=n//5\r\n#print(d)\r\nc=int(math.log2(d+1))\r\nn=n-(5*((2**c)-1))\r\n#print(n,c)\r\na=n//(2**(c))+1 if n%(2**(c))>0 else n//(2**(c)) \r\nif a==1:\r\n print('Sheldon')\r\nelif a==2:\r\n print('Leonard')\r\nelif a==3:\r\n print('Penny')\r\nelif a==4:\r\n print('Rajesh')\r\nelse:\r\n print('Howard')", "s=[\r\n \"Sheldon\",\r\n \"Leonard\",\r\n \"Penny\",\r\n \"Rajesh\",\r\n \"Howard\"\r\n]\r\nn=int(input())\r\nn-=1\r\nwhile(n>=5):\r\n n=n-5\r\n n=n//2\r\nprint(s[n])", "n = int(input())\r\nj = 0\r\nk = 5\r\nwhile n - k > 0:\r\n\tn -= k\r\n\tk *= 2\r\nif n <= k * 0.2:\r\n\tprint('Sheldon')\r\nelif n <= k * 0.4:\r\n\tprint('Leonard')\r\nelif n <= k * 0.6:\r\n\tprint('Penny')\r\nelif n <= k * 0.8:\r\n\tprint('Rajesh')\r\nelse:\r\n\tprint('Howard')\r\n\r\n", "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\n\r\n\r\n\r\n# sys.stdin.readline().rstrip()\r\n#n, m = map(int, input().split())\r\n\r\n\r\n\r\ns = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nn = int(input())\r\np = 1\r\nacc = 0\r\nwhile True:\r\n acc += p * 5\r\n if acc >= n: break\r\n p *= 2\r\n\r\nacc -= (p * 5)\r\nidx = n - acc\r\nprint(s[(idx - 1) // p])", "n = int(input())\r\np = 0\r\nk = 5\r\nwhile k < n:\r\n n -= k\r\n p += 1\r\n k *= 2\r\n \r\nx = n / 2**p\r\nif x <= 1:\r\n print('Sheldon')\r\nelif x <= 2:\r\n print('Leonard')\r\nelif x <= 3:\r\n print('Penny')\r\nelif x <= 4:\r\n print('Rajesh')\r\nelse:\r\n print('Howard')\r\n\r\n", "Our = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\ng = 0\r\no = 0\r\na = 0\r\nb = 0\r\nif n < 6:\r\n print(Our[n-1])\r\n o = 1\r\nwhile b < n and o == 0:\r\n b = b + ((2**a)*5)\r\n if b == n:\r\n print(\"Howard\")\r\n g = 1\r\n if b < n and b + ((2**(a+1))*5) > n:\r\n m = b\r\n if b > n:\r\n k = 2 ** a\r\n a += 1\r\nif g == 0 and o == 0:\r\n t = n - m - 1\r\n print(Our[t//k])\r\n", "from sys import *\r\ninput = lambda:stdin.readline()\r\n\r\nint_arr = lambda : list(map(int,stdin.readline().strip().split()))\r\nstr_arr = lambda :list(map(str,stdin.readline().split()))\r\nget_str = lambda : map(str,stdin.readline().strip().split())\r\nget_int = lambda: map(int,stdin.readline().strip().split())\r\nget_float = lambda : map(float,stdin.readline().strip().split())\r\n\r\n\r\nmod = 1000000007\r\nsetrecursionlimit(1000)\r\n\r\nn = int(input())\r\nlst = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif n <= 5:\r\n print(lst[n - 1])\r\nelse:\r\n exp = 0\r\n while n > 5 * 2 ** exp:\r\n n -= 5 * 2 ** exp\r\n exp += 1\r\n print(lst[n // 2 ** exp])", "from math import ceil\r\n\r\nd = {0: \"Sheldon\", 1: \"Leonard\", 2: \"Penny\", 3: \"Rajesh\", 4: \"Howard\"}\r\nn = int(input())\r\ni = 1\r\nwhile n > i*5:\r\n n -= i*5\r\n i *= 2\r\nprint(d[ceil(n/i)-1])\r\n", "l=['Sheldon', 'Leonard', 'Penny' ,'Rajesh','Howard']\r\nn=int(input())\r\nk=1\r\nwhile(k*5<n):\r\n n-=k*5\r\n k*=2\r\nprint(l[(n-1)//k])", "n=int(input())\r\np = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif(n<=5):\r\n print(p[n-1])\r\nelse:\r\n i=5\r\n c=5\r\n while(c+i*2<n):\r\n i=i*2\r\n c+=i\r\n n=n-c\r\n i=i*2\r\n r=i//5\r\n j=(n-1)//r\r\n print(p[j])", "arr = [0, \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\nr = 5\r\nc = 0\r\nwhile n > r:\r\n n -= r\r\n c += 1\r\n r <<= 1\r\ngap = 1 << c\r\nidx = 1\r\nfor i in range(1, r+1):\r\n if n<=gap*i:break\r\n idx += 1\r\nprint(arr[idx])", "x = int(input())\r\na = \"Sheldon\"\r\nb = \"Leonard\"\r\nc = \"Penny\"\r\nd = \"Rajesh\"\r\ne = \"Howard\"\r\nz = 5\r\nzz = 0\r\nlst = [0]\r\n\r\nwhile(zz<x):\r\n zz += z\r\n z *= 2\r\n lst.append(zz)\r\n \r\nk = lst[len(lst)-2]\r\nkk = k\r\nl = k + 5\r\ny = 0\r\n\r\nfor n in range(len(lst)-1):\r\n if(y==0):\r\n y += 1\r\n else:\r\n y *= 2\r\n\r\nwhile(k<l):\r\n kk += y\r\n if(x <= kk):\r\n break\r\n k += 1\r\n\r\nm = (k+1) % 5\r\nif(m == 1):\r\n print(a)\r\nelif(m == 2):\r\n print(b)\r\nelif(m == 3):\r\n print(c)\r\nelif(m == 4):\r\n print(d)\r\nelif(m == 0):\r\n print(e)\r\n\r\n\r\n\r\n \r\n", "n=int(input())\r\nj=1\r\ni=5\r\nl=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nwhile (i+(10*j))<=n:\r\n j=j*2\r\n i+=5*j\r\nrepeat=(10*j)//5\r\nnum=10*j\r\nif n<=i:\r\n print(l[n-1])\r\nelse:\r\n print(l[((n - i-1) // repeat)])\r\n", "import math\r\n\r\nd = {1:\"Sheldon\",2: \"Leonard\",3: \"Penny\",4: \"Rajesh\",5: \"Howard\" }\r\n\r\nn = int(input())\r\n\r\nt = 0\r\nexp = 0\r\nwhile n > exp:\r\n exp += 5*(2**t)\r\n t += 1\r\n\r\nlast = 0\r\nfor i in range(t-1): \r\n last += 5*(2**i)\r\n\r\nexp = n - last\r\nres = math.ceil(exp/2**(t-1))\r\n\r\n\r\nprint(d.get(res))", "from sys import stdin\n\n# preprocessing\nnames = [ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\" ]\nn = int(stdin.readline().strip())\nif n<=5: \n print(names[n-1])\nelse:\n sodas,queue,i = 0,5,1\n while sodas+queue<=n:\n sodas,queue,i = sodas+queue,queue<<1,i<<1\n if n==sodas: print(names[4])\n else: print(names[(n-sodas-1)//i])\n\n", "import math\nn=int(input())\nn=n-1\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nwhile(n>=5):\n n=n-5\n n=n//2\nprint(a[n])\n'''\nc=math.sqrt(20)\nprint(c)\nc1=math.ceil(c/5)\nprint(c1+1)\n'''\n'''\nSheldon-1,6,7, 16 17 18 19 ;Leonard-2,8,9 20 21 22 23 ;Penny-3,10,11 24 25 26 27 ;Rajesh-4,12,13 28 29 30 31 ;Howard-5,14,15 32 33 34 35;\n 2 3 4 5 1\n@1 Leonard, Penny, Rajesh , Howard ,Shel , Shel = 6\n@2 Penny, Rajesh , Howard ,Shel , Shel,leo,leo = 7\n@3 Rajesh , Howard ,Shel , Shel,leo,leo,penny,penny = 8\n@4 Howard ,Shel , Shel,leo,leo,penny,penny,raj,raj =9\n@5 Shel , Shel,leo,leo,penny,penny,raj,raj,how,how = 10\n@6 Shel,leo,leo,penny,penny,raj,raj,how,how,shel,shel =11 \n'''\n\t\t \t\t\t\t \t\t\t \t\t\t\t\t \t \t\t", "n=int(input())\r\nfor k in range(1,40):\r\n if n//((5*(2**(k+1)-2))/2)<1:\r\n break\r\n\r\nl=((5*(2**(k)-2))/2)+1\r\nm=2**(k-1)-1\r\n\r\nif n>=l and n<=l+m:\r\n print(\"Sheldon\")\r\nelif n>=l+m+1 and n<=l+2*m+1:\r\n print(\"Leonard\")\r\nelif n>=l+2*m+2 and n<=l+3*m+2:\r\n print(\"Penny\")\r\nelif n>=l+3*m+3 and n<=l+4*m+3:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "import math\na=int(input())\nb=0\nc=1\ni=0\nwhile i==0:\n if a<= (b+c*5): \n d=math.ceil((a-b)/c)\n if d==1:\n print('Sheldon')\n elif d==2:\n print('Leonard')\n elif d==3:\n print('Penny')\n elif d==4:\n print('Rajesh')\n elif d==5:\n print('Howard')\n break \n else:\n b= b+(c*5)\n c=c*2\n", "z=int(input())\narr=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\na=1\nwhile(a*5<z):\n z-=a*5\n a*=2\nprint(arr[(z-1)//a])\n \t\t\t \t\t \t\t\t \t \t \t\t\t \t", "import math\r\nn=int(input())\r\nk={1:\"Sheldon\",2:\"Leonard\",3:\"Penny\",4:\"Rajesh\",5:\"Howard\"}\r\nif n<=5:\r\n print(k[n])\r\nelse:\r\n previous=n\r\n n=n/5+1\r\n tmpn=0\r\n for i in range(0,101,1):\r\n if 2**i>n:\r\n tmpn=i-1\r\n break\r\n previous-=5*(2**tmpn-1)\r\n ans=math.ceil(previous/(2**tmpn))\r\n print(k[ans])", "i = int(input())-1\r\na = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nwhile i >= 5:\r\n i = (i-5)//2\r\nprint(a[i])", "n = int(input())\r\nq = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ns = 5\r\nd = 1\r\nacc = 5\r\nwhile n > acc:\r\n d = d * 2\r\n acc += (d *s) \r\nn -= (5 *(d-1))\r\nif n <= d*1:\r\n print(q[0])\r\nelif n <= d*2:\r\n print(q[1])\r\nelif n <= d*3:\r\n print(q[2])\r\nelif n <= d*4:\r\n print(q[3])\r\nelse:\r\n print(q[4])", "from math import log\r\nn = int(input())\r\n\r\nk = int(log((n - 1)/5 + 1, 2) + 1)\r\nb = 1 + 5*(2**(k - 1) - 1)\r\nx = int((n - b) / 2**(k-1)) + 1\r\n\r\nprint({1:'Sheldon', 2:'Leonard', 3:'Penny', 4:'Rajesh', 5:'Howard'}[x])", "res=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nn=int(input())\r\nl,r,d = 1,6,0\r\nwhile True:\r\n if r > n:\r\n print(res[(n-l)//(2**d)])\r\n break\r\n l=r\r\n d+=1\r\n r+=5*(2**d)", "z=int(input())\nar=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nr=1\nwhile(r*5<z):\n z-=r*5\n r*=2\nprint(ar[(z-1)//r])\n \t\t \t \t \t \t \t\t \t \t \t \t", "N = int(input())\r\nk = N/5\r\np = 2\r\nn = 1\r\nwhile p>1:\r\n if k/((2**n)-1) > 1:\r\n n +=1\r\n else:\r\n break\r\nm = (k - ((2**(n-1))-1))*5/(2**(n-1))\r\nif 0<m<=1:\r\n print(\"Sheldon\")\r\nelif 1<m<=2:\r\n print(\"Leonard\")\r\nelif 2<m<= 3:\r\n print(\"Penny\")\r\nelif 3<m<=4:\r\n print(\"Rajesh\")\r\nelif 4<m<=5:\r\n print(\"Howard\")", "num=int(input())\nA=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nR=1\nwhile(R*5<num):\n num-=R*5\n R*=2\nprint(A[(num-1)//R])\n\t\t\t \t\t\t \t\t\t\t \t\t\t\t \t\t\t\t\t\t \t", "import math\r\nfrom collections import OrderedDict\r\nfrom collections import Counter\r\nfrom itertools import combinations\r\nfrom itertools import accumulate\r\nimport operator\r\nimport bisect\r\nimport copy\r\n#a= list(map(int, input(\"\").strip().split()))[:n]\r\n\r\n'''\r\ndef solve(a,x):\r\n \r\nt=int(input(\"\"))\r\nfor _ in range(t):\r\n n,x= list(map(int, input(\"\").strip().split()))[:2]\r\n a= list(map(int, input(\"\").strip().split()))[:n]\r\n solve(a,x)\r\n\r\n'''\r\ndef solve(n):\r\n d={0:\"Sheldon\",1:\"Leonard\",2:\"Penny\",3:\"Rajesh\",4:\"Howard\"}\r\n while n>4:\r\n n=(n-5)//2\r\n print(d[n])\r\nn=int(input(\"\"))\r\nsolve(n-1)", "def main():\r\n q = int(input())\r\n\r\n s = 1\r\n while s * 5 < q:\r\n q -= s * 5\r\n s *= 2\r\n\r\n names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n print(names[(q - 1) // s])\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "# 82A - Double Cola\r\nimport math\r\nn = int(input())\r\nx = (n-1)//5\r\ny = int(math.log((x+1), 2))\r\nn -= 5*((2**y)-1)+1\r\nn //= (2**y)\r\nd = {0: \"Sheldon\", 1: \"Leonard\", 2: \"Penny\", 3: \"Rajesh\", 4: \"Howard\"}\r\nprint(d[n])\r\n", "n = int(input().strip())\r\nname = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\na = 1\r\nwhile n > a * 5:\r\n n -= a * 5\r\n a *= 2\r\nc = n // a\r\nif n % a != 0:\r\n c += 1\r\nprint(name[c - 1])", "name = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\nn = int(input())\nlmt = 5\nwhile n > lmt:\n n -= lmt\n lmt *= 2\nseg = lmt // 5\nprint(name[n // seg if n % seg else n // seg - 1])\n\t\t\t\t \t\t\t \t\t\t \t\t \t\t \t \t \t \t\t", "n = int(input())\r\npeople = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn_people = len(people)\r\ni = 1\r\nwhile n_people * i < n :\r\n n -= n_people * i\r\n i *= 2\r\nprint(people[(n-1) // i])\r\n", "\r\ndef gp2(n):\r\n if n <= 0:\r\n return 0\r\n if n == 1:\r\n return 1\r\n t = 1\r\n while t <= n:\r\n t <<= 1\r\n t >>= 1\r\n\r\n return t\r\n\r\ndef answer(n):\r\n k = (n-1) //5 + 1\r\n gsize = gp2(k)\r\n bn = 5*(gsize-1) + 1\r\n offset = n - bn\r\n subgroup = offset // gsize\r\n answers = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n \r\n return answers[subgroup]\r\n\r\ndef answer2(n):\r\n p = 0\r\n while n > (5 * 2**p) - 5: # last element of previous group\r\n p += 1\r\n # 2**(p-1) is size of subgroups in group p.\r\n p -= 1\r\n sindx = (5 * 2**p) - 4\r\n offset = n - sindx\r\n subgroup = offset // (2**p)\r\n answers = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n return answers[subgroup]\r\n \r\n\r\n\r\ndef main():\r\n n = int(input())\r\n print(answer2(n))\r\n\r\n\r\nmain()", "names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ntoDiv = 5\r\nnum = int(input())\r\nif num <= 5:\r\n print(names[num-1])\r\nelse:\r\n i = 0\r\n while num > toDiv:\r\n num -= toDiv\r\n toDiv *= 2\r\n i += 1\r\n x = num // (2 ** i)\r\n\r\n print(names[x])\r\n", "n = int(input())\r\nx = 1\r\nname = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nwhile 5*x < n:\r\n n -= 5*x\r\n x *= 2\r\nn = (n-1)//x\r\nprint(name[n])", "# Lets goto the next level \r\n# AIM Specialist at CF *__* asap \r\n# template taken from chaudhary_19 \r\n# Remember you were also a novice when you started, \r\n# hence never be rude to anyone who wants to learn something\r\n# Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts \r\n# Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure. \r\n# Any doubts or want to have a talk, contact https://www.facebook.com/chaudhary.mayank\r\n\r\n\r\n# ///==========Libraries, Constants and Functions=============///\r\n\r\nimport sys\r\nfrom bisect import bisect_left,bisect_right,insort\r\nfrom collections import deque,Counter\r\nfrom math import gcd,sqrt,factorial,ceil,log10,log2,floor\r\nfrom itertools import permutations\r\nfrom heapq import heappush,heappop,heapify\r\ninf = float(\"inf\")\r\nmod = 1000000007\r\n#sys.setrecursionlimit(10**5)\r\n\r\n\r\ndef factorial_p(n, p):\r\n ans = 1\r\n if n <= p // 2:\r\n for i in range(1, n + 1):\r\n ans = (ans * i) % p\r\n else:\r\n for i in range(1, p - n):\r\n ans = (ans * i) % p\r\n ans = pow(ans, p - 2, p)\r\n if n % 2 == 0:\r\n ans = p - ans\r\n return ans\r\n\r\n\r\ndef nCr_p(n, r, p):\r\n ans = 1\r\n while (n != 0) or (r != 0):\r\n a, b = n % p, r % p\r\n if a < b:\r\n return 0\r\n ans = (ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p)) % p\r\n n //= p\r\n r //= p\r\n return ans\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\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\ndef binary(number): # <----- calculate the no. of 1's in binary representation of number\r\n result=0\r\n while number:\r\n result=result+1\r\n number=number&(number-1)\r\n return result\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 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 expo(x,n): # x ki power n\r\n if n==0:\r\n return 1\r\n result=1\r\n while n>1:\r\n if n&1:\r\n result=result*x\r\n n-=1\r\n else:\r\n n//=2\r\n x=x*x\r\n return (result*x)\r\n\r\ndef get_array(): return list(map(int, sys.stdin.readline().strip().split()))\r\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\r\ndef input(): return sys.stdin.readline().strip()\r\n# ///===========MAIN=============///\r\nmydict={1:'Sheldon',2:'Leonard',3:'Penny',4:'Rajesh',5:'Howard'}\r\nn=int(input())\r\npower=0;total=0\r\nwhile ((total+(5*expo(2,power)))<=n):\r\n total+=(5*expo(2,power))\r\n power+=1\r\nif n==total:\r\n print(\"Howard\")\r\n exit()\r\nnxt=total+(5*expo(2,power))\r\nz=int(ceil((n-total)/((nxt-total)//5)))\r\nprint(mydict[z])\r\n", "\r\nnum_inp=lambda: int(input())\r\narr_inp=lambda: list(map(int,input().split()))\r\nsp_inp=lambda: map(int,input().split())\r\nstr_inp=lambda:input()\r\nn=int(input())-1\r\nwhile n>4:n=n-5>>1\r\nprint(\"SLPRHheeaoeonjwlnneadaysror hdnd\"[n::5])", "#M\nimport sys\na = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn = int(input())\nk = int(1)\ncount = int(0)\nfor i in range(1, pow(10, 9)): \n for j in range(5):\n n-=k\n if (n<=0):\n print(a[j])\n count+=1\n break\n if (count==1):\n break\n k*=2\n \t \t \t \t\t \t\t \t\t \t\t \t\t \t \t", "# A. Double Cola\n# 82A\n\nnames = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\nn = int(input()) - 1\n# print(f'n is initially {n}')\n\nr = 0\nwhile n >= 5 * 2**r:\n # print()\n n -= 5 * 2**r\n # print(f'subtracting n by {5 * 2**r}')\n r += 1\n # print(f'Now n is {n} and r is {r}')\n\nn //= 2**r\n# print(f'Since 2**r is {2**r} and r is {r}, changing n to {n}')\n\nassert(n < 5)\n\nprint(names[n])\n# print(names)\n\n", "n = int(input())\nlst = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nwhile n > 5:\n n = n // 2 - 2\n\nprint(lst[n - 1])\n", "\"\"\"\r\n author: Adham0 \r\n created: 31.07.2023 22:20:52\r\n \r\n █████ ██████ ██ ██ █████ ███ ███\r\n ██ ██ ██ ██ ██ ██ ██ ██ ████ ████\r\n ███████ ██ ██ ███████ ███████ ██ ████ ██\r\n ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ \r\n ██ ██ ██████ ██ ██ ██ ██ ██ ██\r\n\"\"\"\r\n\r\nn = int(input())\r\nl = ['Sheldon', 'Leonard', 'Penny', 'Rajesh','Howard']\r\n\r\nm = n - 1\r\n \r\nwhile m > 4:\r\n m = (m - 5) // 2 \r\n \r\nprint(l[m])", "import math\r\nn=int(input())\r\n#first i will try to find half of the number like closest call to log of n base 2\r\nf=(n/5)+1\r\nl=math.log(f,2)\r\ne=math.ceil(l)\r\n#e will be my half of the number now\r\nc=5*((2**e)-1)\r\nd=5*((2**(e-1))-1)+1\r\n#the number is in side d,c\r\nx=c-d+1\r\n#x is the range now i find halfs of repetions\r\nt=2**(e-1)\r\nx=d+t\r\na=x+t\r\nb=a+t\r\nm=b+t\r\nv=m+t\r\nif n in range(d,x):\r\n print(\"Sheldon\")\r\nelif n in range(x,a):\r\n print(\"Leonard\")\r\nelif n in range(a,b):\r\n print(\"Penny\")\r\nelif n in range(b,m):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "a=int(input())\r\nl=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nb=5\r\nwhile a>b:\r\n a=a-b\r\n b=b+b\r\nu=b//5\r\nif 5>a:\r\n print(l[a-1])\r\nelse:\r\n if a<u:\r\n print(l[0])\r\n else:\r\n i=a//u\r\n ii=a%u\r\n if ii!=0:\r\n i=i+1\r\n print(l[i-1])", "s = 1\r\nn = int(input())\r\nwhile n>5*s:\r\n n-=5*s\r\n s*=2\r\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][(n-1)//s])\r\n", "from collections import deque\r\n\r\n\r\n\r\ndef code_forces():\r\n\r\n \r\n n = int(input())\r\n queue = deque([('Sheldon',1),('Leonard',1),('Penny',1),('Rajesh',1),('Howard',1)])\r\n\r\n\r\n cokes_drank = 0\r\n\r\n\r\n\r\n while cokes_drank <n:\r\n\r\n person,amount = queue.popleft()\r\n cokes_drank += amount\r\n\r\n queue.append((person,amount * 2))\r\n\r\n\r\n\r\n \r\n print(person)\r\n\r\n\r\n\r\ncode_forces()\r\n\r\n\r\n", "def solve():\r\n n = int(input())\r\n t = 1\r\n a = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n while t * 5 < n:\r\n n -= 5 * t\r\n t *= 2\r\n index = ((n + t - 1) // t) - 1\r\n print(a[index])\r\n\r\n\r\nif __name__ == \"__main__\":\r\n solve()", "people = {1: \"Sheldon\", 2: \"Leonard\", 3: \"Penny\", 4: \"Rajesh\", 5: \"Howard\"}\nn = int(input())\npower = 0\ncan_sum = 0\n\ndef turn(n):\n i = 0\n global can_sum\n while can_sum <= n:\n #if it is exactly n, it is still last turn, the exact last can of the last person, i.e. Howard\n if can_sum == n:\n can_sum -= 5*pow(2,i - 1)\n return i-1\n can_sum += 5 * pow(2, i)\n # print(can_sum)\n i += 1 \n can_sum -= 5*pow(2,i-1) \n return i-1\n\ndef person(can_sum, n, turn) :\n canThisTurn = n-can_sum\n # print(turn)\n # print(f\"the can this turn is {canThisTurn}\") #turn : turn + 1\n for i in range(5):\n if (i+1)*pow(2, turn) < canThisTurn:\n # print(f\"{i+1}th is not the last people, can up to this point is {turn} {(i+1)*pow(2, turn)}\")\n pass\n else :\n # print(f\"The {i+1}th person is the last one\")\n return i+1\nturn = turn(n)\nprint(people[person(can_sum, n, turn)])\n \t\t \t \t \t\t \t\t \t\t \t\t\t \t", "n=int(input())\r\nlst = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif n <= 5:\r\n print(lst[n-1])\r\nelse:\r\n ans=5\r\n i=1\r\n while ans+(5*(2**i))<n:\r\n ans+=5*(2**i)\r\n i+=1\r\n n-=ans\r\n print(lst[n//(2**i)])\r\n", "n = int(input())\r\ni = 1\r\nwhile True:\r\n if n > i*5:\r\n n -= i*5\r\n i *= 2\r\n else:\r\n if n <= i:\r\n print(\"Sheldon\")\r\n elif n <= 2*i:\r\n print(\"Leonard\")\r\n elif n <= 3*i:\r\n print(\"Penny\")\r\n elif n <= 4*i:\r\n print(\"Rajesh\")\r\n else:\r\n print(\"Howard\")\r\n exit(0)", "ans=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\" ,\"Howard\"]\r\nx=int(input())\r\ncur=int(1)\r\nterm=int(0)\r\nwhile cur*5<=x:\r\n x-=(cur*5)\r\n cur*=2\r\nprint(ans[(x//cur)-1] if x%cur==0 else ans[(x//cur)])\r\n", "if __name__ == \"__main__\":\r\n n = int(input())\r\n queue = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n i = 1\r\n start = 1\r\n end = 5\r\n while end < n:\r\n start = end + 1\r\n end += 10*i\r\n i *= 2\r\n print(queue[(n - start)//(i)])", "import math\r\na = ['Sheldon', 'Leonard','Penny','Rajesh','Howard']\r\nn = int(input())\r\nk = math.ceil(math.log(n/5+1,2))-1\r\nclones = 2**k\r\nr = n - 5*(clones-1)\r\nprint(a[(math.ceil(r/clones)-1)%5])\r\n\r\n\r\n\r\n", "n=int(input())\r\nk=5\r\nwhile n>k:\r\n n -= k \r\n k *= 2\r\nk=k//5\r\nif n%k==0:\r\n x=n//k \r\nelse:\r\n x=n//k+1 \r\nif x==1:\r\n print(\"Sheldon\")\r\nelif x==2:\r\n print(\"Leonard\")\r\nelif x==3:\r\n print(\"Penny\")\r\nelif x==4:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "n=int(input())-1\r\n\r\nif n<=4:\r\n if n==0:\r\n print(\"Sheldon\")\r\n elif n==1:\r\n print(\"Leonard\")\r\n elif n==2:\r\n print(\"Penny\")\r\n elif n==3:\r\n print(\"Rajesh\")\r\n elif n==4:\r\n print(\"Howard\")\r\nelse:\r\n while n>=4:\r\n n=n-5>>1\r\n if n==0:\r\n print(\"Sheldon\")\r\n break\r\n elif n==1:\r\n print(\"Leonard\")\r\n break\r\n elif n==2:\r\n print(\"Penny\")\r\n break\r\n elif n==3:\r\n print(\"Rajesh\")\r\n break\r\n elif n==4:\r\n print(\"Howard\")\r\n break", "import math\n\ndef q82a():\n\tnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\tn = int(input())\n\tnumber_doubles = 1\n\tleft_bound = 0\n\tright_bound = 5\n\twhile(right_bound < n):\n\t\tleft_bound = right_bound\n\t\tright_bound = right_bound + 5 * 2 ** number_doubles\n\t\tnumber_doubles += 1\n\tprint(names[math.ceil((n - left_bound) / (right_bound - left_bound) * 5) - 1])\n\t#print(left_bound)\n\t#print(right_bound)\n\t#print(math.ceil((n - left_bound) / (right_bound - left_bound) * 5) - 1)\n\nq82a()", "import math\r\n\r\n\r\ndef main_function():\r\n l = [\"\", \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n s = 5\r\n n = int(input())\r\n is_answer_found = False\r\n while n >= s:\r\n n -= s\r\n s = 2 * s\r\n s //= 5\r\n if n == 0:\r\n print(l[5])\r\n is_answer_found = True\r\n if not is_answer_found:\r\n print(l[math.ceil(n / 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\nmain_function()", "n=int(input())\r\nl=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nwhile(n>5):\r\n n=n>>1\r\n n-=2\r\nprint(l[n-1])", "# coding=utf-8\r\nimport math\r\n\r\nif __name__ == '__main__':\r\n tar_list = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n n = int(input()) - 1\r\n k = int(math.log(n / 5 + 1, 2))\r\n print(tar_list[int((n - 5 * (math.pow(2, k) - 1)) / pow(2, k))])\r\n", "from math import ceil\r\nn = int(input())\r\nfriends = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nfirst = 1\r\nlast = 5\r\ntotal = 5\r\nwhile not first <= n <= last:\r\n first = last + 1\r\n total *= 2\r\n last = first + total - 1\r\nprint(friends[ceil((n + 1 - first) / (total / 5)) - 1])", "import math\r\n\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\nx, i = 0, 0\r\nwhile x < n:\r\n x += 5 * (2 ** i)\r\n i += 1\r\ndiff = n - (x - 5 * (2 ** (i - 1)))\r\nind = math.ceil(diff / 2 ** (i - 1))\r\nprint(names[ind-1])", "s = int(input())\r\ni = 1\r\nsum = 5\r\nwhile sum < s:\r\n i = i + 1\r\n sum = 5 * (pow(2, i) - 1) / (2 - 1)\r\nsum = 5 * (pow(2, i - 1) - 1) / (2 - 1)\r\n#print(sum)\r\n#print(i - 1)\r\ndiff = s - sum\r\nstep = pow(2, i - 1)\r\n#print(diff)\r\n#print(step)\r\nif diff <= step:\r\n print('Sheldon')\r\nelif diff <= 2 * step:\r\n print('Leonard')\r\nelif diff <= 3 * step:\r\n print('Penny')\r\nelif diff <= 4 * step:\r\n print('Rajesh')\r\nelse:\r\n print('Howard')\r\n\r\n\r\n", "n = int(input())-1\r\nk = 5\r\n\r\nshrimps = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nwhile True:\r\n if n - k >= 0:\r\n n -= k\r\n k *= 2\r\n else:\r\n break\r\nc = k//5\r\nprint(shrimps[n//c])\r\n", "n = int(input())\r\norder = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\na,b=2,1\r\ni = 0\r\nwhile n>5*(a**(i)):\r\n n-=5*(a**(i))\r\n i+=1\r\n\r\ncount=0\r\nwhile n >(2**i):\r\n n-=(2**i)\r\n count+=1\r\n \r\nprint(order[count]) ", "import math\n\nn = int(input())\nqueue = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\nc = 1\nwhile 5 * c < n:\n n -= 5 * c\n c *= 2\n\nprint(queue[(n - 1) // c])\n", "n = int(input())\r\nA = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nx = 0\r\nwhile n - 5 * 2 ** x > 0:\r\n n -= 5 * 2 ** x\r\n x += 1\r\ny = 0\r\nwhile n - 2 ** x > 0:\r\n n -= 2 ** x\r\n y += 1\r\nprint(A[y])", "n = int(input())\nx = 0\nwhile n > -5*(1-2**x):\n x += 1\nd = 2 ** (x - 1)\nres = n - (-5*(1-d))\nres = res // d + bool(res%d)\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][res - 1])", "if __name__ == '__main__':\r\n array = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n amount = int(input())\r\n numbers = amount\r\n numbers = numbers // 5\r\n #print(numbers)\r\n n = 0\r\n while True:\r\n if 2 ** n <= numbers:\r\n n += 1\r\n else:\r\n break\r\n number_of_boxes = n - 1\r\n number_of_human = 2 ** number_of_boxes\r\n if number_of_human < 1:\r\n number_of_human = 0\r\n distance = 0\r\n last_number = 0\r\n for index in range(0, number_of_boxes):\r\n if index == 0:\r\n distance += 5\r\n last_number = 5\r\n else:\r\n distance += last_number * 2\r\n last_number *= 2\r\n #print(distance)\r\n difference = amount - distance\r\n #print(f\"n = {n}, difference = {difference}, distance = {distance}, number_of_human = {number_of_human}, amount = {amount}\")\r\n if amount >= 10:\r\n print(array[(difference - 1) // number_of_human])\r\n elif amount <= 5:\r\n print(array[amount - 1])\r\n elif amount == 8 or amount == 9:\r\n print(array[1])\r\n elif amount == 6 or amount == 7:\r\n print(array[0])\r\n", "n = int(input())\r\nm = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nmc = [1, 1, 1, 1, 1]\r\n\r\nc = 0\r\nisReady = False\r\nwhile True:\r\n if isReady:\r\n break\r\n for i in range(5):\r\n if mc[i] + c < n:\r\n c += mc[i]\r\n mc[i] = mc[i] * 2\r\n else:\r\n print(m[i])\r\n isReady = True\r\n break\r\n", "n = int(input())-1\r\n\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\ni = 0\r\nnum = 1\r\n\r\nwhile True:\r\n if n < num:\r\n print(names[i])\r\n break\r\n n -= num\r\n i += 1\r\n if i == 5:\r\n i = 0\r\n num *= 2", "queue = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nn = int(input())\r\np = 0\r\nwhile 5 * (2 ** p) < n:\r\n n -= 5 * (2 ** p)\r\n p += 1\r\nprint(queue[(n - 1) // (2 ** p)])", "n = int(input())\r\ni = 0\r\np = 0\r\nwhile p < n:\r\n p += 5 * (2 ** i)\r\n i += 1\r\ns = n - 5 * (2 ** (i -1) - 1)\r\nif s % (2 ** (i -1)) == 0:\r\n num = int(s / (2 ** (i-1)))\r\nelse:\r\n num = int(s / (2 ** (i -1))) + 1\r\nnum = num - 1\r\nname = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nprint(name[num])", "\r\ndef who_is_next(r):\r\n names = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n n = 0\r\n while r:\r\n if 5*(2**n-1) >= r:\r\n for i in range(1,6):\r\n if r - 5*(2**(n-1)-1) - i*(2**(n-1)) <= 0:\r\n return names[i-1]\r\n else:\r\n n += 1\r\nprint(who_is_next(int(input())))", "from math import log2, floor\r\n\r\n\r\ndef solve():\r\n arr = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n n = int(input())\r\n n -= 1\r\n\r\n i = 0\r\n while True:\r\n sub = 5 * pow(2, i)\r\n if sub > n:\r\n break\r\n n -= sub\r\n i += 1\r\n \r\n print(arr[n // pow(2, i)])\r\n\r\n \r\n\r\ndef main():\r\n solve()\r\n\r\n\r\nif __name__ == '__main__':\r\n main()", "n=int(input())\r\no=n\r\na=5\r\nx=0\r\nwhile n>a:\r\n n=n-a\r\n a=a*2\r\n x=x+1\r\n\r\nz=n//(2**x)\r\ny=n%(2**x)\r\nif (z<1) or ((z==1) and (y==0)):\r\n print('Sheldon')\r\nelif (z<2) or ((z==2) and (y==0)):\r\n print('Leonard')\r\nelif (z<3) or ((z==3) and (y==0)):\r\n print('Penny')\r\nelif (z<4) or ((z==4) and (y==0)):\r\n print('Rajesh')\r\nelif (z<5) or ((z==5) and (y==0)):\r\n print('Howard')\r\n", "k = int(input())\r\n\r\nfrom math import floor,log2\r\n\r\nn = floor(log2(0.8*(k+4)))-1\r\n\r\nm = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n# print((k-(5*(2**(n-1))-4)))\r\n# print(n)\r\nd = 2**(n-1)\r\nt = floor(((k+4)/d)-5)\r\n# print(t)\r\nprint(m[t])\r\n\r\n", "n = \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"\r\nx = int(input())\r\nr = x\r\ni = 1\r\nwhile r > i*5:\r\n r = r-(i*5)\r\n i *= 2\r\nif r % i == 0:\r\n print(n[(r//i)-1])\r\nelse:\r\n print(n[(r//i)])\r\n", "g={\"Sheldon\":1, \"Leonard\":1, \"Penny\":1, \"Rajesh\":1, \"Howard\":1}\r\nu=int(input())\r\nfor t in range(1000000):\r\n\tfor h in g:\r\n\t\tu-=g[h]\r\n\t\tif u<=0:\r\n\t\t\tprint(h)\r\n\t\t\texit()\r\n\t\tg[h]*=2", "n = int(input()) - 1\r\nnames = 'Sheldon Leonard Penny Rajesh Howard'.split()\r\n\r\ntotal = 0\r\nfactor = 1\r\nwhile True:\r\n last = total\r\n total += len(names) * factor\r\n if n < total:\r\n i = (n - last) // factor\r\n print(names[i])\r\n break\r\n factor *= 2", "names = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\nn = int(input()) - 1\nk = 1\nwhile n >= (5 * k):\n\tn -= 5 * k\n\tk *= 2\nprint(names[int(n / k)])\n\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sat Jul 18 02:20:19 2020\r\n\r\n@author: thiva\r\n\"\"\"\r\n\r\nSums = [0,5]\r\nval = 2\r\nfor i in range(30):\r\n val = val * 2\r\n Sums.append(5*(val - 1))\r\n\r\nn = int(input())\r\n\r\nfor i in range(len(Sums)):\r\n if(n <= Sums[i]):\r\n checkpoint = i-1\r\n break\r\n\r\nexcess = n - Sums[checkpoint]\r\nans = (excess - 1)//(Sums[checkpoint]//5 + 1)\r\n\r\nPeople = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nprint(People[ans])", "#82A-Double Cola\r\nimport math\r\nnlist=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn=int(input())\r\nx=int((n-1)/5)\r\ny=int(math.log(x+1,2))\r\nif y == 0:\r\n print(nlist[n-1])\r\nelse:\r\n for i in range(y):\r\n n-=5*(2**i)\r\n z=int(n/2**(y))\r\n print(nlist[z])\r\n", "from math import log\n\nn = int(input()) - 1\nx = int(log(n / 5 + 1, 2))\nprint(('Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard')[int((n - (2 ** x - 1) * 5) / 2 ** x)])\n", "import math\r\nn=int(input())\r\ny=1\r\nc=5\r\nli=[ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif(n<=5):\r\n print(li[n-1])\r\n exit()\r\nwhile(1):\r\n if(c>=n):\r\n break\r\n c2=c\r\n c=c+5*(2**y)\r\n y=y+1\r\nn=n-c2\r\nd=math.ceil(n/((c-c2)/5))\r\nprint(li[d-1])\r\n\r\n\r\n\r\n", "p=int(input())\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nR=1\nwhile(R*5<p):\n p-=R*5\n R*=2\nprint(a[(p-1)//R])\n\t \t\t\t\t\t\t \t\t\t \t \t\t\t\t \t \t", "person = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\ncount = 1\r\nstep = 5\r\nwhile(step < n):\r\n n -= step\r\n step *= 2\r\n count *= 2\r\na = 0\r\nwhile(n > count):\r\n n -= count\r\n a += 1\r\nprint(person[a])", "names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input()) - 1\r\np = 1\r\nfor i in range(1, 1000):\r\n b = 5 * p\r\n if b <= n:\r\n n -= b\r\n else:\r\n n -= n % p\r\n n //= p\r\n print(names[n])\r\n break\r\n p <<= 1\r\n", "import math\r\ndef sum(x):\r\n s = (math.pow(2, x)-1)\r\n return s\r\n\r\nname = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\nk = math.log((n/5), 2)\r\nx = math.floor(k)\r\ny = x\r\nif x == k:\r\n x -= 1\r\nif n <= 5:\r\n print(name[n-1])\r\n exit()\r\nif x < 1:\r\n x = 1\r\ntmp = int((pow(2,x)-1)*5)\r\nindex = (n - tmp)/pow(2,x)\r\nif index == 0:\r\n print(name[0])\r\nif index == math.floor(index):\r\n index -= 1\r\nprint(name[math.floor(index)])\r\n\r\n\r\n\r\n\r\n\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Nov 12 15:45:25 2019\r\n\r\n@author: LV\r\n\"\"\"\r\n\r\nimport math\r\nn = int(input())\r\nname = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nr = math.floor(math.log2(n / 5 + 1))\r\nrs = n - 5 * (2 ** r - 1)\r\nif(n <= 5):\r\n print(name[n - 1])\r\nelse:\r\n print(name[rs // (2 ** r)])", "def main():\n n = int(input())\n s = 0\n for i in range(31):\n t = 5 * (2 ** i)\n if (s + t) >= n:\n st = i\n break\n s += t\n ans = ((n - s) / (2 ** (st)))\n if ans <= 1:\n print('Sheldon')\n elif ans <= 2:\n print('Leonard')\n elif ans <= 3:\n print('Penny')\n elif ans <= 4:\n print('Rajesh')\n elif ans <= 5:\n print('Howard')\n\n \nif __name__ == '__main__':\n # t = int(input())\n # while t > 0:\n # t -= 1\n # main()\n main()", "a = int(input())\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ntmp = '12345'\r\ncounter = 0\r\ncounter2 = 1\r\ncounter_names = 0\r\ni = 5\r\nif a <= 5:\r\n print(names[a-1])\r\nelse:\r\n while a - i >= 0:\r\n a -= i\r\n counter2 += counter2\r\n i *= 2\r\n while a - counter2 >= 0:\r\n a -= counter2\r\n counter_names += 1\r\n print(names[counter_names])", "n = int(input()) - 1\n\nnomes = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\n# if (n <= 5):\n# n -= 1\n\ni = 1\nwhile(True):\n if (i*5 <= n):\n n -= i*5\n i *= 2\n\n else:\n print(nomes[int(n/i)])\n break\n \t \t\t\t\t\t\t\t \t\t\t \t \t\t\t\t\t", "from math import log\r\nn = int(input())\r\nnames = [ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif n < 6:\r\n print(names[n - 1])\r\nelse:\r\n p = int(log(((n + 4) / 5), 2))\r\n s = int(5 * (2 ** p - 1))\r\n k = int(2 ** p)\r\n n = n - s\r\n print(names[(n - 1) // k])", "n, r = int(input()), 1\r\nwhile 5*r < n:\r\n n -= 5*r\r\n r *= 2\r\nprint(['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard'][(n-1)//r])", "n = int(input())\r\nif n == 1:\r\n print(\"Sheldon\")\r\nelif n == 2:\r\n print(\"Leonard\")\r\nelif n == 3:\r\n print(\"Penny\")\r\nelif n == 4:\r\n print(\"Rajesh\")\r\nelif n == 5:\r\n print(\"Howard\")\r\nelse:\r\n backup = n\r\n count = 0\r\n while backup - 5*(2**count) > 0:\r\n backup -= 5*(2**count)\r\n count += 1\r\n if backup in range(1,1*(2**count)+1):\r\n print(\"Sheldon\")\r\n elif backup in range(1*(2**count)+1,2*(2**count)+1):\r\n print(\"Leonard\")\r\n elif backup in range(2*(2**count)+1,3*(2**count)+1):\r\n print(\"Penny\")\r\n elif backup in range(3*(2**count)+1,4*(2**count)+1):\r\n print(\"Rajesh\")\r\n elif backup in range(4*(2**count)+1,5*(2**count)+1):\r\n print(\"Howard\")", "from math import ceil\r\nn = int(input())\r\nl = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nk = [5]\r\nif n <= 5:\r\n print(l[n-1])\r\nelse:\r\n sum = 5\r\n j = 2\r\n while sum < n:\r\n r = 2**(j-1)\r\n sum = sum+(5*r)\r\n k.append(sum)\r\n j = j+1\r\n st = k[-2]\r\n present = n-st\r\n actual = ceil(present/r)\r\n print(l[actual-1])\r\n", "n = int(input())\r\nn -= 1\r\nA = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nk = 5\r\nwhile n >= k:\r\n n -= k\r\n k *= 2\r\nprint(A[n // (k // 5)])\r\n \r\n", "import math\r\nn=int(input())\r\nd={1:\"Sheldon\",2:\"Leonard\",3:\"Penny\",4:\"Rajesh\",5:\"Howard\"}\r\nm=math.ceil(math.log((n+5)/5,2))\r\nif m>1:\r\n n=n-5*(2**(m-1)-1)\r\n print(d[math.ceil(n/2**(m-1))])\r\nelse:\r\n print(d[n])", "n = int(input())\ntrip = 1\nif n<=5:\n if n==1:\n print('Sheldon')\n elif n==2:\n print('Leonard')\n elif n==3:\n print('Penny')\n elif n==4:\n print('Rajesh')\n elif n==5:\n print('Howard')\nelse:\n while (n>trip*5):\n n -= trip*5\n trip = trip*2\n person = n//trip\n #print(person)\n if person==0:\n print('Sheldon')\n elif person==1:\n print('Leonard')\n elif person==2:\n print('Penny')\n elif person==3:\n print('Rajesh')\n elif person==4:\n print('Howard')\n \n \n \n \n\t \t\t \t \t\t \t\t\t\t \t\t\t \t", "import math\r\nx=int(input())\r\nn= int(math.log(((x/5)+1),2))\r\nsize=int(math.pow(2,n))\r\nrem=x-5*(size-1)-1\r\np=rem//size\r\nif p==0:\r\n print(\"Sheldon\")\r\nelif p==1:\r\n print(\"Leonard\")\r\nelif p==2:\r\n print(\"Penny\")\r\nelif p==3:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "# n=int(input())\r\n# if(n%2==0):\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\")\r\n# for _ in range(int(input())):\r\n# n=(input())\r\n# if(len(n)<=10):\r\n# print(n)\r\n# else:\r\n# print(n[0]+str(len(n)-2)+n[len(n)-1])\r\n# a=0\r\n# for _ in range(int(input())):\r\n# n=list(map(int,input().split()))\r\n# count=0\r\n \r\n# for i in range(len(n)):\r\n# if(n[i]==1):\r\n# count+=1\r\n# else:\r\n# count-=1\r\n# if(count>0):\r\n# a+=1\r\n# print(a)\r\n# n,m=map(int,input().split())\r\n# a=list(map(int,input().split()))\r\n# count=0\r\n# for i in range(len(a)):\r\n# if(a[i]>=a[m-1] and a[i]>0):\r\n# count+=1\r\n# print(count)\r\n# n,m=map(int,input().split())\r\n# # if((n*m)%2!=0):\r\n# print((n*m)//2)\r\n# # else:\r\n# # print((n*m)//2)\\\r\n# x=0\r\n# for _ in range(int(input())):\r\n# n=input()\r\n# if(n==\"X++\" or n==\"++X\"):\r\n# x=x+1\r\n# else:\r\n# x=x-1\r\n# print(x)\r\n# n = input()\r\n# m = input()\r\n# n = n.lower()\r\n# m = m.lower()\r\n# if n == m:\r\n# print(\"0\")\r\n# elif n > m:\r\n# print('1')\r\n# elif n <m:\r\n# print('-1')\r\n# matrix=[]\r\n# min=[]\r\n# one_line=0\r\n# one_column=0\r\n# for l in range(0,5):\r\n# m=input().split()\r\n# for col,ele in enumerate()\r\n\r\n# a = list(map(int,input().split('+')))\r\n# a.sort()\r\n# print('+'.join([str(c) for c in a]))\r\n# n=list(input())\r\n# # if(n[0].islower()):\r\n# n[0]=n[0].upper()\r\n# else:\r\n# pass\r\n# print(\"\".join(str(x)for x in n))\r\n# n=list(input())\r\n# s=input()\r\n# count=0\r\n# for i in range(1,len(s)):\r\n# if(s[i]==s[i-1]):\r\n# count+=1\r\n# print(count)\r\n# v=[\"A\",\"O\",\"Y\",\"E\",\"U\",\"I\",\"a\",\"i\",\"e\",\"o\",\"u\",\"y\"]\r\n# n=list(input())\r\n# x=[]\r\n# for i in range(len(n)):\r\n# if n[i] not in v:\r\n# x.append(n[i])\r\n# print(\".\"+\".\".join(str(y.lower())for y in x))\r\n# a=[]\r\n# b=[]\r\n# c=[]\r\n# for _ in range(int(input())):\r\n# x,y,z=map(int,input().split())\r\n# a.append(x)\r\n# b.append(y)\r\n# c.append(z)\r\n# print(\"YES\" if sum(a)==sum(b)==sum(c)== 0 else \"NO\") \r\n# m = \"hello\"\r\n# n=input()\r\n# j=0\r\n# flag=0\r\n# for i in range(len(n)):\r\n# if(n[i]==m[j]):\r\n# j=j+1\r\n# if(j==5):\r\n# flag=1\r\n# break\r\n# if(flag==1):\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\")\r\n# a=set(list(input()))\r\n# print(\"CHAT WITH HER!\" if len(set(list(input())))%2==0 else \"IGNORE HIM!\")\r\n# k,n,w=map(int,input().split())\r\n# sum=0\r\n# a=[]\r\n# for i in range(w+1):\r\n# sum+=k*i\r\n# print((sum-n) if sum>n else 0)\r\n# m,n = 0,0\r\n# for i in range(5):\r\n# \ta = map(int,input().split())\r\n# \tfor j in range(5):\r\n# \t\tif a[j]!=0:\r\n# \t\t\tm = i\r\n# \t\t\tn = j\r\n# \t\t\tbreak\r\n# print(abs(m-2)+abs(n-2))\r\n# l,b=map(int,input().split())\r\n# c=0\r\n# while(l<=b):\r\n# \tl=l*3\r\n# \tb=b*2\r\n# \tc=c+1\r\n# print(c)\r\n# from math import ceil \r\n# n,m,a=map(int,input().split()) \r\n# # print(ceil(n/a),ceil(m/a))\r\n# c=ceil(n/a)*ceil(m/a) \r\n# print(c) \r\n# n=int(input())\r\n# if(n%4==0 or n%7==0 or n%44==0 or n%47==0 or n%74==0 or n%444==0 or n%447==0 or n%474==0 or n%477==0):\r\n# \tprint(\"YES\")\r\n# else:\r\n# \tprint(\"NO\")\r\n# def tramCapacity():\r\n# n = int(input().strip())\r\n# pout, pin = map(int, input().strip().split())\r\n# sm = pin\r\n# mx = pin\r\n# for i in range(n-1):\r\n# pout, pin = map(int, input().strip().split())\r\n# sm = sm - pout + pin\r\n# if sm > mx:\r\n# mx = sm\r\n# return mx\r\n\r\n# print(tramCapacity())\r\n# n,k=map(int,input().split())\r\n# for i in range(k):\r\n# \tif(str(n)[-1]==\"0\"):\r\n# \t\tn=n//10\r\n# \telse:\r\n# \t\tn=n-1\r\n# print(n)\r\n# n=int(input())\r\n# n=int(input())\r\n# if(n%5==0):\r\n# \tprint(n//5)\r\n# else:\r\n# \tprint((n//5)+1)\r\n# n=int(input())\r\n# if(n%2==0):\r\n# print(n//2)\r\n# else:\r\n# print(\"-\"+str(n-((n-1)//2)))\r\n# n=int(input())\r\n# arr=list(map(int,input().split()))\r\n# sum=sum(arr)\r\n# deno=len(arr)*100\r\n# print(format(((sum/deno)*100),'.12f'))\r\n# k=int(input())\r\n# l=int(input())\r\n# m=int(input())\r\n# n=int(input())\r\n# d=int(input())\r\n# count=0\r\n# # if(d%k==0):\r\n# # print(d)\r\n# # elif(d%l==0):\r\n# # print(d//l)\r\n# # elif(d%m==0):\r\n# # print(d//m)\r\n# # elif(d%n==0):\r\n# # print(d//n)\r\n# # else:\r\n# for i in range(1,d+1):\r\n# if(i%k==0 or i%l==0 or i%m==0 or i%n==0):\r\n# count+=1\r\n# print(count)\r\n\r\n# a,b=map(int,input().split())\r\n# # if(n%m==0):\r\n# # print(0) \r\n# # else:\r\n# # for i in range(m):\r\n# # n=n+i\r\n# # if(n%m==0):\r\n# # print(i-1)\r\n# # break\r\n# # else:\r\n# # continue\r\n# x=((a+b)-1)/b\r\n# print((b*x)-1)\r\n# for _ in range(int(input())):\r\n# a, b = map(int,input().split(\" \"))\r\n# x=(a + b - 1) // b\r\n# # print(x)\r\n# print((b * x) - a)\r\n# for _ in range(int(input())):\r\n# n=int(input())\r\n# print((n-1)//2)\r\n# n=int(input())\r\n# # n = int(input())\r\n# if n%2 == 0:\r\n# print(8, n-8)\r\n# else:\r\n# print(9, n-9)\r\n# n=int(input())\r\n# a=[]\r\n# for i in range(len(n)):\r\n# x=int(n)-int(n)%(10**i)\r\n# a.append(x)\r\n# print(a)\r\n# # b=max(a)\r\n# print(a[-1])\r\n# for i in range(len(a)):\r\n# a[i]=a[i]-a[-1]\r\n# print(a)\r\n# for _ in range(int(input())):\r\n# n=int(input())\r\n# p=1\r\n# rl=[]\r\n# x=[]\r\n# while(n>0):\r\n# dig=n%10\r\n# r=dig*p\r\n# rl.append(r)\r\n# p*=10\r\n# n=n//10\r\n# for i in rl:\r\n# if i !=0:\r\n# x.append(i)\r\n# print(len(x))\r\n# print(\" \".join(str(x)for x in x))\r\n# n,m=map(int,input().split())\r\n# print(str(min(n,m))+\" \"+str((max(n,m)-min(n,m))//2))\r\n# arr=sorted(list(map(int,input().split())))\r\n# s=max(arr)\r\n# ac=arr[0]\r\n# ab=arr[1]\r\n# bc=arr[2]\r\n# a=s-bc\r\n# b=ab-a\r\n# c=bc-b\r\n# print(a,b,c)\r\n# x=0\r\n# q,t=map(int,input().split())\r\n# for i in range(1,q+1):\r\n# x=x+5*i\r\n# if(x>240-t):\r\n# print(i-1)\r\n# break\r\n# if(x<=240-t):\r\n# print(q) \r\n# # print(q)\r\n# print(z)\r\n# print(x)\r\n# l=(240-t)-x\r\n# print(l)\r\n# if(((240-t)-x)>=0):\r\n# print(q)\r\n# else:\r\n# print(q-1)\r\n# n, L = map(int, input().split())\r\n# arr = [int(x) for x in input().split()]\r\n# arr.sort()\r\n\r\n# x = arr[0] - 0\r\n# y = L - arr[-1]\r\n\r\n# r = max(x, y) * 2\r\n\r\n# for i in range(1, n):\r\n# r = max(r, arr[i] - arr[i-1])\r\n\r\n# print(format(r/2,'.12f'))\r\n\r\n# n,m=map(int,input().split())\r\n# print(((m-n)*2)-1)\r\n# for _ in range(int(input())):\r\n# n=int(input())\r\n# x=360/(180-n)\r\n# # print(x)\r\n# if(n==60 or n==90 or n==120 or n==108 or n==128.57 or n==135 or n==140 or n==144 or n==162 or n==180):\r\n# print(\"YES\")\r\n# elif(x==round(x)):\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\")\r\n# n,m=map(int,input().split())\r\n# if(n<2 and m==10):\r\n# print(-1)\r\n# else:\r\n# x=10**(n-1)\r\n# print(x+(m-(x%m)))\r\n# for _ in range(int(input())):\r\n# n,k=map(int,input().split())\r\n# a=list(map(int,input().split()))\r\n# a.sort()\r\n# c=0\r\n# for i in range(1,n):\r\n# c = (k-a[i])//a[0]\r\n# # print(c)\r\n# for _ in range(int(input())):\r\n# x,y=map(int,input().split())\r\n# a,b=map(int,input().split())\r\n# q=a*(x+y)\r\n# p=b*(min(x,y))+a*(abs(x-y))\r\n# print(min(p,q))\r\n# n,k=map(int,input().split())\r\n# a=n//2+n%2\r\n# print(a)\r\n# if(k<=a):\r\n# print(2*k-1)\r\n# else:\r\n# print(2*(k-a))\r\n# a,b=map(int,input().split())\r\n# count=0\r\n# if(a>=b):\r\n# print(a-b)\r\n# else:\r\n# while(b>a):\r\n# if(b%2==0):\r\n# b=int(b/2)\r\n# count+=1\r\n# else:\r\n# b+=1\r\n# count+=1\r\n# print(count+(a-b))\r\nn=int(input())\r\nwhile n>5:\r\n n = n - 4\r\n n=(n-((n-4)%2))/2\r\n# print(n)\r\nif n==1:\r\n\tprint('Sheldon')\r\nif n==2:\r\n\tprint('Leonard')\r\nif n==3:\r\n\tprint('Penny') \r\nif n==4:\r\n\tprint('Rajesh')\r\nif n==5:\r\n print('Howard')", "\r\nn = int(input())\r\ncur = 5\r\nwhile True:\r\n\tif n - cur > 0:\r\n\t\tn -= cur\r\n\t\tcur *= 2\r\n\telse:\r\n\t\tbreak\r\n\t\t\r\ncur //= 5\r\n\r\nif (n-1) // cur == 0:\r\n\tprint(\"Sheldon\")\r\nelif (n-1) // cur == 1:\r\n\tprint(\"Leonard\")\r\nelif (n-1) // cur == 2:\r\n\tprint(\"Penny\")\r\nelif (n-1) // cur == 3:\r\n\tprint(\"Rajesh\")\r\nelif (n-1) // cur == 4:\r\n\tprint(\"Howard\")", "\r\nfriends = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\n\r\ndef main() -> None:\r\n n = int(input()) - 1\r\n\r\n curr_sum = 0\r\n curr_amount = 5\r\n\r\n while curr_sum + curr_amount <= n:\r\n curr_sum += curr_amount\r\n curr_amount *= 2\r\n\r\n remaining = n - curr_sum\r\n friend_idx = remaining * 5 // curr_amount\r\n \r\n print(friends[friend_idx])\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "#!/usr/bin/env/python\r\n# -*- coding: utf-8 -*-\r\nn = int(input())\r\nb = 1\r\nwhile n >= b * 5:\r\n n -= b * 5\r\n b *= 2\r\nname = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nprint(name[n // b - (0 if n % b else 1)])\r\n", "n=int(input())\r\nd=1\r\nwhile n>d*5:\r\n\tn-=d*5\r\n\td*=2\r\nif n<=d:\r\n\tprint(\"Sheldon\")\r\nelif n<=d*2:\r\n\tprint(\"Leonard\")\r\nelif n<=d*3:\r\n\tprint(\"Penny\")\r\nelif n<=d*4:\r\n\tprint(\"Rajesh\")\r\nelse:\r\n\tprint(\"Howard\")", "n = int(input())\r\ns = 0\r\ni = 5\r\nk = -1\r\nprev = 0\r\nL = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif n<6:\r\n print(L[n-1])\r\nelse:\r\n while s<n:\r\n prev = s\r\n s += i\r\n i *= 2\r\n k+=1\r\n New = n-prev\r\n val = 2**k\r\n if New%val==0:\r\n print(L[(New//val)-1])\r\n else:\r\n print(L[(New//val)])\r\n", "def who_is_next(names, r): \r\n if len(names)>= r:\r\n return names[r-1]\r\n w= 5\r\n z=1\r\n while r:\r\n if (w+ (pow(2,z))* 5) >= r:\r\n for i in range(5):\r\n w+=pow(2,z)\r\n if w >= r:\r\n return names[i]\r\n else:\r\n z+=1\r\n w=w+ (pow(2,z-1))* 5\r\n\r\nr = int(input())\r\nnames = [ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(who_is_next(names,r))", "def who_it_is(n_):\r\n if n_ == 1:\r\n it_is = \"Sheldon\"\r\n elif n_ == 2:\r\n it_is = \"Leonard\"\r\n elif n_ == 3:\r\n it_is = \"Penny\"\r\n elif n_ == 4:\r\n it_is = \"Rajesh\"\r\n elif n_ == 5:\r\n it_is = \"Howard\"\r\n else:\r\n it_is = \"None\"\r\n exit()\r\n return it_is\r\n\r\n\r\nn = int(input())\r\nk = 0\r\nlow = 0\r\nhigh = 5 * 2 ** k\r\nwhile not (low < n <= high):\r\n k += 1\r\n low = high\r\n high += 5 * 2 ** k\r\n\r\nn = n - low\r\nfor i in range(1, 6):\r\n if n <= i * 2 ** k:\r\n print(who_it_is(i))\r\n break\r\n", "from collections import Counter\r\nimport math\r\nimport sys\r\nfrom os import path\r\n\r\nif path.exists('input.txt'):\r\n sys.stdin = open('input.txt', 'r')\r\n sys.stdout = open('output.txt', 'w')\r\nn = int(sys.stdin.readline().rstrip())\r\ni=0\r\nwhile n > 5*(math.ceil((math.pow(2,i)))):\r\n n -= 5*(math.ceil(pow(2,i)))\r\n i+=1\r\nans = int((n -1)/(math.ceil(pow(2,i))))\r\nl = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(l[ans])\r\n", "queue = ['Sheldon', 'Leonard','Penny','Rajesh','Howard']\r\nn = int(input())\r\nr = 1\r\nwhile (r*5)<n:\r\n n = n-(r*5)\r\n r = r*2\r\nprint(queue[int((n-1)/r)])", "n=int(input())\r\nfor i in range(30):\r\n if 5*(2**i-1)<n<=(2**(i+1)-1)*5:\r\n if n-5*(2**i-1)<=2**i:\r\n print('Sheldon')\r\n elif 2**i<n-5*(2**i-1)<=2*2**i:\r\n print('Leonard')\r\n elif 2*2**i<n-5*(2**i-1)<=3*2**i:\r\n print('Penny')\r\n elif 3*2**i<n-5*(2**i-1)<=4*2**i:\r\n print('Rajesh')\r\n elif 4*2**i<n-5*(2**i-1)<=5*2**i:\r\n print('Howard')\r\n break", "a = []\r\nfor i in range(1,30):\r\n a.append(5*(2**i-1))\r\nn = int(input())\r\na.append(n)\r\na.sort()\r\nk = a.index(n)\r\nif k == 0:\r\n if n == 1:\r\n print('Sheldon')\r\n elif n == 2:\r\n print('Leonard')\r\n elif n == 3:\r\n print('Penny')\r\n elif n == 4:\r\n print('Rajesh')\r\n else:\r\n print('Howard')\r\n\r\nelse:\r\n q = n-a[k-1]\r\n l = q-1\r\n m = l//(2**k)\r\n if m == 0:\r\n print('Sheldon')\r\n elif m == 1:\r\n print('Leonard')\r\n elif m == 2:\r\n print('Penny')\r\n elif m == 3:\r\n print('Rajesh')\r\n else:\r\n print('Howard')\r\n", "from math import ceil\r\n\r\nclass DoubleCola:\r\n def __init__(self, index) -> None:\r\n self.index = index\r\n return\r\n \r\n def low_lim(self, p: int) -> int:\r\n return 5 * 2 ** (p - 1) - 4\r\n \r\n def up_lim(self, p: int) -> int:\r\n return 5 * 2 ** p - 5\r\n \r\n def solve(self) -> str:\r\n x = 0\r\n \r\n while not (self.low_lim(x) <= self.index and self.index <= self.up_lim(x)):\r\n x += 1\r\n \r\n self.index -= self.up_lim(x - 1)\r\n \r\n ans = ceil(self.index / 2 ** (x - 1))\r\n \r\n if ans == 1:\r\n return \"Sheldon\"\r\n elif ans == 2:\r\n return \"Leonard\"\r\n elif ans == 3:\r\n return \"Penny\"\r\n elif ans == 4:\r\n return \"Rajesh\"\r\n elif ans == 5:\r\n return \"Howard\"\r\n \r\nindex = int(input()) \r\n\r\nsolution = DoubleCola(index)\r\nprint(solution.solve())", "def power(n,k):\r\n if n==0:\r\n return 1\r\n elif n%2==0:\r\n return power(n//2,k*k)\r\n else:\r\n return k*power(n//2,k*k)\r\ndef f(n):\r\n for i in range(1,n+1):\r\n if (power(i,2)-1)*5>=n:\r\n return i\r\ndef g(a,b):\r\n if a%b==0:\r\n return a//b\r\n else:\r\n return 1+(a//b)\r\n\r\n\r\nn=int(input())\r\npor=f(n)\r\nd=n-(power(por-1,2)-1)*5\r\ns=power(por-1,2)\r\nans=g(d,s)\r\nif ans==1:\r\n print(\"Sheldon\")\r\nelif ans == 2:\r\n print(\"Leonard\")\r\nelif ans == 3:\r\n print(\"Penny\")\r\nelif ans == 4:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "import math\ndef test(n):\n d =[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\n if n <=5:\n return d[n-1]\n i=1\n ans=1\n newans=1\n while ans < n:\n newans+=((2**(i-1))*5)\n if newans > n:\n break\n ans = newans\n i+=1\n return d[((n%ans)//(2**(i-1)))]\n\nprint(test(int(input())))\n", "N = int(input())\r\nl, r = 1, 5\r\nwhile not (l <= N and N <= r):\r\n\tn = r - l + 1\r\n\tl = r + 1\r\n\tr = l + 2 * n - 1\r\nn = (r - l + 1) / 5\r\nfor i in range(5):\r\n\tif l + i * n <= N and N < l + (i + 1) * n:\r\n\t\tif i == 0:\r\n\t\t\tprint('Sheldon')\r\n\t\telif i == 1:\r\n\t\t\tprint('Leonard')\r\n\t\telif i == 2:\r\n\t\t\tprint('Penny')\r\n\t\telif i == 3:\r\n\t\t\tprint('Rajesh')\r\n\t\telif i == 4:\r\n\t\t\tprint('Howard')\r\n\t\texit(0)\r\n\t\t", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[16]:\n\n\nnum=int(input())\narr=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\npow=1\nm=1\nn=num\nwhile n//(5*m)>0:\n n=n-5*m\n m=m*2\ni=0\nwhile n>0:\n n=n-m\n i=i+1\nprint(arr[i-1])\n\n", "a=['Sheldon','Leonard','Penny','Rajesh','Howard']\nn= int(input())\nn-=1\ni=5\nwhile n>=i:\n n-=i\n i*=2\nprint(a[n//(i//5)])\n", "n = int(input())\nq = [[\"Sheldon\", 1], [\"Leonard\", 1] , [\"Penny\", 1], [\"Rajesh\", 1], [\"Howard\", 1]]\ncur = 0\nwhile cur + q[0][1] < n:\n cur += q[0][1]\n q = q[1 : ] + [[q[0][0], q[0][1] * 2]]\nprint(q[0][0])", "n=int(input())-1\r\nwhile(n > 4): \r\n\tn=(n-5)//2\r\n# print(n)\r\nnames=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nprint (names[n])", "pada_malo=int(input())-1\r\nwhile pada_malo>4:\r\n pada_malo=(pada_malo-5)//2\r\nprint([\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"][pada_malo])", "L = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\nn = int(input() )\nt = 1 \nwhile n > 5*t: \n n -= 5*t\n t *= 2\n\nprint(L[(n + t-1) // t - 1] )\n", "# http://codeforces.com/problemset/problem/82/A\n\nimport math\n\nn = int(input())\n\nli = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\n\n# s1 l2 p3 r4 h5 \n# s6 s7 l8 l9 p10 p11 r12 r13 h14 h15\n# s16 s17 s18 s19 l20 l21 l22 l23 p24 p25 p26 p27 r28 r29 r30 r31 h32 h33 h34 h35\n# s36\n\ndef check(var, factor, name):\n till = int(math.ceil(math.log(n, 2)))\n\n li = [factor*(2**x) for x in range(till)]\n li[0] = var\n for i in range(1, till):\n li[i] = li[i]+li[i-1]\n\n # print(li)\n\n for i in range(till):\n if li[i] <= n < (li[i]+(2)**(i+1)):\n print(name)\n return True\n\n\nif n <=5:\n print(li[n-1])\nelif check(6, 5, \"Sheldon\"):\n pass\nelif check(8, 6, \"Leonard\"):\n pass\nelif check(10, 7, \"Penny\"):\n pass\nelif check(12, 8, \"Rajesh\"):\n pass\nelif check(14, 9, \"Howard\"):\n pass\n\n# s - 1 6 16 36 76 156 316", "from math import floor\r\ndef solve():\r\n n = int(input())\r\n names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n num = 5\r\n i = 1\r\n \r\n while True:\r\n if n - num > 0:\r\n n -= num\r\n num *= 2\r\n else:\r\n\r\n break\r\n i += 1\r\n if n % 2**(i-1) == 0:\r\n return names[(n // 2**(i-1)) - 1]\r\n else:\r\n return names[floor(n / 2**(i-1))]\r\n\r\nprint(solve())\r\n", "n=int(input())\nar=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\ns=1\nwhile(s*5<n):\n n-=s*5\n s*=2\nprint(ar[(n-1)//s]) \n \t\t \t\t\t \t\t \t \t\t \t\t", "n=int(input())\r\nsum=0\r\ni=0\r\nwhile(True):\r\n if(sum>=n):\r\n break\r\n sum=sum+5*(2**i)\r\n i=i+1\r\ns=5*(2**(i-1))\r\na=(sum-s)+1\r\nd=((n-a)//(2**(i-1)))+1\r\nif(d==1):\r\n print(\"Sheldon\")\r\nelif(d==2):\r\n print(\"Leonard\")\r\nelif(d==3):\r\n print(\"Penny\")\r\nelif(d==4):\r\n print(\"Rajesh\")\r\nelif(d==5):\r\n print(\"Howard\")\r\n", "n=int(input())\r\nm=n\r\na=1\r\nl=0\r\nwhile m>5*a:\r\n m -=(5*a)\r\n l+=(5*a)\r\n a*=2\r\ng=(n-l)/a\r\n\r\nif (g<=1):\r\n print(\"Sheldon\")\r\nelif (g>1 and g<=2):\r\n print(\"Leonard\")\r\nelif (g>2 and g<=3):\r\n print(\"Penny\")\r\nelif (g>3 and g<=4):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "import sys\nsys.setrecursionlimit(10 ** 5)\n\nn = int(input())-1\nwhile n>4:\n n = (n-5)//2\n\n# for n=1, o/p = Sheldon. Hence the -1\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][n])", "\r\nanslist=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nn=int(input())\r\nc=1\r\nwhile(c*5<n):\r\n n-=c*5\r\n c*=2\r\nn=n-1\r\nans=n//c\r\nprint(anslist[ans])\r\n", "import math\r\n\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nr = int(input())\r\nk = len(names)\r\nm = int(math.log2((r + k - 1) / k))\r\nprint(names[int((r + k - k * 2 ** m - 1) / 2 ** m)])\r\n", "n = int(input())\r\nk = 0\r\nnames = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nwhile 5*(2**k - 1)<=n:\r\n k+=1\r\nk-=1\r\nclones = 2**k\r\nqueue_len = n - 5*(2**k - 1)\r\nif n>5 and queue_len%clones == 0:\r\n print('Howard')\r\nelif n>5:\r\n print(names[queue_len//clones])\r\nelif n==5:\r\n print('Howard')\r\nelse:\r\n print(names[n-1])", "def cola(n):\r\n p = 0\r\n k = 5\r\n while k <= n:\r\n n -= k\r\n p += 1\r\n k *= 2\r\n x = n / 2**p \r\n if x == 0 or x > 4:\r\n return 'Howard'\r\n elif x <= 1:\r\n return 'Sheldon'\r\n elif x <= 2:\r\n return 'Leonard'\r\n elif x <= 3:\r\n return 'Penny'\r\n else:\r\n return 'Rajesh'\r\n\r\nn = int(input())\r\nprint(cola(n))\r\n", "one = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\" ]\r\nc,r,v=0,0,0\r\nn = int(input())\r\nwhile(c<n):\r\n\tif(r == len(one) ):\r\n\t\tr = 0\r\n\t\tv += 1\r\n\tc += pow(2,v)\r\n\tr+=1\r\nprint(one[r-1])\r\n", "cans = int(input())\r\nline = [\r\n 'Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard'\r\n ]\r\nlength = len(line)\r\nsheldon = 1\r\nleonard = 2\r\npenny = 3\r\nrajesh = 4\r\nhoward = 5\r\nwhile cans > length:\r\n cans -= length\r\n length *= 2\r\n sheldon *= 2\r\n leonard *= 2\r\n penny *= 2\r\n rajesh *= 2\r\n howard *= 2\r\n\r\nif cans <= sheldon:\r\n print(\"Sheldon\")\r\nelif cans <= leonard:\r\n print(\"Leonard\")\r\nelif cans <= penny:\r\n print(\"Penny\")\r\nelif cans <= rajesh:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "import math\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\nj = 0\r\nwhile n > 5*math.ceil(2**j):\r\n n -= 5*math.ceil(2**j)\r\n j += 1\r\nans = int((n-1)/math.ceil(2**j))\r\nprint(names[ans])", "import math\r\nn=int(input())\r\ni=5\r\nwhile n>i:\r\n n-=i\r\n i*=2\r\nl=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(l[math.ceil(n/(i//5))-1])\r\n \r\n", "s = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\ni = 1\r\nwhile 5*i < n:\r\n n -= 5*i\r\n i*=2\r\nres = n//i\r\nif n%i != 0:\r\n res+=1\r\nprint(s[res-1])", "n = int(input())\r\ni = 5\r\nu = 0\r\nwhile n-i >= 0:\r\n n -= i\r\n u += 1\r\n i = 2**u*5\r\nr = n/(2**u)\r\nif 0<n/(2**u)<=1:\r\n print(\"Sheldon\")\r\nelif 1<n/(2**u)<=2:\r\n print(\"Leonard\")\r\nelif 2<n/(2**u)<=3:\r\n print(\"Penny\")\r\nelif 3<n/(2**u)<=4:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "import math\r\ndef solve():\r\n n=int(input());\r\n p=0\r\n x=5*(2**p)\r\n while(x<n):\r\n p+=1;\r\n x+=5*(2**p)\r\n r=0\r\n if(p>=1):\r\n # r=5*(2**(p-1))\r\n for i in range(p):\r\n r+=(5*(2**(i)))\r\n \r\n n-=r\r\n \r\n pos = math.ceil(n/(2**p))\r\n # print(\"p = \",p,\"r = \",r,\"n = \",n,\" \",\"pos = \",pos)\r\n mp={1:'Sheldon',2:'Leonard',3:'Penny',4:'Rajesh',5:'Howard'};\r\n print(mp[pos])\r\n \r\n \r\nif __name__ == '__main__':\r\n t = 1;\r\n # t = int(input());\r\n for _ in range(t):\r\n solve();", "import math\r\n\r\nn=int(input())\r\n\r\ncount=0\r\n\r\nk=-1\r\nwhile(n>count):\r\n if(n<=count):\r\n break\r\n k+=1\r\n count+=(5*(2**(k)))\r\n\r\n#print(k)\r\nif(k==0):\r\n start=1\r\nelse:\r\n x=10*(2**(k-1))\r\n start=(x-4)\r\n\r\n#print(start)\r\n\r\nquotient=(n-start)//(2**(k))\r\n\r\nif(quotient==0):\r\n print('Sheldon')\r\nelif(quotient==1):\r\n print('Leonard')\r\n\r\nelif(quotient==2):\r\n print('Penny')\r\n\r\nelif(quotient==3):\r\n print('Rajesh')\r\n\r\nelif(quotient==4):\r\n print('Howard')\r\n", "arr=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn=int(input())\r\nr=1\r\nwhile(r*5<n):\r\n n=n-(r*5)\r\n r=r*2\r\nprint(arr[(n - 1) // r])", "from math import ceil, log2\r\n\r\nn = int(input())\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\ncur_am = 2 ** (ceil(log2(n / 5 + 1)) - 1)\r\ncur_sm = n - 5 * (cur_am - 1) - 1\r\n\r\nres = cur_sm // cur_am\r\nprint(names[res])\r\n", "names=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\na=int(input())\r\np=1\r\nwhile p*5<a:\r\n\ta-=p*5\r\n\tp*=2\r\nprint(names[(a-1)//p])", "n = int(input())\r\nx = 0\r\nl = 0\r\ny = 0\r\nfor i in range(100):\r\n x += 5*2**i\r\n if (x>=n):\r\n l = i\r\n y = x-n\r\n break\r\nnames = [\"Howard\", \"Rajesh\", \"Penny\", \"Leonard\", \"Sheldon\"]\r\nprint(names[int(y/(2**l))])\r\n\r\n \r\n", "n=int(input())\r\ni=0\r\nwhile True:\r\n if n>5*(2**i):\r\n n-=5*(2**i)\r\n i+=1\r\n else:\r\n n-=1\r\n n//=2**i\r\n break\r\nif n==0:print(\"Sheldon\")\r\nelif n==1:print(\"Leonard\")\r\nelif n==2:print(\"Penny\")\r\nelif n==3:print(\"Rajesh\")\r\nelse :print(\"Howard\")", "q=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\n\r\nn=int(input())-1\r\nwhile n>4:\r\n n=n-5>>1\r\nprint(q[n])\r\n", "names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())-1\r\nj = 0\r\nwhile n >= 5*(2**j):\r\n n -= 5*(2**j)\r\n j += 1\r\nans = int(n/(2**j))\r\nprint(names[ans])", "n=int(input ())\ni=5\nc=1\ns=i\nwhile(s<n):\n c=c*2\n i=i*2\n s=s+i\nt=5\nfor k in range (s,0,-c):\n if(n<=k and n>k-c):\n break\n else:\n t=t-1\nif(t==1):\n print ('Sheldon')\nelif(t==2):\n print ('Leonard')\nelif(t==3):\n \tprint ('Penny')\nelif(t==4):\n print ('Rajesh')\nelif(t==5):\n print ('Howard')\n", "n = int(input())\r\ni = 5\r\nc = 1\r\nm = 0\r\nwhile n > i:\r\n n -= i\r\n i *= 2\r\n c *= 2\r\nwhile n > c:\r\n n -= c\r\n m += 1\r\nlis = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(lis[m])\r\n", "friends = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ncur_friend_count = 0\r\nmultiplier = 1\r\nn = int(input())\r\nwhile(cur_friend_count + len(friends) * multiplier < n):\r\n\tcur_friend_count += len(friends) * multiplier\r\n\tmultiplier *= 2\r\nprint(friends[((n - cur_friend_count - 1) // multiplier)])", "target = int(input())\r\ntemp = target // 5\r\nif target % 5 == 0:\r\n temp -= 1\r\ncounter = 0\r\nwhile temp > 0:\r\n temp = (temp - 1) // 2\r\n counter += 1\r\nnumRange = 5 * (2 ** counter)\r\ndeduction = numRange - 5\r\ntarget -= deduction\r\nif target / numRange <= 0.2:\r\n print(\"Sheldon\")\r\nelif target / numRange <= 0.4:\r\n print(\"Leonard\")\r\nelif target / numRange <= 0.6:\r\n print(\"Penny\")\r\nelif target / numRange <= 0.8:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "n = int (input())\r\nstart = 5\r\nwhile n>start:\r\n n= n-start\r\n start = start*2\r\nif n<=start//5:\r\n print (\"Sheldon\")\r\nelif n<=2*start//5:\r\n print (\"Leonard\")\r\nelif n<=3*start//5:\r\n print (\"Penny\")\r\nelif n<=4*start//5:\r\n print (\"Rajesh\")\r\nelse:\r\n print (\"Howard\")\r\n#rint (n)\r\n#print (start) ", "import math\r\nn=int(input())\r\ns=math.ceil(math.log(n/5+1,2))\r\nn=n-(2**(s-1)-1)*5\r\nif 1<=n<=2**(s-1):\r\n print('Sheldon')\r\nelif 2**(s-1)+1<=n<=2*2**(s-1):\r\n print('Leonard')\r\nelif 2*2**(s-1)+1<=n<=3*2**(s-1):\r\n print('Penny')\r\nelif 3*2**(s-1)+1<=n<=4*2**(s-1):\r\n print('Rajesh')\r\nelif 4*2**(s-1)+1<=n<=5*2**(s-1):\r\n print('Howard')\r\n", "n = int(input())\r\nlis = [\"0\", \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif n <= 5:\r\n print(lis[n])\r\nelse:\r\n i = 0\r\n while n > 5 * (2 ** i) :\r\n n = n - (5 * (2 ** i))\r\n i += 1\r\n get = int(n / (2 ** i))\r\n print(lis[get + 1])\r\n\r\n", "n=int(input())\nd=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nc=1\nwhile(c*5<n):\n n-=c*5\n c*=2\nprint(d[(n-1)//c])\n \t \t \t \t\t \t\t\t\t\t \t \t \t \t \t\t \t", "mas=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\n \r\n \r\nn=int(input())\r\nn-=1\r\nwhile n >= 5:\r\n n = n - 5\r\n n = int(n / 2)\r\nprint(mas[n])", "a = int(input())\r\nb=int(a)\r\ni=0\r\npoint=0\r\nwhile True:\r\n if 5*(2**i)<b:\r\n b-=int(5*(2**i))\r\n else:\r\n break\r\n i+=1\r\n\r\n\r\nres=b\r\n\r\nfor g in range(5):\r\n if res-(2**i)>0:\r\n res-=2**i\r\n else:\r\n break\r\n\r\nif g==0:\r\n print(\"Sheldon\")\r\nif g==1:\r\n print(\"Leonard\")\r\nif g==2:\r\n print(\"Penny\")\r\nif g==3:\r\n print(\"Rajesh\")\r\nif g==4:\r\n print(\"Howard\" )\r\n \r\n", "n=int(input())\r\nc=1\r\nwhile(1==1):\r\n if(n-c*5<=0):\r\n break\r\n else:\r\n n-=c*5\r\n c*=2\r\nn=n//c+int(n%c>0)\r\nif(n==1):\r\n print('Sheldon')\r\nif(n==2):\r\n print('Leonard')\r\nif(n==3):\r\n print('Penny')\r\nif(n==4):\r\n print('Rajesh')\r\nif(n==5):\r\n print('Howard')", "n = int(input().strip())\r\nl = 1\r\nk = 5\r\nlll = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile k <= n:\r\n n = n - k\r\n l += 1\r\n k = 2*k\r\nl = l-1\r\nk = 2**l\r\nj = 0\r\nif n == 0:\r\n print(lll[-1])\r\nelse:\r\n for i in range(5):\r\n if n <= k:\r\n print(lll[j])\r\n break\r\n else:\r\n n = n - k\r\n j += 1", "from math import ceil\r\n\r\ndct = {1: \"Sheldon\", 2: \"Leonard\", 3: \"Penny\", 4: \"Rajesh\", 5: \"Howard\"}\r\n\r\nn = int(input())\r\nstep = 0\r\nwhile 5*(2**step-1) < n:\r\n step += 1\r\nres = (n-(5*(2**(step-1)-1)))/2**(step-1)\r\n\r\nprint(dct[int(ceil(res))])\r\n \r\n \r\n", "index = int(input()) - 1\nnames= [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\nx = 1\ncur = 5*x\nwhile index >= cur:\n index -= cur\n x *= 2\n cur = 5*x\n\nprint(names[int(index / x)])\n", "n = int(input())\n\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\ncount = len(names)\n\nwhile n > count:\n n -= count\n count *= 2\n\nindex = (n - 1) // (count // len(names))\nresult = names[index]\nprint(result)\n \t \t\t \t \t \t\t\t \t \t \t \t \t\t\t \t", "n = int(input())\r\nupper, k = 0, 0\r\nwhile(upper < n):\r\n k += 1\r\n upper = 5 * (2 ** k - 1)\r\nn -= 5 * (2 ** (k - 1) - 1)\r\nt = k - 1\r\nif n > 4 * 2 ** t:\r\n print(\"Howard\")\r\nelif n > 3 * 2 ** t:\r\n print(\"Rajesh\")\r\nelif n > 2 * 2 ** t:\r\n print(\"Penny\")\r\nelif n > 2 ** t:\r\n print(\"Leonard\")\r\nelse:\r\n print(\"Sheldon\")", "n = int(input())\nr = 5\ni = 0\nwhile r < n:\n n -= r\n r += r\n i += 1\nres = (n - 1) // 2 ** i\nif res == 0:\n print(\"Sheldon\")\nelif res == 1:\n print(\"Leonard\")\nelif res == 2:\n print(\"Penny\")\nelif res == 3:\n print(\"Rajesh\")\nelif res == 4:\n print(\"Howard\")\n", "n = int(input())\r\nans = 0\r\ntime = 0\r\nindex = 1\r\nfor i in range(0, 100000):\r\n time = i\r\n index = 1 if i == 0 else index * 2\r\n if ans + index * 5 >= n:\r\n break\r\n ans += index * 5\r\nname = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"] \r\nprint(name[(n - ans + index - 1) // index - 1])", "def fun(n):\r\n power_of_two=0\r\n sm=5\r\n prv_sum=0\r\n while(sm<n):\r\n power_of_two+=1\r\n prv_sum=sm\r\n sm+=5*(2**power_of_two)\r\n each_block=(2**power_of_two)\r\n ls=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n for i in range(0,5):\r\n j=i+1\r\n if(prv_sum+(each_block*j)>=n):\r\n print(ls[i])\r\n return\r\n\r\n\r\n\r\n \r\n\r\n# T = int(input())\r\nT=1\r\nfor i in range(T):\r\n # var=input()\r\n # st=input()\r\n # val=int(input())\r\n # ks= list(map(int, input().split()))\r\n # ms= list(map(int, input().split()))\r\n n=int(input())\r\n # ls= list(map(int, input().split()))\r\n fun(n)", "import math\r\n\r\ns=float(input())\r\n\r\nl=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\ndef pick(s):\r\n r=math.log2(s/5+1)\r\n r1=math.floor(r)\r\n\r\n m=s-5*(2**r1-1)\r\n return int(m//(2**r1))\r\n\r\nprint(l[pick(s-1)])\r\n", "l=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn=int(input())\nn-=1\nwhile(n>=5):\n\tn-=5\n\tn//=2\nprint(l[n])\n\t\t\t\t \t\t \t\t \t \t\t\t\t\t\t\t \t", "from math import ceil\r\nn = [int(i) for i in input().split()][0]\r\ncur = 5\r\nwhile n-cur > 0:\r\n n-=cur\r\n cur*=2\r\nans = ceil (n/(cur//5))\r\nans = int (ans)\r\nif ans == 1:\r\n print ('Sheldon')\r\nelif ans == 2:\r\n print ('Leonard')\r\nelif ans == 3:\r\n print ('Penny')\r\nelif ans == 4:\r\n print ('Rajesh')\r\nelse:\r\n print ('Howard')\r\n", "n = int(input())\r\nwhile n > 5:\r\n n = n - 4\r\n s = n % 2\r\n n = (n - s) / 2\r\nif n == 1:\r\n print('Sheldon')\r\nif n == 2:\r\n print('Leonard')\r\nif n == 3:\r\n print('Penny')\r\nif n == 4:\r\n print('Rajesh')\r\nif n == 5: \r\n print('Howard')", "\r\np=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\na=int(input())\r\nj=0\r\ni=1\r\nwhile True:\r\n if a<=(5*i):\r\n print(p[int((a-1)/i)])\r\n break\r\n else:\r\n a-=(5*i)\r\n i*=2\r\n j+=1", "\r\ndef whoIsNext(names, r):\r\n\twhile r > 5:\r\n\t\tr = int((r - 4) / 2)\r\n\treturn names[r - 1]\r\n\r\nif __name__ == '__main__':\r\n\tnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\tr = 1\r\n\tn=int(input())\r\n\tprint(whoIsNext(names, n))", "from math import ceil\r\nq=[ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn=int(input())\r\ni=0\r\ntemp=0\r\nwhile n>temp+2**i*5:\r\n temp+=2**i*5\r\n i+=1\r\nn-=temp\r\n#print(n,i)\r\nprint(q[ceil(n/(2**i))-1])", "n = int(input())\r\n\r\nfor i in range(60):\r\n n = n - 5 * pow(2, i)\r\n if n <= 0:\r\n break\r\n# print(i)\r\n# print(n)\r\nx = pow(2, i)\r\n# print(x)\r\nw = abs(n)\r\n# print(w)\r\nj = 0\r\nwhile w >= 0:\r\n w = w - x \r\n j += 1\r\n# print(j)\r\nz = x + w\r\n# print(z)\r\n\r\nif j == 1:\r\n print(\"Howard\")\r\nif j == 2:\r\n print(\"Rajesh\")\r\nif j == 3:\r\n print(\"Penny\")\r\nif j == 4:\r\n print(\"Leonard\")\r\nif j == 5:\r\n print(\"Sheldon\")\r\n", "a=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn= int(input())\r\nn = n - 1\r\ni= 5\r\nwhile n>=i:\r\n n-=i\r\n i*= 2\r\nprint(a[int(int(n)/int((i/5)))])\r\n", "def find_person(n):\r\n queue = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n p = 1\r\n\r\n while 5 * p < n:\r\n n -= 5 * p\r\n p *= 2\r\n\r\n index = (n - 1) // p\r\n\r\n return queue[index]\r\n\r\n\r\nn = int(input())\r\n\r\nresult = find_person(n)\r\nprint(result)\r\n", "import math\r\n\r\nn = int(input())\r\n\r\nnames = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nturn = math.ceil(math.log2(n/5 + 1))\r\nn -= 5 * (2 ** (turn - 1) - 1)\r\neach = 2 ** (turn - 1)\r\n\r\nprint(names[math.ceil(n/each) - 1])\r\n", "n=int(input())\r\nL=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\ns1,s2=1,1\r\nwhile(True):\r\n if (n>=5*(s1-s2)+1 and n<=5*s1):\r\n break\r\n else:\r\n s2*=2\r\n s1+=s2\r\nk=(n-5*(s1-s2)-1)//s2\r\nprint(L[k])\r\n\r\n\r\n", "import math\nN=int(input())\nK=math.floor(math.log2(((N-1)/5)+1))\nN=N-5*(2**K-1)\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][((N-1)//(2**K))])\n", "import math\r\n\r\nn = int(input())\r\n\r\ndef ceildiv(x,k):\r\n if x%k ==0: return (x//k)\r\n else: return (x//k+1)\r\n\r\ndef roundup(x):\r\n if x-int(x)==0: return (int(x))\r\n else: return (int(x)+1)\r\n\r\ndef person(k):\r\n r = roundup(math.log(ceildiv(k,5)+1)/math.log(2))\r\n return(ceildiv(5*(2**r-1)-k+1,2**(r-1)))\r\n\r\nif person(n) ==5: print(\"Sheldon\")\r\nif person(n) ==4: print(\"Leonard\")\r\nif person(n) ==3: print(\"Penny\")\r\nif person(n) ==2: print(\"Rajesh\")\r\nif person(n) ==1: print(\"Howard\")", "import sys\r\ninput = lambda:sys.stdin.readline()\r\n\r\nint_arr = lambda: list(map(int,input().split()))\r\nstr_arr = lambda: list(map(str,input().split()))\r\nget_str = lambda: map(str,input().split())\r\nget_int = lambda: map(int,input().split())\r\nget_flo = lambda: map(float,input().split())\r\n\r\nmod = 1000000007\r\n\r\ndef solve(n):\r\n mm = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n if n <= 5:\r\n print(mm[n-1])\r\n else:\r\n i = 0\r\n while n > 5*(2**i):\r\n n -= 5*(2**i)\r\n i += 1\r\n ind = int(n / (2**i))\r\n print(mm[ind])\r\n\r\n\r\n\r\n\r\n# for _ in range(int(input())):\r\nn = int(input())\r\nsolve(n)\r\n", "n=int(input())-1\r\nwhile n>4:n=n-5>>1\r\nprint(\"SLPRHheeaoeonjwlnneadaysror hdnd\"[n::5])", "#A - Double Cola\r\n\r\n\r\n'''\r\n***\r\n*\r\n* author :: 101rror\r\n*\r\n***\r\n'''\r\n\r\n\r\n'''\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⣄⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⠀⠀⢀⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡏⠳⡀⠀⡠⠖⡊⠉⠉⣠⠊⠁⣀⣀⡤⠋⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⢤⠃⠀⣱⣦⣶⡿⢁⠴⣋⣤⣿⣩⠅⠐⠒⠈⠉⠉⠉⠉⠒⠤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡜⢀⣾⣠⣼⣿⣿⣿⢿⣵⣾⣿⠿⣫⣴⣶⣶⣶⣶⣶⣶⣶⡤⠝⢍⡉⠁⢀⣠⢔⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡘⢀⣾⣿⣿⣿⣿⡟⣱⣿⣿⣟⣵⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣤⡀⠈⠉⠁⠀⡼⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡀⣿⣿⣿⣿⣿⣿⣧⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣭⣭⣭⣭⣭⡉⠀⠀⠢⣞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠜⢇⢿⣿⣿⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢿⣿⣖⢄⠈⢣⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⠀⣿⣮⣿⣿⣧⣈⣿⣿⣿⠟⠛⢻⣿⣭⣭⣝⣛⣿⣿⣿⣿⣿⣿⣟⢿⣷⣝⢿⣧⠑⢄⢳⡀⠀⠀⢀⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡔⠉⣽⣿⠟⠉⠉⠀⠉⠀⠀⠀⠀⡿⢿⣿⣿⣿⣿⡁⠈⠛⢿⣿⣿⣿⣇⢻⣿⣷⡿⣷⣄⡙⠳⠶⠚⢹⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡅⣾⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⣼⣿⣿⣿⣿⣷⣀⣠⣾⡟⣿⡟⢿⠀⢿⣿⣿⡘⣿⣿⣿⠟⡱⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⢰⣿⠇⠀⠞⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⡿⠋⢁⣼⣿⣿⡿⢿⣿⡟⡇⠈⠀⣼⣿⣿⣧⠘⢯⠴⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⢲⡤⠤⠤⠂⣾⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣹⢿⣿⡧⠀⠈⠉⣿⡯⣀⣀⡋⠙⣿⡇⢸⣿⣿⡍⠻⢷⡈⠳⢄⣀⣀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠉⠲⠴⢾⣿⣿⠠⠀⠢⠤⣀⡀⠀⠀⠀⠀⠃⠘⠋⣀⡤⠚⠋⠀⠤⠄⠀⠀⠀⣿⡇⣾⣿⣿⣿⣄⢀⣀⣀⣤⠞⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡀⠀⣀⡭⣭⣍⡒⠀⠀⠀⠀⠤⠞⣡⠞⢋⣽⣿⣗⠲⡄⠀⢀⣿⣿⣿⣿⣿⣷⡘⣄⢲⠢⣼⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⢡⣿⣧⠘⡁⣼⡿⢳⣼⠀⠂⠀⠀⠀⠀⠀⡄⢸⢿⣁⣹⠟⣇⠀⣼⣿⣿⣿⣿⢻⣿⣷⣌⠻⢄⣈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠚⠒⠉⢹⣿⣇⠁⠩⡓⠚⢫⡂⠀⠀⠀⠀⠀⠀⠁⠈⠢⢉⡠⠔⣢⣾⣿⣿⣿⡿⡁⢰⣿⣿⣿⠓⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡟⠘⡄⠀⠂⠉⠀⠀⠐⠂⠀⠀⠀⠀⠀⠀⠉⠀⠀⠈⠉⢠⣿⢿⠯⠤⢃⣾⣿⠋⢻⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⣇⠀⠀⠀⠀⠀⠀⡀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠉⠀⠀⣂⣤⣾⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⢼⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣛⣛⣻⣿⣿⣿⣶⣤⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡷⣸⢱⡄⠀⠀⠀⠀⠤⠐⠀⠒⠒⠐⠀⠀⠀⠀⠀⣠⣾⣗⢣⡼⣺⡇⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣟⠱⠻⣻⠢⡀⠀⠀⠀⠀⠉⠁⠀⠀⠀⠀⢀⡤⠚⠉⠈⣇⠌⡟⣸⠷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⠃⠤⣿⠀⠈⠓⢤⣀⠀⠀⠀⠀⣀⡤⠚⠁⣀⡤⠤⠒⢻⠈⠁⢹⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⣼⠀⠀⠀⡟⠪⣵⣶⣾⠭⠔⠒⠋⠉⢀⣀⣤⣶⣿⣀⣀⣸⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠀⢀⡤⣷⣄⠀⠀⢀⣤⣤⣶⣶⣿⣿⣿⣿⣿⠟⠉⠉⠻⣷⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠊⠁⣰⢹⣿⠀⠀⢸⣿⣿⣿⣿⣿⣿⠿⣻⠋⠀⠀⠀⠀⠈⠻⣷⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⡶⠋⠀⠀⠀⣴⣿⠆⠙⠀⠀⠘⢛⣛⣛⣩⣭⣴⣾⠃⠀⠀⠀⠀⠀⠀⠀⠀⡏⢳⣾⣷⣦⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⠀⣠⣶⣿⣿⠏⠀⠀⠀⠀⣼⢻⣿⠈⣿⠿⠻⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⡸⠀⣼⣿⣿⣿⣿⣿⣷⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⡟⠀⣀⣀⣀⣴⣿⠀⢻⠀⣏⣀⡀⢽⣻⣽⣿⣿⣿⣿⣿⣶⣶⣶⣤⣤⣤⣄⣠⠓⠛⠛⠿⠿⠿⣿⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⠀⡜⠉⠉⠉⢩⣿⣿⣿⣿⣿⡍⣿⡆⠀⠘⠋⢡⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⢙⣿⠛⢆⠀⠀⠀⠀⠀\r\n⠀⠀⠀⠀⠀⣸⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⢀⣠⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⡆ ⠈⢆⠀⠀⠀⠀\r\n⠀⠀⠀⠀⢰⡇⠀⠀⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⡇⣼⣿⣿⣿⣿⣿⠤⠤⠤⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀ 101rror⢀⣾⣿⣿⣿⣷⠈⠆ :\r\n⠀⠀⠀⢀⣧⡇⠀⠀⢠⠟⠉⠀⠈⢿⣿⣿⣿⣿⢡⣿⣿⣿⣿⣿⣿⣤⣤⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀ Tanjiro ⢠⣾⣿⣿⣿⣿⣿⡆⠸:\r\n⠀⠀⠀⣼⣿⠀⠀⠀⣼⡀ ⣄⣀⣻⣿⣿⡏⢸⠋⠉⣿⣿⣿⣿⣿⡿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇ Kamando⣰⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⢡⠀⠀\r\n⠀⠀⢰⣿⢹⠀⠀⢀⣿⣖⣀⣨⡏⠙⢻⣿⣿⠇⣿⣶⣶⣿⣿⣿⣿⣿⣿⣼⠿⠿⠿⠿⣿⣿⣿⣿⣿⣀⣀⣀⣀⣀⣀⣀⣀⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⡄⠀\r\n⠀⢀⣿⡇⢸⣿⣿⡿⠀⠀⠘⢿⣧⡤⠘⠛⣿⢰⣿⣿⣿⣿⠿⢿⣟⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⡿⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⢣⠀\r\n⠀⣼⢻⠁⢸⣿⣿⠃⠀⠀⠀⢨⣿⣷⣤⠈⠛⣿⡟⣫⣭⣶⣾⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⠁⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⣿⣿⣿⠀\r\n⢠⣿⢿⠀⢸⣿⡿⠀⠀⠀⠀⣾⣿⣿⣷⣦⣴⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⠁⠀⠀⢹⣿⣿⣿⣿⣿⣿⠟⠁⠀⣿⣿⣿⡇\r\n⠸⠿⠬⠧⠾⠿⠧⠤⠤⠤⠴⠿⠿⠿⠿⠯⠷⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠤⠤⠤⠤⠤⠤⠤⠤⠼⠿⠿⠿⠿⠿⠧⠤⠤⠤⠼⠿⠿⠿⠿⠯⠤⠤⠤⠤⠼⠀⠀⠀⠀⠀⠀\r\n'''\r\n\r\n\r\ndef passion():\r\n n = int(input())\r\n #lst = list(map(int, input().split()))\r\n\r\n name = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\n i = 1\r\n\r\n while (i * 5 < n):\r\n n -= (i * 5)\r\n i *= 2\r\n \r\n s = (n - 1) // i\r\n\r\n print(name[s])\r\n\r\n\r\n\r\ndef main():\r\n '''\r\n ToS = int(input())\r\n ToE = ToS\r\n\r\n while(ToE > 0):\r\n passion()\r\n ToE -= 1\r\n '''\r\n passion()\r\n\r\n \r\n\r\nif __name__ == \"__main__\":\r\n main()", "\ndef main():\n n = int(input())\n list_queue = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n flag = 0\n step = 1\n current_queue_member = 0\n while n > 0:\n current_queue_member = flag\n n -= step\n flag += 1\n if flag > len(list_queue) - 1:\n flag = 0\n step *= 2\n print (list_queue[current_queue_member])\n\n\nif __name__ == \"__main__\":\n main()", "import math\r\narr = ['', 'Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\ns = int(input())\r\n\r\nwhile s > 5:\r\n s = math.ceil((s - 5) / 2)\r\nprint(arr[s])", "n = int(input())\r\nnameline = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\r\nif n <= 5:\r\n print(nameline[n-1])\r\nelse:\r\n five = 5\r\n minus = 2\r\n while True:\r\n nkeep = n - five\r\n if nkeep > 0:\r\n n = nkeep\r\n minus *= 2\r\n five *= 2\r\n else:\r\n break \r\n n = int((n-1)*2/minus)\r\n print(nameline[n])\r\n \r\n", "import math\r\nn=int(input())\r\nt=1\r\nperm=5\r\nwhile n>perm :\r\n n-=perm\r\n t*=2\r\n perm*=2\r\n#print(n,t)\r\np = (math.ceil(n/t))\r\nif p == 1:\r\n print(\"Sheldon\")\r\nelif p == 2:\r\n print(\"Leonard\")\r\nelif p == 3:\r\n print(\"Penny\")\r\nelif p == 4:\r\n print(\"Rajesh \")\r\nelse:\r\n print(\"Howard\")", "# WHERE: https://codeforces.com/problemset/page/8?order=BY_RATING_ASC\n\n# Taxi\n# https://codeforces.com/problemset/problem/158/B\n# Input\n# The first line contains integer n (1 ≤ n ≤ 105) — the number of groups of schoolchildren. The second line contains a sequence of integers s1, s2, ..., sn (1 ≤ si ≤ 4). The integers are separated by a space, si is the number of children in the i-th group.\n# Output\n# Print the single number — the minimum number of taxis necessary to drive all children to Polycarpus.\n# ignoreInput = input()\n# groups = list(map(int, input().split()))\n# i = 0\n# j = len(groups) - 1 # last position of the array\n# counter = 0\n\n# counters = [0, 0, 0, 0]\n\n# for group in groups:\n# counters[(group-1)] += 1\n\n# fours = counters[3]\n# threes = counters[2]\n# ones = 0\n# if counters[0] > threes:\n# ones = counters[0] - threes\n# twos = (counters[1]//2) + (((counters[1] % 2)*2+ones)//4)\n# # left = 0\n# if (((counters[1] % 2)*2+ones) % 4) != 0:\n# twos += 1\n\n# print(fours+threes+twos)\n# ---------------------------------------------------------------------------------------------------------------------\n\n# Fancy Fence\n# https://codeforces.com/problemset/problem/270/A\n# Input\n# The first line of input contains an integer t (0 < t < 180) — the number of tests. Each of the following t lines contains a single integer a (0 < a < 180) — the angle the robot can make corners at measured in degrees.\n# Output\n# For each test, output on a single line \"YES\" (without quotes), if the robot can build a fence Emuskald wants, and \"NO\" (without quotes), if it is impossible.\n\n# times = int(input())\n# answers = []\n# for time in range(times):\n# a = int(input())\n# if 360 % (180 - a) == 0:\n# answers.append(\"YES\")\n# else:\n# answers.append(\"NO\")\n# for answer in answers:\n# print(answer)\n# ---------------------------------------------------------------------------------------------------------------------\n\n# Interesting drink\n# https://codeforces.com/problemset/problem/706/B\n# Input\n# The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink.\n# The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop.\n# The third line contains a single integer q (1 ≤ q ≤ 100 000) — the number of days Vasiliy plans to buy the drink.\n# Then follow q lines each containing one integer mi (1 ≤ mi ≤ 109) — the number of coins Vasiliy can spent on the i-th day.\n# Output\n# Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.\n\n# nShops = int(input())\n# shopPrices = list(map(int, input().split()))\n# shopPrices.sort()\n# times = int(input())\n# answers = []\n\n\n# def binarySearch(array, target, carry):\n# index = len(array)\n# if len(array) == 0:\n# return carry\n# if index == 1:\n# if target < array[0]:\n# return carry\n# else:\n# return carry + 1\n# # position in the middle\n# index = index//2\n# if target < array[index]:\n# # return the left\n# newPrices = array[0:index]\n# return binarySearch(newPrices, target, carry)\n# else:\n# # return the right\n# carry += (index)\n# newPrices = array[index:]\n# return binarySearch(newPrices, target, carry)\n\n\n# def iterativeBinary(array, target):\n# low = 0\n# high = len(array) - 1\n# while (low <= high):\n# mid = low + ((high-low)//2)\n# if array[mid] > target:\n# high = mid - 1\n# else:\n# low = mid + 1\n\n# return low\n\n\n# for time in range(times):\n# money = int(input())\n# # looks like the way i implemented the binary search isnt logN :(\n# # buys = binarySearch(shopPrices, money, 0)\n# buys = iterativeBinary(shopPrices, money)\n# answers.append(buys)\n# for answer in answers:\n# print(answer)\n# ---------------------------------------------------------------------------------------------------------------------\n\n# A and B and Compilation Errors\n# https://codeforces.com/problemset/problem/519/B\n# Output\n# Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.\n\n# compilationTimes = int(input())\n# errors1 = list(map(int, input().split()))\n# errors2 = list(map(int, input().split()))\n# errors3 = list(map(int, input().split()))\n\n# errors1.sort()\n# errors2.sort()\n# errors3.sort()\n\n# n = -1\n# isNFound = False\n# m = 1\n# isMFound = False\n# for time in range(compilationTimes):\n# if isNFound and isMFound:\n# break\n# if not isNFound:\n# if time < len(errors2):\n# if errors1[time] != errors2[time]:\n# n = errors1[time]\n# isNFound = True\n# else:\n# n = errors1[time]\n# isNFound = True\n\n# if not isMFound:\n# if time < len(errors3):\n# if errors2[time] != errors3[time]:\n# m = errors2[time]\n# isMFound = True\n# else:\n# m = errors2[time]\n# isNFound = True\n\n\n# print(n)\n# print(m)\n# ---------------------------------------------------------------------------------------------------------------------\n\n\ntarget = int(input())\npeople = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\ntarget -= 1\nk = 0\nwhile True:\n if 5 * (2**k - 1) > target:\n break\n k += 1\nk -= 1\n# print(k)\n# print((5 * (2**k - 1)))\ncorrimiento = target - (5 * (2**k - 1))\nrealK = 2**(k)\npositionArray = (corrimiento)//realK\n# print(realK)\n# print(corrimiento)\nprint(people[positionArray])\n\n\n# ---------------------------------------------------------------------------------------------------------------------\n", "n=int(input())\r\nwhile n>4:\r\n a=n-5\r\n if a%2==0:\r\n n=a//2\r\n else:\r\n n=(a+1)//2\r\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][n-1])", "#Exspiravit\r\n\r\nn=int(input())\r\nl=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ni=-1\r\nwhile n>0:\r\n i+=1\r\n n-=5*2**i\r\nn+=5*2**i-1\r\nprint(l[n//2**i])\r\n", "def function(l,n):\r\n amt=1\r\n while((5*amt)<=n):\r\n n-=(5*amt)\r\n amt*=2\r\n return l[(n-1)//amt]\r\n\r\nl=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(function(l,int(input())))", "n = int(input())\nt = 1\ns = 0\no = 0\ny = 0\nwhile s < n:\n y += 1\n s += t\n o += 1\n if o == 5:\n t *= 2\n o = 0\ny1 = y\nwhile y1 % 5 != 0:\n y1 -= 1\nif y-y1 == 1:\n print('Sheldon')\nelif y-y1 == 2:\n print('Leonard')\nelif y-y1 == 3:\n print('Penny')\nelif y-y1 == 4:\n print('Rajesh')\nelif y-y1 == 0:\n print('Howard')\n", "import math\r\nn=int(input())\r\np=n/5+1\r\nk=math.log(p,2)\r\nk_c=math.floor(k)\r\nk_b=pow(2,k_c)\r\nans_pre=n-5*(k_b-1)\r\n\r\nk_d=pow(2,k_c)\r\nans_beta=math.ceil(ans_pre/k_d)\r\nl=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nprint(l[ans_beta-1])\r\n", "def find_name(n):\n rounds = 1\n while rounds * 5 < n:\n n -= rounds * 5\n rounds *= 2\n position = (n - 1) // rounds\n names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n return names[position]\n\nn = int(input())\nresult = find_name(n)\nprint(result)\n \t\t\t\t \t\t\t \t\t \t\t \t \t\t\t\t \t\t \t", "a = int(input())\r\ni = 0\r\ns = 5\r\nwhile s < a:\r\n i += 1\r\n s += 5 * 2 ** i\r\nn = ['Sheldon'] + ['Leonard'] + ['Penny'] + ['Rajesh'] + ['Howard']\r\nprint(n[(a - (s - 5 * 2 ** i) - 1) // 2 ** i])", "n=int(input())\nc=1\ns = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nwhile(c*5<n):\n n=n-(c*5)\n c*=2\nn=n-1\nn=n//c\nprint(s[n])\n \t\t \t \t\t \t\t\t\t \t \t\t\t \t", "n = int(input())\n\nqueue = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\ni = 0\n\nwhile True:\n if 5*(2**(i+1)-1) > n:\n break\n else:\n i += 1\nl = n - 5*(2**(i)-1)\n\nprint(queue[int((l-1)//(2**i))])\n\n\n\n\n\n\n", "a=int(input())\r\nd=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ns=5\r\nwhile a>s:\r\n a-=s\r\n s*=2\r\ns//=5\r\nif a%s==0:\r\n a//=s\r\nelse:\r\n a//=s\r\n a+=1\r\n\r\nprint(d[a-1])\r\n", "target = int(input())\nmultiplier = 1\nindex = 0\nq = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\nwhile target > 0:\n index = 0\n for i in range(5):\n target -= multiplier\n if target <= 0:\n break\n index += 1\n multiplier *= 2\n \nprint(q[index])\n \t\t \t\t\t\t\t \t \t\t\t \t \t \t", "n=int(input())\r\n\r\ntemp=5\r\ncnt=0\r\n\r\nwhile n-temp>0:\r\n n-=temp\r\n temp*=2\r\n cnt+=1\r\n\r\nx=n//(2**cnt)\r\nif n%(2**cnt)==0:\r\n x-=1\r\n\r\nl=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(l[x])\r\n\r\n ", "import math\r\n\r\nn = int(input())\r\nname = {1 : 'Sheldon', 2 : 'Leonard', 3 : 'Penny', 4 : 'Rajesh', 5 : 'Howard'}\r\n\r\nsum, i, l = 0, 0, [0]\r\nwhile sum < n:\r\n sum += 5 * 2 ** i\r\n l.append(sum)\r\n i += 1\r\n\r\np = math.ceil((n - l[i - 1]) / 2 ** (i - 1))\r\nprint(name[p])", "n=int(input())\nline=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nwhile n>5:\n n=int((n-4)/2)\nprint(line[n-1])\n", "n = int(input())\r\npeeps = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nif n<6:\r\n print(peeps[n-1])\r\nelse:\r\n r = 1\r\n while r*5 < n:\r\n n -= r*5\r\n r *= 2\r\n print(peeps[(n-1)//r])\r\n", "import math\r\nn = int(input())\r\nnames = {1:'Sheldon', 2:'Leonard', 3:'Penny', 4:'Rajesh', 5:'Howard'}\r\nr = 0\r\nwhile(5*(2**r) < n):\r\n n-= 5*(2**r)\r\n r+=1\r\nprint(names[math.ceil(n/(2**r))])\r\n", "n=int(input())-1\r\nwhile n>4:\r\n n=n-5>>1\r\nprint(\"SLPRHheeaoeonjwlnneadaysror hdnd\"[n::5])", "import math\r\nfor _ in range(1):\r\n s=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n n=int(input())\r\n while(n>5):\r\n n=(n-4)//2\r\n print(s[n-1]) \r\n \r\n \r\n \r\n ", "\r\nnombres = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nt = 1\r\ni = 0\r\nv = 0\r\nn = int(input())\r\nif n <= 5:\r\n print(nombres[n-1])\r\nelse:\r\n while v <= n:\r\n v+=5*t\r\n i+=1\r\n if v>n:\r\n v-=5*t\r\n break\r\n #print(v,i,t)\r\n t*=2\r\n\r\n #print(v, t)\r\n #print(\"A partir de {} y va a crecer en razón de {}\".format(v,t))\r\n p = 0\r\n for i in range(1,6):\r\n p = i\r\n z = v+t*i\r\n if z > n:\r\n break\r\n print(nombres[p-1])\r\n\r\n", "k=int(input())\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nr=1\nwhile(r*5<k):\n k-=r*5\n r*=2\nprint(a[(k-1)//r])\n \t \t \t\t \t\t\t\t\t \t\t\t \t\t\t", "n=int(input())-1\r\nwhile n>4:\r\n n=n-5\r\n n=n//2\r\n\r\nl = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(l[n])\r\n", "import math\r\n\r\n# t = int(input())\r\n# while t>0:\r\nn = [int(i) for i in input().split()][0]\r\nk = math.ceil(math.log2(n/5+1) - 1)\r\n\r\nn-=(5*(2**k - 1))\r\nn-=1\r\nx1 = 2**k\r\nx2 = x1+2**k\r\nx3 = x2+2**k\r\nx4 = x3+2**k\r\nx5 = x4+2**k\r\n\r\nif(x1>n>=0):\r\n print(\"Sheldon\")\r\nelif(x2>n>=x1):\r\n print(\"Leonard\")\r\nelif(x3>n>=x2):\r\n print(\"Penny\")\r\nelif(x4>n>=x3):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n # t-=1", "people = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\r\ndef recursion(n):\r\n if n > 5:\r\n answer = recursion((n - 4) // 2)\r\n else:\r\n global people\r\n answer = people[n - 1]\r\n return(answer)\r\n\r\nnum_of_cola = int(input())\r\n\r\nif num_of_cola < 6:\r\n print(people[num_of_cola - 1])\r\nelse:\r\n print(recursion(num_of_cola))\r\n", "n=int(input())\r\nnum,i=0,0\r\nwhile num<n:\r\n if num+5*2**i>n:\r\n break\r\n else:\r\n num+=5*2**i\r\n i+=1\r\nk=n-num\r\nlis=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nm=k%2**i\r\nif m==0:\r\n print(lis[k//2**i-1])\r\nelse:\r\n print(lis[k//2**i])", "# your code goes here\r\nn=int(input())\r\nans=0\r\ncnt=0\r\ns=0\r\ni=0\r\nwhile ans!=1:\r\n\tfor j in range(5):\r\n\t\ts+=(1<<i)\r\n\t\tif s>=n:\r\n\t\t\tcnt=j+1\r\n\t\t\tans=1\r\n\t\t\tbreak\r\n\ti+=1\r\nif cnt==1:\r\n\tprint('Sheldon')\r\nelif cnt==2:\r\n\tprint('Leonard')\r\nelif cnt==3:\r\n\tprint('Penny')\r\nelif cnt==4:\r\n\tprint('Rajesh')\r\nelif cnt==5:\r\n\tprint('Howard')", "d = {0:'Sheldon',1:'Leonard',2:'Penny',3:'Rajesh',4:'Howard'}\r\nn = int(input())\r\nif n > 5:\r\n n-=1\r\n size = 5\r\n i=2\r\n while size <= n:\r\n size+= 5*i\r\n i*=2\r\n range_size = int(5*(i/2))\r\n subrange_size = int(range_size/5)\r\n subranges = []\r\n for i in range(1,6):\r\n subranges.append(range(size-subrange_size*i,size-subrange_size*(i-1)))\r\n for i,j in enumerate(subranges[::-1]):\r\n if n in j:\r\n print(d[i])\r\n break\r\nelse:\r\n print(d[n-1])\r\n'''\r\nthis code in python3 can solve this problem as well:\r\n \r\nn=int(input())-1\r\nwhile n>4:n=n-5>>1\r\nprint(\"SLPRHheeaoeonjwlnneadaysror\\nhdnd\"[n::5])\r\n\r\nbut wait... how the f%#$ ?! look at my code!\r\n'''", "import math\r\n#s = input()\r\n#n = int(input())\r\n#n= (map(int, input().split()))\r\n\r\n#n, m, k =(map(int, input().split()))\r\n\r\nn = int(input())\r\n\r\nk = 0\r\ni = 0\r\nwhile(1):\r\n\r\n k = 5*(pow(2,i)-1)\r\n if(k>=n):\r\n k = 5*(pow(2,i-1)-1)\r\n break\r\n i += 1\r\n\r\nn -= k+1\r\nif(i!=1):\r\n n //= pow(2,i-1)\r\n\r\nlist_=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nprint(list_[n])\r\n\r\n\r\n\r\n\r\n\r\n", "import math;\r\na =int(input())\r\nn=1\r\ns=0\r\nwhile(s<a):\r\n s=5*((2**n) - 1)\r\n n=n+1\r\nq = 5*2**(n-2)\r\nf=a-(s-q)\r\nd= 2**(n-2)\r\nr = math.ceil(f/d)\r\nif(r==1):\r\n print(\"Sheldon\")\r\nelif(r==2):\r\n print(\"Leonard\")\r\nelif(r==3):\r\n print(\"Penny\")\r\nelif(r==4):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "n=int(input())\nif(n<=5):\n ans=n \nelse:\n x=5\n c=1 \n while((x+(c*2)*5)<n):\n #print(x)\n x=x+(c*2)*5\n c=c*2 \n #print(x,c)\n #print(x,c)\n c=c*2 \n diff=n-x \n ans=diff//c \n if(diff%c!=0):\n ans=ans+1\n#ans=person\n#print(ans)\nif(ans==1):\n print(\"Sheldon\")\nif(ans==2):\n print(\"Leonard\")\nif(ans==3):\n print(\"Penny\")\nif(ans==4):\n print(\"Rajesh\")\nif(ans==5):\n print(\"Howard\")\n \n \n \n\n \t\t\t \t \t \t \t \t\t \t\t \t", "names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\nn = int(input())\r\n\r\n# определяем диапазон банок, который покупает каждый человек\r\ns, i = 5, 1\r\nwhile n > s:\r\n n -= s\r\n s *= 2\r\n i *= 2\r\n\r\n# определяем количество людей в очереди\r\nq = int(s/5)\r\n\r\n# определяем, сколько банок выпьет каждый человек\r\nr = int((n-1)/q)\r\n\r\n# вычисляем оставшееся количество банок, которое выпьет последний человек\r\nn -= r * q\r\n\r\n# находим имя человека, который выпьет n-ую банку\r\nprint(names[r])", "n = int(input())\na = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nl = len(a)\nwhile n> l:\n n -= l \n l *= 2\ni = (n-1)//(l//len(a))\nprint(a[i])", "o = ['#',\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nn = int(input())\r\nk = 1\r\ns1,s2 = 0, k * 5\r\nwhile not s1 < n <= s2:\r\n k *= 2\r\n s1 = s2\r\n s2 = k * 5 + s1\r\nelse:\r\n i = 1\r\n s2 = s1 + k\r\n while not s1< n <= s2:\r\n i += 1\r\n s1 = s2\r\n s2 += k\r\n else:\r\n print(o[i])", "userInput = int(input())\r\n\r\nnumero = 1\r\nbigBang = ['Sheldon','Leonard','Penny','Rajesh','Howard']\r\n\r\nwhile numero * 5 < userInput:\r\n userInput -= numero * 5\r\n numero *= 2\r\n\r\nuserInput = userInput-1\r\nuserInput = int(userInput / numero)\r\nsrt = \"\"\r\nprint(srt.join(bigBang[userInput]))", "from math import ceil, log2\nfrom typing import Iterator, List\n\n\ndef get_num_input() -> Iterator[int]:\n return map(int, input().split())\n\n\ndef main() -> None:\n index: int = int(input())\n\n names: List[str] = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n length = len(names)\n multiplier: int = 2 ** (ceil(log2(index / length + 1)) - 1)\n\n print(names[ceil((index - length * (multiplier - 1)) / multiplier) - 1])\n\n\nif __name__ == \"__main__\":\n ONLY_ONCE: bool = True\n for _ in range(1 if ONLY_ONCE else int(input())):\n main()\n", "s=int(input())\nn=1\nnames=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nwhile(n*5<s):\n\ts=s-n*5\n\tn=n*2\nprint(names[(s-1)//n])\n \t\t \t \t \t \t \t \t \t \t\t\t\t\t\t", "n=int(input())\r\na=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\" ]\r\nst=1\r\nwhile True:\r\n p=n\r\n n-=5*st\r\n if n<=0:break\r\n st+=st\r\nprint(a[(p-1)//st])\r\n", "x=int(input())\r\nimport math\r\nn=math.floor(math.log(0.2*x+1)/math.log(2))\r\na=x-(2**n-1)*5\r\nif a>0 and a <=2**(n):\r\n print('Sheldon')\r\nelif a>2**(n) and a <=2**(n+1):\r\n print('Leonard')\r\nelif a>2*2**(n) and a<=3*2**(n):\r\n print('Penny')\r\nelif a>3*2**(n) and a<=4*2**(n):\r\n print('Rajesh')\r\nelif (a>4*2**(n) and a<5*2**(n)) or a==0:\r\n print('Howard')\r\n", "\r\ndef gp2(n):\r\n if n <= 0:\r\n return 0\r\n if n == 1:\r\n return 1\r\n t = 1\r\n while t <= n:\r\n t <<= 1\r\n t >>= 1\r\n\r\n return t\r\n\r\ndef answer(n):\r\n k = (n-1) //5 + 1\r\n gsize = gp2(k)\r\n bn = 5*(gsize-1) + 1\r\n offset = n - bn\r\n subgroup = offset // gsize\r\n answers = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n \r\n return answers[subgroup]\r\n\r\ndef main():\r\n n = int(input())\r\n print(answer(n))\r\n\r\n\r\nmain()", "n=int(input())\na=1\nwhile(a*5<n):\n n=n- a*5 \n a=a*2 \ni=(n-1)//a \nif(i==0):\n print(\"Sheldon\") \nelif(i==1):\n print(\"Leonard\")\nelif(i==2):\n print('Penny')\nelif(i==3):\n print('Rajesh')\nelif(i==4):\n print('Howard')\n\t\t \t \t \t\t\t\t\t\t \t \t\t\t\t\t\t \t \t\t\t", "n = int(input())\nP = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\nintervals = [(1, 5)]\nstart = 1\nend = 5\nm = 1\n\nif n > 5:\n for i in range(1, 101):\n m += 1\n start = end + 1\n end += 5 * 2 ** i \n intervals.append((start, end))\n \n if end >= n:\n break\n\ncount = 2**(m - 1)\n\nP = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\nc = 0\nfor i in range(intervals[-1][0], intervals[-1][1] + 1):\n if i == n:\n print(P[0])\n break\n\n c += 1\n if c == count:\n c = 0\n del P[0]", "n = int(input())\r\nl = [\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\ni = 5\r\nwhile(i<n):\r\n n-=i\r\n i*=2\r\nprint(l[(n-1)//(i//5)])\r\n", "n = int(input()) - 1\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nqueue = 5\nwhile n >= queue:\n n -= queue\n queue *= 2\n\nqueue //= 5\nprint(names[n // queue])\n", "import math\n#for _ in range(int(input())):\n#x,y,z=map(int,input().split())\nn=int(input())\n#l=list(map(int,input().split()))\nl=['Sheldon', 'Leonard', 'Penny', 'Rajesh' ,'Howard']\ny=math.log(math.ceil(n/5),2)\ny=math.floor(y)\nz=2**y\nn-=5*(z-1)\nprint(l[math.ceil(n/z)-1])", "n = int(input())\r\nnum = 1\r\nwhile num * 5 < n:\r\n n -= num * 5\r\n num *= 2\r\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][(n-1) // num])\r\n", "value = int(input())\n\nx = 5\ni = 1\nwhile(x < value):\n x = x + 10 * i\n i = i * 2\n\ntmp = value\nif(x > 5):\n x = x - 10 * (int(i/2))\n tmp = value - x\n\n\nif(tmp <= i * 1 ):\n print(\"Sheldon\")\nelif(tmp <= i * 2 ):\n print(\"Leonard\")\nelif(tmp <= i * 3 ): \n print(\"Penny\")\nelif(tmp <= i * 4 ):\n print(\"Rajesh\")\nelse:\n print(\"Howard\")\n \t \t\t\t\t \t\t\t \t \t\t \t \t \t\t \t\t", "x={'a':'Sheldon', 'b':'Leonard', 'c':'Penny', 'd':\"Rajesh\", 'e': 'Howard'}\nx = list(x.values())\n\nn = int(input())\n\nlim = 0\n\nval = 5\npo = 0\nwhile lim < n:\n new_line = val*(2**po)\n lim += new_line # Raises the line one step\n if lim >= n: # Here I stop and check backwards\n lim -= new_line\n break\n po += 1\n\nfor i in range(1,6):\n if lim + i*(2**po)>=n:\n print(x[i-1])\n break\n", "n = int(input())\r\nl = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nc = 1\r\nwhile c*5<n:\r\n n-= c*5\r\n c*=2\r\nprint(l[(n-1)//c])", "def main():\r\n n = int(input())\r\n\r\n r = 1\r\n while r * 5 < n:\r\n n -= r * 5\r\n r *= 2\r\n\r\n names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n print(names[(n - 1) // r])\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "from math import ceil\n\nfriends = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\nn = int(input())\n\ni = 0\nj = 1\nk = len(friends)\n\nwhile i <= n:\n\ti += k\n\tk += k\n\tj += j\n\nprint(friends[int(ceil((n - (i - k * 0.5)) / (j * 0.5)) - 1)])", "a = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nn = int(input())-1\r\ni = 5\r\nwhile n>=i:\r\n n-=i\r\n i*=2\r\nprint(a[int(n/int(i/5))])\r\n", "n=int(input())\r\nc=1\r\ns = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nwhile(c*5<n):\r\n n=n-(c*5)\r\n c*=2\r\nn=n-1\r\nn=n//c\r\nprint(s[n])", "\r\n\r\n\r\n\r\nn=int(input())\r\nk=1\r\nl=0\r\ns=0\r\nif n>5:\r\n\r\n while s<n:\r\n cola=5*k\r\n k=k*2\r\n l=l+1\r\n s=s+cola\r\n cal=s-cola\r\n cal3=n-cal\r\n cal2=cal3/(k/2)\r\n\r\nelse:\r\n cal2=n\r\nif cal2<=1:\r\n print('Sheldon')\r\nif 1<cal2<=2:\r\n print('Leonard')\r\nif 2<cal2 <= 3:\r\n print('Penny')\r\nif 3<cal2 <= 4:\r\n print('Rajesh')\r\nif 4< cal2 <= 5:\r\n print('Howard')\r\n", "\r\nans = [ \"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nfrom math import ceil\r\nn = int(input())\r\nif n < 6:\r\n\tprint(ans[n - 1])\r\n\texit()\r\n\r\ncount_ = 5\r\ntotal = 5\r\nrptiton = 1\r\nwhile total < n:\r\n\ttotal += count_ * 2\r\n\tcount_ *= 2 \r\n\trptiton *= 2\r\n\r\nind = n - (total - count_ )\r\nprint(ans[ceil(ind / rptiton) - 1])", "n = int(input()) - 1\r\n\r\nnames = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\n\r\ni = 0\r\nwhile n - 5 * (2 ** i) >= 0:\r\n n -= 5 * (2 ** i)\r\n i += 1\r\n\r\nprint(names[n // (2 ** i)])\r\n", "n = int(input())\r\nx = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nr = 1\r\nwhile r*5 < n:\r\n n -= r*5\r\n r *= 2\r\n\r\nm = int((n-1)/r)\r\nprint(x[m])", "n = int(input())-1\r\nk = 5\r\nmul = 1\r\nwhile n > k * mul:\r\n n -= k * mul\r\n mul *= 2\r\nif n//mul % 5 == 0:\r\n print('Sheldon')\r\nelif n//mul % 5 == 1:\r\n print('Leonard')\r\nelif n//mul % 5 == 2:\r\n print('Penny')\r\nelif n//mul % 5 == 3:\r\n print('Rajesh')\r\nelse:\r\n print('Howard')", "def geo_sum(a, q, n):\r\n return int(a*(1-q**n)/(1-q))\r\n\r\n\r\nn = int(input())\r\n# var1 = [int(x) for x in input().split(' ')]\r\n\r\n# lines = []\r\n# for i in range(n):\r\n# line = input()\r\n# if line:\r\n# lines.append(line)\r\n# else:\r\n# break\r\n\r\nnames = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\ni = 0\r\nwhile True:\r\n if geo_sum(5, 2, i) <= n <= geo_sum(5, 2, i+1):\r\n n -= geo_sum(5, 2, i)\r\n ilosc_osob_gen = 5*2**i\r\n name = n/ilosc_osob_gen\r\n if name <= 0.2:\r\n print('Sheldon')\r\n elif name <= 0.4:\r\n print('Leonard')\r\n elif name<= 0.6:\r\n print('Penny')\r\n elif name <= 0.8:\r\n print('Rajesh')\r\n else:\r\n print('Howard')\r\n break\r\n i += 1\r\n", "#!/usr/bin/env python3\nname = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nn = int(input())\ns = 0\ncount = 0\nfor i in range (0, 1000000):\n s += (5 * pow(2, i))\n #print(s)\n if s >= n:\n count = i - 1\n break\ns = 0\nfor i in range (0, count + 1):\n s += (5 * pow(2, i))\nleft = n - s\n#print(\"left, count \", left, count)\n\nif count == -1:\n print(name[left-1])\nelse:\n print(name[int((left - 1)/ pow(2, count + 1))])\n\n", "import math\r\na= int(input())\r\nr=35\r\nc= True\r\nl=0\r\nwhile(c == True):\r\n mid= (r+l)//2\r\n g= int(5*((2 ** (mid)) -1))\r\n h = int(5*((2 ** (mid+1)) -1))\r\n if g <= a and h > a:\r\n c = False\r\n elif g < a:\r\n l = mid\r\n else:\r\n r= mid\r\nw= math.ceil(((a-g) /((2 ** (mid))))) \r\nif w == 1:\r\n print(\"Sheldon\")\r\nelif w == 2:\r\n print(\"Leonard\")\r\nelif w == 3:\r\n print(\"Penny\")\r\nelif w == 4:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n\r\n", "n = int(input())\r\ns = 0\r\nwhile True:\r\n if 5*(2**s-1)>n:\r\n break\r\n else:\r\n s+=1\r\na = n - (5*(2**s-1)-5*(2**(s-1)))\r\nif 0<a<=2**(s-1):\r\n print(\"Sheldon\")\r\nelif 2**(s-1)<a<=2**(s):\r\n print(\"Leonard\")\r\nelif 2**(s)<a<=3*(2**(s-1)):\r\n print(\"Penny\")\r\nelif 3*(2**(s-1)) < a <= 2 ** (s+1):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")", "N=int(input())\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nR=1\nwhile(R*5<N):\n N-=R*5\n R*=2\nprint(a[(N-1)//R])\n\t\t\t \t\t\t\t \t \t \t\t\t\t \t \t\t\t \t \t \t", "from math import ceil\r\nNames = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nn = int(input())\r\ni = 0\r\nj = 1\r\nk = len(Names)\r\nwhile i <= n:\r\n i += k\r\n k += k\r\n j += j\r\nprint(Names[int(ceil((n - (i - k * 0.5)) / (j * 0.5)) - 1)])\r\n", "n=int(input())\r\ndef f(x):\r\n f=5*(2**(x+1)-1)\r\n return f\r\n\r\nimport math\r\nx=math.floor(math.log(n/5+1,2))-1\r\ny=(n-f(x))/2**(x+1)\r\nprint([['Sheldon','Leonard','Penny','Rajesh','Howard'][math.ceil(y)-1],'Howard'][y==0])", "n=int(input())-1\nwhile n>4:\n n=n-5>>1\nprint([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][n])\n \t\t\t \t\t\t \t \t\t \t\t\t\t\t \t\t\t \t\t", "\r\n\r\nn = int(input())\r\n\r\nl = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\r\na = 1\r\n\r\nwhile 5 * a < n:\r\n n = n - (5 * a)\r\n a = a * 2\r\n \r\nprint(l[(n - 1) // a])", "n=int(input())\r\nfor i in range(32):\r\n if 5*(2**(i+1)-1)>=n:\r\n a=i\r\n b=n-5*(2**i-1)\r\n break\r\nif b<=2**a:\r\n print(\"Sheldon\")\r\nelif b<=2*(2**a):\r\n print(\"Leonard\")\r\nelif b<=3*(2**a):\r\n print(\"Penny\")\r\nelif b<=4*(2**a):\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "k=int(input())\nm=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\nr=1\nwhile(r*5<k):\n k-=r*5\n r*=2\nprint(m[(k-1)//r])\n \t \t \t\t\t \t\t\t\t \t \t", "n=int(input())\nc=1\nwhile(c*5<n):\n n=n- c*5 \n c=c*2 \ni=(n-1)//c \nif(i==0):\n print(\"Sheldon\") \nelif(i==1):\n print(\"Leonard\")\nelif(i==2):\n print('Penny')\nelif(i==3):\n print('Rajesh')\nelif(i==4):\n print('Howard')\n\t \t\t\t \t \t\t \t\t \t\t\t \t \t \t \t\t", "n=int(input())\r\nnames=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n \r\nx=1\r\n\r\nwhile x*5<n:\r\n n-=x*5\r\n x*=2\r\n\r\nprint(names[(n-1)//x])\r\n\r\n", "na= [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\na=int(input())\nif a>5:\n i=10\n temp=5\n while temp+i<a:\n temp+=i\n i*=2\n a-=temp\n i=i//5\n ans=a//i\nelse:\n ans=a-1\n\nprint(na[int(ans)])\n", "def fiveToN (num):\r\n p = 5\r\n inc = 5\r\n t = 1\r\n while num >= p:\r\n inc *= 2\r\n p += inc \r\n t *= 2\r\n return t, p, inc\r\npeople = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nnum = int(input())\r\nq = fiveToN(num-1)\r\ncounter = q[1] - q[2]\r\nt = q[0]\r\nfor j in range(5):\r\n counter += t\r\n if num <= counter:\r\n ans = j\r\n break\r\nprint(people[ans])", "import sys\nfrom math import log2\nfrom itertools import accumulate\nfrom bisect import bisect_left\n\nn = int(input())\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\nlst = []\namtineach = []\nfor i in range(0, 31):\n\tlst.append((2 ** i) * 5)\n\tamtineach.append(2 ** i)\nprefixlst = list(accumulate(lst))\n\n\n\n#print(amtineach)\n#print(lst)\n#print(prefixlst)\n\n#print(amtineach[bisect_left(prefixlst, n)])\n\nif n <= 5:\n\tprint(names[n - 1])\nelse:\n\n\tremain = n - prefixlst[bisect_left(prefixlst, n) - 1]\n\ttemp = lst[bisect_left(prefixlst, n)]\n\ttemp1 = remain / temp\n\tif temp1 <= .2:\n\t\tprint(names[0])\n\telif temp1 <= .4:\n\t\tprint(names[1])\n\telif temp1 <= .6:\n\t\tprint(names[2])\n\telif temp1 <= .8:\n\t\tprint(names[3])\n\telse:\n\t\tprint(names[4])\n\n", "n=int(input())\nk=[\"Sheldon\", \"Leonard\", \"Penny\",\"Rajesh\", \"Howard\"]\nn=n-1\nwhile n>4:\n\tn=(n-5)//2\nprint(k[n])\n\n \t \t \t\t\t \t \t \t\t \t \t\t \t\t", "p = int(input())\r\nn = 0\r\nwhile (5 * (2 ** n - 1) < p):\r\n n += 1\r\n\r\nmin = 5 * (2 ** (n - 1) - 1)\r\nif (min < p <= min + 2 ** (n - 1)):\r\n print(\"Sheldon\")\r\nelif (min + 2 ** (n - 1) < p <= min + 2 ** (n)):\r\n print(\"Leonard\")\r\nelif (min + 2 ** (n) < p <= min + 3 * (2 ** (n - 1))):\r\n print(\"Penny\")\r\nelif (min + 3 * (2 ** (n - 1)) < p <= min + 4 * (2 ** (n - 1))):\r\n print(\"Rajesh\")\r\nelif (min + 4 * (2 ** (n - 1)) < p <= min + 5 * (2 ** (n))):\r\n print(\"Howard\")\r\n", "import math\r\nn=int(input())\r\nk=0\r\nwhile n>5*2**(k+1)-5:\r\n k+=1\r\nm=n-5*2**k+5\r\nb=int(math.ceil(m/(2**k)-1))\r\no=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nprint(o[b])", "n = int(input())\r\na = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nmultiplier = 1\r\ncount = 0\r\nwhile count+5*multiplier <= n:\r\n\tcount = count + 5*multiplier\r\n\tmultiplier *= 2\r\ncek = n - count\r\nidx = cek//multiplier\r\nif(cek%multiplier!=0):\r\n\tprint (a[idx])\r\nelse:\r\n\tprint (a[idx-1])", "import math\r\na=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nt=int(input())\r\nd=math.log2(t/5 +1)\r\nk=int(d)\r\nif k==d :\r\n print(a[4])\r\nelse :\r\n s=int(5*((pow(2,k) -1)))\r\n p=(t-s)/(pow(2,k))\r\n if int(p)==p :\r\n print(a[int(p-1)])\r\n else :\r\n print(a[int(p)])\r\n \r\n\r\n\r\n", "from math import ceil\r\n\r\nn = int(input())\r\ni = 0\r\nwhile(n > 5 * ceil(pow(2, i))):\r\n\tn -= 5 * ceil(pow(2, i))\r\n\ti += 1\r\nans = (n - 1) // ceil(pow(2, i))\r\nif ans == 0:\r\n\tprint('Sheldon')\r\nelif ans == 1:\r\n\tprint('Leonard')\r\nelif ans == 2:\r\n\tprint('Penny')\r\nelif ans == 3:\r\n\tprint('Rajesh')\r\nelse:\r\n\tprint('Howard')", "from math import log\r\narr = ['','Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\r\nn = int(input())\r\nk = int(log((n+5)/5)/(log(2)))\r\n#print(k)\r\n\r\nif n<=5:\r\n\tprint(arr[n])\r\nelse:\r\n\tidx = int((n-5*(2**k-1))/(2**k))\r\n\tans = arr[idx+1]\r\n\tprint(ans)\r\n", "import math\r\nn = int(input())\r\ncounter = 0\r\nfor x in range(100000):\r\n if n - 5*(2**x) > 0:\r\n n -= 5*(2**x)\r\n counter += 1\r\n\r\n else:\r\n break\r\nif math.ceil(n/2**(counter)) == 1:\r\n print(\"Sheldon\")\r\nelif math.ceil(n/2**(counter)) == 2:\r\n print(\"Leonard\")\r\nelif math.ceil(n/2**(counter)) == 3:\r\n print(\"Penny\")\r\nelif math.ceil(n/2**(counter)) == 4:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "\r\nt=1\r\nwhile(t>0):\r\n t-=1\r\n n=int(input())\r\n names=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n r=1\r\n while(r*5<n):\r\n n-=r*5\r\n r*=2\r\n print(names[(n-1)//r])", "t=int(input())\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\np=1\nwhile(p*5<t):\n t-=p*5\n p*=2\nprint(a[(t-1)//p])\n\t \t\t\t \t\t \t \t\t\t\t \t\t\t\t\t\t\t\t \t", "n = int(input())\r\nlst = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nrate = 1\r\nwhile (5 * rate) <= n:\r\n n -= (5 * rate)\r\n rate *= 2\r\n\r\nprint(lst[(n-1)//rate])", "arr = [0, 5, 15, 35, 75, 155, 315, 635, 1275, 2555, 5115, 10235, 20475, 40955, 81915, 163835, 327675, 655355, 1310715, 2621435, 5242875, 10485755, 20971515, 41943035, 83886075, 167772155, 335544315, 671088635, 1342177275, 2684354555, 5368709115, 10737418235, 21474836475, 42949672955, 85899345915, 171798691835, 343597383675, 687194767355, 1374389534715, 2748779069435, 5497558138875, 10995116277755, 21990232555515, 43980465111035, 87960930222075, 175921860444155, 351843720888315, 703687441776635]\r\nans = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\n\"\"\"\r\ni = 0\r\nn = 0\r\nwhile i<= 10**9:\r\n \r\n arr.append(i)\r\n i+=(5* (2**n))\r\n n+=1\r\n\"\"\"\r\ntarget = int(input())\r\n\r\n\r\ndef find_range(arr, target):\r\n prev = 0\r\n for i in arr:\r\n if target in range(prev, i+1):\r\n return prev,i \r\n prev = i\r\n \r\nl, r = find_range(arr, target) \r\n\r\ndiff = r - l \r\nran = diff//5 \r\n\r\nupper = l +ran\r\nlower = l\r\n\r\nfor k in range(len(ans)):\r\n if target in range(lower, upper+1):\r\n print(ans[k])\r\n break\r\n lower = upper+1\r\n upper = upper + ran", "l=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\" ]\r\nn=int(input())\r\nwhile n>5:\r\n\tn=(n-4)//2\r\nprint(l[n-1])", "q = [0,\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nn = int(input())\r\nif n < 6:\r\n print(q[n])\r\nelse:\r\n fac = 5\r\n queue = 0\r\n while True:\r\n if n-fac >= 0:\r\n n -= fac\r\n fac *= 2\r\n queue += 1\r\n else:\r\n total = (2**queue)\r\n temp = 1\r\n while True:\r\n if n-total <= 0:\r\n print(q[temp])\r\n break\r\n else:\r\n temp += 1\r\n n -= total\r\n break", "n = int(input())\r\nc = 1\r\n\r\nwhile n > 5*c:\r\n n -= 5*c\r\n c *= 2\r\n\r\nif n <= c:\r\n print(\"Sheldon\")\r\nelif n <= 2*c:\r\n print(\"Leonard\")\r\nelif n <= 3*c:\r\n print(\"Penny\")\r\nelif n <= 4*c:\r\n print(\"Rajesh\")\r\nelse:\r\n print(\"Howard\")\r\n", "import sys\r\nx = int(input())\r\nmulti = 1\r\ny = 0\r\nlst = []\r\np1 = \"Sheldon\"\r\np2 = \"Leonard\"\r\np3 = \"Penny\"\r\np4 = \"Rajesh\"\r\np5 = \"Howard\"\r\nwhile y <= x:\r\n y = y + multi\r\n if y >= x:\r\n print(p1)\r\n sys.exit()\r\n y = y + multi\r\n if y >= x:\r\n print(p2)\r\n sys.exit()\r\n y = y + multi\r\n if y >= x:\r\n print(p3)\r\n sys.exit()\r\n y = y + multi\r\n if y >= x:\r\n print(p4)\r\n sys.exit()\r\n y = y + multi\r\n if y >= x:\r\n print(p5)\r\n sys.exit()\r\n multi = multi *2", "n = int(input())\nm = 5\ni = 1\nq = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\n\nwhile(m * i < n):\n\tn -= m*i\n\ti *= 2\n\nprint(q[(n-1)//(i)])\n \t \t \t\t \t\t \t \t \t \t \t \t \t", "n=int(input())-1\na=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\ni,j,k=0,5,1\nwhile not(i<=n<j):\n\tk*=2\n\ti,j=j,j+5*k\nprint(a[(n-i)//k])\n", "import math\r\nn = int(input())\r\nL = ['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nfor i in range(30):\r\n if (2**(i+1))*5-5 >= n:\r\n m = 2**i\r\n k = n-(2**i)*5+5\r\n p = math.ceil(k/m)-1\r\n for i in range(5):\r\n if i == p:\r\n print(L[i])\r\n break", "n = int(input())\r\ns = 1\r\nwhile n > 5*s:\r\n s = 2*s+1\r\ns = (s+1) // 2\r\nn -= 5*(s-1)\r\nq = (n-1) // s\r\nif q == 0:\r\n print('Sheldon')\r\nelif q == 1:\r\n print('Leonard')\r\nelif q == 2:\r\n print('Penny')\r\nelif q == 3:\r\n print('Rajesh')\r\nelif q == 4:\r\n print('Howard')\r\n\r\n\r\n\r\n", "from math import ceil\r\nn=int(input())\r\nnames=[\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"]\r\nm,c,t=0,0,n\r\nif (n<6):\r\n print(names[n-1])\r\nelse:\r\n while (1):\r\n c=t\r\n t=n-5*(2**(m+1)-1)\r\n if (t<0):\r\n break\r\n m+=1\r\n print(names[ceil(c//(2**m))])", "n=int(input())\r\na=[\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\nh=0\r\nif n<=5:\r\n print(a[n-1])\r\nelse:\r\n while 5*(2**h)<=n:\r\n n-=5*(2**h)\r\n h+=1\r\n print(a[n//(2**h)])\r\n\r\n \r\n", "n=int(input())\nimport math\nk=math.ceil(math.log(n/5+1,2))\na=math.ceil((n-5*(2**(k-1)-1))/(2**(k-1)))\nif a==1:\n print('Sheldon')\nif a==2:\n print('Leonard')\nif a==3:\n print('Penny')\nif a==4:\n print('Rajesh')\nif a==5:\n print('Howard')\n", "n = int(input())\r\nnames = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"]\r\ni = 1\r\ns = 0\r\nleft = 1\r\nright = 0\r\nwhile right <= n:\r\n s = i * 5\r\n right += s\r\n left = right - s + 1\r\n i *= 2\r\n\r\n# print(left, right)\r\nx = (n - left) // (i//2)\r\n# print(x)\r\nprint(names[x])\r\n", "n = int(input())\nnames = \"Sheldon, Leonard, Penny, Rajesh, Howard\"\nnames = names.split(\", \")\ni = 0\nx = 0\nwhile True:\n if x + (5 * (2 ** i)) >= n:\n d = n - 1 - x\n v = d // (2 ** i)\n print(names[v])\n exit()\n\n x += (5 * (2 ** i))\n i += 1\n", "a = int(input())-1\r\nwhile a > 4 :\r\n a-=5\r\n a = a//2\r\nprint([\"Sheldon\",\"Leonard\",\"Penny\",\"Rajesh\",\"Howard\"][a])\r\n\r\n", "q=['Sheldon','Leonard','Penny','Rajesh','Howard']\r\nn=int(input())\r\nz=0\r\nfor x in range(30):\r\n if 5*(2**x-1)>=n:\r\n z=x\r\n break\r\nb=5*(2**(z-1)-1)\r\nfor x in range(5):\r\n b+=2**(z-1)\r\n if b>=n:\r\n print(q[x])\r\n exit(0)\r\n \r\n\r\n \r\n" ]
{"inputs": ["1", "6", "1802", "1", "2", "3", "4", "5", "10", "534", "5033", "10010", "500000000", "63", "841", "3667", "38614", "282798", "9266286", "27385966", "121580142", "5", "300", "1745", "8302", "184518", "1154414", "28643950", "159222638", "24", "505", "4425", "12079", "469726", "3961838", "57710446", "80719470", "1000000000", "999999999", "999999998", "5"], "outputs": ["Sheldon", "Sheldon", "Penny", "Sheldon", "Leonard", "Penny", "Rajesh", "Howard", "Penny", "Rajesh", "Howard", "Howard", "Penny", "Rajesh", "Leonard", "Penny", "Howard", "Rajesh", "Rajesh", "Leonard", "Penny", "Howard", "Howard", "Leonard", "Rajesh", "Sheldon", "Rajesh", "Leonard", "Howard", "Penny", "Penny", "Rajesh", "Sheldon", "Penny", "Penny", "Leonard", "Howard", "Penny", "Penny", "Penny", "Howard"]}
UNKNOWN
PYTHON3
CODEFORCES
647
e59289ccaaa19425dda3a70ff20768e5
Memory and Crow
There are *n* integers *b*1,<=*b*2,<=...,<=*b**n* written in a row. For all *i* from 1 to *n*, values *a**i* are defined by the crows performing the following procedure: - The crow sets *a**i* initially 0. - The crow then adds *b**i* to *a**i*, subtracts *b**i*<=+<=1, adds the *b**i*<=+<=2 number, and so on until the *n*'th number. Thus, *a**i*<==<=*b**i*<=-<=*b**i*<=+<=1<=+<=*b**i*<=+<=2<=-<=*b**i*<=+<=3.... Memory gives you the values *a*1,<=*a*2,<=...,<=*a**n*, and he now wants you to find the initial numbers *b*1,<=*b*2,<=...,<=*b**n* written in the row? Can you do it? The first line of the input contains a single integer *n* (2<=≤<=*n*<=≤<=100<=000) — the number of integers written in the row. The next line contains *n*, the *i*'th of which is *a**i* (<=-<=109<=≤<=*a**i*<=≤<=109) — the value of the *i*'th number. Print *n* integers corresponding to the sequence *b*1,<=*b*2,<=...,<=*b**n*. It's guaranteed that the answer is unique and fits in 32-bit integer type. Sample Input 5 6 -4 8 -2 3 5 3 -2 -1 5 6 Sample Output 2 4 6 1 3 1 -3 4 11 6
[ "n=int(input())\r\nv=[int(i) for i in input().split()]\r\nb=[v[i]+v[i+1] for i in range(n-1)]\r\nb.append(v[-1])\r\nfor i in range(n):\r\n print(b[i],end=\" \")\r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nk=[]\r\nr=0\r\nfor i in range(len(l)):\r\n\tif i==len(l)-1:\r\n\t\tr=l[len(l)-1]\r\n\t\tprint(r,end=\" \")\r\n\telse:\r\n\t\tr=l[i+1]+l[i]\r\n\t\tprint(r,end=\" \")", "num = int(input())\r\narr = list(map(int, input().split())) + [0]\r\n\r\nans = []\r\n\r\nfor i in range(num):\r\n ans.append(arr[i]+arr[i+1])\r\n\r\nprint(*ans)\r\n\r\n", "n = int(input())\nA = list(map(int, input().split()))\n\ndef solve(n,A):\n ans = ''\n B = [0]*n\n for i in range(n-1):\n B[i] = A[i] + A[i+1]\n B[n-1] = A[n-1]\n for b in B:\n ans += str(b) + ' '\n print(ans)\n\nsolve(n,A)", "n = int(input())\r\na = list(map(int, input().split()))\r\nans = [0] * n\r\nfor i in range(n - 1, -1, -1):\r\n if i == n - 1:\r\n ans[i] = a[i]\r\n else:\r\n ans[i] = a[i] + a[i + 1]\r\nfor i in ans:\r\n print(i, end = \" \")", "n=int(input())\r\nm=list(map(int,input().split()))\r\nm.append(0)\r\nfor i in range(len(m)-1):\r\n print(m[i]+m[i+1],end=\" \")\r\n ", "n=int(input())\r\nlis=list(map(int,input().split()))\r\nlis2=[]\r\nfor i in range(0,len(lis)-1):\r\n lis2.append(lis[i]+lis[i+1])\r\nlis2.append(lis[len(lis)-1])\r\nfor i in lis2:\r\n print(i,end=' ')", "n = int(input())\na = list(map(int, input().split()))\nb = [a[i] + a[i+1] for i in range(n-1)] + [a[-1]]\nprint(' '.join(map(str, b)))\n", "import math\r\nimport string\r\n\r\ndef main():\r\n\tn = int(input())\r\n\tb = list(map(int, input().split()))\r\n\ta = [b[i+1] + b[i] for i in range(n - 1)] + [b[-1]]\r\n\tprint(' '.join(map(str, a)))\r\n\r\nif __name__ == '__main__':\r\n\tmain()", "n = int(input())\r\n\r\na = [int(x) for x in input().split()]\r\n\r\n\r\nb = [0]*(n)\r\n\r\nb[n-1] = a[n-1]\r\n\r\n\r\nfor i in range(n-2,-1,-1):\r\n b[i] = a[i] + a[i+1]\r\n\r\nprint(*b)\r\n", "n=int(input())\r\nb=list(map(int,input().split()))\r\na=[]\r\nfor i in range(n-1):\r\n a.append(b[i]+b[i+1])\r\na.append(b[len(b)-1])\r\nprint(*a)\r\n ", "n = int(input())\nnumbers = [int(x) for x in input().split()]\nans = [0] * n\n\nans[n-1] = numbers[n-1]\nfor i in reversed(range(n-1)):\n ans[i] = numbers[i+1] + numbers[i]\n\nfor an in ans:\n print(an, end=\" \")\n\nprint()", "n = int(input())\r\nal = list(map(int, input().split()))+[0]\r\nbl = []\r\n# Bi = Ai + Ai+1\r\nfor i in range(n):\r\n bl+=[str(al[i]+al[i+1])]\r\nprint(\" \".join(bl))\r\n ", "n=int(input())\r\nstring=input()\r\na=string.split()\r\nfor i in range(n):\r\n a[i]=int(a[i])\r\nb=[]\r\nfor i in range(n-1):\r\n b.append(a[i]+a[i+1])\r\nb.append(a[n-1])\r\nfor i in range(n):\r\n print(b[i],end=\" \")\r\n ", "'''\r\ndef main():\r\n from sys import stdin,stdout\r\nif __name__=='__main__':\r\n main()\r\n'''\r\n#10/9/22016-370.2\r\n#1\r\ndef main():\r\n from sys import stdin,stdout\r\n n=int(stdin.readline())\r\n a=tuple(map(int,stdin.readline().split()))\r\n l=[]\r\n for i in range(n):\r\n if i==n-1:\r\n l.append(a[i])\r\n else:\r\n l.append(a[i]+a[i+1])\r\n for i in l:\r\n stdout.write(str(i)+' ')\r\nif __name__=='__main__':\r\n main()\r\n#2\r\n'''\r\ndef main():\r\n from sys import stdin,stdout\r\n s=stdin.readline().strip().lower()\r\n if len(s) & 1:\r\n stdout.write('-1')\r\n else:\r\n x=0\r\n y=0\r\n for i in s:\r\n if i=='l':\r\n x-=1\r\n elif i=='r':\r\n x+=1\r\n elif i=='u':\r\n y+=1\r\n elif i=='d':\r\n y-=1\r\n stdout.write(str((abs(x)+abs(y))//2))\r\n \r\nif __name__=='__main__':\r\n main()\r\n'''\r\n", "n = int(input())\r\nlst = [int(i) for i in input().split()]\r\n\r\nfor i in range(n-1):\r\n print(lst[i]+lst[i+1], end=' ')\r\nprint(lst[n-1])\r\n", "n=int(input())\r\nl=[int(x) for x in input().split(\" \")]\r\nfor i in range(len(l)-1):\r\n print(l[i]+l[i+1],end=\" \")\r\nprint(l[-1])", "\r\nn = int(input())\r\nl = [int(x) for x in input().split()]\r\nf = [0]*n\r\nf[-1] = l[-1]\r\nfor k in range(n-1):\r\n i = n-k-2\r\n # print(i, k)\r\n f[i] = l[i]+l[i+1]\r\n \r\nprint(*f)", "\r\nn = int(input());\r\narr = list(map(int, input().split()))\r\nfor i in range(0,n):\r\n if i < n-1:\r\n print(arr[i]+arr[i+1], end=\" \")\r\n else:\r\n print(arr[i])", "n = int(input().strip())\r\nl = list(map(int,input().strip().split()))\r\na = [l[i]+l[i+1] for i in range(n-1)]\r\na.append(l[len(l)-1])\r\nans = a\r\nprint(*ans)", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=[0 for i in range(n)]\r\nx=a[n-1]\r\nfor i in range(n-1,0,-1):\r\n b[i]=x\r\n x=a[i]+a[i-1]\r\nb[0]=x\r\nprint(*b,sep=' ')\r\n", "n = int(input())\r\nlist = [int(i) for i in input().split()]\r\n\r\nfor i in range(n-1):\r\n print(list[i] + list[i + 1] , end=' ')\r\nprint(list[len(list)-1])", "n=int(input())\n# a=[]\n# for i in range(n):\n# a.append(int(input()))\na=list(map(int,input().split()))\nb=[]\nb.append(a[n-1])\nfor i in range(n-2,-1,-1):\n b.append(a[i]+a[i+1])\nb.reverse()\nprint(*b,sep=' ')\n", "'''\na = [6, -4, 8, -2, 3]\nb = [None, None, None, None, None]\na4 = b4 b = [None, None, None, None, 3]\na3 = b3 - b4 b3 = a3 + b4 b = [None, None, None, 1, 3]\na2 = b2 - b3 + b4 b = [None, None, 6, 1, 3]\na4 = b4\na3 = b3 - b4 <=> a3 = b3 - (a3)\na2 = b2 - b3 + b4 <=> a2 = b2 - (a3)\n'''\n\nn = int(input())\na = list(map(int, input().split()))\n\nb = [None] * len(a)\n\nfor i in range(len(a) - 1, -1, -1):\n if i == len(a) - 1:\n b[i] = a[i]\n else:\n b[i] = a[i] + a[i+1]\n\nprint(\" \".join(str(n) for n in b))\n", "n = int(input())\na = list(map(int, input().split()))\n\nb = []\n\nfor i in range(n - 1):\n\tb.append(a[i] + a[i + 1])\nb.append(a[n-1])\n\nfor i in range(n):\n\tprint(b[i], end = \" \")", "from sys import stdin, stdout\ndef read():\n\treturn stdin.readline().rstrip()\n\ndef read_int():\n\treturn int(read())\n\ndef read_ints():\n\treturn list(map(int, read().split()))\n\ndef solve():\n\tn=read_int()\n\ta=read_ints()\n\tb=[0]*n\n\tb[n-1]=a[n-1]\n\tfor i in range(n-2, -1, -1):\n\t\tb[i]=a[i]+a[i+1]\n\tprint(\" \".join(map(str, b)))\n\nsolve()\n", "n = int(input())\r\nl = [int(x) for x in input().split()]+[0]\r\nprint(*[x+y for x,y in zip(l,l[1:])])", "n = int(input())\r\narr = list(map(int, input().split()))\r\nfor i in range(n - 1):\r\n print(arr[i] + arr[i + 1], end = ' ')\r\nprint(arr[i + 1])", "n=int(input())\na=list(map(int,input().split()))\nb=[0]*n\nb[-1]=a[-1]\ni=n-2\nwhile(i>-1):\n\tb[i]=a[i+1]+a[i]\n\ti-=1\n\t\nfor i in b:\n\tprint(i,end=' ')\n\n\n\n\n\n", "JEgHBytbfaiOzGTIWeCq = int\r\nJEgHBytbfaiOzGTIWeCl = input\r\nJEgHBytbfaiOzGTIWeCj = list\r\nJEgHBytbfaiOzGTIWeCp = map\r\nJEgHBytbfaiOzGTIWeCm = range\r\nJEgHBytbfaiOzGTIWeCs = print\r\nn = JEgHBytbfaiOzGTIWeCq(JEgHBytbfaiOzGTIWeCl())\r\na = JEgHBytbfaiOzGTIWeCj(JEgHBytbfaiOzGTIWeCp(\r\n JEgHBytbfaiOzGTIWeCq, JEgHBytbfaiOzGTIWeCl().split()))+[0]\r\nfor i in JEgHBytbfaiOzGTIWeCm(n):\r\n JEgHBytbfaiOzGTIWeCs(a[i]+a[i+1], end=' ')\r\n", "n = int(input())\na = [int(i) for i in input().split()]\nfor i in range(n-1):\n s = a[i]+a[i+1]\n print(s,end=\" \")\nprint(a[n-1])\n\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\ns = 0\r\nfor i in range(len(l)-1):\r\n\tl[i] = l[i] + l[i+1]\r\n\r\nprint(*l)", "import sys\r\n\r\ndef main():\r\n s = list(map(int, sys.stdin.read().strip().split()[1:]))\r\n return [i + j for i, j in zip(s, s[1:])] + [s[-1]]\r\n\r\nprint(*main())\r\n", "n = int(input())\r\na = [int(i) for i in input().split()]\r\nl = []\r\nfor i in range(n-1):\r\n\tl.append(a[i]+a[i+1])\r\nl = l + [a[-1]]\r\nprint(*l)\r\n", "import sys\r\n\r\nfin = sys.stdin\r\nfout = sys.stdout\r\nn = int(fin.readline())\r\na = list(map(int, fin.readline().split()))\r\nres = [a[-1]]\r\nfor i in range(n - 2, -1, -1):\r\n res.append(a[i + 1] + a[i])\r\nres.reverse()\r\nfout.write(' '.join(map(str, res)))\r\n", "n = int(input())\r\na = input().split()\r\nfor i in range(n-1):\r\n print(int(a[i])+int(a[i+1]), end=' ')\r\nprint(a[n-1])\r\n\r\n", "n=int(input())\r\nb=list(map(int,input().split()))\r\na=[b[i-1]+b[i] for i in range(1,n)]\r\na.append(b[n-1])\r\nprint(*a)", "n=int(input())\nA=list(range(n))\ns=input().split()\nA=list(map(int, s))\nfor i in range(n-1): \n print(A[i]+A[i+1], ' ',end='') \nprint(A[n-1])\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\np=[]\r\nfor i in range(1,n):\r\n p.append(l[i-1]+l[i])\r\np.append(l[-1]) \r\nprint(*p) ", "n = int(input())\nar = list(map(int, input().split())) + [0]\nprint(' '.join(str(ar[i] + ar[i + 1]) for i in range(n)))\n\n", "n = int(input())\r\narr = list(map(int,input().split()))\r\nans = []\r\nfor i in range(len(arr)-1):\r\n diff = arr[i] + arr[i + 1]\r\n ans.append(diff)\r\nans.append(arr[-1])\r\nprint(*ans)", "numbers = int(input())\r\n\r\na = []\r\nb = []\r\n\r\n# for i in range(0, numbers):\r\n# a.append(int(input()))\r\n\r\na = list(map(int, input().split()))\r\n\r\nfor i in range(1, numbers):\r\n b.append(a[i - 1] + a[i])\r\n\r\nb.append(a[numbers - 1])\r\n# print(b)\r\nprint(\" \".join(list(map(str, b))))\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nprint(*(a[i]+a[i+1] for i in range(n-1)), a[-1])\r\n ", "n = int(input()) \r\na = [int(i) for i in input().split()] \r\nb = [-1]*n \r\nfor i in range(n): \r\n if i == n-1 : b[i] = a[i] \r\n else : b[i] = a[i]+a[i+1]\r\nfor i in b : print(i, end = ' ')", "lim=int(input())\r\nnum=list(map(int,input().split(' ')))\r\nfor i in range(lim):\r\n if i==len(num)-1:\r\n print(num[i])\r\n else: \r\n print(num[i]+num[i+1],end=' ')", "#HELLO FROM MARS!)\n#LFGS CLUB\n#Created by:Miron in --17:23-- 25.01.2019::\nn = int(input())\na = list(map(int, input().split()))\nfor i in range(n - 1):\n print(a[i] + a[i + 1], end = ' ')\nprint(a[n - 1])\n", "N = int(input())\nA = list(map(int, input().split()))\nmem = 0\nB = []\nfor i in range(N - 1, -1, -1):\n b = A[i] + mem\n B.append(b)\n mem = -mem\n mem += b\nprint(\" \".join(map(str, B[::-1])))\n", "n = int(input())\na = list(map(int, input().split()))\n\nb = [i+j for i, j in zip(a, a[1:])]\nb.append(a[-1])\nprint(*b, sep=' ')", "n = int(input())\r\nmas = list(map(int,input().split()))\r\ntemp = []\r\nmas.reverse()\r\ntemp = [mas[0]]\r\nfor i in range(n-1) :\r\n c = mas[i]+mas[i+1]\r\n temp.append(c)\r\n \r\nfor i in range(len(temp)-1,-1,-1) :\r\n print(temp[i], end=' ')\r\n", "z=input\r\nn=int(z())\r\nl=list(map(int,z().split()))\r\nx=l[0]\r\nnl=[]\r\nfor i in l[1:]:\r\n nl.append(x+i)\r\n x=i\r\nnl.append( l[-1])\r\nprint(*nl)\r\n\r\n", "n = int(input())\r\ns = input()\r\nb = s.split()\r\nfor i in range(0, n):\r\n b[i] = int(b[i])\r\na = [0] * n\r\nfor i in range(0, n - 1):\r\n a[i] = str(b[i] + b[i + 1])\r\na[n - 1] = str(b[n - 1])\r\nprint(\" \".join(a))\r\n", "n = int(input())\r\na_l = list(map(int,input().split()))\r\nb_l = [a_l[i]+a_l[i+1] for i in range(n-1)]\r\nb_l.append(a_l[n-1])\r\nprint(*b_l)", "n=int(input())\r\nl=[int(e) for e in input().split()]\r\nch=''\r\nfor i in range(1,n):\r\n ch+=str(l[i-1]+l[i])+\" \"\r\nprint(ch+str(l[-1])) \r\n ", "n=int(input())\r\nL=[int(x) for x in input().split()]\r\nfor i in range(1,n):\r\n print(L[i]+L[i-1],end=\" \")\r\nprint(L[-1])", "n=int(input())\r\nlst=list(map(int,input().split()))\r\nlst2=list()\r\nfor i in range(1,n):\r\n lst2.append(lst[i]+lst[i-1])\r\nlst2.append(lst[-1])\r\nst=str(lst2[0])\r\nfor i in range(1,len(lst2)):\r\n st+=f' {lst2[i]}'\r\nprint(st)", "\r\nif __name__ == '__main__':\r\n\tn, = map(int, input().split())\r\n\ta = list(map(int, input().split()))\r\n\tb = [0 for _ in range(n)]\r\n\tb[n-1] = a[n-1]\r\n\tfor i in range(n-2, -1, -1):\r\n\t\tb[i] = a[i] + a[i+1]\r\n\tprint(\" \".join(map(str, b)))", "n = int(input())\n\narr = [int(x) for x in input().split()]\n\nans = [0] * n\nans[-1] = arr[-1]\n\nfor i in range(n-2, -1, -1):\n ans[i] = arr[i] + arr[i+1]\n\nfor i in range(n):\n print(ans[i], end=' ')\nprint()\n", "size = int(input())\r\n\r\narray = list(map(int, input().split()))\r\n\r\nfor i in range(size-1):\r\n print(array[i]+array[i+1], end=\" \")\r\n\r\nprint(array[-1])", "n = int(input())\r\nl = list(map(int , input().split() ))\r\nans =[]\r\nans.append(l[n-1])\r\ni= n-1\r\nj = i-1\r\nwhile len(ans)!=len(l):\r\n ans.append(l[i]+l[j])\r\n i = i-1\r\n j = i-1\r\nans = ans[::-1]\r\nprint(*ans)", "n = int(input())\r\nmat = list(map(int, input().split()))\r\nodd,even =0,0\r\nfor i in range(n-1,-1,-1):\r\n if i%2==0:\r\n mat[i]-=even\r\n mat[i]+=odd\r\n even+=mat[i]\r\n else:\r\n mat[i]+=even\r\n mat[i]-=odd\r\n odd+=mat[i]\r\nprint(*mat)\r\n \r\n", "n=int(input())\r\nif n!=0: \r\n s=[int(S) for S in input().split()]\r\n for i in range(n-1):\r\n print(s[i]+s[i+1],end=' ')\r\n print(s[n-1])", "n = int(input())\r\nb = list(map(int, input().split()))\r\n\r\nt = 0\r\n\r\nfor i in reversed(range(n)):\r\n b[i] = b[i]+t\r\n t = b[i]-t\r\n b[i]=str(b[i])\r\n\r\nprint(\" \".join(b))\r\n", "num=int(input())\r\nl=list(map(int,input().split()))\r\nfor i in range(len(l)):\r\n if i==len(l)-1:\r\n print(l[i])\r\n break\r\n else:\r\n print(l[i]+l[i+1],end=' ')", "n=int(input())\na=[*map(int,input().split())]\nb=[0]*n\nb[n-1]=a[n-1]\nfor i in range(n-2,-1,-1):\n b[i] = a[i] + a[i+1]\nprint(*b)", "n = int(input())\nA = list(map(int, input().split()))\nB = []\nfor i in range(n - 1):\n B.append(A[i] + A[i + 1])\nB.append(A[-1])\nprint(*B)", "t = input\np = print\nr = range\nn = int(t())\na = list(map(int, t().split()))\nb = [0] * n\nfor i in range(n - 1):\n b[i] = a[i] + a[i + 1]\nb[n - 1] = a[n - 1]\nprint(' '.join(map(str, b)))\n", "def solve(arr):\n res = [arr[-1]]\n for i in range(len(arr)-2,-1,-1):\n \n res.insert(0,arr[i]+arr[i+1])\n \n return res\n \n \n\n \n\ndef main() :\n n = int(input())\n arr = list(map(int, input().split(' ')))\n print(*solve(arr))\nmain()\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\ndata = list(map(int, input().split()))\r\n\r\nprint(*([data[i] + data[i + 1] for i in range(n - 1)] + [data[-1]]))", "n=int(input())\r\nb=list(map(int,input().split()))\r\nb.append(0)\r\nc=[b[i]+b[i+1] for i in range (n)]\r\nprint(*c)", "n=int(input())\r\nl=list(map(int,input().split()[:n]))\r\na=[]\r\nfor i in range(n-1):\r\n a.append(l[i]+l[i+1])\r\na.append(l[-1])\r\nfor i in a:\r\n print(i,end=\" \")", "import sys\r\n\r\ndef main():\r\n n = int(input())\r\n a = list(map(int, input().split(' ')))\r\n a.append(0)\r\n\r\n b = list(a[i] + a[i + 1] for i in range(n))\r\n for i in range(n):\r\n print(b[i], end='')\r\n print(' ' if i < n - 1 else '\\n', end='')\r\n\r\nif __name__ == '__main__':\r\n main()", "# You lost the game.\nn = int(input())\nL = list(map(int, input().split()))\nR = [0 for _ in range(n)]\nR[n-1] = L[n-1]\nt = L[n-1]\nfor i in range(n-2,-1,-1):\n if 1:\n R[i] = L[i]+t\n t = R[i]-t\nfor i in range(n):\n print(R[i],end=\" \")\n", "n=int(input())\r\nan=input().split()\r\nfor i in range(n):\r\n\tan[i]=int(an[i])\r\nfor i in range(n-1):\r\n\t\tan[i]=an[i]+an[i+1]\r\n\t\tan[i]=str(an[i])\r\nan[n-1]=str(an[n-1])\r\nprint(\" \".join(an))", "n=int(input())\nip=list(map(int,input().split()))\nfor i in range(n-1):\n print(ip[i+1]+ip[i],end=' ')\nprint(ip[-1])\n \n", "import sys\nn = int(input())\na = list(map(int, sys.stdin.readline().split()))\na.append(0)\nb = [str(a[i]+a[i+1]) for i in range(n)]\nprint(' '.join(b))\n", "n = int(input())\r\nlst = list(map(int,input().split()))\r\nresult = [0]*n \r\nresult[-1] = lst[-1]\r\n\r\nfor i in range(n-2,-1,-1):\r\n result[i] = lst[i] + lst[i+1]\r\n \r\nprint(*result)", "input();r=[*map(int,input().split())]\r\nprint(*[i+j for i,j in zip(r[:-1],r[1:])],r[-1])", "def this_is_b(a,n):\r\n for i in range(n-1):\r\n a[i]=a[i+1]+a[i]\r\n return a\r\n\r\nn=int(input())\r\na=[int(i) for i in input().split()]\r\nfor i in this_is_b(a,n):\r\n print(i,end=' ')", "n=int(input())\r\nl=list(map(int,input().split()))\r\nl1=[]\r\nfor i in range(n-1):\r\n x=l[i]+l[i+1]\r\n l1.append(x)\r\nl1.append(l[-1])\r\nfor i in l1:\r\n print(i,end=\" \")", "input()\r\nX = list(map(int, input().split()))\r\nfor i in range(len(X) - 1):\r\n print(X[i] + X[i + 1], end=\" \")\r\nprint(X[-1])\r\n", "def main():\n n, s = int(input()), 0\n l = list(map(int, input().split()))\n for i, a, b in zip(range(n), l, l[1:]):\n l[i] = a + b\n print(\" \".join((map(str, l))))\n\n\nif __name__ == '__main__':\n main()\n", "n=int(input())\r\na=input().split()\r\nfor i in range (n):\r\n a[i]=int(a[i])\r\na.reverse()\r\nb=[]\r\nb.append(a[0])\r\nfor i in range (n-1):\r\n b.append(a[i]+a[i+1])\r\nb.reverse()\r\nprint (\" \".join(map(str, b)))\r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nl.append(0)\r\nfor x in range(0,len(l)-1):\r\n\tprint(l[x]+l[x+1],end=\" \")", "n = int(input())\r\na = list(map(int,input().split()))\r\nb = [0]*n\r\nb[n-1] = a[n-1]\r\nfor i in range(n-2,-1,-1):\r\n b[i] = a[i+1]+a[i]\r\n\r\nprint(\" \".join(map(str,b)))", "n=int(input())\r\nA=list(map(int,input().split()))+[0]\r\nfor i in range(n):print(A[i]+A[i+1],end=' ')\r\n", "# import sys\r\n# sys.stdin = open(\"test.in\",\"r\")\r\n# sys.stdout = open(\"test.out\",\"w\")\r\nn=int(input())\r\nl=list(map(int,input().split()))\r\na=[l[i-1]+l[i] for i in range(1,n)]\r\na.append(l[-1])\r\nprint(*a)", "n = int(input())\r\n\r\nbi = [int(x) for x in input().split(' ')]\r\n\r\nai = []\r\nf = False\r\nlast = 0\r\n\r\nfor i in bi[::-1]:\r\n if f is False:\r\n ai.append(i)\r\n last = i\r\n f = True\r\n else:\r\n ai.append(last + i)\r\n last = i\r\n\r\nprint(' '.join([str(x) for x in ai[::-1]]))", "n = int(input())\r\nb = list(map(int,input().split(\" \")))\r\na = [0]*n\r\na[n-1] = b[n-1]\r\ni = n - 2\r\nfor i in range(n-1):\r\n a[i] = b[i] + b[i+1]\r\nprint(' '.join([str(x) for x in a]))\r\n", "from math import *\r\n\r\nn = int(input())\r\nb = list(map(int,input().split()))\r\na =[]\r\na.append(b[n-1])\r\nfor i in range(n-1,0,-1):\r\n a.append(b[i]+b[i-1])\r\na.reverse()\r\nfor i in a:\r\n print(i,end = \" \")\r\n", "x = int(input())\r\nt = 0\r\na = list(map(int,input().split()))\r\nz=[0]*len(a)\r\nz[0] = a[len(a)-1]\r\ns = a[len(a)-1]\r\nfor i in range(1,len(a)):\r\n\tif (i)%2 == 1:\r\n\t\tz[i] = a[len(a)-i-1] + s\r\n\telse:\r\n\t\tz[i] = a[len(a)-i-1] - s\r\n\tif (i)%2 == 1:\r\n\t\ts = s - z[i]\r\n\telse:\r\n\t\ts = s + z[i]\r\nfor i in range(len(z)-1,-1,-1):\r\n\tprint(z[i],end=\" \")", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=[0]*n\r\nb[n-1]=a[n-1]\r\nfor i in range(n-2,-1,-1):\r\n b[i]=a[i]+a[i+1]\r\nprint(' '.join(map(str,b)))", "n = int(input())\r\ncrow = [int(x) for x in input().split()] + [0]\r\nwas = []\r\nfor i in range(n):\r\n was.append(crow[i] + crow[i+1])\r\nprint(*was)", "import math,sys,re,itertools\r\nrs,ri,rai=input,lambda:int(input()),lambda:list(map(int, input().split()))\r\nn = ri()\r\na = rai()\r\nb = [0] * n\r\nb[-1] = a[-1]\r\nfor i in reversed(range(n-1)):\r\n b[i] = a[i] + a[i+1]\r\nprint(\" \".join(map(str, b)))\r\n\r\n", "x=int(input())\r\ny=list(map(int,input().split()))\r\nfor i in range(x-1):\r\n print(y[i]+y[i+1],end=\" \")\r\nprint(y[x-1])\r\n\r\n", "read = lambda: map(int, input().split())\r\nn = int(input())\r\na = list(read())\r\ndif = [a[i + 2] - a[i] for i in range(n - 2)]\r\nb = [0] * n\r\nb[n - 1] = a[n - 1]\r\nb[n - 2] = a[n - 1] + a[n - 2]\r\nfor i in range(n - 3, -1, -1):\r\n b[i] = b[i + 1] - dif[i]\r\nprint(*b)\r\n", "input()\r\nA=list(map(int,input().split()))\r\n\r\nB=[0]*len(A)\r\nB[-1]=A[-1]\r\nfor i in range(len(B) - 2,-1,-1):\r\n B[i] = A[i] + A[i + 1]\r\nfor b in B:\r\n print(b,end=' ') ", "n = int(input())\r\nl = list(map(int, input().split()))\r\nres = [l[0]]+[0] * (n-1)\r\n\r\nfor i in range(1,n):\r\n res[i] = l[i]\r\n res[i-1] = res[i-1] + l[i]\r\nprint(\" \".join(map(str, res)))", "n = int(input())\r\nA = list(map(int, input().split()))\r\nB = [0]*(n+1); A += [0]*2\r\nfor i in range(n-1,-1,-1):\r\n B[i] = A[i] - A[i+2] + B[i+1]\r\nfor i in range(n):\r\n print(B[i], end = ' ')\r\n", "n = int(input())\r\na = list(map(int,input().split()))\r\na.reverse()\r\nb = [str(a[0])]\r\nfor i in range(len(a)-1):\r\n\tb.append(str(a[i]+a[i+1]))\r\nb.reverse()\r\nprint(\" \".join(b))", "input()\r\nb=list(map(int, input().split()))+[0]\r\nprint(*(b[i-1]+b[i] for i in range(1, len(b))))", "n = int(input())\na = list(map(int, input().split()))[::-1]\narr = [a[0]]\nfor i in range(1, n):\n arr.append(a[i] + a[i - 1])\narr.reverse()\nfor item in arr:\n print(item, end=\" \")\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\n# l2=[]\r\n# a=0\r\nfor i in range(n-1):\r\n\tprint(l[i]+l[i+1],end=\" \")\r\n\t# a=l[i]+l[i+1]\r\n\t# l2.append(a)\r\n# l2.append(l[-1])\r\nprint(l[-1])", "#!/usr/bin/python\r\n\r\nN = int(input())\r\nAs = [int(x) for x in input().split(\" \") if len(x) > 0]\r\nprev_a = As[0]\r\nfor a in As[1:]:\r\n print(prev_a + a, end=\" \")\r\n prev_a = a\r\n\r\nprint(prev_a)\r\n\r\n", "a=int(input())\r\nb=list(map(int,input().split()))\r\nfor x in range(a-1):\r\n\tprint(b[x]+b[x+1],end=' ')\r\nprint(b[-1],end='')", "n = int(input())\nx = list(map(int, input().split()))\nfor i in range(n):\n if i == n - 1:\n print(x[i], end=' ')\n else:\n print(x[i] + x[i + 1], end=' ')\n", "n=int(input());a=list(map(int,input().split()));b=[0]*(n-1)+[a[-1]];c=a[-1]\r\nfor j in range(n-2,-1,-1):\r\n b[j]=a[j]+c;c=-1*(c-b[j])\r\nprint(*b)", "n = int(input())\r\na = [int(x) for x in input().split()]\r\nb = []\r\nfor i in range (n - 1):\r\n b.append(a[i] + a[i + 1])\r\nb.append(a[n - 1])\r\nfor x in b:\r\n print(x, end = \" \")", "n = int(input())\r\na = [int(s) for s in input().split()] + [0]\r\nb = [a[i] + a[i + 1] for i in range(n)]\r\nprint(*b)", "n = int(input())\nArr= list(map(int,input().split()))\n\nb =[0 for i in range(n)]\nS =\"\"\nfor i in range(n):\n\tif(i<n-1):\n\t\tb[i] = Arr[i]+Arr[i+1]\n\telse:\n\t\tb[i] = Arr[i]\n\tS+=str(b[i])\n\tS+=\" \"\nprint(S)", "# import sys\r\n# sys.stdin=open(\"input.in\",\"r\")\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nfor i in range(n-1):\r\n\tprint(a[i]+a[i+1],end=\" \")\r\nprint(a[n-1])", "n = int(input())\r\nA = list(map(int, input().split()))\r\n\r\nfor i in range(n-1):\r\n print(A[i]+A[i+1], end=' ')\r\n \r\nprint(A[n-1])", "n = int(input())\r\nd = list(map(int, input().split()))\r\nfor i in range(n-1):\r\n print(d[i] + d[i+1], end=' ')\r\nprint(d[n-1])\r\n", "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 main():\n n = I()\n arr = ARR()\n ans = [0] * n\n ans[-1] = arr[-1]\n for i in range(n - 2, -1, -1):\n ans[i] = arr[i] + arr[i+1]\n \n for e in ans:\n print(e, end=\" \")\n \nmain()", "n=int(input())\r\nl=list(map(int,input().split()))[::-1]\r\nans=[0]*n\r\nans[0]=l[0]\r\nfor i in range(1,n):\r\n ans[i]=l[i]+l[i-1]\r\nprint(' '.join(map(str,ans[::-1])))", "input()\ndata = [int(info) for info in input().split(' ')]\n\ndata = list(reversed(data))\n\noutput = [data[0]]\n\nfor i, e in enumerate(data[1:]):\n\toutput.append(data[i + 1] + data[i])\n\nprint(' '.join([str(info) for info in reversed(output)]))\n", "non = int(input())\r\ntext = input()\r\nnumbers = text.split()\r\nsum = []\r\n\r\n#print(numbers)\r\n\r\nfor i in range(len(numbers)-1):\r\n a = int(numbers[i]) + int(numbers[i+1])\r\n sum.append(a)\r\nsum.append(numbers[len(numbers) - 1])\r\n\r\nfor item in sum:\r\n print(item, end=\" \")\r\n\r\n", "n = int(input())\r\nl = list(map(int, input().split()))\r\nans = [0]*n\r\n\r\nfor i in range(n-1):\r\n ans[i] = l[i] + l[i+1]\r\n\r\nans[-1] = l[-1]\r\nprint(*ans)", "##n = int(input())\r\n##a = list(map(int, input().split()))\r\n##print(\" \".join(map(str, res)))\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\n\r\nb = []\r\nfor i in range(0, n-1):\r\n b.append(a[i]+a[i+1])\r\nb.append(a[n-1])\r\nprint(' '.join(map(str, b)))", "n = int(input())\r\nb = list(map(int, input().split()))\r\nb.append(0)\r\na = map(lambda x, y: str(x+y), b, b[1:])\r\nprint(\" \".join(a))", "a=int(input())\r\nb=list(map(int, input().split()))+[0]\r\nx=[]\r\nfor i in range(a):\r\n x. append(b[i+1]+b[i])\r\nprint(*x)\r\n \r\n", "input()\r\na = [int(x) for x in input().split()]+[0]\r\nprint(\" \".join([str(a[i]+a[i-1]) for i in range(1,len(a))]))", "n = int(input())\r\nl = list(map(int,input().split()))\r\nres = []\r\nfor i in range(n - 1):\r\n res.append(l[i] + l[i+1])\r\n\r\nif len(res) != n :\r\n res.append(l[-1])\r\nprint(*res)\r\n\r\n\r\n\r\n\r\n", "n=int(input())\ns=input().split()\ni=int(0)\nA=list(map(int, s))\nB=list(range(n))\nwhile i!=(n-1):\n B[i]=A[i]+A[i+1]\n i=i+1\nB[i]=A[i]\nfor i in B:\n print( i, end=\" \" )\n", "n = int(input())\r\nli = list(map(int, input().split()))\r\nres = [li[-1]]\r\n\r\nfor i in range(len(li)-1, 0, -1):\r\n res.append(li[i] + li[i-1])\r\n\r\nfor i in res[::-1]:\r\n print(i, end=\" \")\r\n\r\n", "N = int(input())\r\nls = list(map(int, input().split()))\r\nfor i in range(N-1):\r\n print(ls[i]+ls[i+1], end=' ')\r\nprint(ls[-1])\r\n", "n = int(input())\r\na = list(map(int,input().split())) + [0]\r\nr = [a[i] + a[i + 1] for i in range(n)]\r\nprint(*r)", "n = int(input())\r\nli = list(map(int ,input().split()))\r\nans = [0]*n\r\nfor i in range(n-1, -1, -1):\r\n if(i == n-1):\r\n ans[i] = li[i]\r\n else:\r\n ans[i] = li[i] + li[i+1]\r\nfor i in ans:\r\n print(i, end=\" \")\r\nprint()", "n1 = int(input())\r\nx = input().split()\r\nlist1 = []\r\nfor i in x:\r\n list1.append(int(i))\r\nlist2 = [0]*n1\r\nlist2[-1] = list1[-1]\r\nk1 = 0\r\nb1 = False\r\nwhile b1==False:\r\n list2[k1] = list1[k1]+list1[k1+1]\r\n k1+=1\r\n if k1 == len(list1)-1:\r\n break\r\nprint(*list2)", "#!/usr/bin/python3.4\ndef _a () :\n\tn = int (input())\n\ta = [int(i) for i in input().split()]\n\n\ta_len = len (a)\n\n\ts = [''] * a_len\n\n\ts [-1] = a [-1]\n\tfor i in range (a_len - 2,-1,-1) :\n\t\ts[i] = a[i] + a[i+1]\n\tprint (*s)\n_a()\n\ndef _b () :\n\ts = input ()\n\tx = [0,0]\n\tfor i in s :\n\t\tif i == 'U' :\n\t\t\tx[0] += 1\n\t\telif i == 'D' :\n\t\t\tx[0] -= 1\n\t\telif i == 'R' :\n\t\t\tx[1] += 1\n\t\telif i == 'L' :\n\t\t\tx[1] -= 1\n\tif x[1] + x[0] <= 2 :\n\t\tprint(1)\n\telse:\n\t\tprint(-1)\n# _b()", "count_input = int(input())\r\ninput_list = [int(i) for i in str.split(input())]\r\ninput_list.reverse()\r\nout = []\r\nfor i in range(count_input):\r\n if i == 0:\r\n out.append(str(input_list[i]))\r\n else:\r\n out.append(str(input_list[i] + input_list[i-1]))\r\n\r\nout.reverse()\r\nprint(\" \".join(out))\r\n", "n = int(input())\r\nl = list(map(int , input().split())) \r\nconter = 0 \r\nres = ''\r\nfor i in range(1 , n ) : \r\n res += str(l[i - 1] + l[i]) + \" \"\r\nres += str(l[-1]) \r\nprint(res) \r\n", "n= int(input())\r\nli = list(map(int,input().split()))\r\ns = [0]*n\r\nfor i in range(n-1):\r\n s[i] = li[i]+li[i+1]\r\ns[n-1] = li[n-1]\r\nprint(*s)", "def main():\n n = int(input())\n a = [int(_) for _ in input().split()]\n b = ['0'] * n\n\n b[n - 1] = str(a[n - 1])\n for i in range(n - 2, -1, -1):\n b[i] = str(a[i] + a[i + 1])\n\n print(' '.join(b))\n\n\nif __name__ == '__main__':\n main()\n", "n=int(input())\r\n\r\n\r\ns=list(map(int,input().split()))\r\n\r\n\r\nl=s[::-1]\r\n\r\n\r\n\r\ng=[l[0]]\r\nfor k in range(n-1):\r\n g.append(l[k]+l[k+1])\r\n\r\nprint(*g[::-1])\r\n \r\n", "n = int(input())\r\na = [int(x) for x in input().split()]\r\nb = [a[i] + a[i + 1] for i in range(n - 1)]\r\nfor x in b:\r\n print(x, end=' ')\r\nprint(a[-1])\r\n", "n, b = int(input()), list(map(int, input().split()))\r\nprint(' '.join(str(b[i] + b[i + 1]) for i in range(n - 1)), b[-1])", "n = int(input())\na = input().split()\nfor i in range(len(a)):\n a[i] = int(a[i])\nb = [0]*n\nb[n-1] = a[n - 1];\nfor i in range(1, n):\n b[n - i - 1] = a[n - i - 1] + a[n - i]\nfor i in range (0, n):\n\tprint(b[i])", "# a_n = b_n\n# a_{n-1} = b_{n-1} - b_n\n# a_{n-2} = b_{n-2} - b_{n-1} + b_n\n# a_{n-3} = b_{n-3} - b_{n-2} + b_{n-1} - b_n\n# b_{n-3} = a_{n-3} + a_{n-2}\n# a_0 = b_0 - b_1 + b_2 - b_3\n\nn = int(input())\na = [int(i) for i in input().split()]\nb = [0] * n\nr = []\nfor i in range(n-1):\n b[i] = a[i] + a[i+1] \n print(b[i], end=\" \")\nprint(a[n-1])\n", "k=int(input())\r\nn=input().split()\r\nfor i in range (k):\r\n n[i]=int(n[i])\r\nif k>=2 and k<=100000:\r\n for i in range(0,k-1):\r\n n[i]=int(n[i])+int(n[i+1])\r\n print(n[i],'',end='')\r\n print (n[k-1])\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=list(range(0,n))\r\nfor x in range(0,n):\r\n if x==n-1:\r\n b[n-1]=a[n-1]\r\n else:\r\n b[x]=a[x]+a[x+1]\r\nfor x in b:\r\n print(x, end=\" \")", "n = int(input())\r\nmoo = list(map(int, input().split()))\r\nfor i in range(n-1):\r\n print(moo[i]+moo[i+1], end=\" \")\r\nprint(moo[-1])", "n = int(input())\r\na = list(map(int,input().split()))[::-1]\r\nb = [a[0]]\r\nfor i in range(0,n-1):\r\n b.append(a[i]+a[i+1])\r\nprint(*b[::-1])", "n = int(input())\r\nA = list(map(int, input().split()))\r\nbrev = []\r\nA.reverse()\r\nbrev.append(A[0])\r\nfor i in range(len(A)-1):\r\n brev.append(A[i]+A[i+1])\r\nbrev.reverse()\r\nprint(' '.join(list(map(str,brev))))", "n=int(input())\r\nl=list(map(int,input().strip().split(' ')))\r\nl1=[]\r\nfor i in range(n-1):\r\n l1.append(l[i]+l[i+1])\r\nl1.append(l[n-1])\r\nprint(*l1)", "n=int(input())\r\na=[int(x) for x in input().split()]\r\nb=[0 for x in range(0,n)]\r\nk=0\r\nl=0\r\nfor i in range(1,n+1):\r\n if i%2==1:\r\n b[n-i]=a[n-i]-k+l\r\n k+=b[n-i]\r\n else:\r\n b[n-i]=a[n-i]-l+k\r\n l+=b[n-i]\r\nfor i in b:\r\n print (i)\r\n", "input();c=0;a=[]\r\nfor x in [*map(int,input().split())][::-1]:a+=[x-c];c=-c-a[-1]\r\nprint(*a[::-1])", "n = int(input())\r\narr = list(map(int ,input().split()))\r\n\r\nb = [0]*n\r\nb[n-1] = arr[n-1]\r\nfor i in range(n-2,-1,-1):\r\n b[i]=arr[i]+arr[i+1]\r\nprint(*b)", "n = int(input())\r\na = [int(i) for i in input().split()]\r\nfor i in range(len(a) - 1):\r\n a[i] += a[i + 1]\r\n print(a[i], end=' ')\r\nprint(a[len(a) - 1])", "# import sys\r\n# sys.stdin=open(\"input.in\",'r')\r\n# sys.stdout=open(\"output4.out\",'w')\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nb=[a[-1]]\r\nfor i in range(n-1,0,-1):\r\n\tb.append(a[i]+a[i-1])\r\nprint(*b[::-1])\t", "'''input\n5\n3 -2 -1 5 6\n'''\nn = int(input())\na = list(map(int, input().split()))\nfor x in range(n-1):\n\tprint(a[x] + a[x+1], end = \" \")\nprint(a[-1])", "n = int(input())\r\narr = [int(i) for i in input().split()]\r\nans = []\r\nres = 0\r\nfor i in range(1,n):\r\n res = arr[i-1] + arr[i]\r\n ans.append(res)\r\n res = 0\r\nans.append(arr[-1])\r\nprint(\" \".join([str(i) for i in ans]))\r\n", "#!/usr/bin/env python3.5\r\nimport sys\r\n\r\ndef read_data():\r\n n = int(next(sys.stdin).strip())\r\n numbers = list(map(int, next(sys.stdin).split()))[:n]\r\n return numbers\r\n\r\n\r\ndef solve(numbers):\r\n ans = numbers.copy()\r\n for i in range(len(numbers) - 1):\r\n ans[i] += numbers[i + 1]\r\n return ans\r\n\r\n\r\nif __name__ == \"__main__\":\r\n numbers = read_data()\r\n print(\" \".join(map(str, solve(numbers))))\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=[]\r\nfor i in range(n-1):\r\n b.append(a[i]+a[i+1])\r\nb.append(a[n-1])\r\nfor j in b:\r\n print(j,end=\" \")", "n=int(input())\r\na=list(map(int,input().split()))\r\na.reverse()\r\nb=[]\r\nb.append(a[0])\r\nfor i in range(len(a)-1):\r\n\tb.append(a[i]+a[i+1])\r\nb.reverse()\r\nfor i in b:\r\n\tprint(i,end=\" \")", "lg = int(input())\r\na = list(map(int, input().split()))\r\n\r\nfor i in range(lg):\r\n if i == len(a) - 1:\r\n print(a[i])\r\n else:\r\n print(a[i] + a[i + 1], end=\" \")\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=[0]*n\r\nfor i in range(n-1):\r\n b[i]=a[i]+a[i+1]\r\nb[n-1]=a[n-1]\r\nfor i in range(n):\r\n print(b[i],end=\" \")", "from sys import stdin\r\nn=int(stdin.readline().strip())\r\ns=list(map(int,stdin.readline().strip().split()))\r\nans=[]\r\nfor i in range(n-1):\r\n ans.append(s[i]+s[i+1])\r\nans.append(s[-1])\r\nprint(*ans)\r\n", "input()\r\ndata = list(map(int, input().split()))\r\nresult = [0] * len(data)\r\n\r\nsums = [0, 0]\r\n\r\nresult[-1] = sums[(len(data) - 1) % 2] = data[-1]\r\n\r\nsign = len(data) % 2 * 2 - 1\r\nfor i in range(len(data) - 2, -1, -1):\r\n delta = sign * (sums[0] - sums[1])\r\n result[i] = data[i] + delta\r\n sums[i % 2] += result[i]\r\n sign *= -1\r\n\r\nprint(' '.join(map(str, result)))\r\n", "n=int(input())\r\nl=list(map(int,input().split()))+[0]\r\n\r\nemp=[]\r\nfor i in range(n):\r\n emp.append(l[i]+l[i+1])\r\nprint(*emp)\r\n", "n = int(input())\nlst_a = list(map(int, input().split()))\nfor index in range(n-1):\n print(lst_a[index] + lst_a[index + 1], end = \" \")\nprint(lst_a[n-1])\n", "n = int(input())\na = list(map(int, input().split()))\nprint(' '.join([str(x+y) for x, y in zip(a[1:], a[:-1])]+[str(a[-1])]))\n\n", "n=int(input())\r\nA=list(map(int,input().split(\" \")))\r\nfor i in range(len(A)-1):\r\n A[i]+=A[i+1]\r\nfor i in A:\r\n print(i,end=' ')\r\n", "import sys\r\nimport math\r\nimport bisect\r\nimport itertools\r\nimport random\r\n\r\ndef main():\r\n n = int(input())\r\n A = list(map(int, input().split()))\r\n B = [0] * n\r\n for i in range(n - 1):\r\n B[i] = A[i] + A[i+1]\r\n B[n-1] = A[n-1]\r\n print(' '.join(list(str(a) for a in B)))\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "n = int(input())\r\nL = [int(a) for a in input().split(\" \",n-1)]\r\nl=[]\r\nfor i in range(n-1):\r\n l.append(L[i]+L[i+1])\r\nl.append(L[n-1])\r\nprint(' '.join(map(str,l)))\r\n ", "N=int(input())\r\nA=list(map(int,input().split()))\r\nfor i in range(N-1):\r\n print(A[i]+A[i+1],end=\" \")\r\nprint(A[N-1])", "# for testCase in range(int(input())):\nn = int(input())\narr = list(map(int ,input().split()))\ni = n-1\nsum = [0 ,0]\nb = []\nwhile i >= 0:\n tmp = arr[i] + sum[not(i&1)] - sum[i&1]\n sum[i&1] += tmp\n b.append(tmp)\n i -= 1\nb.reverse()\nfor i in b:\n print(i ,end=' ')\nprint()\n", "n = int(input())\r\na = list(map(int, input().split()))\r\n\r\nb = [0 for i in range(n)]\r\nc = 0\r\nb[n - 1] = a[n - 1]\r\nfor i in range(n - 2, -1, -1):\r\n b[i] = a[i + 1] + a[i]\r\n\r\nprint(*b)", "# problem/712/A\n\nimport copy\n\nn = int(input())\n\na = [int(n) for i,n in enumerate(input().split(\" \"))]\nb = []\ns = \"\"\n\nfor i in range(n-1, -1, -1):\n x = a[i]\n\n if i < n-1:\n x += a[i+1]\n\n # ss += \" \" + str(x)\n b.append(x)\n\nfor i in range(len(b)-1,-1,-1):\n s += str(b[i]) + \" \"\n\nprint(s)", "n = int(input())\n#n, m = map(int, input().split())\n#s = input()\nc = list(map(int, input().split()))\nc.append(0)\nfor i in range(n):\n print(c[i] + c[i + 1], end = ' ')\n ", "n = int(input())\r\narray = list(map(int, input().split(' ')))\r\nfor i in range(0, n - 1):\r\n print((array[i] + array[i + 1]), end = ' ')\r\nprint (array[n - 1])", "n = int(input())\r\nal = list(map(int,input().split())) + [0]\r\nprint(*[al[i]+al[i+1] for i in range(n)])\r\n", "n = int(input())\nb = [int(x) for x in input().split()]\n\nfor i in range(len(b) - 1):\n print(b[i] + b[i+1], end=\" \")\n\nprint(b[-1], end=\" \")", "n = int(input())\r\n\r\nlist_num = [int(x) for x in input().split()]\r\nfor a in range(n):\r\n if n != a + 1:\r\n b = list_num[a] + list_num[a + 1]\r\n print(str(b), end=' ')\r\n else:\r\n print(list_num[a])", "n = int(input())\r\nb = [int(x) for x in input().split()]\r\nfor i in range(n - 1):\r\n print(b[i] + b[i+1], end=\" \")\r\nprint(b[n-1])", "n=int(input())\r\na=int(0)\r\ns=input().split()\r\nList=list(map(int, s))\r\nfor i in range(n-1):\r\n print((List[i]+List[i+1]),end=\" \")\r\nprint(List[n-1])\r\n", "input()\r\nl = list(map(int, input().split()))\r\nfor i in range(len(l)-1):\r\n print(l[i]+l[i+1], end=\" \")\r\nprint(l[len(l)-1])\r\n", "t=int(input())\r\na=list(map(int,input().split()))\r\ni=0\r\nl=[]\r\nwhile i<=t-2:\r\n x=a[i]+a[i+1]\r\n l.append(x)\r\n i=i+1\r\nl.append(a[-1])\r\nprint(*l)\r\n", "n = int(input())\na = list(map(int, input().split()))\nb = []\n\nfor i in range(0, n - 1):\n b.append(a[i] + a[i + 1])\nb.append(a[n - 1])\n\nprint(*b)\n\n\n", "n = int(input())\r\nA = list(map(int, input().split()))\r\nanswer = [0] * n\r\nfor i in range(len(A) - 1, - 1, -1):\r\n if i == len(A) - 1:\r\n answer[i] = A[i]\r\n else:\r\n answer[i] = (A[i] + A[i + 1])\r\nprint( ' '.join(map(str, answer)))\r\n ", "n = int(input())\r\na = [int(s) for s in input().split(\" \")]\r\nans = [0]*n\r\nfor i in reversed(range(n)):\r\n if i == n-1:\r\n ans[i] = a[i]\r\n else:\r\n ans[i] = a[i] + a[i+1]\r\nprint(*ans)", "n = int(input())\r\na = list(map(int, input().split()))\r\nout = \"\"\r\n\r\nfor i in range(n-1):\r\n out += str(a[i] + a[i+1]) + \" \"\r\nout += str(a[-1])\r\nprint(out)\r\n", "input()\r\nl: list[int] = list(map(int,input().split()))[::-1]\r\ntemp: list[int] = [l[0]]\r\nfor i in range(len(l)-1):\r\n temp.append(l[i+1]+l[i])\r\nprint(*temp[::-1])", "def solution(l1):\r\n \r\n i=0\r\n while i<len(l1)-1:\r\n l1[i]=str(int(l1[i])+int(l1[i+1]))+\" \"\r\n i+=1\r\n c_out=\"\".join(l1)\r\n return c_out\r\ndef answer():\r\n a = int(input())\r\n l1 = input().split()\r\n print(solution(l1))\r\nanswer()\r\n", "n = int(input())\r\nl = list(map(int,input().split()))\r\n\r\nr = []\r\nt = 0\r\nfor i,x in enumerate(l[::-1]):\r\n if i%2:\r\n r.append(str(t+x))\r\n t = - x\r\n else:\r\n r.append(str(x-t))\r\n t = x\r\nprint (' '.join(r[::-1]))\r\n\r\n", "def solve(n, a):\n a.append(0)\n b = [str(a[i-1] + a[i]) for i in range(1, n+1)]\n return ' '.join(b)\n\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n print(solve(n, a))\n\n\nmain()\n", "n = int(input())\nlist1 = input().split()\nfinal= '' \nfor i in range(len(list1)-1):\n final += str(int(list1[i])+int(list1[i+1])) + \" \"\nfinal += str(list1[len(list1)-1])\nprint(final)\n\n\n", "x=int(input());a=list(map(int,input().split()))\r\nprint(*[a[i]+a[i+1] for i in range(x-1)],a[-1])", "testcase = int(input())\r\nlist = list(map(int, input().split()))[:testcase]\r\nanotherList = []\r\nfor i in range(1,len(list)):\r\n anotherList.append(list[i-1]+list[i])\r\nanotherList.append(list[len(list)-1])\r\nprint(*anotherList,sep=\" \")\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\ntmp = 0\r\ntmp2 = 0\r\nfor i in range(n - 1):\r\n a[i] = a[i] + a[i + 1]\r\nprint(*a)\r\n# CodeForcesian\r\n# ♥\r\n# میخوام برم مهمونی\r\n\r\n", "# Description of the problem can be found at http://codeforces.com/problemset/problem/712/A\r\n\r\nn = int(input())\r\nl_n = list(map(int, input().split()))\r\n\r\nc_s = 0\r\nfor i in range(len(l_n)):\r\n l_n[len(l_n) - i - 1] += c_s\r\n c_s = -c_s\r\n c_s += l_n[len(l_n) - i - 1]\r\n\r\nprint(\" \".join(str(x) for x in l_n))", "n = int(input())\r\na = list(map(int, input().split()))\r\nb = []\r\nfor i in range(n):\r\n v = a[i]\r\n if i+1 == n :\r\n g=0\r\n else:\r\n g= a[i+1]\r\n h = (v+g)\r\n b.append(h)\r\nfor i in b:\r\n print(i, end=\" \")", "def crows(lst1):\r\n lst2 = [0] * len(lst1)\r\n lst2[len(lst1) - 1] = lst1[len(lst1) - 1]\r\n for i in range(len(lst1) - 2, -1, -1):\r\n if i + 1 < len(lst1):\r\n lst2[i] = lst1[i + 1] + lst1[i]\r\n return lst2\r\n\r\n\r\nn = int(input())\r\na = [int(j) for j in input().split()]\r\nprint(*crows(a))\r\n", "n=int(input())\r\na1=[int(i) for i in input().split()]\r\nb1=[]\r\nfor j in range(n):\r\n if j!=n-1:\r\n b1.append(a1[j]+a1[j+1])\r\n else :\r\n b1.append(a1[j])\r\nprint(*b1,sep=\" \")", "no_of_integers = int(input())\n\nintegers = list(map(int, input().split()))\n\noriginal_integers = []\n\nfor i in range(no_of_integers - 1) :\n original_integers.append(str(integers[i] + integers[i + 1]))\n\nprint(' '.join(original_integers) + ' ' + str(integers[-1]))\n", "n=int(input())\r\nl=[int(i) for i in input().split()]\r\nres=[0]*n\r\nres[n-1]=l[n-1]\r\nfor i in range(n-2,-1,-1):\r\n res[i]=l[i]+l[i+1]\r\nprint(*res)\r\n", "n=int(input())\r\na=list(map(int, input().split()))\r\nj=1\r\nb=[]\r\nfor i in range(n-1,-1,-1):\r\n\tif i==n-1:\r\n\t\tb+=[a[i]]\r\n\telse:\r\n\t\tb+=[a[i]+a[i+1]]\r\nprint(\" \".join(map(str, b[::-1])))", "# print (\"Input n\")\nn = int(input())\n# print (\"Input the n integers on one line\")\n\na = list(int(x) for x in input().split())\nanswer = [0 for i in range(n)]\n\nanswer[-1] = a[-1]\nfor i in range(-2, -len(a)-1, -1):\n answer[i] = a[i] + a[i+1]\n\nfor x in answer:\n print(x, end = ' ')\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nfor x in range(n):\r\n\tif x==n-1:print(l[x])\r\n\telse:print(l[x]+l[x+1],end=\" \")", "def main():\n count = int(input())\n numbers = list(map(int, str(input()).split(' ')))\n revnumbers = list(reversed(numbers))\n revans = [1]\n revans[0] = revnumbers[0]\n\n for i in range(1, count):\n revans.append(revnumbers[i - 1] + revnumbers[i])\n\n print(' '.join(list(map(str, reversed(revans)))))\n\n\nmain()", "n=int(input())\r\na=list(map(int,input().split()))\r\nfor i in range(n-1):\r\n\tx=a[i]+a[i+1]\r\n\tprint(x,end=' ')\r\nprint(a[n-1])", "n = int(input())\r\nnumbers = list(map(int, input().split()))\r\n\r\nans = numbers\r\n\r\nfor i in range(n-1):\r\n ans[i] = numbers[i+1] + numbers[i]\r\n\r\nans[n-1] = numbers[-1]\r\n\r\nfor i in ans:\r\n print(i, end=' ')", "n = int(input())\r\ntargetList = [int(x) for x in input().split()]\r\nfor i in range(0, n - 1):\r\n print(targetList[i] + targetList[i + 1], end=\" \")\r\nprint(targetList[n - 1])\r\n", "def main():\r\n n = int(input())\r\n a = list(map(int, input().split()))\r\n result = solve(a)\r\n print(\" \".join(map(str, result)))\r\n\r\ndef solve(a):\r\n return [a[i] + (a[i + 1] if i < len(a) - 1 else 0) for i in range(len(a))]\r\n\r\nif __name__ == \"__main__\":\r\n main()", "n=int(input())\r\na=list(map(int,input().split()))\r\n\r\nres=[a[i+1]+a[i] for i in range(n-1)]+[a[n-1]]\r\n\r\nprint(' '.join(map(str,res)))", "def bits_count(a):\n a = int(a)\n ans = 0\n while (a > 0):\n ans += a & 1\n a >>= 1\n return ans\n\nn = int(input())\na = [eval(i) for i in input().split()]\nans = [a[n - 1]]\nfor i in reversed(range(n - 1)) :\n ans.append(a[i] + a[i + 1])\nfor i in reversed(ans) :\n print(i)", "input()\r\ns=[*map(int,input().split()),0]\r\nprint(*[*(x+y for x,y in zip(s,s[1:]))])", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nn = int(input())\r\na = list(map(int, input().split())) + [0]\r\nb = [a[i] + a[i + 1] for i in range(n)]\r\nsys.stdout.write(\" \".join(map(str, b)))", "n=int(input())\r\ninp = list(map(int,input().split()))\r\nfor i in range(0,n-1):\r\n print (inp[i]+inp[i+1],end=\" \")\r\nprint (inp[len(inp)-1])", "n = int(input())\na = list(map(int, input().split()))\nb = [0] * n\nm = 0\nfor i in range(n-1, -1, -1):\n b[i] = a[i] - m\n m = -1 * (b[i] + m)\nprint(*b)\n\n \t\t\t \t\t\t\t\t\t\t \t \t\t\t \t\t\t\t \t\t", "n = int(input())\r\nli = list(map(int, input().split()))[:n]\r\nr_li = []\r\n\r\nfor i in range(1,len(li)):\r\n if i%2 == 1:\r\n sum = li[i] + li[i-1]\r\n else:\r\n sum = li[i-1] + li[i]\r\n\r\n r_li.append(sum)\r\n\r\nr_li.append(li[len(li)-1])\r\nprint(*r_li, sep=\" \")", "n = int(input())\nval = list(map(int, input().split())) + [0]\nans = [val[i] + val[i + 1] for i in range(n)]\nprint(*ans)", "n=int(input())\r\nl=list(map(int,input().split()))\r\na=[0]*n\r\nfor i in range(n-1,-1,-1):\r\n if i==n-1:a[i]=l[i]\r\n else:a[i]=l[i]+l[i+1]\r\nprint(*a)\r\n ", "n = int(input())\na = list(map(int,input().split()))\nb = [a[i]+a[i+1] for i in range(n-1)]\nb.append(a[-1])\nfor i in range(n):\n print(b[i],end=\" \")", "n, a = int(input()), [int(i) for i in input().split()]\nres = [0] * n\ns, bs = 1, 0\n# an = bn => bn = an\n# an-1 = bn-1 - bn => bn-1 = an-1 + bn\n# bk = ak + s * bs\nfor i in reversed(range(n)):\n res[i] = a[i] + s * bs\n s *= -1\n bs += s * res[i]\nprint(*res)\n", "from math import *\r\nn=int(input())\r\na=input().split()\r\ns=list(map(int,a))\r\nB=[0]*n\r\nfor i in range(n-1):\r\n B[i]=s[i]+s[i+1]\r\nB[n-1]=s[n-1]\r\nfor i in range(n):\r\n print(B[i], end=' ')\r\n", "n=(map(int,input().split()))\r\n\r\n\r\nd=list(map(int,input().split()))\r\nd.append(0)\r\n\r\n\r\nfor i in range(0, len(d)-1):\r\n print(d[i]+d[i+1],end=' ')\r\n\r\n", "n=int(input())\r\ns=list(map(int,input().split()))\r\nb=[]\r\nfor i in range(n-1):\r\n\tb.append(s[i]+s[i+1])\r\nb.append(s[n-1])\r\nfor i in range(n):\r\n\tprint(b[i],end=' ')", "n=int(input())\r\nl=[]\r\nl.extend(map(int,input().split()))\r\nl.append(0)\r\nfor i in range(n):\r\n print (l[i]+l[i+1],end=' ')", "lenn = int(input())\r\nlist1 = list(map(int,input().split()))\r\nstring = ''\r\nfor i in range(lenn-1):\r\n string += str(list1[i]+list1[i+1])+' '\r\nprint(string+str(list1[-1]))", "n=int(input())\r\nli=list(map(int, input().split()))\r\nfor i in range(n-1):\r\n print(li[i]+li[i+1],end=' ')\r\nprint(li[n-1])\r\n\r\n", "n = int(input())\r\nar = list(map(int, input().split()))\r\n\r\nnr = []\r\n\r\ni = 0\r\n\r\nwhile i+1 < n: \r\n nr.append(ar[i]+ar[i+1])\r\n i+=1\r\nnr.append(ar[n-1])\r\n\r\nfor i in nr : \r\n print(i , end=' ' )\r\n", "num=int(input())\r\n\r\na=list(map(int,input().split()))\r\n\r\nb=[]\r\n\r\nfor i in range(num):\r\n \r\n \r\n if i==num-1:\r\n b.append(a[-1])\r\n \r\n else:\r\n b.append(a[i]+a[i+1])\r\n\r\n\r\nfor i in b:\r\n print(i,end=' ')\r\n", "n=int(input())\r\na=[int(x) for x in input().split()]\r\nfor i in range(1,n):\r\n print(a[i]+a[i-1],end=' ')\r\nprint(a[n-1])", "tc=int(input())\r\nlist1=list(map(int,input().split()))\r\nlist1.append(0)\r\nstr1=''\r\nfor i in range(len(list1)-1):\r\n str1+=str(list1[i]+list1[i+1])+' '\r\nprint(str1)", "n=int(input())\r\na=[int(a) for a in input().split()]\r\nb=[]\r\nfor _ in range(n-1):\r\n b.append(a[_]+a[_+1])\r\nb.append(a[-1])\r\nprint(*b)", "n = int(input())\r\nw = list(map(int, input().split())) + [0]\r\nfor i in range(n):\r\n print(w[i+1] + w[i], end=' ')", "n=int(input())\r\narr=[int(i) for i in input().split()]\r\nl=[]\r\nfor i in range(n-1):\r\n l.append(arr[i]+arr[i+1])\r\nl.append(arr[n-1])\r\nprint(*l)", "a = int(input())\r\nb = list(map(int, input().split()))\r\nz = 0\r\nv = [b[-1]]\r\nfr = b[-1]\r\nsc = 0\r\nif a % 2 != 0:\r\n for i in range(a-2, -1, -1):\r\n if i % 2 != 0:\r\n z -= fr\r\n z += sc\r\n sc += b[i] - z\r\n else:\r\n z += fr\r\n z -= sc\r\n fr += b[i] - z\r\n v.append(b[i] - z)\r\n z = 0\r\nelse:\r\n for i in range(a-2, -1, -1):\r\n if i % 2 != 0:\r\n z += fr\r\n z -= sc\r\n fr += b[i] - z\r\n else:\r\n z -= fr\r\n z += sc\r\n sc += b[i] - z\r\n v.append(b[i] - z)\r\n z = 0\r\nv.reverse()\r\nprint(*v)\r\n", "n = int(input())\r\na = list(map(int, input().split()))\r\nb = []\r\nfor i in range(n-1):\r\n b += [a[i]+a[i+1]]\r\nb += [a[n-1]]\r\nprint(\" \".join(str(k) for k in b))", "n = int(input())\r\nList = list(map(int,input().split()))\r\n\r\nA = 0\r\nlist_new = []\r\nfor i in range(0,n):\r\n if i == len(List)-1:\r\n list_new.append(List[i]) \r\n break \r\n A = List[i+1] + List[i]\r\n list_new.append(A)\r\n A = 0\r\n\r\nfor i in range(len(list_new)):\r\n print(list_new[i],end=\" \")\r\n", "n = int(input())\narr = list(map(int, input().split()))\narr.reverse()\nres = []\ns = 0\nfor i in arr:\n res.append(i-s)\n s += res[-1]\n s *= -1\nprint(' '.join(map(str, reversed(res))))", "f=lambda:map(int,input().split())\r\nn=int(input())\r\nl=list(f())\r\nfor i in range(0,n-1):\r\n print(l[i]+l[i+1],end=' ')\r\nprint(l[-1])", "N=int(input())\r\ni=0\r\ns=input().split()\r\nA=list(map(int, s))\r\nB=[0]*N\r\nwhile i<N-1:\r\n B[i]=A[i]+A[i+1]\r\n i=i+1\r\nB[N-1]=A[N-1]\r\ni=0\r\nwhile i<N:\r\n print(B[i], end=' ')\r\n i=i+1\r\n", "n=int(input())\r\nl=list(map(int,input().split()))[:n]\r\nl1=[]\r\nfor i in range(n-1):\r\n k=l[i]+l[i+1]\r\n l1.append(k)\r\nl1.append(l[-1])\r\nfor i in l1:\r\n print(i,end=' ')\r\n", "import sys, math\r\nn = int(input())\r\nz = list(map(int, input().split()))\r\nz.append(0)\r\nfor i in range(n):\r\n print(z[i] + z[i + 1], end = ' ')\r\n\r\n", "if __name__ == '__main__':\r\n n = int(input())\r\n line = str(input()).split()\r\n line = [int(it) for it in line]\r\n temp = list()\r\n for i in range(n - 1):\r\n temp.append(line[i] + line[i + 1])\r\n temp.append(line[-1])\r\n temp = [str(it) for it in temp]\r\n print(' '.join(temp))\r\n", "n = int(input())\na = list(map(int , input().split())) + [0]\nb = [0] * n\nb[n - 1] = a[n - 1]\n\nfor i in range(n - 1, 0, -1):\n b[i - 1] = a[i - 1] + a[i]\n \nprint(*b)", "n = int(input())\r\nL = [int(x) for x in input().split()]\r\nfor i in range(n-1): print(L[i]+L[i+1], end = ' ')\r\nprint(L[-1])\r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nv=[]\r\nl.append(0)\r\nfor i in range(n):\r\n\tv.append(l[i]+l[i+1])\r\nprint(*v)", "n=int(input())\r\nb=list(map(int,input().split()))\r\nb.reverse()\r\na=[0]*n\r\na[0]=b[0]\r\nch=0\r\nfor i in range(1,len(b)):\r\n a[i]=b[i-1]+b[i]\r\n\r\n\r\na.reverse()\r\nfor i in a:\r\n print(i,end=' ')", "input()\r\na = [int(i) for i in input().split()]\r\nfor i in range(1, len(a)):\r\n print(a[i-1] + a[i], end=\" \")\r\nprint(a[-1])\r\n", "n = int(input())\na = list(map(int,input().split()))\nfor i in range(n-1):\n\tprint(a[i]+a[i+1],end=\" \")\nprint(a[n-1])\n", "import sys\r\n# if __debug__:\r\n# fin = open('crows.in', 'r')\r\n# else:\r\n# fin = sys.stdin\r\nfin = sys.stdin\r\nn = int(fin.readline())\r\na = [int(x) for x in fin.readline().split()]\r\nb = [0] * n\r\nsum = 0\r\nfor i in reversed(range(len(a))):\r\n b[i] = str(a[i] + sum)\r\n sum = a[i]\r\nprint(\" \".join(b))", "n, a = int(input()), [0] + list(map(int, input().split()))\r\nb = [0] * (n + 1)\r\nb[n], chan, le = a[n], 0, 0\r\nfor x in range(n, 0, -1):\r\n if x & 1 == 0: b[x], chan = a[x] - chan + le, a[x] + le\r\n else: b[x], le = a[x] - le + chan, a[x] + chan\r\nfor x in range(n): print(b[x + 1], end = \" \")", "n=int(input())\r\nl=list(map(int,input().split()))\r\nsums=[0]\r\nfor i in range(n-2,-1,-1):\r\n g=(l[i+1]-sums[-1])\r\n l[i]=l[i]+g\r\n sums.append(g)\r\nfor i in l:\r\n print(i,end=\" \")\r\n \r\n", "n = int(input())\nvector = list(map(int, input().split(' ')))\nlista = []\nfor i in range(0, n - 1):\n lista.append(vector[i] + vector[i + 1])\n if i == (n-2):\n lista.append(vector[-1])\nlista = map(str, lista)\nprint(' '.join(lista))\n\n", "N=int(input())\r\nA=list(map(int,input().split()))\r\nAns=[]\r\nfor i in range(N-1):\r\n Ans.append(A[i]+A[i+1])\r\nAns.append(A[len(A)-1])\r\nprint(*Ans)", "def main():\n n, s = int(input()), 0\n l = list(map(int, input().split()))\n for i in range(n - 1, -1, -1):\n a = l[i]\n l[i] = b = a + s\n s = b - s\n print(\" \".join((map(str, l))))\n\n\nif __name__ == '__main__':\n main()\n", "n = int(input())\r\nl = list(map(int , input().split()))\r\nfor i in range(1,n):\r\n print(l[i]+l[i-1] , end=' ')\r\nprint(l[-1])", "n = int(input())\r\na_values = [int(i) for i in input().split()]\r\nb = []\r\nfor i in range(1, len(a_values)):\r\n b_value = a_values[i] + a_values[i - 1]\r\n b.append(b_value)\r\n\r\nb.append(a_values[n - 1])\r\nprint(*b)\r\n\r\n", "import math\r\nimport sys\r\n\r\nn = input()\r\nn = int(n)\r\n\r\na = input().split()\r\n\r\nfor i in range(n):\r\n a[i]=int(a[i])\r\n \r\nfor i in range(n-1):\r\n print(a[i]+a[i+1])\r\n \r\nprint(a[n-1])", "n = int(input())\r\nlis = list(map(int,input().split()))\r\nans=[]\r\nfor i in range(n-1):\r\n ans.append(lis[i]+lis[i+1])\r\nans.append(lis[-1])\r\nprint(*ans) \r\n \r\n\r\n\r\n", "input()\r\nA = list(map(int, input().split()))\r\n\r\nfor x, y in zip(A, A[1:] + [0]):\r\n print(x + y, end=' ')", "import sys\n\nn = int(input())\nan = list(map(int, sys.stdin.readline().split()))\nbn = [0] * n\n\nbn[n-1] = an[n-1]\ni = n-2\nwhile i >= 0:\n bn[i] = an[i] + an[i+1]\n i -= 1\n\nprint(' '.join(map(str, bn)))\n", "input()\nv = list(map(int, input().split()))\nv = v[::-1]\nk = [v[0]] * len(v)\ns = [0] * len(v)\ns[0] = k[0]\nfor i, x in enumerate(v[1:], 1):\n a = s[i - 1]\n b = [0, s[i - 2]][i < 0]\n k[i] = a + x - b\n s[i] = x + [0, s[i - 2]][i < 0]\nprint(*k[::-1])\n", "n = int(input())\r\nar = [int(i) for i in input().split()]\r\nfor i in range(n - 1):\r\n print(ar[i] + ar[i + 1], end = ' ')\r\nprint(ar[n - 1])", "n=int(input())\r\nl=list(map(int,input().split()))\r\ni=0\r\nwhile i<n-1:\r\n print(l[i]+l[i+1],end=\" \")\r\n i+=1\r\nprint(l[n-1])\r\n \r\n", "n=int(input())\r\nl=list(map(int,input().split()))\r\nfor i in range(0,n-1):\r\n print(l[i]+l[i+1],end=' ')\r\nprint(l[n-1])", "num = int(input())\r\nnum_list = input().split()\r\nlist = []\r\nfor i in num_list:\r\n list.append(int(i))\r\n# print(list)\r\nlist_b = []\r\nb = 0\r\nfor i in range(num-1):\r\n b = list[i] + list[i+1]\r\n list_b.append(b)\r\nlist_b.append(list[-1])\r\nfor i in list_b:\r\n print(i, end=\" \")\r\n\r\n", "n=int(input())\r\na=list(map(int,input().split()))\r\nb=[0]*n\r\nsumi=0\r\nfor i in range(n-1,-1,-1):\r\n\tb[i]=a[i]+sumi\r\n\tsumi=-sumi+b[i]\r\nfor p in b:\r\n\tprint(p,end=\" \")\r\n", " # https://codeforces.com/problemset/problem/712/A\r\n\r\nn = int(input())\r\n\r\nt = tuple(map(int, input().split()))\r\n\r\nfor i in range(1, n):\r\n print(t[i - 1] + t[i], end=\" \")\r\nprint(t[-1])\r\n", "n = int(input())\r\narr = [int(x) for x in input().split()]\r\nbrr = [arr[n-1]]\r\nfor i in range(n-2,-1,-1):\r\n x = +arr[i+1]+arr[i]\r\n brr.append(x)\r\ncrr = brr[::-1]\r\ns = str(crr[0])\r\nfor i in range(1,n):\r\n s += ' '+str(crr[i])\r\nprint(s)\r\n", "n=int(input())\r\nnumbers=list(map(int,input().split()))\r\niN=list()\r\nfor i in range(n-1):\r\n iN.append(numbers[i]+numbers[i+1])\r\niN.append(numbers[n-1])\r\nprint(*iN)\r\n\r\n\r\n ", "n = int(input())\r\na = [int(i) for i in input().split()]\r\nfor i in range(n-1):\r\n\tprint(a[i]+a[i+1],end=' ')\r\nprint(a[n-1])\r\n\r\n", "n=int(input())\r\na=input().split()\r\nt=\"\"\r\nfor i in range(n-1):\r\n t+=str(int(a[i])+int(a[i+1]))+\" \"\r\nt+=a[n-1]\r\nprint(t)\r\n ", "n = int(input())\r\na = list(map(int, input().split()))\r\nb = [a[-1]]\r\nfor i in range(n-2, -1,-1):\r\n b.append(a[i] + a[i+1])\r\nprint(*list(reversed(b)))", "n = int(input())\n\na = list(map(int, input().split()))\n\nb = []\nfor a1, a2 in zip(a, a[1:]+[0]):\n b.append(a1+a2)\n \nprint(*b)\n", "n = int(input())\nl = list(map(int,input().split()))\na = []\na += [l[-1]]\nfor i in range(n-1,0,-1):\n a += [l[i] + l[i-1]]\na = a[::-1]\nprint(' '.join(list(map(str,a))))", "n=int(input())\r\nl=list(map(int,input().split()))\r\nans=list(l[i]+l[i-1] for i in range(1,n))\r\nans.append(l[-1])\r\nprint(*ans)", "n=int(input())\r\nl = [*map(int,input().split())]+[0]\r\nprint(*[*(l[i]+l[i+1] for i in range(n))])", "n=int(input())\r\na=list(map(int, input().split()))+[0]\r\nprint(*(a[i]+a[i-1]for i in range(1,n+1)))", "n=int(input())\r\narry=[int(a) for a in input().split()]\r\nary1=[arry[i]+arry[i+1] for i in range(0,len(arry)-1)]\r\nprint(*ary1,arry[len(arry)-1])", "N = int(input())\na = list(map(int, input().split()))\nb = [None] * N\nmemo = 0\nfor i in range(N)[::-1]:\n b[i] = a[i] - memo\n memo = -1 * (b[i] + memo)\nprint(\" \".join(map(str,b)))\n\n\n\t \t \t \t\t \t \t \t \t\t\t \t \t\t \t \t", "num = input()\nnumlist = input().split(' ')\noutlist = []\nfor i in range(int(num)-1):\n\toutlist.append(int(numlist[i])+int(numlist[i+1]))\noutlist.append(int(numlist[-1]))\nprint(\" \".join(map(str,outlist)))\n", "n = int(input())\r\nstring = input()\r\nvalues = string.split(\" \")\r\nfor x in range(n):\r\n values[x] = int(values[x])\r\nnumbers = []\r\nfor x in range(n - 1):\r\n numbers.append(str(values[x] + values[x + 1]))\r\nnumbers.append(str(values[n - 1]))\r\nprint(\" \".join(numbers))", "#-------------Program--------------\r\n#----Kuzlyaev-Nikita-Codeforces----\r\n#-------------Training-------------\r\n#----------------------------------\r\n\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nb=[str(a[-1])]\r\nfor i in range(n-1,0,-1):\r\n b.append(str(a[i]+a[i-1]))\r\nb=b[::-1]\r\nprint(\" \".join(b))", "n=int(input())\na=list(map(int,input().split()))\nfor i in range (len(a)-1):\n print(a[i]+a[i+1],end=\" \")\nprint(a[i+1])\n", "def memoryCrow(s):\r\n for i in range(len(s)-1):\r\n s[i] = (s[i] + s[i+1])\r\n return s\r\n\r\nn = int(input())\r\nss = list(map(int, input().split()))\r\nprint(*memoryCrow(ss))", "t=int(input())\r\nx=[int(a) for a in input().split(' ')]\r\nfor i in range(0,t-1):\r\n print((x[i]+x[i+1]),end=\" \")\r\nprint(x[t-1])\r\n \r\n", "n=int(input())\r\nlist=list(map(int,input().split()))\r\nlist.append(0)\r\nfor i in range(len(list)-1):\r\n list[i]=list[i]+list[i+1]\r\n print(list[i],end=' ')", "n, s = int(input()) + 1, list(map(int, input().split())) + [0]\r\nprint(*(s[i - 1] + s[i] for i in range(1, n)))\r\n", "n = int(input())\r\na = list(map(int,input().split()))\r\nb=[0]*n\r\nb[n-1]=a[n-1]\r\nfor i in range(n-1):\r\n b[i]=a[i]+a[i+1]\r\nfor i in b:\r\n print(i,end=' ')\r\nprint()", "n = int(input())\r\nA = list(map(int,input().split()))\r\nL = []\r\nL.append(A[n-1])\r\ncnt = 0\r\nfor i in range(n):\r\n r = A[n-i-1] + A[n-i-2]\r\n cnt+=1\r\n if cnt == n:\r\n break\r\n # print(r)\r\n L.append(r)\r\nL.reverse()\r\n\r\nprint(*L)", "n = int(input())\n\nr = [int(x) for x in input().split()] + [0]\n\na = []\nfor i in range(n):\n a.append(r[i] + r[i + 1])\nprint(\" \".join([str(x) for x in a]))\n", "n=int(input())\r\na=[int(i) for i in input().split()]\r\na=a[::-1]\r\nl=[a[0]]\r\nfor i in range(1,len(a)):\r\n l.append(a[i]+a[i-1])\r\nprint(*l[::-1])", "# A. Memory and Crow\n# TLE: Time limit exceeded on test 5\n\nn = int(input())\na = list(map(int, input().split()))\n\nans = [a[n-1]]\nfor i in range(n-2, -1, -1):\n ans.append(a[i] + a[i+1])\n\nprint(' '.join([str(x) for x in ans[::-1]]))\n", "n=int(input())\na=list(map(int,input().split()))\na.append(0)\nfor i in range(0,n):\n\tprint(a[i]+a[i+1],end=\" \")\n", "n = int(input())\r\na = [int(i) for i in input().split()]\r\nb = [a[n - 1]]\r\nfor i in range(n - 1, 0, -1):\r\n b.append(a[i] + a[i - 1])\r\nfor i in range(n - 1, -1, -1):\r\n print(b[i])\r\n", "n = int(input())\r\ns = [int(i) for i in input().split()]\r\nd = []\r\n\r\nfor i in range(n-1):\r\n\td.append(s[i]+s[i+1])\r\n\r\nd.append(s[-1])\r\n\r\nprint(*d)", "from collections import Counter\r\nimport string\r\nimport math\r\nimport sys\r\ndef array_int():\r\n return [int(i) for i in sys.stdin.readline().split()]\r\ndef vary(number_of_variables):\r\n if number_of_variables==1:\r\n return int(sys.stdin.readline())\r\n if number_of_variables>=2:\r\n return map(int,sys.stdin.readline().split()) \r\ndef makedict(var):\r\n return dict(Counter(var))\r\nmod=100000007\r\nn=vary(1)\r\nnum=array_int()\r\nfor i in range(n-1):\r\n print(num[i]+num[i+1],end=\" \")\r\nprint(num[-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\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n \r\n\r\n\r\n\r\n", "n = int(input())\r\nb = list(map(int, input().split()))\r\n\r\nt = 0\r\n\r\nfor i in reversed(range(n)):\r\n b[i] = b[i]+t\r\n t = b[i]-t\r\n\r\nfor x in b:\r\n print(x, end=' ')\r\n" ]
{"inputs": ["5\n6 -4 8 -2 3", "5\n3 -2 -1 5 6", "10\n13 -2 532 -63 -23 -63 -64 -23 12 10", "10\n0 0 0 0 0 0 0 0 0 0", "10\n1 -1 1 -1 1 -1 1 -1 1 -1", "10\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000", "10\n124 532 -642 6482 -124 952 -235 7594 34 -12", "10\n1294 35852 32749 537295 12048 53729 29357 58320 64739 1240"], "outputs": ["2 4 6 1 3 ", "1 -3 4 11 6 ", "11 530 469 -86 -86 -127 -87 -11 22 10 ", "0 0 0 0 0 0 0 0 0 0 ", "0 0 0 0 0 0 0 0 0 -1 ", "0 0 0 0 0 0 0 0 0 1000000000 ", "656 -110 5840 6358 828 717 7359 7628 22 -12 ", "37146 68601 570044 549343 65777 83086 87677 123059 65979 1240 "]}
UNKNOWN
PYTHON3
CODEFORCES
291
e5a3243f561080c07faa1d584aa2ccae
Exam
An exam for *n* students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that students with adjacent numbers (*i* and *i*<=+<=1) always studied side by side and became friends and if they take an exam sitting next to each other, they will help each other for sure. Your task is to choose the maximum number of students and make such an arrangement of students in the room that no two students with adjacent numbers sit side by side. A single line contains integer *n* (1<=≤<=*n*<=≤<=5000) — the number of students at an exam. In the first line print integer *k* — the maximum number of students who can be seated so that no two students with adjacent numbers sit next to each other. In the second line print *k* distinct integers *a*1,<=*a*2,<=...,<=*a**k* (1<=≤<=*a**i*<=≤<=*n*), where *a**i* is the number of the student on the *i*-th position. The students on adjacent positions mustn't have adjacent numbers. Formally, the following should be true: |*a**i*<=-<=*a**i*<=+<=1|<=≠<=1 for all *i* from 1 to *k*<=-<=1. If there are several possible answers, output any of them. Sample Input 63 Sample Output 6 1 5 3 6 2 42 1 3
[ "def odd(lst,n):\r\n for i in range(1,n+1,2):\r\n lst.append(i)\r\n \r\ndef even(lst,n):\r\n start=2\r\n if len(lst)==1 or n==3:\r\n start=4\r\n for j in range(start,n+1,2):\r\n lst.append(j) \r\n\r\nn=int(input())\r\nlst=[]\r\n\r\nif n%2==0 and n>2:\r\n even(lst, n)\r\n odd(lst, n) \r\n \r\nelse:\r\n \r\n odd(lst, n)\r\n even(lst, n)\r\nprint(len(lst))\r\nprint(*lst)", "a = []\r\nfor i in range(6000):\r\n a = a + [i]\r\ninp = int(input())\r\nif inp == 1 or inp == 2:\r\n print(1)\r\n print(1)\r\nelif inp == 3:\r\n print(2)\r\n print(1,3)\r\nelse:\r\n print(inp)\r\n print(2,end = '')\r\n for i in a[4:inp+1:2]:\r\n print(' ',i,end = '')\r\n for i in a[1:inp+1:2]:\r\n print(' ',i,end = '')\r\n print()\r\n", "n = int(input())\nif n == 1 or n == 2:\n print ('1')\n print ('1')\nelif n == 3:\n print ('2')\n print ('1 3')\nelse:\n print (n)\n resp = []\n for i in range(2, n+1, 2):\n resp.append(str(i))\n for i in range(1, n+1, 2):\n resp.append(str(i))\n resp = ' '.join(resp)\n print (resp)\n\t \t\t \t\t \t\t\t \t \t \t \t \t\t\t\t \t", "n = int(input())\na = []\nif n % 2 == 0: \n b = n - 1\nelse:\n b = n\nfor i in range(b, 0, -2):\n a.append(i)\nb = n // 2 * 2\nwhile abs(b - a[-1]) != 1 and b > 1:\n a.append(b)\n b -= 2\nprint(len(a))\nprint(' '.join(map(str, a)))", "n = int(input())\r\nb = []\r\nfor i in range(2, n + 1, 2):\r\n b.append(i)\r\nfor i in range(1, n + 1, 2):\r\n b.append(i)\r\nfor i in range(n - 1):\r\n if abs(b[i] - b[i + 1]) == 1:\r\n b.pop(i)\r\n break\r\nprint(\"%d\\n\" % (len(b)) + \" \".join([str(x) for x in b]))", "n = int(input())\r\n\r\nif n < 1:\r\n res = []\r\nelif n < 3:\r\n res = [1]\r\nelif n == 3:\r\n res = [1,3]\r\nelse:\r\n res = [i for i in range(2,n+1,2)] + [i for i in range(1,n+1,2)]\r\n \r\nprint(len(res))\r\nprint(' '.join(map(str,res)))", "n = int(input())\nif n == 1:\n\n res = [1]\n\nelse:\n\n even, odd = list(range(2, n + 1, 2)), list(range(1, n + 1, 2))\n l, r = sorted((even, odd), key=lambda c: c[-1], reverse=True)\n while r and abs(l[-1] - r[0]) == 1:\n\n r.pop(0)\n\n res = l + r\n\nprint(len(res))\nprint(str.join(\" \", map(str, res)))\n", "n=int(input())\nif n<3:\n print('1\\n1')\nelif n==3:\n print('2\\n1 3')\nelif n==4:\n print('4\\n3 1 4 2')\nelse:\n a=[i for i in range(1,n+1,2)]+[i for i in range(2,n+1,2)]\n print(len(a))\n print(*a)", "import sys\r\n\r\nI=sys.stdin.readline\r\n\r\nn=int(I())\r\n\r\nif n<3:\r\n\tprint(1)\r\n\tprint(1)\r\nelif n==3:\r\n\tprint(2)\r\n\tprint(1,3)\r\nelse:\r\n\teven=[]\r\n\todd=[]\r\n\tfor i in range(1,n+1):\r\n\t\tif i%2:\r\n\t\t\todd.append(i)\r\n\t\telse:\r\n\t\t\teven.append(i)\r\n\tprint(n)\r\n\tprint(*(even+odd))", "n=int(input())\nif n==1:\n\tprint(\"1\")\n\tprint(\"1\")\nelif n==2:\n\tprint(\"1\")\n\tprint(\"1\")\nelif n==3:\n\tprint(\"2\")\n\tprint(\"1 3\")\nelif n>=4:\n\tl=list()\n\tprint(n)\n\tif n%2==0:\n\t\tj=n\n\t\ti=n-1\n\telse:\n\t\tj=n-1\n\t\ti=n\n\twhile(i>0):\n\t\tl.append(i)\n\t\ti=i-2\n\twhile(j>0):\n\t\tl.append(j)\n\t\tj=j-2\n\tprint(*l)", "n = int(input())\r\n\r\nres = ([],[i for i in range(2,n+1,2)]) [n > 3] + [i for i in range(1,n+1,2)]\r\n \r\nprint(len(res))\r\nprint(' '.join(map(str,res)))", "n = int(input())\r\nif(n==1 or n==2):\r\n print(\"1\\n1\")\r\nelif(n==3):\r\n print(\"2\\n1 3\")\r\nelse:\r\n A=[]\r\n for i in range(2,n+1,2):\r\n A.append(i)\r\n for i in range(1,n+1,2):\r\n A.append(i)\r\n print(len(A))\r\n for x in A:\r\n print(x,end=\" \")", "x=int(input())\r\nif x<3:\r\n print(1)\r\n print(1)\r\nelif x==3:\r\n print(2)\r\n print('1 3')\r\nelif x==4:\r\n print(4)\r\n print('3 1 4 2')\r\nelse:\r\n print(x)\r\n for i in range(1,x+1,2):\r\n print(i,end=' ')\r\n for i in range(2,x+1,2):\r\n print(i,end=' ')\r\n", "n=int(input(''))\r\nc=n-1\r\nb=n\r\na=[]*n\r\nif n==2:\r\n print('1')\r\n print('1')\r\nelif n==3:\r\n print('2')\r\n print('1 3')\r\nelse:\r\n if n%2==0:\r\n b=n-1\r\n c=n\r\n while(1):\r\n if b<=0:\r\n break\r\n else:\r\n a.append(b)\r\n b-=2\r\n while(1):\r\n if c<=0:\r\n break\r\n else:\r\n a.append(c)\r\n c-=2\r\n\r\n print(len(a))\r\n for i in range(0,len(a)):\r\n print(a[i],end=' ')", "import sys\ninput = sys.stdin.buffer.readline\n# input = sys.stdin.readline\nprint = sys.stdout.write\n\n# from heapq import heapify,heappush,heappop\n\ndef solve():\n n = int(input())\n ans = []\n start = 0\n if(n % 2 == 0):\n start += 1\n for i in range(1+start,n+1,2):\n ans.append(i)\n for i in range(2-start,n+1,2):\n if(len(ans) == 0):\n ans.append(i)\n else:\n if(abs(ans[-1] - i) > 1):\n ans.append(i)\n print(str(len(ans)) + \"\\n\")\n print(' '.join(map(str,ans)) + \"\\n\")\n\nfor _ in range(1):\n solve()\n\n# code by Kavorka\n# code by Kavorka\n# code by Kavorka\n# code by Kavorka\n# code by Kavorka\n\t\t \t \t\t\t \t\t \t\t \t\t \t\t \t \t \t", "def main():\n n = int(input())\n x = []\n p = True\n k = n\n l = 1\n for i in range(n):\n if p:\n x.append(l)\n l += 1\n else:\n x.append(k)\n k -= 1\n p ^= True\n if len(x) > 1 and abs(x[-1] - x[-2]) == 1:\n x = [x.pop(-1)] + x\n if len(x) <= 3 and len(x) > 1:\n x = x[1:]\n print(len(x))\n print(' '.join(list(map(str, x))))\nmain()\n", "n = int(input())\r\nif n == 1 or n == 2:\r\n print(\"1\")\r\n print(\"1\")\r\nelif n == 3:\r\n print(\"2\")\r\n print(\"1 3\")\r\nelse:\r\n a = []\r\n for i in range(2, n+1, 2):\r\n a.append(i)\r\n for i in range(1, n+1, 2):\r\n a.append(i)\r\n print(n)\r\n print(' '.join(str(i) for i in a))\r\n", "n = int(input())\r\nk = n\r\nif n==1:\r\n print(1)\r\n print(1)\r\nelif n==2:\r\n print(1)\r\n print(1)\r\nelif n == 3:\r\n print(2)\r\n print(1,3)\r\nelif n%2==0:\r\n print(n)\r\n for i in range(2,n//2+1):\r\n print(i,k,end=' ')\r\n k -= 1\r\n\r\n \r\n\r\n print(1,k)\r\nelse:\r\n print(n)\r\n for i in range(2,n//2+2):\r\n if i < n//2+1:\r\n print(i,k,end=' ')\r\n k -= 1\r\n else:\r\n print(i,end=' ')\r\n print(1,k)\r\n \r\n", "n=int(input())\r\nif n<=2:\r\n print(1)\r\n print(1)\r\nelif n==3:\r\n print(2)\r\n print(1,3)\r\nelif n!=4:\r\n p=[0]*(n+1)\r\n if n %2==0:\r\n t=int(n/2)\r\n for i in range (1,t+1):\r\n p[2*i-1]=i\r\n p[2*i]=t+i\r\n else:\r\n t=int(n/2)\r\n for j in range (1,t+1):\r\n p[2 * j - 1] = j+t\r\n p[2 * j] = j\r\n p[n]=n\r\n print(n)\r\n for k in range (1,n+1):\r\n\r\n print(p[k],end=\" \")\r\nelse:\r\n print(4)\r\n print(3,1,4,2)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "s=int( input())\r\nv1=list(range(1,s+1,2))\r\nv2=list(range(2,s+1,2))\r\nif s==1 or s==2:\r\n print(\"1\\n1\")\r\n exit()\r\nif s==3:\r\n print(\"2\\n1 3\")\r\n exit()\r\nv1=v2+v1\r\nprint(len(v1))\r\nprint(' '.join(map(str, v1)))", "n = int(input())\r\na = []\r\nif n == 1 or n == 2:\r\n print(1)\r\n print(1)\r\nelif n == 3:\r\n print(2)\r\n print(1, 3)\r\nelif n == 4:\r\n print(4)\r\n print(3, 1, 4, 2)\r\nelse:\r\n if n % 2 != 0: \r\n ind1 = n // 2 + 2\r\n else:\r\n ind1 = n // 2 + 1\r\n ind2 = 1\r\n for i in range(n):\r\n if i % 2 == 0:\r\n a.append(ind2)\r\n ind2 += 1\r\n else:\r\n a.append(ind1)\r\n ind1 += 1\r\n print(n)\r\n print(*a)", "n = int(input())\nif n == 2:\n print(1)\n print(1)\nelif n == 3:\n print(2)\n print(1, 3)\nelse:\n a = []\n if n % 2 == 1:\n a.append(n)\n n -= 1\n for i in range(n // 2 - 1, -1, -1):\n a.append(i + 1)\n a.append(i + 1 + n // 2)\n print(len(a))\n print(*a)\n \n", "def fun():\n n = int(input())\n answer = []\n\n if n <= 2:\n print(1)\n print(1)\n return\n\n if n == 3 or n % 2 == 0:\n for i in range(n//2):\n answer.insert(0, 1 + i*2)\n answer.append(n - i*2)\n print(len(answer))\n print(*answer)\n return\n else:\n for i in range(n//2):\n answer.insert(0, 1 + i*2)\n answer.append(n-1 - i*2)\n answer.insert(0, n)\n print(len(answer))\n print(*answer)\n return\n\nfun()\n\t \t\t \t\t\t \t \t \t\t\t\t \t\t\t", "n = int(input())\r\nm = []\r\nfor i in range(1, n+1):\r\n m.append(i)\r\nr1 = []\r\nr2 = []\r\nres = []\r\nif n == 1 or n == 2:\r\n res.append(\"1\")\r\nelif n == 3:\r\n res.append(\"1\")\r\n res.append(\"3\")\r\nelif n % 2 == 0:\r\n i = 0\r\n while i < n//2:\r\n r1.append(m[i])\r\n i += 1\r\n j = n//2\r\n while j < n:\r\n r2.append(m[j])\r\n j += 1\r\n for i in range(n//2):\r\n res.append(r2[i])\r\n res.append(r1[i])\r\nelse:\r\n i = 0\r\n while i < n//2:\r\n r1.append(m[i])\r\n i += 1\r\n j = n//2 \r\n while j < n:\r\n r2.append(m[j])\r\n j += 1\r\n for i in range(n//2):\r\n res.append(r2[i])\r\n res.append(r1[i])\r\n res.append(r2[n//2])\r\nprint(len(res))\r\nres = ' '.join(map(str, res))\r\nprint(res)", "t=int(input())\r\nif(t==1):\r\n print(1)\r\n print(1)\r\nelif t==2:\r\n print(1)\r\n print(1)\r\n \r\nelif t==3:\r\n print(2)\r\n print(1,3)\r\nelse:\r\n print(t)\r\n l=[]\r\n l1=[]\r\n for i in range(1,t+1):\r\n if(i%2==0):\r\n print(i)\r\n for i in range(1,t+1):\r\n if(i%2!=0):\r\n print(i)\r\n \r\n \r\n", "n = int(input())\r\nif(n <= 2):\r\n print(1)\r\n print(1)\r\n exit()\r\nif(n == 3):\r\n print(2)\r\n print(1,3)\r\n exit()\r\nprint(n)\r\nfor i in range(n - 1,0,-2):\r\n print(i,end=\" \")\r\nfor i in range(n,0,-2):\r\n print(i,end=\" \")", "n=int(input())\r\nl=[]\r\nif n==3:\r\n print('2')\r\n print('1','3')\r\nelif n<3:\r\n print('1')\r\n print('1')\r\nelse:\r\n print(n)\r\n for i in range(1,n+1):\r\n if i%2==0:\r\n print(i,end=' ')\r\n else:\r\n l.append(i)\r\nprint(*l,sep=' ')", "n = int(input())\r\nprint(n if n > 3 else (n + 1) // 2)\r\nif n > 3:\r\n for i in range(2, n + 1, 2): print(i, end=' ')\r\nfor i in range(1, n + 1, 2): print(i, end=' ')", "n = int(input())\r\nif n < 3:\r\n print(1)\r\n print(1)\r\nelif n == 3:\r\n print(2)\r\n print(1, 3)\r\nelse:\r\n print(n)\r\n print(' '.join(str(i) for i in range(n-1,0,-2)) + ' ' + ' '.join(str(i) for i in range(n, 0, -2)))\r\n", "n = int(input())\r\nif n==2: print(1,'\\n1')\r\nelif n==3: print(2,'\\n1 3')\r\nelif n==4: print(4,'\\n3 1 4 2')\r\nelif n==5: print(5,'\\n3 1 4 2 5')\r\nelse:\r\n print(n)\r\n i, j = 1, (n // 2) + 1\r\n if n%2!=0: print(n,end=' ')\r\n while i<=n/2:\r\n print(i,j,end=' ')\r\n i+=1\r\n j+=1", "n = int(input())\na=[]\nif(n==2):\n print(1)\n print(1)\n exit()\nif(n==3):\n print(2)\n print(1,3)\n exit()\ncurr=0\nif(n & 1):\n curr=n\nelse:\n curr= n-1\n\nfor i in range(n):\n if(curr<0):\n if(n & 1):\n curr=n-1\n else:\n curr=n\n a.append(curr)\n curr-=2\n\nprint(n)\nfor i in a:\n print(i,end=' ')\n\n\n \t \t \t\t\t \t \t \t \t\t \t\t\t\t \t\t", "n = int(input().strip())\nif 2 >= n:\n print(1)\n print(1)\nelif 3 == n:\n print(2)\n print('1 3')\nelse:\n print(n)\n sits = [1]\n place = 0\n for i in range(n, 1, -1):\n if 0 == place:\n sits.append(i)\n else:\n sits = [i] + sits\n place = (place + 1) % 2\n print(' '.join(map(str, sits)))", "x=int(input())\narray=[];j=[];k=[]\nfor i in range(1,x+1):\n array.append(i)\n if(i%2==0):\n j.append(i)\n else:\n k.append(i)\nif(i==3):\n print(2)\n print(1,3)\nelif(i==2):\n print(1)\n print(1)\nelse: \n print(len(j+k))\n for y in (j+k):\n print(y, end=' ')\n \t\t\t\t\t \t \t \t \t \t\t \t \t\t\t \t", "n=int(input())\r\nif n==2:print(1,\"\\n\",1)\r\nelif n==3:print(2,\"\\n\",3,1)\r\nelif n==4:print(4,\"\\n\",\"3 1 4 2\") \r\nelse:print(n,\"\\n\",*[i for i in range(n,0,-2)],*[i for i in range(n-1,0,-2)])", "n = int(input())\nif n == 1 or n == 2:\n print(1)\n print(1)\nelif n == 3:\n print(2)\n print(1, 3)\nelse:\n l = [i for i in range(2, n + 1, 2)] + [i for i in range(1, n + 1, 2)]\n print(n)\n print(*l)\n\t \t \t \t \t \t\t \t \t\t\t\t \t\t \t\t", "n=int(input())\r\nl=[]\r\nif n>=4 :\r\n for i in range(n,0,-1) :\r\n if (i)%2!=0 :\r\n l.append(str(i))\r\n for i in range(n,1,-1) :\r\n if i%2==0 :\r\n l.append(str(i))\r\n print(n)\r\n print(' '.join(l))\r\nif n==3 :\r\n print(2)\r\n print(1,3)\r\nif n==2 :\r\n print(1)\r\n print(1)\r\nif n==1 :\r\n print(1)\r\n print(1)\r\n\r\n \r\n", "n = int(input())\nif(n != 4):\n counter = 0\n #Impar\n ant_i = 0\n i = 1\n ans = \"\"\n while(i <= n):\n ant_i = i \n ans += str(i) + \" \"\n counter += 1\n i += 2\n #Par\n j = 2\n while(ant_i != j - 1 and ant_i != j + 1 and j <= n):\n ant_i = j\n ans += str(j) + \" \"\n counter += 1\n j += 2\n print(counter)\n print(ans)\nelse:\n print(4)\n print(\"2 4 1 3\")\n\n \t\t \t\t \t\t \t\t \t \t \t\t \t\t\t\t\t", "n=int(input())\r\nif n<3:a=[1]\r\nelif n<4:a=1,3\r\nelse:\r\n y,a=0,[3,1,4,2]\r\n for i in range(5,n+1):a.insert(len(a)*y,i);y=1-y\r\nprint(len(a))\r\nfor i in a:print(i,end=' ')", "n = int(input())\r\n\r\nodd = []\r\neven = []\r\n\r\nif n == 3 :\r\n print(2)\r\n print(\"1\", \"3\")\r\n\r\nelif n == 2 :\r\n print(1)\r\n print(1)\r\nelif n == 1 :\r\n print(1)\r\n print(1)\r\n\r\nelse:\r\n \r\n for i in range(1,n+1,1):\r\n \r\n if i%2 == 0 :\r\n even.append(i)\r\n else:\r\n odd.append(i)\r\n odd.reverse()\r\n even.reverse() \r\n\r\n q = odd + even\r\n\r\n print(len(q))\r\n print(*q)\r\n\r\n", "n=int(input())\r\na=[]\r\nb=[]\r\nk=1\r\nfor x in range(1,n+1):\r\n\tif k%2!=0:\r\n\t\ta.append(x)\r\n\telse:\r\n\t\tb.append(x)\r\n\tk+=1\r\nif n==1 or n==2:\r\n\tprint(1)\r\n\tprint(1)\r\nelif n==3:\r\n\tprint(2)\r\n\tprint('1 3')\r\nelse:\r\n\tif a[-1]>b[-1]:\r\n\t\tk=a+b\t\r\n\telse:k=b+a\r\n\tprint(len(k))\r\n\tprint(*k)", "n = int(input())\r\n\r\nif n==1 or n==2:\r\n print(1)\r\n print(1)\r\nelif n==3:\r\n print(2)\r\n print(1,3)\r\nelif n==4:\r\n print(4)\r\n print(2,4,1,3)\r\nelif n%2==0:\r\n print(n)\r\n for i in range(1, n//2 + 1):\r\n print(i, end = \" \")\r\n print(n//2 + i, end = \" \")\r\nelse:\r\n print(n)\r\n for i in range(1, n//2 + 1):\r\n print(i, end = \" \")\r\n print(n//2 + i + 1, end = \" \")\r\n print(n//2 + 1)\r\n", "n=int(input());\r\nif n!=2 and n!=3:\r\n print(n);a=[0]*n;l=n//2+1;k=1\r\n for i in range(n):\r\n if i%2==0:\r\n a[i]=l;l+=1\r\n else:\r\n a[i]=k;k+=1\r\n print(*a)\r\nelif n==2:\r\n print(1);print(1)\r\nelif n==3:\r\n print(2);print(1,3)", "from math import sqrt, pow, ceil\nfrom decimal import *\n\n#getcontext().prec = 10\n\nl1 = int(input())\n#l2= int(input())\n#l3 = int(input())\n#l1 = input().split()\n#l2 = input()\n#l2 = input().split()\n#l2 = list(input())\n\n#l1 = [int(i) for i in l1]\n#l2 = [int(i) for i in l2]\nif (l1 <= 2):\n print(\"1\")\n print(\"1\")\nelif (l1 == 3):\n print(\"2\")\n print(\"1 3\")\nelif (l1 == 4):\n print(\"4\")\n print(\"3 1 4 2\");\nelse:\n print(l1)\n for i in range (2, l1+1, 2):\n print(str(i)+ \" \", end=\"\")\n for i in range (1, l1+1, 2):\n print(str(i)+ \" \", end=\"\")\n\n \t \t \t \t\t\t \t\t\t \t\t\t\t \t\t \t", "n=int(input())\r\nif n==1 or n==2:\r\n\tprint(\"1\\n1\")\r\nelif n==3:\r\n\tprint(\"2\\n1 3\")\r\nelif n==4:\r\n\tprint(\"4\\n3 1 4 2\")\r\nelif n==5:\r\n\tprint(\"5\\n1 4 2 5 3\")\r\nelse:\r\n\thalf=n//2\r\n\tprint(n)\r\n\tif n%2:\r\n\t\tprint(str(n)+\" \",end=\"\")\r\n\tfor i in range(1,half+1):\r\n\t\tprint(str(i)+\" \"+str(half+i)+\" \",end=\"\")", "n = int(input())\nif n == 1 or n==2:\n print(1)\n print(1)\nelif n==3:\n print(2)\n print(1,3)\nelse:\n print(n)\n nums = [2,4,1,3]\n left = True\n for i in range(4,n,1):\n if left:\n nums.insert(0,i+1)\n else:\n nums.append(i+1)\n left = not left\n [print(num,end=\" \") for num in nums]\n print()\n\n", "a = int(input())\nif a == 1 or a == 2:\n print(1)\n print(1)\nelif a == 3:\n print(2)\n print(1, 3)\nelif a == 4:\n print(4)\n print(3, 1, 4, 2)\nelse:\n print(a)\n b = []\n for i in range(a//2+a%2):\n b.append(i*2+1)\n for k in range(a//2):\n b.append(k*2+2)\n print(*b)\n", "n=int(input())\r\nl=[]\r\nfor i in range(1,n+1,2):\r\n l.append(i)\r\nl.reverse()\r\nif(n>3):\r\n for i in range(n-n%2,1,-2):\r\n l.append(i)\r\nprint(len(l))\r\nfor i in l:\r\n print(i,end=\" \")", "n = int(input())\r\n\r\nif n in (2, 3):\r\n print(n - 1)\r\n print(*(1, 3)[:n-1])\r\nelse:\r\n print(n)\r\n print(*range(2, n + 1, 2), *range(1, n + 1, 2))", "import math\r\nimport string\r\n\r\ndef main():\r\n\tn = int(input())\r\n\tif n <= 2:\r\n\t\tans = [1]\r\n\telif n == 3:\r\n\t\tans = [1, 3]\r\n\telse:\r\n\t\tans = list(range(2, n + 1, 2)) + list(range(1, n + 1, 2))\r\n\tprint(len(ans))\r\n\tprint(' '.join(map(str, ans)))\r\n\r\nif __name__ == '__main__':\r\n\tmain()", "n = int(input()) \r\nx = [i for i in range(n , 0, -1 ) if i %2 != 0 ] + [i for i in range(n , 0, -1 ) if i %2 == 0 ]\r\nl =[x[0]] \r\nfor i in range(1 , len(x)) : \r\n if abs(x[i] - x[i-1]) <= 1 :\r\n continue \r\n else : \r\n l.append(x[i])\r\nprint(len(l)) \r\nprint(*l) ", "n = int(input()) ;odd = [];even = []\r\nif n == 3 :print(2);print(\"1\", \"3\")\r\nelif n == 2 :print(1);print(1)\r\nelif n == 1 : print(1); print(1)\r\nelse: \r\n for i in range(1,n+1,1):\r\n if i%2 == 0 :even.append(i)\r\n else:odd.append(i)\r\n odd.reverse();even.reverse();q = odd + even;print(len(q));print(*q)", "n=int(input())\r\nif n>3:\r\n print(n)\r\n print(*([i*2+2 for i in range(n//2)]+[i*2+1 for i in range(n-n//2)]))\r\nelif n==3:\r\n print('2\\n1 3')\r\nelif n==2:\r\n print('1\\n1')\r\nelse:\r\n print('1\\n1')", "n=int(input())\n\nif(n==2):\n print(\"1\\n1\")\nelif(n==3):\n print(\"2\\n1 3\")\nelif n==4:\n print(\"4\\n3 1 4 2\")\nelif(n==1):\n print(\"1\\n1\")\nelse:\n print(n)\n for i in range(1,n+1,2):\n print(i,end=' ')\n for i in range(2,n+1,2):\n print(i,end=' ')", "n=int(input())\r\na=list(range(2,n+1,2))+list(range(1,n+1,2))\r\nif n>1 and n<4:\r\n a=a[1:]\r\nprint(len(a))\r\nprint(' '.join(map(str,a)))", "n = int(input())\r\n\r\neven_arr = []\t\t\t#even - нечетный\r\nuneven_arr =[]\t\t\t#uneven - нечетный\r\ni=0\r\nif (n % 2 == 0):\t\t\t\t\t\t\t# Разбиваю N на два списка с четным индексами N=12 [][]\r\n\tfirst_index = n //2\r\n\t#second_index = first_index\r\n\r\n\twhile(i<first_index):\r\n\t\tuneven_arr.append(2*i+1)\t\r\n\t\ti+=1\r\n\ti=0\r\n\twhile(i<first_index):\r\n\t\ti+=1\r\n\t\teven_arr.append(2*i)\r\n\r\nelse:\t\t\t\t\t\t\t# n - нечетное кол-во\r\n\tfirst_index = (n+1)//2 # получаем индекс, где будет на один нечет. элемент больше\t\tто есть при n= 7\r\n\tsecond_index = ((n+1)//2)-1 # где будут четные\t\t\t\t\t\t\t\t\t\t\t[1 3 5 7] [2 4 6] \r\n\ti=0\r\n\r\n\twhile(i<first_index):\r\n\t\tuneven_arr.append(2*i+1)\t\r\n\t\ti+=1\r\n\r\n\ti=0\r\n\twhile(i<second_index):\r\n\t\ti+=1\r\n\t\teven_arr.append(2*i)\r\n\r\nif n==4:\t\t\t\t\t\t\t\t\t\t\t\t\t#Частные случаи\r\n\t\tprint(4)\r\n\t\teven_arr.extend(uneven_arr) \r\n\t\tprint(' '.join([str(i) for i in even_arr]))\r\n\t\t\r\nelif n==3:\r\n\t\tprint(2)\r\n\t\tprint(' '.join([str(i) for i in uneven_arr]))\r\nelif n==2 or n==1:\r\n\tprint(1)\r\n\tprint(' '.join([str(i) for i in uneven_arr]))\r\nelse:\r\n\tprint(n)\r\n\tuneven_arr.extend(even_arr) \r\n\tprint(' '.join([str(i) for i in uneven_arr]))", "n = int(input())\n\n\nans = []\nif n <= 4:\n if n == 1 or n == 2:\n ans.append(1)\n elif n == 3:\n ans.append(1)\n ans.append(3)\n else:\n ans.append(2)\n ans.append(4)\n ans.append(1)\n ans.append(3)\nelse:\n for i in range(1, n + 1, 2):\n ans.append(i)\n for i in range(2, n + 1, 2):\n ans.append(i)\n\nprint(len(ans))\nans = [str(x) for x in ans]\nans = ' '.join(ans)\nprint(ans)\n \t\t\t \t \t \t\t \t \t\t\t\t\t \t", "n = int(input())\r\n\r\nl_o = list()\r\nl_e = list()\r\n\r\nfor i in range(1, n + 1):\r\n if i % 2 == 0:\r\n l_e.append(i)\r\n else:\r\n l_o.append(i)\r\n \r\nl_e.sort(reverse = True)\r\nl_o.sort(reverse = True)\r\nl_o.extend(l_e)\r\n\r\nif n >= 2 and abs(l_o[n - len(l_e)] - l_o[n - len(l_e) - 1]) <= 1:\r\n l_o.remove(l_o[n - 1])\r\n\r\nprint(len(l_o))\r\nprint(\" \".join(str(x) for x in l_o))", "n = int(input())\r\nans = list(range(2, n+1, 2))+list(range(1, n+1, 2))\r\nif 1 < n < 4:\r\n print(n-1)\r\n print(*ans[1:])\r\nelse:\r\n print(n)\r\n print(*ans)\r\n", "n=int(input())\r\n\r\nif n<=2:\r\n print(1)\r\n print(1)\r\nelif n==3:\r\n print(2)\r\n print(1, 3)\r\nelse:\r\n print(n)\r\n for number in range(2, n+1, 2):\r\n print(number, end=\" \")\r\n\r\n for number in range(1, n+1, 2):\r\n print(number, end=\" \")", "n = int(input())\r\n\r\nif n == 2:\r\n print(1)\r\n print(1)\r\n\r\nelif n == 3:\r\n print(2)\r\n print(1, 3)\r\n\r\nelif n == 4:\r\n print(4)\r\n print(2, 4, 1, 3)\r\n\r\nelif n % 2 == 0:\r\n print(n)\r\n for i in range(1, n, 2):\r\n print(i, end=' ')\r\n for i in range(2, n+1, 2):\r\n print(i, end=' ')\r\n\r\nelse:\r\n print(n)\r\n for i in range(1, n+1, 2):\r\n print(i, end=' ')\r\n for i in range(2, n, 2):\r\n print(i, end=' ')\r\n", "n=int(input())\r\nb=\"\"\r\nfor i in range(1,n,2):\r\n b+=str(i+1)+\" \"\r\nfor i in range(0,n,2):\r\n b+=str(i+1)+\" \"\r\nif n==1:\r\n print(1)\r\n print(1)\r\nelif n==2:\r\n print(1)\r\n print(2)\r\nelif n==3:\r\n print(2)\r\n print(1,3)\r\nelse:\r\n print(n)\r\n print(b)\r\n", "a = int(input())\r\nif a == 3:\r\n print(2)\r\n print(1,3)\r\nelif a <= 2:\r\n print(1)\r\n print(1)\r\nelse:\r\n print(a)\r\n for i in reversed(range(1,a+1, 2)):\r\n print(i, end=' ')\r\n for i in reversed(range(2, a+1, 2)):\r\n print(i, end=' ')", "s1=int( input())\r\nv1=list(range(1,s1+1,2))\r\nv2=list(range(2,s1+1,2))\r\nif s1==1 or s1==2:\r\n print(\"1\\n1\")\r\n exit()\r\nif s1==3:\r\n print(\"2\\n1 3\")\r\n exit()\r\nv1=v2+v1\r\nprint(len(v1))\r\nprint(' '.join(map(str, v1)))", "n = int(input())\r\n\r\na = [i for i in range(1, n+1)]\r\n\r\nif n == 1 or n == 2:\r\n print(1)\r\n print(1)\r\nelif n == 3:\r\n print(2)\r\n print(1, 3)\r\nelif n == 4:\r\n print(4)\r\n print(2, 4, 1, 3)\r\nelif n == 5:\r\n print(5)\r\n print(4, 2, 5, 3, 1)\r\nelse:\r\n print(n)\r\n if n % 2 == 1:\r\n print(n, end=\" \")\r\n for i in range(1, int(n/2) + 1):\r\n print(i, int(n/2 + i), end=\" \")", "def f(n):\r\n l = [None,[[1],[1]], [[1],[1]], [[2],[1,3]]]\r\n if n<4:\r\n return l[n]\r\n ol = list(range(1,n+1,2))\r\n ol.reverse()\r\n el = list(range(2,n+1,2))\r\n el.reverse()\r\n return [[n],ol+el] # ...-3-1-(2k)-(2k-2)-...-2\r\n\r\n[print(*r) for r in f(int(input()))]\r\n", "a = int(input());\r\nif(a==1 or a==2):\r\n print(1);\r\n print(1);\r\nelif(a==3):\r\n print(a-1);\r\n print(1, 3);\r\nelse:\r\n print(a);\r\n for i in range(1, a+1):\r\n if(i%2==0):\r\n print(i, \"\", end='');\r\n for i in range(1, a+1):\r\n if(i%2==1):\r\n print(i, \"\", end='');", "from sys import stdin; inp = stdin.readline\r\ndef IA(): return list(map(int, inp().split()))\r\ndef FA(): return list(map(float, inp().split()))\r\ndef SA(): return inp().split()\r\ndef I(): return int(inp())\r\ndef F(): return float(inp())\r\ndef S(): return inp()\r\nfrom collections import deque\r\n\r\ndef main():\r\n n = I() \r\n \r\n if n < 3:\r\n print(1)\r\n return 1 \r\n elif n == 3:\r\n print(2)\r\n s = '1 3' \r\n return s \r\n else:\r\n odd = ''\r\n even = ''\r\n for i in range(n, 0, -1):\r\n if i%2==1:\r\n odd += str(i) + ' '\r\n else: \r\n even += str(i) + ' '\r\n s = odd + even\r\n print(n)\r\n return s\r\n \r\n \r\n\r\nif __name__ == '__main__':\r\n print(main())", "n = int(input())\r\nif n <= 2:\r\n print(1)\r\n print(1)\r\nelif n == 3:\r\n print(2)\r\n print('1 3')\r\nelif n == 4:\r\n print(4)\r\n print('2 4 1 3')\r\nelse:\r\n print(n)\r\n for i in range(1, n + 1, 2):\r\n print(i, end=' ')\r\n for i in range(2, n + 1, 2):\r\n print(i, end=' ')\r\n\r\n\r\n'''\r\n6\r\n\r\n1 2 3 4 5 6\r\n1 3 5 2 4 6\r\n***************************\r\n10\r\n\r\n1 2 3 4 5 6 7 8 9 10\r\n1 3 5 7 9 2 4 6 8 10\r\n***************************\r\n1\r\n1\r\n***************************\r\n2\r\n\r\n1\r\n****************************\r\n3\r\n \r\n1 3\r\n****************************\r\n4 \r\n\r\n2 4 1 3\r\n****************************\r\n5\r\n1 3 5 2 4 \r\n****************************\r\n6\r\n1 3 5 2 4 6 \r\n'''\r\n", "n = int(input())\r\nif n <= 2:\r\n print(1)\r\n print(1)\r\nelif n == 3:\r\n print(2)\r\n print(1, 3)\r\nelif n == 4:\r\n print(4)\r\n print(2, 4, 1, 3)\r\nelse:\r\n print(n)\r\n for i in range(1, n + 1, 2):\r\n print(i, end=' ')\r\n for i in range(2, n + 1, 2):\r\n print(i, end=' ')\r\n\r\n'''\r\n4\r\n1234\r\n1423\r\n2\r\n1 3\r\n\r\n5\r\n12345\r\n13524\r\n\r\n6\r\n123 456\r\n135246\r\n7\r\n1234567\r\n1357246\r\n4 1 5 2 6 3 \r\n4 1\r\n5 2\r\n6 3\r\n\r\n\r\n'''", "nn=int(input())\r\nr=''\r\nif nn!=2 and nn!=3:\r\n print(nn)\r\n for i in range(2,nn+1,2):\r\n r+=str(i)\r\n r+=' '\r\n for i in range(1,nn+1,2):\r\n r+=str(i)\r\n r+=' '\r\n print(r)\r\nelse:\r\n if nn==2:\r\n print(1)\r\n print(1)\r\n else:\r\n print(2)\r\n print('1 3')\r\n", "n = int(input())\nif n==2:\n print(\"1\\n1\")\nelif n==3:\n print(\"2\\n1 3\")\nelse:\n print(n)\n for i in range(n-1,0,-2):\n print(i, end=' ')\n for i in range(n,0,-2):\n print(i, end=' ')\n\n \t\t\t \t\t\t \t\t \t\t\t \t \t \t\t\t\t", "#!/usr/bin/env python3\r\nn = int(input())\r\nif n<3:\r\n print(1)\r\n print(1)\r\nelif n==3:\r\n print(2)\r\n print('1 3')\r\nelif n==4:\r\n print(4)\r\n print('2 4 1 3')\r\nelse:\r\n print(n)\r\n for i in range(1, n+1, 2):\r\n print(i, end = ' ', flush = True)\r\n for i in range(2, n+1, 2):\r\n print(i, end = ' ', flush = True)", "n = int(input())\r\n\r\nif n == 1 or n == 2 :\r\n print(1)\r\n print(1)\r\n\r\nelif n == 3 :\r\n print(2)\r\n print(1 , 3)\r\n\r\nelif n == 4 :\r\n print(4)\r\n print(3 , 1 , 4 , 2 )\r\n\r\nelse:\r\n k = 1\r\n print(n)\r\n\r\n for i in range(n):\r\n print(k , end=' ')\r\n k+=2\r\n if k > n :\r\n k = 2 ", "n = int(input())\r\ne,o = [],[]\r\nfor i in range(1,n+1):\r\n if i%2:o.append(f'{i}')\r\n else:e.append(f'{i}')\r\ntry:\r\n if abs(int(e[-1]) - int(o[0])) == 1:e.pop()\r\nexcept:...\r\nprint(len(e) + len(o) , '\\n' , *(e + o))", "n = int(input())\r\nif n == 2:\r\n print(1, '\\n', 1, sep=\"\")\r\nelif n == 3:\r\n print(2, \"\\n\", '1 ', 3, sep=\"\")\r\nelse:\r\n a = [x for x in range(1, n + 1, 2)][-1::-1]\r\n b = [x for x in range(2, n + 1, 2)][-1::-1]\r\n print(len(a + b))\r\n print(*a, *b)\r\n", "#!/usr/bin/env python\n\nimport sys\n\nn = int(input())\n\nif n == 4:\n print(4)\n print(3,1,4,2)\n sys.exit(0)\n\nout = []\n\nfor i in range(0, n, 2):\n out.append(i+1)\nif not abs(out[-1] - 2) == 1:\n for i in range(1, n, 2):\n out.append(i+1)\n\nprint(len(out))\nprint(' '.join(map(str, out)))\n", "n = int(input())\r\nif n <= 2:\r\n print(1)\r\n print(1)\r\nelif n == 3:\r\n print(2)\r\n print(1, 3)\r\nelse:\r\n # n >= 4\r\n print(n)\r\n if n % 2 == 1: # odd\r\n for i in range(n, 0, -2): print(i, end = ' ')\r\n for i in range(n-1, 0, -2): print(i, end = ' ')\r\n print()\r\n elif n % 2 == 0: # even\r\n for i in range(n-1, 0, -2): print(i, end = ' ')\r\n for i in range(n, 0, -2): print(i, end = ' ')\r\n print()", "from math import gcd\nn = int(input())\nif n <= 2:\n print(\"1\\n1\")\nelif n == 3:\n print(\"2\\n1 3\")\nelif n == 4:\n print(\"4\\n2 4 1 3\")\nelif n == 6:\n print('6\\n1 5 3 6 2 4')\nelif n > 4:\n for d in range(2, n):\n if gcd(d, n) == 1:\n print(n)\n ans = []\n for i in range(n):\n ans += [ d * i % n + 1 ]\n print(' '.join(map(str, ans)))\n exit(0)\n", "n = int(input())\n\nif n == 1:\n\tprint(1)\n\tprint(1)\nelif n == 2:\n\tprint(1)\n\tprint(2)\nelif n == 3:\n\tprint(2)\n\tprint(1, 3)\nelif n == 4:\n\tprint(4)\n\tprint(2, 4, 1, 3)\nelse:\n\tprint(n)\n\todd = 1\n\teven = 2\n\tfor i in range(n):\n\t\tif odd <= n:\n\t\t\tprint(odd, end = \" \")\n\t\t\todd += 2\n\t\telif even <= n:\n\t\t\tprint(even, end = \" \")\n\t\t\teven += 2", "n=int(input())\r\nif(n==1 or n==2):\r\n print(1)\r\n print(1)\r\nelif(n==3):\r\n print(2)\r\n print(1,3)\r\nelse:\r\n c=[]\r\n for i in range(n-1,0,-2):\r\n c.append(i)\r\n for i in range(n,0,-2):\r\n c.append(i)\r\n print(len(c))\r\n for i in c:\r\n print(i,end=\" \")\r\n", "n = int(input())\r\nif n == 1:\r\n print(1)\r\n print(1)\r\nelif n == 2:\r\n print(1)\r\n print(1)\r\nelif n == 3:\r\n print(2)\r\n print(1, 3)\r\nelse:\r\n print(n)\r\n odd = []\r\n even = []\r\n for i in range(1, n+1):\r\n if i % 2 == 0:\r\n even.insert(0, i)\r\n else:\r\n odd.insert(0,i)\r\n ans = odd + even\r\n print(*ans)", "n = int(input())\r\nif n==1 or n==2:\r\n print(1)\r\n print(1)\r\nelif n==3:\r\n print(2)\r\n print(1,3)\r\nelse:\r\n odd = []\r\n even = []\r\n for i in range(1,n+1):\r\n if i%2==0:\r\n even.append(i)\r\n else:\r\n odd.append(i)\r\n if n%2==0:\r\n ans = odd[-1::-1]+even[-1::-1]\r\n else:\r\n ans = odd+even\r\n print(n)\r\n print(*ans)", "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\nelse:\r\n input = sys.stdin.readline\r\n\r\n############## Code starts here ##########################\r\n\r\nn = int(input())\r\n\r\nif n==2 or n==1:\r\n print(1)\r\n print(1)\r\nelif n==3:\r\n print(2)\r\n print(1,3)\r\n\r\nelse:\r\n print(n)\r\n for i in range(n-1,0,-2):\r\n print(i,end=\" \")\r\n for i in range(n,0,-2):\r\n print(i,end=\" \")\r\n\r\n############## Code ends here ############################\r\n", "def func(n):\n if n==1 or n==2:\n return 1,[1]\n if n==3:\n return 2,[1,3]\n t=[None]*n\n i=0\n k=2\n while k<=n:\n t[i]=k\n k+=2\n i+=1\n k=1\n while k<=n:\n t[i]=k\n k+=2\n i+=1\n return n,t\n \n\nn=int(input())\np,q=func(n)\n \nprint(p)\nfor i in range(len(q)):\n print(q[i],end=' ')\n \t\t \t \t\t\t \t \t\t\t\t\t\t\t", "n = int(input())\r\nif(n==1):\r\n print(1)\r\n print(1)\r\nif(n==2):\r\n print(1)\r\n print(2)\r\nif(n==3):\r\n print(2)\r\n print(1,3)\r\nif(n>=4):\r\n print(n)\r\n idx_2 = (n)//2\r\n idx_1 = 0\r\n while(idx_2 < n and idx_1 < n//2):\r\n print(idx_2+1, idx_1+1, end=' ')\r\n idx_2+=1\r\n idx_1+=1\r\n if(idx_2<n):\r\n print(idx_2+1)", "n=int(input())\r\nif (n==1 or n==2):\r\n print(1)\r\n print(1)\r\nelif (n==3):\r\n print(2)\r\n print(\"1 3\")\r\nelif (n==4):\r\n print(4)\r\n print(\"3 1 4 2\")\r\nelse:\r\n print(n)\r\n for i in range(n):\r\n if (i%2==0):\r\n print(i+1,end=\" \")\r\n for i in range(n):\r\n if (i%2):\r\n print(i+1,end=\" \")", "# A. Exam\r\nn=int(input())\r\no=[]\r\ne=[]\r\nfor i in range(1,n+1):\r\n if i%2==0:\r\n e.append(i)\r\n else:\r\n o.append(i)\r\no.sort(reverse=1)\r\ne.sort(reverse=1)\r\nif n<=2:\r\n print(\"1\")\r\n print(\"1\")\r\nelif n==3:\r\n print(\"2\")\r\n print(\"1\",\"3\")\r\nelse:\r\n print(n)\r\n o=o+e\r\n print(*o)", "import sys\r\n\r\nx = int(input())\r\n\r\nlist = list(range(1, x+1))\r\n\r\nif x==2:\r\n print(1)\r\n print(1)\r\n sys.exit()\r\n\r\nif x==3:\r\n print(2)\r\n print(\"1 3\")\r\n sys.exit()\r\n\r\nprint(x)\r\nif x % 2 == 1:\r\n y = int(x/2)\r\n print(\"{:d} \".format(y+1), end=\"\")\r\n for i in range(x, x-y, -1):\r\n print(\"{:d} {:d} \".format(i, (x+1)-i), end=\"\")\r\n\r\nelse:\r\n y = int(x/2)\r\n print(\"{:d} \".format(y), end=\"\")\r\n for i in range(x, y+1, -1):\r\n print(\"{:d} {:d} \".format(i, (x + 1) - i), end=\"\")\r\n print(y+1)", "n=int(input())\r\n\r\nfl=[]\r\n\r\nif n>=4:\r\n for i in range(2,n+1,2):\r\n fl.append(i)\r\n for i in range(1,n+1,2):\r\n fl.append(i)\r\n print(n)\r\n print(*fl)\r\n\r\nif n==3:\r\n print(2)\r\n print(1,3)\r\n\r\nif n==2:\r\n print(1)\r\n print(1)\r\nif n==1:\r\n print(1)\r\n print(1)", "n=int(input())\r\nx=[(i+1) for i in range(n)]\r\ny=[]\r\nz=[1,3]\r\nif n==1 or n==2:\r\n print(1)\r\n print(1)\r\nelif n==3:\r\n print(2)\r\n print(*z)\r\nelse:\r\n for i in range(len(x)):\r\n if x[i]%2==0:\r\n y.append(x[i])\r\n for i in range(len(x)):\r\n if x[i]%2!=0:\r\n y.append(x[i])\r\n print(len(y))\r\n print(*y)", "n = int(input())\r\nif 1 <= n < 4:\r\n k = n\r\n n -= 1 * (n != 1)\r\n print(n)\r\n print([\"1\", \"1\", \"1 3\"][k - 1])\r\nelse:\r\n s = list(range(1, n + 1))\r\n print(n)\r\n for i in range(1, n, 2):\r\n s[i], s[i - 1] = s[i - 1], s[i]\r\n for i in range(2, (n // 2) * 2 - 1, 2):\r\n s[i - 1], s[i] = s[i], s[i - 1]\r\n for e in s[:-1]:\r\n print(e, end=' ')\r\n print(s[-1])\r\n", "''' Тавас и Нафас 1000'''\r\ns = int(input())\r\n#ch = input()\r\n#ch = ch.split()\r\n#ch = [int(x) for x in ch]\r\n#n, m = ch\r\nif s < 3:\r\n print(1)\r\n print(1)\r\n exit()\r\nif s == 3:\r\n print(2)\r\n print(1,3)\r\n exit()\r\n\r\nif s % 2 != 0:\r\n rz = [s]\r\nelse:\r\n rz = []\r\nchet = [2*(x+1) for x in range(s//2)]\r\nne4et = [2*(x+1)-1 for x in range(s//2)]\r\nrz.extend(chet)\r\nrz.extend(ne4et)\r\n\r\nprint(s)\r\nfor i in rz:\r\n print(i, end=' ')", "n = int(input())\r\nif n == 1: print(\"1\\n1\")\r\nelif n == 2: print(\"1\\n1\")\r\nelif n == 3: print(\"2\\n1 3\")\r\nelse:\r\n res = []\r\n for i in range(n//2):\r\n res.append(2*(i+1))\r\n for i in range(n//2):\r\n res.append(2*i+1)\r\n if n % 2 == 1:\r\n res.append(n)\r\n print(n)\r\n print(\" \".join(str(x) for x in res))", "n = int(input())\r\nbase = [2, 4, 1, 3]\r\n\r\nif n == 1 or n == 2:\r\n print(1)\r\n print(1)\r\nelif n == 3:\r\n print(2)\r\n print(1, 3)\r\nelse:\r\n print(n)\r\n for i in range(5, n + 1):\r\n if i & 1:\r\n base = [i] + base\r\n else:\r\n base.append(i)\r\n\r\n print(*base)\r\n ", "n = int(input().rstrip())\r\nans = ''\r\nif n > 3:\r\n ans += str(n)\r\n for i in range(1, n):\r\n if i % 2 == 0:\r\n ans += ' ' + str(i)\r\n else:\r\n ans = str(i) + ' ' + ans\r\n print(n)\r\n print(ans)\r\nelif n == 3:\r\n print(2)\r\n print('1 3')\r\nelif n == 2 or n == 1:\r\n print(1)\r\n print('1')", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\nn = int(input())\r\nif n <= 2:\r\n k, ans = 1, [1]\r\nelif n == 3:\r\n k, ans = 2, [1, 3]\r\nelse:\r\n k = n\r\n ans = [0] * n\r\n x = 1\r\n for i in range(1, -1, -1):\r\n for j in range(i, n, 2):\r\n ans[j] = x\r\n x += 1\r\nprint(k)\r\nsys.stdout.write(\" \".join(map(str, ans)))", "# Wadea #\r\n \r\nn = int(input())\r\narr = []\r\nfor i in range(1,n+1):\r\n arr.append(i)\r\n\r\nif n <= 3:\r\n if n == 3:\r\n print(2)\r\n print(1,3)\r\n elif n == 2:\r\n print(1)\r\n print(2)\r\n else:\r\n print(1)\r\n print(1)\r\n\r\nelse:\r\n out = \"\"\r\n if n % 2 == 0:\r\n a,b = 0,-1\r\n for i in range(n//2):\r\n if arr[a] == n // 2:\r\n out = f\"{arr[a]} \" + out\r\n out += f\"{arr[b]} \"\r\n break\r\n out += f\"{arr[b]} \"\r\n out += f\"{arr[a]} \"\r\n a += 1\r\n b -= 1\r\n print(n)\r\n print(out)\r\n \r\n else:\r\n a,b = 0,-1\r\n for i in range(n//2):\r\n out += f\"{arr[b]} \"\r\n out += f\"{arr[a]} \"\r\n a += 1\r\n b -= 1\r\n print(n)\r\n print(f\"{n//2 + 1} \"+out)\r\n", "n=int(input())\r\nif(n==2 or n==1):\r\n\tprint(1)\r\n\tprint(1)\r\nelif(n==3):\r\n\tprint(2)\r\n\tprint('1 3')\r\nelse:\r\n\ts1=''\r\n\ts2=''\r\n\tfor i in range(1,n+1):\r\n\t\tif(i%2==0):\r\n\t\t\ts1+=str(i)+' '\r\n\t\telse:\r\n\t\t\ts2+=str(i)+' '\r\n\tprint(n)\r\n\tprint(s1+s2)", "import random\r\nt = 1-0\r\nfor ___________ in range(t):\r\n n = int(input())\r\n a = [int(i) for i in range(1, n+1)]\r\n if(n<=2):\r\n print(1)\r\n print(1)\r\n if(n==3):\r\n print(2)\r\n print(1, 3)\r\n if(n<4):\r\n exit(0)\r\n while(1):\r\n random.shuffle(a)\r\n for i in range(n-1):\r\n if(abs(a[i]-a[i+1])==1):\r\n break\r\n else:\r\n print(n)\r\n print(*a)\r\n exit(0)\r\n\r\n\r\n", "# # test case 1\r\n# n = 6\r\n\r\n# # test case 2\r\n# n = 3\r\n\r\n\r\nn = int(input(''))\r\n\r\nif not 1 <= n <= 5000:\r\n print('ошибка ввода данных')\r\n exit(1)\r\n\r\nif n == 1 or n == 2:\r\n answer = [1, '1']\r\nelif n == 3:\r\n answer = [2, '1 3']\r\nelse:\r\n pupils = list(range(1, n + 1))\r\n part_1, part_2 = pupils[n // 2:], pupils[:n // 2]\r\n _pupils = [pupils[-1]] if len(pupils) % 2 else []\r\n for el in list(zip(part_1, part_2)):\r\n _pupils.extend(el)\r\n answer = [n, ' '.join(map(str, _pupils))]\r\n\r\n[print(el) for el in answer]\r\n", "t=int(input())\r\nif t==1:\r\n print('1')\r\n print('1')\r\nelif t==2:\r\n print('1')\r\n print('2')\r\nelif t==3:\r\n print('2')\r\n print('1 3')\r\nelif t==4:\r\n print('4')\r\n print('3 1 4 2')\r\nelse:\r\n print(t)\r\n for i in range(1,t+1,2):\r\n print(i,end=' ')\r\n for i in range(2,t+1,2):\r\n print(i,end=' ')", "import sys\r\n\r\nn = int(input())\r\n\r\nif(n < 3):\r\n print(1)\r\n print(1)\r\nelif(n == 3):\r\n print(2)\r\n print(1, 3)\r\nelif(n == 4):\r\n print(4)\r\n print(3, 1, 4, 2)\r\nelse:\r\n print(n)\r\n i = 1\r\n while(i <= n):\r\n sys.stdout.write(str(i))\r\n sys.stdout.write(\" \")\r\n i += 2\r\n\r\n i = 2\r\n while(i <= n):\r\n sys.stdout.write(str(i))\r\n sys.stdout.write(\" \")\r\n i += 2\r\n\r\n\r\n\r\n", "n=input()\r\nn=int(n)\r\nmylist=[]\r\nans=0\r\nif n<3:\r\n mylist.append(1)\r\nelif n==3:\r\n mylist.append(1)\r\n mylist.append(3)\r\nelif n==4:\r\n mylist.append(3)\r\n mylist.append(1)\r\n mylist.append(4)\r\n mylist.append(2)\r\nelse:\r\n for i in range(1,n+1,2):\r\n mylist.append(i)\r\n for i in range(2,n+1,2):\r\n mylist.append(i)\r\nans=len(mylist)\r\n\r\nprint(ans)\r\nfor p in mylist:\r\n print(p,\" \", end=\"\")\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n=int(input())\r\nif n==1 or n==2:\r\n\tprint(1)\r\n\tprint(1)\r\nelif n==3:\r\n\tprint(2)\r\n\tprint(1,3)\r\nelse:\r\n\tz=[]\r\n\tfor i in range(n//2):\r\n\t\tz.append(n//2+i+1)\r\n\t\tz.append(i+1)\r\n\tif n%2==1:\r\n\t\tz.append(n)\r\n\tprint(n)\r\n\tprint(*z)", "n = int(input())\r\nif n == 1:\r\n print ('1')\r\n print ('1')\r\nelif n == 2:\r\n print ('1')\r\n print ('1')\r\nelif n == 3:\r\n print ('2')\r\n print ('1 3')\r\nelif n == 4:\r\n print ('4')\r\n print ('3 1 4 2')\r\nelif n == 5:\r\n print ('5')\r\n print ('3 1 5 2 4')\r\nelif n == 6:\r\n print ('6')\r\n print ('1 5 3 6 2 4')\r\nelse:\r\n arr = [i + 1 for i in range(n)]\r\n for i in range(n // 2):\r\n if i % 2 == 0:\r\n arr[i], arr[n - i - 1] = arr[n - i - 1], arr[i] \r\n arr[n // 2], arr[0] = arr[0], arr[n // 2]\r\n print (n)\r\n print (*arr)", "class Queue:\r\n def __init__(self):\r\n self.items = []\r\n\r\n def isEmpty(self):\r\n return self.items == []\r\n\r\n def enqueue(self, item):\r\n self.items.insert(0, item)\r\n\r\n def dequeue(self):\r\n return self.items.pop()\r\n\r\n def size(self):\r\n return len(self.items)\r\nx=int(input())\r\nif x==3 :\r\n print(\"2\")\r\n print(\"1 3\")\r\n exit()\r\nelif x==2 :\r\n print(\"1\")\r\n print(\"1\")\r\n exit()\r\nst=Queue()\r\nalist=[]\r\n\r\nc=0\r\nfor i in range (1,x+1):\r\n alist.append(i)\r\nm=0\r\nwhile(c<x):\r\n st.enqueue(alist[m+(x//2)])\r\n c+=1\r\n if c < x :\r\n st.enqueue(alist[m])\r\n m += 1\r\n c += 1\r\n\r\nprint(st.size())\r\nwhile(not st.isEmpty()):\r\n print(st.dequeue(),end=' ')\r\nprint(\"\\n\")\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n = int(input())\r\n\r\nif n <= 2:\r\n\tprint(1)\r\n\tprint(1)\r\nelif n == 3:\r\n\tprint(2)\r\n\tprint(1, 3)\r\nelif n == 4:\r\n\tprint(4)\r\n\tprint(2, 4, 1, 3)\r\nelse:\r\n\ti = 1\r\n\tj = n\r\n\tl = []\r\n\twhile i <= j:\r\n\t\tif len(l) % 2 == 0:\r\n\t\t\tl.append(i)\r\n\t\t\ti += 1\r\n\t\telse:\r\n\t\t\tl.append(j)\r\n\t\t\tj -= 1\r\n\tprint(len(l))\r\n\tt = l[0]\r\n\tl[0] = l[n - 1]\r\n\tl[n - 1] = t\r\n\tprint(\" \".join(map(str, l)))\r\n", "#!/usr/bin/env python3\r\n\r\nfrom sys import stdin, stdout\r\nfrom math import *\r\nfrom itertools import *\r\n\r\nlmap = lambda x, y: list(map(x, y))\r\nlfilter = lambda x, y: list(filter(x, y))\r\n\r\ndef solve(test):\r\n n = int(test.strip())\r\n if n <= 2:\r\n return \"1\\n1\"\r\n elif n == 3:\r\n return \"2\\n1 3\"\r\n elif n == 4:\r\n return \"4\\n2 4 1 3\"\r\n else:\r\n return str(n) + \"\\n\" + \" \".join(\r\n lmap(str, list(range(1, n + 1, 2)) + list(range(2, n + 1, 2))))\r\n \r\nstdout.write(str(solve(stdin.read())))\r\n", "x=int(input());y=list(range(2,x+1,2))+list(range(1,x+1,2))\r\nif 1<x<4:y=y[1:]\r\nprint(len(y));print(' '.join(map(str,y)))", "#!/usr/bin/python3\n\nimport itertools as ittls\nfrom collections import Counter\n\nimport re\nimport math\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\nif N == 3:\n print(2)\n print(1, 3)\n quit()\nelif N == 2:\n print(1)\n print(1)\n quit()\n\ns, t = [None]*N, 0\n\nfor i in range(2, N + 1, 2):\n s[t], t = i, t + 1\nfor i in range(1, N + 1, 2):\n s[t], t = i, t + 1\n\nprint(N)\n\nprint(' '.join(map(str, s)))\n", "# import sys \r\n# sys.stdin=open(\"input.in\",'r')\r\n# sys.stdout=open(\"out.out\",'w')\r\nn=int(input())\r\nif n<=2:\r\n\tprint(1)\r\n\tprint(1)\r\nelif n==3:\r\n\tprint(2)\r\n\tprint(1,3)\r\nelse:\r\n\tprint(n)\r\n\to=[]\r\n\te=[]\r\n\tfor i in range(1,n+1):\r\n\t\tif i%2==0:\r\n\t\t\te.append(i)\r\n\t\telse:\r\n\t\t\to.append(i)\r\n\to.sort(reverse=True)\r\n\te.sort(reverse=True)\r\n\tprint(*(o+e))\r\n\r\n\r\n\r\n\r\n", "z=int(input())\r\nif 2+2<=z:\r\n print(z)\r\n for i in range(2,z+1,2):\r\n print(i,end=' ') \r\nelse:\r\n print(['1','%d'%(z-1)][z>1]) \r\nfor i in range(1,z+1,2):\r\n print(i,end=' ') ", "t = int(input())\narr =[]\nif t%2==0:\n for i in range(1,t+1):\n if i%2==0:\n arr.append(i)\n for i in range(1,t+1):\n if i%2 ==0 or arr[-1]-1==i or arr[-1]+1==i:\n continue\n else:\n arr.append(i)\nelse:\n for i in range(1,t+1):\n if i%2==1:\n arr.append(i)\n for i in range(1,t+1):\n if i%2 ==1 or arr[-1]-1==i or arr[-1]+1==i:\n continue\n else:\n arr.append(i)\nx = arr\nprint(len(x))\narr= map(str,arr)\nprint(' '.join(arr))\n", "l = [None, '1\\n1', '1\\n1', '2\\n1 3', '4\\n2 4 1 3']\r\n\r\nn = int(input())\r\nif n in range(len(l)):\r\n print(l[n])\r\nelse:\r\n print(n)\r\n print(' '.join(map(str, range(1, n + 1, 2))), end=' ')\r\n print(' '.join(map(str, range(2, n + 1, 2))))\r\n", "n = int(input())\r\nresult = ''\r\nk = 0\r\nif n == 1 or n == 2:\r\n print('1')\r\n print('1')\r\n exit()\r\nelif n == 3:\r\n print('2')\r\n print('3 1')\r\n exit()\r\nfor i in reversed(range(1, n + 1, 2)):\r\n result += \"%s \" % str(i)\r\n k += 1\r\nfor j in reversed(range(2, n + 1, 2)):\r\n result += \"%s \" % str(j)\r\n k += 1\r\nprint(k)\r\nprint(result)", "n=int(input())\r\n\r\nif(n>1 and n<4):\r\n print(n-1)\r\n if(n==2):\r\n print(\"1\")\r\n if(n==3):\r\n print(\"1 3\")\r\n if(n==4):\r\n print(\"4 1 3\")\r\nelse:\r\n print(n)\r\n i=2\r\n l=[]\r\n while(i<=n):\r\n l.append(i)\r\n i+=2\r\n i=1\r\n while(i<=n):\r\n l.append(i)\r\n i+=2\r\n for i in range(n-1):\r\n print(l[i],\" \",end=\"\")\r\n print(l[-1])\r\n", "n = int(input())\n\nif n <= 2:\n r = [1]\nelif n == 3:\n r = [1, 3]\nelif n == 4:\n r = [3, 1, 4, 2]\nelse:\n i = 1\n r = []\n while i <= n // 2 - 1:\n r.append(i)\n r.append(n - i)\n i += 1\n\n if n % 2:\n r.append(i)\n\n r.append(n)\n r.append((n + 1) // 2)\n\nprint(len(r))\nprint(' '.join(map(str, r)))\n", "import functools\r\nn=int(input())\r\nif n==1 or n==2:\r\n\tprint(1)\r\n\tprint(1)\r\n\texit(0)\r\nelif n==3:\r\n\tprint(2)\r\n\tprint(1,3)\r\n\texit(0)\r\nodds=list(filter(lambda x:True if x%2==1 else False, range(1,n+1)))\r\nevens=list(filter(lambda x:True if x%2==0 else False, range(1,n+1)))\r\nodds.reverse()\r\nevens.reverse()\r\nod=' '.join(map(str,odds))\r\nev=' '.join(map(str,evens))\r\nprint(n)\r\nprint(od+\" \"+ev)", "# http://codeforces.com/problemset/problem/534/A\r\nn=int(input())\r\nif n==1:\r\n print(1)\r\n print(1)\r\n exit()\r\nif n==2:\r\n print(1)\r\n print(1)\r\n exit()\r\nif n==3:\r\n print(2)\r\n print(1,3)\r\n exit() \r\n \r\nprint(n)\r\n\r\n\r\na=list(range(1,n+1))\r\nans=[]\r\n\r\nwhile a:\r\n ans.append(a.pop(0))\r\n if a:\r\n ans.append(a.pop())\r\nans.insert(0,ans.pop())\r\nprint(' '.join(map(str,ans)))\r\n", "n=int(input())\r\na=[0]*n\r\ncount=0\r\nif n==1:\r\n print(1);print(1)\r\nelif n==2:\r\n print(1);print(1)\r\nelif n==3:\r\n print(2);print(1,3)\r\nelif n==4:\r\n print(4);print(3,1,4,2)\r\nelse:\r\n print(n)\r\n for i in range(n):\r\n if count>(n-1):\r\n count=1\r\n a[count]=i+1\r\n count+=2\r\n print(*a)\r\n ", "n = int(input())\r\na =list( range(2,n+1,2))+list(range(1,n+1,2))\r\nif n>1 and n<4:\r\n a = a[1:]\r\nprint(len(a))\r\nfor x in a:print(x),", "import random\r\n\r\nn = int(input())\r\ntemp = random.randint(2, 3)\r\n\r\nif n == 1:\r\n print(f'{1}\\n{1}')\r\nelif n == 2:\r\n print(f'{1}\\n{2}')\r\nelif n == 3:\r\n print(f'{2}\\n{1} {3}')\r\nelif n == 4:\r\n print(f'{4}\\n{3} {1} {4} {2}' if temp % 2 == 0 else f'{4}\\n{2} {4} {1} {3}')\r\nelse:\r\n print(n)\r\n for i in range(1, n + 1, 2):\r\n print(f'{i} ', end='')\r\n for i in range(2, n + 1, 2):\r\n print(f'{i} ', end='')\r\n", "n=int(input())\r\np=[]\r\nl=[]\r\nif n==1:\r\n print(1)\r\n print(1)\r\nelif n==2: \r\n print(1)\r\n print(1)\r\nelif n==3: \r\n print(2)\r\n print(1,3) \r\nelse:\r\n for i in range(1,n+1):\r\n if i%2==0:\r\n p.append(i)\r\n else:\r\n l.append(i)\r\n o=p+l \r\n print(len(o))\r\n for j in o:\r\n print(j,end=' ')", "\r\nn = int(input())\r\n\r\nif n == 1:\r\n\tprint (1)\r\n\tprint (1)\r\nelif n == 2:\r\n\tprint (1)\r\n\tprint (2)\r\nelif n == 3:\r\n\tprint (2)\r\n\tprint (*[1, 3])\r\nelif n == 4:\r\n\tprint (4)\r\n\tprint (*[3, 1, 4, 2])\r\nelse:\r\n\t\r\n\tL = [0]*n\r\n\t\r\n\ti = 0\r\n\tj = 1\r\n\twhile j <= n:\r\n\t\tL[i] = j\r\n\t\tj += 2\r\n\t\ti += 1\r\n\t\r\n\tj = 2\r\n\twhile j <= n:\r\n\t\tL[i] = j\r\n\t\ti += 1\r\n\t\tj += 2\r\n\t\r\n\tprint (len(L))\r\n\tprint (*L)\r\n", "n = int(input())\r\nif n ==1:\r\n print(1)\r\n print(1)\r\nelse:\r\n odd = [int(k) for k in range(n+1) if k % 2 != 0]\r\n odd.reverse()\r\n even = [int(k) for k in range(1,n+1) if k % 2 == 0]\r\n even.reverse()\r\n odd_len = len(odd)\r\n #even.reverse()\r\n if abs(odd[odd_len-1]-even[0]) == 1:\r\n even = even[1:]\r\n num = odd + even\r\n print(len(num))\r\n num =[str(k) for k in num]\r\n print(\" \".join(num))", "n = int(input())\nif n>3:\n print(n)\n s=[]\n for i in range(1, n+1):\n if i%2 == 0:\n s.append(i)\n for i in range(1, n+1):\n if i%2:\n s.append(i)\n print(*s)\nif n == 3:\n print(2)\n print(1, 3)\nif n == 2:\n print(1)\n print(1)\nif n == 1:\n print(1)\n print(1)", "n = int(input())\r\n\r\nif n < 1:\r\n print('0')\r\nelif n < 3:\r\n print('1')\r\n print('1')\r\nelif n == 3:\r\n print('2')\r\n print('1 3')\r\nelif n == 4:\r\n print('4')\r\n print('2 4 1 3')\r\nelse:\r\n print(n)\r\n print(' '.join((str(int(i//2+1 + (0 if i%2==0 else (n+1)//2))) for i in range(n))))", "N=int(input())\r\nif N<=2:\r\n print('1\\n1')\r\nelif N==3:\r\n print('2\\n1 3')\r\nelif N==4:\r\n print('4\\n2 4 1 3')\r\nelse:\r\n print(N)\r\n for I in range(1,N+1,2):\r\n print(I)\r\n for I in range(2,N+1,2):\r\n print(I)", "entrada = int(input())\n\ndef solve():\n print(entrada)\n arr_a = [0] * entrada\n contador = 1\n \n i = 0\n while i < len(arr_a):\n arr_a[i] = contador\n contador += 1\n i += 2\n \n i = 1\n while i < len(arr_a):\n arr_a[i] = contador\n contador += 1\n i += 2\n \n for a in arr_a:\n print(a, end=' ')\n print()\n\nif entrada == 1 or entrada == 2:\n print(1)\n print(1)\nelif entrada == 3:\n print(2)\n print('1 3')\nelif entrada == 4:\n print(4)\n print('2 4 1 3')\nelse:\n solve()\n \t\t\t\t\t\t\t \t\t \t \t \t\t\t\t\t \t\t\t" ]
{"inputs": ["6", "3", "1", "2", "4", "5", "7", "8", "9", "10", "13", "16", "25", "29", "120", "128", "216", "729", "1111", "1597", "1777", "2048", "2999", "3001", "4181", "4990", "4991", "4992", "4993", "4994", "4995", "4996", "4997", "4998", "4999", "5000"], "outputs": ["6\n5 3 1 6 4 2 ", "2\n1 3", "1\n1 ", "1\n1", "4\n3 1 4 2 ", "5\n5 3 1 4 2 ", "7\n7 5 3 1 6 4 2 ", "8\n7 5 3 1 8 6 4 2 ", "9\n9 7 5 3 1 8 6 4 2 ", "10\n9 7 5 3 1 10 8 6 4 2 ", "13\n13 11 9 7 5 3 1 12 10 8 6 4 2 ", "16\n15 13 11 9 7 5 3 1 16 14 12 10 8 6 4 2 ", "25\n25 23 21 19 17 15 13 11 9 7 5 3 1 24 22 20 18 16 14 12 10 8 6 4 2 ", "29\n29 27 25 23 21 19 17 15 13 11 9 7 5 3 1 28 26 24 22 20 18 16 14 12 10 8 6 4 2 ", "120\n119 117 115 113 111 109 107 105 103 101 99 97 95 93 91 89 87 85 83 81 79 77 75 73 71 69 67 65 63 61 59 57 55 53 51 49 47 45 43 41 39 37 35 33 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1 120 118 116 114 112 110 108 106 104 102 100 98 96 94 92 90 88 86 84 82 80 78 76 74 72 70 68 66 64 62 60 58 56 54 52 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 ", "128\n127 125 123 121 119 117 115 113 111 109 107 105 103 101 99 97 95 93 91 89 87 85 83 81 79 77 75 73 71 69 67 65 63 61 59 57 55 53 51 49 47 45 43 41 39 37 35 33 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1 128 126 124 122 120 118 116 114 112 110 108 106 104 102 100 98 96 94 92 90 88 86 84 82 80 78 76 74 72 70 68 66 64 62 60 58 56 54 52 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 ", "216\n215 213 211 209 207 205 203 201 199 197 195 193 191 189 187 185 183 181 179 177 175 173 171 169 167 165 163 161 159 157 155 153 151 149 147 145 143 141 139 137 135 133 131 129 127 125 123 121 119 117 115 113 111 109 107 105 103 101 99 97 95 93 91 89 87 85 83 81 79 77 75 73 71 69 67 65 63 61 59 57 55 53 51 49 47 45 43 41 39 37 35 33 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1 216 214 212 210 208 206 204 202 200 198 196 194 192 190 188 186 184 182 180 178 176 174 172 170 168 166 164 162 160 158 156 154 1...", "729\n729 727 725 723 721 719 717 715 713 711 709 707 705 703 701 699 697 695 693 691 689 687 685 683 681 679 677 675 673 671 669 667 665 663 661 659 657 655 653 651 649 647 645 643 641 639 637 635 633 631 629 627 625 623 621 619 617 615 613 611 609 607 605 603 601 599 597 595 593 591 589 587 585 583 581 579 577 575 573 571 569 567 565 563 561 559 557 555 553 551 549 547 545 543 541 539 537 535 533 531 529 527 525 523 521 519 517 515 513 511 509 507 505 503 501 499 497 495 493 491 489 487 485 483 481 479 47...", "1111\n1111 1109 1107 1105 1103 1101 1099 1097 1095 1093 1091 1089 1087 1085 1083 1081 1079 1077 1075 1073 1071 1069 1067 1065 1063 1061 1059 1057 1055 1053 1051 1049 1047 1045 1043 1041 1039 1037 1035 1033 1031 1029 1027 1025 1023 1021 1019 1017 1015 1013 1011 1009 1007 1005 1003 1001 999 997 995 993 991 989 987 985 983 981 979 977 975 973 971 969 967 965 963 961 959 957 955 953 951 949 947 945 943 941 939 937 935 933 931 929 927 925 923 921 919 917 915 913 911 909 907 905 903 901 899 897 895 893 891 889 8...", "1597\n1597 1595 1593 1591 1589 1587 1585 1583 1581 1579 1577 1575 1573 1571 1569 1567 1565 1563 1561 1559 1557 1555 1553 1551 1549 1547 1545 1543 1541 1539 1537 1535 1533 1531 1529 1527 1525 1523 1521 1519 1517 1515 1513 1511 1509 1507 1505 1503 1501 1499 1497 1495 1493 1491 1489 1487 1485 1483 1481 1479 1477 1475 1473 1471 1469 1467 1465 1463 1461 1459 1457 1455 1453 1451 1449 1447 1445 1443 1441 1439 1437 1435 1433 1431 1429 1427 1425 1423 1421 1419 1417 1415 1413 1411 1409 1407 1405 1403 1401 1399 1397 ...", "1777\n1777 1775 1773 1771 1769 1767 1765 1763 1761 1759 1757 1755 1753 1751 1749 1747 1745 1743 1741 1739 1737 1735 1733 1731 1729 1727 1725 1723 1721 1719 1717 1715 1713 1711 1709 1707 1705 1703 1701 1699 1697 1695 1693 1691 1689 1687 1685 1683 1681 1679 1677 1675 1673 1671 1669 1667 1665 1663 1661 1659 1657 1655 1653 1651 1649 1647 1645 1643 1641 1639 1637 1635 1633 1631 1629 1627 1625 1623 1621 1619 1617 1615 1613 1611 1609 1607 1605 1603 1601 1599 1597 1595 1593 1591 1589 1587 1585 1583 1581 1579 1577 ...", "2048\n2047 2045 2043 2041 2039 2037 2035 2033 2031 2029 2027 2025 2023 2021 2019 2017 2015 2013 2011 2009 2007 2005 2003 2001 1999 1997 1995 1993 1991 1989 1987 1985 1983 1981 1979 1977 1975 1973 1971 1969 1967 1965 1963 1961 1959 1957 1955 1953 1951 1949 1947 1945 1943 1941 1939 1937 1935 1933 1931 1929 1927 1925 1923 1921 1919 1917 1915 1913 1911 1909 1907 1905 1903 1901 1899 1897 1895 1893 1891 1889 1887 1885 1883 1881 1879 1877 1875 1873 1871 1869 1867 1865 1863 1861 1859 1857 1855 1853 1851 1849 1847 ...", "2999\n2999 2997 2995 2993 2991 2989 2987 2985 2983 2981 2979 2977 2975 2973 2971 2969 2967 2965 2963 2961 2959 2957 2955 2953 2951 2949 2947 2945 2943 2941 2939 2937 2935 2933 2931 2929 2927 2925 2923 2921 2919 2917 2915 2913 2911 2909 2907 2905 2903 2901 2899 2897 2895 2893 2891 2889 2887 2885 2883 2881 2879 2877 2875 2873 2871 2869 2867 2865 2863 2861 2859 2857 2855 2853 2851 2849 2847 2845 2843 2841 2839 2837 2835 2833 2831 2829 2827 2825 2823 2821 2819 2817 2815 2813 2811 2809 2807 2805 2803 2801 2799 ...", "3001\n3001 2999 2997 2995 2993 2991 2989 2987 2985 2983 2981 2979 2977 2975 2973 2971 2969 2967 2965 2963 2961 2959 2957 2955 2953 2951 2949 2947 2945 2943 2941 2939 2937 2935 2933 2931 2929 2927 2925 2923 2921 2919 2917 2915 2913 2911 2909 2907 2905 2903 2901 2899 2897 2895 2893 2891 2889 2887 2885 2883 2881 2879 2877 2875 2873 2871 2869 2867 2865 2863 2861 2859 2857 2855 2853 2851 2849 2847 2845 2843 2841 2839 2837 2835 2833 2831 2829 2827 2825 2823 2821 2819 2817 2815 2813 2811 2809 2807 2805 2803 2801 ...", "4181\n4181 4179 4177 4175 4173 4171 4169 4167 4165 4163 4161 4159 4157 4155 4153 4151 4149 4147 4145 4143 4141 4139 4137 4135 4133 4131 4129 4127 4125 4123 4121 4119 4117 4115 4113 4111 4109 4107 4105 4103 4101 4099 4097 4095 4093 4091 4089 4087 4085 4083 4081 4079 4077 4075 4073 4071 4069 4067 4065 4063 4061 4059 4057 4055 4053 4051 4049 4047 4045 4043 4041 4039 4037 4035 4033 4031 4029 4027 4025 4023 4021 4019 4017 4015 4013 4011 4009 4007 4005 4003 4001 3999 3997 3995 3993 3991 3989 3987 3985 3983 3981 ...", "4990\n4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 4797 4795 4793 4791 4789 ...", "4991\n4991 4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 4797 4795 4793 4791 ...", "4992\n4991 4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 4797 4795 4793 4791 ...", "4993\n4993 4991 4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 4797 4795 4793 ...", "4994\n4993 4991 4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 4797 4795 4793 ...", "4995\n4995 4993 4991 4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 4797 4795 ...", "4996\n4995 4993 4991 4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 4797 4795 ...", "4997\n4997 4995 4993 4991 4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 4797 ...", "4998\n4997 4995 4993 4991 4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 4797 ...", "4999\n4999 4997 4995 4993 4991 4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 ...", "5000\n4999 4997 4995 4993 4991 4989 4987 4985 4983 4981 4979 4977 4975 4973 4971 4969 4967 4965 4963 4961 4959 4957 4955 4953 4951 4949 4947 4945 4943 4941 4939 4937 4935 4933 4931 4929 4927 4925 4923 4921 4919 4917 4915 4913 4911 4909 4907 4905 4903 4901 4899 4897 4895 4893 4891 4889 4887 4885 4883 4881 4879 4877 4875 4873 4871 4869 4867 4865 4863 4861 4859 4857 4855 4853 4851 4849 4847 4845 4843 4841 4839 4837 4835 4833 4831 4829 4827 4825 4823 4821 4819 4817 4815 4813 4811 4809 4807 4805 4803 4801 4799 ..."]}
UNKNOWN
PYTHON3
CODEFORCES
129
e5ab2a069857df3a839cc2a15ef7044f
Divide by Three
A positive integer number *n* is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not. Write a program which for the given *n* will find a beautiful number such that *n* can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number *n*. If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them. The first line of input contains *n* — a positive integer number without leading zeroes (1<=≤<=*n*<=&lt;<=10100000). Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print <=-<=1. Sample Input 1033 10 11 Sample Output 33 0 -1
[ "import re\ns = input()\nt = s.translate(str.maketrans(\"0123456789\", \"0120120120\"))\nx = (t.count('1') + t.count('2') * 2) % 3\nif x:\n res = ['']\n l = t.rsplit(\"12\"[x == 2], 1)\n if len(l) == 2:\n a = len(l[0])\n res.append((s[:a], s[a + 1:]))\n l = t.rsplit(\"12\"[x == 1], 2)\n if len(l) == 3:\n a, b = map(len, l[:2])\n res.append((s[:a], s[a + 1:a + b + 1], s[a + b + 2:]))\n s = max((re.sub(r'^0*(\\d)', r'\\1', ''.join(e)) for e in res), key=len)\nprint(s or '-1')", "n = list(input())\nleng = 0\nmp=[0,0,0]\nfor x in n:\n\tleng += 1\n\tmp[int(x)%3]+=1\ntot = (mp[1]+2*mp[2])%3\nif tot == 0:\n\tprint(\"\".join(n))\n\texit()\nif mp[tot] == 0:\n\tdo = tot ^ 3\n\tcnt = 2\nelse:\n\tif mp[tot] == 1 and int(n[0])%3==tot and n[1:3] == ['0','0']:\n\t\tdo =tot^3\n\t\tcnt = 2\n\t\tif mp[do] == 0:\n\t\t\tdo = tot\n\t\t\tcnt = 1\n\telse:\n\t\tdo = tot\n\t\tcnt =1\nindex = leng-1\nif cnt>=leng:\n\tprint(-1)\n\texit()\nfor x in range(cnt):\n\twhile int(n[index])%3 != do:\n\t\tindex-=1\n\tn[index] = \"\"\n\tindex -=1\n\nindex = 0\nans = \"\".join(n)\nwhile ans[index] == '0' and index<leng-cnt-1:\n\tindex+=1\nprint(ans[index:])\n", "def erase(s, n, m):\r\n p='147' if n==1 else '258'\r\n if sum(s.count(c) for c in p)<m:\r\n return []\r\n t=list(reversed(s))\r\n for c in p:\r\n while t.count(c)>0 and m>0:\r\n t.remove(c)\r\n m-=1\r\n while len(t)>1 and t[-1]=='0':\r\n t.pop()\r\n return list(reversed(t))\r\n\r\ndef solve():\r\n s=list(input())\r\n n=sum(int(c) for c in s)%3\r\n if n==0:\r\n a=b=s\r\n if n==1:\r\n a=erase(s, 1, 1)\r\n b=erase(s, 2, 2)\r\n if n==2:\r\n a=erase(s, 2, 1)\r\n b=erase(s, 1, 2)\r\n s=max(a, b, key=len)\r\n return '-1' if s==[] else s\r\n\r\nprint(*solve(), sep='')", "import re\r\nf = lambda t: re.sub(r'^0+(\\d)', r'\\1', t)\r\ng = lambda k: n - p.index(s, k)\r\n\r\nt = input()\r\nn = len(t) - 1\r\np = [int(q) % 3 for q in t][::-1]\r\ns = sum(p) % 3\r\n\r\nif s == 0:\r\n print(t)\r\n exit()\r\n\r\nu = v = ''\r\nif s in p:\r\n i = g(0)\r\n u = f(t[:i] + t[i + 1:])\r\n\r\ns = 3 - s\r\nif p.count(s) > 1:\r\n i = g(0)\r\n j = g(n - i + 1)\r\n v = f(t[:j] + t[j + 1:i] + t[i + 1:])\r\n\r\nt = u if len(u) > len(v) else v\r\nprint(t if t else -1)", "#Bhargey Mehta (Sophomore)\r\n#DA-IICT, Gandhinagar\r\nimport sys, math, queue\r\nsys.setrecursionlimit(1000000)\r\n#sys.stdin = open(\"input.txt\", \"r\")\r\n\r\ndef removeZeros(x):\r\n i = 0\r\n while i < len(x) and x[i] == 0:\r\n i += 1\r\n return x[i:]\r\n\r\nn = input()\r\nd = list(map(int, list(n)))\r\ns = sum(d)\r\nif s%3 == 0:\r\n print(n)\r\n exit()\r\n\r\nr = [[], [], []]\r\nfor i in range(len(d)):\r\n r[d[i]%3].append(i)\r\n\r\nif s%3 == 1:\r\n a1 = []\r\n a2 = []\r\n if len(r[1]) >= 1:\r\n for i in range(len(d)):\r\n if i != r[1][-1]:\r\n a1.append(d[i])\r\n a1 = removeZeros(a1)\r\n\r\n if len(r[2]) >= 2:\r\n for i in range(len(d)):\r\n if i != r[2][-1] and i != r[2][-2]:\r\n a2.append(d[i])\r\n a2 = removeZeros(a2)\r\n if len(a1) == 0 and len(a2) == 0:\r\n for i in range(len(d)):\r\n if d[i] == 0:\r\n print(0)\r\n exit()\r\n print(-1)\r\n exit()\r\n else:\r\n if len(a1) > len(a2):\r\n for i in range(len(a1)):\r\n print(a1[i], end=\"\")\r\n exit()\r\n else:\r\n for i in range(len(a2)):\r\n print(a2[i], end=\"\")\r\n exit()\r\nelse:\r\n a1 = []\r\n a2 = []\r\n if len(r[2]) >= 1:\r\n for i in range(len(d)):\r\n if i != r[2][-1]:\r\n a1.append(d[i])\r\n a1 = removeZeros(a1)\r\n\r\n if len(r[1]) >= 2:\r\n for i in range(len(d)):\r\n if i != r[1][-1] and i != r[1][-2]:\r\n a2.append(d[i])\r\n a2 = removeZeros(a2)\r\n if len(a1) == 0 and len(a2) == 0:\r\n for i in range(len(d)):\r\n if d[i] == 0:\r\n print(0)\r\n exit()\r\n print(-1)\r\n exit()\r\n else:\r\n if len(a1) > len(a2):\r\n for i in range(len(a1)):\r\n print(a1[i], end=\"\")\r\n exit()\r\n else:\r\n for i in range(len(a2)):\r\n print(a2[i], end=\"\")\r\n exit()\r\n\r\n", "#import sys\r\n#sys.stdin = open('in', 'r')\r\n#n = int(input())\r\n#a = [int(x) for x in input().split()]\r\n#n,m = map(int, input().split())\r\na = [int(x) for x in input()]\r\nn = len(a)\r\nrem = sum(a) % 3\r\na1 = a[:]\r\nr1 = rem\r\ni = n-1\r\nwhile r1 > 0 and i >= 0:\r\n if a1[i] % 3 == 2:\r\n if r1 == 1:\r\n a1[i] = -1\r\n r1 = 2\r\n else:\r\n a1[i] = -1\r\n r1 = 0\r\n i-=1\r\n\r\ncb = n + 1\r\nab = []\r\nif r1 == 0:\r\n c1 = 0\r\n i = 0\r\n while i < n and (a1[i] == -1 or a1[i] == 0):\r\n c1 += 1\r\n i += 1\r\n while i < n:\r\n c1 += 1 if a1[i] == -1 else 0\r\n i += 1\r\n cb = c1\r\n ab = a1\r\n\r\na2 = a[:]\r\nr2 = rem\r\ni = n-1\r\nwhile r2 > 0 and i >= 0:\r\n if a2[i] % 3 == 1:\r\n a2[i] = -1\r\n r2 -= 1\r\n i-=1\r\nif r2 == 0:\r\n c1 = 0\r\n i = 0\r\n while i < n and (a2[i] == -1 or a2[i] == 0):\r\n c1 += 1\r\n i += 1\r\n while i < n:\r\n c1 += 1 if a2[i] == -1 else 0\r\n i += 1\r\n if c1 < cb:\r\n cb = c1\r\n ab = a2\r\n\r\na3 = a[:]\r\nr3 = rem\r\ni = n-1\r\nwhile r3 > 0 and i >= 0:\r\n d1 = 1\r\n d2 = 2\r\n if a3[i] % 3 == 1 and d1 > 0:\r\n a3[i] = -1\r\n r3 -= 1\r\n if a3[i] % 3 == 2 and d2 > 0:\r\n if r3 == 1:\r\n a3[i] = -1\r\n r3 = 2\r\n else:\r\n a3[i] = -1\r\n r3 = 0\r\n i-=1\r\n\r\nif r3 == 0:\r\n c1 = 0\r\n i = 0\r\n while i < n and (a3[i] == -1 or a3[i] == 0):\r\n c1 += 1\r\n i += 1\r\n while i < n:\r\n c1 += 1 if a3[i] == -1 else 0\r\n i += 1\r\n if c1 < cb:\r\n cb = c1\r\n ab = a3\r\n\r\nif cb == n + 1:\r\n print(-1)\r\nelse:\r\n i = 0\r\n while i < n and (ab[i] == 0 or ab[i] == -1):\r\n i += 1\r\n if i == n:\r\n print(0 if sum(ab) != -n else -1)\r\n else:\r\n while i < n:\r\n if ab[i] != -1:\r\n print(ab[i], end='')\r\n i += 1\r\n", "def sumstr(s):\n\tsums = 0\n\tfor i in range(len(s)):\n\t\tsums += int(s[i])\n\treturn sums\n\t\ndef mod3(s):\n\tsums = sumstr(s)\n\treturn sums % 3\n\ndef onlyzeros(s):\n\ti = 0\n\twhile i < len(s):\n\t\tif s[i] != '0':\n\t\t\treturn False\n\t\ti += 1\n\treturn True\n\ndef lastin(s, s1):\n\tmaxf = -1\n\t#d = '-'\n\tfor d in s1:\n\t\tf = s.rfind(d)\n\t\t#print(d, f, maxf)\n\t\tif f > maxf:\n\t\t\tmaxf = f\n\treturn maxf\n\ndef del1(s, s1):\n\tif s[0] == '-':\n\t\treturn '-'\n\tmaxf = lastin(s, s1)\n\t#print('lastfin', maxf)\n\tif maxf != -1:\n\t\t#found digit\n\t\tif maxf != 0:\n\t\t\t#not first or can del first\n\t\t\tret = s[:maxf]\n\t\t\tif maxf + 1 < len(s):\n\t\t\t\tret = ret + s[maxf + 1:]\n\t\t\treturn ret\n\t\telif len(s) > 1 and s[1] != '0':\n\t\t\treturn s[1:]\n\t\telif len(s) == 1:\n\t\t\treturn '-'\n\t\telse:\n\t\t\tind = 1\n\t\t\twhile ind < len(s) and s[ind] == '0':\n\t\t\t\tind += 1\n\t\t\tif ind == len(s):\n\t\t\t\treturn '0'\n\t\t\telse:\n\t\t\t\treturn s[ind:]\n\telse:\n\t\treturn '-'\n\ndef only0(s):\n\tif '0' in s:\n\t\treturn '0'\n\telse:\n\t\treturn '-'\n\t\t\n\nfrom random import randint\n\ndef testing():\n\ts = input()\n\t#n = randint(0, 10000000000000000)\n\t#n = 0\n\t#s = str(n)\n\t#print(s, mod3(s))\n\n\tm3 = mod3(s)\n\tif m3 == 0:\n\t\tprint(s)\n\telif m3 == 1:\n\t\tvar1 = del1(s, '147')\n\t\tvar2 = del1(del1(s, '258'), '258')\n\t\tvar3 = only0(s)\n\t\tl1 = len(var1)\n\t\tl2 = len(var2)\n\t\tif l1 > l2:\n\t\t\t#not -\n\t\t\t#print('v1')\n\t\t\tprint(var1)\n\t\telif l2 > l1:\n\t\t\t#print('v2')\n\t\t\tprint(var2)\n\t\telse:\n\t\t\t#eq\n\t\t\tif var1[0] != '-':\n\t\t\t\tprint(var1)\n\t\t\telif var2[0] != '-':\n\t\t\t\tprint(var2)\n\t\t\telif var3[0] != '-':\n\t\t\t\tprint(var3)\n\t\t\telse:\n\t\t\t\tprint(-1)\n\t\t\n\telif m3 == 2:\n\t\tvar1 = del1(s, '258')\n\t\tvar2 = del1(del1(s, '147'), '147')\n\t\tvar3 = only0(s)\n\t\tl1 = len(var1)\n\t\tl2 = len(var2)\n\t\tif l1 > l2:\n\t\t\t#not -\n\t\t\tprint(var1)\n\t\t\t#print('v1')\n\t\telif l2 > l1:\n\t\t\tprint(var2)\n\t\t\t#print('v2')\n\t\telse:\n\t\t\t#eq\n\t\t\tif var1[0] != '-':\n\t\t\t\tprint(var1)\n\t\t\telif var2[0] != '-':\n\t\t\t\tprint(var2)\n\t\t\telif var3[0] != '-':\n\t\t\t\tprint(var3)\n\t\t\telse:\n\t\t\t\tprint(-1)\n\t#print('\\n\\n')\n\n\nfor i in range(1):\n\ttesting()\n", "s = str(input())\r\ns = [int(c) for c in s]\r\n\r\nn = len(s)\r\n\r\nINF = 10**18\r\ndp = [[[-INF]*2 for i in range(3)] for i in range(n+1)]\r\npre = {}\r\ndp[0][0][0] = 0\r\nfor i in range(n):\r\n c = s[i]\r\n for j in range(3):\r\n for k in range(2):\r\n if dp[i+1][j][k] < dp[i][j][k]:\r\n dp[i+1][j][k] = dp[i][j][k]\r\n pre[(i+1, j, k)] = (i, j, k, 0)\r\n for j in range(3):\r\n if c != 0:\r\n nj = (j+c)%3\r\n if dp[i][j][0] >= 0:\r\n if dp[i+1][nj][1] < dp[i][j][0]+1:\r\n dp[i+1][nj][1] = dp[i][j][0]+1\r\n pre[(i+1, nj, k)] = (i, j, 0, 1)\r\n if dp[i][j][1] >= 0:\r\n if dp[i+1][nj][1] < dp[i][j][1]+1:\r\n dp[i+1][nj][1] = dp[i][j][1]+1\r\n pre[(i+1, nj, k)] = (i, j, 1, 1)\r\n else:\r\n nj = (j+c)%3\r\n if dp[i][j][1] >= 0:\r\n if dp[i+1][nj][1] < dp[i][j][1]+1:\r\n dp[i+1][nj][1] = dp[i][j][1]+1\r\n pre[(i+1, nj, k)] = (i, j, 1, 1)\r\nif dp[n][0][1] < 0:\r\n for c in s:\r\n if c == 0:\r\n print(0)\r\n break\r\n else:\r\n print(-1)\r\n exit()\r\nans = []\r\ni = n\r\nj = 0\r\nk = 1\r\nwhile i > 0 or j > 0 or k > 0:\r\n pi, pj, pk, flag = pre[(i, j, k)]\r\n if flag:\r\n ans.append(s[pi])\r\n i, j, k = pi, pj, pk\r\nans.reverse()\r\nans = [str(c) for c in ans]\r\nprint(''.join(ans))\r\n", "def find(s):\r\n if len(s)==1:\r\n if int(s)%3==0:\r\n return s\r\n return -1\r\n \r\n \r\n digit=[[] for i in range(3)]\r\n zeros=[]\r\n for i in range(len(s)):\r\n digit[int(s[i])%3]+=[i]\r\n if s[i]==\"0\":\r\n zeros+=[i]\r\n total=(len(digit[1])*1+len(digit[2])*2)%3\r\n if total==0:\r\n return s\r\n if total==1:\r\n ##delete one 1\r\n ##delete two 2\r\n s1=\"\"\r\n if len(digit[1])>=1:\r\n p1=digit[1][-1]\r\n s1=s[:p1]+s[p1+1:]\r\n last_pos=len(s1)\r\n for i in range(len(s1)):\r\n if s1[i]!=\"0\":\r\n last_pos=i\r\n break\r\n if last_pos<len(s1):\r\n s1=s1[last_pos:]\r\n else:\r\n if len(s1)>0:\r\n if s1[-1]==\"0\":\r\n s1=\"0\"\r\n\r\n\r\n \r\n s2=\"\"\r\n if len(digit[2])>=2:\r\n p1=digit[2][-2]\r\n p2=digit[2][-1]\r\n s2=s[:p1]+s[p1+1:p2]+s[p2+1:]\r\n last_pos=len(s2)\r\n for i in range(len(s2)):\r\n if s2[i]!=\"0\":\r\n last_pos=i\r\n break\r\n if last_pos<len(s2):\r\n s2=s2[last_pos:]\r\n else:\r\n if len(s2)>0:\r\n if s2[-1]==\"0\":\r\n s2=\"0\"\r\n\r\n if s1==\"\" and s2==\"\":\r\n return -1\r\n elif s1==\"\":\r\n return s2\r\n elif s2==\"\":\r\n return s1\r\n else:\r\n if len(s1)>len(s2):\r\n return s1\r\n return s2\r\n \r\n \r\n \r\n if total==2:\r\n ##delete one 1\r\n ##delete two 2\r\n digit[1],digit[2]=digit[2],digit[1]\r\n ##delete one 1\r\n ##delete two 2\r\n s1=\"\"\r\n if len(digit[1])>=1:\r\n p1=digit[1][-1]\r\n s1=s[:p1]+s[p1+1:]\r\n last_pos=len(s1)\r\n for i in range(len(s1)):\r\n if s1[i]!=\"0\":\r\n last_pos=i\r\n break\r\n if last_pos<len(s1):\r\n s1=s1[last_pos:]\r\n else:\r\n if len(s1)>0:\r\n\r\n if s1[-1]==\"0\":\r\n s1=\"0\"\r\n\r\n\r\n \r\n s2=\"\"\r\n if len(digit[2])>=2:\r\n p1=digit[2][-2]\r\n p2=digit[2][-1]\r\n s2=s[:p1]+s[p1+1:p2]+s[p2+1:]\r\n last_pos=len(s2)\r\n for i in range(len(s2)):\r\n if s2[i]!=\"0\":\r\n last_pos=i\r\n break\r\n if last_pos<len(s2):\r\n s2=s2[last_pos:]\r\n else:\r\n if len(s2)>0:\r\n if s2[-1]==\"0\":\r\n s2=\"0\"\r\n \r\n if s1==\"\" and s2==\"\":\r\n return -1\r\n elif s1==\"\":\r\n return s2\r\n elif s2==\"\":\r\n return s1\r\n else:\r\n if len(s1)>len(s2):\r\n return s1\r\n return s2\r\n \r\n \r\n \r\n \r\nprint(find(input()))\r\n \r\n ", "def erase(s, n, m):\r\n p = '147' if n == 1 else '258'\r\n if sum(s.count(c) for c in p) < m:\r\n return []\r\n t = list(reversed(s))\r\n for c in p:\r\n while t.count(c) > 0 and m > 0:\r\n t.remove(c)\r\n m -= 1\r\n while len(t) > 1 and t[-1] == '0':\r\n t.pop()\r\n return list(reversed(t))\r\n\r\n\r\ndef solve(s):\r\n n = sum(int(c) for c in s) % 3\r\n if n == 0:\r\n a = b = s\r\n if n == 1:\r\n a = erase(s, 1, 1)\r\n b = erase(s, 2, 2)\r\n if n == 2:\r\n a = erase(s, 2, 1)\r\n b = erase(s, 1, 2)\r\n s = max(a, b, key=len)\r\n return '-1' if s == [] else s\r\n\r\n\r\ndef divide_by_three(s):\r\n return solve(s)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n s = list(input())\r\n result = divide_by_three(s)\r\n print(*result, sep='')\r\n", "n = input()\r\n\r\ndef remove(s, mod):\r\n for i in range(len(s)-1, -1, -1):\r\n if int(s[i]) % 3 == mod:\r\n return s[:i] + s[i+1:]\r\n return s\r\n\r\ndef check(s):\r\n return -1 if not s or int(s) % 3 else int(s)\r\n\r\nls = [n, x:=remove(n, 1), remove(x, 1), y:=remove(n, 2), remove(y, 2)]\r\nprint(max(map(check, ls)))", "def f(t):\r\n i, n = 0, len(t) - 1\r\n while i < n and t[i] == '0': i += 1\r\n return t[i:]\r\nt = input()\r\nn = len(t) - 1\r\np = [int(q) % 3 for q in t][::-1]\r\ns = sum(p) % 3\r\nif s == 0:\r\n print(t)\r\n exit()\r\nu = v = ''\r\nif s in p:\r\n i = n - p.index(s)\r\n u = f(t[:i] + t[i + 1:])\r\ns = 3 - s\r\nif p.count(s) > 1:\r\n i = n - p.index(s)\r\n j = n - p.index(s, n - i + 1)\r\n v = f(t[:j] + t[j + 1:i] + t[i + 1:])\r\nt = u if len(u) > len(v) else v\r\nprint(t if t else -1)", "#!/usr/bin/env python3\n\n# solution after hint:(\n\nsn = input().strip()\nn = len(sn)\n\ndef rem3(sn):\n\treturn sum(map(int, sn)) % 3\n\ndef buildn(sn, com, start=0):\n\treturn ''.join(sn[start + i] for i in com)\n\ndef subminbeau2(sn, start=0):\n\tn = len(sn)\n\tr3 = rem3(sn[start:])\n\tsn3 = ''.join(str(int(c) % 3) for c in sn)\n\tnums3 = set(sn3[1 + start:])\n\tif r3 == 0:\n\t\treturn (0, sn[start:])\n\telif str(r3) in nums3:\n\t\tp1 = sn3.find(str(r3), start + 1)\n\t\treturn (1, sn[start:p1] + sn[p1 + 1:])\n\telif sn3[1 + start:].count(str(3 - r3)) >= 2:\n\t\tp1 = sn3.find(str(3 - r3), start + 1)\n\t\tp2 = sn3.find(str(3 - r3), p1 + 1)\n\t\treturn (2, sn[start:p1] + sn[p1 + 1:p2] + sn[p2 + 1:])\n\telse:\n\t\treturn (-1, None)\n\t\t\t\t\ndef minbeau(sn):\n\tn = len(sn)\n\tnnzs = [i for i, c in enumerate(sn) if (c != '0')]\n\tres = (n, '')\n\tfor i in nnzs[:3]:\n\t\t(td, d3n) = subminbeau2(sn, i)\n\t\tif td >= 0:\n\t\t\tres = min(res, (i + td, d3n))\n\tif res[0] < n:\n\t\treturn res[1]\n\telif '0' in sn:\n\t\treturn '0'\n\telse:\n\t\treturn '-1'\n\nprint (minbeau(sn))\n", "\ns = input()\n\ndef rm(s,m):\n if s == None or len(s) == 1:\n return None\n i = len(s) - 1\n while i >= 0:\n if int(s[i]) % 3 == m:\n break\n i -= 1\n\n if i == -1:\n return None\n else:\n if i == 0:\n k = i+1\n while k < len(s) and s[k] == \"0\":\n k += 1\n if k == len(s):\n return \"0\"\n else:\n return s[k:]\n elif i == len(s)-1:\n return s[:i]\n else:\n return s[:i] + s[i+1:]\n\n\ndef ans(s):\n s_sum = 0\n i = 0\n while i<len(s):\n s_sum += int(s[i])\n s_sum = s_sum % 3\n i += 1\n\n if s_sum == 0:\n return s\n elif s_sum == 1:\n s1 = rm(s,1)\n s2 = rm(rm(s,2),2)\n if s1 == None and s2 == None:\n return -1\n elif s1 == None:\n return s2\n elif s2 == None:\n return s1\n else:\n if len(s1) > len(s2):\n return s1\n else:\n return s2\n elif s_sum == 2:\n s1 = rm(s,2)\n s2 = rm(rm(s,1),1)\n if s1 == None and s2 == None:\n return -1\n elif s1 == None:\n return s2\n elif s2 == None:\n return s1\n else:\n if len(s1) > len(s2):\n return s1\n else:\n return s2\n\n\nt = ans(s)\nif t == None:\n print(-1)\nelse:\n print(t)\n\n", "def erase(s, n, m):\r\n p='147' if n==1 else '258'\r\n if sum(s.count(c) for c in p)<m:\r\n return []\r\n t=list(reversed(s))\r\n for c in p:\r\n while t.count(c)>0 and m>0:\r\n t.remove(c)\r\n m-=1\r\n while len(t)>1 and t[-1]=='0':\r\n t.pop()\r\n return list(reversed(t))\r\n\r\ndef solve():\r\n s=list(input())\r\n n=sum(int(c) for c in s)\r\n if n%3==0:\r\n c=s\r\n if n%3==1:\r\n a=erase(s, 1, 1)\r\n b=erase(s, 2, 2)\r\n c=a if len(a)>len(b) else b\r\n if n%3==2:\r\n a=erase(s, 2, 1)\r\n b=erase(s, 1, 2)\r\n c=a if len(a)>len(b) else b\r\n return '-1' if c==[] else c\r\n\r\nprint(*solve(), sep='')", "import sys\r\n\r\nn = list(input(\"\"))\r\nl = [int(c)%3 for c in n][::-1]\r\nd = sum(l)%3\r\n\r\nif (len(n) == 1):\r\n\tif (n == ['3']):\r\n\t\tprint(3)\r\n\telse:\r\n\t\tprint(-1)\r\n\tsys.exit(0)\r\n\r\ndef li(x):\r\n\tglobal n\r\n\tdel n[len(n)-1-l.index(x)]\r\n\tdel l[l.index(x)]\r\n\r\ndef cond(x):\r\n\tx = x.lstrip('0')\r\n\tif (len(x) == 0): return \"0\"\r\n\treturn x\r\n\r\nif (d == 0):\r\n\tpass\r\nelif (d in l):\r\n\tif (l.index(d) == len(l)-1 and int(n[1])==0 and l.count(3-d) >= 2):\r\n\t\tli(3-d); li(3-d)\r\n\telse:\r\n\t\tli(d)\r\nelse:\r\n\tli(3-d); li(3-d)\r\n\r\nif (len(n) > 0):\r\n\tq=cond(\"\".join(n))\r\n\tprint(q)\r\nelse:\r\n\tprint(-1)\r\n\r\n", "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 remove_rem(a,rem,cout):\r\n temp=list(a)\r\n i=len(temp)-1\r\n cc=0\r\n #print(1)\r\n while(i>=0 and cc<cout):\r\n if(int(temp[i]))%3==rem:\r\n cc+=1\r\n temp=temp[:i]+temp[i+1:]\r\n i-=1\r\n if(cc!=cout):\r\n return \"\"\r\n while(len(temp)>1 and temp[0]=='0'):\r\n temp=temp[1:]\r\n return \"\".join(temp)\r\ndef hnbhai(tc):\r\n s=sa()\r\n b=list(map(int,list(s)))\r\n rem=sum(b)%3\r\n #print(1)\r\n if(rem==0):\r\n print(s)\r\n return\r\n x=remove_rem(s,rem,1)\r\n y=remove_rem(s,3-rem,2)\r\n if(len(x)==0 and len(y)==0):\r\n print(-1)\r\n return\r\n elif len(x)>len(y):\r\n print(x)\r\n return\r\n print(y)\r\n \r\nfor _ in range(1):\r\n hnbhai(_+1)\r\n", "import sys\r\n#import random\r\nfrom bisect import bisect_right as rb\r\nfrom collections import deque\r\n#sys.setrecursionlimit(10**8)\r\nfrom queue import PriorityQueue\r\nfrom math import *\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\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\nmod = 10**9 + 7\r\n\r\ndef tot(n,rem,c) :\r\n cnt = 0\r\n i = len(n) - 1\r\n s = n\r\n\r\n while ((i>=0) and cnt < c) :\r\n if int(s[i])%3 == rem :\r\n cnt += 1\r\n s = s[:i] + s[i+1:]\r\n i-=1\r\n\r\n if (cnt!=c) :\r\n return \"\"\r\n\r\n while (len(s) > 1 and s[0] == '0') :\r\n s = s[1:]\r\n\r\n return s\r\n\r\nn = ip()\r\n\r\na = 0\r\nn1 = list(n)\r\n\r\nfor i in n1 :\r\n a += int(i)\r\n a %= 3\r\n\r\nif (a == 0) :\r\n print(n)\r\n exit(0)\r\n\r\nx1 = tot(n,3-a,2)\r\nx2 = tot(n,a,1)\r\n\r\nif (len(x1) == 0 and len(x2) == 0) :\r\n print(-1)\r\nelif (len(x1)>len(x2)) :\r\n print(x1)\r\nelse :\r\n print(x2)\r\n\r\n\r\n", "from copy import deepcopy\r\nw = input()\r\na = [int(c) for c in w]\r\nsm = sum(a)\r\n\r\ndef process_res():\r\n if (len(a) == 0):\r\n return \"\"\r\n else:\r\n res = \"\"\r\n non_zero = False\r\n for n in range(len(a)):\r\n if not non_zero and n == len(a) - 1 and a[n] == 0:\r\n res += \"0\"\r\n break\r\n if not non_zero and a[n] != 0:\r\n non_zero = True\r\n res += str(a[n])\r\n elif non_zero:\r\n res += str(a[n])\r\n return res\r\n \r\nif sm % 3 == 0:\r\n print(w)\r\nelse:\r\n res1 = ''\r\n if (sm % 3 == 1):\r\n n1 = 1\r\n n2 = 2\r\n else:\r\n n1 = 2\r\n n2 = 1\r\n for i in range(len(a) - 1, -1, -1):\r\n if a[i] % 3 == n1:\r\n b = deepcopy(a)\r\n a.pop(i)\r\n res1 = process_res()\r\n a = deepcopy(b)\r\n break\r\n\r\n cnt = 0\r\n frst = None\r\n res2 = ''\r\n for i in range(len(a) - 1, -1, -1):\r\n if a[i] % 3 == n2:\r\n cnt += 1\r\n if (cnt == 2):\r\n b = deepcopy(a)\r\n a.pop(max(i, frst))\r\n a.pop(min(i, frst))\r\n res2 = process_res()\r\n a = deepcopy(b)\r\n break \r\n elif cnt == 1:\r\n frst = i\r\n if (res1 == '' and res2 == ''):\r\n print(-1)\r\n else:\r\n if (len(res1) > len(res2)):\r\n print(res1)\r\n else:\r\n print(res2)\r\n \r\n\r\n \r\n \r\n", "n = input()\r\ndef rm(s, mod):\r\n for i in range(len(s) - 1, -1, -1):\r\n if int(s[i]) % 3 == mod:\r\n return s[:i] + s[i + 1:]\r\n return s\r\ndef S(s):\r\n if not s or int(s) % 3:\r\n return -1\r\n else:\r\n return int(s)\r\na = (n, rm(n, 1), rm(rm(n, 1), 1), rm(n, 2), rm(rm(n, 2), 2))\r\nprint(max(map(S, a)))", "import sys\r\nfrom itertools import compress\r\n\r\ns = input()\r\nn = len(s)\r\nmod = [0]*n\r\nfor i, x in enumerate(map(int, s)):\r\n mod[i] = x % 3\r\n\r\ntotal_mod = sum(mod) % 3\r\n\r\n\r\ndef remove_zeros(a):\r\n for i in range(n):\r\n if not a[i]:\r\n continue\r\n if s[i] == '0':\r\n a[i] = 0\r\n else:\r\n return\r\n\r\n\r\nif total_mod == 0:\r\n a = [1]*n\r\n remove_zeros(a)\r\n ans = ''.join(compress(s, a))\r\n if ans:\r\n print(ans)\r\n else:\r\n print(0 if '0' in s else -1)\r\nelse:\r\n ans1, ans2 = '', ''\r\n\r\n for i in range(n-1, -1, -1):\r\n if mod[i] == total_mod:\r\n a = [1]*n\r\n a[i] = 0\r\n remove_zeros(a)\r\n ans1 = ''.join(compress(s, a))\r\n break\r\n\r\n rem = 2\r\n a = [1]*n\r\n for i in range(n-1, -1, -1):\r\n if mod[i] == 3 - total_mod:\r\n a[i] = 0\r\n rem -= 1\r\n if rem == 0:\r\n remove_zeros(a)\r\n ans2 = ''.join(compress(s, a))\r\n break\r\n\r\n ans = ans1 if len(ans1) > len(ans2) else ans2\r\n if ans:\r\n print(ans)\r\n else:\r\n print(0 if '0' in s else -1)\r\n" ]
{"inputs": ["1033", "10", "11", "3", "1", "117", "518", "327", "270461", "609209", "110930", "37616145150713688775", "98509135612114839419", "41674994051436988162", "82547062721736129804", "4902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814", "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122", "5388306043547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157", "20000111", "100222", "202", "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033", "101", "1000000222", "1001", "205", "102211", "100000002022", "20203", "1002001", "10002223", "1002223", "100000231", "220", "322", "100000222", "10033", "2003302", "10011001", "20000000011001111", "100000000", "1000", "200000000000000000000000000008", "1000000000000222", "100000000000000000222", "29512", "88888888888888", "100000000000222", "11000000", "2200", "10000555", "1000222", "10021", "223", "1013", "100020001", "20000000000000000000932", "1010", "2000000002222", "10213", "109111", "1010101010", "300055", "200200", "202222", "4000888", "200000111", "2000000111", "1000000", "1003301", "100001", "40000000000000000000888", "100000", "4000000888", "334733", "1000002220", "100321", "101111", "100000000222", "10001", "7", "2000000000111", "100000001", "10000000000222", "200000000000000111", "404044", "30202", "20000000000000000111", "707", "20000300000000003000050000003", "400000888", "2888", "200111", "10000000888", "40000888", "40404044", "5500000000", "100012", "1000007", "200093", "10000000222", "20000000002", "74333", "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008", "10000000111", "100007", "20000006711", "8059", "8008", "88", "2002", "2000111", "100000000100000002", "1000000000000000000000000000000000", "10000000000000000222", "1000001", "200000000000111", "2000000002", "2010000100001", "200330", "10000222", "2005", "100000000000822", "10000000000000000000000", "7046", "4000117", "971", "404", "5", "164", "140", "74", "2058232", "4", "20206", "103310", "100", "417179", "70558", "298", "7003", "2212", "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", "2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002", "1002200", "1222", "101200100", "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003", "20020201", "12122", "20200", "2", "1000000000000258"], "outputs": ["33", "0", "-1", "3", "-1", "117", "18", "327", "70461", "60909", "930", "3616145150713688775", "9509135612114839419", "1674994051436988162", "82547062721736129804", "490501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814", "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122", "538830603547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157", "200001", "1002", "0", "33", "0", "10000002", "0", "0", "10221", "1000000002", "3", "100200", "100023", "10023", "10000023", "0", "3", "1000002", "33", "330", "1001001", "200000000001111", "0", "0", "0", "10000000000002", "1000000000000000002", "2952", "888888888888", "1000000000002", "0", "0", "100005", "10002", "1002", "3", "3", "10002000", "93", "0", "20000000022", "1023", "10911", "10001010", "3000", "0", "2022", "40008", "2000001", "20000001", "0", "330", "0", "400000000000000000008", "0", "40000008", "3333", "10000020", "10032", "1011", "1000000002", "0", "-1", "20000000001", "0", "100000000002", "2000000000000001", "40044", "300", "200000000000000001", "0", "30000000000300000000003", "4000008", "888", "2001", "100000008", "400008", "400044", "0", "10002", "0", "93", "100000002", "0", "333", "0", "1000000011", "0", "200000061", "9", "0", "-1", "0", "20001", "10000000000000002", "0", "100000000000000002", "0", "2000000000001", "0", "10000100001", "330", "100002", "0", "1000000000002", "0", "6", "400017", "9", "0", "-1", "6", "0", "-1", "20232", "-1", "6", "330", "0", "7179", "558", "9", "3", "222", "0", "0", "100200", "222", "10100100", "3", "2002020", "1122", "0", "-1", "10000000000008"]}
UNKNOWN
PYTHON3
CODEFORCES
21
e5c1492df82be26090ac459cf081f0c9
Covered Points Count
You are given $n$ segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide. Your task is the following: for every $k \in [1..n]$, calculate the number of points with integer coordinates such that the number of segments that cover these points equals $k$. A segment with endpoints $l_i$ and $r_i$ covers point $x$ if and only if $l_i \le x \le r_i$. The first line of the input contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of segments. The next $n$ lines contain segments. The $i$-th line contains a pair of integers $l_i, r_i$ ($0 \le l_i \le r_i \le 10^{18}$) — the endpoints of the $i$-th segment. Print $n$ space separated integers $cnt_1, cnt_2, \dots, cnt_n$, where $cnt_i$ is equal to the number of points such that the number of segments that cover these points equals to $i$. Sample Input 3 0 3 1 3 3 8 3 1 3 2 4 5 7 Sample Output 6 2 1 5 2 0
[ "import collections\r\n\r\nif __name__ == '__main__':\r\n n = int(input())\r\n ans = collections.defaultdict(int)\r\n for i in range(n):\r\n l, r = list(map(int, input().strip().split()))\r\n ans[l] += 1; ans[r + 1] -= 1\r\n ans = dict(sorted(ans.items(), key=lambda k: k[0]))\r\n keys = list(ans.keys())\r\n tot = len(keys)\r\n for i in range(1, tot):\r\n ans[keys[i]] += ans[keys[i - 1]]\r\n res = [0] * (n + 1)\r\n for i in range(tot - 1):\r\n res[ans[keys[i]]] += keys[i + 1] - keys[i]\r\n for i in range(1, n):\r\n print(res[i], end=\" \")\r\n print(res[n])", "import sys\r\nfrom array import array\r\n\r\ninput = lambda: sys.stdin.buffer.readline().decode().strip()\r\ninp = lambda dtype: [dtype(x) for x in input().split()]\r\ndebug = lambda *x: print(*x, file=sys.stderr)\r\nceil_ = lambda a, b: (a + b - 1) // b\r\nsum_n = lambda n: (n * (n + 1)) // 2\r\nget_bit = lambda x, i: (x >> i) & 1\r\nMint, Mlong, out = 2 ** 31 - 1, 2 ** 63 - 1, []\r\n\r\nfor _ in range(1):\r\n # 0->open , 1->close\r\n n = int(input())\r\n points, type_ = [], array('b')\r\n\r\n for i in range(n):\r\n l, r = inp(int)\r\n points.extend([l, r])\r\n type_.extend([1, 0])\r\n\r\n ixs = sorted(range(n * 2), key=points.__getitem__)\r\n ans, open = [0] * (n + 1), 0\r\n i = 0\r\n\r\n while i < n * 2:\r\n old, new, isfirst = 0, 0, 1\r\n if open:\r\n ans[open] += points[ixs[i]] - points[ixs[i - 1]] - 1\r\n\r\n while i < n * 2 and (isfirst or points[ixs[i]] == points[ixs[i - 1]]):\r\n new += type_[ixs[i]]\r\n old += type_[ixs[i]] ^ 1\r\n i += 1\r\n isfirst = 0\r\n\r\n ans[new + open] += 1\r\n open = open - old + new\r\n\r\n out.append(' '.join(map(str, ans[1:])))\r\nprint('\\n'.join(map(str, out)))\r\n", "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\nimport math\r\nfrom heapq import heappush , heappop\r\nfrom collections import defaultdict,deque,Counter\r\n \r\nN = int(input())\r\nA = []\r\nfor _ in range(N):\r\n l,r = map(int, input().split())\r\n A.append((l,1))\r\n A.append((r+1,-1))\r\n\r\nlib = defaultdict(int)\r\nA.sort()\r\ncur = 0\r\nfor i,c in A:\r\n if c==1:\r\n cur+=1\r\n else:\r\n cur-=1\r\n lib[i]=cur\r\n \r\nB = []\r\nfor k,v in lib.items():\r\n B.append((k,v))\r\nB.sort()\r\n\r\nprei,prec = A[0][0],A[0][1]\r\nans = [0]*(N+1)\r\nfor i,c in B:\r\n if prec==c:continue\r\n ans[prec]+=i-prei\r\n prei = i\r\n prec = c\r\nprint(*ans[1:])\r\n \r\n", "n = int(input())\r\nsl = []\r\nfor i in range(n):\r\n l, r = map(int, input().split())\r\n sl.append([l, 1])\r\n sl.append([r + 1, -1])\r\nsl.sort()\r\nans = [0] * (n + 1)\r\nbal = 0\r\nfor i in range(len(sl) - 1):\r\n bal += sl[i][1]\r\n ans[bal] += sl[i + 1][0] - sl[i][0]\r\nprint(*ans[1::])\r\n", "n = int(input())\r\nscanline = []\r\nfor _ in range(n):\r\n l, r = map(int, input().split())\r\n scanline.append((l, 0))\r\n scanline.append((r + 1, 1))\r\nscanline.sort()\r\n\r\ncover = 0\r\nres = [0] * (n + 1)\r\nls = 0\r\n\r\nfor x, tp in scanline:\r\n res[cover] += x - ls\r\n if tp == 0:\r\n cover += 1\r\n else:\r\n cover -= 1\r\n ls = x\r\nprint(*res[1:])\r\n", "from collections import defaultdict\r\n\r\ndef solve():\r\n n = int(input())\r\n\r\n seg = defaultdict(int)\r\n for i in range(n):\r\n l, r = map(int, input().split())\r\n seg[l] += 1; seg[r + 1] -= 1\r\n\r\n ans = [0] * (n + 1)\r\n\r\n layer = 0; pre_coord = 0\r\n for coord, cnt in sorted(seg.items()):\r\n ans[layer] += coord - pre_coord\r\n layer += cnt\r\n pre_coord = coord\r\n\r\n print(*ans[1:])\r\n\r\nsolve()", "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\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\nmod = 1000000007\r\n# print(\"Case #\"+str(_+1)+\":\",)\r\n\r\nfrom collections import Counter,defaultdict,deque\r\n#from heapq import heappush,heappop,heapify\r\nimport sys\r\nimport math\r\nimport bisect\r\n\r\nfor _ in range(1):\r\n n = int(input())\r\n h = []\r\n for i in range(n):\r\n l,r = map(int,input().split())\r\n h.append([l,1])\r\n h.append([r+1,-1])\r\n h.sort()\r\n a = set(); b = defaultdict(lambda:0)\r\n for i in range(2*n):\r\n a.add(h[i][0])\r\n b[h[i][0]]+=h[i][-1]\r\n a = list(a)\r\n a.sort()\r\n c = [] ; s = 0\r\n for i in b:\r\n s += b[i]\r\n c.append(s)\r\n d = defaultdict(lambda:0)\r\n #print(c)\r\n #print(a)\r\n for i in range(len(c)-1):\r\n d[c[i]] += a[i+1]-a[i]\r\n for i in range(1,n+1):\r\n print(d[i],end=' ')\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n", "import collections\r\n\r\nif __name__ == '__main__':\r\n n = int(input())\r\n a = collections.defaultdict(int)\r\n\r\n # O(n) loop\r\n for _ in range(n):\r\n start, end = [int(x) for x in input().split()]\r\n a[start] += 1\r\n a[end + 1] -= 1\r\n # print(a)\r\n\r\n # takes n*long(n) for sorting\r\n key_points = sorted(a.keys())\r\n # print(key_points)\r\n\r\n # prefix sum s\r\n s = collections.defaultdict(int)\r\n i, prev = 0, 0\r\n # O(n) loop\r\n for p in key_points:\r\n if i == 0:\r\n s[p] = a[p]\r\n else:\r\n s[p] = prev + a[p]\r\n prev = s[p]\r\n i += 1\r\n # print(s)\r\n\r\n # python dict maintain insert order, in this case key already order\r\n cnt = collections.defaultdict(int)\r\n i, prev_k, prev_v = 0, 0, 0\r\n for k, v in s.items():\r\n if i > 0:\r\n cnt[prev_v] += k - prev_k\r\n prev_k, prev_v = k, v\r\n i += 1\r\n # print(cnt)\r\n\r\n for i in range(1, n + 1):\r\n print(cnt[i], end=\" \")\r\n", "import bisect\r\n\r\nintervals = []\r\n\r\nunique_coordinates = set()\r\nfor _ in range(int(input())):\r\n left, right = map(int, input().split())\r\n intervals.append((left, right))\r\n unique_coordinates.add(left)\r\n unique_coordinates.add(right)\r\n unique_coordinates.add(right + 1)\r\n\r\ncompressed = sorted(unique_coordinates)\r\n\r\np_sum = [0] * (len(compressed) + 1)\r\n\r\nfor left, right in intervals:\r\n p_sum[bisect.bisect_left(compressed, left)] += 1\r\n p_sum[bisect.bisect_left(compressed, right) + 1] -= 1\r\n\r\nfor i in range(1, len(p_sum)):\r\n p_sum[i] += p_sum[i - 1]\r\n\r\nfreq_of = [0] * (len(intervals) + 1)\r\n\r\ncomp_i = 0\r\nwhile comp_i < len(compressed) - 1:\r\n left_comp_i = comp_i\r\n while comp_i + 1 < len(compressed) and p_sum[comp_i + 1] == p_sum[comp_i]:\r\n comp_i += 1\r\n width = compressed[comp_i + 1] - compressed[left_comp_i]\r\n freq_of[p_sum[left_comp_i]] += width\r\n comp_i += 1\r\n\r\nprint(*freq_of[1:])\r\n", "import sys\r\nfrom collections import defaultdict\r\ninput = sys.stdin.readline \r\n\r\nn = int(input()) \r\nd = defaultdict(int)\r\nans = [0] * (n + 1)\r\nfor i in range(n):\r\n l ,r = map(int, input().split())\r\n d[l] += 1 \r\n d[r + 1] -= 1\r\ns = p = 0 \r\nfor k in sorted(d):\r\n ans[s] += k - p \r\n s += d[k] \r\n p = k \r\n\r\nprint(*ans[1:])", "import collections\r\n\r\n\r\ndef work():\r\n sums = collections.defaultdict(int)\r\n i, prev = 0, 0\r\n for p in key_points:\r\n if i == 0:\r\n sums[p] = points[p]\r\n else:\r\n sums[p] = prev + points[p]\r\n prev = sums[p]\r\n i += 1\r\n\r\n cnt = collections.defaultdict(int)\r\n i, prev_k, prev_v = 0, 0, 0\r\n for k, v in sums.items():\r\n if i > 0:\r\n cnt[prev_v] += k - prev_k\r\n prev_k, prev_v = k, v\r\n i += 1\r\n\r\n for i in range(1, n + 1):\r\n print(cnt[i], end=\" \")\r\n\r\n\r\nif __name__ == '__main__':\r\n n = int(input())\r\n points = collections.defaultdict(int)\r\n\r\n for _ in range(n):\r\n start, end = [int(x) for x in input().split()]\r\n points[start] += 1\r\n points[end + 1] -= 1\r\n\r\n key_points = sorted(points.keys())\r\n work()\r\n" ]
{"inputs": ["3\n0 3\n1 3\n3 8", "3\n1 3\n2 4\n5 7", "1\n0 1000000000000000000"], "outputs": ["6 2 1 ", "5 2 0 ", "1000000000000000001 "]}
UNKNOWN
PYTHON3
CODEFORCES
11
e5d95d51685545ecb2cbc871cbfe17da
Too Easy Problems
You are preparing for an exam on scheduling theory. The exam will last for exactly *T* milliseconds and will consist of *n* problems. You can either solve problem *i* in exactly *t**i* milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either. Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer *a**i* to every problem *i* meaning that the problem *i* can bring you a point to the final score only in case you have solved no more than *a**i* problems overall (including problem *i*). Formally, suppose you solve problems *p*1,<=*p*2,<=...,<=*p**k* during the exam. Then, your final score *s* will be equal to the number of values of *j* between 1 and *k* such that *k*<=≤<=*a**p**j*. You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do. The first line contains two integers *n* and *T* (1<=≤<=*n*<=≤<=2·105; 1<=≤<=*T*<=≤<=109) — the number of problems in the exam and the length of the exam in milliseconds, respectively. Each of the next *n* lines contains two integers *a**i* and *t**i* (1<=≤<=*a**i*<=≤<=*n*; 1<=≤<=*t**i*<=≤<=104). The problems are numbered from 1 to *n*. In the first line, output a single integer *s* — your maximum possible final score. In the second line, output a single integer *k* (0<=≤<=*k*<=≤<=*n*) — the number of problems you should solve. In the third line, output *k* distinct integers *p*1,<=*p*2,<=...,<=*p**k* (1<=≤<=*p**i*<=≤<=*n*) — the indexes of problems you should solve, in any order. If there are several optimal sets of problems, you may output any of them. Sample Input 5 300 3 100 4 150 4 80 2 90 2 300 2 100 1 787 2 788 2 100 2 42 2 58 Sample Output 2 3 3 1 4 0 0 2 2 1 2
[ "import sys\r\nimport math\r\nfrom collections import defaultdict,deque\r\nimport heapq\r\ndef search(arr,points,t):\r\n l=[]\r\n n=len(arr)\r\n cnt=0\r\n for i in range(n):\r\n if arr[i][0]>=points:\r\n l.append(arr[i][1])\r\n cnt+=1\r\n if cnt>=points:\r\n l.sort()\r\n #print(l,'l')\r\n if sum(l[:points])<=t:\r\n return True\r\n return False\r\ndef get(arr,points):\r\n n=len(arr)\r\n l=[]\r\n for i in range(n):\r\n if arr[i][0]>=points:\r\n l.append([arr[i][1],arr[i][2]+1])\r\n l.sort()\r\n #print(l,'get')\r\n res=[]\r\n for i in range(points):\r\n res.append(l[i][1])\r\n return res\r\nn,t=map(int,sys.stdin.readline().split())\r\ndic=defaultdict(int)\r\narr=[]\r\nfor i in range(n):\r\n a,b=map(int,sys.stdin.readline().split())\r\n arr.append([a,b,i])\r\nlow,high=0,n\r\nans=0\r\nwhile low<=high:\r\n mid=(low+high)//2\r\n if search(arr,mid,t):\r\n ans=max(ans,mid)\r\n low=mid+1\r\n else:\r\n high=mid-1\r\n#print(ans)\r\nif ans==0:\r\n print(0)\r\n print(0)\r\n print('')\r\n sys.exit()\r\nl=get(arr,ans)\r\nprint(len(l))\r\nprint(len(l))\r\nprint(*l)\r\n\r\n", "from collections import deque\r\nimport heapq\r\nimport sys\r\n\r\n\r\ndef input():\r\n return sys.stdin.readline().rstrip()\r\n\r\n\r\nn, T = map(int, input().split())\r\nproblems = [tuple(map(int, input().split())) for i in range(n)]\r\n\r\n\r\ndef possible(K):\r\n d = []\r\n for a, t in problems:\r\n if a >= K:\r\n d.append(t)\r\n d.sort()\r\n if len(d) < K:\r\n return False\r\n else:\r\n return sum(d[:K]) <= T\r\n\r\n\r\nl = 0\r\nr = n + 1\r\nwhile r - l > 1:\r\n med = (r + l)//2\r\n if possible(med):\r\n l = med\r\n else:\r\n r = med\r\nprint(l)\r\nprint(l)\r\nd = []\r\nfor i, (a, t) in enumerate(problems):\r\n if a >= l:\r\n d.append((t, i+1))\r\nd.sort(key=lambda x: x[0])\r\nans = [v[1] for v in d[:l]]\r\nprint(*ans)\r\n", "from sys import stdin, stdout\r\n \r\ndef check(k, b, T):\r\n\tc = [e for e in b if e[0] >= k]\r\n \r\n\tif len(c) < k:\r\n\t\treturn False, None\r\n \r\n\tfirst_k_probs = c[:k]\r\n\ts = sum([e[1] for e in first_k_probs])\r\n \r\n\tif s > T:\r\n\t\treturn False, None\r\n \r\n\treturn True, first_k_probs\r\n \r\n \r\ndef solve(n, T, a, t):\r\n\tb = []\r\n \r\n\tfor i in range(n):\r\n\t\tb.append((a[i], t[i], i + 1))\r\n \r\n\tb.sort(key=lambda x: x[1])\r\n \r\n\tlow, high = 0, n\r\n\tresult = 0\r\n\tfinal_probs = []\r\n \r\n\twhile low <= high:\r\n\t\tmid = (low + high) // 2\r\n \r\n\t\t(possible, probs) = check(mid, b, T)\r\n\t\tif possible:\r\n\t\t\tresult, final_probs = mid, probs\r\n\t\t\tlow = mid + 1\r\n\t\telse:\r\n\t\t\thigh = mid - 1\r\n \r\n\treturn (result, [e[2] for e in final_probs])\r\n \r\n \r\nn, T = (int(x) for x in stdin.readline().split())\r\n \r\na = [0] * n\r\nt = [0] * n\r\n \r\nfor i in range(n):\r\n\ta[i], t[i] = (int(x) for x in stdin.readline().split())\r\n \r\npoint, probs = solve(n, T, a, t)\r\nstdout.write(\"%s\\n\" % point)\r\nstdout.write(\"%s\\n\" % len(probs))\r\nif len(probs) > 0:\r\n\tstdout.write(\"%s\\n\" % \" \".join([str(x) for x in probs]))" ]
{"inputs": ["5 300\n3 100\n4 150\n4 80\n2 90\n2 300", "2 100\n1 787\n2 788", "2 100\n2 42\n2 58", "1 1\n1 1", "10 481\n4 25\n3 85\n6 96\n6 13\n1 9\n4 27\n2 7\n3 42\n9 66\n9 70", "1 1000000000\n1 10000", "1 1\n1 10000", "5 66\n2 64\n4 91\n5 91\n1 79\n3 85", "1 1000000000\n1 1", "5 100\n1 10\n1 10\n1 10\n1 10\n1 10"], "outputs": ["2\n2\n3 4", "0\n0", "2\n2\n1 2", "1\n1\n1", "4\n4\n4 1 6 9", "1\n1\n1", "0\n0", "1\n1\n1", "1\n1\n1", "1\n1\n1"]}
UNKNOWN
PYTHON3
CODEFORCES
3
e5e6897144e5e79c74783dcb22208415
Binary Protocol
Polycarp has just invented a new binary protocol for data transmission. He is encoding positive integer decimal number to binary string using following algorithm: - Each digit is represented with number of '1' characters equal to the value of that digit (for 0 it is zero ones). - Digits are written one by one in order corresponding to number and separated by single '0' character. Though Polycarp learnt how to encode the numbers, he has no idea how to decode them back. Help him calculate the decoded number. The first line contains one integer number *n* (1<=≤<=*n*<=≤<=89) — length of the string *s*. The second line contains string *s* — sequence of '0' and '1' characters, number in its encoded format. It is guaranteed that the number corresponding to the string is positive and doesn't exceed 109. The string always starts with '1'. Print the decoded number. Sample Input 3 111 9 110011101 Sample Output 3 2031
[ "n = int(input())\r\n# print(n)\r\ns = input()\r\n# print(s)\r\nk = 0\r\nans = ''\r\nfor c in s:\r\n # print(c)\r\n if c == '0':\r\n ans += str(k)\r\n k = 0\r\n else:\r\n k += 1\r\n\r\nprint(ans + str(k))\r\n", "n=int(input())\r\ns=input().strip()\r\nprint(*map(len, s.split('0')), sep='')", "def solve():\r\n n = int(input())\r\n s = input()\r\n k = 0\r\n r = ''\r\n for c in s:\r\n if c == '0':\r\n r += str(k)\r\n k = 0\r\n else:\r\n k += 1\r\n r += str(k)\r\n return r\r\n\r\nprint(solve())", "input()\ncount = 0\nout = ''\nfor l in input():\n if l == '1':\n count +=1\n else:\n out=out+str(count)\n count = 0\nout=out+str(count)\nprint(out)\n", "import sys\nsys.stdin.readline()\nsecond_line = sys.stdin.readline()[:-1]\nnums = second_line.split('0')\nans = ''\nfor num in nums:\n ans +=str(len(num))\nprint(ans)\n", "n = int(input())\r\na = input().split(\"0\")\r\n\r\nfor x in a:\r\n print(x.count(\"1\"),end=\"\")\r\n", "l = int(input())\r\ns = input()\r\ns = s.replace(\"111111111\",\"9\")\r\ns = s.replace(\"11111111\",\"8\")\r\ns = s.replace(\"1111111\",\"7\")\r\ns = s.replace(\"111111\",\"6\")\r\ns = s.replace(\"11111\",\"5\")\r\ns = s.replace(\"1111\",\"4\")\r\ns = s.replace(\"111\",\"3\")\r\ns = s.replace(\"11\",\"2\")\r\nfor i in range(len(s)-1):\r\n s = list(s)\r\n if s[i] == '0' and s[i+1] != \"0\":\r\n s[i] = \"\"\r\nprint(*s,sep = \"\")\r\n", "S = int(input())\ns = input().split('0')\n\nans = ''\nfor c in s:\n ans += str(len(c))\nprint(ans)\n", "n = int(input())\r\ns = input()\r\nresult = ''\r\ncount = 0\r\nfor i in range(n):\r\n if s[i] == '1':\r\n count += 1\r\n else:\r\n result += str(count)\r\n count = 0\r\nresult += str(count)\r\nprint(result)\r\n", "n = int(input())\r\ns = input()\r\ns += \"0\"\r\nq = ''\r\ncount = 0\r\nfor i in range(0, len(s)):\r\n if s[i] == '1':\r\n count += 1\r\n else:\r\n q += str(count)\r\n count = 0\r\nprint(q)\r\n", "n = int(input())\ns = list(input().split('0'))\nt = ''\nfor i in s:\n t += str(len(i))\nprint(t)", "x = int(input())\r\na = input()\r\nl = 0\r\nc = []\r\nv = ''\r\nb = a.split(\"0\")\r\nfor i in b:\r\n g = len(i)\r\n c.append(g)\r\nfor p in c:\r\n v += str(p)\r\nprint(v)\r\n", "def decoder(code):\n\tl = list(code);\n\tnumber = 0\n\tresult = \"\"\n\tflag = 1\n\tfor char in l:\n\t\tif char == \"1\" :\n\t\t\tnumber += 1\n\t\t\tflag = 1\n\t\telif char == \"0\" and flag == 1 :\n\t\t\tresult += str(number)\n\t\t\tflag = 0\n\t\t\tnumber = 0\n\t\telif char == \"0\" and flag == 0 :\n\t\t\tresult += str(\"0\")\n\t\t\tflag = 1\n\tresult += str(number)\n\tprint(result)\nnumber = input()\ncode = input()\ndecoder(code)", "input()\ns=input().split('0')\nmessage=''\nfor word in s:\n message=message+str(len(word))\nprint(message)", "n = int(input())\r\n\r\nnumber = input()\r\n\r\nanswer = \"\"\r\ncount = 0\r\n\r\nfor el in range(n):\r\n if number[el] == \"1\":\r\n count += 1\r\n else:\r\n answer += str(count)\r\n count = 0\r\n\r\nanswer += str(count)\r\nprint(answer)", "from sys import maxsize, stdout, stdin,stderr\r\nmod = int(1e9 + 7)\r\nimport re #can use multiple splits\r\ntup = lambda : map(int,stdin.readline().split())\r\nI = lambda :int(stdin.readline())\r\nlint=lambda : [int(x) for x in stdin.readline().split()]\r\nS = lambda :stdin.readline().replace('\\n','').strip()\r\ndef grid(r, c): return [lint() for i in range(r)]\r\ndef debug(*args, c=6): print('\\033[3{}m'.format(c), *args, '\\033[0m', file=stderr)\r\nfrom math import log2,sqrt\r\nfrom collections import defaultdict\r\nn = I()\r\ns = S()\r\nans = [0]*89 ; c = 0\r\nfor i in s:\r\n if i=='1':\r\n ans[c]+=1\r\n else:\r\n c+=1\r\n ans[c]=0\r\nprint(''.join(map(str,ans[:c+1])))\r\n\r\n\r\n\r\n\r\n\r\n", "input()\nprint(''.join(map(str, map(len, input().split('0')))))\n", "n = int(input())\r\na = input().strip()\r\na = a.split('0')\r\nprint(''.join(str(len(x)) for x in a))", "n = input()\ns = input().split('0')\nprint(\"\".join([str(len(x)) for x in s]))\n \n", "n = int(input())\r\ns = input()\r\n\r\ncount = 0\r\n\r\nfor c in s:\r\n if c == '1':\r\n count += 1\r\n else:\r\n print(count, end='')\r\n count = 0\r\n\r\nprint(count)\r\n", "n = int(input())\r\ns = str(input())\r\n\r\nS = list(s.split('0'))\r\n#print(S)\r\nans = []\r\nfor s in S:\r\n ans.append(str(len(s)))\r\nprint(''.join(ans))\r\n", "n=int(input())\ns=str(input())\nq=\"\"\nr=0\np=[]\nfor i in s:\n if i==\"1\":\n r=r+1\n else:\n p.append(r)\n r=0\np.append(r)\nfor i in p:\n q=q+str(i)\nprint(q)\n\t\t\t \t \t\t\t \t\t\t\t \t\t\t\t\t\t\t\t\t\t\t\t", "comp = int(input())\nmensagem = input()\ncod = 0\n\nfor x in mensagem:\n if x == '1':\n cod += 1\n elif x == '0':\n cod *= 10\nprint(cod)\n\n \t \t \t \t\t \t\t\t\t \t\t \t\t \t \t \t \t", "input()\ns = input()\nl = s.split('0')\nl = [str(len(x)) for x in l]\nans = ''.join(l)\nprint(ans)\n", "n = int(input())\r\ns = input()\r\nd = 0\r\nt = ''\r\nfor i in s:\r\n if i == '1':\r\n d += 1\r\n else:\r\n t = t + str(d)\r\n d = 0\r\nt = t + str(d)\r\nprint(t)", "##n = int(input())\r\n##a = list(map(int, input().split()))\r\n##print(' '.join(map(str, res)))\r\ndef list_input():\r\n return list(map(int, input().split()))\r\n\r\nn = int(input())\r\ns = input()\r\ns += '0'\r\nn += 1\r\n\r\np = 0\r\nres = list()\r\nwhile p < n:\r\n q = p\r\n while q < n and s[q] == '1':\r\n q += 1\r\n x = q-p\r\n if x > 0:\r\n res.append(x) \r\n if p == q:\r\n res.append(0)\r\n p = q+1\r\nprint(''.join(map(str, res)))", "def main():\r\n input()\r\n t = input()\r\n c = 0\r\n ans = 0\r\n for i in t:\r\n if i == '1':\r\n c+=1\r\n else:\r\n ans+=c\r\n ans*= 10\r\n c = 0\r\n ans += c\r\n print(ans)\r\n\r\nmain()", "n = int(input())\r\ns = input()\r\nnum = 0\r\n\r\nfor i in range(n):\r\n if s[i] == '1':\r\n num += 1\r\n else:\r\n print(num, end = '')\r\n num = 0\r\n\r\nprint(num)\r\n", "i=input;i();print(''.join(map(str,map(len,i().split('0')))))", "n = int(input())\r\nline = input() \r\n\r\nans = 0\r\nfor s in line.split(\"0\"):\r\n\tans *= 10\r\n\tans += len(s)\r\n\t\r\nprint(ans)", "input()\nprint(''.join(str(len(i)) for i in input().split('0')))\n", "#ROUNIAAUDI\r\nr=int(input())\r\nstring1=input()\r\nlist1=string1.split(\"0\")\r\n#print(list1)\r\nlist2=[]\r\nfor u in list1:\r\n if u =='':\r\n list2.append(\"0\")\r\n else:\r\n list2.append(str(u.count(\"1\")))\r\nprint(\"\".join(list2))\r\n\r\n\r\n\r\n\r\n\r\n", "input()\r\nprint (''.join([str(len(i)) for i in input().split('0') ] ))\r\n", "n = int(input())\r\nprint(*[len(x) for x in input().split('0')], sep = '')", "input()\r\nprint(''.join(map(str,map(len,input().split('0')))))", "n=int(input())\r\ns=str(input())\r\nans,count=0,0\r\nfor i in range(n):\r\n if s[i]==\"0\":\r\n ans*=10\r\n ans+=count\r\n count=0\r\n else:\r\n count+=1\r\n if i == n - 1:\r\n ans *= 10\r\n ans += count\r\n count = 0\r\nprint(ans)", "n=int(input())\r\nans= 0\r\ns=str(input())\r\nfor i in range(n):\r\n if s[i]=='1' :\r\n ans+=1\r\n if i==n-1:\r\n print(ans,end=\"\")\r\n elif s[i]=='0' :\r\n print(ans,end=\"\")\r\n if i==n-1:\r\n print(\"0\",end=\"\")\r\n ans=0\r\n elif s[i]=='0' and s[i-1]=='0':\r\n print(\"0\",end=\"\")\r\n ans=0\r\n\r\n", "i = int(input())\r\nl = list(map(int,input()))\r\nt = ''\r\nwhile True:\r\n if len(l) == 0 or l.count(0)==0:\r\n t+=str(len(l))\r\n break\r\n t += str(len(l[:l.index(0)]))\r\n l = l[l.index(0)+1:]\r\nprint(t)", "a = input()\r\nb = input().split('0')\r\nans = [0]* len(b)\r\nfor i in range(len(b)):\r\n ans[i] = str(len(b[i]))\r\n\r\nprint(''.join(ans))", "n = input()\ns = input() + '0'\nnum = \"\"\n\nbd = 0\nfor d in s:\n if d == '0':\n num += str(bd)\n bd = 0\n else:\n bd += 1\n\nprint(num)\n", "n = int(input())\r\nencoded_num = input() + \"0\"\r\nnum_of_1s = 0\r\nres = 0\r\nfor char in encoded_num:\r\n if char == '1':\r\n num_of_1s += 1\r\n else:\r\n res = res * 10 + num_of_1s\r\n num_of_1s = 0\r\nprint(res)", "input()\r\ns = input()\r\nres = ''\r\nfor i in s.split('0'):\r\n res += str(len(i))\r\nprint(res)", "result = []\ncount = input()\nlst = input().split(\"0\")\nwhile len(lst):\n result.append(str(len(lst.pop(0))))\nprint(\"\".join(result))", "n = int(input())\r\ns = list(input())\r\na = []\r\nc = 0\r\nfor i in range(n):\r\n if int(s[i]) == 1:\r\n c += 1\r\n elif int(s[i]) == 0:\r\n a.append(c)\r\n c = 0\r\na.append(c)\r\nprint(*a, sep=\"\")\r\n", "class CodeforcesTask825ASolution:\n def __init__(self):\n self.result = ''\n self.encoded = ''\n\n def read_input(self):\n input()\n self.encoded = input()\n\n def process_task(self):\n res = [len(x) for x in self.encoded.split(\"0\")]\n self.result = \"\".join([str(x) for x in res])\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask825ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n", "input()\r\ns=input()\r\nl=s.split('0')\r\nans=''\r\nfor d in l:\r\n ans+=str(len(d))\r\nprint(ans)", "n=int(input())\r\nL=input()\r\nK=[]\r\nm=0\r\nfor h in L:\r\n if h=='1':\r\n m+=1\r\n else:\r\n K.append(m)\r\n m=0\r\nK.append(m)\r\nprint(int(''.join(str(x) for x in K)))\r\n", "input()\r\nprint(*[len(i) for i in input().split('0')], sep='')", "n = int(input())\r\ns = str(input())\r\nans = ''\r\nnum = 0\r\n\r\nfor i in range(n):\r\n if s[i] == '1':\r\n num += 1\r\n if s[i] == '0':\r\n if s[i - 1] == '0':\r\n ans += '0'\r\n else:\r\n ans += str(num)\r\n num = 0\r\n if i == n - 1:\r\n ans += str(num)\r\nprint(ans)", "n=int(input())\r\ns=[int(x) for x in input()]\r\n\r\na=[[]]\r\nfor i in range(len(s)):\r\n\tif(s[i]==0):\r\n\t\ta.append([])\r\n\telse:\r\n\t\ta[-1].append(1)\r\n# print(a)\r\nfor x in a:\r\n\tprint(len(x),end=\"\")\r\nprint()\r\n", "n = int(input())\r\nm = input()\r\nans = ''\r\nk = 0\r\nfor i in range(n):\r\n\tif m[i] == '1':\r\n\t\tk+=1\r\n\telse:\r\n\t\tif k == 0:\r\n\t\t\tans+= '0'\r\n\t\telse:\r\n\t\t\tans+= str(k)\r\n\t\t\tk = 0\r\nans+=str(k)\r\nprint(ans)\r\n\t\r\n", "n=int(input())\r\nnums=input().split(\"0\")\r\nres=[]\r\nfor num in nums:\r\n res.append(str(len(num)))\r\nprint(\"\".join(res))", "n = int(input())\r\nslist = input()\r\nslist += '0'\r\nc = 0\r\nans = ''\r\nfor s in slist:\r\n if s == '0':\r\n ans += str(c)\r\n c = 0\r\n else: c += 1\r\nprint(ans)", "n=int(input())\r\ns=input()\r\nj=0\r\nfor i in range(s.count('0')):\r\n x=0\r\n while s[j]!='0':\r\n x+=1\r\n j+=1\r\n j+=1\r\n print(x,end='')\r\nprint(n-j)\r\n \r\n\r\n \r\n", "input()\r\na=input().split('0')\r\nans=\"\"\r\nfor x in a:\r\n ans+=str(len(x))\r\nprint(ans)\r\n", "input()\r\ny = input().split('0')\r\nfor d in y:\r\n print(len(d), end='')", "n = int(input())\r\nst = input()\r\nout = ''\r\ncurr = 0\r\nfor e in st:\r\n if e == '1':\r\n curr += 1\r\n if e == '0':\r\n out += str(curr)\r\n curr = 0\r\nout += str(curr)\r\nprint(out)\r\n ", "n = int(input())\ns = list(input().split('0'))\nprint(''.join(map(lambda ls: str(len(ls)), s)))\n\n", "input()\r\nprint(*(map(len,input().split(\"0\"))),sep='')\r\n", "n = int(input())\r\ns = input().split('0')\r\n\r\nresult = ''\r\n\r\nfor each in s:\r\n result += str(len(each)) \r\n\r\nprint(result)", "n = input()\nline = input()\nwas = line.split('0')\nfor a in was:\n\tprint(len(a), end='')", "n = int(input())\r\nnumber = []\r\ncount = 0\r\nfor i in input():\r\n i = int(i)\r\n if i == 0:\r\n number.append(str(count))\r\n count = 0\r\n else:\r\n count += 1\r\nnumber.append(str(count))\r\nprint(''.join(number))", "def main():\n n = input()\n coded = input()\n print(''.join([str(len(x)) for x in coded.split(\"0\")]))\n\nif __name__ == '__main__':\n main()\n", "n = int(input())\r\nprint(*map(len,input().split('0')),sep='')", "n=int(input())\nz=input()\ncnt=0\nfor i in z:\n if(i=='0'):\n print(cnt,end=\"\")\n cnt=0\n else:\n cnt+=1\nprint(cnt);", "import sys\r\n\r\nstdin = sys.stdin\r\n\r\nni = lambda: int(ns())\r\nna = lambda: list(map(int, stdin.readline().split()))\r\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\r\n\r\nn = ni()\r\ns = ns()\r\nct = 0\r\nfor i in range(n):\r\n if s[i] == '1':\r\n ct += 1\r\n else:\r\n print(ct, end=\"\")\r\n ct = 0\r\nprint(ct)\r\n", "n = int(input())\r\ns = input()\r\nsol = ''\r\nst = s.split('0')\r\nfor i in st:\r\n sol += str(len(i))\r\nprint(sol)\r\n", "n, a = int(input()), input()[::-1]\no, j = 0, 0\nfor i in range(n):\n\tif a[i]=='0': j+=1\n\telse: o+=(10**j)\nprint(o)", "def mainFunc():\r\n n = int(input())\r\n binaryStr = input()[:n]\r\n binaryArr = []\r\n Str = '1'\r\n flag=True\r\n for i in range(1,n):\r\n if binaryStr[i]=='0':\r\n if flag==False:\r\n Str += binaryStr[i]\r\n else:\r\n binaryArr.append(Str)\r\n Str=binaryStr[i]\r\n flag=False\r\n else:\r\n if flag==True:\r\n Str += binaryStr[i]\r\n else:\r\n binaryArr.append(Str)\r\n Str=binaryStr[i]\r\n flag=True\r\n # if Str!='':\r\n binaryArr.append(Str)\r\n binaryChar=''\r\n for i in range(len(binaryArr)):\r\n if binaryArr[i][0]=='1':\r\n binaryChar += str(len(binaryArr[i]))\r\n else:\r\n if(i!=len(binaryArr)-1):\r\n binaryChar += binaryArr[i][:-1]\r\n else:\r\n binaryChar += binaryArr[i]\r\n print(int(binaryChar))\r\nmainFunc()", "def binarycode(A):\n\tfront=0\n\tend=1\n\tcount=0\n\tres=[]\n\twhile front<len(A) and end<=len(A):\n\t\t\t\t\tif front<len(A) and A[front]==0:\n\t\t\t\t\t\twhile front<len(A) and A[front]==0:\n\t\t\t\t\t\t\tres.append(0)\n\t\t\t\t\t\t\tfront=front +1\n\t\t\t\t\t\tend=front+1\n\t\t\t\t\tif ((end<len(A) and A[end]==0) or end==len(A)) and (front<len(A) and A[front]!=0):\n\t\t\t\t\t\tres.append(end-front)\n\t\t\t\t\t\tfront=end+1\n\t\t\t\t\tend=end+1\n\tif A[len(A)-1]==0:\n\t\tres.append(0)\n\t\t\n\treturn res\nsize=int(input())\n#A=list(int(num) for num in input().strip().split())[:size]\nA=list(map(int,input()))\nres= binarycode(A)\nfor i in res:\n\t\tprint(i,end=\"\")\n\t\t", "import math\r\nimport operator\r\nn = int(input())\r\ns = input()\r\na = \"\"\r\ndem = 1\r\nfor i in range(1,n):\r\n if s[i] == '1':\r\n dem += 1\r\n else:\r\n if s[i-1] == '1':\r\n a = a + str(dem)\r\n dem = 0\r\n else:\r\n a = a + '0'\r\na = a + str(dem)\r\nprint(a)\r\n\r\n \r\n\r\n\r\n ", "n = input()\r\ns = input()\r\n\r\nfor item in s.split('0'):\r\n item = item.strip()\r\n if not len(item):\r\n print('0', end='')\r\n else:\r\n print(len(item), end='')\r\n", "input()\r\ns=input().split('0')\r\nprint(''.join(map(str, map(len, s))))\r\n", "n = int(input())\nx = input().split('0')\nout = []\nfor d in x:\n out.append(str(len(d)))\nprint(''.join(out))", "num = input()\r\nstring = input()+'0'\r\noutput = \"\"\r\ncount = 0\r\nfor i in string:\r\n if i == '1':\r\n count += 1\r\n if i == '0':\r\n output += str(count)\r\n count = 0\r\nprint(output)\r\n", "while True:\n try:\n x=input()\n a=input()\n b=0\n for i in a:\n if i=='1':\n b+=1\n else:\n print(b,end='')\n b=0\n print(b)\n except EOFError:\n break", "def main():\n input()\n s = input()\n out = []\n cur = 0\n prev = '-'\n for c in s:\n if c == '0' and prev == '0':\n out.append(0)\n continue\n elif c == '0':\n out.append(cur)\n cur = 0\n else:\n cur += 1\n\n prev = c\n out.append(cur)\n print(''.join(str(x) for x in out))\n\nmain()\n", "n=int(input())\r\ns=input()\r\nk=0\r\nr=\"\"\r\nfor i in s:\r\n if i==\"1\":\r\n k+=1\r\n if i==\"0\":\r\n r+=str(k)\r\n k=0\r\nr+=str(k)\r\nprint(r)\r\n ", "input()\r\nprint(*map(len, input().split('0')), sep='')", "n = int(input())\n\ns = input()\n\ndigit = 0\nfor c in s:\n if c == '1':\n digit += 1\n else:\n print(digit, end='')\n digit = 0\nprint(digit)\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\ns = input() + \"0\"\r\nans = []\r\ntmp = 0\r\nfor i in range(n + 1):\r\n if s[i] == \"1\":\r\n tmp += 1\r\n else:\r\n ans.append(str(tmp))\r\n tmp = 0\r\nprint(\"\".join(ans))", "a=int(input())\r\ns=input()\r\nar=[]\r\nsu=0\r\nfor i in s:\r\n if i=='1':\r\n su+=1\r\n elif i=='0':\r\n ar.append(su)\r\n su=0\r\nar.append(su)\r\nfor i in (ar):\r\n print(i,end='')\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\ns = [\"0\"] + list(input().rstrip()) + [\"0\"]\r\nans = []\r\nwhile len(s) > 1:\r\n s.pop()\r\n c = 0\r\n while s[-1] == \"1\":\r\n s.pop()\r\n c += 1\r\n ans.append(str(c))\r\nans = \"\".join(reversed(ans))\r\nprint(ans)", "import math\r\ndef reversed_string(a_string):\r\n return a_string[::-1]\r\n\r\ndigits = input()\r\nstring = input()\r\na = []\r\nb = []\r\nfloatingNumber = \"\"\r\n\r\na = string.split(\"0\")\r\nfor item in a:\r\n\tb.append(item)\r\n\r\nfor item in b:\r\n\tfloatingNumber = str(len(item)) + floatingNumber\r\n\r\nprint(reversed_string(floatingNumber))", "n=int(input())\r\ns=input()\r\nj=-1\r\nfor i in range(n):\r\n if s[i]=='0':\r\n print(i-j-1,end='')\r\n j=i\r\nprint(n-j-1)", "n=int(input())\r\ns=input()\r\nr=''\r\nc=0\r\nfor i in s:\r\n if(i=='1'):\r\n c=c+1\r\n else:\r\n r=r+str(c)\r\n c=0\r\nr=r+str(c)\r\nprint(r)", "input()\r\nprint(''.join(str(len(d)) for d in input().split('0')))\r\n", "n = input()\r\nres = ''.join([str(len(i)) for i in input().split('0')])\r\nprint(res, end = \"\")", "n=int(input())\r\na=[int(x) for x in input()]\r\nres=[]\r\nr=0\r\nfor i in range(n):\r\n r+=a[i]\r\n if a[i]==0:\r\n res.append(r)\r\n r=0\r\nres.append(r)\r\nfor i in range(len(res)):\r\n print(res[i],end='')", "input()\r\nprint(''.join(list(map(str, map(len, input().split('0'))))))\r\n", "input();print(''.join([str(len(i)) for i in str.split(input(), \"0\")]))\n", "n = int(input())\r\na = input()\r\nkek = ''\r\ns = 0\r\nfor i in a:\r\n if i == '0':\r\n kek += str(s)\r\n s = 0\r\n else: s += 1\r\nelse: kek += str(s)\r\nprint(kek)\r\n", "n = int(input())\r\ns = list(input())\r\nans = [0] * (s.count('0') + 1)\r\nraz = 0\r\nans1 = ''\r\nfor i in range(len(s)):\r\n if int(s[i]) == 1:\r\n ans[raz] += 1\r\n else:\r\n raz += 1\r\nfor i in range(len(ans)):\r\n ans1 += str(ans[i])\r\nprint(ans1)", "n = int(input())\r\nx = input().split('0')\r\nfor i in x:\r\n print(len(i),end=\"\")\r\n", "n = int(input())\r\ns = input()\r\n\r\na = 0\r\nans = ''\r\n\r\nfor c in s:\r\n if c == '1':\r\n a += 1\r\n else:\r\n ans += str(a)\r\n a = 0\r\n\r\nans += str(a)\r\nprint(ans)", "n = int(input())\r\ns = input() + '0'\r\nans = ''\r\nc = 0\r\nfor i in s:\r\n if i == '0':\r\n ans += str(c)\r\n c = 0\r\n else:\r\n c += 1\r\nprint(ans)", "n = int(input())\r\nl = list(input())\r\n\r\nprev = ''\r\nval = 0\r\nstring = ''\r\nfor i,e in enumerate(l):\r\n \r\n if e == '1':\r\n val += 1\r\n \r\n elif prev == '1' and e == '0':\r\n string += str(val)\r\n val = 0\r\n\r\n elif prev == '0' and e == '0':\r\n string += '0'\r\n\r\n prev = e\r\n \r\n\r\nstring += str(val)\r\nprint(string)", "input()\r\nans=\"\"\r\nfor s in input().split(\"0\"):\r\n ans+=str(len(s))\r\nprint(ans)\r\n", "input()\r\ns = input()\r\nprint(''.join(str(i.count('1')) for i in s.split('0')))\r\n", "n=input()\r\ns=input().split('0')\r\nprint(''.join(map(str,map(len,s))))\r\n", "n = int(input())\r\ns = [len(st) for st in input().split('0')]\r\nprint(\"\".join(str(x) for x in s))", "(lambda _, s: print(''.join(map(str, map(len, s.split('0'))))))(input(), input())", "n = int(input())\r\ns = input()\r\nl = s.split('0')\r\nif s == '0':\r\n print(0)\r\nelse:\r\n for i in l:\r\n if i == '':\r\n print(0, end = \"\")\r\n else:\r\n print(len(i), end = \"\")\r\n", "s = input()\r\nb = input()\r\nt = 0\r\nfor i in b:\r\n pos = ord(i)\r\n if pos == ord(\"0\") and pos-1 != ord(\"0\"):\r\n print(str(t),end='',flush=True)\r\n t=0\r\n elif pos == ord(\"1\"):\r\n t+= 1\r\n else:\r\n print(str(t),end ='',flush=True)\r\nprint(str(t))", "s=input()\r\na=list(input())\r\na+=['0']\r\nb=''\r\nc=''\r\nif a[:-1].count('0')==0:\r\n print(s)\r\nelse:\r\n while len(a)>0:\r\n b=a[:a.index('0')]\r\n c+=b.count('0')*'0'+str(len(b)-b.count('0'))\r\n a=a[a.index('0')+1:]\r\n print(c)", "n = int(input())\r\ns = input()\r\n\r\na = [0]\r\nfor i in range(n):\r\n if s[i] == '1':\r\n a[-1] += 1\r\n else:\r\n a.append(0)\r\n\r\nprint(''.join([str(i) for i in a]))\r\n", "import sys\n\ninput()\ns = input().split('0')\n\ndef main(argv):\n ans = 0\n for c in s:\n # print('print do tamanho de ' + s + str(len(s)))\n ans *= 10\n ans += len(c)\n print(ans)\nif __name__ == \"__main__\":\n main(sys.argv)\n", "n, c, v = int(input()), 0, 0\r\nfor ch in input():\r\n if ch == '0':\r\n c, v = 0, 10 * v + c\r\n else:\r\n c += 1\r\nprint(10 * v + c)", "n, t = input(), 0\nfor c in input():\n if c == '0':\n t *= 10\n else:\n t += 1\nprint(t)\n", "a=int(input())\r\nb=input()\r\nc=0\r\nif b.count(\"0\")==0:\r\n print(a)\r\n exit(0)\r\nwhile b.count(\"0\")>0:\r\n c+=b.index(\"0\")*10**(b.count(\"0\"))\r\n b=b[b.index(\"0\")+1:]\r\nc+=len(b)\r\nprint(c)", "input()\nprint(''.join([str(len(i)) for i in input().strip().split('0')]))\n", "# cook your dish here\r\nt=int(input())\r\ns=input()\r\ns=s.split(\"0\")\r\nans=\"\"\r\nfor i in s:\r\n ans=ans+str(len(i))\r\nprint(ans)", "n = int(input())\r\ns = input() + \"0\"\r\nt = \"\"\r\ntmp = 0\r\nfor i in s:\r\n if i == \"1\":\r\n tmp += 1\r\n else:\r\n t += str(tmp)\r\n tmp = 0\r\nprint(t)", "input()\r\ns = input().split('0')\r\nprint(''.join([str(len(i)) for i in s]))", "def main():\r\n\tinput()\r\n\ts = input()\r\n\tfor i in s.split('0'):\r\n\t\tprint(len(i), end='')\r\n\r\nif __name__ == '__main__':\r\n\tmain()", "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\r\ndef decode(encoded_string):\r\n\r\n decoded_string = []\r\n\r\n counter = 0\r\n for char in encoded_string:\r\n\r\n if char == \"1\":\r\n counter = counter + 1\r\n elif char == \"0\":\r\n decoded_string.append(str(counter))\r\n counter = 0\r\n\r\n # Add any leftover strings\r\n decoded_string.append(str(counter))\r\n\r\n return \"\".join(decoded_string)\r\n\r\n\r\nstr_length = inp()\r\nencoded_string = insr()\r\nresult = decode(encoded_string)\r\nprint(result)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n = int(input())\r\nst = input()\r\n\r\nans = []\r\nnum = 0\r\nfor i in range(n):\r\n\tif st[i] == '1':\r\n\t\tnum += 1\r\n\telse:\r\n\t\tans.append(num)\r\n\t\tnum = 0\r\n\r\nans.append(num)\r\n\r\nprint(*ans, sep = '')\r\n", "n = int(input())\r\nstring = input()\r\nnum = 0\r\nk = 0\r\n\r\nfor i in range(n):\r\n if int(string[i])==1: k+=1\r\n else:\r\n num = num*10 + k\r\n k = 0\r\nnum = num*10 + k\r\n \r\nprint(num)", "n = int(input())\r\ns = input()\r\nk1, k0 = 0, 0\r\na = 0\r\nfor i in range(n):\r\n\tif s[i] == '0':\r\n\t\ta = a * 10 + k1\r\n\t\tk1 = 0\r\n\telse:\r\n\t\tk1 += 1\r\nelse:\r\n\ta = a * 10 + k1\r\nprint(a)", "input()\r\nfor i in input().split(\"0\"):print(len(i),end=\"\")", "n = int(input())\r\ns = input()\r\nc = 0\r\nans = \"\"\r\nfor i in range(n):\r\n\tif (s[i] == '1'):\r\n\t\tc += 1\r\n\telse:\r\n\t\tans += str(c)\r\n\t\tc = 0\r\nprint (ans + str(c))\r\n", "# Rating: 1100, https://codeforces.com/contest/825/problem/A\n\nn = int(input())\ndata = input().strip()\n\ncount_seq_1 = 0\n\nans = \"\"\n\nfor i in range(n):\n if data[i] == \"1\":\n count_seq_1 += 1\n else:\n ans += str(count_seq_1)\n count_seq_1 = 0\n\nans += str(count_seq_1)\n\nprint(ans)", "n=int(input())\r\ns=str(input())\r\nl=s.split('0')\r\ne=''\r\nfor i in range(0,len(l)):\r\n e=e+str(len(l[i]))\r\nprint(e)", "input()\r\n\r\nk = 0\r\nfor c in input():\r\n if c == '1':\r\n k += 1\r\n else:\r\n print(k, end = '')\r\n k = 0\r\n\r\nprint(k)", "n = input()\nstring = input()\nans = string.split('0')\nres = 0\nfor item in ans:\n\tres *= 10\n\tres += item.count('1')\nprint (res)", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\ns = input()[:-1]\r\nc, x = 0, 0\r\nd = ''\r\nfor i in range(n):\r\n if s[i] == '1':\r\n c += 1\r\n x = 0\r\n else:\r\n if x == 0:\r\n d += str(c)\r\n c = 0\r\n else:\r\n d += '0'\r\n x = 1\r\nd += str(c)\r\nprint(d)", "input()\r\nans = ''\r\nfor st in input().split('0'):\r\n ans += str(st.count('1'))\r\nprint(ans)\r\n", "#!/usr/bin/env python3\n\ninput()\nprint(''.join(list(map(lambda x: str(len(x)), input().split('0')))))\n", "def solve(s):\r\n ans=0\r\n tmp=0\r\n fn=\"\"\r\n for i in s:\r\n if i=='1':\r\n ans+=1\r\n else:\r\n fn+=str(ans)\r\n ans=0\r\n tmp = ans\r\n fn+=str(ans)\r\n return fn\r\n\r\nn=input()\r\ns=input()\r\nprint(solve(s))\r\n\r\n", "n=int(input())\r\nls=list(map(int,list(input())))\r\nlz=[]\r\ncnt=0\r\ng=False\r\nfor i in ls:\r\n if i==1:\r\n cnt+=1\r\n g=False\r\n else:\r\n if g==False:\r\n lz.append(cnt)\r\n g=True\r\n cnt=0\r\n continue\r\n else:\r\n lz.append(cnt)\r\nlz.append(cnt)\r\nprint(\"\".join(map(str,lz)))\r\n", "import sys, math\r\ninput=sys.stdin.readline\r\nINF=int(1e9)+7\r\n\r\n\r\ndef solve():\r\n n=int(input())\r\n data=list(input().rstrip().split('0'))\r\n ans=''\r\n for i in data:\r\n ans+=str(len(i))\r\n print(ans)\r\n \r\n \r\nt=1\r\nwhile t:\r\n t-=1\r\n solve()\r\n", "#! python3\n\nN = int(input())\ns = input()\nr = ''\ncount = 0\nfor i in s:\n if i == '0':\n r += str(count)\n count = 0\n else:\n count += 1\nr += str(count)\nprint(r)\n", "n = int(input())\r\n\r\nstart_str = input()\r\nfinal_str = \"\"\r\nassert (len(start_str) == n)\r\n\r\nl = list(start_str)\r\ncur_num = 0\r\nk = 0\r\n\r\nfor i in range(len(l)):\r\n if int(l[i]) == 1:\r\n k = 0\r\n cur_num += 1\r\n elif int(l[i]) == 0 and k == 0:\r\n k += 1\r\n final_str += str(cur_num)\r\n cur_num = 0\r\n elif int(l[i]) == 0 and k >= 1:\r\n final_str += \"0\"\r\nfinal_str += str(cur_num)\r\nprint(final_str)\r\n", "n = int(input())\r\nentrada = input().split('0')\r\n[ print(len(n), end='') for n in entrada]\r\n", "def read_ints():\n return list(map(int, input().split()))\n\n\nif __name__ == '__main__':\n _ = input()\n s = input().split('0')\n print(*[len(token) for token in s], sep='')\n", "n=int(input())\r\nprint(''.join(str(len(x))for x in input().split('0')))", "n = int(input())\r\ns = input()\r\n\r\nl = s.split('0')\r\n\r\nle = len(l)\r\n\r\nans = 0\r\n\r\nfor i in range(le):\r\n t = l[i]\r\n ans *= 10\r\n ans += len(t)\r\n\r\nprint(ans)\r\n", "useless = int(input())\nn = input()\n\nres = 0\nh = 0\np = 0\n\nfor e in n[::-1]:\n if int(e) == 1:\n h += 1\n else:\n res = res + (10**p * h)\n p += 1 \n h = 0\nres = res + (10**p * h)\n\n\nprint(res) \n\n\n", "n = input()\ns = input()\nprint(''.join([str(len(i)) for i in s.split('0')]))\n", "n = input()\r\n[print(len(i), end='') for i in input().split('0')]", "input()\nprint(''.join(str(len(x)) for x in input().split('0')))\n", "import sys\r\n\r\nn = int(input())\r\ns = input().split('0')\r\nprint(*(map(str, (len(one) for one in s))), sep='')\r\n", "n=int(input())\r\ns=input().split('0')\r\nfor i in s:\r\n print(len(i), end='')", "n = int(input())\r\ns = input().split(\"0\")\r\nans = \"\"\r\nfor a in s:\r\n if a == \"\":\r\n ans = ans + str(0)\r\n else:\r\n ans = ans + str(len(a))\r\nprint(ans)", "t = int(input())\r\nn = input()\r\n\r\np = n.split(\"0\")\r\n\r\nfor i in range(len(p)):\r\n print(len(p[i]),end=\"\")", "n=int(input())\r\nstr1=input()\r\nlist1=list(str1)\r\n\r\ncount1=0\r\nnewList=[]\r\nfor i in range(len(list1)):\r\n if list1[i]=='1':\r\n count1+=1\r\n else:\r\n newList.append(str(count1))\r\n count1=0\r\n\r\nnewList.append(str(count1))\r\nprint(\"\".join(newList))\r\n", "n = input()\r\ns = input()\r\nx = s.split('0')\r\nprint(''.join([str(len(i)) for i in x]))", "#!/usr/local/bin/python3\n\ninput()\n\nbinary_number = input()\n\nsplitted = binary_number.split('0')\ndigits = map(len, splitted)\nprint(''.join(map(str, digits)))\n", "n = input()\r\ns = input()\r\n \r\ntmp = s.split('0')\r\nl = ''\r\nfor i in tmp:\r\n l+=str(len(i))\r\n \r\nprint(l)\r\n", "n = int(input())\n\nstring = input()\n\nnumber = \"\"\n\ncount = 0\n\nfor i in range(0, n):\n if string[i] == \"1\":\n count += 1\n elif string[i] == \"0\" and i > 0 and string[i-1] == \"1\":\n number += str(count)\n count = 0\n else:\n number += \"0\"\n\nnumber += str(count)\n\nprint(number)\n\n", "n = int(input())\ns = input()\n\na = s.split('0')\n\nans = []\nfor i in a:\n if i == '':\n ans.append('0')\n continue\n ans.append(str(len(i)))\n\nprint(''.join(ans))\n", "a = int(input())\r\nb = str(input())\r\nd = str()\r\nnum = 0\r\nfor i in range(0, a):\r\n if str(b[i]) == str(1):\r\n num += 1\r\n else:\r\n d += str(num)\r\n num = 0\r\n\r\nd += str(num)\r\nprint(d)\n# Mon Oct 16 2023 21:29:06 GMT+0300 (Moscow Standard Time)\n", "input()\r\ns = input().split('0')\r\nfor d in s: print(len(d), end='')", "from math import inf,sqrt,floor,ceil\r\nfrom collections import Counter,defaultdict,deque\r\nfrom heapq import heappush as hpush,heappop as hpop,heapify as h\r\nfrom operator import itemgetter\r\nfrom itertools import product\r\nfrom bisect import bisect_left,bisect_right\r\n\r\nn=int(input())\r\nprint(''.join(list(map(str,list(map(len,input().split(\"0\")))))))\r\n", "n = int(input())\r\ns = input()\r\nsum = 0\r\nflag = 0\r\nl = \"\"\r\nout = \"\"\r\nfor c in s :\r\n if c == '1' :\r\n sum+=1\r\n l = '1'\r\n elif c== '0' and l == '1' :\r\n out+=str(sum)\r\n sum = 0\r\n l = '0'\r\n elif c == '0' and l == '0' :\r\n out+='0'\r\n sum = 0\r\nout+=str(sum)\r\nprint(out)\r\n\r\n\r\n\r\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\nans = []\r\nfor k in input().rstrip().split('0'):\r\n ans.append(len(k))\r\nprint(*ans, sep='')\r\n", "n = int(input())\r\ns = input()\r\nc = 0\r\nfor x in range(n):\r\n if s[x] == \"1\":\r\n c += 1\r\n else:\r\n print(c, end=\"\")\r\n c = 0\r\nprint(c)\r\n ", "n=int(input())\r\nz=[0]\r\nt=[]\r\nfor i in input():\r\n t.append(int(i))\r\n if i=='0':\r\n z.append(len(t)-1)\r\ns=''\r\nfor i in range(len(z)-1):\r\n s+=str(sum(t[z[i]:z[i+1]]))\r\ns+=str(sum(t[z[-1]:]))\r\nprint(s)", "def read():\r\n return [int(e) for e in input()]\r\nno=read()\r\nx=read()\r\ni=1\r\ns=\"\"\r\na=0\r\nfor e in x:\r\n if e==1:\r\n a+=1\r\n i=1\r\n elif e==0 and i==0:\r\n s+=str(0)\r\n else:\r\n s+=str(a)\r\n i=0\r\n a=0\r\ns+=str(a)\r\nprint (s)\r\n \r\n", "n=int(input())\r\ns=input()\r\nt=\"\"\r\nl=list(s.split(\"0\"))\r\nfor i in l:\r\n if i==\"\":\r\n t+=\"0\"\r\n else:\r\n t+=str(len(i))\r\nprint (t)\r\n", "def main():\n N = int(input())\n S = input()\n\n num = 0\n ans = ''\n for i in range(N):\n if S[i] == '1':\n num += 1\n else:\n if not num:\n ans = ans + '0'\n else:\n ans = ans + str(num)\n num = 0\n else:\n ans = ans + str(num)\n\n print(ans)\n\nmain()\n", "input()\nprint(''.join(map(lambda x: str(len(x)), input().strip().split('0'))))\n", "from collections import defaultdict, deque\r\nfrom heapq import heappush, heappop\r\nfrom math import inf\r\nfrom itertools import groupby\r\n\r\nri = lambda : map(int, input().split())\r\n\r\ndef solve():\r\n n = int(input())\r\n s = input()\r\n res = []\r\n curr = 0\r\n for x in s:\r\n if x == \"0\":\r\n print(curr,end=\"\")\r\n curr = 0\r\n else:\r\n curr += 1\r\n print(curr)\r\n\r\n\r\nt = 1\r\n#t = int(input())\r\nwhile t:\r\n t -= 1\r\n solve()\r\n\r\n", "a=input()\r\na=input()\r\nans=0\r\nfor i in a:\r\n if i=='1':\r\n ans+=1\r\n else:\r\n print(ans,end='')\r\n ans=0\r\nprint(ans)", "n=int(input())\r\ns=input()\r\nyep=False\r\nans=\"\"\r\ncur=0\r\nfor x in s:\r\n if x==\"1\":\r\n cur+=1\r\n elif x==\"0\":\r\n ans+=str(cur)\r\n cur=0\r\nif len(ans)!=(s.count(\"0\")+1):\r\n ans+=str(cur)\r\n print(ans)\r\nelse:\r\n print(ans)", "n = int(input())\r\ns = input().split(\"0\")\r\nans = \"\"\r\nfor t in s:\r\n\tans += str(len(t))\r\nprint(ans)", "tamanho_string = int(input())\nstring = input()\nstring = string[:: -1]\nstring += '0'\n\nnumero = 0\ncont = 0\ndigito_1 = 0 \nfor i in string:\n if (i == '1'):\n digito_1 += 1\n else:\n numero += digito_1 * (10**cont)\n digito_1 = 0\n cont += 1\n\nprint(numero)\n\t \t\t \t \t \t\t \t \t \t\t\t \t", "n=int(input())\r\ns=input()\r\nr=list()\r\ni=k=0\r\nwhile i<n:\r\n if(s[i]=='1'):\r\n k+=1\r\n elif(s[i]=='0' and k==0):\r\n r.append(0)\r\n else:\r\n r.append(k)\r\n k=0\r\n i+=1\r\nr.append(k)\r\nfor i in r:\r\n print(i,end='')", "n=input()\r\nt=input()\r\ncnt=0\r\ns=''\r\nfor i in t:\r\n if i=='0':\r\n s+=str(cnt)\r\n cnt=0\r\n \r\n else:cnt+=1\r\ns+=str(cnt)\r\nprint(s)", "n=int(input())\r\nl=input()\r\ns=\"\"\r\ninp=\"\"\r\nfor i in range(n) :\r\n if l[i]=='1' :\r\n s+=l[i]\r\n else :\r\n if len(s)==0 :\r\n inp+=\"0\"\r\n else :\r\n inp+=str(len(s))\r\n \r\n s=\"\"\r\ninp+=str(len(s))\r\nprint(inp)\r\n \r\n\r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n", "n =int(input())\r\nstring =input()\r\nastr =\"\"\r\ncount =0\r\nfor i in range(n):\r\n if string[i] == '1':\r\n count+=1\r\n elif string[i] == '0':\r\n astr+=str(count)\r\n count =0\r\n elif string[i] == '0' and i > 0 and string[i-1] == '0':\r\n astr+='0'\r\nastr+=str(count)\r\nprint (astr)", "encodeNumberLength = int(input())\r\n\r\nencodeNumber = list(map(str, input().split('0')))\r\n\r\nresult = ''\r\n\r\nfor element in encodeNumber:\r\n \r\n if element == '':\r\n result = result + '0'\r\n continue\r\n \r\n result = result + str(len(element))\r\n \r\nprint(result)", "# from collections import defaultdict,deque,OrderedDict\r\n# from sys import stdin\r\n# import itertools\r\n# import bisect\r\n# from math import sqrt,ceil,floor,gcd,sin,radians\r\n# from sortedcontainers import SortedList\r\n# from functools import reduce\r\n# from typing import *\r\n\r\ndef func(put,mapping,unpack):\r\n n,s = put(int),put(str)\r\n print(*map(len,s.split('0')),sep='')\r\n\r\ndef init(TestCases=True):\r\n put = lambda s: s(input().strip())\r\n mapping = lambda s: list(map(s,input().split()))\r\n unpack = lambda s: map(s,input().split())\r\n for _ in range(int(input()) if TestCases else 1):\r\n func(put,mapping,unpack)\r\n\r\nif __name__ == '__main__':\r\n init(False)", "s=input()\r\ns=str(input())\r\nval='';\r\ncount=0;\r\nfor a in s:\r\n\tif a=='1':\r\n\t\tcount+=1\r\n\telse:\r\n\t\tval+=str(count)\r\n\t\tcount=0\r\nval+=str(count)\r\nprint (val)\r\n\t\t\t", "n = int(input())\r\nst = input()\r\ncount = 0\r\nfor i in st:\r\n if i == '1':\r\n count += 1\r\n elif i == '0' and count :\r\n print(count, end='')\r\n count = 0\r\n else:\r\n print(0, end='')\r\nprint(count)", "#done by gautham\r\nn=int(input())\r\ns=str(input())\r\nq=\"\"\r\nr=0\r\np=[]\r\nfor i in s:\r\n if i==\"1\":\r\n r=r+1\r\n else:\r\n p.append(r)\r\n r=0\r\np.append(r)\r\nfor i in p:\r\n q=q+str(i)\r\nprint(q)\r\n", "size=int(input())\r\nlel=input()\r\nnumber=list(lel)\r\n#print(number)\r\noriginal=0\r\nout=''\r\nfor x in number:\r\n\t#print(x)\r\n\tif x=='1':\r\n\t\toriginal+=1\r\n\telse:\r\n\t\tout=out+str(original)\r\n\t\toriginal=0\r\nout=out+str(original)\r\nprint(out)", "input()\r\nfor i in input().split(\"0\"):\r\n print(len(i), end = \"\")\n# Sun Oct 29 2023 14:04:34 GMT+0300 (Moscow Standard Time)\n", "#Bhargey Mehta (Sophomore)\r\n#DA-IICT, Gandhinagar\r\nimport sys, math, queue, bisect\r\n#sys.stdin = open(\"input.txt\", \"r\")\r\nMOD = 10**9+7\r\nsys.setrecursionlimit(1000000)\r\n\r\nn = int(input())\r\ns = input()+'0'\r\nans = [0]\r\nfor i in range(n):\r\n if s[i] == '0':\r\n ans.append(0)\r\n else:\r\n ans[-1] += 1\r\nans = [str(a) for a in ans]\r\nans = ''.join(ans)\r\nprint(ans)\r\n", "n = int(input())\ns = input()\nk1, k0 = 0, 0\na = 0\nfor i in range(n):\n\tif s[i] == '0':\n\t\ta = a * 10 + k1\n\t\tk1 = 0\n\telse:\n\t\tk1 += 1\nelse:\n\ta = a * 10 + k1\nprint(a)\n", "\r\nimport sys\r\n#sys.stdin=open(\"data.txt\")\r\ninput=sys.stdin.readline\r\n\r\nnum=\"\"\r\ncnt=0\r\n\r\ninput()\r\nfor ch in input().strip()+\"0\":\r\n if ch==\"1\":\r\n cnt+=1\r\n else:\r\n num+=str(cnt)\r\n cnt=0\r\n\r\nprint(num)", "n=int(input())\ns=input()+'0'\ni=0\nfor x in range(n):\n if s[x]=='1':\n i+=1\n elif s[x]=='0':\n print(i,end='')\n i=0\nprint(i,end='')\n", "n=int(input())\r\nn1=input()\r\ns=''\r\nv=''\r\nc=0\r\nk=0\r\nlst=[]\r\nfor i in n1:\r\n if(i=='1'):\r\n if(c>0):\r\n lst.append(s)\r\n s=''\r\n c=0\r\n s=s+'1'\r\n k=k+1\r\n elif(i=='0'):\r\n if(k>0):\r\n lst.append(s)\r\n s=''\r\n k=0\r\n s=s+'0'\r\n c=c+1\r\nlst.append(s)\r\nfor j in range(len(lst)):\r\n if('1' in lst[j]):\r\n v=v+str(len(lst[j]))\r\n else:\r\n if(j!=len(lst)-1):\r\n v=v+str((len(lst[j])-1)*'0')\r\n else:\r\n v=v+lst[j]\r\nprint(v)\r\n", "n = input()\r\nn = int(n)\r\n\r\ns = str(input())\r\ns = s.split('0')\r\n\r\nans = \"\"\r\nfor digit in s:\r\n\tans += str(len(digit))\r\n\r\nprint(ans)", "n = int(input())\r\ns = input()\r\nv = s.split('0')\r\nans = \"\"\r\nfor x in v:\r\n ans += str(len(x))\r\nprint(ans)", "# reciving input\r\ninput()\r\nprint(*map(len, input().split('0')), sep='') # explain sep''\r\n", "n = int(input())\r\nres = ''\r\nct = 0\r\n\r\nfor i in input():\r\n if i == '1':\r\n ct += 1\r\n if i == '0':\r\n res += str(ct)\r\n ct = 0\r\n \r\nres += str(ct)\r\nprint(res)\r\n", "n=int(input())\r\nsum=input().split(\"0\")\r\na=\"\"\r\nfor i in sum:\r\n\ta+=str(len(i))\r\nprint(a)", "import sys\r\n\"\"\"for text in sys.stdin:\r\n\ta, b, c = map(int, text.split(\" \"))\r\n\tprint(\"the number is: %d %d %d\"%(a, b, c))\"\"\"\r\n\r\nn = int(input())\r\ntext = input()\r\ntext = text.split(\"0\")\r\na = \"\"\r\nfor i in text:\r\n\tif(i == \"\"):\r\n\t\ta += \"0\"\r\n\telse:\r\n\t\ta += str(len(i))\r\nprint(a)", "a = input()\r\nb = input().split('0')\r\nfor i in b:\r\n\tprint(len(i), end='')", "n=int(input());\r\ns=input();\r\nl=list(s.split('0'));\r\nfor x in l:\r\n print(len(x),end='');\r\n \r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Jul 21 13:33:46 2017\r\n\r\n@author: Gad\r\n\"\"\"\r\n\r\n \r\ndef decode(info):\r\n for i in map(len, info.split('0')):\r\n print(i,end='') \r\n print()\r\n \r\ninput() \r\ninfo = input()\r\ndecode(info)\r\n \r\n \r\n\r\n ", "input()\ns = input()\n\nprint(\"\".join(map(str, map(len, s.split(\"0\")))))\n", "input()\r\nh = input().split('0')\r\nfor a in h:\r\n print(len(a), end='')", "n = int(input())\r\ns = input()\r\nfreq = [0]\r\nj, flag = 0, 0\r\nfor i in range(len(s)):\r\n if (s[i] == \"1\"):\r\n if (flag == 1):\r\n freq.append(0)\r\n freq[j] += 1\r\n flag = 0\r\n else:\r\n freq[j] += 1\r\n else:\r\n if (flag == 1):\r\n j += 1\r\n pass\r\n else:\r\n j += 1\r\n tmp = i\r\n lst = 0\r\n ok = False\r\n while True:\r\n lst += 1\r\n tmp += 1\r\n if (tmp == len(s)):\r\n break\r\n if (s[tmp] == \"1\"):\r\n ok = True\r\n break\r\n if ok:\r\n lst = [0]*(lst - 1)\r\n freq += lst\r\n else:\r\n lst = [0]*(lst)\r\n freq += lst\r\n flag = 1\r\nfor i in freq:\r\n print(i, end = \"\")", "n = int(input())\r\ns = input()\r\ncurr = 0\r\n\r\nfor char in s:\r\n if char == '1':\r\n curr += 1\r\n else:\r\n print(curr, end = '')\r\n curr = 0\r\n \r\nprint(curr)\r\n", "def main():\r\n N = int(input())\r\n S = list(input())\r\n\r\n count = 0\r\n res = \"\"\r\n for s in S: \r\n if s == \"1\":\r\n count += 1\r\n else:\r\n res += str(count)\r\n count = 0\r\n\r\n res += str(count)\r\n print(res)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n # global stime\r\n # stime = time.clock()\r\n main()", "input()\r\ns = input().split('0')\r\nfor i in s:\r\n print(len(i), end='')", "length = input()\r\ns = input()\r\ns = s.split('0')\r\nresult = \"\"\r\nfor i in s:\r\n result += str(len(i))\r\nprint(result)", "n = int(input())\r\na = list(input().split('0'))\r\nfor i in a:\r\n print(len(i), end=\"\")", "n=int(input())\r\nq=list(input())\r\n\r\ni=0\r\nc=[]\r\ns=0\r\nwhile(i<n):\r\n if(q[i]=='1'):\r\n s=s+1\r\n else:\r\n c.append(s)\r\n s=0\r\n i=i+1\r\n\r\nc.append(s)\r\nfor i in range(len(c)):\r\n print(c[i],end='')\r\n ", "input()\nfor number in input().split('0'):\n\tprint(len(number), end='')", "n = int(input())\r\nstring = input()\r\nnumbers = string.split(\"0\")\r\na = \"\"\r\nfor x in numbers:\r\n a += str(len(x))\r\na = int(a)\r\nprint(a)", "n = int(input())\r\ns = input().split(\"0\")\r\nnum = \"\"\r\nfor i in range(len(s)):\r\n if s[i] == \"\":\r\n num += \"0\"\r\n else:\r\n num += str(s[i].count(\"1\"))\r\nprint(num)", "input()\r\ngivenstring = input().split('0')\r\nfor index in givenstring:\r\n print(len(index), end='')", "\r\ndef Binary(l):\r\n\tresult=\"\"\r\n\tp1=[list(y) for y in l.split('0')]\r\n\tfor x in p1:\r\n\t\tif x==\"\":\r\n\t\t\tresult=result+\"0\"\r\n\t\t\tcontinue\r\n\t\tresult=result+str(sum([int(h) for h in x]))\r\n\tprint(result)\r\n\t\r\ninput()\r\nBinary(input())\r\n\r\n", "t = input()\ns=input()+\"0\"\ni = 0\nj = 0\nans = \"\"\nwhile j < len(s):\n i = 0\n while s[j]!='0':\n j+=1\n i+=1\n ans+=str(i)\n j+=1\nprint(ans)\n", "def main():\n input()\n r = 0\n for d in map(len, input().split('0')):\n r = r * 10 + d\n print(r)\n\n\nif __name__ == '__main__':\n main()\n", "#!/bin/python3\r\n\r\nimport sys\r\nn=int(input())\r\ns=input()\r\nans=0\r\nt=0\r\nfor i in s:\r\n if(i==\"0\"):\r\n ans=ans*10+t\r\n t=0\r\n else:\r\n t+=1\r\nans=ans*10+t\r\nprint (ans)\r\n \r\n ", "l = input()\r\ns = input()\r\nout = \"\"\r\nfor i in s.split(\"0\"):\r\n out += str(len(i))\r\n\r\nprint(out)\r\n", "n = int(input())\nans = ''\nfor i in input().split('0'):\n ans += str(len(i))\nprint(ans)\n", "n=input()\r\na=list(map(str, input().split('0')))\r\nans=\"\"\r\nfor i in a:\r\n ans+=str(len(i))\r\nprint(ans)\r\n", "n=int(input())\ns=input()\ncount=1\nfor i in range(1,n):\n if s[i]=='0' and s[i-1]!='0':\n print(count, end='')\n count=0\n elif s[i]=='1':\n count+=1\n elif s[i]=='0':\n print(0,end='')\nprint(count,end='')\n", "# ===================================\r\n# (c) MidAndFeed aka ASilentVoice\r\n# ===================================\r\n# import math, fractions, collections\r\n# ===================================\r\nn = int(input())\r\ns = str(input())\r\nans = 0\r\nfor x in s.split(\"0\"):\r\n\tans += len(x)\r\n\tans *= 10\r\nprint(ans//10)", "import math\r\nn = int(input())\r\ns = input()\r\narray = []\r\nresult = ''\r\nfor i in s.split('0'):\r\n array.append(i)\r\nfor i in range(len(array)):\r\n counter = 0\r\n for j in range(len(array[i])):\r\n counter += 1\r\n result += str(counter)\r\nprint(result)" ]
{"inputs": ["3\n111", "9\n110011101", "1\n1", "3\n100", "5\n10001", "14\n11001100011000", "31\n1000011111111100011110111111111", "53\n10110111011110111110111111011111110111111110111111111", "89\n11111111101111111110111111111011111111101111111110111111111011111111101111111110111111111", "10\n1000000000", "2\n10", "4\n1110", "8\n10101010"], "outputs": ["3", "2031", "1", "100", "1001", "202002000", "100090049", "123456789", "999999999", "1000000000", "10", "30", "11110"]}
UNKNOWN
PYTHON3
CODEFORCES
215
e5eb77ed5fde83dd01fd25945e8d87e6
Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are *n*<=+<=1 cities consecutively numbered from 0 to *n*. City 0 is Metropolis that is the meeting point for all jury members. For each city from 1 to *n* there is exactly one jury member living there. Olympiad preparation is a long and demanding process that requires *k* days of work. For all of these *k* days each of the *n* jury members should be present in Metropolis to be able to work on problems. You know the flight schedule in the country (jury members consider themselves important enough to only use flights for transportation). All flights in Metropolia are either going to Metropolis or out of Metropolis. There are no night flights in Metropolia, or in the other words, plane always takes off at the same day it arrives. On his arrival day and departure day jury member is not able to discuss the olympiad. All flights in Megapolia depart and arrive at the same day. Gather everybody for *k* days in the capital is a hard objective, doing that while spending the minimum possible money is even harder. Nevertheless, your task is to arrange the cheapest way to bring all of the jury members to Metrpolis, so that they can work together for *k* days and then send them back to their home cities. Cost of the arrangement is defined as a total cost of tickets for all used flights. It is allowed for jury member to stay in Metropolis for more than *k* days. The first line of input contains three integers *n*, *m* and *k* (1<=≤<=*n*<=≤<=105, 0<=≤<=*m*<=≤<=105, 1<=≤<=*k*<=≤<=106). The *i*-th of the following *m* lines contains the description of the *i*-th flight defined by four integers *d**i*, *f**i*, *t**i* and *c**i* (1<=≤<=*d**i*<=≤<=106, 0<=≤<=*f**i*<=≤<=*n*, 0<=≤<=*t**i*<=≤<=*n*, 1<=≤<=*c**i*<=≤<=106, exactly one of *f**i* and *t**i* equals zero), the day of departure (and arrival), the departure city, the arrival city and the ticket cost. Output the only integer that is the minimum cost of gathering all jury members in city 0 for *k* days and then sending them back to their home cities. If it is impossible to gather everybody in Metropolis for *k* days and then send them back to their home cities, output "-1" (without the quotes). Sample Input 2 6 5 1 1 0 5000 3 2 0 5500 2 2 0 6000 15 0 2 9000 9 0 1 7000 8 0 2 6500 2 4 5 1 2 0 5000 2 1 0 4500 2 1 0 3000 8 0 1 6000 Sample Output 24500 -1
[ "g = lambda: map(int, input().split())\r\nn, m, k = g()\r\nF, T = [], []\r\ne = int(3e11)\r\n\r\nfor i in range(m):\r\n d, f, t, c = g()\r\n if f: F.append((d, f, c))\r\n else: T.append((-d, t, c))\r\n\r\nfor p in [F, T]:\r\n C = [e] * (n + 1)\r\n s = n * e\r\n q = []\r\n\r\n p.sort()\r\n for d, t, c in p:\r\n if C[t] > c:\r\n s += c - C[t]\r\n C[t] = c\r\n if s < e: q.append((s, d))\r\n p.clear()\r\n p += q\r\n\r\ns, t = e, (0, 0)\r\nfor f in F:\r\n while f:\r\n if t[1] + f[1] + k < 0: s = min(s, f[0] + t[0])\r\n elif T:\r\n t = T.pop()\r\n continue\r\n f = 0\r\n\r\nprint(s if s < e else -1)", "R=lambda :map(int,input().split())\r\nn,m,k=R()\r\nF,T=[],[]\r\nans=int(1e12)\r\nfor i in range(m):\r\n d,f,t,c=R()\r\n if f:F.append((d,f,c))\r\n else:T.append((-d,t,c))\r\nfor p in [F,T]:\r\n cost=[ans]*(n+1)\r\n s=n*ans\r\n q=[]\r\n p.sort()\r\n for d,t,c in p:\r\n #print(p)\r\n if c<cost[t]:\r\n #print(c,cost[t])\r\n s+=c-cost[t]\r\n #print(s)\r\n cost[t]=c\r\n if s<ans:\r\n q.append((s,d))\r\n p.clear()\r\n #print(q)\r\n p+=q\r\n #print(p)\r\ns,t=ans,(0,0)\r\n#print(F,T)\r\nfor f in F:\r\n while f:\r\n if f[1]+t[1]+k<0:s=min(s,f[0]+t[0])\r\n elif T:\r\n #print(T)\r\n t=T.pop()\r\n #print(T)\r\n # print(t)\r\n continue\r\n #print(f)\r\n f=0\r\n #print(f)\r\nprint(s if s<ans else -1)\r\n", "import sys\r\n\r\ninput = lambda: sys.stdin.buffer.readline().decode().strip()\r\nn, m, k = map(int, input().split())\r\nday, dep, arr, cost = [[0] * m for _ in range(4)]\r\n\r\nfor i in range(m):\r\n day[i], dep[i], arr[i], cost[i] = map(int, input().split())\r\n\r\nran, pre = sorted(range(m), key=day.__getitem__), [10 ** 12] * (10 ** 6 + 1)\r\ncur, num, su = [0] * (n + 1), 0, 0\r\n\r\nfor i in ran:\r\n if arr[i] == 0:\r\n su -= cur[dep[i]]\r\n if not cur[dep[i]]:\r\n num += 1\r\n cur[dep[i]] = cost[i]\r\n elif cur[dep[i]] > cost[i]:\r\n cur[dep[i]] = cost[i]\r\n su += cur[dep[i]]\r\n\r\n if num == n and day[i] + k + 1 <= 10 ** 6:\r\n pre[day[i] + k + 1] = su\r\n\r\nfor i in range(1, 10 ** 6 + 1):\r\n pre[i] = min(pre[i], pre[i - 1])\r\n\r\ncur, num, su, ans = [0] * (n + 1), 0, 0, 10 ** 12\r\nfor i in ran[::-1]:\r\n if arr[i]:\r\n su -= cur[arr[i]]\r\n if not cur[arr[i]]:\r\n num += 1\r\n cur[arr[i]] = cost[i]\r\n elif cur[arr[i]] > cost[i]:\r\n cur[arr[i]] = cost[i]\r\n su += cur[arr[i]]\r\n\r\n if num == n:\r\n ans = min(ans, su + pre[day[i]])\r\n\r\nprint(-1 if ans == 10 ** 12 else ans)\r\n", "def main():\n n, m, k = map(int, input().split())\n ff, tt = [], []\n for _ in range(m):\n d, f, t, c = map(int, input().split())\n if f:\n ff.append((d, f, c))\n else:\n tt.append((-d, t, c))\n for ft in ff, tt:\n cnt, costs = n, [1000001] * (n + 1)\n ft.sort(reverse=True)\n while ft:\n day, city, cost = ft.pop()\n oldcost = costs[city]\n if oldcost > cost:\n costs[city] = cost\n if oldcost == 1000001:\n cnt -= 1\n if not cnt:\n break\n else:\n print(-1)\n return\n total = sum(costs) - 1000001\n l = [(day, total)]\n while ft:\n day, city, cost = ft.pop()\n oldcost = costs[city]\n if oldcost > cost:\n total -= oldcost - cost\n costs[city] = cost\n if l[-1][0] == day:\n l[-1] = (day, total)\n else:\n l.append((day, total))\n if ft is ff:\n ff = l\n else:\n tt = l\n l, k = [], -k\n d, c = tt.pop()\n try:\n for day, cost in ff:\n while d + day >= k:\n d, c = tt.pop()\n if d + day < k:\n l.append(c + cost)\n except IndexError:\n pass\n print(min(l, default=-1))\n\n\nif __name__ == '__main__':\n main()\n", "N,M,K = map(int,input().split())\r\n\r\nINF = 10**6+1\r\nfrom collections import defaultdict\r\n\r\nincoming = defaultdict(list)\r\noutgoing = defaultdict(list)\r\n\r\nfor _ in range(M):\r\n d,f,t,c = map(int,input().split())\r\n if t == 0:\r\n incoming[d].append((c,f-1))\r\n if f == 0:\r\n outgoing[d].append((c,t-1))\r\n\r\nincoming_dates = sorted(incoming.keys())\r\noutgoing_dates = sorted(outgoing.keys(),reverse=True)\r\n\r\n\r\n\r\nLi = []\r\nmark = [False]*N\r\ncnt = 0\r\ncosts = [0]*N\r\ntotal_cost = 0\r\n\r\nfor d in incoming_dates:\r\n for c,x in incoming[d]:\r\n if mark[x]:\r\n if costs[x] > c:\r\n total_cost += c-costs[x]\r\n costs[x] = c\r\n else:\r\n mark[x] = True\r\n cnt += 1\r\n costs[x] = c\r\n total_cost += c\r\n\r\n if cnt == N:\r\n Li.append((d,total_cost))\r\n\r\n\r\nLo = []\r\nmark = [False]*N\r\ncnt = 0\r\ncosts = [0]*N\r\ntotal_cost = 0\r\n\r\nfor d in outgoing_dates:\r\n for c,x in outgoing[d]:\r\n if mark[x]:\r\n if costs[x] > c:\r\n total_cost += c-costs[x]\r\n costs[x] = c\r\n else:\r\n mark[x] = True\r\n cnt += 1\r\n costs[x] = c\r\n total_cost += c\r\n\r\n if cnt == N:\r\n Lo.append((d,total_cost))\r\n\r\nLo.reverse()\r\n\r\n\r\nif not Li or not Lo:\r\n print(-1)\r\n exit()\r\n\r\n\r\n# print(Li,Lo)\r\n\r\nfrom bisect import bisect\r\n\r\nbest = float('inf')\r\n\r\nfor d,c in Li:\r\n i = bisect(Lo,(d+K+1,0))\r\n if i >= len(Lo):\r\n break\r\n else:\r\n best = min(best,c+Lo[i][1])\r\n\r\nif best == float('inf'):\r\n print(-1)\r\nelse:\r\n print(best)" ]
{"inputs": ["2 6 5\n1 1 0 5000\n3 2 0 5500\n2 2 0 6000\n15 0 2 9000\n9 0 1 7000\n8 0 2 6500", "2 4 5\n1 2 0 5000\n2 1 0 4500\n2 1 0 3000\n8 0 1 6000", "2 5 5\n1 1 0 1\n2 2 0 100\n3 2 0 10\n9 0 1 1000\n10 0 2 10000", "2 4 5\n1 1 0 1\n2 2 0 10\n8 0 1 100\n9 0 2 1000", "1 2 1\n10 1 0 16\n20 0 1 7", "1 2 10\n20 0 1 36\n10 1 0 28", "1 2 9\n20 0 1 97\n10 1 0 47", "2 4 1\n20 0 1 72\n21 0 2 94\n9 2 0 43\n10 1 0 91", "2 4 10\n20 0 1 7\n9 2 0 32\n10 1 0 27\n21 0 2 19", "2 4 9\n10 1 0 22\n21 0 2 92\n9 2 0 29\n20 0 1 37", "3 6 1\n10 1 0 62\n8 3 0 83\n20 0 1 28\n22 0 3 61\n21 0 2 61\n9 2 0 75", "3 6 10\n22 0 3 71\n20 0 1 57\n8 3 0 42\n10 1 0 26\n9 2 0 35\n21 0 2 84", "3 6 9\n10 1 0 93\n20 0 1 26\n8 3 0 51\n22 0 3 90\n21 0 2 78\n9 2 0 65", "4 8 1\n9 2 0 3\n22 0 3 100\n20 0 1 40\n10 1 0 37\n23 0 4 49\n7 4 0 53\n21 0 2 94\n8 3 0 97", "4 8 10\n8 3 0 65\n21 0 2 75\n7 4 0 7\n23 0 4 38\n20 0 1 27\n10 1 0 33\n22 0 3 91\n9 2 0 27", "4 8 9\n8 3 0 61\n9 2 0 94\n23 0 4 18\n21 0 2 19\n20 0 1 52\n10 1 0 68\n22 0 3 5\n7 4 0 59", "5 10 1\n24 0 5 61\n22 0 3 36\n8 3 0 7\n21 0 2 20\n6 5 0 23\n20 0 1 28\n23 0 4 18\n9 2 0 40\n7 4 0 87\n10 1 0 8", "5 10 10\n24 0 5 64\n23 0 4 17\n20 0 1 91\n9 2 0 35\n21 0 2 4\n22 0 3 51\n6 5 0 69\n7 4 0 46\n8 3 0 92\n10 1 0 36", "5 10 9\n22 0 3 13\n9 2 0 30\n24 0 5 42\n21 0 2 33\n23 0 4 36\n20 0 1 57\n10 1 0 39\n8 3 0 68\n7 4 0 85\n6 5 0 35", "1 10 1\n278 1 0 4\n208 1 0 4\n102 0 1 9\n499 0 1 7\n159 0 1 8\n218 1 0 6\n655 0 1 5\n532 1 0 6\n318 0 1 6\n304 1 0 7", "2 10 1\n5 0 2 5\n52 2 0 9\n627 0 2 6\n75 0 1 6\n642 0 1 8\n543 0 2 7\n273 1 0 2\n737 2 0 4\n576 0 1 7\n959 0 2 5", "3 10 1\n48 2 0 9\n98 0 2 5\n43 0 1 8\n267 0 1 7\n394 3 0 7\n612 0 3 9\n502 2 0 6\n36 0 2 9\n602 0 1 3\n112 1 0 6", "4 10 1\n988 0 1 1\n507 1 0 9\n798 1 0 9\n246 0 3 7\n242 1 0 8\n574 4 0 7\n458 0 4 9\n330 0 2 9\n303 2 0 8\n293 0 3 9", "5 10 1\n132 0 4 7\n803 0 2 8\n280 3 0 5\n175 4 0 6\n196 1 0 7\n801 0 4 6\n320 0 5 7\n221 0 4 6\n446 4 0 8\n699 0 5 9", "6 10 1\n845 0 4 9\n47 0 4 8\n762 0 2 8\n212 6 0 6\n416 0 5 9\n112 5 0 9\n897 0 6 9\n541 0 4 5\n799 0 6 7\n252 2 0 9", "7 10 1\n369 6 0 9\n86 7 0 9\n696 0 4 8\n953 6 0 7\n280 4 0 9\n244 0 2 9\n645 6 0 8\n598 7 0 6\n598 0 7 8\n358 0 4 6", "8 10 1\n196 2 0 9\n67 2 0 9\n372 3 0 6\n886 6 0 6\n943 0 3 8\n430 3 0 6\n548 0 4 9\n522 0 3 8\n1 4 0 3\n279 4 0 8", "9 10 1\n531 8 0 5\n392 2 0 9\n627 8 0 9\n363 5 0 9\n592 0 5 3\n483 0 6 7\n104 3 0 8\n97 8 0 9\n591 0 7 9\n897 0 6 7", "10 10 1\n351 0 3 7\n214 0 9 9\n606 0 7 8\n688 0 9 3\n188 3 0 9\n994 0 1 7\n372 5 0 8\n957 0 3 6\n458 8 0 7\n379 0 4 7", "1 2 1\n5 0 1 91\n1 1 0 87", "2 4 1\n1 1 0 88\n5 2 0 88\n3 0 1 46\n9 0 2 63", "3 6 1\n19 0 3 80\n11 0 2 32\n8 2 0 31\n4 0 1 45\n1 1 0 63\n15 3 0 76", "1 0 1", "5 0 1"], "outputs": ["24500", "-1", "11011", "1111", "23", "-1", "144", "300", "-1", "180", "370", "-1", "403", "473", "-1", "376", "328", "-1", "438", "9", "23", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "178", "-1", "-1", "-1", "-1"]}
UNKNOWN
PYTHON3
CODEFORCES
5
e5f49ec42951e7d7c45b82e1e5435575
Symmetric Projections
You are given a set of *n* points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines. Multiset is a set where equal elements are allowed. Multiset is called symmetric, if there is a point *P* on the plane such that the multiset is [centrally symmetric](https://en.wikipedia.org/wiki/Point_reflection) in respect of point *P*. The first line contains a single integer *n* (1<=≤<=*n*<=≤<=2000) — the number of points in the set. Each of the next *n* lines contains two integers *x**i* and *y**i* (<=-<=106<=<=≤<=<=*x**i*,<=<=*y**i*<=<=≤<=<=106) — the coordinates of the points. It is guaranteed that no two points coincide. If there are infinitely many good lines, print -1. Otherwise, print single integer — the number of good lines. Sample Input 3 1 2 2 1 3 3 2 4 3 1 2 Sample Output 3 -1
[ "from fractions import Fraction\r\nimport time\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 to_tuple(self):\r\n return (self.x, self.y)\r\n\r\n def __repr__(self):\r\n return \"Point({}, {})\".format(self.x, self.y)\r\n\r\n def __eq__(self, other):\r\n return self.to_tuple() == other.to_tuple()\r\n\r\n def __hash__(self):\r\n return hash(self.to_tuple())\r\n\r\n def __neg__(self):\r\n return Point(-self.x, -self.y)\r\n\r\n def __add__(self, other):\r\n return Point(self.x+other.x, self.y+other.y)\r\n\r\n def __sub__(self, other):\r\n return self+(-other)\r\n\r\n def scalar_mul(self, mu):\r\n return Point(mu*self.x, mu*self.y)\r\n\r\n def int_divide(self, den):\r\n return Point(self.x//den, self.y//den)\r\n\r\n\r\nclass Line:\r\n def __init__(self, a, b, c):\r\n # ax+by+c=0\r\n self.a = a\r\n self.b = b\r\n self.c = c\r\n\r\n def __repr__(self):\r\n return \"{}*x + {}*y + {} = 0\".format(self.a, self.b, self.c)\r\n\r\n @classmethod\r\n def between_two_points(cls, P, Q):\r\n return cls(P.y-Q.y, Q.x-P.x, P.x*Q.y-P.y*Q.x)\r\n\r\n def evaluate(self, P):\r\n return self.a*P.x+self.b*P.y+self.c\r\n\r\n def direction(self):\r\n if self.a == 0:\r\n return (0, 1)\r\n return (1, Fraction(self.b, self.a))\r\n\r\n\r\ntrue_start = time.time()\r\nn = int(input())\r\npoints = set()\r\ncenter = Point(0, 0)\r\nfor i in range(n):\r\n row = input().split(\" \")\r\n cur = Point(int(row[0]), int(row[1])).scalar_mul(2*n)\r\n center += cur\r\n points.add(cur)\r\n\r\ncenter = center.int_divide(n)\r\ndcenter = center+center\r\n\r\nsym_points_set = set()\r\nfor p in points:\r\n sym_points_set.add(dcenter-p)\r\nnosym = list(points - sym_points_set)\r\n\r\nif len(nosym) == 0:\r\n print(-1)\r\n exit(0)\r\n\r\n\r\ncnt = 0\r\np0 = nosym[0]\r\ngood_lines = set()\r\nfor p in nosym:\r\n m = (p+p0).int_divide(2)\r\n line = Line.between_two_points(m, center)\r\n distances = list(map(line.evaluate, nosym))\r\n\r\n ok = True\r\n mydict = {}\r\n for dd in distances:\r\n dda = abs(dd)\r\n if dda not in mydict:\r\n mydict[dda] = 1\r\n else:\r\n mydict[dda] += 1\r\n for k in mydict:\r\n if mydict[k] % 2 == 1 and k != 0:\r\n ok = False\r\n break\r\n if ok:\r\n good_lines.add(line.direction())\r\n\r\nprint(len(good_lines))\r\n" ]
{"inputs": ["3\n1 2\n2 1\n3 3", "2\n4 3\n1 2", "6\n0 4\n1 5\n2 1\n3 2\n4 3\n5 0", "1\n5 2", "4\n2 4\n1 2\n0 0\n-2 -4", "10\n0 5\n1 0\n2 3\n3 2\n4 6\n5 9\n6 1\n7 8\n8 4\n9 7", "9\n-1000000 -500000\n-750000 250000\n-500000 1000000\n-250000 -250000\n0 -1000000\n250000 750000\n500000 0\n750000 -750000\n1000000 500000", "10\n-84 -60\n-41 -100\n8 -8\n-52 -62\n-61 -76\n-52 -52\n14 -11\n-2 -54\n46 8\n26 -17", "5\n-1000000 -500000\n-500000 0\n0 500000\n500000 1000000\n1000000 -1000000", "6\n-100000 100000\n-60000 -20000\n-20000 20000\n20000 60000\n60000 -100000\n100000 -60000", "8\n-10000 4285\n-7143 -10000\n-4286 -1429\n-1429 -7143\n1428 1428\n4285 9999\n7142 7142\n9999 -4286", "10\n-1000000 -777778\n-777778 555554\n-555556 333332\n-333334 111110\n-111112 999998\n111110 -333334\n333332 -1000000\n555554 -555556\n777776 -111112\n999998 777776", "7\n14 -3\n2 -13\n12 -1\n10 -7\n8 -11\n4 -9\n6 -5", "24\n-1 -7\n-37 -45\n-1 -97\n-37 -25\n9 -107\n-47 -85\n-73 -43\n-73 -63\n9 -87\n-63 -3\n-47 -35\n-47 -15\n15 -39\n-11 -87\n-63 -73\n-17 -65\n-1 -77\n9 -17\n-53 -63\n-1 -27\n-63 -53\n-57 -25\n-11 3\n-11 -17", "8\n11 -3\n12 -5\n10 -6\n9 -4\n8 -8\n6 -7\n7 -10\n5 -9", "32\n16 37\n-26 41\n5 -6\n12 -5\n17 -30\n-31 -14\n-35 4\n-23 -20\n17 -20\n-25 34\n-33 40\n-32 33\n15 24\n22 -25\n-30 -21\n13 -12\n6 -13\n6 37\n-40 -1\n22 25\n16 17\n-16 21\n11 42\n11 32\n-26 21\n-35 -6\n12 -25\n23 18\n-21 16\n-24 -13\n-21 26\n-30 -1", "10\n-7 6\n-16 11\n-9 -5\n3 4\n-8 12\n-17 6\n2 -1\n-5 15\n-7 4\n-6 -2", "10\n-8 11\n1 10\n2 10\n2 11\n0 9\n3 12\n-7 16\n11 4\n4 8\n12 9", "10\n9 6\n8 1\n-10 13\n-11 8\n-1 6\n0 8\n-2 7\n-1 7\n1 17\n-3 -3", "20\n12 -3\n-18 -24\n-13 7\n17 -23\n15 11\n-17 5\n0 -26\n18 10\n12 -18\n-14 -26\n-20 -24\n16 4\n-19 -21\n-14 -11\n-15 -19\n-18 12\n16 10\n-2 12\n11 9\n13 -25", "50\n-38 -107\n-34 -75\n-200 -143\n-222 -139\n-34 55\n-102 -79\n48 -99\n2 -237\n-118 -167\n-56 -41\n10 17\n68 -89\n-32 41\n-100 -93\n84 -1\n86 -15\n46 -145\n-58 -117\n8 31\n-36 -61\n-12 21\n-116 79\n88 -205\n70 -103\n-78 -37\n106 -5\n-96 -201\n-60 -103\n-54 45\n-138 -177\n-178 -47\n-154 -5\n-138 83\n44 -131\n-76 -191\n-176 -61\n-14 -65\n-210 53\n-116 -181\n-74 -205\n-174 -15\n0 -223\n-136 69\n-198 -57\n-76 -51\n-152 -19\n-80 -83\n22 -227\n24 -141\n-220 -153", "6\n-10 -10\n-10 10\n10 10\n10 -10\n10 11\n10 -11"], "outputs": ["3", "-1", "5", "-1", "1", "5", "5", "0", "3", "5", "5", "3", "5", "2", "4", "3", "-1", "3", "3", "5", "7", "1"]}
UNKNOWN
PYTHON3
CODEFORCES
1
e5fd38f32e822cd47f7428b401223cab
none
Вам задано прямоугольное клетчатое поле, состоящее из *n* строк и *m* столбцов. Поле содержит цикл из символов «*», такой что: - цикл можно обойти, посетив каждую его клетку ровно один раз, перемещаясь каждый раз вверх/вниз/вправо/влево на одну клетку; - цикл не содержит самопересечений и самокасаний, то есть две клетки цикла соседствуют по стороне тогда и только тогда, когда они соседние при перемещении вдоль цикла (самокасание по углу тоже запрещено). Ниже изображены несколько примеров допустимых циклов: Все клетки поля, отличные от цикла, содержат символ «.». Цикл на поле ровно один. Посещать клетки, отличные от цикла, Роботу нельзя. В одной из клеток цикла находится Робот. Эта клетка помечена символом «S». Найдите последовательность команд для Робота, чтобы обойти цикл. Каждая из четырёх возможных команд кодируется буквой и обозначает перемещение Робота на одну клетку: - «U» — сдвинуться на клетку вверх, - «R» — сдвинуться на клетку вправо, - «D» — сдвинуться на клетку вниз, - «L» — сдвинуться на клетку влево. Робот должен обойти цикл, побывав в каждой его клетке ровно один раз (кроме стартовой точки — в ней он начинает и заканчивает свой путь). Найдите искомую последовательность команд, допускается любое направление обхода цикла. В первой строке входных данных записаны два целых числа *n* и *m* (3<=≤<=*n*,<=*m*<=≤<=100) — количество строк и столбцов прямоугольного клетчатого поля соответственно. В следующих *n* строках записаны по *m* символов, каждый из которых — «.», «*» или «S». Гарантируется, что отличные от «.» символы образуют цикл без самопересечений и самокасаний. Также гарантируется, что на поле ровно одна клетка содержит «S» и что она принадлежит циклу. Робот не может посещать клетки, помеченные символом «.». В первую строку выходных данных выведите искомую последовательность команд для Робота. Направление обхода цикла Роботом может быть любым. Sample Input 3 3 *** *.* *S* 6 7 .***... .*.*... .*.S**. .*...** .*....* .****** Sample Output LUURRDDL UULLDDDDDRRRRRUULULL
[ "n, m = map(int, input().split())\r\nA = ['#'*(m+2)]\r\nfor i in range(1, n+1):\r\n B = ['#'] + list(input()) + ['#']\r\n A.append(B)\r\n if 'S' in B:\r\n C = [i, B.index('S')]\r\nA.append('#'*(m+2))\r\nN = C.copy()\r\nq = 'L'\r\nsh = 0\r\nwhile sh==0 or N!=C:\r\n sh+=1\r\n if (A[N[0]-1][N[1]]=='*' or A[N[0]-1][N[1]]=='S') and q!='D':\r\n N[0]-=1\r\n print('U', end='')\r\n q = 'U'\r\n elif (A[N[0]+1][N[1]]=='*' or A[N[0]+1][N[1]]=='S') and q!='U':\r\n N[0]+=1\r\n print('D', end='')\r\n q = 'D' \r\n elif (A[N[0]][N[1]-1]=='*' or A[N[0]][N[1]-1]=='S') and q!='R':\r\n N[1]-=1\r\n print('L', end='')\r\n q = 'L' \r\n elif (A[N[0]][N[1]+1]=='*' or A[N[0]][N[1]+1]=='S') and q!='L':\r\n N[1]+=1\r\n print('R', end='')\r\n q = 'R' ", "import sys\nsys.setrecursionlimit(1000000)\n\n\ndef dfs(y, x, k, dr=None):\n if k[y][x] == 'S' and dr != None:\n return 1, ' '\n for a, b, d, d2 in ((0, 1, 'D', 'U'), (1, 0, 'R', 'L'), (0, -1, 'U', 'D'), (-1, 0, 'L', 'R')):\n if k[y + b][x + a] in '*S' and dr != d2:\n bl, w = dfs(y + b, x + a, k, d)\n if bl:\n return 1, d + w\n\n\nh, w = map(int, input().split())\nk = ['.' * (w + 2)]\nfor i in range(1, h + 1):\n k.append('.' + input() + '.')\n u = k[-1].find('S')\n if u != -1:\n pos = [i, u]\nk.append('.' * (w + 2))\nprint(dfs(pos[0], pos[1], k)[1])", "from copy import deepcopy\r\n\r\nn, m = map(int, input().split())\r\npole = []\r\nx, y = 0, 0\r\ncount = 0\r\nfor i in range(n):\r\n s = input()\r\n pole.append(s)\r\n for j in range(len(s)):\r\n if s[j] == '*':\r\n count += 1\r\n if s[j] == 'S':\r\n x = i\r\n y = j\r\n\r\nX = [0, -1, 0, 1] \r\nY = [-1, 0, 1, 0]\r\n\r\nd = dict()\r\nd[0] = 'L'\r\nd[1] = 'U'\r\nd[2] = 'R'\r\nd[3] = 'D'\r\n\r\nprevx, prevy = -1, -1\r\n\r\nxbegin, ybegin = deepcopy(x), deepcopy(y)\r\ns = ''\r\nnow = 0\r\nfor i in range(n):\r\n for j in range(m):\r\n for u in range(4):\r\n if x + X[u] >= 0 and x + X[u] < n and y + Y[u] >= 0 and y + Y[u] < m:\r\n if pole[x + X[u]][y + Y[u]] == '*' and (x + X[u] != prevx or y + Y[u] != prevy):\r\n prevx, prevy = deepcopy(x), deepcopy(y)\r\n x += X[u]\r\n y += Y[u]\r\n s += d[u]\r\n count -= 1\r\n break\r\n if count == -1:\r\n break\r\n if count == -1:\r\n break\r\nif x - 1 >= 0 and pole[x - 1][y] == 'S':\r\n s += 'U'\r\nif x + 1 < n and pole[x + 1][y] == 'S':\r\n s += 'D'\r\nif y - 1 >= 0 and pole[x][y - 1] == 'S':\r\n s += 'L'\r\nif y + 1 < m and pole[x][y + 1] == 'S':\r\n s += 'R'\r\nprint(s)\r\n\r\n \r\n", "s = input().split()\r\nn = int(s[0])\r\nm = int(s[1])\r\na = []\r\nx = 0\r\ny = 0\r\nb = [0]\r\nfor i in range(n):\r\n a.append(input())\r\nfor i in range(len(a)):\r\n for j in range(m):\r\n if a[i][j] == 'S':\r\n y = j\r\n x = i\r\nfor i in range(n):\r\n for j in range(m):\r\n if (y+1) < m:\r\n if a[x][y+1] == '*' and b[-1] != 'L':\r\n b.append('R')\r\n if a[x][y] != 'S':\r\n a[x] = a[x][:y+1] + '.' + a[x][y+2:]\r\n else:\r\n a[x] = a[x][:y] + '*' + a[x][y+1:]\r\n y = y+1\r\n if (y-1) > -1:\r\n if a[x][y-1] == '*' and b[-1] != 'R':\r\n b.append('L')\r\n if a[x][y] != 'S':\r\n a[x] = a[x][:y-1] + '.' + a[x][y:]\r\n else:\r\n a[x] = a[x][:y] + '*' + a[x][y+1:]\r\n y = y-1\r\n if (x+1) < n:\r\n if a[x+1][y] == '*' and b[-1] != 'U':\r\n b.append('D')\r\n if a[x][y] != 'S':\r\n a[x+1] = a[x+1][:y] + '.' + a[x+1][y+1:]\r\n else:\r\n a[x] = a[x][:y] + '*' + a[x][y+1:]\r\n x = x+1\r\n if (x-1) > -1:\r\n if a[x-1][y] == '*' and b[-1] != 'D':\r\n b.append('U')\r\n if a[x][y] != 'S':\r\n a[x-1] = a[x-1][:y] + '.' + a[x-1][y+1:]\r\n else:\r\n a[x] = a[x][:y] + '*' + a[x][y+1:]\r\n x = x-1\r\ndel b[0]\r\ndel b[-1]\r\nprint(''.join(b))\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n", "n,m = map(int, input().split())\r\nA = [0] * n\r\nfor i in range(n):\r\n A[i] = input()\r\n for j in range(m):\r\n if A[i][j] == 'S':\r\n per1,per2 = i,j\r\n \r\nt1, t2 = per1, per2\r\nend1,end2 = per1,per2\r\nwhile True:\r\n \r\n \r\n if per1 > 0 and (t1 != per1 - 1 or t2 != per2) and (A[per1-1][per2] == '*' or A[per1-1][per2] == 'S'):\r\n t1 = per1\r\n t2 =per2\r\n per1 -=1\r\n print('U', end ='')\r\n elif per1 < n-1 and (t1 != per1 + 1 or t2!= per2) and (A[per1+1][per2] == '*' or A[per1+1][per2] == 'S'):\r\n t1 = per1\r\n t2 = per2\r\n per1 += 1\r\n print('D', end ='')\r\n elif per2 > 0 and (t1!=per1 or t2 !=per2 - 1) and (A[per1][per2-1] == '*' or A[per1][per2-1] == 'S'):\r\n t1 = per1\r\n t2 = per2\r\n per2 -=1\r\n print('L', end ='')\r\n elif per2 < m -1 and (t1!= per1 or t2 != per2+1) and (A[per1][per2+1] == '*' or A[per1][per2+1] == 'S'):\r\n t1 = per1\r\n t2 = per2\r\n per2 += 1\r\n print('R', end ='')\r\n if end1 == per1 and end2 == per2:\r\n break\r\n \r\n \r\n", "n=list(map(int, input().split()))\r\na=[0]*(n[0]+2)\r\ns=[]\r\ni1=0\r\nj1=0\r\nt=0\r\nf=''\r\nfor i in range(1,n[0]+1):\r\n l='.'+input()+'.'\r\n a[i]=list(l)\r\n if 'S' in a[i]:\r\n for j in range(len(a[i])):\r\n if a[i][j]=='S':\r\n i1=i\r\n j1=j\r\n break\r\na[0]=list('.'*(n[1]+2))\r\na[n[0]+1]=list('.'*(n[1]+2))\r\ni2=i1+1\r\nj2=j1+1\r\nwhile i2!=i1 or j2!=j1:\r\n t+=1\r\n if t==1:\r\n i2-=1\r\n j2-=1\r\n if t==3:\r\n a[i1].insert(j1,'*')\r\n del(a[i1][j1+1])\r\n if a[i2][j2-1]=='*':\r\n a[i2][j2-1]='.'\r\n j2=j2-1\r\n s.append('L')\r\n continue\r\n elif a[i2][j2+1]=='*':\r\n a[i2][j2+1]='.'\r\n j2=j2+1\r\n s.append('R')\r\n continue\r\n elif a[i2-1][j2]=='*':\r\n a[i2-1][j2]='.'\r\n i2=i2-1\r\n s.append('U')\r\n continue\r\n elif a[i2+1][j2]=='*':\r\n a[i2+1][j2]='.'\r\n i2=i2+1\r\n s.append('D')\r\n continue\r\nfor i in range(len(s)):\r\n f+=s[i]\r\nprint(f)\r\n", "from collections import deque\r\nss = 4\r\nstep = [(0, 1, 'R'), (0, -1, 'L'), (1, 0, 'D'), (-1, 0, 'U')]\r\nn, m = map(int, input().split())\r\nmaps = []\r\nqueue = deque()\r\nvisit = [[0 for i in range(m)] for j in range(n)]\r\nfor i in range(n):\r\n maps.append(input())\r\n if maps[-1].count('S'):\r\n queue.append((i, maps[-1].index('S')))\r\n\r\nwhile queue:\r\n string, column = queue.popleft()\r\n visit[string][column] = 1\r\n for i in range(ss):\r\n if (string + step[i][0] >= 0) and (string + step[i][0] < n) and (column + step[i][1] >= 0) and (column + step[i][1] < m) and not visit[string + step[i][0]][column + step[i][1]] and (maps[string + step[i][0]][column + step[i][1]] == '*'):\r\n queue.append((string + step[i][0], column + step[i][1]))\r\n print(step[i][-1], end = '')\r\n break\r\n\r\nfor i in range(ss):\r\n if (string + step[i][0] >= 0) and (string + step[i][0] < n) and (column + step[i][1] >= 0) and (column + step[i][1] < m) and maps[string + step[i][0]][column + step[i][1]] == 'S':\r\n print(step[i][-1])", "from copy import *\r\ndef finds(r):\r\n\tfor i in range(len(r)):\r\n\t\tfor j in range(len(r[0])):\r\n\t\t\tif r[i][j]=='S':\r\n\t\t\t\treturn i,j\r\n\r\nn,m=(int(z) for z in input().split())\r\nr=[]\r\nfor i in range(n):\r\n\ts=input()\r\n\tr.append(s)\r\nx,y=finds(r)\r\nk=1\r\nq,w=x,y\r\ne,t=x,y\r\nwhile k!=0:\r\n\tif q!=n-1 and e!=q+1 and r[q+1][w]=='*':\r\n\t\tprint('D',end='')\r\n\t\tq,w,e,t=q+1,w,q,w\r\n\telif q!=0 and e!=q-1 and r[q-1][w]=='*':\r\n\t\tprint('U',end='')\r\n\t\tq,w,e,t=q-1,w,q,w\r\n\telif w!=0 and t!=w-1 and r[q][w-1]=='*':\r\n\t\tprint('L',end='')\r\n\t\tq,w,e,t=q,w-1,q,w\r\n\telif w!=m-1 and t!=w+1 and r[q][w+1]=='*':\r\n\t\tprint('R',end='')\r\n\t\tq,w,e,t=q,w+1,q,w\r\n\telse:\r\n\t\tk=0\r\nif q>x:\r\n\tprint('U')\r\nif q<x:\r\n\tprint('D')\r\nif w>y:\r\n\tprint('L')\r\nif w<y:\r\n\tprint('R')", "\r\ndef getVertexByIndex(i):\r\n if(i==0):\r\n return \"L\"\r\n if(i==1):\r\n return \"R\"\r\n if(i==2):\r\n return \"U\"\r\n if(i==3):\r\n return \"D\"\r\n\r\n\r\ndef getDeltaX(i):\r\n if(i==\"L\"):\r\n return int(-1)\r\n if(i==\"R\"):\r\n return int(1)\r\n else:\r\n return int(0)\r\n\r\n\r\n\r\ndef getDeltaY(i):\r\n if(i==\"U\"):\r\n return int(-1)\r\n if(i==\"D\"):\r\n return int(1)\r\n else:\r\n return int(0)\r\n\r\n\r\ndef getInvert(i):\r\n if(i==\"U\"):\r\n return \"D\"\r\n if(i==\"D\"):\r\n return \"U\"\r\n if(i==\"L\"):\r\n return \"R\"\r\n if(i==\"R\"):\r\n return \"L\"\r\n else:\r\n return \" \"\r\n\r\ndef getWay(x,y,old,MAP):\r\n dx=[-1,1,0,0]\r\n dy=[0,0,-1,1]\r\n #лево право вверх вниз\r\n\r\n for i in range(4):\r\n if 0<=int(y+dy[i])<len(MAP) and 0<=int(x+dx[i])<len(MAP[0])and (MAP[y+dy[i]][x+dx[i]]==\"*\") and getVertexByIndex(i)!=getInvert(old):\r\n return getVertexByIndex(i)\r\n return \"S\"\r\n\r\n\r\ndef searchStart(x,y,MAP):\r\n dx=[-1,1,0,0]\r\n dy=[0,0,-1,1]\r\n #лево право вверх вниз\r\n\r\n for i in range(4):\r\n if 0<=int(y+dy[i])<len(MAP) and 0<=int(x+dx[i])<len(MAP[0])and (MAP[y+dy[i]][x+dx[i]]==\"S\"):\r\n return getVertexByIndex(i)\r\n\r\ninStr = input()\r\nn,m=inStr.split()\r\n#n строк по m символов в каждой\r\nmymap=[]\r\nstartX=0\r\nstartY=0\r\n\r\nthisX=0\r\nthisY=0\r\n\r\nway = \"\"\r\n\r\nfor i in range(int(n)):\r\n inStr = input()\r\n\r\n if(inStr.find('S')!=-1):\r\n startX=inStr.find('S')\r\n startY=i\r\n \r\n \r\n mymap+=[inStr]\r\n\r\n\r\n\r\n\r\nthisX=startX\r\nthisY=startY\r\n\r\n#print(startX,startY)\r\n\r\nway+=getWay(startX,startY,\" \",mymap)\r\n\r\nthisX+=getDeltaX(way[len(way)-1])\r\nthisY+=getDeltaY(way[len(way)-1])\r\n\r\nwhile (startX!=thisX) or (startY!=thisY):\r\n way+=getWay(thisX,thisY,way[len(way)-1],mymap)\r\n if(way[len(way)-1]==\"S\"):\r\n way=way[0:-1]\r\n way+=searchStart(thisX,thisY,mymap);\r\n break;\r\n thisX+=getDeltaX(way[len(way)-1])\r\n thisY+=getDeltaY(way[len(way)-1])\r\n #print(way)\r\nprint(way)\r\n\r\n\r\n\r\n", "x, y = map(int, input().split())\r\nar = []\r\n\r\nsx, xy = 0, 0\r\n\r\nfor i in range(x):\r\n\tar.append(list(input()))\r\n\tif 'S' in ar[-1]:\r\n\t\tsx = i\r\n\t\tsy = ar[-1].index('S')\r\n\r\n\r\ndone = False\r\nnowx, nowy = sx, sy\r\nlastx, lasty = sx, sy\r\n\r\nwhile (nowx, nowy) != (sx, sy) or not done:\r\n\tdone = True\r\n\thp = 'RLUD'\r\n\tu = [(0, 1), (0, -1), (-1, 0), (1, 0)]\r\n\r\n\tfor key, p in enumerate(u):\r\n\t\tpx, py = p\r\n\t\tif (nowx + px, nowy+py) != (lastx, lasty) and 0 <= nowx + px < x and 0 <= nowy + py < y and ar[nowx+px][nowy+py] in 'S*':\r\n\t\t\tlastx, lasty = nowx, nowy\r\n\t\t\tnowx, nowy = nowx + px, nowy + py\r\n\t\t\tprint(hp[key], end='')\r\n\t\t\tbreak\r\n\r\n", "height, width = list(map(lambda x: int(x), input().split()))\nmaze = []\nfor _ in range(height):\n\tmaze.append(list(input()))\n\npos = []\n\nfor y in range(height):\n\tfor x in range(width):\n\t\tif maze[y][x] == \"S\":\n\t\t\tpos = [y,x]\n\nways = [((1,0), \"D\"), ((0,1), \"R\"), ((-1,0), \"U\"), ((0, -1), \"L\")]\n\nthereIsWhereToGo = True\nturns = \"\"\nwhile thereIsWhereToGo:\n\t#for x in maze: print(x)\n\t#print(pos)\n\tfor way in ways:\n\t\ty = pos[0] + way[0][0]\n\t\tx = pos[1] + way[0][1]\n\n\t\tif y < height and y >= 0 and x < width and x >= 0 and maze[y][x] ==\"*\":\n\t\t\tmaze[y][x] = \".\"\n\t\t\tpos = [y,x]\n\t\t\tturns = turns + way[1]\n\t\t\tbreak\n\telse:\n\t\tthereIsWhereToGo = False\n\nfor way in ways:\n\ty = pos[0] + way[0][0]\n\tx = pos[1] + way[0][1]\n\n\tif y < height and y >= 0 and x < width and x >= 0 and maze[y][x] ==\"S\":\n\t\tpos = [y,x]\n\t\tturns = turns + way[1]\n\t\tbreak\n\nprint(turns)", "y, x = map(int, input().split())\r\nm = ['.'*(x+2)]\r\ne = ''\r\ntry:\r\n for i in range(y):\r\n m.append('.'+input()+'.')\r\n a = m[i+1].find('S')\r\n if a != -1:\r\n b = [i+1, a]\r\nexcept:\r\n pass\r\nm.append('.'*(x+2))\r\na = [b[0], b[1]]\r\nif m[a[0]-1][a[1]] == '*':\r\n e += ('U')\r\n a = [(a[0]-1), a[1]]\r\nelif m[a[0]][a[1]-1] == '*':\r\n e += ('L')\r\n a = [a[0], a[1]-1]\r\nelif m[a[0]+1][a[1]] == '*':\r\n e += 'D'\r\n a = [a[0]+1, a[1]]\r\nelse:\r\n e += 'R'\r\n a = [a[0], a[1]+1]\r\nwhile a != b:\r\n if ((m[a[0]-1][a[1]] == '*') or (m[a[0]-1][a[1]] == 'S')) and e[-1] != 'D':\r\n e += ('U')\r\n a = [(a[0]-1), a[1]]\r\n elif ((m[a[0]][a[1]-1] == '*') or (m[a[0]][a[1]-1] == 'S')) and e[-1] != 'R':\r\n e += ('L')\r\n a = [a[0], a[1]-1]\r\n elif ((m[a[0]+1][a[1]] == '*') or (m[a[0]+1][a[1]] == 'S')) and e[-1] != 'U':\r\n e += 'D'\r\n a = [(a[0]+1), a[1]]\r\n else:\r\n e += 'R'\r\n a = [a[0], a[1]+1]\r\nprint(e)\r\n", "n, m = map(int, input().split())\r\na = [list(input()) for i in range(n)]\r\nwas = [[False] * m for i in range(n)]\r\nx, y = 0, 0\r\ncnt = 0\r\nfor i in range(n):\r\n if 'S' in a[i]:\r\n x, y = i, a[i].index('S')\r\n a[x][y] = '*'\r\n for j in range(m):\r\n cnt += int(a[i][j] == '*')\r\nans = []\r\nsx, sy = x, y\r\nwas[x][y] = True\r\nwhile cnt:\r\n for dx, dy in ((0, -1), (0, 1), (-1, 0), (1, 0)):\r\n nx, ny = x + dx, y + dy\r\n if 0 <= nx < n and 0 <= ny < m and not was[nx][ny] and a[nx][ny] == '*':\r\n x, y = nx, ny\r\n cur = 0\r\n if (dx, dy) == (0, -1): cur = 'L'\r\n if (dx, dy) == (0, 1): cur = 'R'\r\n if (dx, dy) == (-1, 0): cur = 'U'\r\n if (dx, dy) == (1, 0): cur = 'D'\r\n ans.append(cur)\r\n was[nx][ny] = 1\r\n break\r\n cnt -= 1\r\ndx, dy = sx - x, sy - y\r\nif (dx, dy) == (0, -1): cur = 'L'\r\nif (dx, dy) == (0, 1): cur = 'R'\r\nif (dx, dy) == (-1, 0): cur = 'U'\r\nif (dx, dy) == (1, 0): cur = 'D'\r\nans.append(cur)\r\nprint(''.join(map(str, ans)))" ]
{"inputs": ["3 3\n***\n*.*\n*S*", "6 7\n.***...\n.*.*...\n.*.S**.\n.*...**\n.*....*\n.******", "100 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*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\nS.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n*.*\n***", "3 100\n****************************************************************************************************\n*..................................................................................................*\n**********************************************************************************S*****************"], "outputs": ["LUURRDDL", "UULLDDDDDRRRRRUULULL", "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUURRDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDLLUUUUUUUUUUUUUUUUUU", "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLUURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRDDLLLLLLLLLLLLLLLLL"]}
UNKNOWN
PYTHON3
CODEFORCES
13
e60b3cbd2c86af1239ce62fe75b31479
Pizza, Pizza, Pizza!!!
Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems. Today is Shiro's birthday. She really loves pizza so she wants to invite her friends to the pizza restaurant near her house to celebrate her birthday, including her best friends Katie and Kuro. She has ordered a very big round pizza, in order to serve her many friends. Exactly $n$ of Shiro's friends are here. That's why she has to divide the pizza into $n + 1$ slices (Shiro also needs to eat). She wants the slices to be exactly the same size and shape. If not, some of her friends will get mad and go home early, and the party will be over. Shiro is now hungry. She wants to cut the pizza with minimum of straight cuts. A cut is a straight segment, it might have ends inside or outside the pizza. But she is too lazy to pick up the calculator. As usual, she will ask Katie and Kuro for help. But they haven't come yet. Could you help Shiro with this problem? A single line contains one non-negative integer $n$ ($0 \le n \leq 10^{18}$) — the number of Shiro's friends. The circular pizza has to be sliced into $n + 1$ pieces. A single integer — the number of straight cuts Shiro needs. Sample Input 3 4 Sample Output 25
[ "x=int(input())\r\nprint( 0 if x==0 else (x+1)//2 if (x+1)%2==0 else x+1 )\r\n\r\n\r\n# My code says who am i\r\n# red is love\r\n# love is not in logic\r\n\r\n", "n=int(input())\nif n==0:\n print(0)\nelse:\n if (n+1)%2==0:\n print((n+1)//2)\n else:\n print((n + 1))\n \t\t \t\t \t \t \t\t\t\t\t\t \t\t\t \t\t\t", "n = int(input())\nif n == 0:\n print(0)\nelif (n+1) % 2 == 1:\n print(n+1)\nelse:\n print((n+1)//2)", "t=int(input())\r\nif (t+1)%2==0 and t!=0:\r\n print((t+1)//2)\r\nelif (t+1)%2!=0 and t!=0:\r\n print(t+1)\r\nelse:\r\n print('0')", "n = int(input())\r\nn = n + 1\r\nif(n==1): \r\n res = 0\r\nelif(n%2==0):\r\n res = n // 2\r\nelse: \r\n res = n\r\nprint(res)", "n=int(input())\nif((n+1)%2==0):\n\tprint((n+1)//2)\nelif(n==0):\n\tprint(0)\nelse:\n\tprint(n+1)\n", "n = int(input())\r\nif n==0:print(0)\r\nelif (n+1)%2==0:\r\n\tprint((n+1)//2)\r\nelse:print(n+1)\t", "n=int(input())+1\r\nn-=int(n==1)\r\nprint(n//(2-(n%2)))", "a = int(int(input()) + 1)\nif a == 1:\n print(0)\nelif a % 2 == 0:\n print(a//2)\nelse:\n print(a)", "N = int(input())\r\nprint(0 if N == 0 else (N + 1 if N % 2 == 0 else (N + 1) // 2))\r\n", "from sys import stdin, stdout\r\n\r\nn = int(stdin.readline())\r\nif n == 0:\r\n stdout.write('0')\r\nelif (n + 1) % 2 == 0:\r\n result = (n + 1) // 2\r\n stdout.write(str(result))\r\nelse:\r\n result = n + 1\r\n stdout.write(str(result))", "x=int(input())\r\nif((x+1)%2==0):\r\n print((x+1)//2)\r\nelif(x==0):\r\n print(0)\r\nelse:\r\n print(x+1)", "from bisect import bisect_left, bisect_right\r\n\r\ndef tuple_input(type):\r\n return map(type, input().strip().split())\r\n\r\nn = int(input())\r\nif n == 0:\r\n print('0')\r\nelse: \r\n if (n + 1) % 2 == 0:\r\n print((n + 1) // 2)\r\n else:\r\n print(n + 1)", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn = int(input())\r\nprint((n+1)//2 if n % 2 == 1 else 0 if n == 0 else n+1)\r\n", "n = int(input())\n\nif n == 0:\n print(0)\nelif n % 2 == 0:\n print(n+1)\nelse:\n print((n+1)//2)\n\t \t \t \t\t\t \t \t\t \t \t\t\t\t \t \t", "n=int(input())\r\nprint((n+1)//2 if n%2 else 0 if n==0 else n+1)", "# LUOGU_RID: 117687698\nx = input()\r\ny = int(x)+1\r\nif y == 1 :\r\n print( \"0\" )\r\nelif y % 2 == 0 :\r\n print(y // 2)\r\nelif y%2!=0 : \r\n print( y )", "n = int(input()) + 1\r\nprint(n // 2 if n % 2 == 0 else n if n != 1 else 0)\r\n", "n = int(input()) + 1\nres = 0 if n == 1 else n // 2 if n & 1 == 0 else n\nprint(res)\n", "import sys\r\n\r\nn = int(sys.stdin.read())\r\nm = n + 1\r\nif m == 1:\r\n print(0)\r\nelif m%2 == 0:\r\n print(m//2)\r\nelse:\r\n print(m)", "n = int(input())\r\nif n == 0:\r\n ans = 0\r\nelif n % 2 == 1:\r\n ans = (n + 1) // 2\r\nelse:\r\n ans = n + 1\r\nprint(ans)\r\n\r\n", "n=int(input())+1\r\nprint(0) if n==1 else print([int(n//2),n][n%2])", "x = int(input()) + 1\r\n\r\nif x == 1: print(0)\r\nelif x % 2 == 0: print(x // 2)\r\nelse: print(x)", "x=int(input())\nif x%2==0 and x!=0:\n print(x+1)\nelse:\n if x%2!=0 or x==0:\n print((x+1)//2)\n \t\t\t \t \t\t\t\t \t \t\t \t", "\r\nn=int(input())+1\r\n\r\nif n%2==0:\r\n print(n//2)\r\nelif n==1:\r\n print(0)\r\nelse:\r\n print(n)\r\n", "n=int(input())\r\nif n==0:\r\n print(0)\r\nelif n%2==1:\r\n n+=1\r\n print(n//2)\r\nelse:\r\n print(n+1)", "n = int(input()) + 1\nprint([n//2, n][n % 2 and n != 1])", "n=int(input())\r\nn+=1\r\n\r\nif n%2==0 or n==1:\r\n\tprint(n//2)\r\nelse:\r\n\tprint(n)", "friends = int(input())\r\nif (friends == 0):\r\n print(0)\r\nelif (friends == 1):\r\n print(1)\r\nelif (friends % 2 == 0):\r\n print(friends+1)\r\nelse:\r\n print((friends+1)//2)", "n=int(input())\r\nn+=(n>1)\r\nprint(n//(2-(n%2)))", "a = int(input())\r\nif a==0:\r\n print(0)\r\nelse:\r\n if (a+1)%2 == 1:\r\n print(a+1)\r\n else:\r\n print((a+1)//2)", "import math\r\nimport os\r\nimport random\r\nimport re\r\nimport sys\r\nif __name__ == '__main__':\r\n n=int(input())\r\n if(n==0):\r\n print(\"0\")\r\n elif((n+1)%2==0):\r\n print((n+1)//2)\r\n else:\r\n print((n+1))\r\n", "n=int(input())\r\nx=n+1\r\nif(x==1):\r\n\tprint(0)\r\nelse:\r\n\tif(x%2==0):\r\n\t\tprint(x//2)\r\n\telse:\r\n\t\tprint(x)", "n = int(input())\r\nif n ==0:print(n)\r\nelif (n+1)%2==0:print((n+1)//2)\r\nelse: print(n+1)", "n = int(input()) + 1\nif n == 1:\n print(0)\nelif n % 2 == 0:\n print(n//2)\nelse:\n print(n)\n\t \t\t\t\t\t\t \t\t\t\t \t\t \t\t \t\t", "def pizza(num):\r\n\tif num == 0:\r\n\t\treturn 0\r\n\tif (num + 1) % 2 == 0:\r\n\t\treturn (num + 1) // 2\r\n\telse:\r\n\t\treturn num + 1\r\nn = int(input())\r\nprint(pizza(n))", "n = int(input())\r\nif n==0:\r\n\tprint(0)\r\nelse:\r\n\tprint([(n+1)//2,n+1][(n+1)%2])", "n = int(input()) + 1\r\nprint((n // 2, (0, n)[n > 1])[n % 2])", "a = input()\r\nb = int(a)\r\nif ((b+1)% 2 == 0):\r\n print(((b+1)//2))\r\nelif (b == 0):\r\n print(0)\r\nelse:\r\n print(b+1)\r\n", "n = int(input()) + 1\r\nprint((n // 2, n)[n % 2 and n > 1])", "n = int(input())\r\nm = n + 1\r\nif m == 1:\r\n print(0)\r\nelse:\r\n if m % 2 == 0:\r\n print(m//2)\r\n else:\r\n print(m)", "n = int(input())\r\nn = n + 1\r\nif n<2:\r\n print(0)\r\n\r\nelif n&1:\r\n print(n)\r\nelse:\r\n print(n>>1)", "n = int(input()) + 1\r\nprint(0 if n == 1 else (n if n % 2 == 1 else n // 2))\r\n", "n=int(input())\r\nif (n+1)%2==0:\r\n\tprint((n+1)//2)\r\nelif n==0:\r\n\tprint(0)\r\nelse:\r\n\tprint(n+1)", "n = int(input())\r\nif n>0:\r\n if (n+1)%2==0:\r\n print((n+1)//2)\r\n else:print(n+1)\r\nelse:print(n)\r\n", "n = int(input())\ncut = 0\nn += 1\n\nif(n % 2 == 0):\n cut = n//2\nelif(n == 1):\n cut = 0\nelse:\n cut = n\n\nprint(cut)\n\n\t\t\t \t\t\t\t \t \t\t\t \t \t\t\t\t \t\t\t\t\t", "n=int(input())\nif n==0:\n print(0)\nelse:\n n+=1\n if n%2==0: print(n//2)\n else: print(n)", "n = int(input())\nm = n+1\nif m==1:\n print(0)\nelif m%2==0:\n print(m//2)\nelse:\n print(m)\n\n \t \t \t\t \t\t\t \t \t \t \t \t\t", "n=int(input())\r\nif(n==0):\r\n print(n)\r\nelse:\r\n t=n+1\r\n if(t%2==0):\r\n print(t//2)\r\n else:\r\n print(t)", "n = int(input())\r\nprint(0 if n == 0 else ((n + 1) // 2 if n & 1 else n + 1))", "n=int(input())\r\nif n==0:\r\n\tprint('0')\r\n\texit()\r\nprint([n+1,(n//2)+1][n%2==1])", "a=int(input())\r\na=a+1\r\nif a%2==0:\r\n print(a//2)\r\nelif a==1 or a==0:\r\n print(0)\r\nelse:\r\n print(a)\r\n", "n=int(input())\r\ns=n+1\r\nif(n==0):\r\n print(0)\r\nelse:\r\n if(s%2==0):\r\n print(s//2)\r\n else:\r\n print(s)", "\r\n\r\nn = int(input())\r\nif (n==0):\r\n print(0)\r\n exit()\r\n\r\nif n%2:\r\n print(n//2+1)\r\n\r\nelse:\r\n print(n+1)\r\n\r\n\r\n", "import sys\r\n\r\n\r\nn = int(sys.stdin.readline().strip()) + 1\r\nif n - 1 == 0:\r\n print(0)\r\nelif n % 2 == 0:\r\n print(n//2)\r\nelse:\r\n print(n)\r\n", "n=int(input())+1\r\nif n==1: print(0)\r\nelse: print(n if n%2==1 else n//2)", "n=int(input())\r\n\r\nif n==0:\r\n print(\"0\")\r\n exit(0)\r\n\r\nn+=1\r\n\r\nif n%2==0:\r\n print(n//2)\r\n\r\nelse:\r\n print(n)", "# pizza\r\n\r\ndata = input()\r\nn = int(data) + 1\r\ns = None\r\n\r\nif n == 1:\r\n s = 0\r\nelif n % 2 == 1:\r\n s = n\r\nelse:\r\n s = n // 2\r\n\r\nprint(s)", "n = int(input())\r\nif n == 0: \r\n print(0)\r\n exit(0)\r\nprint([n//2 + 1, n + 1][n%2==0])", "def stuff(n):\r\n n=n+1\r\n if n-1==0:\r\n return(0)\r\n elif n%2==0:\r\n return(n//2)\r\n else:\r\n return(n)\r\nprint(stuff(int(input())))", "n=int(input())+1\r\nprint('0'if n==1 else n if n%2 else n//2)", "n=int(input())\r\nif n==0:\r\n print(0)\r\nelse:\r\n p=n+1\r\n if p%2==0:\r\n print(p//2)\r\n else:\r\n print(p)", "n = int(input())\r\n\r\nif n == 0 : print(0)\r\nelif (n + 1) % 2 == 0 : print((n + 1) // 2 )\r\nelse:print(n + 1 )\r\n\r\n", "t = int(input())\r\nt +=1\r\nif t == 1 :\r\n print('0')\r\nelif t % 2 == 0 :\r\n print(int (t // 2 ) )\r\nelse :\r\n print( t ) ", "# A. Pizza, Pizza, Pizza!!!\nn = int(input())\nn += 1 # yo tambien como puchas xD\nprint('0' if (n == 1) else (n//2) if (n % 2 == 0) else (n))\n", "a=int(input())\r\nif a==0:print(0)\r\nelif a%2==0:print(a+1)\r\nelse:print((a+1)//2)", "n=int(input())\r\nif n==0:print(0)\r\nelif n==1:print(1)\r\nelse:\r\n if n%2==0:print(n+1)\r\n else:print((n+1)//2)", "n=int(input())\r\nif n!=0:\r\n n+=1\r\nif n%2:\r\n print(n)\r\nelse:\r\n print(n//2)", "n=int(input())\r\nn+=1\r\nif(n==1):print(0)\r\nelif n%2==0:print(n//2)\r\nelse :print(n)", "n = int(input())\r\nif (n+1)%2==0 and n>0:\r\n print((n+1)//2)\r\nelif (n+1)%2==1 and n>0:\r\n print(n+1)\r\nelse:\r\n print(0)\r\n", "n = int(input())\nif n==0:\n\tprint(0)\nelif n%2:\n\tprint((n+1)//2)\nelse:\n\tprint(n+1)", "n = int(input())\r\nn+=1\r\nif(n==1): print(0)\r\nelif(n&1): print(n)\r\nelse: print(n//2)", "A = int(input())\r\na = (A+1)\r\nif A== 0:\r\n print(0)\r\nelif a%2 == 0:\r\n print(a//2)\r\nelse:\r\n print(a)", "n = int(input())\r\nn+=1\r\nif n==1:\r\n\tprint(0)\r\nelif n%2==0:\r\n\tprint(n//2)\r\nelif n%2!=0 and n!=1:\r\n\tprint(n)", "import sys\r\n\r\ndef Solution():\r\n people=int(sys.stdin.readline())\r\n people=people+1\r\n if people==1:\r\n return print(\"0\")\r\n elif people%2==1:\r\n return print(people)\r\n else:\r\n print(people//2)\r\n \r\nSolution()", "n = int(input())\n\nif n == 0:\n\tprint(0)\nelif n % 2 == 0:\n\tprint(n + 1)\nelse:\n\tprint((n + 1) // 2)", "guests = int(input())\r\ntotal = guests + 1\r\n\r\nif total % 2 == 0 or total == 1:\r\n print(total // 2)\r\nelse:\r\n print(total)", "a=int(input())\r\nif(a%2==0 and a!=0):\r\n print(a+1)\r\nelif(a==0):\r\n print(0)\r\nelse:\r\n print((a+1)//2)\r\n", "n=int(input())\r\nif(n==0):\r\n print(n)\r\nelse:\r\n x=n+1\r\n if(x%2!=0):\r\n print(x)\r\n else:\r\n print(x//2)\r\n \r\n", "def solve(n: int) -> int:\r\n if n == 1:\r\n return(0)\r\n elif n % 2 == 0:\r\n return(n//2)\r\n else:\r\n return(n) \r\n \r\nn = (int(input()))+1\r\nprint(solve(n))\r\n\r\n \r\n \r\n ", "def process(n):\r\n if n==0:\r\n return 0\r\n #divide pizza into n+1 pieces\r\n #if n=0, 1 piece, 0 \r\n #if n=1, 2 pieces, 1\r\n #if n=2, 3 pieces, 3\r\n #if n=3, 4 pieces 2\r\n #if n=4, 5 pieces, 5\r\n #if n=5, 6 pieces, 3\r\n elif n % 2==0:\r\n return n+1\r\n else:\r\n return n//2+1\r\nn = int(input())\r\nprint(process(n))", "def pizza_forces():\r\n a=int(input())\r\n b = a+1\r\n if a == 0:\r\n print(0)\r\n elif b%2!=0:\r\n print(b)\r\n else:\r\n print(b//2)\r\npizza_forces()\r\n", "n = int(input())\r\nn += 1\r\nprint(n if n%2 != 0 and n != 1 else n//2)", "n = int(input())+1\r\nif n==1:\r\n print(0)\r\nelse:\r\n div,mod = divmod(n,2)\r\n if mod:\r\n print(n)\r\n else:\r\n print(div)", "\r\nnum_inp=lambda: int(input())\r\narr_inp=lambda: list(map(int,input().split()))\r\nsp_inp=lambda: map(int,input().split())\r\nstr_inp=lambda:input()\r\nn=int(input())+1\r\nprint([n,n//2][(n%2==0 or n==1)])\r\n", "n = int(input()) + 1\r\n\r\ndef solve1():\r\n i = 0\r\n while n != 1:\r\n if n % 2 == 0:\r\n i += 1\r\n n //= 2\r\n else:\r\n break\r\n else:\r\n n = 0\r\n print(n+i)\r\n\r\n\r\ndef solve2():\r\n if n == 1: print(0)\r\n elif n % 2 == 0: print(n//2)\r\n else: print(n)\r\n\r\nsolve2()\r\n", "n = int(input())+1\r\nif n==1:\r\n print(0)\r\nelif n % 2 ==0:\r\n print(n//2)\r\nelse:\r\n print(n)", "n=int(input())\r\nn+=1\r\nif n==1:\r\n print (0)\r\nelif n%2==0:\r\n print (n//2)\r\nelse:\r\n print (n)\r\n \r\n", "n = int(input())+1\r\nprint(0 if not (n-1) else n//2 if not n&1 else n)", "n=int(input())+1\r\nif(n==1): print(0)\r\nelif(n%2): print(n)\r\nelse: print(n//2)", "a = int(input()) + 1\nif a == 1:\n print(0)\n exit()\nif a % 2 == 0:\n print(a // 2)\nelse:\n print(a)\n", "n=int(input())\r\nif n==0:\r\n\tprint(0)\r\nelse:\r\n\tn+=1\r\n\tif n%2==0:\r\n\t\tp=n//2\r\n\t\tprint(min(p,n))\r\n\telse:\r\n\t\tprint(n)\r\n", "slices = int(input())+1\n\nif slices%2==0:\n print(slices//2)\nelif slices==1:\n print(0)\nelse:\n print(slices)\n", "n=int(input())+1\r\nprint(n//2if n%2==0 or n==1 else n)", "n = int(input())\r\nif n != 0 :\r\n print(n+1 if n%2 == 0 else (n+1)//2)\r\nelse :\r\n print(0)", "n = int(input()) + 1\r\nprint(n if n % 2 and (n - 1) else n // 2)", "a=int(input())\r\nif (a+1) % 2 == 0:\r\n print((a+1)//2)\r\nelse:\r\n if a != 0:\r\n print(a+1)\r\n else:\r\n print(a)", "sum1=int(input())\r\nif( sum1%2==0 and sum1!=0):\r\n print(sum1+1)\r\nelse:\r\n print((sum1+1)//2)\r\n", "n = int(input())\r\n \r\nif n != 0:\r\n\tif (n+1)%2:\r\n\t\tprint(n+1)\r\n\telse:\r\n\t\tprint(int((n+1)//2))\r\nelse:\r\n\tprint(0)", "friends = int(input()) + 1\n\n\nif friends % 2 == 0:\n\tres = friends//2\n\tprint(res)\n\nelif friends == 1:\n\tprint(0)\nelse:\n\tprint(friends)\n\n\n", "n = int(input())\r\nans = (n+1)//2\r\nif n%2 == 0:\r\n ans = n+1\r\n if n == 0:\r\n ans = 0\r\nprint(ans)\r\n", "\r\nt=int(input())\r\nt=t+1\r\nif t==1:\r\n\tprint(0)\r\n\texit()\r\nelif t%2==0:\r\n\tprint(t//2)\r\n\texit()\r\nelse :\r\n\tprint(t)\r\n\t", "def pizza(n):\r\n if n == 0:\r\n return 0\r\n elif (n + 1) % 2 == 0:\r\n return (n + 1) // 2\r\n return n + 1\r\n\r\n\r\nm = int(input())\r\nprint(pizza(m))\r\n", "n = int(input())\r\n\r\nif n != 0:\r\n cuts = 0\r\n if (n+1)%2 == 0:\r\n cuts = (n+1)//2\r\n else:\r\n cuts = n+1\r\nelse:\r\n cuts = 0\r\nprint(cuts)", "f = int(input())\r\nif f == 0:\r\n print(0)\r\nelif (f +1)%2 == 0:\r\n print(int((f+1)//2))\r\nelse:\r\n print(f+1)", "n = int(input())\r\nn = n+1\r\nif(n == 1):\r\n print(0)\r\nelif (n % 2 == 0):\r\n print(n//2)\r\nelse:\r\n print(n)", "s = int(input())\r\nm = s+1\r\nif m == 1:\r\n print(0)\r\nelse:\r\n if m % 2 :\r\n print(m)\r\n else:\r\n print(m//2)\r\n", "n = int(input())\nif n == 0:\n print(0)\nelse:\n print((n+1)//2 if n%2 else n+1)\n", "n = int(input()) + 1\nif (n == 1):\n print(0)\nelse:\n print(n if n % 2 == 1 else n // 2)\n", "import sys\r\ninput = sys.stdin.readline\r\ncount_friends = int(input())\r\ncount_eating_friends = count_friends + 1\r\ncount_parts = 0\r\nif count_friends == 0:\r\n count_parts = 0\r\nelif count_eating_friends % 2 == 0:\r\n count_parts = count_eating_friends // 2\r\nelse:\r\n count_parts = count_eating_friends\r\nprint(count_parts)", "n = int(input())\r\nn = n+1\r\nans = n//2\r\nif n%2!=0:\r\n ans = n\r\nif n==1:\r\n ans=0\r\nprint(ans)", "n=int(input())\r\nif(n==0):\r\n\tprint(0)\r\n\texit()\r\nn+=1\r\nif(n%2==0):\r\n\tprint(n//2)\r\nelse:\r\n\tprint(n)", "n = int(input())\r\nn += 1\r\nif n%2 ==0 or n == 1:\r\n print(n//2)\r\nelse:\r\n print(n)", "n = int(input())\nif n == 0:\n\tprint(0)\n\texit()\nn += 1\nif n % 2:\n\tprint(n)\nelse:\n\tprint(n // 2)\n", "import math\r\n\r\n\r\nguests = int(input())\r\nguests = guests+1\r\n\r\nif guests == 1:\r\n print(\"0\")\r\nelif guests % 2 == 0:\r\n print(guests//2)\r\n\r\nelse:\r\n print(guests)\r\n", "n = int(input())\r\nif n==0: print(0)\r\nelif n%2==0: print(n+1)\r\nelse: print((n+1)//2)", "# LUOGU_RID: 109862685\na=int(input())\nb=a+1\nif b==1:\n print(\"0\")\nelif b%2!=0:\n print(b)\nelif b%2==0:\n print(b//2)", "n=int(input())\r\ns=n\r\nd=n+1\r\nif(d%2==0):\r\n k=d//2 \r\nelse:\r\n k=d \r\nif(s==0):\r\n print('0')\r\nelse:\r\n print(k)\r\n", "n = int(input()) + 1\r\nif n == 1:\r\n print(0)\r\n exit()\r\nprint(n if n % 2 else n // 2)\r\n", "n=int(input())\r\nif n==0:\r\n\tprint(0)\r\n\texit()\r\nif n%2==0:\r\n\tprint(n+1)\r\nelse:\r\n\tprint((n+1)//2)\t", "x = int(input())\r\nif x == 0:\r\n\tprint(0)\r\nelif x%2 == 0:\r\n\tprint(x+1)\r\nelif x%2 == 1:\r\n\tprint((x+1)//2)\r\n", "x=int(input())\r\nif x==0:\r\n print(\"0\")\r\nelif x%2!=0:\r\n print((x+1)//2)\r\nelse:\r\n print(x+1) ", "n=int(input())\r\nif (n+1)%2==0:print((n+1)//2)\r\nelif n==0:print(0)\r\nelse:print(n+1)", "a=input()\r\nb=int(a)+1\r\nif b==1 :\r\n print(\"0\")\r\nelif b%2==0 :\r\n print(b//2)\r\nelif b%2!=0 : \r\n print(b)", "#Pizza\r\nn=int(input())\r\nif (n+1)%2==0 and n!=0: print((n+1)//2)\r\nelif n==0: print(0)\r\nelse: print(n+1)", "def solve():\n\tn = int(input()) + 1\n\tprint(n // 2 if n % 2 == 0 or n == 1 else n)\n\nsolve()\n", "x = int(input())\r\nif x==0:\r\n print(0)\r\nelif (x%2==0):\r\n print(x+1)\r\nelse:\r\n print((x+1)//2)\r\n", "n=int(input())+1\r\nif n%2!=0 and n!=1:\r\n\tprint(n)\r\nelif n==1:\r\n\tprint(0)\r\nelse:\r\n\tprint(n//2)", "\r\nn = int(input()) + 1\r\nif n == 1:\r\n\tprint(0)\r\n\texit()\r\n\r\nif n % 2 == 0:\r\n\tprint(n //2)\r\nelse:\r\n\tprint(n)", "from math import floor\r\nn=int(input())\r\nif n==0:\r\n\tprint(0)\r\n\texit()\r\nelif n%2==1:\r\n\tprint((n+1)//2)\r\n\texit()\r\nelse:\r\n\tprint(n+1)\r\n\texit()", "'''\r\nBeezMinh\r\n11:03 UTC+7\r\n08/07/2023\r\n'''\r\nn = int(input()) + 1\r\nif n == 1:\r\n\tprint(0)\r\nelif n % 2 == 0:\r\n\tprint(n // 2)\r\nelse:\r\n\tprint(n)", "f=int(input())\r\n \r\nif f==0:\r\n print(0)\r\nelif (f+1)%2==0:\r\n print((f+1)//2)\r\nelse:\r\n print(f+1)", "n=int(input())+1\r\nif n%2==0:\r\n print(n//2)\r\nelif n>2:\r\n print(n)\r\nelse:\r\n print(0)\r\n", "#!/usr/bin/env python3\n# -*- coding: UTF-8 -*-\n\nn = int(input())\nif not n:\n print(0)\nelif n&1:\n print((n+1)//2)\nelse:\n print(n+1)\n \n \t \t \t \t \t \t\t \t \t\t\t\t\t", "#n, k = map(int, input().split(\" \")) # read multiple integers into different variables\r\n#L = [int(x) for x in input().split()] # read multiple integers into a list\r\n#print(' '.join(map(str, L))) # print multiple integers in one line\r\n\r\n\r\nn = int(input())\r\n\r\nif n == 0 : print(0)\r\nelif n % 2 == 0 : print(n + 1)\r\nelse : print((n + 1) // 2)\r\n\r\n\r\n", "n=int(input())\r\nif n==0 or n==1:\r\n print(n)\r\nelif (n+1)%2==0:\r\n print((n+1)//2)\r\nelse:\r\n print(n+1)", "n=int(input())\r\np=(n+1)%2\r\nif n==0:\r\n print(\"0\")\r\nelif p==0:\r\n print((n+1)//2) \r\nelse:\r\n print(n+1)\r\n", "i = int(input())+1\r\nif i==1:\r\n print(0)\r\nelif i%2==0:\r\n print(i//2)\r\nelse:\r\n print(i)", "n = int(input())\r\nif n==0: print(0)\r\nelif n%2 ==1 : print( (n+1)//2)\r\nelse: print(n+1)\r\n", "n = int(input().strip())+1\nif n % 2 == 0:\n\tprint(n//2)\nelse:\n\tprint(0 if n == 1 else n)", "n = int(input())\r\nif (n+1) % 2 == 0 and n != 0: print((n+1)//2)\r\nelif n != 0: print(n+1)\r\nelse:\r\n print(0)", "import sys\r\nimport math\r\n\r\n#to read string\r\nget_string = lambda: sys.stdin.readline().strip()\r\n#to read list of integers\r\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\r\n#to read integers\r\nget_int = lambda: int(sys.stdin.readline())\r\n\r\n#--------------------------------WhiteHat010--------------------------------------#\r\nn = get_int()\r\nif (n+1)%2 == 0:\r\n print((n+1)//2)\r\nelse:\r\n if n>0:\r\n print(n+1)\r\n else:\r\n print(0)", "n=int(input())\r\nn+=1\r\nif n==1:\r\n print(0)\r\nelif n%2==0:\r\n print(n//2)\r\nelse:\r\n print(n)", "n = int(input())\nn+=1\nif(n==1):\n print(0)\nelif(n%2==0):\n print(n//2)\nelse:\n print(n)\n\t \t \t \t\t\t\t\t\t \t \t \t \t\t \t\t\t\t", "n = int(input())\n\nif (n+1)%2 == 0 or n == 0:\n\tprint((n+1)//2)\nelse:\n\tprint(n+1)", "n = int(input())\r\nn+=1\r\nif(n==1):\r\n\tans = 0\r\nelif(n%2==0):\r\n\tans = n//2\r\nelse:\r\n\tans = n\r\nprint(ans)", "r = int( input ())\r\nif r == 0:\r\n print('0')\r\nelse:\r\n r = r + 1\r\n t = r % 2\r\n if t == 0:\r\n print (r // 2)\r\n else:\r\n print (r)\r\n", "n = int(input())\r\nif n != 0:\r\n\tn = n + 1\r\nif n % 2 == 1:\r\n\tprint(n)\r\nelse:\r\n\tprint(n//2)", "n = int(input())\r\nn += 1\r\n\r\n\r\nif n%2 == 0:\r\n print(n//2)\r\nelse:\r\n if n == 1: print(0)\r\n else: print(n)", "n=int(input())\r\nif n==0:print(0)\r\nelif (n+1)%2==0:print((n+1)//2)\r\nelse:print(n+1)", "x = int(input())\r\nif x == 0:\r\n print(0)\r\nelif (x+1)%2 == 0:\r\n print((x+1)//2)\r\nelif x>0:\r\n print(x+1)\r\n", "n=int(input())\r\np=n+1\r\nif p%2==0:\r\n print(p//2)\r\nelif n==0:\r\n print('0')\r\nelse:\r\n print(p)", "n=int(input())+1\r\nif n<2:\r\n print(0)\r\nelif n%2==0:\r\n print(n//2)\r\nelse:\r\n print(n)", "n = int(input())\nprint((n+1)//2 if n%2==1 or n==0 else n+1)\n" ]
{"inputs": ["3", "4", "10", "10000000000", "1234567891", "7509213957", "99999999999999999", "21", "712394453192", "172212168", "822981260158260519", "28316250877914571", "779547116602436424", "578223540024979436", "335408917861648766", "74859962623690078", "252509054433933439", "760713016476190622", "919845426262703496", "585335723211047194", "522842184971407769", "148049062628894320", "84324828731963974", "354979173822804781", "1312150450968413", "269587449430302150", "645762258982631926", "615812229161735895", "0", "349993004923078531", "891351282707723851", "563324731189330734", "520974001910286909", "666729339802329204", "856674611404539671", "791809296303238499", "711066337317063338", "931356503492686566", "234122432773361866", "1000000000000000000", "1", "2", "7", "63", "24", "8", "15"], "outputs": ["2", "5", "11", "10000000001", "617283946", "3754606979", "50000000000000000", "11", "712394453193", "172212169", "411490630079130260", "14158125438957286", "779547116602436425", "578223540024979437", "335408917861648767", "74859962623690079", "126254527216966720", "760713016476190623", "919845426262703497", "585335723211047195", "261421092485703885", "148049062628894321", "84324828731963975", "177489586911402391", "656075225484207", "269587449430302151", "645762258982631927", "307906114580867948", "0", "174996502461539266", "445675641353861926", "563324731189330735", "260487000955143455", "666729339802329205", "428337305702269836", "395904648151619250", "711066337317063339", "931356503492686567", "234122432773361867", "1000000000000000001", "1", "3", "4", "32", "25", "9", "8"]}
UNKNOWN
PYTHON3
CODEFORCES
154
e638521913c2072acd0316e2f71ff040
Hamming Distance Sum
Genos needs your help. He was asked to solve the following programming problem by Saitama: The length of some string *s* is denoted |*s*|. The Hamming distance between two strings *s* and *t* of equal length is defined as , where *s**i* is the *i*-th character of *s* and *t**i* is the *i*-th character of *t*. For example, the Hamming distance between string "0011" and string "0110" is |0<=-<=0|<=+<=|0<=-<=1|<=+<=|1<=-<=1|<=+<=|1<=-<=0|<==<=0<=+<=1<=+<=0<=+<=1<==<=2. Given two binary strings *a* and *b*, find the sum of the Hamming distances between *a* and all contiguous substrings of *b* of length |*a*|. The first line of the input contains binary string *a* (1<=≤<=|*a*|<=≤<=200<=000). The second line of the input contains binary string *b* (|*a*|<=≤<=|*b*|<=≤<=200<=000). Both strings are guaranteed to consist of characters '0' and '1' only. Print a single integer — the sum of Hamming distances between *a* and all contiguous substrings of *b* of length |*a*|. Sample Input 01 00111 0011 0110 Sample Output 3 2
[ "from collections import deque\r\ndef hamming(arr1, arr2, n):\r\n sum1 = 0\r\n for i in range(n):\r\n sum1 += arr1[i]^arr2[i]\r\n return sum1\r\ns = input()\r\nt = input()\r\nn = len(t)\r\nm = len(s)\r\ntotal = 0\r\ncount1 = 0\r\nlength = n-m+1\r\nfor i in range(n-m+1):\r\n if t[i] == '1':\r\n count1 += 1\r\nfor i in range(m):\r\n if s[i] == '1':\r\n total += (length - count1)\r\n else:\r\n total += count1\r\n if i < m-1:\r\n if t[i] == '1':\r\n count1 -= 1\r\n if t[i+n-m+1] == '1':\r\n count1 += 1\r\nprint(total)", "first_string = input()\r\nsecond_string = input()\r\ninfo ={\r\n \"F_S_L\" : len(first_string) ,\r\n \"S_S_L\" : len(second_string)\r\n}\r\narr = []\r\ncounter = 0\r\nif info[\"F_S_L\"] == info[\"S_S_L\"] :\r\n for i in range(0 , info[\"S_S_L\"]) :\r\n counter += abs(int(second_string[i]) - int(first_string[i]) )\r\nelse :\r\n for i in range(0 , info[\"S_S_L\"]) :\r\n #element of second string\r\n E_O_S_S = int(second_string[i])\r\n #the opposite\r\n opposit = 0 if E_O_S_S == 1 else 1\r\n if i < info[\"F_S_L\"] :\r\n #element of first string\r\n E_O_F_S = int(first_string[i])\r\n if i == 0 :\r\n arr.append([0 , 0])\r\n else :\r\n arr.append([arr[-1][0] , arr[-1][1]])\r\n arr[-1][E_O_F_S] += 1\r\n if info[\"S_S_L\"] - 1 - i < info[\"F_S_L\"] - 1 :\r\n start = arr[-1]\r\n x = info[\"F_S_L\"] - (info[\"S_S_L\"] - 1- i +2)\r\n end = arr[x]\r\n ar = [abs(start[0] - end[0] ), abs(start[1] - end[1]) ]\r\n counter += ar[opposit]\r\n elif i < info[\"F_S_L\"] :\r\n counter += arr[i][opposit]\r\n else :\r\n counter += arr[-1][opposit]\r\nprint(counter)\r\n", "import math\nimport itertools\n\na = [int(x) for x in input().rstrip()]\nb = [int(x) for x in input().rstrip()]\nn = len(a)\nm = len(b)\nprefix_b = [0] + list(itertools.accumulate(b))\nres = 0\nfor i in range(n):\n ones = prefix_b[-n+i] - prefix_b[i]\n res += m-n+1 - ones if a[i] else ones\nprint(res)\n \n\n \n", "a = input()\r\nb = input()\r\no = []\r\nz = []\r\nc0 = 0\r\nc1 = 0\r\nfor i in b:\r\n if i == \"0\":\r\n c0 += 1\r\n\r\n else:\r\n c1 += 1\r\n\r\n o.append(c1)\r\n z.append(c0)\r\n\r\nn = len(b)-1\r\nm = len(a)-1\r\nans = 0\r\nfor i in range(len(a)):\r\n x = a[i]\r\n if x == \"1\":\r\n ans += z[(n-(m-i))]-z[i]\r\n if b[i] == \"0\":\r\n ans += 1\r\n\r\n else:\r\n ans += o[(n - (m - i))] - o[i]\r\n if b[i] == \"1\":\r\n ans += 1\r\n\r\nprint(ans)", "a, b, ans, c = input(), input(), 0, [0]\r\nd = len(b) - len(a)\r\nfor i in range(len(b)):\r\n c.append(c[-1] + int(b[i]))\r\nfor i in range(len(a)):\r\n ones = c[d + i + 1] - c[i]\r\n zeros = d + 1 - ones\r\n ans += ones if a[i] == \"0\" else zeros\r\nprint(ans)\r\n", "a=list(input())\r\nb=list(input())\r\nm=len(a)\r\nn=len(b)\r\nans=0 \r\npre=[0]*(n+1)\r\nfor i in range(1,n+1):\r\n pre[i]=pre[i-1]+int(b[i-1])\r\n#print(pre)\r\nk=0\r\nfor i in range(m-1,-1,-1):\r\n sm=pre[n-k]-pre[i]\r\n length=(n-k-i)\r\n # print(sm)\r\n #length=m \r\n if a[i]=='0':\r\n ans+=sm \r\n else:\r\n ans+=(length-sm)\r\n k+=1\r\nprint(ans)", "a=input()\r\nb=input()\r\ninv = len(b)-len(a)+1\r\ncount=0\r\nfor i in range(inv) :\r\n count += int(b[i])\r\nans=0\r\nfor i in range(len(a)) :\r\n if a[i] == '1' :\r\n ans += inv-count\r\n else :\r\n ans += count\r\n if i < len(a)-1 :\r\n count -= int(b[i])\r\n count += int(b[inv+i])\r\nprint(ans)", "a=input()\r\nb=input()\r\nl=len(a)\r\nm=len(b)\r\ninit=0\r\nlent=m-l+1\r\nfor i in range(lent):\r\n init+=int(b[i])\r\narray=[init]\r\nfor i in range(l-1):\r\n init+=int(b[i+lent])-int(b[i])\r\n array.append(init)\r\ns=0\r\nfor i in range(l):\r\n if a[i]==\"0\":\r\n s+=array[i]\r\n else:\r\n s+=(lent-array[i])\r\nprint(s)", "a=input()\r\nb=input()\r\nl1=len(a)\r\nl2=len(b)\r\na='X'+a\r\nb='X'+b\r\nones=[0 for i in range(l2+1)]\r\nzeros=[0 for i in range(l2+1)]\r\nfor i in range(1,l2+1):\r\n if b[i]=='0':\r\n zeros[i]=1+zeros[i-1]\r\n ones[i]=ones[i-1]\r\n else:\r\n zeros[i]=zeros[i-1]\r\n ones[i]=1+ones[i-1]\r\nfinal=0\r\nfor i in range(1,l1+1):\r\n if a[i]=='0':\r\n final+=ones[l2-l1+i]-ones[i-1]\r\n else:\r\n final+=zeros[l2-l1+i]-zeros[i-1]\r\nprint(final)", "a=input();b=input();c=[0];s=0;ans=0\r\nfor i in range(len(b)):\r\n s+=int(b[i])\r\n c.append(s)\r\nx=len(b)-len(a)+1\r\nfor i in range(len(a)):\r\n if a[i]=='0':\r\n ans+=c[x+i]-c[i]\r\n else:\r\n ans+=x-c[x+i]+c[i]\r\nprint(ans)", "a = input()\r\nb = input()\r\n\r\nstep = len(b) - len(a) + 1\r\nzeroes = b[:step].count('0')\r\nresult = zeroes if a[0] == '1' else (step - zeroes)\r\n\r\nfor i in range(1, len(a)):\r\n if b[i - 1] != b[step + i - 1]:\r\n zeroes += 1 if b[i - 1] == '1' else -1\r\n result += zeroes if a[i] == '1' else (step - zeroes)\r\n\r\nprint(result)\r\n", "a, b=input(), input()\r\nla=len(a)\r\nd=len(b)-la+1\r\nc0, c1= b[0:d].count('0'), b[0:d].count('1')\r\ns=c0 if a[0]=='1' else c1\r\nfor i in range(1, la):\r\n\tx=int(b[i+d-1])-int(b[i-1])\r\n\tc1+=x; c0-=x\r\n\ts+=c1 if a[i]=='0' else c0\r\n\r\nprint(s)\r\n", "a,b,c,d,e=input(),input(),[0],0,0\r\nfor i in range(len(b)):d+=int(b[i]);c.append(d)\r\nfor i in range(len(a)):\r\n nOO=c[len(b)-(len(a)-i)+1]-c[i]\r\n nOZ=len(b)-len(a)+1-nOO\r\n if a[i]=='0':e+=nOO\r\n else:e+=nOZ\r\nprint(e)", "a=input()\r\nb=input() \r\nzero=[0]\r\nones=[0]\r\nfor i in range(len(b)):\r\n if b[i]=='0':\r\n zero.append(zero[-1]+1)\r\n ones.append(ones[-1])\r\n else:\r\n ones.append(ones[-1]+1)\r\n zero.append(zero[-1])\r\nans=0\r\nfor i in range(len(a)):\r\n if a[i]=='0':\r\n ans+=(ones[len(b)-len(a)+i+1]-ones[i])\r\n else:\r\n ans+=(zero[len(b)-len(a)+(i+1)]-zero[i])\r\nprint(ans) ", "a=input()\r\nb=input()\r\nl1=len(a)\r\nl2=len(b)\r\npre_sum=[0]*l2\r\npre_sum[0]=b[0].count('1')\r\nfor i in range(1,l2):\r\n if b[i]=='1':\r\n pre_sum[i]=pre_sum[i-1]+1\r\n else:\r\n pre_sum[i]=pre_sum[i-1]\r\nans=0\r\nif a[0]=='0':\r\n ans+=pre_sum[l2-l1]\r\nelse:\r\n ans+=(l2-l1+1-pre_sum[l2-l1])\r\n \r\n\r\nfor i in range(1,l1):\r\n x=pre_sum[l2-l1+i]-pre_sum[i-1]\r\n if a[i]=='0':\r\n ans+=x\r\n else:\r\n ans+=(l2-l1+1-x)\r\nprint(ans)\r\n \r\n ", "a , b = input(), input()\nans = 0\n \nones = [0 for i in range(len(b)+1)]\nzeros = [0 for i in range(len(b)+1)]\n \nfor i in range(len(b)):\n ones[i] = ones[i-1] + int(b[i])\n zeros[i] = i + 1 - ones[i]\n \nfor i in range(len(a)):\n if a[i] == '1':\n ans += zeros[len(b)-len(a)+i] - zeros[i-1]\n \n else:\n ans += ones[len(b)-len(a)+i] - ones[i-1]\n \nprint(ans)\n \t \t \t \t \t\t\t\t \t \t\t\t", "a, b, c = input(), input(), 0\r\np = [[0] * (len(b) + 1), [0] * (len(b) + 1)]\r\nfor i in range(0, len(b)):\r\n p[0][i + 1] = p[0][i] + int(b[i] == '0')\r\n p[1][i + 1] = p[1][i] + int(b[i] != '0')\r\nfor i in range(len(a)):\r\n cr = int(a[i] == '1')\r\n for j in range(2):\r\n c += abs(cr - j) * (p[j][len(b) - len(a) + i + 1] - p[j][i])\r\nprint(c)\r\n", "a=list(map(int,input()))\r\nb=list(map(int,input()))\r\ns=0\r\nl=len(b)\r\nif len(a)==len(b):\r\n for i in range(l):\r\n s+=abs(a[i]-b[i])\r\n print(s)\r\n exit(0)\r\nl=len(b)\r\nm=len(a)\r\nj=k=0\r\nc=[0]\r\nd=[0]\r\nfor i in range(l):\r\n if b[i]==0:\r\n j+=1\r\n if b[i]==1:\r\n k+=1\r\n c.append(j)\r\n d.append(k)\r\n#print(c)\r\n#print(d)\r\nfor i in range(m):\r\n if a[i]==0:\r\n s+=(d[l-m+i+1]-d[i])\r\n #print(s)\r\n else:\r\n s+=(c[l-m+i+1]-c[i])\r\n #print(s)\r\nprint(s)\r\n\r\n ", "import sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\na = list(input().rstrip())\r\nb = list(input().rstrip())\r\nc = [0]\r\nfor i in b:\r\n c.append(c[-1] + (i & 1))\r\nm = len(b) - len(a) + 1\r\nans = 0\r\nfor i in range(len(a)):\r\n u = c[i + m] - c[i]\r\n ans += u if not a[i] & 1 else m - u\r\nprint(ans)", "\nif __name__ == '__main__':\n a = [int(c) for c in str(input())]\n b = [int(c) for c in str(input())]\n b_len = len(b)\n a_len = len(a)\n carCountPrefix = [[ 0 for c in range(2)] for _ in range(b_len+1)]\n b_zero_count = 0\n b_one_count = 0\n for b_i in range(b_len):\n if b[b_i] == 0:\n b_zero_count += 1\n elif b[b_i] == 1:\n b_one_count += 1\n carCountPrefix[b_i+1][1] = b_one_count\n carCountPrefix[b_i+1][0] = b_zero_count\n res = 0\n for cur in range(0, a_len):\n for dig in range(2):\n res += (carCountPrefix[b_len - a_len + cur + 1][dig] - carCountPrefix[cur][dig]) * abs(a[cur] -dig)\n print(res)\n\n \t \t\t \t\t\t\t\t \t \t \t \t\t \t\t \t", "a = input()\r\n\r\nb = input()\r\n\r\ntotal = [0, 0]\r\n\r\n\r\nfor i in range(len(a)):\r\n if (a[i] == \"0\"):\r\n total[0] += 1\r\n else:\r\n total[1] += 1\r\n\r\n\r\nleft_pref = []\r\n\r\n\r\ncnt_0 = 0\r\ncnt_1 = 0\r\n\r\nfor i in range (len(a)):\r\n if (a[i] == \"1\"):\r\n cnt_1 += 1\r\n \r\n else:\r\n cnt_0 += 1\r\n \r\n left_pref.append([cnt_0, cnt_1])\r\n\r\n\r\nright_pref = []\r\n\r\n\r\ncnt_0 = 0\r\ncnt_1 = 0\r\n\r\nfor i in range (len(a) - 1, -1, -1):\r\n if (a[i] == \"1\"):\r\n cnt_1 += 1\r\n \r\n else:\r\n cnt_0 += 1\r\n \r\n right_pref.append([cnt_0, cnt_1])\r\n\r\n\r\n\r\ns = 0\r\n\r\n\r\n\r\nfor i in range(len(b)):\r\n left = i\r\n right = len(b) - (left + 1)\r\n\r\n\r\n left_sum = 0\r\n right_sum = 0\r\n\r\n if (left < len(a) - 1): \r\n diff = (len(a) - 1) - left\r\n\r\n if (b[i] == \"0\"):\r\n right_sum = right_pref[diff - 1][1]\r\n else:\r\n right_sum = right_pref[diff - 1][0]\r\n\r\n if (right < len(a) - 1):\r\n diff = (len(a) - 1) - right\r\n\r\n if (b[i] == \"0\"):\r\n left_sum = left_pref[diff - 1][1]\r\n else:\r\n left_sum = left_pref[diff - 1][0]\r\n\r\n\r\n if (b[i] == \"0\"):\r\n s += total[1] - (left_sum + right_sum)\r\n else:\r\n s += total[0] - (left_sum + right_sum)\r\n\r\n\r\nprint(s)", "a = input()\nb = input()\na_len = len(a)\nb_len = len(b)\ntemporary_sum = 0\nhamming_sum = 0\nfor i in range(b_len-a_len+1):\n temporary_sum += int(b[i])\nhamming_sum += abs((b_len-a_len+1)*int(a[0]) - temporary_sum)\nfor i in range(b_len-a_len+1, b_len):\n temporary_sum += int(b[i]) - int(b[i - (b_len-a_len+1)])\n hamming_sum += abs((b_len-a_len+1)*int(a[i - (b_len-a_len+1)+1]) - temporary_sum)\nprint(hamming_sum)\n \t\t\t\t \t\t \t\t\t\t\t\t\t\t \t \t", "def solve():\n S = input()\n T = input()\n\n lens = len(S)\n lent = len(T)\n\n a0 = [0] * lens\n a1 = [0] * lens\n for i in range(lens):\n if i > 0:\n a0[i] = a0[i - 1]\n a1[i] = a1[i - 1]\n if S[i] == '0':\n a1[i] += 1\n else:\n a0[i] += 1\n\n ans = 0\n for i in range(lens):\n if T[i] == '0':\n ans += a0[i]\n else:\n ans += a1[i]\n\n for i in range(lens, lent):\n if T[i] == '0':\n ans += a0[-1]\n else:\n ans += a1[-1]\n\n for i in range(lent - lens + 1, lent):\n d = lent - i\n if T[i] == '0':\n ans -= a0[-d - 1]\n else:\n ans -= a1[-d - 1]\n\n print(ans)\n\n\nif __name__ == '__main__':\n solve()\n", "import math\r\n\r\n\r\n#n, s = tuple(map(int, input().split()))\r\n#floors = [0 for i in range(s + 1)]\r\n\r\n#for i in range(n):\r\n# floor, time = tuple(map(int, input().split()))\r\n# floors[floor] = max(floors[floor], time)\r\n\r\n#res = s\r\n#for i in range(s + 1):\r\n# res = max(res, floors[i] + i)\r\n\r\n#print(res)\r\n\r\na = input()\r\nb = input()\r\nshift = [0]\r\nfor i in range(len(b) - len(a) + 1):\r\n shift[0] += int(b[i])\r\nfor i in range(len(a) - 1):\r\n shift.append(shift[i] - int(b[i]) + int(b[len(b) - len(a) + i + 1]))\r\n\r\nres = 0\r\nfor i in range(len(a)):\r\n if a[i] == '0':\r\n res += shift[i]\r\n else:\r\n res += len(b) - len(a) + 1 - shift[i]\r\nprint(res)\r\n\r\n", "a, b, ans, c = input(), input(), 0, [0]\r\ndiff = len(b) - len(a)\r\n\r\nfor i in range(len(b)):\r\n c.append(c[-1] + int(b[i]))\r\n\r\nfor i in range(len(a)):\r\n ones = c[diff + i + 1] - c[i]\r\n zeros = diff + 1 - ones\r\n ans += ones if a[i] == \"0\" else zeros\r\nprint(ans)\r\n", "a=input()\r\nb=input()\r\n\r\nres=0\r\n\r\npref=[0]*len(b)\r\n\r\npref[0] = int(b[0])\r\n\r\nfor i in range(1, len(b)):\r\n\tpref[i]+=pref[i-1] + int(b[i])\r\n\r\nsub = len(b)-len(a)+1\r\n#print(sub)\r\n\r\nones= pref[sub-1]\r\n\r\nif int(a[0])==1:\r\n\tres = sub-ones\r\nelse:\r\n\tres = ones\r\nj=1\r\n#print(pref)\r\nfor i in range(1,len(b)-sub+1):\r\n\tst=i\r\n\ten=i+sub-1\r\n\tones=pref[en]-pref[st-1]\r\n\t#print(st, en, ones)\r\n\tif int(a[j])==1:\r\n\t\tres += (sub-ones)\r\n\telse:\r\n\t\tres += ones\r\n\tj+=1\r\nprint(res)\r\n\r\n", "#!/usr/bin/env python3\r\n\r\na, b = input(), input()\r\nalen, blen = len(a), len(b) # blen >= alen\r\n\r\ndiff = blen-alen\r\ncount = b[:diff+1].count('0')\r\nresult = 0\r\nfor i in range(0, alen):\r\n #print('at i=%d, count=%d' % (i, count))\r\n result += diff+1-count if a[i] == '0' else count\r\n #print('compared at', i, diff+i+1)\r\n if i == alen-1: break\r\n count -= 1 if b[i] == '0' else 0\r\n count += 1 if b[diff+1+i] == '0' else 0\r\nprint(result)\r\n", "a=input()\nb=input()\na1=len(a)\nb1=len(b)\ns=[0]\nn=0\nb='0'+b\nd=b1-a1\nfor i in range(1,b1+1):\n s.append(s[i-1]+int(b[i]))#前缀和\nfor i in range(1,a1+1):\n if a[i-1]=='0':\n n+=s[d+i]-s[i-1]\n elif a[i-1]=='1':\n n+=d+1-(s[d+i]-s[i-1])\nprint(n)\n \t \t \t \t\t \t\t \t \t \t \t \t\t", "def main():\n a = input()\n b = input()\n\n total_comparable = len(b) - len(a) + 1\n if total_comparable < 1:\n print(0)\n return\n\n cumulitive_one_b = [0] * len(b)\n\n for i in range(len(b)):\n if i != 0:\n cumulitive_one_b[i] += cumulitive_one_b[i - 1]\n\n if b[i] == '1':\n cumulitive_one_b[i] += 1\n\n hamming_distance = 0\n\n for i in range(len(a)):\n start = i\n end = i + total_comparable - 1\n if start == 0:\n total_comparable_one = cumulitive_one_b[end]\n else:\n total_comparable_one = cumulitive_one_b[end] - cumulitive_one_b[start - 1]\n\n if a[i] == '0':\n hamming_distance += total_comparable_one\n else:\n hamming_distance += total_comparable - total_comparable_one\n\n print(hamming_distance)\n\n\nif __name__ == '__main__':\n main()\n", "from sys import stdin,stdout\r\nfrom math import gcd,sqrt,factorial,pi\r\nfrom collections import deque,defaultdict\r\ninput=stdin.readline\r\nR=lambda:map(int,input().split())\r\nI=lambda:int(input())\r\nS=lambda:input().rstrip('\\n')\r\nL=lambda:list(R())\r\nP=lambda x:stdout.write(x)\r\nlcm=lambda x,y:(x*y)//gcd(x,y)\r\nhg=lambda x,y:((y+x-1)//x)*x\r\npw=lambda x:1 if x==1 else 1+pw(x//2)\r\nchk=lambda x:chk(x//2) if not x%2 else True if x==1 else False\r\nsm=lambda x:(x**2+x)//2\r\nN=10**9+7\r\ndef binary(l,r,a,k):\r\n\tv=a[l]\r\n\tans=l\r\n\twhile l<=r:\r\n\t\tm=(l+r)//2\r\n\t\tif a[m]-v<=k:\r\n\t\t\tans=max(ans,m)\r\n\t\t\tl=m+1\r\n\t\telse:\r\n\t\t\tr=m-1\r\n\treturn ans\r\na=[int(i) for i in S()]\r\nb=[int(i) for i in S()]\r\nd=[[0,0]]\r\np=[0,0]\r\nfor i in b:\r\n\tp[i]+=1\r\n\td.append(p.copy())\r\nans=0\r\nn=len(a)\r\nm=len(d)\r\nfor i in range(n):\r\n\tans+=[d[m-(n-i)][0]-d[i][0],d[m-(n-i)][1]-d[i][1]][a[i]^1]\r\nprint(ans)\r\n#1 2 3 4\r\n#0 1 2 3 4 5", "def solve(a, b):\r\n m = len(a)\r\n n = len(b)\r\n p_b = [0]\r\n for x in b[:]:\r\n p_b.append(p_b[-1] + int(x))\r\n s = 0\r\n for i in range(m):\r\n if a[i] == '0':\r\n s += p_b[n - m + 1 + i] - p_b[i]\r\n else:\r\n s += (n - m + 1) - (p_b[n - m + 1 + i] - p_b[i])\r\n return s\r\n\r\n\r\na = input()\r\nb = input()\r\nprint(solve(a, b))\r\n", "a=list(input())\r\nb=list(input())\r\nla=len(a)\r\nlb=len(b)\r\ns=0 \r\nr=[0]*(lb+1)\r\nfor i in range(1,lb+1):\r\n r[i]=r[i-1]+int(b[i-1])\r\nj=0\r\nfor i in range(la-1,-1,-1):\r\n t=r[lb-j]-r[i]\r\n k=lb-j-i\r\n if a[i]!='1':\r\n s+=t \r\n else:\r\n s+=k-t\r\n j+=1\r\nprint(s)", "a = list(input())\r\nb = list(input())\r\nsum = 0\r\nfor i in range(len(a)):\r\n sum += int(a[i])\r\n a[i] = sum\r\na.insert(0, 0)\r\nsum = 0\r\nfor i in range(len(b)):\r\n l = max(0, len(a) - 1 - (len(b) - i))\r\n r = min(len(a) - 2, i)\r\n col1 = a[r + 1] - a[l]\r\n col2 = r - l + 1 - col1\r\n if b[i] == '0':\r\n sum += col1\r\n else:\r\n sum += col2\r\nprint(sum)\r\n", "\"\"\"\r\nhttps://codeforces.com/contest/608/problem/B\r\n01\r\n00111 should output 3\r\n\r\n0011\r\n0110 should output 2\r\n\"\"\"\r\nfirst = [int(i) for i in input()]\r\nsecond = [int(i) for i in input()]\r\n\r\npref_dists = [\r\n [0] + [int(0 != c) for c in second],\r\n [0] + [int(1 != c) for c in second]\r\n]\r\nfor i in range(1, len(second) + 1):\r\n pref_dists[0][i] += pref_dists[0][i - 1]\r\n pref_dists[1][i] += pref_dists[1][i - 1]\r\n\r\ntotal = 0\r\nfor i, c in enumerate(first):\r\n end = len(second) - (len(first) - i)\r\n total += pref_dists[c][end + 1] - pref_dists[c][i]\r\nprint(total)\r\n", "from copy import copy\r\na=input()\r\nb=input()\r\naa=len(a)\r\nbb=len(b)\r\nf=dict(zip([i for i in range(aa)],[0 for j in range(aa)]))\r\nc=bb-aa\r\ndef brraw(b):\r\n global f\r\n for i in range(c+1):\r\n if b[i]=='1':\r\n f[0]+=1\r\n for i in range(1,aa):\r\n f[i]=copy(f[i-1])\r\n if b[i+c]=='1':\r\n f[i]+=1\r\n if b[i-1]=='1':\r\n f[i]-=1\r\nbrraw(b)\r\nres=0\r\nfor i in range(aa):\r\n if a[i]=='0':\r\n res+=f[i]\r\n else:\r\n res+=c+1-f[i]\r\nprint(res)\r\n\r\n", "p = input()\r\ns = input()\r\nn = len(s)\r\nans = 0\r\ndl = len(s) - len(p)\r\nm = ([(0, 0), (0, 1)] if s[0] == '1' else [(0, 0), (1, 0)])\r\nfor i in range(1, n):\r\n if s[i] == '0':\r\n m.append((m[-1][0] + 1, m[-1][1]))\r\n else:\r\n m.append((m[-1][0], m[-1][1] + 1))\r\n\r\nfor i in range(len(p)):\r\n if p[i] == '0':\r\n ans += (m[dl + i + 1][1] - m[i][1])\r\n else:\r\n ans += (m[dl + i + 1][0] - m[i][0])\r\nprint(ans)\r\n", "a = input()\r\nb = input()\r\nans = 0\r\npref = [0 for i in range(len(b) + 1)]\r\nfor i in range(len(b)):\r\n pref[i + 1] = pref[i] + int(b[i])\r\nfor i in range(len(a)):\r\n ans += abs(int(a[i]) * (len(b) - len(a) + 1) - pref[len(b) - len(a) + i + 1] + pref[i])\r\nprint(ans)", "def solve(a,b):\r\n dict_ = {}\r\n ones_count = 0\r\n for i in range(len(a)-len(b)+1):\r\n if a[i] == '1':\r\n ones_count += 1\r\n\r\n dict_[0] = ones_count\r\n\r\n for i in range(1,len(b)):\r\n if a[i-1] == '1':\r\n ones_count -= 1\r\n if a[len(a)-len(b)+i] == '1':\r\n ones_count += 1\r\n dict_[i] = ones_count\r\n\r\n sum_ = 0\r\n for i in range(len(b)):\r\n if b[i] == '0':\r\n sum_ += dict_[i]\r\n else:\r\n sum_ += (len(a)-len(b)+1) - dict_[i]\r\n\r\n return str(sum_)\r\n\r\nb = input()\r\na = input()\r\nprint(solve(a,b))", "I = lambda: list(map(int, input().split()))\r\n\r\ns1, s2 = input(), input()\r\nl1, l2 = len(s1), len(s2)\r\nans, units = 0, 0\r\ndp = [0]\r\nfor i in range(l2):\r\n units += int(s2[i])\r\n dp.append(units)\r\n\r\nfor i in range(l1):\r\n if s1[i] == '0':\r\n ans += dp[l2 - l1 + i + 1] - dp[i]\r\n else:\r\n ans += l2 - l1 + 1 - dp[l2 - l1 + i + 1] + dp[i]\r\nprint(ans)", "x=input()\ny=input()\nlen1=len(x)\nlen2=len(y)\nindex1=0\nindex2=0\nsum0=0\ns=[0]#原数列的前缀和\nfor i in range(len2):\n index1+=1\n s.append(s[index1-1]+int(y[index1-1])) #前缀和\nfor j in range(len1):\n index2+=1\n if x[j]=='0':\n sum0+=s[len2-len1+index2]-s[j]\n else:\n sum0+=len2-len1+1-(s[len2-len1+index2]-s[j])\nprint(sum0) \n\t\t\t\t\t\t\t\t\t\t \t \t\t\t \t\t \t \t\t", "a = input()\nb = input()\nsb = len(b)\nsa = len(a)\npref1 = [0] * (sb + 1)\npref0 = [0] * (sb + 1)\nfor i in range(sb):\n\tpref1[i + 1] = pref1[i] + (b[i] == '1')\n\tpref0[i + 1] = pref0[i] + (b[i] == '0')\n\nres = 0\nend = sb - sa + 1\nfor i in range(sa):\n\tif a[i] == '1':\n\t\tl = i + 1\n\t\tr = i + end\n\t\tres+= pref0[r] - pref0[l - 1]\n\telse:\n\t\tl = i + 1\n\t\tr = i + end\n\t\tres+= pref1[r] - pref1[l - 1]\nprint(res)\n", "a = input()\nb = input()\n\nnumOf0 = [0 for i in range(len(b) + 1)]\nnumOf1 = [0 for i in range(len(b) + 1)]\nr = 0\n\nfor i in range(len(b)):\n numOf0[i] = numOf0[i-1] + (b[i] == '0')\n numOf1[i] = numOf1[i-1] + (b[i] == '1')\n \nfor i in range(len(a)):\n r += (numOf1[len(b)-len(a)+i] - numOf1[i-1]) if a[i] == '0' else (numOf0[len(b)-len(a)+i] - numOf0[i-1])\n\nprint(r)\n \t \t \t \t\t\t\t \t\t\t \t\t\t \t\t\t \t\t\t\t", "if __name__ == \"__main__\":\r\n\ta = str(input())\r\n\tb = str(input())\r\n\tn, m = len(a), len(b)\r\n\tones, sum = 0, 0\r\n\tdiff = m - n + 1\r\n\tfor i in range(diff):\r\n\t\tif(b[i] == '1'): ones += 1\r\n\tfor i in range(n):\r\n\t\tif a[i] == '0': sum += ones\r\n\t\telse :\r\n\t\t\tsum += (diff - ones)\r\n\t\tif i == n - 1:\r\n\t\t\tbreak\r\n\t\tif b[i] == '1':\r\n\t\t\tones -= 1\r\n\t\tif b[i + diff] == '1':\r\n\t\t\tones += 1\r\n\tprint(sum)\r\n\t\r\n\r\n\t\t\r\n", "a=input()\r\nb=input()\r\nc=0\r\nd=0\r\ne=len(b)-len(a)+1\r\n\r\nfor i in range(len(b)-len(a)+1):\r\n c+=int(b[i])\r\n\r\nfor j in range(len(a)):\r\n f=int(a[j])\r\n if f==1:\r\n d=d+e-c\r\n else:\r\n d=d+c\r\n if j==len(a)-1:\r\n break\r\n c=c+int(b[e+j])\r\n c=c-int(b[j])\r\n\r\nprint(d)", "a=[int(x) for x in input()]\nb=[int(x) for x in input()]\nA=len(a)\nB=len(b)\nc=[[b[0]^1]+[0]*(B-1),[b[0]]+[0]*(B-1)]\nfor i in range(1,B):\n c[0][i]=c[0][i-1]+(b[i]^1)\nfor i in range(1,B):\n c[1][i]=c[1][i-1]+b[i]\nans=0\nfor i in range(A):\n ans+=c[a[i]^1][i+B-A]-(c[a[i]^1][i-1] if i!=0 else 0)\nprint(ans)\n\n", "a=input()\r\nb=input()\r\n\r\nA=len(a)\r\nB=len(b)\r\nd=B-A+1\r\n\r\nl=[-1]*A\r\n\r\ncount=0\r\n\r\nfor i in range (d):\r\n if b[i]=='1':\r\n count += 1\r\n\r\nl[0]=count\r\nc=0\r\n\r\nfor i in range (d, B):\r\n if b[i] == '1':\r\n count += 1\r\n if b[c] == '1':\r\n count -= 1\r\n c += 1\r\n l[c]=count\r\n\r\nnet=0\r\n\r\nfor i in range (A):\r\n if a[i] == '0':\r\n net += l[i]\r\n else:\r\n net += d - l[i]\r\n\r\nprint(net)\r\n", "a, b, f, g = input(), input(), [[0], [0]], lambda x: 0 if x == '1' else 1\r\n\r\nfor i in b:\r\n f[0].append( f[0][-1] + (i == '0'))\r\n f[1].append( f[1][-1] + (i == '1'))\r\n\r\nans = sum([ f[g(c)][ len(b) - len(a) + i + 1 ] - f[g(c)][i] for i, c in enumerate(a)])\r\nprint(ans)", "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nfrom collections import Counter, defaultdict\r\nfrom sys import stdin, stdout\r\nimport io\r\nimport math\r\nimport heapq\r\nimport bisect\r\nimport collections\r\ndef ceil(a, b):\r\n return (a + b - 1) // b\r\ninf = float('inf')\r\ndef get():\r\n return stdin.readline().rstrip()\r\nmod = 10 ** 5 + 7\r\ndef decimalToBinary(n):\r\n return bin(n).replace(\"0b\", \"\")\r\n# for _ in range(int(get())):\r\n# n=int(get())\r\n# l=list(map(int,get().split()))\r\n# = map(int,get().split())\r\ndef fun(a,b):\r\n ans = 0\r\n l1 = [];\r\n l2 = []\r\n\r\n s1 = 0;\r\n s2 = 0\r\n for i in range(len(b)):\r\n if b[i] == \"0\":\r\n s1 += 1\r\n else:\r\n s2 += 1\r\n l1.append(s1)\r\n l2.append(s2)\r\n for i in range(1, len(a)):\r\n if a[i] == \"0\":\r\n ans = ans - l2[i - 1]\r\n else:\r\n ans = ans - l1[i - 1]\r\n return ans\r\na=list(get())\r\nb=list(get())\r\nansf=0\r\nansf += b.count(\"1\") * a.count(\"0\")\r\nansf += b.count(\"0\") * a.count(\"1\")\r\nansf=ansf+fun(a,b)+fun(a[::-1],b[::-1])\r\nprint(ansf)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "a=input()\r\nb=input()\r\nl1=len(a)\r\nl2=len(b)\r\nC=l2-l1+1\r\npref=[]\r\ns=0\r\nfor i in range(l2):\r\n pref.append(s)\r\n s+=b[i]=='0'\r\npref.append(s)\r\ns2=0\r\nfor i in range(l1):\r\n if a[i]=='0':\r\n new=pref[i+C]-pref[i]\r\n s2+=new\r\n else:\r\n new=C-(pref[i+C]-pref[i])\r\n s2+=new\r\n #print(s2,new)\r\nprint(l1*C-s2)", "a = list(map(int, input()))\r\nb = list(map(int, input()))\r\n\r\nps = [0] * (len(b) + 1)\r\nfor i in range(len(b)):\r\n ps[i + 1] = ps[i] + b[i]\r\n\r\nans = 0\r\nfor i in range(len(a)):\r\n left = i\r\n right = len(b) - len(a) + i + 1\r\n sub = ps[right] - ps[left]\r\n if a[i] == 1:\r\n sub = right - left - sub\r\n ans += sub\r\nprint(ans)", "a = list(input())\r\na = [int(x) for x in a]\r\n\r\nb = list(input())\r\nb = [int(x) for x in b]\r\n\r\nn = len(a)\r\nm = len(b)\r\n\r\nans = 0\r\nfor i in range(n):\r\n ans+=a[i]^b[i]\r\nones = [0 for i in range(m)]\r\nzeros = [0 for i in range(m)]\r\n# print(b)\r\nfor i in range(m):\r\n if b[i]:\r\n ones[i]=1\r\n else:\r\n zeros[i]=1\r\n# print(ones,zeros)\r\nfor i in range(1,m):\r\n ones[i]+=ones[i-1]\r\n zeros[i]+=zeros[i-1]\r\n \r\nfor i in range(n):\r\n if a[i]==1:\r\n ans+=zeros[m-n+i]-zeros[i]\r\n else:\r\n ans+=ones[m-n+i]-ones[i]\r\nprint(ans)\r\n", "#!/usr/bin/env python3\n\na = input()\nb = input()\n\nsumi = 0\n\nfor i in range(len(b) - len(a) + 1):\n if b[i] == '1':\n sumi += 1\n\nlowest = 0\nhighest = len(b) - len(a) + 1\n\ntotal = 0\nfor i in range(len(a)):\n if a[i] == '0':\n total += sumi\n else:\n total += highest - lowest - sumi\n if b[lowest] == '1':\n sumi -= 1\n if highest < len(b) and b[highest] == '1':\n sumi += 1\n lowest += 1\n highest += 1\nprint(total)\n", "from sys import stdin\r\n\r\ns=stdin.readline().strip()\r\ns1=stdin.readline().strip()\r\nones=[0 for i in range(len(s1)+10)]\r\nzeros=[0 for i in range(len(s1)+10)]\r\nfor i in range(len(s1)):\r\n if s1[i]=='1':\r\n ones[i]=1\r\n else:\r\n zeros[i]=1\r\n if i>0:\r\n ones[i]+=ones[i-1]\r\n zeros[i]+=zeros[i-1]\r\nr=len(s1)-len(s)\r\nans=0\r\nfor i in range(len(s)):\r\n if s[i]=='0':\r\n ans+=ones[r]-ones[i-1]\r\n else:\r\n ans+=zeros[r]-zeros[i-1]\r\n r+=1\r\nprint(ans)\r\n \r\n \r\n", "a = input()\r\nb = input()\r\n\r\nones = [1 if b[0] == '1' else 0]\r\nzeroes = [1 if b[0] == '0' else 0]\r\n\r\nfor i in range(1, len(b)):\r\n if b[i] == '1':\r\n ones.append(ones[-1] + 1)\r\n zeroes.append(zeroes[-1])\r\n else:\r\n ones.append(ones[-1])\r\n zeroes.append(zeroes[-1] + 1)\r\n\r\nans = 0\r\nstart = -1\r\npoint = len(a)\r\n\r\nwhile start >= -len(a):\r\n if a[start] == '1':\r\n if start == -len(a) and point - 2 == -1:\r\n ans += zeroes[start]\r\n else:\r\n ans += zeroes[start] - zeroes[point - 2]\r\n else:\r\n if start == -len(a) and point - 2 == -1:\r\n ans += ones[start]\r\n else:\r\n ans += ones[start] - ones[point - 2]\r\n\r\n point -= 1\r\n start -= 1\r\n\r\n\r\nprint(ans)", "x=input()\ny=input()\nlens=len(y)-len(x)+1\nl1=len(x)\nl2=len(y)\nindex1=0\nindex2=0\nsum=0\ns=[0]\nfor i in range(l2):\n index1+=1\n s.append(s[index1-1]+int(y[index1-1])) #前缀和\nfor i in range(l1):\n index2+=1\n if x[i]=='0':\n sum+=s[len(y)-len(x)+index2]-s[i]\n else:\n sum+=lens-(s[len(y)-len(x)+index2]-s[i])\nprint(sum)\n\t\t\t\t \t \t \t\t \t \t \t\t\t \t\t \t", "import sys\r\ninput=sys.stdin.readline\r\na=input()\r\nb=input()\r\nna=len(a)\r\nnb=len(b)\r\nc=0\r\nd=0\r\ne=[[0,0]]\r\nfor i in range(nb):\r\n if b[i]==\"0\":\r\n c+=1\r\n else:\r\n d+=1\r\n e.append([c,d])\r\ns=0\r\nfor i in range(na):\r\n if a[i]==\"0\":\r\n s+=e[i+nb-na+1][1]-e[i][1]\r\n elif a[i]==\"1\":\r\n s+=e[i+nb-na+1][0]-e[i][0]\r\nprint(s)", "from sys import stdin,stdout\r\n# input=stdin.readline\r\nmod=10**9+7\r\nt=1\r\nfor _ in range(t):\r\n a=input()\r\n b=input()\r\n n=len(a)\r\n m=len(b)\r\n dp=[[0 for i in range(2)] for j in range(m+1)]\r\n dp[1][0]=int(b[0])^1\r\n dp[1][1]=int(b[0])\r\n for i in range(2,m+1):\r\n dp[i][0]=dp[i-1][0]+(int(b[i-1])^1)\r\n dp[i][1]=dp[i-1][1]+int(b[i-1])\r\n ans=0\r\n for i in range(n):\r\n count0=dp[m-n+i+1][0]-dp[i][0]\r\n count1=dp[m-n+i+1][1]-dp[i][1]\r\n ans+=count0*int(a[i])+count1*(int(a[i])^1)\r\n print(ans)", "a = input()\r\nb = input()\r\n\r\nn = len(b) - len(a) + 1\r\nc = []\r\nc.append(b[:n].count('1'))\r\nfor i in range(len(a) - 1):\r\n ci = c[-1] + int(b[n+i]) - int(b[i])\r\n c.append(ci)\r\n\r\nsol = 0\r\nfor i, ai in enumerate(a):\r\n if ai == '0':\r\n sol += c[i]\r\n else:\r\n sol += n - c[i]\r\n\r\nprint(sol)\r\n", "a = input()\nb = input()\ndata = len(a) * [0]\ncur_count = [0, 0]\nfor _ in range(len(b) - len(a) + 1):\n cur_count[int(b[_])] += 1\ndata[0] = [cur_count[0], cur_count[1]]\n\nlp, rp = 0, len(b) - len(a)\nfor i in range(len(b)):\n cur_count[int(b[lp])] -= 1\n lp += 1\n rp += 1\n if rp == len(b):\n break\n cur_count[int(b[rp])] += 1\n data[i + 1] = [cur_count[0], cur_count[1]]\n\nres = 0\nfor j in range(len(a)):\n res += data[j][(int(a[j]) + 1) % 2]\nprint(res)\n", "import sys\ninput = lambda: sys.stdin.readline().rstrip()\nfrom collections import deque,defaultdict,Counter\nfrom itertools import permutations,combinations\nfrom bisect import *\nfrom heapq import *\nfrom math import ceil,gcd,lcm,floor\n\nS = input()\nT = input()\nans = 0\nl = defaultdict(int)\nfor i in range(len(T)-len(S)+1):\n l[T[i]]+=1\n\nx = 0\nif S[x]==\"1\":ans+=l[\"0\"]\nelse:ans+=l[\"1\"]\n\nnum = len(T)-len(S)+1\nfor i in range(num,len(T)):\n x+=1\n l[T[i]]+=1\n l[T[i-num]]-=1\n if S[x]==\"1\":ans+=l[\"0\"]\n else:ans+=l[\"1\"]\nprint(ans)", "s= input()\r\nt= input()\r\nd= len(t)- len(s) +1\r\nans=0\r\nl1=[0]\r\n\r\nfor i in range(len(t)):\r\n if t[i]=='1':\r\n ans+=1\r\n l1.append(ans)\r\nans=0\r\n\r\nfor i in range(len(s)):\r\n if s[i]=='0':\r\n #print(d+i)\r\n ans+= l1[d+i] - l1[i]\r\n else:\r\n ans+= d-l1[d+i] + l1[i]\r\n\r\nprint(ans)\r\n\r\n#print(l1)", "a, b = input(), input()\nc = [[0] * 210000, [0] * 210000]\nfor i, d in enumerate(b):\n for t in range(2):\n c[t][i + 1] = c[t][i] + (d == str(t))\nprint(sum(c[int(t)^1][len(b) - len(a) + 1 + i] - c[int(t)^1][i] for i, t in enumerate(a))) \n", "s= list(map(int,[x for x in input()]))\r\nb= list(map(int,[x for x in input()]))\r\nanswer=0\r\n\r\npre=[b[0] for i in range(len(b))]\r\nfor i in range(1,len(b)):\r\n pre[i]= pre[i-1]+b[i]\r\npre.append(0)\r\n\r\nfor i in range(len(s)):\r\n right = len(b)-(len(s)-i)\r\n if(s[i]==0):\r\n answer+= (pre[right]-pre[i-1])\r\n else:\r\n answer+= (right - (i-1) -(pre[right]-pre[i-1]) )\r\n\r\nprint(answer)\r\n", "def main():\n aa, bb, zz, oo = input(), input(), [0], [0]\n z = o = 0\n for c in bb:\n if c == '0':\n z += 1\n else:\n o += 1\n zz.append(z)\n oo.append(o)\n print(sum((oo[stop] - oo[start]) if c == '0' else (zz[stop] - zz[start])\n for c, start, stop in zip(aa, range(999999), range(len(bb) - len(aa) + 1, 999999))))\n\n\nif __name__ == '__main__':\n main()\n", "s = [bool(int(i)) for i in input()]\nn = [bool(int(i)) for i in input()]\nk = 0\na = 0\nb = 0\nn1 = [0]\nfor i in n:\n\ta+=i\n\tn1.append(a)\nfor i in range(len(s)):\n\tif not s[i]:\n\t\tk+=(n1[len(n)-len(s)+i+1]-n1[i])\n\telse:\n\t\tk+=(len(n)-len(s)+i+1 - n1[len(n)-len(s)+i+1]-(i - n1[i]))\nprint(k)\n\t\n", "import math\r\nimport sys\r\ninp = lambda: sys.stdin.readline()[:-1]\r\nmass = lambda: list(map(int, input().split()))\r\n\r\n\r\ndef solve():\r\n a = inp()\r\n b = inp()\r\n pref = [[abs(int(b[0]) - 1), int(b[0])]]\r\n for i in range(1, len(b)):\r\n pref.append([pref[-1][0] + abs(int(b[i]) - 1), pref[-1][1] + int(b[i])])\r\n\r\n res = 0\r\n for i in range(len(a)):\r\n t = abs(int(a[i]) - 1)\r\n res += pref[-1][t]\r\n if i != 0:\r\n res -= pref[i - 1][t]\r\n if i != len(a) - 1:\r\n res -= pref[-1][t] - pref[-(len(a) - i)][t]\r\n print(res)\r\n\r\n\r\n\r\nsolve()", "a=str(input())\nb=str(input())\ncount=0\nal=len(a)\nbl=len(b)\ns=b[:bl-al+1].count('1')\nfor i in range(al-1):\n if a[i]=='0':\n count+=s\n else:\n count+=bl-al+1-s\n s+=int(b[bl-al+i+1])-int(b[i])\n\nif a[-1]=='0':\n count+=s\nelse:\n count+=bl-al+1-s\nprint(count)\n", "from sys import stdin\r\n\r\n\r\n# main start\r\na = stdin.readline().strip()\r\nb = stdin.readline().strip()\r\n\r\none = [0] * len(b)\r\nzero = [0] * len(b)\r\n\r\nif b[0] == '0':\r\n\tzero[0] += 1\r\nelse:\r\n\tone[0] += 1\r\nfor i in range(1, len(b)):\r\n\tzero[i] = zero[i - 1]\r\n\tone[i] = one[i - 1]\r\n\tif b[i] == '0':\r\n\t\tzero[i] += 1\r\n\telse:\r\n\t\tone[i] += 1\r\n\r\np = len(b) - len(a)\r\nans = 0\r\nfor i in range(len(a)):\r\n\tif i == 0:\r\n\t\tif a[i] == '1':\r\n\t\t\tans += zero[i + p]\r\n\t\telse:\r\n\t\t\tans += one[i + p]\r\n\telse:\r\n\t\tif a[i] == '1':\r\n\t\t\tans += zero[i + p] - zero[i - 1]\r\n\t\telse:\r\n\t\t\tans += one[i + p] - one[i - 1]\r\nprint(ans)\r\n\t\t\r\n\t\t", "a = input()\r\nb = input()\r\ndp = [[0,0] for _ in range(len(b)+1)]\r\nfor i in range(len(b)):\r\n dp[i+1][0] = dp[i][0]\r\n dp[i+1][1] = dp[i][1]\r\n if b[i]=='1':\r\n dp[i+1][1]+=1\r\n else:\r\n dp[i+1][0]+=1\r\nla = len(a)\r\nans = 0\r\nfor i in range(la-1,-1,-1):\r\n ed = len(b)-(la-1-i)\r\n st = i\r\n if a[i]=='0':\r\n ans+= dp[ed][1]-dp[st][1]\r\n else:\r\n ans+= dp[ed][0]-dp[st][0]\r\nprint(ans)", "def binary(b1, b2):\r\n lst=[0]\r\n for i in range(len(b2)):\r\n lst.append(lst[i]+int(b2[i]))\r\n tmp=len(b2)-len(b1)\r\n ans=0\r\n for i in range(len(b1)):\r\n if b1[i]=='0':\r\n ans+=lst[i+tmp+1]-lst[i]\r\n else:\r\n ans+=tmp+1-(lst[i+tmp+1]-lst[i])\r\n\r\n return ans\r\n\r\nb1=input()\r\nb2=input()\r\nprint(binary(b1,b2))\r\n", "# Dictionary == Hash Collision\r\n\r\nfrom sys import stdin\r\nfrom bisect import bisect_left as bl, bisect_right as br\r\nfrom collections import defaultdict, Counter, deque\r\n\r\n\r\ndef input():\r\n return stdin.readline().strip()\r\n\r\n\r\ndef read(default=int):\r\n return list(map(default, input().split()))\r\n\r\n\r\ndef solve():\r\n a = list(map(int, list(input())))\r\n b = list(map(int, list(input())))\r\n ans = z = o = 0\r\n lst = [(0, 0)] + [0] * len(b)\r\n for idx, el in enumerate(b):\r\n z += int(not el)\r\n o += int(el)\r\n lst[idx + 1] = (z, o)\r\n # print(lst)\r\n for i in range(len(a)):\r\n if a[i]:\r\n ans += lst[len(b) - len(a) + 1 + i][0] - lst[i][0]\r\n else:\r\n ans += lst[len(b) - len(a) + 1 + i][1] - lst[i][1]\r\n return ans\r\n\r\n\r\nt = 1\r\nfor test in range(t):\r\n print(solve())\r\n", "str1=input() ; str2=input() ; lenth1=len(str1) ; lenth2=len(str2) ; summ=0 ; cum=0 ; prefix=[]\r\nfor i in str2:\r\n cum+=int(i) ; prefix.append(cum) \r\nfor i in range(lenth1):\r\n x=lenth2-lenth1+i\r\n if i==0:\r\n summ+=abs((lenth2-lenth1+1)*int(str1[i])-prefix[x])\r\n else:\r\n summ+=abs((lenth2-lenth1+1)*int(str1[i])-(prefix[x]-prefix[i-1]))\r\nprint(summ)", "a = input().rstrip()\r\nb = input().rstrip()\r\nn, m = len(a), len(b)\r\nq = [0] * (m + 1)\r\nfor i in range(1, m + 1):\r\n q[i] = q[i - 1] + int(b[i - 1])\r\nans = 0\r\nw = m - n + 1\r\nfor i in range(n):\r\n if a[i] == '0':\r\n ans += q[w + i] - q[i]\r\n else:\r\n ans += w - (q[w + i] - q[i])\r\nprint(ans)", "#author: Sushmanth\r\n\r\nfrom sys import stdin\r\ninput = stdin.readline\r\n \r\ninp = lambda : list(map(int,input().split()))\r\n\r\ndef answer():\r\n\r\n\r\n pref = [0]\r\n for i in range(n):\r\n pref.append(pref[-1] + (b[i] == '1'))\r\n\r\n\r\n ans = 0\r\n for i in range(m):\r\n\r\n\r\n left = i\r\n right = n - (m - i) + 1\r\n\r\n ones = pref[right] - pref[left]\r\n if(a[i] == '0'):ans += ones\r\n else:\r\n ans += (right - left) - ones\r\n\r\n\r\n return ans\r\n \r\n\r\nfor T in range(1):\r\n\r\n a = input().strip()\r\n b = input().strip()\r\n\r\n n , m = len(b) , len(a)\r\n \r\n \r\n print(answer())\r\n \r\n\r\n \r\n", "a = input()\nb = input()\nnum_n = [0]\nnum_one = [0]\nfor elem in a:\n if elem == '1':\n num_one.append(num_one[-1] + 1)\n num_n.append(num_n[-1])\n else:\n num_one.append(num_one[-1])\n num_n.append(num_n[-1] + 1) \nres = 0\nla = len(a)\nlb = len(b)\nfor i in range(lb):\n left = max(0, i - lb + la)\n right = min(la - 1, i)\n if b[i] == '1':\n res += num_n[right + 1] - num_n[left]\n else:\n res += num_one[right + 1] - num_one[left]\nprint(res)", "sub = input().rstrip()\r\ns = input().rstrip()\r\n\r\ndef sumRange(left, right):\r\n return psums[right + 1] - psums[left]\r\n\r\nn = len(s)\r\nsubSize = len(sub)\r\npsums = [0]\r\nfor i, ch in enumerate(sub):\r\n psums.append(psums[-1] + int(ch))\r\nret = 0\r\nfor i in range(len(s)):\r\n ch = s[i]\r\n left = max(0, i + subSize - n)\r\n right = min(i, subSize - 1)\r\n oneCnt = sumRange(left, right)\r\n size = right - left + 1\r\n ret += oneCnt if ch == '0' else size - oneCnt\r\nprint(ret)", "a = input()\r\nb = input()\r\n\r\ncs_one = [0]\r\nfor ai in a:\r\n cs_one.append(cs_one[-1] + int(ai=='1'))\r\n\r\ndef find_zeros_ones_in_range(l, r):\r\n n_ones = cs_one[r+1] - cs_one[l]\r\n n_zeros = (r-l+1) - n_ones\r\n return n_zeros, n_ones\r\n\r\nsum_hamming_dis = 0\r\n\r\nfor i, bi in enumerate(b):\r\n n_before = i\r\n n_after = len(b) - n_before - 1\r\n l = max(len(a) - 1 - n_after, 0)\r\n r = min(n_before, len(a) -1)\r\n nz, no = find_zeros_ones_in_range(l, r)\r\n if bi == '0':\r\n sum_hamming_dis += no\r\n else:\r\n sum_hamming_dis += nz\r\n\r\nprint(sum_hamming_dis)", "a=input()\r\nb=input()\r\nl=len(a)\r\nn=len(b)\r\nans=0\r\n\r\n \r\nans1,ans0=[0],[0]\r\ncount0,count1=0,0 \r\nfor i in range(n):\r\n if b[i]=='0':\r\n count0+=1 \r\n ans1.append(count1)\r\n ans0.append(count0)\r\n else:\r\n count1+= 1 \r\n ans1.append(count1)\r\n ans0.append(count0)\r\n# print(ans1)\r\n# print(ans0)\r\n \r\nfor i in range(len(a)):\r\n if a[i]=='0':\r\n ans+=abs(ans1[n-l+i+1]-ans1[i])\r\n else:\r\n# print(aa)\r\n \r\n ans+=abs(ans0[n-l+i+1]-ans0[i])\r\n\r\n#1 print(ans)\r\nprint(ans)", "a = input()\nb = input()\none_count = []\nc = 0\nfor ch in b:\n\tone_count.append(c)\n\tif ch == '1':\n\t\tc +=1\none_count.append(c)\n\nhamming = 0\nlen_a = len(a)\nlen_b = len(b)\nfor i in range(len_a):\n\tj = len_b - (len_a - i - 1)\n\tn_ones = one_count[j] - one_count[i]\n\tn_zeroes = j - i - n_ones\n\t\n\thamming += n_ones if a[i] == '0' else n_zeroes\n\nprint(hamming)", "def main():\r\n a = input()\r\n b = input()\r\n len_a = len(a)\r\n len_b = len(b)\r\n num0 = [0 for _ in range(len_b)]\r\n num1 = [0 for _ in range(len_b)]\r\n for i in range(len_b):\r\n if b[i] == '0':\r\n num0[i] = 1\r\n else:\r\n num1[i] = 1\r\n if i > 0:\r\n num0[i] += num0[i - 1]\r\n num1[i] += num1[i - 1]\r\n ans = 0\r\n for i in range(len_a):\r\n if a[i] == '0':\r\n ans += num1[len_b - len_a + i]\r\n if i > 0:\r\n ans -= num1[i - 1]\r\n if a[i] == '1':\r\n ans += num0[len_b - len_a + i]\r\n if i > 0:\r\n ans -= num0[i - 1]\r\n\r\n print(ans)\r\nmain()", "a, b, s, res = \" \" + input(), \" \" + input(), [0], 0\nn, m = len(a)-1, len(b)-1\nfor i in range(1, n+1):\n s.append(s[i-1] + (a[i] == \"1\"))\nfor i in range(1, m+1):\n l, r = 1 if m-i+1 >= n else n+i-m, min(n, i)\n if b[i] == \"0\":\n res += s[r]-s[l-1]\n else:\n res += (r-l+1)-s[r]+s[l-1]\nprint(res)\n", "a = input()\nb = input()\n\ncum_freq = [0]\nif b[0] == '1':\n\tcum_freq[0] = 1\nfor i in range(1, len(b)):\n\tcum_freq.append(cum_freq[-1])\n\tif b[i] == '1':\n\t\tcum_freq[-1] += 1\n\noverlap = 0\na_count = 0\nif a[0] == '1':\n\toverlap += cum_freq[len(b)-len(a)]\n\ta_count += 1\n\nfor i in range(1, len(a)):\n\tif a[i] == '1':\n\t\toverlap += (cum_freq[len(b)-len(a)+i] - cum_freq[i-1])\n\t\ta_count += 1\n\nb_count = cum_freq[len(a)-1]\nfor i in range(len(a), len(b)):\n\tb_count += (cum_freq[i] - cum_freq[i-len(a)])\n# print(a_count, b_count, overlap)\nprint(a_count*(len(b)-len(a)+1) + b_count - 2*overlap)", "#!/usr/bin/python \nstr1 = input()\nstr2 = input()\ndiff = len(str2) - len(str1)\narr1 = [ 0 for x in range(len(str2))]\narr2 = [ 0 for x in range(len(str2))]\nif(int(str2[0]) == 1):\n\tarr1[0] = 1\nelse:\n\tarr2[0] = 1\n\nfor x in range(1,len(str2)):\n\tif(int(str2[x]) == 1):\n\t\tarr1[x] += arr1[x-1] + 1\n\t\tarr2[x] = arr2[x-1]\n\n\telse:\n\t\tarr2[x] += arr2[x-1] + 1\n\t\tarr1[x] = arr1[x-1]\nans = 0\nif(int(str1[0]) == 1):\n\tans = arr2[diff]\nelse:\n\tans = arr1[diff]\n\n\n\n\nfor x in range(1,len(str1)):\n\tif(int(str1[x]) ==1 ):\n\t\tans += arr2[x+diff] - arr2[x-1]\n\telse:\n\t\tans += arr1[x+diff] - arr1[x-1]\n\nprint(ans)\n\n \n\n", "import sys\r\ninput = sys.stdin.readline\r\n\r\na = input()[:-1]\r\nb = input()[:-1]\r\nn = len(a)\r\nm = len(b)\r\nx = m-n\r\no = b[:x+1].count('1')\r\nc = o if a[0] == '0' else x+1-o\r\nfor i in range(n-1):\r\n if b[i] == '1':\r\n o -= 1\r\n if b[i+x+1] == '1':\r\n o += 1\r\n c += (o if a[i+1] == '0' else x+1-o)\r\nprint(c)", "a=input()\r\nb=input()\r\n\r\nrange_count=len(b)-len(a)+1\r\ncount_0=b[:range_count].count('0')\r\nresult=count_0 if a[0]=='1' else (range_count-count_0)\r\nfor i in range(1,len(a)):\r\n\tif b[i-1]!=b[range_count+i-1]:\r\n\t\tcount_0+=1 if b[i-1]=='1' else -1\r\n\tresult+=count_0 if a[i]=='1' else (range_count-count_0)\r\nprint(result)", "a=input()\r\nb=input()\r\nlb=len(b)\r\nla=len(a)\r\nc0, c1= b[0:lb-la+1].count('0'), b[0:lb-la+1].count('1')\r\ns=c0 if a[0]=='1' else c1\r\nfor i in range(1, la):\r\n\tif int(b[i-1])==1: c1-=1\r\n\telse: c0-=1\r\n\tif int(b[i+lb-la])==1: c1+=1\r\n\telse: c0+=1\r\n\ts+=c1 if a[i]=='0' else c0\r\n\r\nprint(s)\r\n", "c=[];d=[]\r\nc.append(0)\r\nd.append(0)\r\nsum=0;k=0;l=0\r\na=list(map(int,input()))\r\nb=list(map(int,input()))\r\nfor i in range(len(b)):\r\n if b[i]==0:\r\n k+=1\r\n else:\r\n l+=1\r\n c.append(k)\r\n d.append(l)\r\n#print(c,d)\r\nfor j in range(len(a)):\r\n if a[j]==0:\r\n sum+=d[len(b)-len(a)+j+1]-d[j]\r\n else:\r\n sum+=c[len(b)-len(a)+j+1]-c[j]\r\nprint(sum)", "import sys\r\nimport math\r\nimport collections as cl\r\nfrom pprint import pprint as pp\r\nmod = 1000000007\r\n\r\n\r\ndef vector(size, val=0):\r\n vec = [val for i in range(size)]\r\n return vec\r\n\r\n\r\ndef matrix(rowNum, colNum, val=0):\r\n mat = []\r\n for i in range(rowNum):\r\n collumn = [val for j in range(colNum)]\r\n mat.append(collumn)\r\n return mat\r\n\r\n\r\ns, t = input(), input()\r\nn, m = len(s), len(t)\r\nx, y = vector(n), vector(n)\r\n\r\nc0, c1 = 0, 0\r\nfor i in range(m - n + 1):\r\n if t[i] == '0':\r\n c0 += 1\r\n else:\r\n c1 += 1\r\nx[0], y[0] = c0, c1\r\n\r\nfor i in range(1, n):\r\n if t[i + m - n] == '0':\r\n c0 += 1\r\n else:\r\n c1 += 1\r\n if t[i - 1] == '0':\r\n c0 -= 1\r\n else:\r\n c1 -= 1\r\n x[i], y[i] = c0, c1\r\n\r\nans = 0\r\nfor i in range(n):\r\n if s[i] == '0':\r\n ans += y[i]\r\n else:\r\n ans += x[i]\r\nprint(ans)\r\n", "import sys\n\na = sys.stdin.readline().rstrip()\nb = sys.stdin.readline().rstrip()\n\nla, lb = len(a), len(b)\nsum, cur = 0, 0\n\nfor i in range(lb - la + 1):\n cur += int(b[i])\n\nfor i in range(la):\n if a[i] == '0':\n sum += cur\n else:\n sum += (lb - la + 1) - cur\n\n if i != la - 1:\n if b[i] == '1':\n cur -= 1\n if b[lb-la+i+1] == '1':\n cur += 1\n\nprint(sum)\n\n", "a = input()\r\nb = input()\r\nn = len(b)\r\nm = len(a)\r\nans = 0\r\nones = [0]*(n+1)\r\nfor i in range(1,n+1):\r\n ones[i] = ones[i-1] + int(b[i-1])\r\n\r\nfor i in range(m):\r\n x = i\r\n y = n - m + i\r\n if a[i] == \"0\":\r\n ans += ones[y+1] - ones[x]\r\n elif a[i] == \"1\":\r\n ans += abs(((y-x)+1) - (ones[y + 1] - ones[x]))\r\n\r\nprint(ans)\r\n\r\n", "a = input()\r\nb = input()\r\nl = len(b)\r\np0 = [0] * (l + 1)\r\ns0 = [0] * (l + 1)\r\np1 = [0] * (l + 1)\r\ns1 = [0] * (l + 1)\r\n\r\nfor i in range(l):\r\n if b[i] == '0':\r\n p1[i + 1] = p1[i] + 1\r\n p0[i + 1] = p0[i]\r\n else: \r\n p0[i + 1] = p0[i] + 1\r\n p1[i + 1] = p1[i]\r\n \r\nfor i in range(l - 1, -1, -1):\r\n if b[i] == '0':\r\n s1[i] = s1[i + 1] + 1\r\n s0[i] = s0[i + 1]\r\n else:\r\n s0[i] = s0[i + 1] + 1\r\n s1[i] = s1[i + 1]\r\n \r\nl1 = len(a)\r\nres = 0\r\nfor i in range(l1):\r\n if a[i] == '0':\r\n res += p0[l] - p0[i] - s0[l - l1 + i + 1]\r\n if a[i] == '1':\r\n res += p1[l] - p1[i] - s1[l - l1 + i + 1] \r\nprint(res)", "a=[int(i) for i in list(input())]\r\nb=[int(i) for i in list(input())]\r\naa=len(a)\r\nbb=len(b)\r\nl=t=0\r\nt=bb-aa+1\r\nans=0\r\nfor i in range(bb-aa+1):\r\n l+=int(b[i])\r\nfor i in range(aa):\r\n if a[i]==1:\r\n ans+=t-l\r\n else:\r\n ans+=l \r\n if i==len(a)-1:\r\n break \r\n l+=int(b[t+i])\r\n l-=int(b[i])\r\nprint(ans) \r\n", "from sys import stdin, stdout\nrd = lambda: list(map(int, stdin.readline().split()))\nrds = lambda: stdin.readline().rstrip()\nii = lambda: int(stdin.readline())\nINF = 1 << 62\nmod = 10**9 + 7\n\na = input()\nb = input()\nl = len(a)\n\nps = [(0,0)]\nfor i in range(len(b)):\n zero, one = ps[-1]\n\n if b[i] == '1':\n one += 1\n else:\n zero += 1\n ps.append((zero, one))\n\nres = 0\n\n#print('a', a)\n#print('b', b)\n#print('ps', ps)\n\n# for each a[i] find counts\n# for prefix i:len(b)-len(a) + i [)\nfor i in range(len(a)):\n r0, r1 = ps[len(b)-len(a) + i + 1]\n l0, l1 = ps[i]\n c0 = r0 - l0\n c1 = r1 - l1\n\n if a[i] == '1':\n x = c0\n else:\n x = c1\n\n# print(i, a[i], x)\n res += x\n\n\n#stdout.write(' '.join(map(str, ar)))\nstdout.write(f'{res}')\n\n", "a=input()\r\nb=input()\r\na1=[0]\r\ncurr=0\r\nfor i in b:\r\n if i=='1':\r\n curr+=1\r\n a1.append(curr)\r\na2=[0]\r\ncurr=0\r\nfor i in b:\r\n if i=='0':\r\n curr+=1\r\n a2.append(curr)\r\nans=0\r\nfor i in range(len(a)):\r\n if a[i]=='0':\r\n t=a1[len(b)-len(a)+i+1]-a1[i]\r\n if t>=0:\r\n ans+=t\r\n else:\r\n break\r\nfor i in range(len(a)):\r\n if a[i]=='1':\r\n t=a2[len(b)-len(a)+i+1]-a2[i]\r\n if t>=0:\r\n ans+=t\r\n else:\r\n break\r\nprint(ans)\r\n", "read = lambda: list(map(int, input()))\r\na, b = read(), read()\r\nn, m = len(a), len(b)\r\ncnt1 = [0] * (n + 1)\r\ncnt0 = [0] * (n + 1)\r\nif a[0]: cnt1[0] = 1\r\nelse: cnt0[0] = 1\r\nfor i in range(1, n):\r\n cnt1[i] = cnt1[i - 1]\r\n cnt0[i] = cnt0[i - 1]\r\n if a[i]: cnt1[i] += 1\r\n else: cnt0[i] += 1\r\nSum = 0\r\nfor i in range(m):\r\n L = max(0, n + i - m)\r\n R = min(n - 1, i)\r\n if b[i]: cur = cnt0[R] - cnt0[L - 1]\r\n else: cur = cnt1[R] - cnt1[L - 1]\r\n Sum += cur\r\nprint(Sum)\r\n", "import sys\r\n\r\na = input()\r\nb = input()\r\nl1 = len(a)\r\n\r\none = [0]*len(b)\r\nzero = [0]*len(b)\r\ncnt = cnt1 = cnt0 = 0\r\nfor i in range(len(b)):\r\n if b[i] == '1':\r\n cnt1 += 1\r\n elif b[i] == '0':\r\n cnt0 += 1\r\n\r\n one[i] = cnt1\r\n zero[i] = cnt0\r\n\r\n\r\nlast = len(b) - len(a)\r\nfirst = -1\r\nfor i in range(l1):\r\n if a[i] == '0':\r\n if i == 0:\r\n cnt += one[last]\r\n else:\r\n cnt += one[last] - one[first]\r\n elif a[i] == '1':\r\n if i == 0:\r\n cnt += zero[last]\r\n else:\r\n cnt += zero[last] - zero[first]\r\n first += 1\r\n last += 1\r\nprint(cnt)", "a=input()\r\nb=input()\r\nt=0\r\nans=0\r\np=len(b)-len(a)+1\r\n\r\nfor i in range(len(b)-len(a)+1):\r\n t+=int(b[i])\r\n\r\nfor j in range(len(a)):\r\n v=int(a[j])\r\n if v==1:\r\n ans=ans+p-t\r\n else:\r\n ans=ans+t\r\n if j==len(a)-1:\r\n break\r\n t=t+int(b[p+j])\r\n t=t-int(b[j])\r\n\r\nprint(ans)\r\n", "a = str(input())\r\nb = str(input())\r\nn = len(a)\r\nm = len(b)\r\nans = 0\r\nc = m - n + 1\r\nones = 0\r\nfor i in range(c):\r\n if b[i] == '1':\r\n ones += 1\r\nfor i in range(n):\r\n if a[i] == '0':\r\n ans += ones\r\n else:\r\n ans += (c - ones)\r\n if i == n - 1:\r\n break\r\n if b[i] == '1':\r\n ones -= 1\r\n if b[i + c] == '1':\r\n ones += 1\r\nprint(ans)\r\n", "a=[int(x) for x in input().strip()]\r\nb=[int(x) for x in input().strip()]\r\nc=[[b[0]^1]+[0]*(len(b)-1), [b[0]]+[0]*(len(b)-1)]\r\nfor i in range(1,len(b)):\r\n c[0][i]=c[0][i-1]+(b[i]^1)\r\nfor i in range(1,len(b)):\r\n c[1][i]=c[1][i-1]+b[i]\r\n\r\nans=0\r\nfor x in range(len(a)):\r\n ans+=c[a[x]^1][x+len(b)-len(a)]-(c[a[x]^1][x-1] if x!=0 else 0)\r\nprint(ans)", "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\nimport math\r\nfrom heapq import heappush , heappop\r\nfrom collections import defaultdict,deque,Counter\r\nfrom bisect import *\r\n\r\nS = input()\r\nT = input()\r\nN = len(S)\r\nM = len(T)\r\n\r\nsums = [0]\r\nfor a in S:\r\n if a=='0':\r\n sums.append(sums[-1])\r\n else:\r\n sums.append(sums[-1]+1)\r\n\r\nans = 0\r\nfor i in range(M):\r\n l = max(0, N-(M-i))\r\n r = min(N-1, i)\r\n \r\n t = sums[r+1]-sums[l]\r\n if T[i]=='0':\r\n ans += t\r\n else:\r\n ans += (r-l+1)-t\r\n \r\nprint(ans)\r\n\r\n", "a = input()\r\nb = input()\r\npresum_0 = []\r\npresum_1 = []\r\nc_0 = 0\r\nc_1 = 0\r\nfor i in b:\r\n if i == '1':\r\n c_0 += 1\r\n if i== '0':\r\n c_1 += 1\r\n presum_0.append(c_0)\r\n presum_1.append(c_1)\r\nans = 0\r\n#print(presum_0,presum_1)\r\nif a[0] == '1':\r\n ans += presum_1[len(b)-len(a)]\r\nelse:\r\n ans += presum_0[len(b)-len(a)]\r\nfor i in range(1,len(a)):\r\n if a[i] == '1':\r\n ans += presum_1[len(b)-len(a)+i] - presum_1[i-1]\r\n else:\r\n ans += presum_0[len(b)-len(a)+i] - presum_0[i-1]\r\nprint(ans)\r\n", "a = input()\r\nb = input()\r\n\r\ncs = [0]\r\nfor ch in b:\r\n cs.append(cs[-1] + (ch == '1'))\r\n\r\ndiff = len(b) - len(a)\r\nans = 0\r\nfor idx, ch in enumerate(a):\r\n ones = cs[idx+diff +1] - cs[idx-1 +1]\r\n zeros = diff+1 - ones\r\n if ch == '1':\r\n ans += zeros\r\n else:\r\n ans += ones\r\n\r\nprint(ans)", "import sys\r\n\r\ndef solve():\r\n N = len(B)\r\n count0 = [0] * (N + 1)\r\n count1 = [0] * (N + 1)\r\n for i in range(N):\r\n count0[i + 1] = count0[i]\r\n count1[i + 1] = count1[i]\r\n if B[i] == 1:\r\n count1[i + 1] += 1\r\n else:\r\n count0[i + 1] += 1\r\n\r\n ans = 0\r\n M = len(A)\r\n for i, bit in enumerate(A):\r\n inc_i = N - M + 1 + i\r\n exc_i = i\r\n inc = count0[inc_i] if bit == 1 else count1[inc_i]\r\n exc = count0[exc_i] if bit == 1 else count1[exc_i]\r\n ans += inc - exc\r\n\r\n return ans\r\n\r\ninput = sys.stdin.buffer.readline\r\nA = list(map(int, input().strip().decode()))\r\nB = list(map(int, input().strip().decode()))\r\nprint(solve())", "a = input()\r\nb = input()\r\nans = 0\r\np = [0 for i in range(len(b)+1)]\r\nfor i in range(len(b)):\r\n p[i+1] = p[i] + int(b[i])\r\nfor i in range(len(a)):\r\n ans += abs(int(a[i])*(len(b)-len(a)+1) - p[len(b)-len(a)+i+1] + p[i])\r\nprint(ans)", "\r\nimport sys \r\na = input()\r\nb = input()\r\nsums = []\r\nfor i in range(len(b)):\r\n sums.append(ord(b[i]) - ord('0'))\r\n if len(sums) >= 2:\r\n sums[-1] += sums[-2]\r\nans = 0\r\nfor i in range(len(a)):\r\n onenum = sums[len(b) - len(a) +i]\r\n if i > 0:\r\n onenum -= sums[i-1]\r\n if a[i] == '1':\r\n ans += len(b) - len(a) - onenum + 1\r\n else:\r\n ans += onenum\r\nprint(ans)\r\n \r\n \r\n \r\n ", "a, b = '0'+input(),'0'+input()\r\nm, n = len(a), len(b)\r\nc, s = [0]*(n+1), 0 \r\nif m <= n: \r\n for i in range(1,n):\r\n c[i] = int(b[i]) + c[i-1]\r\n for i in range(1,m):\r\n if a[i] == '0':\r\n s += c[i+n-m]-c[i-1]\r\n else:\r\n s += n-m+1 - (c[i+n-m]-c[i-1])\r\nprint(s)\r\n", "a,b,cum,total,ans=input(),input(),[0],0,0\r\n\r\nfor i in range(len(b)):\r\n total+=int(b[i])\r\n cum.append(total)\r\n\r\nfor i in range(len(a)):\r\n one = cum[len(b)-(len(a)-i)+1]- cum[i]\r\n zero = len(b)-len(a)+1-one\r\n if a[i]=='0':\r\n ans+=one\r\n else:\r\n ans+=zero\r\n# print(\"i:\",i,\"one:\",one,\"zero:\",zero,\"ans:\",ans,\"large:\",len(b)-(len(a)-i)+1,\"cum:\",cum[len(b)-(len(a)-i)+1],\"small:\",i,\"cum:\",cum[i])\r\n \r\nprint(ans)\r\n", "a=input()\r\nb=input()\r\nn=len(a)\r\nm=len(b)\r\nc=[[0]*(m+1) for _ in range(2)]\r\nfor i in range(1,m+1):\r\n t=int(b[i-1])\r\n c[0][i]=c[0][i-1]+abs(t)\r\n c[1][i]=c[1][i-1]+abs(1-t)\r\nans=0\r\nfor i in range(1,n+1):\r\n j=i+m-n\r\n t=int(a[i-1])\r\n ans+=c[t][j]-c[t][i-1]\r\nprint(ans)\r\n", "'''\r\n# Submitted By M7moud Ala3rj\r\nDon't Copy This Code, CopyRight . [email protected] © 2022-2023 :)\r\n'''\r\n# Problem Name = \"Hamming Distance Sum\"\r\n# Class: B\r\n\r\nimport sys\r\n\r\n#sys.setrecursionlimit(2147483647)\r\ninput = sys.stdin.readline\r\ndef printf(*args, end='\\n', sep=' ') -> None:\r\n sys.stdout.write(sep.join(map(str, args)) + end)\r\n\r\ndef Solve():\r\n a = input().strip()\r\n b = input().strip()\r\n lb = len(b) ; la = len(a)\r\n x = [[0 for o in range(2)] for i in range(lb+1)]\r\n zc = 0 ; oc = 0\r\n for i in range(lb):\r\n if b[i] == \"0\":\r\n zc += 1\r\n else:\r\n oc += 1\r\n x[i+1][1] = oc\r\n x[i+1][0] = zc\r\n ans = 0\r\n for i in range(0, la):\r\n for o in range(2):\r\n ans += (x[lb - la + i + 1][o] - x[i][o]) * abs(int(a[i]) - o)\r\n print(ans)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n # for t in range(int(input())):\r\n Solve()", "A = [int(x) for x in input()]\nB = [int(x) for x in input()]\nsumm = 0\nprefixZeros = [0 for x in range(len(B)+1)]\nprefixOnes = [0 for x in range(len(B)+1)]\nfor i in range(len(B)):\n prefixOnes[i + 1] = prefixOnes[i] + (B[i] == 1)\n prefixZeros[i + 1] = prefixZeros[i] + (B[i] == 0)\nfor i in range(len(A)):\n if A[i] == 0:\n summ += prefixOnes[len(B) - len(A) + i + 1] - prefixOnes[i]\n else:\n summ += prefixZeros[len(B) - len(A) + i + 1] - prefixZeros[i]\nprint(summ)\n \t\t\t\t\t\t\t \t \t\t\t \t \t \t\t", "a=[int(i) for i in input()]\r\nb=[int(i) for i in input()]\r\np=[0,0]\r\nds={-1:[p[0],p[1]]}\r\nk,sm,La,Lb=0,0,len(a),len(b)\r\nfor i in a:\r\n p[abs(i-1)]+=1\r\n ds.update({k:[p[0],p[1]]})\r\n k+=1\r\nfor i,j in zip(range(Lb),b):\r\n xe=min(i,La-1)\r\n xb=max(La-(Lb-i),0)\r\n sm+=ds[xe][j]-ds[xb-1][j]\r\nprint(sm)\r\n ", "a=str(input())\r\nb=str(input())\r\ncount=0\r\nal=len(a)\r\nbl=len(b)\r\ns=b[:bl-al+1].count('1')\r\nfor i in range(al-1):\r\n if a[i]=='0':\r\n count+=s\r\n else:\r\n count+=bl-al+1-s\r\n s+=int(b[bl-al+i+1])-int(b[i])\r\n \r\nif a[-1]=='0':\r\n count+=s\r\nelse:\r\n count+=bl-al+1-s\r\nprint(count)", "a = list(input())\nb = list(input())\n# print(a)\n# print(b)\nn = len(a)\nbn = len(b)\nMAXN = int(2e5+10)\npre0 = [0]*MAXN\npre1 = [0]*MAXN\nif b[0] == '1':\n pre1[0] = 1\nelse:\n pre0[0] = 1\nfor i in range(1,bn):\n pre0[i] = pre0[i-1]\n pre1[i] = pre1[i-1]\n if b[i] == '0':\n pre0[i]+=1\n else:\n pre1[i]+=1\nans = 0\nk = bn-n\nif a[0] == '1':\n ans += pre0[k]\nelse:\n ans += pre1[k]\nfor i in range(1,n):\n if a[i] == '1':\n ans += pre0[k+i]-pre0[i-1]\n else:\n ans += pre1[k+i]-pre1[i-1]\nprint(ans)\n\n\t \t\t \t\t\t \t\t\t \t\t\t \t\t\t\t\t \t\t" ]
{"inputs": ["01\n00111", "0011\n0110", "0\n0", "1\n0", "0\n1", "1\n1", "1001101001101110101101000\n01111000010011111111110010001101000100011110101111", "1110010001000101001011111\n00011011000000100001010000010100110011010001111010"], "outputs": ["3", "2", "0", "1", "1", "0", "321", "316"]}
UNKNOWN
PYTHON3
CODEFORCES
113
e666dd51fa2686b4cee373003f8f43e6
Photo Processing
Evlampiy has found one more cool application to process photos. However the application has certain limitations. Each photo *i* has a contrast *v**i*. In order for the processing to be truly of high quality, the application must receive at least *k* photos with contrasts which differ as little as possible. Evlampiy already knows the contrast *v**i* for each of his *n* photos. Now he wants to split the photos into groups, so that each group contains at least *k* photos. As a result, each photo must belong to exactly one group. He considers a processing time of the *j*-th group to be the difference between the maximum and minimum values of *v**i* in the group. Because of multithreading the processing time of a division into groups is the maximum processing time among all groups. Split *n* photos into groups in a such way that the processing time of the division is the minimum possible, i.e. that the the maximum processing time over all groups as least as possible. The first line contains two integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=3·105) — number of photos and minimum size of a group. The second line contains *n* integers *v*1,<=*v*2,<=...,<=*v**n* (1<=≤<=*v**i*<=≤<=109), where *v**i* is the contrast of the *i*-th photo. Print the minimal processing time of the division into groups. Sample Input 5 2 50 110 130 40 120 4 1 2 3 4 1 Sample Output 20 0
[ "from bisect import bisect_left, bisect_right\r\nfrom collections import Counter, deque\r\nfrom functools import lru_cache\r\nfrom math import factorial, comb, sqrt, gcd, lcm, log2\r\nfrom copy import deepcopy\r\nimport heapq\r\n\r\nfrom sys import stdin, stdout\r\n\r\n\r\ninput = stdin.readline\r\n\r\n\r\n\r\ndef main():\r\n n, k = map(int, input().split())\r\n L = list(map(int, input().split()))\r\n L.sort()\r\n left = 0\r\n right = L[-1] - L[0]\r\n def check(flag):\r\n # dp[i] 表示 以 L[i] 为结尾的子数组是否满足以下要求\r\n # 将数组分成若干组,每组最少有 k 个数,且每组的最大值- 最小值 <= flag\r\n dp = [False] * n\r\n q = deque([-1]) # 保存所有 True 值的索引来优化 dp 的时间复杂度\r\n for i in range(k - 1, n):\r\n while len(q) > 0 and L[i] - L[q[0] + 1] > flag and i - q[0] >= k:\r\n q.popleft()\r\n if len(q) > 0 and i - q[0] >= k:\r\n dp[i] = True\r\n q.append(i)\r\n return dp[-1]\r\n\r\n\r\n while left < right:\r\n middle = (left + right) // 2\r\n if check(middle) is True:\r\n right = middle\r\n else:\r\n left = middle + 1\r\n print(left)\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()", "# 最小值尽量大 最大值尽量小 尽量多分组\r\nn,k = map(int,input().split())\r\na = list(map(int,input().split()))\r\na.sort()\r\nleft = 0\r\nright = 10**10\r\n\r\n# 居然是dp吗\r\ndef check(num):\r\n dp = [True] + [False] * n\r\n left = 0\r\n for right in range(n):\r\n while left < right and (a[right] - a[left] > num or not dp[left]):\r\n left += 1\r\n if a[right] - a[left] <= num and right - left + 1 >= k:\r\n dp[right + 1] = True\r\n return dp[-1]\r\n\r\n\r\nwhile left <= right:\r\n mid = (left + right) // 2\r\n if check(mid):\r\n right = mid - 1\r\n else:\r\n left = mid + 1\r\nprint(left)", "import sys\r\ninput = lambda: sys.stdin.readline().strip()\r\ndef solve():\r\n n, k = map(int, input().split())\r\n a = list(map(int, input().split()))\r\n a.sort()\r\n\r\n def check(v):\r\n f = [True] + [False] * n\r\n j = 0\r\n for i in range(n):\r\n while j < i and (a[i] - a[j] > v or not f[j]):\r\n j += 1\r\n if a[i]- a[j] <= v and i - j + 1 >= k:\r\n f[i+1] = True\r\n return f[n]\r\n\r\n left, right = -1, 10 ** 10\r\n while left+1 != right:\r\n mid = (left+right)//2\r\n if check(mid):\r\n right = mid\r\n else:\r\n left = mid\r\n print(right)\r\n\r\nsolve()", "n, k = map(int, input().split())\r\nif k == 1:\r\n print(0)\r\n exit()\r\n\r\nnums = [int(v) for v in input().split()]\r\nnums.sort()\r\n\r\ndef check(mx):\r\n f = [False] * (n + 1)\r\n f[0] = True\r\n j0 = 0\r\n\r\n # 依次求f[i + 1]\r\n for i in range(k - 1, n):\r\n while nums[i] - nums[j0] > mx:\r\n j0 += 1\r\n while i - j0 + 1 > k and not f[j0]:\r\n j0 += 1\r\n\r\n f[i + 1] = f[j0] and i - j0 + 1 >= k\r\n return f[n]\r\n\r\nl, r = 0, nums[-1] - nums[0]\r\nwhile l < r:\r\n mid = (l + r) // 2\r\n if not check(mid):\r\n l = mid + 1\r\n else:\r\n r = mid\r\nprint(l)", "from heapq import heappush, heappop, heapify\r\nfrom collections import defaultdict, Counter, deque\r\nfrom functools import lru_cache\r\nimport threading\r\nimport sys\r\nimport bisect\r\ninput = sys.stdin.readline\r\ndef ri(): return int(input())\r\ndef rs(): return input()\r\ndef rl(): return list(map(int, input().split()))\r\ndef rls(): return list(input().split())\r\n\r\n# threading.stack_size(10**8)\r\n# sys.setrecursionlimit(10**6)\r\n \r\ndef main():\t\r\n\t\r\n\tn,k=rl()\r\n\tv=rl()\r\n\tv.sort()\r\n\tl=0\r\n\tr=1<<33\r\n\t\r\n\tdef check(x):\r\n\t\tdp=[0]*(n+1)\r\n\t\tdp[0]=1\r\n\t\tidx=0\r\n\t\tfor i in range(n):\r\n\t\t\twhile idx<=i-k+1 and (v[i]-v[idx]>x or not dp[idx]):\r\n\t\t\t\tidx+=1\r\n\t\t\tif idx<=i-k+1:\r\n\t\t\t\tdp[i+1]=1\r\n\t\treturn dp[-1] \r\n\t\t\t\r\n\twhile l<=r:\r\n\t\tm=(l+r)>>1\r\n\t\tif check(m):r=m-1\r\n\t\telse:l=m+1\r\n\tprint(l)\r\n\tpass\t\r\n\r\n# for _ in range(ri()):\r\nmain()\r\n# threading.Thread(target=main).start()\r\n", "# Problem: I. Photo Processing\r\n# Contest: Codeforces - 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)\r\n# URL: https://codeforces.com/problemset/problem/883/I\r\n# Memory Limit: 256 MB\r\n# Time Limit: 3000 ms\r\n\r\nimport sys\r\nimport bisect\r\nimport random\r\nimport io, os\r\nfrom bisect import *\r\nfrom collections import *\r\nfrom contextlib import redirect_stdout\r\nfrom itertools import *\r\nfrom array import *\r\nfrom functools import lru_cache, reduce\r\nfrom types import GeneratorType\r\nfrom heapq import *\r\nfrom math import sqrt, gcd, inf\r\n\r\nif sys.version >= '3.8': # ACW没有comb\r\n from math import comb\r\n\r\nRI = lambda: map(int, sys.stdin.buffer.readline().split())\r\nRS = lambda: map(bytes.decode, sys.stdin.buffer.readline().strip().split())\r\nRILST = lambda: list(RI())\r\nDEBUG = lambda *x: sys.stderr.write(f'{str(x)}\\n')\r\n# print = lambda d: sys.stdout.write(str(d) + \"\\n\") # 打开可以快写,但是无法使用print(*ans,sep=' ')这种语法\r\n\r\nMOD = 10 ** 9 + 7\r\nPROBLEM = \"\"\"https://codeforces.com/problemset/problem/883/I\r\n\r\n输入 n k(1≤k≤n≤3e5) 和长为 n 的数组 a(1≤a[i]≤1e9)。\r\n\r\n把这 n 个数重新排列,然后分成若干个组,要求每组至少有 k 个数。\r\n定义 diff(b) 表示序列 b 中最大值与最小值的差。\r\n计算所有组的 diff 值的最大值 mx。\r\n输出 mx 的最小值。\r\n输入\r\n5 2\r\n50 110 130 40 120\r\n输出 20\r\n\r\n输入\r\n4 1\r\n2 3 4 1\r\n输出 0\r\n\"\"\"\r\n\r\n\r\ndef lower_bound(lo: int, hi: int, key):\r\n \"\"\"由于3.10才能用key参数,因此自己实现一个。\r\n :param lo: 二分的左边界(闭区间)\r\n :param hi: 二分的右边界(闭区间)\r\n :param key: key(mid)判断当前枚举的mid是否应该划分到右半部分。\r\n :return: 右半部分第一个位置。若不存在True则返回hi+1。\r\n 虽然实现是开区间写法,但为了思考简单,接口以[左闭,右闭]方式放出。\r\n \"\"\"\r\n lo -= 1 # 开区间(lo,hi)\r\n hi += 1\r\n while lo + 1 < hi: # 区间不为空\r\n mid = (lo + hi) >> 1 # py不担心溢出,实测py自己不会优化除2,手动写右移\r\n if key(mid): # is_right则右边界向里移动,目标区间剩余(lo,mid)\r\n hi = mid\r\n else: # is_left则左边界向里移动,剩余(mid,hi)\r\n lo = mid\r\n return hi\r\n\r\n\r\n# ms\r\ndef solve():\r\n n, k = RI()\r\n a = RILST()\r\n a.sort()\r\n\r\n def ok(x):\r\n f = [0] * (n + 1)\r\n f[0] = 1\r\n j = 0\r\n for i in range(k-1, n):\r\n while i - j + 1 >= k and a[i] - a[j] > x:\r\n j += 1\r\n while i - j + 1 >= k and f[j] == 0:\r\n j += 1\r\n if i - j + 1 >= k:\r\n f[i + 1] = 1\r\n # print(f)\r\n return f[n] == 1\r\n # print(ok(0))\r\n print(lower_bound(0, a[-1] - a[0], ok))\r\n\r\n\r\nif __name__ == '__main__':\r\n t = 0\r\n if t:\r\n t, = RI()\r\n for _ in range(t):\r\n solve()\r\n else:\r\n solve()\r\n" ]
{"inputs": ["5 2\n50 110 130 40 120", "4 1\n2 3 4 1", "1 1\n4", "2 2\n7 5", "3 2\n34 3 75", "5 2\n932 328 886 96 589", "10 4\n810 8527 9736 3143 2341 6029 7474 707 2513 2023", "20 11\n924129 939902 178964 918687 720767 695035 577430 407131 213304 810868 596349 266075 123602 376312 36680 18426 716200 121546 61834 851586", "100 28\n1 2 3 5 1 1 1 4 1 5 2 4 3 2 5 4 1 1 4 1 4 5 4 1 4 5 1 3 5 1 1 1 4 2 5 2 3 5 2 2 3 2 4 5 5 5 5 1 2 4 1 3 1 1 1 4 3 1 5 2 5 1 3 3 2 4 5 1 1 3 4 1 1 3 3 1 2 4 3 3 4 4 3 1 2 1 5 1 4 4 2 3 1 3 3 4 2 4 1 1", "101 9\n3 2 2 1 4 1 3 2 3 4 3 2 3 1 4 4 1 1 4 1 3 3 4 1 2 1 1 3 1 2 2 4 3 1 4 3 1 1 4 4 1 2 1 1 4 2 3 4 1 2 1 4 4 1 4 3 1 4 2 1 2 1 4 3 4 3 4 2 2 4 3 2 1 3 4 3 2 2 4 3 3 2 4 1 3 2 2 4 1 3 4 2 1 3 3 2 2 1 1 3 1", "2 2\n1 1000000000", "2 1\n1 1000000000", "11 3\n412 3306 3390 2290 1534 316 1080 2860 253 230 3166", "10 3\n2414 294 184 666 2706 1999 2201 1270 904 653", "24 4\n33 27 12 65 19 6 46 33 57 2 21 50 73 13 59 69 51 45 39 1 6 64 39 27"], "outputs": ["20", "0", "0", "2", "72", "343", "3707", "921476", "1", "0", "999999999", "0", "1122", "707", "9"]}
UNKNOWN
PYTHON3
CODEFORCES
6
e66985f39a9769f994faf9ce3d63f424
none
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0. There are also *n* cards, each card has 2 attributes: length *l**i* and cost *c**i*. If she pays *c**i* dollars then she can apply *i*-th card. After applying *i*-th card she becomes able to make jumps of length *l**i*, i. e. from cell *x* to cell (*x*<=-<=*l**i*) or cell (*x*<=+<=*l**i*). She wants to be able to jump to any cell on the tape (possibly, visiting some intermediate cells). For achieving this goal, she wants to buy some cards, paying as little money as possible. If this is possible, calculate the minimal cost. The first line contains an integer *n* (1<=≤<=*n*<=≤<=300), number of cards. The second line contains *n* numbers *l**i* (1<=≤<=*l**i*<=≤<=109), the jump lengths of cards. The third line contains *n* numbers *c**i* (1<=≤<=*c**i*<=≤<=105), the costs of cards. If it is impossible to buy some cards and become able to jump to any cell, output -1. Otherwise output the minimal cost of buying such set of cards. Sample Input 3 100 99 9900 1 1 1 5 10 20 30 40 50 1 1 1 1 1 7 15015 10010 6006 4290 2730 2310 1 1 1 1 1 1 1 10 8 4264 4921 6321 6984 2316 8432 6120 1026 4264 4921 6321 6984 2316 8432 6120 1026 Sample Output 2 -1 6 7237
[ "def gcd(x, y):\r\n if y == 0:\r\n return x\r\n return gcd(y, x % y)\r\n\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\nc = [int(x) for x in input().split()]\r\nf = {}\r\nfor i in range(n):\r\n h = {}\r\n for x in f:\r\n h[x] = f[x]\r\n for x in f:\r\n tmp = h[x] + c[i]\r\n g = gcd(x, a[i])\r\n h[g] = min(h[g], tmp) if g in h else tmp\r\n f = h\r\n f[a[i]] = min(f[a[i]], c[i]) if a[i] in f else c[i]\r\nif 1 in f:\r\n print(f[1])\r\nelse:\r\n print(\"-1\")\r\n", "# import math\r\n\r\n# input()\r\n# ls = map(int, input().split())\r\n# cs = map(int, input().split())\r\n\r\n# dp = {0: 0}\r\n# for l, c in zip(ls, cs):\r\n# for k, v in list(dp.items()):\r\n# x = math.gcd(k, l)\r\n# dp[x] = min(dp.get(x, math.inf), v + c)\r\n# print(dp.get(1, -1))\r\n\r\n\r\nimport math\r\nimport heapq\r\n\r\nn = int(input())\r\nls = list(map(int, input().split()))\r\ncs = list(map(int, input().split()))\r\n\r\nheap = [(0, 0)]\r\nvisited = set()\r\ndist = {0: 0}\r\n\r\nwhile heap:\r\n u = heapq.heappop(heap)[1]\r\n if u == 1:\r\n break\r\n if u in visited:\r\n continue\r\n visited.add(u)\r\n for l, c in zip(ls, cs):\r\n v = math.gcd(u, l)\r\n if u == v or v in visited or v in dist and dist[v] <= dist[u] + c:\r\n continue\r\n dist[v] = dist[u] + c\r\n heapq.heappush(heap, (dist[v], v))\r\n\r\nprint(dist.get(1, -1))\r\n", "import math\r\n\r\ninput()\r\nlengths = list(map(int, input().split()))\r\ncosts = list(map(int, input().split()))\r\n\r\ndp = {0: 0}\r\nfor l, c in zip(lengths, costs):\r\n for k, v in list(dp.items()):\r\n x = math.gcd(k, l)\r\n dp[x] = min(dp.get(x, math.inf), v + c)\r\nprint(dp.get(1, -1))", "import sys\r\n\r\nn = int(input())\r\nl = list(map(int,input().split()))\r\nc = list(map(int,input().split()))\r\n\r\ndef gcd(a, b):\r\n if b == 0: return a\r\n return gcd(b, a % b)\r\n\r\na = {0:0}\r\n\r\nfor i in range(n):\r\n b = a.copy()\r\n for p in a.items():\r\n d = gcd(p[0], l[i])\r\n cost = p[1] + c[i]\r\n if d not in b: b[d] = cost\r\n elif b[d] > cost: b[d] = cost\r\n a = b.copy()\r\n\r\nif 1 not in a: a[1] = -1\r\nprint(a[1])\r\n\r\n ", "import sys\r\nimport fractions as f\r\n#sys.stdin = open('in.txt')\r\n\r\nn=int(input())\r\n\r\ndef dfs(cur = n-1, g = 0):\r\n if g==1 :\r\n return 0\r\n if cur<0:\r\n return 100000000000\r\n if g in d[cur]:\r\n return d[cur][g]\r\n d[cur][g]=min(dfs(cur-1, g), dfs(cur-1, f.gcd(g, l[cur]))+c[cur])\r\n return d[cur][g]\r\n\r\nl=list(map(int,input().split()))\r\nc=list(map(int,input().split()))\r\nd=[{} for i in range(n)]\r\n\r\nans=dfs(n-1, 0)\r\nprint([ans, -1][ans>=100000000000])", "import math\r\n\r\nnum = int(input())\r\nlst1 = list(map(int, input().split()))\r\nlst2 = list(map(int, input().split()))\r\n\r\nfrom functools import lru_cache\r\n\r\n@lru_cache(None)\r\ndef find_min_cost(idx, n):\r\n if n == 1:\r\n return 0\r\n if idx >= len(lst1):\r\n return float('inf')\r\n j, c = lst1[idx], lst2[idx]\r\n return min(\r\n find_min_cost(idx + 1, math.gcd(j, n)) + c,\r\n find_min_cost(idx + 1, n),\r\n )\r\n\r\nmin_cost = float('inf')\r\nfor i, v in enumerate(lst1):\r\n min_cost = min(min_cost, find_min_cost(i + 1, v) + lst2[i])\r\n\r\nif min_cost == float('inf'):\r\n print(-1)\r\nelse:\r\n print(min_cost)\r\n", "def main():\n input()\n acc = {0: 0}\n for p, c in zip(list(map(int, input().split())),\n list(map(int, input().split()))):\n adds = []\n for b, u in acc.items():\n a = p\n while b:\n a, b = b, a % b\n adds.append((a, u + c))\n for a, u in adds:\n acc[a] = min(u, acc.get(a, 1000000000))\n print(acc.get(1, -1))\n\n\nif __name__ == '__main__':\n main()\n\n\n\n# Made By Mostafa_Khaled", "import fractions\r\n\r\ndef dfs(s, g) :\r\n global cache, N, L, C\r\n if g == 1 : return 0\r\n if s == N : return float(\"INF\")\r\n if g in cache[s] :\r\n return cache[s][g]\r\n cache[s][g] = min(dfs(s+1, g),dfs(s+1, gcd(g, L[s]))+C[s])\r\n return cache[s][g]\r\n \r\ngcd = fractions.gcd\r\nN = int(input())\r\nL = list(map(int, input().split(' ')))\r\nC = list(map(int, input().split(' ')))\r\ncache = [dict() for i in range(N)]\r\nans = dfs(0, 0)\r\nif ans == float(\"INF\") :\r\n print(-1)\r\nelse :\r\n print(ans)" ]
{"inputs": ["3\n100 99 9900\n1 1 1", "5\n10 20 30 40 50\n1 1 1 1 1", "7\n15015 10010 6006 4290 2730 2310 1\n1 1 1 1 1 1 10", "8\n4264 4921 6321 6984 2316 8432 6120 1026\n4264 4921 6321 6984 2316 8432 6120 1026", "6\n1 2 4 8 16 32\n32 16 8 4 2 1", "1\n1\n1", "1\n2\n2", "8\n2 3 5 7 11 13 17 19\n4 8 7 1 5 2 6 3", "1\n1000000000\n100000", "2\n1000000000 999999999\n100000 100000", "39\n692835 4849845 22610 1995 19019 114 6270 15 85085 27170 1365 1155 7410 238 3135 546 373065 715 110 969 15 10374 2730 19019 85 65 5187 26 3233230 1122 399 1122 53295 910 110 12597 16302 125970 67830\n4197 6490 2652 99457 65400 96257 33631 23456 14319 22288 16179 74656 89713 31503 45895 31777 64534 27989 60861 69846 44586 87185 96589 62279 62478 6180 26977 12112 9975 72933 73239 65856 98253 18875 55266 55867 36397 40743 47977", "35\n512 268435456 8 128 134217728 8192 33554432 33554432 536870912 512 65536 1048576 32768 512 524288 1024 536870912 536870912 16 32 33554432 134217728 2 16 16777216 8192 262144 65536 33554432 128 4096 2097152 33554432 2097152 2\n36157 67877 79710 63062 12683 36255 61053 83828 93590 74236 5281 28143 7350 45953 96803 15998 11240 45207 63010 74076 85227 83498 68320 77288 48100 51373 87843 70054 28986 25365 98581 11195 43674 75769 22053"], "outputs": ["2", "-1", "6", "7237", "32", "1", "-1", "3", "-1", "200000", "18961", "-1"]}
UNKNOWN
PYTHON3
CODEFORCES
8
e677e0b9b13403595b58533bae5f399b
April Fools' Problem (medium)
The marmots need to prepare *k* problems for HC2 over *n* days. Each problem, once prepared, also has to be printed. The preparation of a problem on day *i* (at most one per day) costs *a**i* CHF, and the printing of a problem on day *i* (also at most one per day) costs *b**i* CHF. Of course, a problem cannot be printed before it has been prepared (but doing both on the same day is fine). What is the minimum cost of preparation and printing? The first line of input contains two space-separated integers *n* and *k* (1<=≤<=*k*<=≤<=*n*<=≤<=2200). The second line contains *n* space-separated integers *a*1,<=...,<=*a**n* () — the preparation costs. The third line contains *n* space-separated integers *b*1,<=...,<=*b**n* () — the printing costs. Output the minimum cost of preparation and printing *k* problems — that is, the minimum possible sum *a**i*1<=+<=*a**i*2<=+<=...<=+<=*a**i**k*<=+<=*b**j*1<=+<=*b**j*2<=+<=...<=+<=*b**j**k*, where 1<=≤<=*i*1<=&lt;<=*i*2<=&lt;<=...<=&lt;<=*i**k*<=≤<=*n*, 1<=≤<=*j*1<=&lt;<=*j*2<=&lt;<=...<=&lt;<=*j**k*<=≤<=*n* and *i*1<=≤<=*j*1, *i*2<=≤<=*j*2, ..., *i**k*<=≤<=*j**k*. Sample Input 8 4 3 8 7 9 9 4 6 8 2 5 9 4 3 8 9 1 Sample Output 32
[ "from collections import deque\nfrom heapq import heappop, heappush\n \nclass Edge(object):\n __slots__ = ('x', 'y', 'cap', 'cost', 'inv')\n def __repr__(self):\n return '{e.x}-->{e.y} ({e.cap} , {e.cost})'.format(e=self)\n\nclass MCFP(list):\n def add(G, x, y, cap, cost):\n n = max(x, y) + 1\n while len(G)<n: G.append([])\n e = Edge() ; G[x].append(e)\n w = Edge() ; G[y].append(w)\n e.x=x ; e.y=y; e.cap=cap; e.cost=cost ; w.inv=e \n w.x=y ; w.y=x; w.cap=0; w.cost=-cost ; e.inv=w\n \n def solve(G, src, tgt, flowStop=float('inf'), inf=float('inf')):\n flowVal = flowCost = 0\n n = len(G)\n G.inQ = [0]*n\n G.phi = h = [0]*n\n G.prev = p = [None]*n\n G.dist = d = [inf]*n\n G.SPFA(src)\n while p[tgt]!=None and flowVal<flowStop:\n b = [] ; x = tgt\n while x!=src: b.append(p[x]) ; x=p[x].x\n z = min(e.cap for e in b)\n for e in b: e.cap-=z ; e.inv.cap+=z\n flowVal += z\n flowCost += z * (d[tgt] - h[src] + h[tgt])\n for i in range(n):\n if p[i]!=None: h[i]+=d[i] ; d[i]=inf\n p[tgt] = None\n G.SPFA(src)\n return flowVal, flowCost\n\n def SPFA(G, src):\n inQ = G.inQ ; prev = G.prev\n d = G.dist ; h = G.phi\n d[src] = 0\n Q = deque([src])\n while Q:\n x = Q.popleft()\n inQ[x] = 0\n for e in G[x]:\n if e.cap <= 0: continue\n y = e.y ; dy = d[x] + h[x] + e.cost - h[y]\n if dy < d[y]:\n d[y] = dy ; prev[y] = e\n if inQ[y]==0:\n inQ[y] = 1\n if not Q or dy > d[Q[0]]: Q.append(y)\n else: Q.appendleft(y)\n return\n\nimport sys, random\nints = (int(x) for x in sys.stdin.read().split())\nsys.setrecursionlimit(3000)\n\ndef main():\n n, k = (next(ints) for i in range(2))\n a = [next(ints) for i in range(n)]\n b = [next(ints) for i in range(n)]\n G = MCFP()\n src, tgt = 2*n+1, 2*n+2\n for i in range(n):\n G.add(src, i, 1, 0)\n G.add(i, i+n, 1, a[i])\n G.add(i+n, tgt, 1, b[i])\n if i+1<n:\n G.add(i, i+1, n, 0)\n G.add(i+n, i+n+1, n, 0)\n flowVal, ans = G.solve(src, tgt, k)\n assert flowVal == k\n print(ans)\n #print(G)\n return\n\ndef test(n,k):\n R = random.Random(0)\n yield n ; yield k\n for i in range(n): yield R.randint(1, 10**9)\n for i in range(n): yield R.randint(1, 10**9)\n\n#ints=test(1000, 800)\n\nmain()" ]
{"inputs": ["8 4\n3 8 7 9 9 4 6 8\n2 5 9 4 3 8 9 1", "10 6\n60 8 63 72 1 100 23 59 71 59\n81 27 66 53 46 64 86 27 41 82", "13 13\n93 19 58 34 96 7 35 46 60 5 36 40 41\n57 3 42 68 26 85 25 45 50 21 60 23 79", "12 1\n49 49 4 16 79 20 86 94 43 55 45 17\n15 36 51 20 83 6 83 80 72 22 66 100", "1 1\n96\n86"], "outputs": ["32", "472", "1154", "10", "182"]}
UNKNOWN
PYTHON3
CODEFORCES
1
e68539488f58313b1362264cddb9b8e7
Diplomas and Certificates
There are *n* students who have taken part in an olympiad. Now it's time to award the students. Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly *k* times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of *n*). It's possible that there are no winners. You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners. The first (and the only) line of input contains two integers *n* and *k* (1<=≤<=*n*,<=*k*<=≤<=1012), where *n* is the number of students and *k* is the ratio between the number of certificates and the number of diplomas. Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible. It's possible that there are no winners. Sample Input 18 2 9 10 1000000000000 5 1000000000000 499999999999 Sample Output 3 6 9 0 0 9 83333333333 416666666665 500000000002 1 499999999999 500000000000
[ "s=input()\r\nl=s.split()\r\nn=int(l[0])\r\nk=int(l[1])\r\na=n//2\r\np1=a//(k+1)\r\np2=k*p1\r\np3=n-p2-p1\r\nif p3>=n/2 :\r\n print(int(p1),int(p2),int(p3))\r\nelse :\r\n print(0,0,n)", "[n, k] = [int(i) for i in input().split()]\r\nhalf = n // 2\r\ncorrection = half % (k + 1)\r\nwinners = half - correction\r\ndiplomas = winners // (k + 1)\r\nprint(diplomas, winners - diplomas, n - winners)", "n,k=map(int,input().split())\r\nd=(n//2)//(k+1)\r\nc=k*d\r\nl=n-c-d\r\nprint(str(d)+\" \"+str(c)+\" \"+str(l))", "import math\nn, k = map(int, input().split())\n\na = (math.floor(math.floor(n/2)/(k+1)))\nb = a*k\nrest = n - a - b\nprint(a, b, rest)\n", "n , k = map(int,input().split())\r\na = n//2\r\nb = a//(k+1)\r\nprint(b,k*b,n-(k+1)*b)", "n, k = map(int, input().split())\r\nmax_diplomas = n // (2 * (k + 1))\r\nmax_certificates = max_diplomas * k\r\nmax_participation = n - max_diplomas - max_certificates\r\nprint(max_diplomas, max_certificates, max_participation)", "def f(m):\r\n global n,k\r\n if(2*(m*k+m)<=n):\r\n return True\r\n else:\r\n return False\r\n\r\nn, k = [int(x) for x in input().split()]\r\nl = -1\r\nr = n\r\nwhile( l+1!= r):\r\n mid = (l+r) // 2\r\n if(f(mid)):\r\n l =mid\r\n else:\r\n r = mid\r\nprint(l,l*k,n-(l+l*k),sep = \" \")\r\n", "n, k = map(int,input().split())\r\n\r\nd = 0\r\ng = 0\r\nnul = n\r\n\r\nl = 0\r\nr = n\r\n\r\nwhile r-l!=1:\r\n x = (l+r)//2\r\n if x+x//k<=n//2:\r\n if x%k==0:\r\n d = x//k\r\n g = d*k\r\n nul = n - d - g \r\n l = x \r\n else:\r\n r = x\r\nd = l//k\r\ng = d*k\r\nnul = n - d - g\r\nprint(d,g,nul)", "# n^2 + n - x = 0]\r\n# 1 - 1\r\n# 2 - 3\r\n# 3 - 6\r\n# 4 - 10\r\n# 5 - 15\r\n# 6 - 21\r\n# 7 - 28\r\n# 8 - 36\r\n\r\nfrom math import *\r\n\r\nn,k = map(int,input().split())\r\n\r\nprint(n//(2*(k+1)),(n//(2*(k+1))) *k, n - (n//(2*(k+1))*(k+1)))", "from math import *\r\n\r\nst = input()\r\ns = st.split(' ')\r\ns1 = [0, 0]\r\ns1[0] = int(s[0])\r\ns1[1] = int(s[1])\r\nn = s1[0]\r\nk = s1[1]\r\nhalf = n // 2\r\nx = half / (k + 1)\r\nprint (floor(x))\r\nprint (k * floor(x))\r\nprint (n - (k + 1) * floor(x))\r\n", "n, k = map(int, input().split())\r\nl, r = 0, n//2\r\nwhile l < r:\r\n d = (l+r+1)//2\r\n if 2*d*(1+k) <= n:\r\n l = d\r\n else:\r\n r = d - 1\r\n\r\nprint(l, k*l, n - (l+k*l))\r\n\r\n\r\n", "n, k = map(int, input().split())\r\nl = 0\r\nr = 10 ** 12 + 1\r\nwhile r - l > 1:\r\n d = (r + l) // 2\r\n if n // (d*k + d) >= 2:\r\n l = d\r\n else:\r\n r = d\r\nd = l\r\ng = d * k\r\nsh = n - g - d\r\nprint(d, g, sh)", "\r\nn, k = map(int, input().split())\r\n\r\ndips = (n // 2) // (k + 1)\r\nprint(dips , dips * k, n - (1 + k) * dips)", "n,k = map(int, input().split())\r\n\r\nw = n//2\r\nd = 0\r\nc = 0\r\n\r\nif k < n:\r\n d = w//(k+1)\r\n c = k*d\r\n\r\nprint(f'{d} {c} {n-c-d}')", "n, k = map(int, input().split())\r\nd = n // (2 * (k + 1))\r\nc = d * k\r\nl = n - d - c\r\nprint(d, c, l)\r\n", "n, k = map(int, input().split())\r\na = (n // 2) // (k+1)\r\nprint(a, k * a, n - (k+1)*a)", "n, k = map(int, input().split())\r\nh = n//2\r\na = h //(k+1)\r\nprint(a,k * a,n-a*(k + 1),end=\" \")\r\n", "n, k = map(int, input().split())\r\nd = n//2//(k+1)\r\n\r\nprint(d, k*d, n-(k+1)*d)", "z=input\r\na,b=list(map(int,z().split()))\r\nd=(a//2)//(b+1)\r\nprint(d,d*b,a-d-d*b)\r\n", "n, k = [int(item) for item in input().split()]\r\n\r\nu = n // 2\r\n\r\nprint(u // (k + 1), (u // (k + 1)) * k, n - u // (k + 1) - (u // (k + 1)) * k)", "n, k = [int(i) for i in input().split()]\r\nans = []\r\nd = (n//2)//(k + 1)\r\ng = d*k\r\nnoth = n - d - g\r\nprint(d, g, noth)", "a,b=map(int,input().split())\r\nx=a//2\r\nif x<(b+1):\r\n\tprint(0,0,a)\r\nelse:\r\n\twhile x>=(b+1) and x%(b+1)!=0:\r\n\t\tx-=x%(b+1)\r\n\tif x%(b+1)==0:\r\n\t\ty=x//(b+1)\r\n\t\ts=a-x\r\n\t\tprint(y,b*y,s)\r\n\telse:\r\n\t\tprint(0,0,a)\r\n", "n,k=map(int,input().split())\r\np=n//2\r\nd=p//(k+1)\r\ng=d*k\r\nz=n-d-g\r\nprint(str(d)+' '+str(g)+' '+str(z))\r\n", "n, k = (int(i) for i in input().split())\n# d + kd = n // 2\nd = (n // 2) // (k + 1)\nres = d, k * d, n - d * (k + 1)\nprint(*res)\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nn, k = map(int, input().split())\r\nnimi_n = n // 2 # Man Abduaziz :-)\r\na1 = nimi_n // (k + 1)\r\na2 = nimi_n // (k + 1) * k\r\na3 = n - a1 - a2\r\nprint(a1, a2, a3)\r\n", "n,k=map(int,input().split())\r\ny=(n//2)//(k+1)\r\nprint(y,y*k,n-y-y*k)", "\nn, k = map(int, input().split())\n\nm = (n // 2) // (k + 1)\n\nprint(str(m) + \" \" + str(k * m) + \" \" + str(n - m * (k + 1)))\n", "n, k = map(int, input().split())\r\n\r\nl = 0\r\nr = 10 ** 12 + 1\r\nwhile (l < r - 1):\r\n m = (l + r) // 2\r\n if m + m * k <= n // 2:\r\n l = m\r\n else:\r\n r = m\r\n \r\nprint(l, l * k, n - l * (k + 1))", "n,k=map(int,input().split())\r\nm=(n//2)/(k+1)\r\nprint(int(m),k*int(m),n-((k+1)*int(m)))", "n,k=map(int,input().split())\r\nhalf=n//2\r\nd=0\r\nc=0\r\nu=n\r\ni=half\r\nwhile i>=0:\r\n if i%(k+1)==0:\r\n d=i//(k+1)\r\n c=i-d\r\n u=n-i\r\n break\r\n i-=i%(k+1)\r\nprint(d,c,u)\r\n", "inp=(input().split());\r\nn=int(inp[0])\r\nk=int(inp[1])\r\nhn=int(n/2);\r\nres=int(hn/(k+1));\r\nif(res==0):\r\n print(\"0 0 \"+str(n));\r\nelse:\r\n print(str(res)+\" \"+str(k*res)+\" \"+str(n-(k+1)*res));\r\n", "n,k=[int(x) for x in input().split()]\r\nd=n//(2*(k+1))\r\nprint(d,k*d,n-(k+1)*d)", "n,k = map(int, input().split())\r\n\r\ndef f(x):\r\n return (k+1)*x <= n // 2\r\n\r\nleft, right = 0, n // k\r\nl,r = left, right\r\nwhile l < r:\r\n m = (l + r) // 2\r\n if f(m):\r\n l = m\r\n else:\r\n r = min(m - 1,right)\r\n if l == r - 1:\r\n if f(r): l = r\r\n else: r = l \r\nprint(r)\r\nprint(k*r)\r\nprint(n - (k+1)*r)\r\n", "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\nn, k = map(int, input().split())\r\n\r\ntmp = (n // 2) // (k + 1)\r\nprint(tmp, tmp * k, n - (tmp + tmp * k))", "n,k=map(int,input().split(\" \"))\r\nmaxwin=n//2\r\nif(maxwin%(k+1)!=0):\r\n maxwin=(maxwin//(k+1))*(k+1)\r\nleft=n-maxwin\r\nmaxdip=maxwin//(k+1)\r\nmaxcer=(maxwin//(k+1))*k\r\nprint(maxdip,maxcer,left)\r\n", "n,k=map(int,input().split());a=(n//2)//(k+1);print(a,k*a,n-a*(k+1))", "n,k=map(int,input().split())\r\nm=n//2\r\na=m//(k+1)\r\nb=a*k\r\nprint(a,b,n-(a+b))", "from sys import stdin, stdout\r\n\r\nn, k = map(int, stdin.readline().split())\r\n\r\nl, r = 0, n // 2\r\nwhile (r - l > 1):\r\n m = (r + l) // 2\r\n \r\n if m * k + m > n / 2:\r\n r = m\r\n else:\r\n l = m\r\n\r\n\r\nstdout.write(str(l) + ' ' + str(l * k) + ' ' + str(n - l * (k + 1)))", "n,k=map(int,input().split())\r\nc=n//(2*(k+1))\r\nprint(c,c*k,n-(c+c*k))", "'''input\r\n1000000000000 499999999999\r\n'''\r\nn,k = map(int, input().strip().split())\r\nwinners = int(n/2)\r\nx = int(winners/(k+1))\r\na = x\r\nb = x*k\r\nc = n-a-b\r\nprint(a,b,c)", "import math\nn, k = map(int, input().split())\nz = math.ceil(n / 2)\nn -= z\na = n // (k + 1)\nb = n // (k + 1) * k\nprint(a, b, z + n - a - b)\n", "n,k=map(int,input().split())\r\nd=(n//2)//(k+1)\r\nprint(d,d*k,n-(d+d*k))", "# https://codeforces.com/problemset/problem/818/A# https://codeforces.com/problemset/problem/818/A\r\n\r\nn, k = map(int, input().split())\r\n# winners = cert + diploma\r\n# cert = k * diploma\r\n# winners <= n//2 and winners an be 0\r\n\r\n# print diploma, cert, not winners\r\n\r\n\r\nd = (n // 2) // (k + 1)\r\n\r\nprint(d, d * k, n - (k + 1) * d)\r\n", "n, k = map(int, input().split())\r\nlo, hi, ans = 1, n, 0\r\n\r\nwhile lo <= hi:\r\n mid = (lo + hi) // 2\r\n if mid * (k + 1) * 2 <= n:\r\n ans = mid\r\n lo = mid + 1\r\n else:\r\n hi = mid - 1\r\nprint('%d %d %d' % (ans, ans * k, n - ans * (k + 1)))\r\n", "n, k = (int(x) for x in input().split())\r\nl = 1\r\nr = n//(k+1)\r\nans = 0\r\nwhile l <= r:\r\n mid = (l+r)//2\r\n if (k+1)*mid <= n//2:\r\n l = mid+1\r\n ans = mid\r\n else:\r\n r = mid-1\r\n\r\nprint(ans, ans*k, n-(k+1)*ans)", "n,k=input().split(\" \")\r\nn=int(n)\r\nk=int(k)\r\nprint(int(((n//2)//(k+1))),k*int(((n//2)//(k+1))), n-((k+1)*int(((n//2)//(k+1))) ))", "n,k=map(int,input().split())\r\nz=n//2\r\nif(n%2!=0):\r\n z+=1\r\nn-=z\r\nx=n//(k+1)\r\nif(x==0):\r\n print(\"0 0\",n+z)\r\nelse:\r\n y=k*x\r\n print(x,y,n+z-x-y)\r\n \r\n", "inp = input().split()\nn = int(inp[0])\nk = int(inp[1])\n\nv = n // (2*(k + 1))\nprint(v,v*k,n-v*(k+1))\n", "#!/usr/bin/env python\r\n\r\nimport math\r\nimport sys\r\nimport itertools\r\nimport fractions\r\n\r\nif __name__ == '__main__':\r\n wtf = sys.stdin.read()\r\n wtf = wtf.strip().split('\\n')\r\n n,k = map(int, wtf[0].split())\r\n x = (n/2)/(1+k)\r\n x = int(x)\r\n print(x, x*k, n-x-x*k)\r\n", "n, k = map(int, input().split())\r\na = n//2\r\np = a//(k+1)\r\nprint(p, k*p, n-p-k*p)\r\n", "import sys\r\n\r\ndef main():\r\n n, k = map(int, sys.stdin.read().strip().split())\r\n t = n//2//(k + 1)\r\n return t, t*k, n - t*(k + 1)\r\n \r\nprint(*main())\r\n\r\n", "import sys,string,bisect\r\ninput=sys.stdin.readline\r\nimport random\r\nfrom collections import deque,defaultdict\r\nL=lambda : list(map(int,input().split()))\r\nLs=lambda : list(input().split())\r\nM=lambda : map(int,input().split())\r\nI=lambda :int(input())\r\nn,k=M()\r\np=n//2\r\nw=p//(k+1)\r\na=w\r\nb=w*k\r\nprint(a,b,n-(a+b))\r\n", "a,k=map(int,input().split())\nc=int((a/2)/(1+k))\nd=int(c*k)\ne=a-c-d\nprint(c,\" \",d,\" \",e)\n", "n,k=list(map(int,input().split()))\r\nd=n//2//(k+1)\r\nprint(d,d*k,n-d*(k+1))", "n,k=input().split()\r\nn=eval(n)\r\nk=eval(k)\r\nd=n/(2*(k+1))\r\nd=int(d)\r\nc=k*d\r\no=n-d-c\r\nprint(d,\" \",c,\" \",o)\r\n", "n,k =map(int,input().split())\r\nx=(n//2)//(1+k)\r\nprint(x,x*k,n-(x*(k+1)))", "n,k=map(int,input().split())\r\nd=n//(2*(k+1))\r\nc=k*d\r\nprint(d,c,n-d-c)", "n, k=map(int, input().split())\r\nprint((n//2)//(k+1), (n//2)//(k+1)*k, n-(n//2)//(k+1)*(k+1))\r\n", "import sys\r\nimport math\r\n\r\n#to read string\r\nget_string = lambda: sys.stdin.readline().strip()\r\n#to read list of integers\r\nget_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )\r\n#to read integers\r\nget_int = lambda: int(sys.stdin.readline())\r\n#to print fast\r\npt = lambda x: sys.stdout.write(str(x)+'\\n')\r\n\r\n#--------------------------------WhiteHat010--------------------------------------#\r\nn,k = get_int_list()\r\n\r\nx = n//(k+1)\r\nt = min(x*(k+1), n//2)\r\nx = t//(k+1)\r\nprint(x , k*x, n-(k+1)*x)", "n=list(map(int,input().split()))\r\ns=n[0]//2\r\nz=s//(n[1]+1)\r\nm=z*n[1]\r\nif(n[0]%2==0):\r\n print(z,m,s+(s-(m+z)))\r\nelse:\r\n print(z,m,s+1+(s-(m+z)))\r\n", "n,k = map(int,input().split())\r\nx = n//(2*(k+1))\r\ny = x*k\r\nz = n - x - y\r\nprint (str(x) + ' ' + str(y) + ' ' + str(z))\r\n9\r\n", "n,k=map(int,input().split())\r\nprint(((n//2)//(k+1)),(((n//2)//(k+1))*k),n-(((n//2)//(k+1))*k+((n//2)//(k+1))))", "import math\r\n\r\nstudents, ratio = input().split()\r\nstudents, ratio = int(students), int(ratio)\r\n\r\ndip = math.floor((students/2)/(ratio+1))\r\nwin = dip * ratio\r\nprint(dip, win, students - dip - win)", "n,k = list(map(int, input().split()))\r\nd = int(n/(2*(k+1)))\r\nprint(d,k*d,n-((k+1)*d))", "[n, k] = map(int, input().split())\r\nd = int(n / (2 * (k + 1)))\r\nprint(\"{0:d} {1:d} {2:d}\".format(d, d * k, n - d - d * k))\r\n", "line=input().split(\" \")\r\nn=int(line[0])\r\nk=int(line[1])\r\nmitad=n/2\r\nif k>=mitad:\r\n\tdipl=0\r\n\tcert=0\r\nelse:\r\n\tdipl=int(mitad)//(1+k)\r\n\tcert=dipl*k\r\nprint(str(dipl)+\" \"+str(cert)+\" \"+str(n-dipl-cert))", "n, k = map(int, input().split())\r\nd = n // (2 * k + 2)\r\nprint(d, d * k, n - d - d * k)\r\n", "n,k=map(int,input().split())\r\na=n//2\r\nb=0\r\nc=n-a\r\nif n<=k:\r\n print(0,0,n)\r\nelif n>k:\r\n d=a//(k+1)\r\n if d==0:\r\n print(d,b,n)\r\n else:\r\n b=k*d\r\n c=c+(a%(k+1))\r\n print(d,b,c)\r\n", "import sys\n\nfor line in sys.stdin:\n n, k = map(int, line.split())\n\n d = n // (2 * (k + 1))\n c = k * d\n\n print(d, c, n - c - d)", "n,k=map(int,input().split())\r\nx=n//(2*(k+1))\r\nprint(x,k*x,n-x-k*x)", "n,k=map(int,(input().split()))\r\n\r\nx = n//(2*(k+1))\r\n\r\ny = x*k\r\n\r\nz= n-(x+y)\r\n\r\nprint(x,y,z)", "\r\n\r\n\r\nn,k = map(int,input().split())\r\nx = n //(2* (k + 1))\r\ny = k * x\r\n\r\nprint(x,y,n -(x+y))", "n, k = input().split()\r\n \r\nn = int(n)\r\nk = int(k)\r\n \r\nhalf = n / 2\r\n \r\nlow = 0\r\nhigh = 1000000000000 + 1\r\nbest = 0\r\n \r\nwhile low <= high:\r\n mid = (low + high) // 2\r\n if((k + 1) * mid <= half):\r\n best = mid;\r\n low = mid + 1\r\n else:\r\n high = mid - 1\r\n \r\nprint(best, k * best, n - (k + 1) * best)", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn, k = map(int, input().split())\r\nc = (n + 1) // 2\r\nx = (n - c) % (k + 1)\r\nc += x\r\na = (n - c) // (k + 1)\r\nb = n - a - c\r\nprint(a, b, c)", "def dipCert(arr):\r\n n, k = arr[0], arr[1]\r\n d, c, l = 0, 0, 0\r\n \r\n if k > n//2:\r\n d, c, l = 0, 0, n \r\n \r\n else:\r\n c = (n//2)//(k+1)\r\n d = c*k\r\n l = n - (c+d)\r\n ml = [c,d,l]\r\n return ml\r\n\r\nns = list(map(int, input().split()))\r\nprint(*dipCert(ns))", "n, k = map(int, input().split())\r\n\r\nd = n // 2 // (k + 1)\r\nc = k * d\r\n\r\nprint(d, c, n - d - c)\r\n", "n, k = [int(i) for i in input().split()]\r\na = n // 2 // (k + 1)\r\nprint(a, a * k, n - a * (k + 1))", "n, k = map(int, input().split())\r\n\r\nif n // 2 < k:\r\n\tprint(0, 0, n)\r\nelse:\r\n\ta = n // 2 // (k + 1)\r\n\tb = n // 2 // (k + 1) * k\r\n\tprint(a, b, n - a - b)\r\n", "a, b = [int(x) for x in input().split()]\nnum_w = (a // 2) // (b + 1) * (b + 1)\nnum_c = num_w // (b + 1) * (b)\nnum_d = num_w // (b + 1)\nnum_l = a - num_c - num_d\nprint(\"%d %d %d\"%(num_d, num_c, num_l))\n\n", "n,k = map(int,input().strip().split(' '))\nw = int(n/2);\nx = int(w/(k+1))\nprint(str(x)+' '+str(int(x*k))+' '+str(int(n - x - x*k)))", "read = lambda: map(int, input().split())\r\nn, k = read()\r\np = n // 2 // (k + 1)\r\nprint(p, p * k, n - p * (k + 1))", "n, k = map(int, input().split())\r\nd = (n//2)//(k+1)\r\nans = k*d\r\n\r\nif ans >= 0 and d >= 0 and ans+d <= n//2:\r\n print(d, ans, n-ans-d)\r\nelse:\r\n print(\"0 0\", n)\r\n", "n, k = [int(x) for x in input().split()]\r\n\r\ndef check(n, dip, k):\r\n return n - (dip + k * dip) >= n / 2\r\n\r\nl, r = 0, 1000000000000000000000000000\r\nwhile l + 1 != r:\r\n m = (l + r) // 2\r\n if check(n, m, k):\r\n l = m\r\n else:\r\n r = m\r\nprint(l, l * k, n - (l + l * k))", "n,k=map(int,input().split())\r\nnd2=n//2\r\nc=nd2//(k+1)\r\nd=k*c\r\nprint(c,d,n-c-d)", "n, k = map(int, input().split())\r\nr1 = (n//2) // (k+1)\r\nr2 = k*r1\r\nr3 = max(n-r1-r2, (n+1)//2)\r\nprint(r1, r2, r3)", "n, k = list(map(int, input().strip().split()))\r\n\r\nd = (n // 2) // (k+1)\r\nprint(str(d) + \" \" + str(d*k) + \" \" + str(n-d*(k+1)))", "string = input()\r\nnumbers = string.split(\" \")\r\na = int(numbers[0])\r\nb = int(numbers[1])\r\nx = a // 2 // (b + 1)\r\ny = b * x\r\nz = a - x - y\r\nprint(\"%d %d %d\" % (x, y, z))", "n, k = map(int, input().split(' '))\r\nd = (n//2) // (1+k)\r\nprint(d, d*k, n-(d+d*k))", "n, k = map(int, input().split())\nd = (n // 2) // (k + 1)\nprint(d, k * d, n - (d * (k + 1)))\n", "n,k=map(int,input().split())\nm=(n//2)//(k+1)\nprint(m,m*k,n-m*(k+1))\n\n \t \t\t \t\t \t\t \t \t\t\t \t \t \t\t\t\t", "n,k=list(map(int,input().split()))\r\na=0\r\nb=0\r\na=int(int((n/2))/(k+1))\r\nb=k*a\r\nr=n-a-b\r\nprint(int(a),int(b),int(r))", "cnt=lambda s,i:s.count(i)\r\nii=lambda:int(input())\r\nsi=lambda:input()\r\nf=lambda:map(int,input().split())\r\nil=lambda:list(map(int,input().split()))\r\nn,k=f()\r\ni=n//2//(k+1)\r\nprint(i,i*k,n-(i+i*k))", "n,k = map(int,input().split(' '))\r\nprint(\"%d %d %d\"%(n//(2*k+2),n//(2*k+2)*k,n-(n//(2*k+2)+n//(2*k+2)*k)))\r\n", "n, k = map(int,input().split())\r\nx = int((n / 2) / (k + 1))\r\nprint(x, k * x, n - (k + 1) * x)", "n,k=map(int,input().split())\r\nnd=n//(2*(k+1))\r\nnc=k*nd\r\nprint(nd,nc,n-(nc+nd))", "n,k = map(int,input().split())\r\nnum = int(n / 2 // (k+1))\r\nprint(num, num * k, n - num*(k+1))\r\n", "n,k=map(int,input().split())\r\nwin = (n//2)//(k+1)\r\nprint(win,win*k,n-win*(k+1))", "n,k = map(int,input().split())\r\ns = n//2\r\np = s//(k+1)\r\nprint(p,k*p,n-p-k*p)\r\n", "n, k = map(int, input().split())\n\nl = -1\nr = int(1e13)\n\n\ndef check(x):\n return x * (k + 1) >= n // 2\n\n\nwhile (r - l > 1):\n mid = (l + r) // 2\n\n if check(mid):\n r = mid\n else:\n l = mid\n\nif r * (k + 1) > n // 2:\n r = l\n\nprint(r, r * k, n - r * (k + 1))", "a,b = map(int,input().split())\r\nt = a//2\r\nprint(t//(b+1),b*(t//(b+1)),a-(t//(b+1))-b*(t//(b+1)))", "n,k=map(int,input().split())\nbase=n//(2*(k+1))\nprint(base,k*base,n-(k+1)*base)\n", "n, k = map(int, input().split())\r\nd = n // (2 * (k + 1))\r\nprint(d, k * d, n - (k + 1) * d)", "[n,k]=[int(_) for _ in input().split()]\r\n[l,r]=[0,n]\r\nwhile(l+1<r):\r\n m=(l+r)//2\r\n p=m+m*k\r\n if (p<=n//2):\r\n l=m\r\n else:\r\n r=m\r\nprint(l,l*k,n-l*k-l)", "n, k = [int(s) for s in input().split(' ')]\r\nd = (n // 2) // (k + 1)\r\nprint(d, k * d, n - (k + 1) * d)\r\n\r\n", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n\ndef main():\n n, k = [int(x) for x in input().split()]\n d = max(0, (n//(2*k + 2)))\n g = d * k\n print(d, g, n-(d+g))\n\n\nif __name__ == '__main__':\n main()\n\n# EOF\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Jul 10 12:58:17 2017\r\nCF818A.py\r\n\r\n@author: Alexandru Sirghi\r\n\"\"\"\r\n\r\nline_input = list(map(int, input().split()))\r\nnum_students = line_input[0]\r\nratio = line_input[1]\r\n\r\nmax_winners = int(num_students / 2)\r\n\r\ndiplomas = int(max_winners / (ratio + 1))\r\ncertificates = diplomas * ratio\r\nlosers = num_students - diplomas - certificates\r\n\r\nprint(\"%d %d %d\" % (diplomas, certificates, losers))", "class CodeforcesTask818ASolution:\n def __init__(self):\n self.result = ''\n self.n_k = []\n\n def read_input(self):\n self.n_k = [int(x) for x in input().split(\" \")]\n\n def process_task(self):\n r = self.n_k[1] + 1\n x = self.n_k[0] // 2 // r\n self.result = \"{1} {2} {0}\".format(self.n_k[0] - r * x, x, x * self.n_k[1])\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask818ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n", "#!/usr/bin/env python3\n\n[n, k] = map(int, input().strip().split())\n\nd = (n // 2) // (k + 1)\ng = d * k\n\nprint (d, g, n - d - g)\n", "import sys\r\nn,k = map(int,input().split())\r\n\r\nd=int(int(n/2) / (k+1))\r\nc=k*d\r\n\r\nif (d>=0 and c>=0 and c+d<=int(n/2)):\r\n print(d,c,n-d-c)\r\nelse:\r\n print(\"0 0\",n)\r\n", "inp=input().split()\nn=int(inp[0])\nk=int(inp[1])\nprint(int(n/(2*(k+1))),k*int(n/(2*(k+1))),n-(k+1)*int(n/(2*(k+1))))", "n,k=input().split()\r\nn=int(n)\r\nk=int(k)\r\n\r\na=n//2//(k+1)\r\nb=a*k\r\nc=n-a-b\r\nprint(a,b,c)\r\n", "n,k=map(int, input().split())\nd=int((n/2)/(k+1))\ns=d*k\nkazanamayan=n-(s+d)\nprint(d,s,kazanamayan,sep=\" \")\n\n\n", "n, k = map(int, input().split())\r\n\r\nh = n // 2\r\na = h // (k + 1)\r\nprint(a, \" \", k * a, \" \", n - a * (k + 1))\r\n", "n, k = map(int, input().split())\r\n\r\nwin = n // 2\r\ndip = win // (k + 1)\r\ncer = dip * k\r\nlosers = n - dip - cer\r\nprint(dip, cer, losers)\r\n", "n,k=map(int,input().split())\r\nb=n/2\r\nif n>k:\r\n a=1+k\r\n d=b/a\r\n d=int(d)\r\n c=k*d\r\n c=int(c)\r\n e=c+d\r\n o=n-e\r\n o=int(o)\r\n print(str(d)+\" \"+str(c)+\" \"+str(o))\r\nelse:\r\n print(\"0\"+\" \"+\"0\"+\" \"+str(n))\r\n", "n,k = map(int, input().split())\r\nif n//2 == n/2:\r\n t = n//2\r\n n -= t\r\n t += n%(k+1)\r\n n -= n%(k+1)\r\n n //= (k+1)\r\n print(\"{} {} {}\".format(n,k*n,t))\r\nelse:\r\n t = n//2 + 1\r\n n -= t\r\n t += n%(k+1)\r\n n -= n%(k+1)\r\n n //= (k+1)\r\n print(\"{} {} {}\".format(n,k*n,t))", "n, k = map(int, input().split())\r\n\r\ncertificate = n//2//(k+1) * k\r\ndiplomas = n//2//(k+1)\r\nnon_winners = n - diplomas-certificate\r\n\r\nprint(diplomas, certificate, non_winners)", "n,k = list(map(int,input().split()))\r\nr = n//((k+1)<<1)\r\nprint(r,r*k,n-r*(k+1))\r\n", "import sys\n\narr = sys.stdin.readline().split()\narr_ = [int(elem) for elem in arr]\n\nn = arr_[0]\nk = arr_[1]\n\nx = int(0.5* ((n)/(k+1)))\n\n\nprint(x, k*x, n-(k*x+x))\n", "n,k = map(int, input().strip(' ').split(' '))\n # diplomas = 0\n# certificates = k*diplomas\ndiplomas = n//(2*(k+1))\nwinners=diplomas + k*diplomas\nif(diplomas<1):\n\t# print(\"case 1\")\n\tprint(0,0,n)\nelif(winners>n/2):\n\twhile(winners>n/2 and diplomas >0):\n\t\tdiplomas-=1\n\t\twinners=diplomas + k*diplomas\n\t\t# print(\"winners\",winners)\n\t# print(\"case 2\")\n\tprint(diplomas,k*diplomas,n-winners)\nelse:\n\t# print(\"case 3\")\n\tprint(diplomas,k*diplomas,n-winners)", "import math\r\nip=input()\r\nI=ip.split()\r\nn=int(I[0])\r\nk=int(I[1])\r\nmax_wins=n//2\r\ndipls=math.floor(max_wins/(k+1))\r\ncerts=dipls*k\r\nnon_winners=n-(certs+dipls)\r\nprint(str(dipls)+\" \"+str(certs)+\" \"+str(non_winners))\r\n", "\r\nimport sys\r\n#sys.stdin=open(\"data.txt\")\r\ninput=sys.stdin.readline\r\n\r\nn,k=map(int,input().split())\r\n\r\nfactor=(n//2)//(k+1)\r\n\r\nprint(\"%d %d %d\"%(factor,factor*k,n-factor*(k+1)))\r\n", "n, k = [int(i) for i in input().split()]\r\nl = 0\r\nr = 10 ** 13\r\n\r\nwhile l < r:\r\n \r\n cur = (l + r + 1) // 2\r\n priz = cur * k\r\n if cur + priz <= n // 2:\r\n l = cur\r\n else:\r\n r = cur - 1\r\n\r\nprint(l, l * k, n - l - l * k)\r\n", "n, k = map(int, input().split())\r\na = (n//2)//(k+1)\r\nprint(a, a*k,n-a*(k+1))", "n, k = map(int, input().split())\r\n\r\n# handle the case when there are no winners\r\nif n // 2 < k:\r\n print(0, 0, n)\r\n exit()\r\n\r\n# find the maximum number of winners\r\nlow, high = 0, n // 2\r\nwhile low < high:\r\n mid = (low + high + 1) // 2\r\n if mid + k*mid <= n // 2:\r\n low = mid\r\n else:\r\n high = mid - 1\r\n\r\nx = low\r\nkx = k * x\r\nnot_winners = n - (x + kx)\r\n\r\nprint(x, kx, not_winners)\r\n", "n, k = map(int, input().split())\n\nv_max = int(n/2)\n\nx_floor = int(v_max/(k+1))\nx = v_max/(k+1)\n\n\nif x_floor == x:\n\taux = x_floor * (k+1)\n\taux = n - aux\n\tprint(x_floor, x_floor*k, aux, sep=' ')\nelse:\n\tprint(x_floor, x_floor*k, (n - x_floor*(k+1)), sep=' ')\n", "n,k = [int(x) for x in input().split()]\nx= n//(2*(k+1))\nprint(str(x) +\" \"+ str(k*x)+\" \"+ str((n-(k+1)*x)))\n", "X = list(map(int, input().split()))\r\nif X[1] > X[0] // 2:\r\n print(0, 0, X[0])\r\n exit()\r\nMAX = X[0] // 2\r\nMAX = MAX - MAX % (X[1] + 1)\r\nx = MAX // (X[1] + 1)\r\nprint(x, x * X[1], X[0] - MAX)\r\n\r\n# UB_CodeForces\r\n# Advice: Help everyone in any situation\r\n# Location: Next to the tissue box\r\n# Caption: I am so sick\r\n", "n,k=map(int,input().split())\r\nl=int(n/2)\r\nl-=l%(k+1)\r\na=l\r\nprint(int(a/(k+1)),int(a/(k+1))*k,n-int(a/(k+1))*k-int(a/(k+1)))\r\n\r\n", "n, k = [int(i) for i in input().split(' ')]\r\ns = ((n//2)//(k+1))\r\nprint(s, k*s, n - (k+1)*s)", "n,k = input().strip().split()\r\nn,k = int(n),int(k)\r\nx=n//(2*(k+1))\r\n\r\nif x<1:\r\n print(0,' ',0,' ',n)\r\nelse:\r\n print(x,' ',k*x,' ',n-x-k*x)\r\n", "a = [int(x) for x in input().split()]\r\nn=a[0]\r\nk=a[1]\r\nif k+1>int(n/2): print(0, 0,n)\r\n\r\nelse:\r\n a = int(int(n/2)/(1+k))\r\n first = a\r\n second = a*k\r\n print(first,second,n-first-second) ", "n,k=map(int,input().split())\r\nd = int(n//(2*k+2))\r\nc = k*d\r\ns = n - c - d\r\nprint(d,c,s)\r\n", "# http://codeforces.com/problemset/problem/818/A\r\nget=lambda:list(map(int,input().split()))\r\nn,k=get()\r\na=n//2\r\nb=a//(k+1)\r\nans=[b*k,b]\r\n\r\nprint(ans[1],ans[0], n-(b*(k+1)))\r\n", "n, k = map(int, input().split())\r\nh = n // 2 + n % 2\r\nm = n - h\r\nif m == 0:\r\n print(0, 0, h)\r\nelse:\r\n a = m // (k + 1)\r\n print(m // (k + 1), a * k, n - (m // (k + 1) + a * k))\r\n", "n, k = map(int, input().split())\r\nl, r = 0, n\r\nwhile r - l > 1:\r\n m = (l + r) // 2\r\n if n >= m * (k + 1) * 2:\r\n l = m\r\n else:\r\n r = m\r\nprint(l, l * k, n - l * (k + 1))", "n, k = (input().split())\nn = int(n)\nk = int(k)\nd = int((n/2)/(k+1))\nc = int(k*d)\nprint(d,c, n-d-c)\n", "n, k = [int(i) for i in input().split()]\r\n\r\nd = n // (2 * (k + 1))\r\nc = d * k\r\nl = n - (d + c)\r\nprint(d, c, l)", "n, k = map(int, input().split())\r\nans = n // ((k + 1) * 2)\r\nprint(ans, ans * k, n - (ans * k + ans))\r\n", "if __name__ == '__main__':\r\n str = input()\r\n (n, k) = str.split(' ')\r\n n = int(n)\r\n k = int(k)\r\n a = n // 2 // (k+1)\r\n b = a * k\r\n c = n - a - b\r\n print(a, b, c)", "\r\nn,k=map(int,input().split())\r\nc=n//((k+1)*2)\r\nprint(c,end=' ')\r\nd=k*c\r\nprint(d,end=' ')\r\nre=n-(c+d)\r\nprint(re)", "a,b=map(int,input().split())\r\nc=a//2\r\nd=c//(b+1)\r\nprint(d,b*d,a-d-b*d)", "N, K = map(int, input().split())\r\n\r\n\r\nD = int(N / (2 * ( K + 1)))\r\nprint(D,end= \" \")\r\nprint(D * K, end= \" \")\r\nprint(max(N // 2, N - D*(K + 1)))", "##n = int(input())\r\n##a = list(map(int, input().split()))\r\n##print(' '.join(map(str, res)))\r\ndef list_input():\r\n return list(map(int, input().split()))\r\n\r\n[n, k] = list_input()\r\nd = n//(2*(k+1))\r\nc = k*d\r\nl = n-(c+d)\r\nprint(' '.join(map(str, [d, c, l])))\r\n", "n,k=list(map(int,input().split()))\r\nx=(n//2)//(k+1)\r\nprint(x,k*x,n-(x+k*x))", "n,k=map(int,input().split())\r\nd=n//(2*(k+1))\r\nc=k*d\r\nnw=n-(c+d)\r\nprint(d,c,nw)", "s = input().split()\nn = int(s[0])\nk = int(s[1])\n\na = n//(2*(k+1))\n\nb = k * a;\n\nprint(a,\" \",b,\" \",n-(a+b))", "n, k = map(int, input().split())\r\npr = n//2\r\nprint(pr//(k+1), pr//(k+1)*k, n - pr//(k+1)*(k+1))", "from math import floor\r\n\r\nn, k = map(int, input().split())\r\nr = floor(n / (2 * (k + 1)))\r\nprint(r, k * r, n - r * (k + 1))\r\n", "n,k=list(map(int,input().strip().split(' ')))\r\nd=n//(2*(k+1))\r\nc=(k)*d\r\nw=0\r\nif (d+c)>=n/2:\r\n w=n//2\r\nelse:\r\n w=c+d\r\n \r\nprint(d,c,n-w)\r\n ", "N,k = [int(i) for i in input().split()]\r\ng = N // 2 // (k + 1)\r\nprint(g,g * k,N - g * (k + 1))", "n , k = map(int , input().split())\r\n\r\nmid = n // 2\r\n\r\nu = mid // (k + 1)\r\n\r\nprint(str(u) + ' ' + str(k * u) + ' ' + str(n - (k + 1) * u))", "def diploma():\r\n IPT = []\r\n ipt = input()\r\n Ipt = ipt.split()\r\n for x in Ipt:\r\n IPT.append(int(x))\r\n n = IPT[0]\r\n k = IPT[1]\r\n C = 0\r\n D = 0\r\n R = int(n/2)\r\n C = (int(R/(k+1)))\r\n D = (C*k)\r\n print(str(int(C))+' '+str(int(D))+' '+str(int(n-C-D)))\r\n\r\ndiploma()\r\n", "from math import *\r\nn, k = map(int, input().split())\r\n\r\nif k >= n:\r\n l = n\r\n d = 0\r\n c = 0\r\n\r\nelse:\r\n w = floor(n / 2)\r\n l = n - w\r\n d = w // (k + 1)\r\n c = d * k\r\n l += n - l - d - c\r\n\r\nprint(d, c, l)\r\n", "import sys\r\n\r\nn, k = map(int, input().split())\r\nx = n // (2*k + 2)\r\nprint(x, x*k, n - x*(k+1))\r\n", "\nn,k = map(int,input().split())\n\nd = 0\nlo = 0\nhi = n//2\n\nwhile hi - lo > 1:\n\tmid = (lo + hi) >> 1\n\tif mid*(k+1) <= n//2:\n\t\tlo = mid\n\telse:\n\t\thi = mid\n\nif hi*(k+1) <= n//2:\n\td = hi\nelse:\n\td = lo\n\nc = d*k\nrest = n - d - c\n\nprint (str(d) + ' ' + str(c) + ' ' + str(rest))\n\n\n", "n, k = map(int, input().split())\r\nl = 0\r\nr = n\r\nans = 0\r\nwhile l <= r:\r\n m = (l + r) // 2\r\n if m + m * k <= n // 2:\r\n ans = m\r\n l = m + 1\r\n else:\r\n r = m - 1\r\n\r\n\r\nprint(ans, ans * k, n - ans - ans * k)", "n, k = input().split()\nn, k = int(n), int(k)\ndip = gram = 0\n\ndip = int( (n/2) / (k+1))\ngram = int(dip * k)\n\nif (dip + gram > n/2):\n\tprint(0, 0, n, end=' ')\nelse:\n\tother=n-dip-gram\n\tprint(int(dip), int(gram), int(other), end=' ')\n\n", "\r\nn , k = map(int , input().split())\r\n\r\na = (n // 2) // (k + 1)\r\n\r\n\r\nprint(a , a * k , n - (a * (k + 1)))", "n,k=map(int,input().split())\r\np=((n//2)//(k+1))*(k+1)\r\na=(p/(k+1))\r\nb=(k*p/(k+1))\r\nprint (int(a),int(b),int(n-a-b)) ", "nk = input().split()\r\nn = int(nk[0])\r\nk = int(nk[1])\r\nt = n // 2\r\nt -= t % (k+1)\r\nd = (t*k)//(k+1)\r\ng = t // (k+1)\r\no = n - d - g\r\nprint(g, d, o)\r\n", "def read():\r\n return [int(x) for x in input().split()]\r\nx,y=read()\r\ni=0\r\nz=x//2\r\na=0\r\nwhile z>0:\r\n if i%(y+1)==0:\r\n a=int(z/(y+1))\r\n break\r\n z-=1\r\nprint(str(a)+\" \"+str(a*y)+\" \"+str(x-(a*(y+1))))\r\n", "numList=input().split(\" \")\r\nn=int(numList[0])\r\nk=int(numList[1])\r\nd=(n//2)//(k+1)\r\nc=k*d\r\nother=n-c-d\r\nprint(d,c,other)", "# import sys\r\n# sys.stdin = open(\"test.in\",\"r\")\r\n# sys.stdout = open(\"test.out.py\",\"w\")\r\nn,k=map(int,input().split())\r\na=n//2\r\nif k<=a-1:\r\n\tx=int(a/(k+1))\r\n\tprint(x,k*x,n-(k+1)*x)\r\nelse:\r\n\tprint(0,0,n)\t", "a,b=input().split()\r\na=int(a)\r\nb=int(b)\r\nif b>=a//2:print(\"0 0\",a)\r\nelse:\r\n\ti=a//(2*(b+1))\r\n\tprint(i,i*b,a-i*(b+1))\r\n\t", "n, k = [int(t) for t in input().split()]\r\n\r\ndip = (n // 2) // (k + 1)\r\ngr = k*dip\r\nlost = n - dip - gr\r\n\r\nprint(dip, gr, lost)\r\n", "# n \tnumber of students\n# k\t\tratio between number of certificates and the number of diplomas\n\nn, k = map(int, input().split())\n\nmax_winners = n // 2\n\ncertificates = max_winners // (k + 1)\n\ndiplomas = certificates * k\n\nnot_winners = n - (certificates + diplomas)\n\nprint(certificates, diplomas, not_winners)", "n,k = map(int,input().split())\r\nx =int(n/2)/(k+1)\r\nx=int(x)\r\ny=k*x ;\r\nz=n-y-x\r\nprint(x,y,z)\r\n", "n,k=map(int,input().split())\r\nd=n//(2*k+2)\r\nprint(d,d*k,n-d-d*k)\r\n", "n,k = map(int, input().split())\nd = n//(2*(k+1))\nc = d*k\nl = n-d-c\nprint(d,c,l)", "n, k = input().split()\r\nn=int(n)\r\nk=int(k)\r\nx = (n//2)//(k+1)\r\nprint(x,k*x,n-x*(k+1))", "n, k = (int(a) for a in input('').split())\r\na = int(n/2)\r\nif(a%(k+1)!=0):\r\n a=a-(a%(k+1))\r\nx=int(a/(k+1))\r\ny=int(x*k)\r\nz=int(n-(x+y))\r\nprint(x,y,z)\r\n", "n, k = map(int, input().split())\r\nans1 = n // (k+1) * (k+1) // ((k+1)*2)\r\nans2 = n // (k+1) * (k+1) // ((k+1)*2) * k\r\nans3 = n - ans1 - ans2\r\nprint(ans1, ans2, ans3)", "n, k = [int(x) for x in input().split()]\r\nd = ((n//2)-(n//2)%(k+1))//(k+1)\r\nc = k*d\r\nl = n-((n//2)-(n//2)%(k+1))\r\nprint(d,c,l)", "a, b=map(int, input().split())\r\nc=a//2\r\nd=c//(b+1)\r\ne=b*d\r\nprint(d, e, a-d-e)\r\n ", "import sys\r\ninput=sys.stdin.readline\r\nfrom collections import defaultdict as dc\r\nfrom collections import Counter\r\nfrom bisect import bisect_right, bisect_left,bisect\r\nimport math\r\nfrom operator import itemgetter\r\nfrom heapq import heapify, heappop, heappush\r\nn,k=map(int,input().split())\r\nx=(n//2)//(k+1)\r\ny=k*x\r\nprint(x,y,n-x-y)", "import math\r\nn,k = map(int,input().split())\r\ntotal = n\r\nnone = math.ceil(n/2)\r\nn-=none\r\nindex = n//(k+1)\r\na = index\r\nb = index*k\r\nnone+=(n-(a+b))\r\nprint(a,b,none)\r\n ", "\r\nn,k=map(int,input().split())\r\nans=n//(k+1)\r\n#print(ans)\r\nif (k+1)*ans>n//2:\r\n\tans=(n//2)//(k+1)\r\n\r\nprint(ans,k*ans,n-((k+1)*ans))", "from math import floor\n\n\ndef main():\n [n, k] = [int(_) for _ in input().split()]\n diplomas = floor((n // 2) / (k + 1))\n certificates = k * diplomas\n non_winners = n - diplomas - certificates\n\n print(diplomas, certificates, non_winners)\n\n\nif __name__ == '__main__':\n main()\n", "n,k=map(int,input().split())\r\nr=n//2;r//=(k+1)\r\nprint(r,r*k,n-r-r*k)", "n, k = map(int, input().split())\r\na = n // 2 // (k + 1)\r\nprint(a, a * k, n - a * (k + 1))\r\n", "n, k = map(int, input().split())\ns = n // 2\na = s // (k + 1)\nb = a * k\nc = n - a - b\nprint(a, b, c)\n", "n, k = map(int, input().split())\r\na = n // 2\r\nb = a // (k+1)\r\n\r\nprint(b, b*k, n - (b*(k+1)))", "data=input().split()\r\nn=int(data[0])\r\nk=int(data[1])\r\n\r\nd=int(n/(2*(1+k)))\r\nc=int(k*d)\r\nw=int(n-(c+d))\r\n\r\nprint(d,c,w)\r\n", "# A. Diplomas and Certificates\r\n\r\nn, k = map(int, input().split())\r\n\r\nd = n // (2 * (k+1))\r\ns = d * k\r\nnw = n - (d + s)\r\n\r\nprint(d, s, nw)\r\n", "n, k = map(int, input().split())\r\nif k>=n//2:\r\n\tprint(0, 0, n)\r\nelse:\r\n\tb=n//(2*(k+1))\r\n\tprint(b, b*k, n-b-b*k)", "n, k = map(int, input().split())\r\na = 0\r\nb = 10 ** 12 + 1\r\nwhile (a < b - 1):\r\n m = (a + b) // 2\r\n if m + m * k <= n // 2:\r\n a = m\r\n else:\r\n b = m\r\nprint(a, a * k, n - a * (k + 1))", "n,k=map(int,input().split())\r\nm=n//(2*(k+1))\r\nprint(m,m*k,n-m*(k+1))", "n,k=map(int,input().split())\r\nnwi=(n+1)//2\r\nwi=(n//2)\r\nnwi=nwi+(wi%(k+1))\r\nwi=(wi//(k+1))*(k+1)\r\ndip=wi//(k+1)\r\ncert=wi-dip\r\nprint(dip,cert,nwi)\r\n", "import random\r\nimport math\r\nimport sys\r\nimport turtle\r\n\r\n#.stdin=open(\"E:1.in\",\"r\");\r\n# sys.stdout=open(\"E:1.in\",\"w\");\r\n\r\ns=input()\r\nt=s.split(' ')\r\nn,m=int(t[0]),int(t[1])\r\nc=n/2\r\nan2=0\r\nan3=n\r\nan1=int(c/(m+1))\r\nif (an1<=0) :\r\n\tan1=0\r\nelse :\r\n\tan2=an1*m\r\n\tan3=n-an1-an2\r\nprint('%d %d %d' %(an1,an2,an3))", "n , k = map(int,input().strip().split())\r\nA = []\r\nt = int((n/2)//(k+1))\r\nA.append(t)\r\nA.append(t*k)\r\nA.append(n - t - k*t)\r\nprint(*A)", "n,k=map(int,input().split())\r\ndip=n//(2*(k+1));\r\nprint(dip,dip*k,n-dip-dip*k)", "import math\r\nz , k = map(int , input().split())\r\ntmp = z\r\nz //= 2\r\nx = int(z / (k + 1))\r\ny = int(x * k)\r\nprint(x , y , tmp - x - y)\r\n", "n,k=map(int,input().split())\r\nif n/2<(k+1):\r\n\tprint(0,0,n)\r\nelse:\r\n\ta=(n//2)//(k+1)\r\n\tprint(a,a*k,n-a*(k+1))", "n, k = map(int, input().split())\r\nprize = n // 2\r\nprize -= (prize % (k + 1))\r\ndipl = prize // (k + 1)\r\nrest = dipl * k\r\nprint(dipl, rest, n - prize)", "def solve(p,a):\r\n tmp = p//2//(a+1)\r\n ans1 = tmp\r\n ans2 = tmp*a\r\n ans3 = p - tmp - tmp*a\r\n return \"{} {} {}\".format(ans1,ans2,ans3)\r\n\r\np,a=map(int,input().split())\r\nprint(solve(p,a))\r\n", "n,k=map(int,input().split())\r\n\r\n\r\n\r\na=(n//2)//(1+k)\r\n\r\n\r\nprint(a,a*k,(n-(a*(1+k))))\r\n", "n,k = map(int,input().split())\r\np = (n // 2) //(k+1)\r\no = p * k\r\nl = n - p - o\r\nprint(str(p)+' '+str(o)+' '+str(l))", "def main():\r\n n,k=map(int,input().split())\r\n we=n//(2*(k+1))\r\n ans=n-((k+1)*we)\r\n print(we,end=' ')\r\n print(we*k,end=' ')\r\n print(ans)\r\nmain()\r\n \r\n \r\n \r\n \r\n \r\n", "n, k = map(int, input().split())\r\nt1 = n // 2\r\nt2 = k + 1\r\na = t1 // t2\r\nb = a * k\r\nc = n - (a + b)\r\nprint(a,b,c)", "n, k = map(int, input().split())\r\nx = n // (2 * (k + 1))\r\nprint(x, x * k, n - x * (k + 1))", "def winners(n, k):\r\n w = n // 2\r\n #d > c\r\n #d = c * k\r\n #w = d + c\r\n #w = c * k + c\r\n #w = c (k + 1)\r\n c = w // (k + 1)\r\n d = c * k\r\n nw = n - c - d\r\n return [c, d, nw]\r\n\r\nn, k = list(map(int, input().strip().split()))\r\nprint(*winners(n, k))", "import math\r\n\r\nn, k = map(int, input().split())\r\nt = math.floor((n // 2) / (k+1))\r\nprint(t, k*t, n-(t+t*k))", "from math import floor, ceil\r\nn, k = map(int, input().split())\r\n\r\n\r\ni = floor(0.5 * n / (k + 1))\r\nprint(i, i * k, n - i * (k + 1))\r\n ", "n , k =[int(x)for x in input().split(\" \")]\na = n // (2*(1+k))\nb = a*k \nc = n - (a+b)\nprint (\"%d %d %d\"%(a,b,c))\n", "n,k = map(int,input().split())\r\na = n//(2*(k+1))\r\nprint(a,k*a,n-(k+1)*a)", "import math\r\n\r\nn,k=map(int,input().split())\r\n\r\np = n//2\r\nd = p//(1+k)\r\ng = d*k\r\n\r\nprint(d, g, n-g-d)", "def read():\n return [int(x) for x in input().split(\" \")]\n\nn, k = read()\n# We have to divide n/2 in a proportion k:1, hence we divide n/2 in k+1 and we multiply the results\nproportion = n // 2 // (k+1)\nd = proportion\nc = proportion * k\nprint(\"{} {} {}\".format(d, c, n - (c+d)))", "n,k = map(int,input().split())\r\ndiploma = (n//2) // (k+1)\r\ngram = diploma *k\r\ns = n - gram - diploma\r\nprint(diploma,gram,s)\r\n", "n, k = map(int, input().split())\r\n\r\nl = n // (2 * (k + 1))\r\n\r\nprint(l, l * k, n - l * (k + 1))\r\n", "s = input ()\r\nl = s.split (' ')\r\ncount_of_members = int (l [0])\r\nratio = int (l [1])\r\n\r\ncount_of_win = count_of_members // 2\r\ns = count_of_win // (ratio+1)\r\nl = s * ratio\r\nr = count_of_members - l - s\r\n\r\nprint (s),\r\nprint (l),\r\nprint (r) ", "n, k = map(int, input().split())\r\np_max = n // 2\r\nnd = p_max // (k + 1)\r\nng = nd * k\r\nprint(nd, ng, n - ng - nd)\r\n", "if __name__ == \"__main__\":\n\tn,k = map(int,input().split())\n\tc = n//((k+1)*2)\n\tif c==0:\n\t\tprint(0,0,n)\n\telse:\n\t\tprint(c,k*c,n-(k+1)*c)\n", "n, k = map(int, input().split())\r\nd = int(n/(2*(k+1)))\r\nc = k*d\r\nl = n - d - c\r\nprint(d,c,l)", "import math as math\ninput_ar = list(map(int,input().rstrip().split(\" \")))\nn = input_ar[0]\nk = input_ar[1]\nwinner_max = n//2\nmax_diplomas = winner_max/(k+1)\nint_dip = int(math.floor(max_diplomas))\nif max_diplomas == int_dip:\n print('{} {} {}'.format(int_dip,winner_max-int_dip,n-winner_max))\nelse:\n print('{} {} {}'.format(int_dip,k*int_dip,n-((k+1)*int_dip)))\n", "n, k = map(int, input().split())\r\n\r\n# winners <= n / 2\r\n# certificates = k * diplomas\r\n\r\ndiplomas = n // (2 * (k + 1))\r\ncerts = diplomas * k\r\n\r\n\r\nprint(\r\n diplomas,\r\n certs,\r\n n - diplomas - certs\r\n)\r\n", "n, k = map(int, input().split())\r\nd = n // 2 // (k + 1)\r\ng = k * d\r\nprint(d, g, n - d - g)\r\n", "a,b=map(int,input().split())\r\nmult=(a//2)//(b+1)\r\nprint(mult, mult*b, a-mult*(b+1))", "n,k = input().split()\r\nn = int(n)\r\nk = int(k)\r\nupper = int(n/(2*(k+1)))\r\nD = 0\r\nC = 0\r\nif upper==0:\r\n print(D,C,n)\r\nelse:\r\n D = upper\r\n C = k*upper\r\n while C+D > n/2:\r\n D = D - 1\r\n C = k*D\r\n \r\n print(int(D),int(C),int(n-(D+C)))", "n,k = map(int, input().split())\r\nd = n // 2 // (k+1)\r\nc = k * d\r\nprint(d,c,n-d-c)", "\nInput=lambda:map(int,input().split())\ns, k = Input()\n \n# s = c+d+n\n# c = kd k = c//d\n# c+d <= s//2\n \n# kd+d <= s//2\n\nif k+1 > s//2:\n print(0,0,s)\n exit()\n\ni = s//2\n \n #(k+1)*d == i\nif i % (k+1) == 0:\n d = i//(k+1)\n n = s - i\nelse:\n y = i // (k+1)\n i = y * (k+1)\n d = i//(k+1)\n n = s - i\n \nc = s - d - n\n \nprint(d,c,n)", "n,k=map(int,input().split())\r\nnd=(n//2)//(k+1)\r\nnc=k*nd\r\nnl=n-nc-nd\r\nprint(nd,nc,nl)", "n , k = map(int,input().split())\r\nl = -1\r\nh = n + 1\r\nwhile l + 1 < h:\r\n mid = (l + h) // 2\r\n if 2 * (mid + k * mid) <= n:\r\n l = mid\r\n else:\r\n h = mid\r\nprint(l , k * l , n - (l + k * l))\r\n", "n, k = map(int, input().split())\r\nw = n // 2\r\nc = k + 1\r\nd = w // c\r\ncert = d * k\r\nprint(d, cert, (n - (d + cert)), end = \" \")", "n, k = list(map(int, input().split()))\r\na = n / 2\r\nd = a // (k + 1)\r\ntemp = a % (k + 1)\r\na += temp\r\nc = d * k\r\nprint(int(d), int(c), int(a))\r\n", "n,k = map(int,input().split())\r\nf=(n//2)//(k+1)\r\nif f==0:\r\n print(0,0,n)\r\nelse:\r\n print(f,k*f,n-(k+1)*f)\r\n \r\n", "n,k=list(map(int,input().split()))\r\na=n//(2*(k+1))\r\nb=k*a\r\nc=n-a-b\r\nprint(a,b,c)", "\r\n\r\nn,k=map(int,input().split())\r\n\r\nwin=n//2;\r\n\r\nwin=win-win%(k+1)\r\n\r\nprint(win//(k+1),win*k//(k+1),n-win)\r\n\r\n", "n , k = map(int, input().split())\r\nh = n // 2\r\nd = h // ( k + 1 )\r\nprint( d , d * k , n - (d + ( d*k )))", "n, k = map(int, input().split())\r\n\r\n\r\nprint(n//2 // (k+1), n//2 // (k+1) * k, n - n//2 // (k+1) * (k+1))", "\"\"\"\r\n\r\nAuthor\t:\tIndian Coder\r\nDate\t:\t29th May ,2021\r\n\r\n\"\"\"\r\n#Imports\r\n\r\nimport math\r\nimport time \r\nimport random\r\nstart=time.time()\r\n\r\n\r\n# n k \r\nn,k=list(map(int ,input().split()))\r\ncerti=n//(2*(k+1))\r\ndiploma=k*certi\r\nrem=n-certi-diploma\r\nprint(certi,diploma,rem)\r\n\r\n\r\nend=time.time()\r\n#print(\"Time Of Execution Is\",end-start)\r\n\r\n", "n,k=map(int,input().split())\n\nwin=n//2\ndi=win//(k+1)\nce=di*k\nlos=n-di-ce\nprint(di,ce,los)\n ", "n , k = map(int , input().split())\r\nwhile True : \r\n chtar = n / 2 \r\n part = chtar // (k + 1)\r\n if part * (k+1) > chtar : \r\n chtar -= 1\r\n elif part *(k + 1) <= n : \r\n print(str(int(part)) + \" \" + str(int(part * k)) + \" \" + str(int(n - part *(k + 1))))\r\n break\r\n", "n,k=map(int,input().split())\r\nd=((n//(2*(k+1))))\r\nc=d*k\r\nprint(d,c,n-c-d)", "n, k = [int(i) for i in input().split()]\r\nl, r = 0, n\r\nwhile l != r - 1:\r\n m = (l + r) // 2\r\n if (m + k * m) * 2 <= n:\r\n l = m\r\n else:\r\n r = m\r\nprint(l, k * l, n - (k + 1) * l)\r\n", "n,k=map(int, input().split())\r\ndip=n//2//(k+1)\r\nprint(dip, dip*k,n-dip-dip*k)\r\n\r\n ", "def check(n, k, cnt):\r\n if (2 * cnt * (k + 1) <= n):\r\n return True\r\n else:\r\n return False\r\n \r\nn, k = map(int, input().split())\r\nl = 0\r\nr = 100000000000000\r\nwhile(r - l > 1):\r\n m = (l + r) // 2\r\n if (check(n, k, m) == True):\r\n l = m\r\n else:\r\n r = m\r\nprint(l, l * k, n - l * (k + 1))\r\n", "n, k = map(int, input().split())\r\notv = n // (2 * k + 2)\r\nprint(otv, otv * k, n - otv * (k + 1))", "def solution(n, k):\r\n p = n // 2 // (k + 1)\r\n return p, k * p, n - p - k * p\r\n \r\nn, k = map(int, input().split())\r\nprint(*solution(n, k))", "n, k = list(map(int, input().split()))\r\nm = n // 2\r\nx = m // (k + 1)\r\nprint(x, k * x, n - x - k * x)\r\n", "#!/bin/python3\r\n\r\nimport sys\r\n\r\nn, k = input().strip().split(' ')\r\nn, k = [int(n), int(k)]\r\n\r\nhalf=int(n/2)\r\n\r\nanswer=int(half/(k+1))\r\ncertificates=answer*k\r\nnot_winners=n-(answer+certificates)\r\n\r\nprint(str(answer)+\" \"+str(certificates)+\" \"+str(not_winners))", "n,k = map(int,input().split())\r\nfrom math import floor\r\npriz = floor(n/2)\r\npob = floor(priz / (k + 1))\r\npriz = pob * k\r\nprint(pob,\" \",priz,\" \",n-pob-priz)", "n, k = map(int, input().split())\r\nd = (n//2)//(k+1)\r\nprint(d, k*d, n-(k+1)*d)\r\n", "n,k = list(map(int, input().split(\" \")))\r\nprint((n//2-(n//2)%(k+1))//(k+1),((n//2-(n//2)%(k+1))//(k+1))*k,n-(n//2-((n//2)%(k+1))) if k<=n//2 else n)", "n,k=[int(x) for x in input().split()]\r\nprint((n//2)//(k+1),(n//2)//(k+1)*k,n-(n//2)//(k+1)*(k+1))", "n,k=(int(i) for i in input().split())\r\nx=int((n-(n/2))/(1+k))\r\nprint(x,x*k,n-x-x*k)", "a,b = map(int,input().split())\r\nz = a//2\r\nx =z//(b+1)\r\nprint(x,b*x,a-(b+1)*x)", "n,k=list(map(int,input().split()))\r\nno_of_nonWinners=n//2\r\nno_of_diplomas=no_of_nonWinners//(k+1)\r\nno_of_certificates=(k)*no_of_diplomas\r\nno_of_nonWinners=n-(no_of_certificates+no_of_diplomas)\r\nprint(no_of_diplomas,end=\" \")\r\nprint(no_of_certificates,end=\" \")\r\nprint(no_of_nonWinners,end=\" \")\r\n\r\n", "\r\n# -*- coding: utf-8 -*-\r\n# @Date : 2019-01-23 13:27:28\r\n# @Author : raj lath ([email protected])\r\n# @Link : link\r\n# @Version : 1.0.0\r\n\r\nfrom sys import stdin\r\n\r\nmax_val=int(10e12)\r\nmin_val=int(-10e12)\r\n\r\ndef read_int() : return int(stdin.readline())\r\ndef read_ints() : return [int(x) for x in stdin.readline().split()]\r\ndef read_str() : return input()\r\ndef read_strs() : return [x for x in stdin.readline().split()]\r\n\r\n\r\nnb_students, ratio = read_ints()\r\ndiploma = (nb_students//2) // (ratio + 1)\r\ncertifi = diploma * ratio\r\nnons = nb_students - diploma - certifi\r\nprint(diploma, certifi, nons)", "n,k=map(int,input().split())\r\nd=n//(2*(1+k))\r\nprint(d,k*d,n-(1+k)*d)\r\n", "import sys\r\n\r\nn, k = (int(el) for el in input().split())\r\n\r\nif k > n:\r\n print(0, 0, n)\r\n sys.exit()\r\n\r\n'''a, b, c = 0, 0, 0\r\na = int((n // 2) ** 0.5)\r\nb = a * k\r\nc = n - (a + b)\r\n'''\r\n'''for i in range((n // 2) ** 0.5, 0, -1):\r\n x = i\r\n y = n // 2 - i\r\n if max(y, x) / min(x, y) == k:\r\n a = min(x, y)\r\n b = max(x, y)\r\n break\r\n \r\nc = n - (a + b)'''\r\na = (n // 2) // (k + 1)\r\nb = a * k\r\nc = n - (a + b)\r\nprint(a, b, c)\r\n \r\n ", "n, k = map(int, input().split())\r\na = (n // 2) // (k + 1)\r\nb = a * k\r\nc = n - a - b\r\nprint(a, b ,c)", "n,k=map(int,input().split())\nx=n//(2*(k+1))\nprint(x,k*x,n-x*(k+1))", "def solution(n, k):\r\n d = (n//2)//(k+1)\r\n if d > 0:\r\n return [d, k*d, n - (k+1)*d]\r\n else:\r\n return [0, 0, n]\r\n\r\nn, k = [int(x) for x in input().strip().split(\" \")]\r\nans = solution(n, k)\r\nprint(ans[0], ans[1], ans[2])", "s = input().split()\r\nn , k = int(s[0]), int(s[1])\r\nd = int((n//2) / (k+1))\r\nc = k*d\r\nnw = n - (c + d)\r\nprint(d, c, nw)\r\n", "n, k = input().split()\nn, k = int(n), int(k)\n\nlo, hi = 0, n // (k + 1)\nwhile lo < hi:\n mid = (lo + hi + 1) // 2\n if mid * (k + 1) > n // 2:\n hi = mid - 1\n else:\n lo = mid\n\nprint(lo, lo * k, n - lo * (k + 1))\n", "#Needed Help.....\r\nn,k=map(int, input().split())\r\n\r\na=n//(2*(k+1))\t#Diploma\r\nb=a*k\t#Certificate\r\nc=n-(b+a)\t#Losers\r\n\r\nprint(a, b, c)", "n, k = [int(x) for x in input().split()]\r\n\r\nh = n >> 1\r\nw = h // (k + 1)\r\nc = k * w\r\nl = n - w - c\r\n\r\nprint(w, k * w, l)", "n,k=map(int,input().split())\r\nprint((n//2)//(k+1),k*((n//2)//(k+1)),n-(n//2)//(k+1)-k*((n//2)//(k+1)))", "n, k = map(int, input().split())\r\nd = n//2//(k+1)\r\nprint(d, d*k, n-d*(k+1))\r\n\r\n", "n,k = map(int, input().split())\r\np = n / 2\r\nd = p // (k+1)\r\ng = d * k\r\nn -= d + g\r\nprint(int(d), int(g), int(n))\r\n", "n, k = map(int, input().split())\r\n# d * (k + 1) * 2 <= n\r\nd = n // (2 * (k + 1))\r\ng = k * d\r\nr = n - d - g\r\nprint(str(d) + \" \" + str(g) + \" \" + str(r))", "n , k =map(int, input().split())\r\nhalf = n//2\r\nx= half//(k+1)\r\nnon_winners= n- x - (x*k)\r\nprint(x , x*k , non_winners)", "n, k = [int(number) for number in input().split()]\r\nx=n//2\r\na = x//(k+1)\r\nprint(a, a*k, n-a-a*k)", "n, k = map(int, input().split())\r\nx = (n//2)//(k+1)\r\nprint(x, x*k, n-x*(k+1))\r\n", "def main():\r\n n, k = map(int, input().split())\r\n\r\n x = n // ((k + 1) * 2) - 1\r\n if x < 0:\r\n x = 0\r\n\r\n y = x + 1\r\n \r\n if (1 + k) * y <= n / 2:\r\n print(str(y) + \" \" + str(k * y) + \" \" + str(n - (1 + k) * y))\r\n return\r\n \r\n if (1 + k) * x <= n / 2:\r\n print(str(x) + \" \" + str(k * x) + \" \" + str(n - (1 + k) * x))\r\n else:\r\n print(\"0 0 \" + str(n))\r\n\r\n\r\nmain()", "n, k = map(int, input().split())\nx = (n//2)//(k+1)\nprint(x, k*x, n-(k+1)*x)\n", "n,k = map(int, input().split())\n\nmw = n//2\n\nd = mw//(k+1)\n\nprint(d, k*d, n-d*(1+k))\n\n", "import sys, math\r\ninput=sys.stdin.readline\r\nINF=int(1e9)+7\r\n\r\n\r\ndef solve():\r\n n,k=map(int,input().split())\r\n pos=n//2\r\n pos//=(k+1)\r\n print(pos,k*pos,n-(k+1)*pos)\r\n \r\n \r\nt=1\r\nwhile t:\r\n t-=1\r\n solve()\r\n", "n, k = map(int, input().split())\r\nd = n // 2 // (1 + k)\r\nc = k * d\r\nprint(d, c, n - c - d)", "n,k=map(int,input().split())\r\nh=n//2\r\nh-=h%(k+1)\r\nprint(h//(k+1),h//(k+1)*k,n-h)", "a = input()\nm = a.split()\nn = int(m[0])\nk = int(m[1])\npol = n//2\npob = pol//(k+1)\nprint(pob, \" \", k*pob, \" \", n - (k+1)*pob)", "n,k = map(int,input().split())\r\n\r\nx = n // 2\r\nx //= k+1\r\ny = k*x\r\nz = n - (x+y)\r\nprint(x,y,z)\r\n", "#Bhargey Mehta (Sophomore)\r\n#DA-IICT, Gandhinagar\r\nimport sys, math, queue, bisect\r\n#sys.stdin = open(\"input.txt\", \"r\")\r\nMOD = 10**9+7\r\nsys.setrecursionlimit(1000000)\r\n\r\nn, k = map(int, input().split())\r\nd = n//(2*k+2)\r\nc = d*k\r\nr = n-c-d\r\nprint(d, c, r)", "n, k = input().split()\r\nn = int(n)\r\nk = int(k)\r\n\r\nesq = 0\r\ndir = 1e12\r\nres = 0\r\n\r\nwhile esq <= dir:\r\n mid = (esq+dir)//2\r\n D = mid\r\n C = mid*k\r\n if 2*C+2*D <= n:\r\n esq = mid+1\r\n res = max(res, D)\r\n else:\r\n dir = mid-1\r\n \r\nprint(str(int(res)) + \" \" + str(int(res*k)) + \" \"+ str(int(n-res-res*k)) )", "n, k = map(int, input().split())\r\na = (n // 2) // (k + 1)\r\nb = a * k\r\nprint(a, b, n - a - b)\r\n", "n,k = map(int,input().split())\r\nr = n//2\r\nd = r//(k+1)\r\nc = k*d\r\nprint(d,c,n-c-d)\r\n", "n,k = map(int,input().split())\r\nd = (n//2)//(k+1)\r\nprint(d,k*d,n-d-k*d)\r\n", "n, k = map(int, input().split())\nx = (n//(k+1))//2\nprint(x, k*x, n-(k+1)*x)\n", "(n, k) = (int(i) for i in input().split())\r\nt = int((n/2)//(k+1))\r\nprint(t,t*k,n-t*(k+1))", "n, k =map(int, input().split())\ndip = n // 2 // (k + 1)\nprint(dip, dip * k, n - dip * (k + 1))\n\n", "n, k = [int(i) for i in input().split()]\r\n\r\nmax_wins = n // 2;\r\ndiplo = (max_wins // (k + 1))\r\ncerti = diplo * k\r\n\r\nprint(diplo, certi, n - diplo - certi)\r\n" ]
{"inputs": ["18 2", "9 10", "1000000000000 5", "1000000000000 499999999999", "1 1", "5 3", "42 6", "1000000000000 1000", "999999999999 999999", "732577309725 132613", "152326362626 15", "2 1", "1000000000000 500000000000", "100000000000 50000000011", "1000000000000 32416187567", "1000000000000 7777777777", "1000000000000 77777777777", "100000000000 578485652", "999999999999 10000000000", "7 2", "420506530901 752346673804", "960375521135 321688347872", "1000000000000 1000000000000", "99999999999 15253636363", "19 2", "999999999999 1000000000000", "1000000000000 5915587276", "1000000000000 1000000006", "549755813888 134217728", "99999999999 3333333", "9 1", "1000000000000 250000000001", "5 1", "3107038133 596040207", "1000000000000 73786977", "1000000000000 73786976", "1000000000000 25000000000", "216929598879 768233755932", "1000000000000 250000000000", "1000000000000 100000000001", "100000000000 100000000001", "900000000000 100281800001", "906028900004 109123020071", "1000000000000 1"], "outputs": ["3 6 9", "0 0 9", "83333333333 416666666665 500000000002", "1 499999999999 500000000000", "0 0 1", "0 0 5", "3 18 21", "499500499 499500499000 500000000501", "499999 499998500001 500000999999", "2762066 366285858458 366288689201", "4760198832 71402982480 76163181314", "0 0 2", "0 0 1000000000000", "0 0 100000000000", "15 486242813505 513757186480", "64 497777777728 502222222208", "6 466666666662 533333333332", "86 49749766072 50250233842", "49 490000000000 509999999950", "1 2 4", "0 0 420506530901", "1 321688347872 638687173262", "0 0 1000000000000", "3 45760909089 54239090907", "3 6 10", "0 0 999999999999", "84 496909331184 503090668732", "499 499000002994 500999996507", "2047 274743689216 275012122625", "14999 49996661667 50003323333", "2 2 5", "1 250000000001 749999999998", "1 1 3", "2 1192080414 1914957717", "6776 499980556152 500019437072", "6776 499980549376 500019443848", "19 475000000000 524999999981", "0 0 216929598879", "1 250000000000 749999999999", "4 400000000004 599999999992", "0 0 100000000000", "4 401127200004 498872799992", "4 436492080284 469536819716", "250000000000 250000000000 500000000000"]}
UNKNOWN
PYTHON3
CODEFORCES
282
e69b2a591819307c7664c4c2dab6fe18
Translation
The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the «translation». Vasya translated word *s* from Berlandish into Birlandish as *t*. Help him: find out if he translated the word correctly. The first line contains word *s*, the second line contains word *t*. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols. If the word *t* is a word *s*, written reversely, print YES, otherwise print NO. Sample Input code edoc abb aba code code Sample Output YES NO NO
[ "s=input()\r\ng=input()\r\nr=s[::-1]\r\nif(g==r):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\nn=len(s)\r\nm=len(t)\r\nif(n==m):\r\n c=0\r\n for i in range(m):\r\n if(s[i]!=t[m-1-i]):\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 ", "import os, io\r\n \r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n \r\ndef main(): \r\n s = input().decode().rstrip(\"\\r\\n\")\r\n t = input().decode().rstrip(\"\\r\\n\")\r\n if s == t[::-1]:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\nmain()", "lines = []\nfor i in range(2):\n\tlines.append(input())\n#print(lines)\n\nl = len(lines[0])\ncomp = \"\"\nfor i in range(l):\n\tcomp = lines[0][i] + comp\n\nif comp == lines[1]:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n \t \t\t\t\t \t \t \t\t \t\t \t\t\t\t \t", "s=input()\r\nt=input()\r\nx=0\r\nif len(s)>len(t) or len(s)<len(t):\r\n print('NO')\r\nelse:\r\n for i in range(len(s)):\r\n if s[i]==t[-i-1]:\r\n x=x+1\r\n if x==len(s):\r\n print('YES')\r\n else:\r\n print('NO')\r\n", "t = list(input())\ns = input()\ni=0\nj=len(t)-1\nwhile(i<j):\n t[i],t[j] = t[j],t[i]\n i=i+1\n j=j-1\nx = \"\".join(t)\n\nif(x==s):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t \t\t\t \t\t \t \t \t\t \t \t", "def reverse(s): \r\n str1 = \"\" \r\n for i in s: \r\n str1 = i + str1\r\n return str1\r\ns1=str(input())\r\ns2=str(input())\r\nrev=\"\"\r\nrev=reverse(s1)\r\nif s2==rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n=input()\na=input()\ns=\"\"\nfor i in range(1,len(n)+1):\n s=s+n[-i]\nif s in a:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t \t\t\t\t\t \t \t \t \t\t \t\t\t\t\t", "a = input()\r\nb = input()\r\nc = ''\r\nfor i in reversed(range(len(a))):\r\n c += a[i]\r\nif b == c:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\r\n\r\n", "inp=input()\r\ninp1=input()\r\ninp2=inp[::-1]\r\nif inp1==inp2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "word_1 = input()\r\nword_2 = input()\r\n\r\nword_2 = word_2[-1:0:-1] + word_2[0]\r\n\r\nif word_1 == word_2:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")", "line_s = input().strip()\r\nline_t = input().strip()\r\n\r\nif line_s == line_t[-1::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "n=input()\r\nf=input()\r\nn=list(n)\r\nf=list(f)\r\nc=0\r\ni=0\r\nj=len(f)-1\r\nfor k in range(len(n)):\r\n if n[i]==f[j]:\r\n i+=1\r\n j-=1\r\n c+=1\r\nif c==len(n):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\n\r\ndef reverse(s):\r\n return s[::-1]\r\n\r\nif b == reverse(a):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\ncnt=0\r\nif len(s)!=len(t):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(s)):\r\n if s[i]==t[len(s)-i-1]:\r\n cnt+=1\r\n else:\r\n continue\r\n if cnt==len(s):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "word = input()\nbword = input()\nn = len(word) if len(word) < len(bword) else len(bword)\ngood = True if len(word) == len(bword) else False\n\nfor i in range(n):\n\tif word[i] != bword[n - 1 - i]:\n\t\tgood = False\nprint(\"YES\") if good else print(\"NO\")", "chir = input()\r\nvanG = input()\r\nif vanG==chir[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "string1 = input()\r\nstring2 = input()\r\nflag = True\r\nj = len(string2) - 1\r\n\r\nfor i in range(len(string1)):\r\n if string1[i] != string2[j]:\r\n flag = False\r\n break\r\n j = j - 1\r\n\r\nif flag == True: print(\"YES\")\r\nelse: print(\"NO\")\r\n", "import sys\r\n\r\ndef input(): return sys.stdin.readline().strip()\r\ndef iinput(): return int(input())\r\ndef rinput(): return map(int, sys.stdin.readline().strip().split()) \r\ndef get_list(): return list(map(int, sys.stdin.readline().strip().split())) \r\n\r\n\r\nn=input()\r\nm=input()\r\nl=list(n)\r\ns=[]\r\nfor i in range(len(n)-1,-1,-1):\r\n s.append(n[i])\r\nk=\"\".join(s)\r\nif(m==k):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\np=input()\r\nq=s[::-1]\r\nif q==p:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\np=input()\nif(p==s[::-1]):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\t \t\t\t\t \t \t\t\t \t \t\t \t\t \t \t\t \t\t\t", "s = input() # read the first line as string s\r\nt = input() # read the second line as string t\r\n\r\n# check if t is equal to the reverse of s\r\nif t == s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "str1 = input()\nstr2 = input()\nn = len(str1)\nstr1 = str1[::-1]\nif str1 == str2:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\t \t\t \t\t\t\t \t\t\t\t \t\t \t \t\t", "if __name__ == '__main__':\n s = input()\n t = input()\n lower = 0\n upper = 0\n for char in s:\n upper += 1\n lower += 1\n if t == s[::-1]:\n print ('YES')\n else:\n print(\"NO\")\n\n", "s = input()\r\nt = input()\r\nls = list(s)\r\nlt = list(t)\r\nlt.reverse()\r\nif ls==lt :\r\n print('YES')\r\nelse:\r\n print(\"NO\")\r\n ", "s = input()\r\nt = input()\r\nt1 = s[::-1]\r\nif(t==t1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "x=str(input())\r\ny=str(input())\r\nx_rev=x[::-1]\r\nif x_rev==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t=input()\r\ns=input()\r\nif s==t[-1::-1]:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\r\nr=input()\r\nx=s[::-1]\r\nif r == x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\na = input()\r\nres = []\r\nk = len(s) - 1\r\nwhile k >= 0:\r\n res.append(s[k])\r\n k -= 1\r\nif (''.join(res) == a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = input()\r\na = input()\r\nf = \"YES\"\r\nm = 0\r\nfor i in range(len(n)):\r\n if len(n) != len(a):\r\n m = 1\r\n print(\"NO\")\r\n break\r\n else:\r\n if a[i] != n[i*(-1)-1]:\r\n f = \"NO\"\r\n break\r\nif m != 1:\r\n print(f)", "word = list(input())\r\ntrans = list(input())\r\nword = word[::-1]\r\nif word == trans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nr = input()\r\nL = []\r\nfor i in range(len(s)):\r\n L.extend(s[i])\r\nL.reverse()\r\nans = L[0]\r\nfor i in range(1,len(s)):\r\n ans += L[i]\r\nif ans == r:\r\n print('YES')\r\nelse:\r\n print('NO')", "# Read the two words\r\ns = input()\r\nt = input()\r\n\r\n# Check if the reversed t is equal to s\r\nif t == s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nu = t[::-1]\r\nif s == u:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Mar 30 19:32:51 2021\r\n\r\n@author: nehas\r\n\"\"\"\r\na=input()\r\nb=input()\r\nif(b==''.join(reversed(a))):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\ns=\"\"\r\nfor i in range(len(a)-1,-1,-1):\r\n s+=a[i]\r\nif b==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import sys\r\nimport math\r\nimport bisect\r\nfrom sys import stdin,stdout\r\nfrom math import gcd,floor,sqrt,log\r\nfrom collections import defaultdict as dd\r\nfrom bisect import bisect_left as bl,bisect_right as br\r\n\r\nsys.setrecursionlimit(100000000)\r\n\r\nii =lambda: int(input())\r\nsi =lambda: input()\r\njn =lambda x,l: x.join(map(str,l))\r\nsl =lambda: list(map(str,input().strip()))\r\nmi =lambda: map(int,input().split())\r\nmif =lambda: map(float,input().split())\r\nlii =lambda: list(map(int,input().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\nstdstr =lambda: stdin.readline()\r\nstdint =lambda: int(stdin.readline())\r\nstdpr =lambda x: stdout.write(str(x))\r\n\r\nmod=1000000007\r\n\r\n\r\n#main code\r\ns=si()\r\nsa=si()\r\n\r\nif sa==s[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\nx=''\r\nfor i in range(len(t)-1,-1,-1):\r\n x+=t[i]\r\nif s==x:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n", "def main():\n\ts = input()\n\tt = input()\n\tt_p = ''.join([s[- i - 1] for i in range(len(s))])\n\tif t == t_p:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nif __name__ == \"__main__\":\n\tmain()", "n = list(input())\r\nr_n = input()\r\nr = list(reversed(n))\r\nresult=\"\"\r\nfor i in r:\r\n result+=i\r\nif result==r_n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Jun 22 16:56:03 2018\r\n\r\n@author: KOTS2Z\r\n\"\"\"\r\n\r\ns = input()\r\nt = input()\r\nif s == t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "ber=input()\r\nber=list(ber)\r\nbir=input()\r\nbir=list(bir)\r\nn=len(ber)\r\ntransber=[]\r\nfor i in range(n):\r\n transber.append(ber[n-1-i])\r\nif transber==bir:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "word=input()\r\nreversedWord=input()\r\nprint(\"YES\") if(word[::-1]==reversedWord) else print(\"NO\")", "n=input()\r\ng=input()\r\nif g==n[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nx=input()\r\nm=s[::-1]\r\nif x==m:\r\n print('YES')\r\nelse:\r\n print('NO')", "x=input()\r\ny=input()\r\nif(x[::-1]==y):print(\"YES\")\r\nelse: print(\"NO\")", "s = input()\r\nt = input()\r\n\r\nbool = True\r\nfor i in range(len(s)):\r\n if s[i] != t[-1-i]:\r\n bool = False\r\n break\r\n\r\nif bool == True:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "string = input()\r\nstring2 = input()\r\n\r\nreverse = string[: : -1]\r\nif(string2==reverse):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "kelime=list(input())\r\nword=list(input())\r\nkelime.reverse()\r\nif kelime==word:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nrev = input()\r\nx = s[::-1]\r\n\r\nif (x==rev):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon May 21 19:54:16 2022\r\n\r\n ,-. _,---._ __ / \\\r\n / ) .-' `./ / \\\r\n( ( ,' `/ /|\r\n \\ `-\" \\'\\ / |\r\n `. , \\ \\ / |\r\n /`. ,'-`----Y |\r\n ( ; | '\r\n | ,-. ,-' | /\r\n | | ( | @bibble | /\r\n ) | \\ `.___________|/\r\n `--' `--'\r\n\r\n\"\"\"\r\n\r\n# =============================================================================\r\n# The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if he translated the word correctly.\r\n# \r\n# Input:\r\n# The first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.\r\n# \r\n# Output:\r\n# If the word t is a word s, written reversely, print YES, otherwise print NO.\r\n# =============================================================================\r\n\r\ns = list(input())\r\nt = list(input())\r\ns.reverse()\r\n\r\nif t==s:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s= input()\r\nt = input()\r\nT= []\r\nnew = \"\"\r\nfor i in range (len(s)-1,-1, -1):\r\n T.append(s[i])\r\nfor m in T:\r\n new = new + m\r\nif t == new:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=str(input())\r\nb=str(input())\r\na=list(a)\r\nb=list(b)\r\na.reverse()\r\nif a == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import math\r\n\r\ndef reverse(string):\r\n string = \"\".join(reversed(string))\r\n return string\r\n\r\n\r\nword1 = input(\"\")\r\nword2 = input(\"\")\r\n\r\nif word1 == reverse(word2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "print('YES') if input()[::-1] == input() else print('NO')\r\n", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[75]:\n\n\nmasukan1 = input()\nmasukan2 = input()\nbalik = masukan1[::-1]\nif masukan2 == balik:\n print ('YES')\nelse:\n print ('NO')\n\n\n# In[ ]:\n\n\n\n\n", "t=input()\r\ns=input()\r\nk=\"\"\r\nk+=t[::-1]\r\n#print(k)\r\nif(s==k):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\nt=input()\nx=''\nz=len(n)\nfor i in range(z):\n x=x+n[z-i-1]\nif x==t:\n print('YES')\n \nelse:\n print('NO')\n \t \t\t \t\t\t\t \t\t\t \t\t \t\t \t \t \t\t", "w=str(input())\r\nb=str(input())\r\nprint('YES'if w[::-1]==b else 'NO')\r\n", "s1=input()\r\ns2=input()\r\nflag=True\r\nfor i in range(len(s1)):\r\n if s1[i]!=s2[len(s2)-1-i]:\r\n flag=False\r\n break\r\nif flag:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n \r\n", "s = input()\r\nt = input()\r\nisSame = True\r\nfor i in range(len(s)):\r\n if s[i] != t[len(t) - 1 - i]:\r\n isSame = False\r\n break\r\nif isSame:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def SameChar(s, t):\r\n l = len(s)\r\n s2 = \"\"\r\n for i in s : \r\n if i in t:\r\n s2 = i+ s2\r\n else:\r\n return False\r\n return t == s2\r\n \r\ndef IS_Same(s, t):\r\n if len(s) == len(t):\r\n if SameChar(s, t):\r\n print(\"YES\")\r\n else :\r\n print(\"NO\")\r\n else :\r\n print(\"NO\")\r\n \r\ns = input()\r\nt = input()\r\n\r\nIS_Same(s, t)", "for i in range(1):\r\n n=input()\r\n c=input()\r\n x=n[::-1]\r\n if c==x:\r\n y='YES'\r\n if c!=x:\r\n y='NO'\r\nprint(y)", "s = input()\r\nt = list(reversed(input()))\r\nt = ''.join(t)\r\nif s==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "str1 = input()\nstr2 = input()\nstr1 = str1.lower()\nstr2 = str2.lower()\ntext = str2[::-1]\nif text == str1:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t \t \t \t\t \t\t \t \t \t\t", "l = input()\r\nm = input()\r\nz = l[::-1]\r\nif z == m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n=input()\r\nl=input()\r\nif n==l[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nf=0\r\nif(len(s)==len(t)):\r\n n=len(s)\r\nelse:\r\n print(\"NO\")\r\n exit(0)\r\nfor i in range(n):\r\n if(s[i]!=t[n-i-1]):\r\n f=1 \r\nif(f):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "s=str(input())\r\nt=str(input())\r\ns=reversed(s)\r\nm=\"\".join(s)\r\nif m==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "print('NO' if input()!= input()[::-1] else 'YES')", "# your code goes here\r\nstr1=input()\r\nstr2=input()\r\n\r\n# Python code to reverse a string \r\n# using reversed() \r\n \r\n# Function to reverse a string \r\ndef reverse(string): \r\n string = \"\".join(reversed(string)) \r\n return string \r\nresstr2=reverse(str2)\r\nif(str1==resstr2):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\nt=input()\nif s[-1: :-1]==t:\n\tprint('YES')\nelse:\n\tprint('NO')\n\t", "berland = input()\r\nbirland = input()\r\nprint((lambda: 'YES' if berland == birland[::-1] else 'NO')())", "def is_translation(word1: str, word2: str) -> bool:\n return word1 == word2[::-1]\n\n\nif __name__ == \"__main__\":\n w1 = input()\n w2 = input()\n if (is_translation(w1, w2)):\n print(\"YES\")\n else:\n print(\"NO\")\n", "s=str(input())\r\nt=str(input())\r\nm=s[::-1]\r\nif m==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\ns_2 = input()\r\n\r\nprint('YES' if s == s_2[::-1] else 'NO')", "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\ndef inp():\r\n\treturn(int(input()))\r\ndef inlt():\r\n\treturn(list(map(int,input().split())))\r\ndef insr():\r\n\ts = input()\r\n\treturn(list(s[:len(s)]))\r\ndef invr():\r\n\treturn(map(int,input().split()))\r\n\r\nimport math\r\nfrom collections import deque\r\ns1 = insr()\r\ns2 = insr()\r\ns2.reverse()\r\nif s1==s2:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "def func():\n s,u = input(),input()\n t = s[::-1]\n print('YES'if u == t else 'NO')\n\ndef init(flag=True):\n for _ in range(int(input()) if flag else 1):\n func()\n\nif __name__ == '__main__':\n init(False)", "t=input()\nr=input()\nf=t[::-1]\nif (f==r):\n print('YES')\nelse:\n print('NO') \n \n\t\t \t \t \t\t \t\t \t \t \t", "#https://codeforces.com/problemset/problem/41/A\r\n\r\na=input()\r\nb=input()\r\nb=list(b)\r\nb.reverse()\r\n\r\nif a==''.join(b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\nr=input()\nif (r[::-1]==s):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t\t \t\t\t\t \t \t\t\t \t\t \t \t \t \t", "# import sys\r\n# sys.stdout = open('C:/Study/codes/output.txt', 'w')\r\n# sys.stdin = open('C:/Study/codes/input.txt', 'r')\r\n\r\na = input()\r\nb = input()\r\n\r\nnewa =a[::-1]\r\n\r\nif newa == b:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\nt=input()\nprint(\"YES\") if s[::-1]==t else print(\"NO\")", "#перевод\nt=list(input())\ns=list(reversed(list(input())))\nif t==s:\n print('YES')\nelse:\n print('NO')", "s = list(input())\r\nt = list(input())\r\nn = len(s)\r\nN = len(t)\r\nv = 0\r\nif n != N:\r\n print('NO')\r\nelse:\r\n for i in range(n):\r\n if s[i] != t[-i-1]:\r\n v += 1\r\n if v == 0:\r\n print('YES')\r\n else:\r\n print('NO')", "s=input()\r\nt=input()\r\nz=s[::-1]\r\nif t==z:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\nx=input()\r\nl1=[]\r\nl2=[]\r\nfor i in n:\r\n l1.append(i)\r\nfor k in x:\r\n l2.append(k)\r\nif l1==l2[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input(\"\")\r\nn = input(\"\")\r\nstxt = s[::-1]\r\n\r\nif stxt == n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def int_arr():\r\n return map(int, input().split())\r\n\r\ndef intp():\r\n return int(input())\r\n\r\n\r\ndef solve():\r\n s = input()\r\n t = input()\r\n\r\n if s == t[::-1]:\r\n print(\"YES\")\r\n return\r\n\r\n print(\"NO\")\r\n\r\n\r\nsolve()", "n = input()\r\nz= input()\r\nif z==n[::-1]:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")", "a='@'.join(input()).split('@')\r\na.reverse()\r\nprint('YES') if ''.join(a)==input() else print('NO')", "l1 = list(input())\r\nl2 = list(input())\r\nl2.reverse()\r\nif l1 == l2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n", "s1=input()\r\ns2=input()\r\n\r\n# print(s1==s2[::-1])\r\n\r\nfine=True\r\ntry:\r\n \r\n for i in range(len(s1)):\r\n if s1[i]==s2[-1-i]:\r\n pass\r\n else:\r\n fine=False\r\nexcept:\r\n fine=False \r\nif fine:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def solve():\r\n s = input()\r\n t = input()\r\n rev = s[::-1]\r\n if rev == t:\r\n return \"YES\"\r\n return \"NO\"\r\n\r\n\r\nprint(solve())", "a=input()\r\nb=input()\r\nif b!=a[::-1]:print(\"NO\")\r\nelse:print(\"YES\")", "n1=input()\r\nn2=input()\r\nx=len(n1)\r\nj=x-1\r\ncount=0\r\nfor i in range(0,len(n1)):\r\n if(n2[i]==n1[j]):\r\n count+=1\r\n else:\r\n break\r\n j=j-1\r\nif(count==x):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t = input()\r\nx = input()\r\nf = t[::-1]\r\nif f == x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t=input()\r\ns=input()\r\nc=0\r\nz=-1\r\nfor a in range(len(t)):\r\n if t[a]==s[z] :\r\n c+=1\r\n z-=1\r\n else:\r\n c+=0\r\n\r\n\r\nprint([\"NO\",\"YES\"][c==len(t)])", "s1=input()\r\ns2=input()\r\ni=len(s1)-1\r\nj=0\r\nwhile i >=0 :\r\n if s1[i] != s2[j] :\r\n print('NO')\r\n break\r\n i=i-1\r\n j=j+1\r\nelse :\r\n print('YES')\r\n\r\n ", "s1 = input()\r\ns2 = input()\r\nif len(s1) == len(s2):\r\n n = len(s1)\r\n flag = 0\r\n for i in range(n):\r\n if s1[i] != s2[n-1-i]:\r\n flag = 1\r\n break\r\n \r\n print(\"NO\" if flag else \"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nif(s == t[::-1]):print('YES')\r\nelse:print('NO')", "str=input()\r\nstr1=input()\r\nif str[::-1]==str1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\nstart_s = 0\r\nend_t = len(t) - 1\r\n\r\nwhile start_s < len(s) and end_t >= 0:\r\n if s[start_s] != t[end_t]:\r\n print(\"NO\")\r\n exit()\r\n start_s += 1\r\n end_t -= 1\r\n\r\nprint(\"YES\")\r\n", "x = input()\r\ny = input()\r\ndef reverse(s) :\r\n\tst = \"\"\r\n\tfor i in s :\r\n\t\tst = i + st\r\n\treturn st\r\nrx = reverse(x)\r\nif y == rx :\r\n\tprint(\"YES\")\r\nelse :\r\n\tprint(\"NO\")", "t=input()\r\ns=input()\r\nnt=''\r\nfor i in range(1,len(t)+1):\r\n nt+=t[-i]\r\nif nt==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "x=input()\r\na=[i for i in x]\r\ny=input()\r\nb=[i for i in y]\r\nc=0\r\nb.reverse()\r\nif len(a)!=len(b):\r\n print(\"NO\")\r\nelse:\r\n for i in range(0,len(a)):\r\n if b[i]==a[i]:\r\n c=c+1\r\n if c==len(a):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "s = list(input())\r\nt = list(input())\r\n\r\nt_rev = t.copy()\r\nt_rev.reverse()\r\n\r\n#print(s)\r\n#print(t_rev)\r\n\r\nif str(s) == str(t_rev):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\r\n\r\n", "s = input()\nt = input()\n\ndef reverse(string):\n string = string[::-1]\n return string\n \nif reverse(s) == t:\n print(\"YES\")\nelse:\n print(\"NO\")\n\nquit()\n\t\t \t\t \t \t\t \t \t \t\t\t \t \t", "s = input()\r\ns1 = input()\r\nlst = []\r\nlst.append(s1)\r\nif s == s1[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word_one = input()\nword_two = input()\n\nif word_one == word_two[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "import sys\r\ns = sys.stdin.readline()[:-1]\r\nt = sys.stdin.readline()[:-1]\r\nif s == t[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "n=list(input())\r\na=input()\r\nc=\"\"\r\nfor i in range(len(n)-1,-1,-1) :\r\n c=c+n[i]\r\nif c==a :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n", "print('YES' if input().rstrip() == input().rstrip()[::-1] else 'NO')\r\n", "from sys import stdin, stdout\r\n\r\ns = stdin.readline()[:-1]\r\nt = stdin.readline()[:-1]\r\nif s[::-1] == t:\r\n stdout.write('YES')\r\nelse:\r\n stdout.write('NO')\r\n", "word1 = input()\r\nword2 = input()\r\ncorrect = True\r\n\r\nif word1[::-1] != word2:\r\n correct = False\r\nif correct == False:\r\n print('NO')\r\nif correct == True:\r\n print('YES')", "t = input()\r\ns = input()\r\n\r\na = t[::-1]\r\n\r\nif s==a:\r\n print(\"YES\")\r\n \r\nelse:\r\n print(\"NO\")", "a=input()\nc=input()\nb=a[::-1]\nif(c==b):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t \t \t\t \t \t \t \t \t \t\t \t", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Jun 15 13:11:03 2018\r\n\r\n@author: HP\r\n\"\"\"\r\n\r\na=str(input())\r\nb=str(input())\r\n\r\n\r\nif(a==b[::-1]):\r\n print('YES')\r\nelse:\r\n print('NO')", "n=input()\r\nm=input()\r\nsum=\"\"\r\nfor i in range(-1,-len(n),-1):\r\n sum+=n[i]\r\nsum+=n[-len(n)]\r\nif(sum==m):\r\n print(\"YES\")\r\nelif(sum!=m):\r\n print(\"NO\")\r\n ", "str = list(input())\r\n\r\nrevers = list(input())\r\n\r\nstr.reverse()\r\n\r\nif str == revers:\r\n print('YES')\r\nelse :\r\n print('NO')", "\"\"\" 41A - Translation \"\"\"\r\ntry:\r\n s = input()\r\n r = input()\r\n\r\n ans = 'YES' if s[::-1] == r else 'NO'\r\n print('{}'.format(ans))\r\nexcept EOFError as e:\r\n pass", "s=input()\r\nt=input()\r\nr=s[len(s)-1::-1]\r\nif(t==r):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n1=input()\r\nn1=n1[::-1]\r\nn2=input()\r\nif n2==n1:\r\n print('YES')\r\nelse:\r\n print('NO')", "def translate(string1,string2):\r\n if string1==string2[::-1]:\r\n return 'YES'\r\n else:\r\n return 'NO'\r\nstring1=input()\r\nstring2=input()\r\nprint(translate(string1, string2))", "n=input()\r\nm=input()\r\nx=m[::-1]\r\nif n==x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1=input()\r\nstr2=input()\r\n\r\nif(\"\".join(reversed(str1))==str2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "theOriginalWord = input(\"\").lower()\r\ntheTranslatedWord = input(\"\").lower()\r\n\r\nif len(theOriginalWord) >= 1 and len(theOriginalWord) <= 100 and len(theTranslatedWord) >= 1 and len(theTranslatedWord) <= 100:\r\n if theOriginalWord[::-1] == theTranslatedWord:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "a=str(input())\r\nb=str(input())\r\nx=a[::-1]\r\nif x==b:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "word = input()\r\ntranslation = input()\r\nprint(\"YES\" if word == translation[::-1] else \"NO\")", "x = input()\r\ny = input()\r\nprint(\"YES\" if(x==y[::-1]) else \"NO\")", "s=input()\r\nt=input()\r\nss=[]\r\ntt=[]\r\nfor i in range(len(s)):\r\n ss.append(s[i])\r\nfor i in range(len(t)):\r\n tt.append(t[-i-1])\r\nif ss==tt:\r\n print('YES')\r\nelse:\r\n print('NO')", "s1=input()\ns2=input()\ns3=s1[::-1]\nif(s2==s3):\n print(\"YES\")\nelse:\n print(\"NO\")\n\t\t \t\t \t \t\t \t\t \t\t\t\t\t \t", "text = input()\r\ntheans = input()\r\nmylist = [x for x in text]\r\nreverse = mylist[::-1]\r\nans = ''.join(reverse)\r\nif ans == theans:\r\n print('YES')\r\n \r\nelse:\r\n print('NO')", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sat Jun 8 09:55:30 2019\r\n\r\n@author: avina\r\n\"\"\"\r\n\r\ns = input()\r\ne = input()\r\nif s[::-1] == e:\r\n print('YES')\r\nelse:\r\n print('NO')", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nSpyder Editor\r\n\r\nThis is a temporary script file.\r\n\"\"\"\r\n\r\ns=input('')\r\nt=input('')\r\nif s[:]==t[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "\ndef reverse(inp):\n\tout = ''\n\tfor i in range(len(inp)-1,-1,-1):\n\t\tout += inp[i]\n\treturn out\n\t\t\n\n\ninp1 = input()\ninp2 = input()\nif inp1 == reverse(str(inp2)):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "a=list(input())\nb=input()\na.reverse()\nc=\"\".join(a)\nif b==c:\n print(\"YES\")\nelse:\n print(\"NO\")", "s = input()\r\ns = s[::-1]\r\nt = input()\r\n\r\nprint(\"YES\" if s == t else \"NO\")", "s, s2 = input(), input()\r\nprint( \"YES\" if(s2 == s[::-1]) else \"NO\" )", "s = str(input())\nt = str(input())\na = \"\"\nfor i in reversed(s):\n a += i\nif a == t:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "if __name__=='__main__':\r\n ip=input()\r\n op=input()\r\n if ip[::-1]==op:\r\n print('YES')\r\n else:\r\n print('NO')", "def reverse(s):\r\n str=\"\"\r\n for i in s:\r\n str=i+str\r\n return str\r\n\r\na=input(\"\")\r\nb=input(\"\")\r\nt=reverse(a)\r\nif(t==b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") \r\n", "n = str(input())\r\nx = str(input())\r\nif n[::-1] == x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import sys\r\n#import bisect\r\nimport math\r\nimport itertools\r\n#import array as ab\r\nimport random\r\ndef get_line(): return list(map(int, sys.stdin.readline().strip().split()))\r\ndef in1(): return int(input())\r\n\r\ns1=str(input())\r\ns2=str(input())\r\ns3=''.join(list(s2[::-1]))\r\nif s1==s3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n", "n = str(input())\r\ny=str(input())\r\nx=n[::-1]\r\n\r\nif(y == x):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=str(input(\"\"))\r\na=str(input(\"\"))\r\nk=n[::-1]\r\nif a==k:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def stringReverse(str):\r\n reversedStr = [None] * len(str)\r\n j = 0\r\n for i in reversed(range(len(str))):\r\n reversedStr[j] = str[i]\r\n j+=1\r\n return \"\".join(reversedStr)\r\n\r\ninputStr = list(input())\r\ninputReversedStr = input()\r\nreverseStr = stringReverse(inputStr)\r\nprint(\"YES\" if reverseStr == inputReversedStr else \"NO\")\r\n", "def main():\r\n n = list(input())\r\n m = list(input())\r\n\r\n if n == list(reversed(m)):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nif __name__ == \"__main__\":\r\n main()", "# 41A\r\nt = input()\r\ns = input()\r\n\r\n\r\nt1 = list(reversed(t))\r\nt2 = ''\r\nfor i in t1:\r\n t2 += i\r\n\r\nif s == t2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\ns0=input()\r\ns = list(s)\r\nl = len(s)\r\ni = 0\r\nif l % 2 == 0:\r\n while i < l/2:\r\n s[i], s[-i-1] = s[-i-1], s[i]\r\n i += 1\r\nif l % 2 != 0:\r\n while i < int(l/2):\r\n s[i],s[-i-1]=s[-i-1],s[i]\r\n i+=1\r\na=(''.join(s))\r\nif a==s0:\r\n print('YES')\r\nelse:\r\n print('NO')", "s= input()\r\nt=input()\r\nm= s[::-1]\r\nif t==m:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\r\nt=input()\r\nT=[]\r\nn=len(t)\r\nfor i in range(n):\r\n T.append(t[n-i-1])\r\nt=''.join(T)\r\nif t==s:\r\n print('YES')\r\nelse:\r\n print('NO')", "a = input()\r\nb = input()\r\n\r\n\r\nflag = 0\r\n\r\nfor i in range(len(a)):\r\n if(a[i] == b[-i-1]):\r\n flag=0\r\n else:\r\n flag=1\r\n break\r\n\r\nif(flag==0):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def rev(k:str) -> str:\r\n return k[::-1]\r\na = input()\r\nb = input()\r\nif rev(a) == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# Code_15 Status: Still Working\r\n\r\ns = str(input(''))\r\nt = str(input(''))\r\ns_1 = ''\r\n\r\nfor i in reversed(s):\r\n s_1 += i\r\n\r\nif s_1 == t:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\n\r\ns_r=\"\"\r\n\r\nfor i in s:\r\n s_r=i+s_r\r\n\r\nif(s_r==t):\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")", "import sys\r\nword=sys.stdin.readline().strip()\r\nword1=sys.stdin.readline().strip()\r\nif word==word1[::-1]:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "# with open(\"input.txt\",'r') as f:\r\n# \tt = int(f.readline().rstrip())\r\n# \t# n = int(f.readline().rstrip())\r\n\t# n ,a,b = int(f.readline().rstrip().split())\r\n# \t# arr = list(map(int,f.readline().rstrip().split()))\r\n\r\n\r\ndef main(N,ans):\r\n\tstring = N[::-1]\r\n\tif ans==string:\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")\r\n\treturn \r\n\r\ndef text():\r\n\twith open(\"input.txt\",\"r\") as f:\r\n\t\tt = int(f.readline().rstrip())\r\n\t\twhile t:\r\n\t\t\tN = int(f.readline().rstrip())\r\n\t\t\t# arr = list(map(int,f.readline().rstrip().split()))\r\n\t\t\tmain(N)\r\n\t\t\tt-=1\r\n\r\ndef normal():\r\n\tstring = str(input())\r\n\tans = str(input())\r\n\t# arr = list(map(int,input().split()))\r\n\tmain(string,ans)\r\n\r\n\r\n\r\n\r\n# text()\r\nnormal()\r\n\r\n", "s = input()\r\nt = input()\r\n\r\nif len(s) != len(t): print(\"NO\")\r\nelse:\r\n f = False\r\n i = 0\r\n j = len(t)-1\r\n while i<len(s) and j >=0:\r\n \r\n if s[i] == t[j]:\r\n i += 1\r\n j -= 1\r\n f = True\r\n else:\r\n print(\"NO\")\r\n f = False\r\n break\r\n if f == True: print(\"YES\")\r\n", "s = input()\r\nt = input()\r\nrev = ''\r\nn = len(s)\r\nfor i in range(n):\r\n rev = rev + s[n-i-1]\r\nif(rev == t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\ns=list(s)\r\nt=list(t)\r\nx=[]\r\nx=s.reverse()\r\nx=tuple(s)\r\nx=\"\".join(x)\r\nt=tuple(t)\r\nt=\"\".join(t)\r\nif(x==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s0 = input()\r\ns1 = input()\r\nn = len(s0);x=0\r\nif n==len(s1):\r\n for i in range(n):\r\n if s0[i]==s1[n-1-i]:\r\n x+=1\r\n if x==n:\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')", "s=input()\nt=input()\nu=s[::-1]\nif t==u:\n print('YES')\nelse:\n print('NO')\n\t \t \t \t\t \t \t\t \t \t", "def is_translation_correct(s, t):\n reversed_s = s[::-1] # Reverse the spelling of word s\n \n if reversed_s == t:\n return \"YES\" \n else:\n return \"NO\" \n\ns = input()\nt = input()\n\nresult = is_translation_correct(s, t)\nprint(result)\n\n\t \t\t \t \t \t \t \t\t\t\t\t \t \t\t \t", "word = input()\r\nword2 = input()\r\nx = word[::-1]\r\nif x == word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input() \r\nt = input()\r\nflag = 1\r\nif len(s) == len(t):\r\n n = len(s)\r\n for i in range(n):\r\n if s[i] == t[n - i - 1]:\r\n continue\r\n else:\r\n print(\"NO\")\r\n flag = 0\r\n break\r\n if flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nk=input()\r\nd=''\r\nl=len(s)\r\nwhile(l>0):\r\n d=d+s[l-1]\r\n l-=1\r\nif(k==d):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "s = input()\r\nt = input()\r\ns1 = s[::-1]\r\nif (t == s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str = input()\r\ntxt = str [::-1]\r\nstr1 = input()\r\n\r\nif txt==str1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nc=input() \r\nx=c[::-1]\r\nif x == s: print('YES')\r\nelse:print('NO')", "word = input()\nif input()==word[-1::-1]: print(\"YES\")\nelse: print(\"NO\")\n\n \t\t \t\t\t\t \t\t\t \t\t \t \t\t \t \t", "a=str(input())\r\nb=str(input())\r\nlst=(list(a))\r\nlst1=[]\r\nfor i in lst:\r\n lst1.insert(0,i)\r\ns=\"\".join(lst1)\r\nif b==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n=input().lower()\r\nm=input().lower()\r\nn=n[::-1]\r\nif n==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=str(input())\r\ns1=str(input())\r\nif s==s1[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "n = input()\r\nn1 = input()\r\n\r\n\r\nif n1 == n[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = str(input())\r\nt = str(input())\r\n\r\nt = \"\".join(reversed(t))\r\nx = 0\r\nfor i in range(len(s)):\r\n if (s[i] != t[i]):\r\n print (\"NO\")\r\n break\r\n x+=1\r\nif x == len(s):\r\n print (\"YES\")", "berland=input()\r\nbirland=input()\r\nberland=list(berland)\r\nbirland=list(birland)\r\nbirland.reverse()\r\nif berland==birland:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\nb = input()\nc = a[::-1]\nif b == c:\n print('YES')\nelse:\n print('NO')", "\"\"\"\nThe translation from the Berland language into the Birland language is not an easy task. \nThose languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little:\n it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc.\n However, it's easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. \n Help him: find out if he translated the word correctly.\n\nInput\nThe first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. \nThe input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.\n\nOutput\nIf the word t is a word s, written reversely, print YES, otherwise print NO.\n\"\"\"\n\nword = input()\nif word[::-1] == input():\n print('YES')\nelse:\n print('NO')", "firstInput = input()\r\nsecondInput = input()\r\nreversedInput = firstInput[::-1]\r\nif reversedInput == secondInput:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n = input()\r\nprint('YES' if input() == n[::-1] else 'NO')", "def translation(n,n2):\r\n for i in range(len(n)):\r\n t=n[::-1]\r\n if t==n2:\r\n return \"YES\"\r\n return \"NO\"\r\nn=input()\r\nn2=input()\r\np=translation(n,n2)\r\nprint(p)", "s = input()\r\nsr= input()\r\nsrr=[sr[k] for k in range(0,len(sr))]\r\nfor i in range(0,int(len(sr)/2)):\r\n srr[i] = sr[len(sr)-i-1]\r\n srr[len(sr) - i - 1] = sr[i]\r\nsr = ''.join(srr)\r\nif sr==s : print('YES')\r\nelse: print(\"NO\")", "s = [input() for i in range(2)]\r\nprint('YES' if s[0] == s[1][::-1] else 'NO')", "s = input()\r\nt = input()\r\np = \"\"\r\np = t[::-1]\r\nif(s==p):\r\n print(\"YES\")\r\nelse: \r\n print(\"NO\")", "# your code goes here\r\na=str(input())\r\nb=str(input())\r\nla=len(a)\r\nbl=len(b)\r\nans=\"YES\"\r\nif(la==bl):\r\n\tfor i in range(la):\r\n\t\tif(a[i]!=b[bl-1-i]):\r\n\t\t\tans=\"NO\"\r\nelse:\r\n\tans=\"NO\"\r\nprint(ans)", "s=input() \r\nt=input() \r\nk=\"\"\r\nfor i in range(len(s)-1,-1,-1):\r\n k+=s[i] \r\nif k==t:\r\n print(\"YES\") \r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nm=s[::-1]\r\na=input()\r\nif m==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nfor i in range(len(s)):\r\n if(s[i] == t[-i-1]):\r\n c=1\r\n else:\r\n c=0\r\n break\r\nif(c==1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\ns1=input()\r\nk=list(s1)\r\nk.reverse()\r\nk=\"\".join(k)\r\nif(s==k):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\nnewS = \"\"\r\n\r\nfor i in range(len(s)):\r\n newS += s[(-i)-1]\r\n\r\nif newS == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import sys\n\nn = list(input())\n\nn_2 = list(input())\n\nn = list(reversed(n))\n\nif n==n_2:\n \n print(\"YES\")\n \nelse:\n \n print(\"NO\")\n", "def answer(a,b):\n length1=len(a)\n length2=len(b)\n if(length1!=length2):\n return('NO')\n length2=length2-1\n for i in range(length1):\n if(a[i]!=b[(length2-i)]):\n return('NO')\n return('YES')\n \n \na=input()\nb=input()\n\nprint(answer(a,b))\n\n\t\t \t\t \t \t\t\t\t\t \t\t \t \t\t\t \t\t\t", "w = str(input())\r\ns = str(input())\r\nw_inverse= w[::-1]\r\nif s == w_inverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\nn=len(a)\r\nc=0\r\npos=len(b)-1\r\nfor i in range(0,n):\r\n if(a[i]==b[pos]):\r\n c=c+1\r\n pos=pos-1\r\nif(c==len(a)):\r\n print('YES')\r\nelse:\r\n print('NO')", "a = input()\r\nb = input()\r\nprint(\"YES\" if ''.join(reversed(a)) == b else \"NO\")", "s= input()\r\nt= input()\r\ndef rev(s):\r\n return s[::-1]\r\nre=rev(s)\r\n\r\nif(s !=' ' and t !=' '):\r\n if re== t:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\ns2 = input()\r\nans= True\r\nif len(s)==len(s2):\r\n for i in range(len(s)):\r\n if not s[i]==s2[len(s)-i-1]:\r\n ans=False\r\n break\r\n if ans:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")", "s = input() #berland\r\nt = input() #birland\r\nfor letter in t:\r\n x = t[::-1]\r\nif x == s:\r\n print('YES')\r\nelse:\r\n print('NO')", "ber=input() # Berlandish word\r\nbir=input() # Birlandish word\r\n\r\nfor i in range(len(ber)):\r\n if ber[i]==bir[-(i+1)]:\r\n c=i\r\n else:\r\n print('NO')\r\n break\r\n if c==len(ber)-1:\r\n print('YES')\r\n \r\n \r\n \r\n \r\n", "k=input()\r\nl=input()\r\no=l[::-1]\r\nif k==o:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def is_translation_correct(s, t):\r\n if s == t[::-1]:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n\r\n# Read input\r\ns = input()\r\nt = input()\r\n\r\n# Call the function to check if the translation is correct\r\nresult = is_translation_correct(s, t)\r\n\r\n# Print the result\r\nprint(result)\r\n", "s = input()\r\nt = input()\r\n\r\nu = \"\"\r\n\r\nfor i in range(-1, -1*(len(s)+1), -1):\r\n u += s[i]\r\n\r\nif u == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def is_reverse(string1, string2):\n if string1[::-1] == string2:\n return \"YES\"\n return \"NO\"\n\nprint(is_reverse(input(), input()))", "#TRANSLATION\r\n\r\nstr = input()\r\nstr1 = input()\r\nstr2 = str[::-1]\r\n\r\nif str2 == str1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "k=input().strip()\r\nz=input()[::-1].strip()\r\nif k==z:\r\n print ('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nq=len(t)\r\np=len(s)\r\nx=0\r\nif q is p :\r\n for i in range(0,len(s)):\r\n if s[i]==t[len(s)-i-1]:\r\n x=x+1\r\n if x>len(s)-1:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print('NO')", "a = [x for x in input()]\nb = [x for x in input()]\na.reverse()\n\nif a == b:\n print(\"YES\")\nelse:\n print(\"NO\")", "l = input()\nn = input()\nif \"\".join(reversed(l)) == n:\n print(\"YES\")\nelse:\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nSpyder Editor\r\n\r\nThis is a temporary script file.\r\n\"\"\"\r\n\r\na = list(input())\r\nb = list(input())\r\nb.reverse()\r\nif a == b:\r\n print('YES')\r\nelse:\r\n print('NO')", "t = input()\r\ns = input()\r\nnum=0\r\nfor i,j in zip(range(len(t)), range(1,len(s)+1)): \r\n if t[i]==s[-j]: num+=1\r\n\r\nif num == len(t): print(\"YES\")\r\nelse : print (\"NO\")", "n=input()\r\nk=input()\r\nprint(\"YES\") if k[::-1]==n else print('NO')\r\n", "first_string=input()\r\nsecond_string=input()\r\ntemp_string=list(first_string)\r\ntemp_string.reverse()\r\nfinal_string=''.join(temp_string)\r\nif final_string==second_string:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s1=input()\r\ns2=input()\r\ns3=''\r\nfor i in range(len(s1)):\r\n s3=s3+s1[len(s1)-i-1]\r\nif(s3==s2):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a=input()\r\nb=input()\r\nc=\"\"\r\nfor i in range(len(a),0,-1):\r\n c=c+a[i-1]\r\nif b==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# Input word s and word t\nss = input()\ntt= input()\n\n# Check if the reverse of s is equal to t\nif ss[::-1] == tt:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\t \t\t \t\t\t \t \t\t \t\t\t\t \t\t\t \t\t", "# -*- coding: utf-8 -*-\r\n\r\nimport math\r\nimport collections\r\nimport bisect\r\nimport heapq\r\nimport time\r\nimport random\r\nimport itertools\r\nimport sys\r\n\r\n\"\"\"\r\ncreated by shhuan at 2017/11/21 23:35\r\n\r\n\"\"\"\r\n\r\ns = input()\r\nt = input()\r\n\r\nif s == t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "ber = input()\nbur = input()\n\n\nif ber[::-1] == bur:\n print('YES')\nelse:\n print('NO')", "word = list(input())\r\nword2 = list(input())\r\nreverseWord = list(reversed(word))\r\nif word2 == reverseWord:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "import sys\r\n\r\nfirst_word = list(input())\r\nsecond_word = list(input())[::-1]\r\ncount = 0\r\nif len(first_word) != len(second_word):\r\n print(\"NO\")\r\n sys.exit()\r\nfor i in range(len(first_word)):\r\n if first_word[i] != second_word[i]:\r\n count += 1\r\nif count == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "inp = str(input())\r\nrev = str(input())\r\nreverse = inp[::-1]\r\n\r\nif len(inp) > 100 or len(rev) > 100:\r\n exit(0)\r\nelse:\r\n if rev == reverse:\r\n print('YES')\r\n else:\r\n print('NO')\r\n", "palabra=input()\ninverso=input()\nlista=[]\nfor x in palabra:\n lista.append(x)\nreversa=\"\"\nfor x in reversed(lista):\n reversa+=x\nif reversa==inverso:\n print(\"YES\")\nelif reversa!=inverso:\n print(\"NO\")\n\n \t\t \t \t \t\t\t\t\t\t\t\t\t \t \t\t\t \t \t", "def is_reverse_word(s, t):\r\n return s[::-1] == t\r\n\r\n# Input\r\nword_s = input().strip()\r\nword_t = input().strip()\r\n\r\n# Check if t is the reverse of s\r\nif is_reverse_word(word_s, word_t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "t1 = input()\r\nt2 = input()\r\nt2 = t2[::-1]\r\nif t1 == t2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = input()\ns2 = input()\nif s1 == s2[-1::-1]:print(\"YES\")\nelse:print(\"NO\")\n \t\t\t\t\t\t\t\t\t\t \t \t \t\t\t \t \t\t\t\t", "s1 = input()\r\ns2 = input()\r\ny = 0\r\nfor i in range(len(s1)):\r\n if s1[i]!=s2[-i-1]:\r\n y = 1 \r\n break\r\nif y==1:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "a=input()\r\nb=input()\r\ns=a[::-1]\r\nif s==b:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "n=input()\r\n\r\nn1=input()\r\ns=n1[::-1]\r\nif(s==n):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n", "#initializes inputs, aswell as the translation list and new word string\r\nberland = input()\r\nbirland = input()\r\ntranslation = []\r\nnewWord = ''\r\n\r\n#swaps the order of characters of the berland word\r\nfor letter in berland:\r\n translation.insert(0, letter)\r\ntranslatedWord = newWord.join(translation)\r\n\r\n#checks if the translation was correct\r\nif translatedWord == birland:\r\n print('YES')\r\nelse:\r\n print('NO')", "t1=input()\nt3=input()\nt2=t1[::-1]\nif t2 == t3:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sun Oct 11 20:37:09 2020\r\n\r\n@author: My Family\r\n\"\"\"\r\n\r\n\r\n\r\nx=input()\r\ny=input()\r\n\r\nx1=[]\r\ny1=[]\r\ny2=[]\r\n\r\nfor i in x:\r\n x1.append(ord(i))\r\n \r\nfor j in y:\r\n y1.append(ord(j))\r\n \r\n\r\nfor a in y1[::-1]:\r\n y2.append(a)\r\n\r\n\r\n\r\n\r\nif (x1==y2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#int = integer\r\n#str = string\r\n#float = double\r\n#d = input()\r\n#print(d)\r\n\r\n#int()\r\n#e=int(input())\r\n#e=str(e)\r\n#print(e)\r\n# + - * /\r\n#chr\r\n#ord\r\n#a=int(input())\r\n#b=int(input())\r\n#print(len(l))\r\n#print(l[len(l)])\r\n#print(l)\r\nimport math\r\n\r\n#for x in range(1,10):\r\n# print(x)\r\n#min()\r\n#max()\r\n#sum()\r\n#input row: s=list(map(int,input().split()))\r\n\r\n\r\na=list(input())\r\na.reverse()\r\nb=list(input())\r\nif a==b:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = str(input())\r\nr = str(input())\r\nr1 = r[len(r)::-1]\r\nif r1 in s:\r\n print('YES')\r\nelse:\r\n print('NO')", "a = input()\r\nb = input()\r\nprint(\"YES\" if b == a[::-1] else \"NO\")\r\n", "a=list(input())\r\na.reverse()\r\nb=\"\"\r\nfor i in range(len(a)):b+=a[i]\r\nif b==input():print(\"YES\")\r\nelse:print(\"NO\")\r\n", "a = input();b = input()\r\nc = list(reversed(list(a)))==list(b)\r\nd = ['NO','YES']\r\nprint(d[c])", "def is_reverse_translation(s, t):\n return s == t[::-1]\n\ns = input().strip()\nt = input().strip()\n\nresult = \"YES\" if is_reverse_translation(s, t) else \"NO\"\nprint(result)\n\n \t \t \t \t\t \t\t \t\t\t\t \t\t\t", "s=input()\r\ns2=input()\r\nl=[s[::-1]]\r\nch=\"\".join(l)\r\nif s2==ch:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n", "s1=list(input())\r\ns2=list(input())\r\ns2.reverse()\r\nif(s1==s2):\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\n\r\ns_reversed = \"\"\r\n\r\nfor i in range(len(s)):\r\n s_reversed += s[len(s)-1 - i]\r\n\r\nif t == s_reversed:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def reverse(a):\r\n n = len(a)\r\n k=\"\"\r\n for i in range(0,n):\r\n k = k+ a[n-i-1]\r\n return k\r\n \r\n\r\n\r\na = input()\r\nb = input()\r\nif(a == reverse(b)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word1 = input()\r\nword2 = input()\r\n\r\nw1len = len(word1)\r\nw2len = len(word2)\r\n\r\n\r\n\r\nif w1len != w2len:\r\n print('NO')\r\n\r\nelse:\r\n\r\n\r\n if (w1len % 2) == 0: # ES\r\n index = w1len - 1\r\n cant = w1len\r\n i = 0\r\n while cant != 0:\r\n a = word1[i]\r\n b = word2[index]\r\n\r\n\r\n\r\n if a == b:\r\n i += 1\r\n index -= 1\r\n cant -= 1\r\n\r\n else:\r\n print('NO')\r\n break\r\n if cant == 0:\r\n print('YES')\r\n\r\n else:\r\n index = w1len - 1\r\n cant = w1len\r\n i = 0\r\n while cant != 0:\r\n a = word1[i]\r\n b = word2[index]\r\n\r\n\r\n\r\n if a == b:\r\n i += 1\r\n index -= 1\r\n cant -= 1\r\n\r\n else:\r\n print('NO')\r\n break\r\n if cant == 0:\r\n print('YES')\r\n\r\n", "st1 = input()\r\nst2 = input()\r\n\r\nif st1 == st2[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "strg = input()\r\nstrg2= input()\r\nif strg2 == strg[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = str(input())\r\nr = str(input())\r\nt = []\r\nfor i in range(len(s)-1,-1,-1):\r\n t.append(s[i])\r\ns1 = ''.join(map(str,t))\r\nif s1 == r:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n", "a, b = input(), input()\r\nrev = a[::-1]\r\nif b == rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "x = input()\r\ny = input()\r\nnew=x[::-1]\r\nif new==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\nt=input()\nnn=n[::-1]\nif nn==t:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t \t\t\t\t\t\t\t \t\t\t\t \t\t \t", "n = input()\r\nt = input()\r\nprint(\"YES\" if t==n[::-1] else \"NO\")\r\n\r\n", "s=input()\r\nt=input()\r\nn=len(s)\r\nk=0\r\nif n==len(t):\r\n for i in range (0,n):\r\n if s[i]==t[n-i-1]:\r\n k=k+1\r\nif k==len(s):\r\n print (\"YES\")\r\nelse: print(\"NO\")", "t=input()\r\ns=input()\r\ns1=list(t)\r\ni=len(s1)-1\r\nk=''\r\nwhile i > -1 :\r\n k+=s1[i]\r\n i-=1\r\nif k == s :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t = input()\r\ns=input()\r\nprint( \"YES\" if(s == t[::-1]) else \"NO\" )", "def reverse(s):\r\n str = \"\"\r\n for i in s:\r\n str = i + str\r\n return str\r\nc=str(input())\r\nx=str(input())\r\ni=0\r\na=0\r\ng=reverse(x)\r\nfor i in range(len(c)):\r\n \r\n \r\n if(c[i]==g[i]):\r\n a+=1\r\n continue\r\n \r\n else:\r\n print(\"NO\")\r\n break\r\n \r\n i+=1\r\n\r\nif(a==len(c)):\r\n print(\"YES\")", "ber = input()\r\nbir = input()\r\n\r\ntranslation = (ber[::-1])\r\n\r\nif translation == bir:\r\n print(\"YES\")\r\nelse:\r\n print (\"NO\")\r\n", "text1=input()\ntext2=input()\nl=text2[::-1]\n\nif l==text1:\n print('YES')\n\nelse:\n print('NO')\n\n", "s1 = input()\r\ns2 = input()\r\nr_s1 = s1[::-1]\r\nif r_s1==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = str(input())\ns2 = str(input())\n\nif s2 == s1[::-1]: print(\"YES\")\nelse: print(\"NO\")", "\r\n\r\nword=input()\r\nr_word=input()\r\n\r\nlength=len(word) \r\nreverse_word=word[length::-1]\r\n\r\nif r_word == reverse_word:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "mot=input()\r\ninverse = input()\r\n\r\ncp = len(inverse)-1\r\ncorrige =\"\"\r\nwhile (cp >= 0):\r\n corrige = corrige + inverse[cp]\r\n cp -= 1\r\n \r\nif corrige == mot :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "txt=input()\r\ntxt1=input()\r\ntxt2=txt[::-1]\r\nif txt1 == txt2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "p = input()\r\nq = input()\r\nif len(p) == len(q):\r\n i = 0\r\n j = len(p) - 1\r\n f = 1\r\n while i < len(p) and j >= 0:\r\n if p[i] != q[j]:\r\n f = 0\r\n print(\"NO\")\r\n break\r\n i += 1\r\n j -= 1\r\n if f == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "# read the input strings\r\ns = input()\r\nt = input()\r\n\r\n# reverse s using string slicing\r\ns_reversed = s[::-1]\r\n\r\n# check if s_reversed is equal to t\r\nif s_reversed == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\ncounter = 1\r\nn = 0\r\na = ''\r\nfor i in s :\r\n\tcounter += 1 \r\n\tn += 1\r\nfor i in s :\r\n\tcharacter = s[n-counter]\r\n\tcounter += 1\r\n\ta += character\r\nif a == t :\r\n\tprint('YES')\r\nelse : \r\n\tprint('NO')\r\n", "x = input()\r\ny = input()\r\na = []\r\n\r\nfor i in range(len(x)):\r\n a = x[:: -1]\r\nif a == y:\r\n print('YES')\r\nelse:\r\n print('NO')", "s= input()\nt = input()\nans = 'YES'\nif len(s)!=len(t):\n print('NO')\n exit()\nfor i in range(len(s)):\n if s[i] != t[len(s)-i-1] :\n ans = 'NO'\nprint(ans)", "s=input()\r\nt=input()\r\nk=0\r\nm=0\r\nif len(s)==len(t):\r\n for i in range(1,(len(s)+1)):\r\n if s[-i]!=t[k]:\r\n m=m+1\r\n else:\r\n k=k+1\r\nelse:\r\n print(\"NO\")\r\n exit()\r\nif m==0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\n\r\nrev_s = \"\"\r\ns = list(s)\r\n\r\nfor i in reversed(range(len(s))):\r\n rev_s += s[i]\r\n \r\nprint(\"YES\") if rev_s == t else print(\"NO\")", "x=input()\r\ny=list(input())\r\ny.reverse()\r\n\r\nif (x==(\"\".join(y))):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\r\nrev = s[::-1]\r\ns1 = input()\r\nif (s1 == rev): print(\"YES\")\r\nelse: print(\"NO\")", "w = input()\r\nr = input()\r\ny = 'YES'\r\nfor i in range(len(w)) :\r\n if r[i] != w[len(w) - i-1] :\r\n y = 'NO'\r\n break\r\nprint(y) ", "def rev_word(string, string2):\r\n if string[::-1] == string2:\r\n return print(\"YES\")\r\n else:\r\n return print(\"NO\")\r\n\r\n\r\ns = input()\r\ns2 = input()\r\n\r\nrev_word(s, s2)", "s = input()\r\nt = input()\r\nr = \"\"\r\n\r\nfor i in s:\r\n r = i + r\r\n\r\nif r == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "def f(s, t):\r\n '''\r\n >>> f('code', 'edoc')\r\n 'YES'\r\n >>> f('abb', 'aba')\r\n 'NO'\r\n >>> f('code', 'code')\r\n 'NO'\r\n '''\r\n if t == s[::-1]:\r\n return 'YES'\r\n else:\r\n return 'NO'\r\n \r\n \r\nprint(f(input(), input()))", "z = input().lower()\r\ns = input().lower()\r\nif z[::-1] == s:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "def main():\r\n s=input()\r\n s1=input()\r\n o=''\r\n for i in range(len(s)-1,-1,-1):\r\n o+=s[i]\r\n if o==s1:\r\n print('YES')\r\n else:\r\n print('NO')\r\nmain()\r\n", "#Translation\r\ns = input()\r\ns1 = input()\r\nnew = s[::-1]\r\nif new == s1:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \r\n ", "s = str(input())\r\ns1 = str(input())\r\n\r\naux = s1[::-1]\r\n\r\nif s == aux:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \r\n \r\n\t\r\n", "s = input()\r\ns2 = input()\r\nrs = list(reversed(s2))\r\nf = \"\"\r\nf = f.join(rs)\r\nif(s == f):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = input()\r\ntocheck = input()\r\n\r\nif word == tocheck[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "import sys\ndef get_ints():return map(int,sys.stdin.readline().strip().split())\ndef single_ints():return int(sys.stdin.readline())\ndef p(a):return sys.stdout.write(a)\ns=sys.stdin.readline().strip()\nt=sys.stdin.readline().strip()\nrev=s[::-1]\n# print(rev)\nif t==rev:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\t\t \t\t \t\t \t \t \t \t\t\t\t\t \t \t\t", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Wed Sep 6 19:11:06 2023\r\n\r\n@author: mac\r\n\"\"\"\r\n\r\ns, t = input(), input()\r\nif s == t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nr=input()\r\nprint('YES' if s==r[::-1] else 'NO')\r\n", "i = input()\r\nk = input()\r\nj = i[::-1]\r\nif k == j :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# your code goes here\r\ns=input()\r\nt=input()\r\nc=\"\"\r\nfor i in range(1,len(s)+1):\r\n\tc+=s[-i]\r\nif t==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "magic=input()\r\nmushroom=input()\r\nwizard=\"\"\r\nfor i in range(len(magic)-1, -1, -1):\r\n wizard+=magic[i]\r\nif mushroom==wizard:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\ng=input()\r\nt=s[-1:-len(s)-1:-1]\r\nif(t==g):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "s = input()\r\nt = input()\r\ns = list(s)\r\ns.reverse()\r\nj = True\r\nfor i in range(len(s)):\r\n if s[i] != t[i]:\r\n j = False\r\n break\r\nif j:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nt=list(t)\r\nt=t[-1::-1];\r\nt=\"\".join(t)\r\nif(t==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def translation(s, t):\n j = len(t) - 1\n for i in range(len(s)):\n if t[j] != s[i]: return False\n\n j -= 1\n\n return True\n\ndef main():\n s = input()\n t = input()\n if translation(s, t):\n print('YES')\n else:\n print('NO')\n\n\nmain()\n\n", "a=input()\r\nb=input()\r\nd=[]\r\nfor i in b:\r\n d.append(i)\r\nc=[]\r\nfor i in range(len(a)-1,-1,-1):\r\n c.append(a[i])\r\nif c==d:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "n=input()\r\nm=input()\r\np=n[::-1]\r\nif p==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\nm=input()\r\nl1=list(n)\r\nl1.reverse()\r\nl2=list(m)\r\nf=0\r\nif(len(l2)>len(l1)):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(l1)):\r\n if(l1[i]!=l2[i]):\r\n f=1\r\n break\r\n if(f==0):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n \r\n", "i = input()\r\ni2 = input()\r\nif i == i2[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "user = input()\r\nuser_1 = input()\r\nnew_s = \"\"\r\nfor i in range(len(user_1)-1,-1,-1):\r\n new_s+=user_1[i]\r\nif user==new_s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "frst = input()\r\nsec = input()\r\nif frst[::-1] == sec:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s, t = input(), input()\r\ntemp = \"\"\r\nfor i in range(len(t)):\r\n temp += t[len(t) - 1 - i]\r\nif s == temp:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "x = input()\r\ny = input()\r\nz = []\r\nfor i in range(0, len(x)):\r\n z.append(x[(len(x)-i)-1])\r\nif (\"\".join(z)) == y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t=input()\r\ns=input()\r\nx=t[::-1]\r\nif x==s:\r\n print('YES')\r\nelse:\r\n print('NO')", "str1=input()\r\nstr2=input()\r\nlst1=list(str1)\r\nlst1.reverse()\r\nstr3=\"\".join(lst1)\r\nif str2==str3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "s1 = str(input())\r\ns2 = str(input())\r\np = ''.join(reversed(s1))\r\nif p == s2:\r\n print('YES')\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nif len(s)<=100: \r\n if s==t[::-1]:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "inp1=input()\r\ninp2=input()\r\nst=inp2[-1::-1]\r\nif inp1==st:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import sys\r\nx = input()\r\ny = input()\r\nif len(x) != len(y):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(x)):\r\n if x[i] != y[-(i+1)]:\r\n print(\"NO\")\r\n sys.exit(0)\r\n print(\"YES\")", "def translation(word1, word2):\r\n if word1[::-1] != word2:\r\n return 'NO'\r\n else:\r\n return 'YES'\r\na = input()\r\nb = input()\r\nprint(translation(a, b))", "n = list(input())\r\ne = list(input())\r\nn.reverse()\r\n#print(n)\r\nif n == e:\r\n print(\"YES\")\r\nelse:\r\n print('NO')\r\n\r\n", "a = input()\r\nb = input()\r\nc = list(b)\r\nd = []\r\nfor i in range(len(c)):\r\n d.append(c[len(c)-i-1])\r\nif list(a) == d:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "def reversed4(variable):\r\n res=''.join(reversed(variable))\r\n return res\r\na = input()\r\nb = input()\r\nif a == reversed4(b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n\r\n ", "s=input()\r\nt=input()\r\ns=list(s)\r\ns.reverse()\r\nlength=len(s)\r\nstring=\"\"\r\nfor i in range(length):\r\n string+=s[i]\r\nif string==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\nj = len(b) - 1\r\ni = 0\r\nif len(a) != len(b):\r\n print(\"NO\")\r\n exit()\r\nwhile i < len(a):\r\n if a[i] != b[j]:\r\n print(\"NO\")\r\n exit()\r\n i = i + 1\r\n j = j - 1\r\nprint(\"YES\")\r\n", "inp1 = str(input())\r\ninp2 = str(input())\r\n\r\nif (inp1[::-1] == inp2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n# new pull request test 4\r\n", "word = input()\r\nans = input()\r\nstrin = word[::-1]\r\nif strin == ans:\r\n print(\"YES\")\r\n\r\nelif strin != ans:\r\n print(\"NO\")\r\n\r\nelse:\r\n pass", "ori = input()\r\ntrans = input()\r\nl1 = []\r\nfor char in ori:\r\n l1.append(char)\r\nl1.reverse()\r\noriori = ''.join(l1)\r\nif (oriori == trans):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1 = list(input())\r\nstr1.reverse()\r\ny = ''.join(str1)\r\nif y == input():\r\n print('YES')\r\nelse:\r\n print('NO')", "l1 = input()\nl2 = input()\nk = l2[::-1]\nif l1 ==k:\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", "n = input()\r\nm = input()\r\nn = n[::-1]\r\nprint(\"YES\" if m == n else \"NO\")", "x=input()\r\ny=input()\r\nl2=len(y)\r\nl=len(x)\r\nr=0\r\nif(l!=l2):\r\n\tr=1\r\nif r==0:\r\n\tfor i in range(0,l):\r\n\t\tif x[i]!=y[l-1-i]:\r\n\t\t\tr=1\r\n\t\t\tbreak\r\nif r==1:\r\n\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")\r\n", "first = list(input())\r\nsec = list(input())\r\nfirst.reverse()\r\nif first == sec:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "\r\nt=input()\r\ne=input()\r\nt=list(t)\r\ne=list(e)\r\nr=[]\r\nfor i in range(len(t)-1,-1,-1):\r\n\tr.append(t[i])\r\nif r==e:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "s=input()\r\ns1=input()\r\nl=list(s)\r\na=list(s1)\r\nb=[]\r\nfor i in range(len(l)-1,-1,-1):\r\n b.append(l[i])\r\nif(b==a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "print('YES' if list(reversed(input()))==list(input()) else 'NO')", "s=input()\r\nt=input()\r\nlist_s=[]\r\n\r\nfor i in s:\r\n list_s.append(i)\r\nreversed_s=list(reversed(list_s))\r\nreversed_s=\"\".join(reversed_s)\r\n\r\nif t==reversed_s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "inputStringA = input()\r\ninputStringB = input()\r\n\r\nreverseA = inputStringA[::-1]\r\n\r\nif inputStringB == reverseA:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\r\nt = input()\r\nn_st = \"\"\r\nif len(s) == len(t):\r\n for i in range(len(t) - 1, -1, -1):\r\n n_st = n_st + t[i]\r\n if s == n_st:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nb=input()\r\nc=[]\r\nd=\"\"\r\nfor i in a:\r\n c.append(i)\r\nc.reverse()\r\nfor i in c:\r\n d+=str(i)\r\nif(d==b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "a=input()\r\nb=input()\r\ntr=a[::-1]\r\nif tr==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t1 = input()\r\nt2 = input()\r\n\r\ndef reverseString(word):\r\n return word[::-1]\r\n\r\nif t2 == reverseString(t1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n1=(input())\r\nn2=input()\r\nn=\"\"\r\nn1=list(n1)\r\nfor i in range(len(n1)):\r\n\tn=n+n1[len(n1)-i-1]\r\nif n==n2:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "s=str(input())\r\nl=str(input())\r\nk=s[::-1]\r\nif l==k:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "stringas=input()\nstringbs=input()\nif(stringas[::-1]==stringbs):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t\t \t\t \t \t \t\t\t\t\t \t\t", "t = input()\r\ns = input()\r\nt1=\"\"\r\nfor i in t:\r\n #print(i)\r\n t1=i+t1\r\n#print(t1)\r\nif t1 == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "n=list(input())\r\nn.reverse() \r\nm=list(input())\r\n\r\nif n==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nprint({True: \"YES\", False: \"NO\"} [s == t[::-1]])\r\n", "inp1 = input()\r\ninp2 = input()\r\ninp2 = inp2[-1::-1]\r\nif inp1==inp2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "berland = input()\r\nbirland = input()\r\ntranslation = birland[::-1]\r\nif translation == berland:\r\n print('YES')\r\nelse:\r\n print('NO')", "S_One = input()\r\nS_Two = input()\r\nS_One_reversed = S_One[::-1]\r\nif S_Two == S_One_reversed:\r\n print('YES')\r\nelse:\r\n print('NO')", "codes=[]\nfor i in range(2):\n codes.append(input())\nif codes[1]==codes[0][::-1]:\n print(\"YES\")\nelse:\n print(\"NO\") \n\t\t \t\t \t \t \t\t \t \t\t \t\t", "a = input()\nb = \"\".join(list(reversed(input())))\nif a == b:\n print(\"YES\")\nelse:\n print(\"NO\")", "s=input()\r\na=input()\r\nt=s[::-1]\r\nif a==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\nu = \"\"\r\nfor i in s:\r\n\tu = i + u\r\nif t == u:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\r\nt=input()\r\nprint(\"YES\" if s==t[::-1] else \"NO\")\r\n ", "t=input()\r\ns=input()\r\ndef rev(t):\r\n str=\"\"\r\n for i in t:\r\n str=i+str\r\n return str\r\nif(s==rev(t)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "n = input()\r\nn2 = input()\r\nif n2 == n[::-1] :\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nc=input()\r\nd=c[::-1]\r\nif s==d:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s = list(input())\r\nrev = ''.join(reversed(s))\r\nss = input()\r\nif ss == rev:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\r\nt = input()\r\nprint(['NO','YES'][s[::-1] == t])", "n=list(input())\r\nk=list(input())\r\nk.reverse()\r\nif(k==n):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "from builtins import print, input\r\nif __name__ == '__main__':\r\n x = input()\r\n y = input()\r\n temp = len(x) - 1\r\n sum = 0\r\n if (len(x) == len(y)):\r\n for i in range(len(x)):\r\n if x[i] == y[temp]:\r\n sum +=1\r\n temp -= 1\r\n else:\r\n break\r\n if sum == len(x):\r\n print('YES')\r\n else:\r\n print('NO')", "a=input()\r\nb=input()\r\nstr=\"\".join(reversed(a))\r\nif(b==str):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def reverse(s): \r\n str = \"\" \r\n for i in s: \r\n str = i + str\r\n return str\r\n \r\nt= input (\"\")\r\nr= input (\"\")\r\n\r\nresul= reverse(t)\r\nif (resul==r):\r\n\tprint (\"YES\")\r\nelse:\r\n\tprint (\"NO\")", "a=input()\r\nb=input()\r\ntemp=''\r\nif len(a)==len(b):\r\n for i in range(len(a)-1,-1,-1):\r\n temp=temp+b[i]\r\n if temp==a:\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')", "main_word = input()\r\nuser_rev_word = input()\r\n\r\nlst = []\r\nlst[:0] = main_word\r\nlst.reverse()\r\n\r\nrev_word = \"\"\r\nrev_word = rev_word.join(lst)\r\n\r\nif rev_word == user_rev_word:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb= input()\r\nx= a[::-1]\r\nif x == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "m=input;print(\"YNEOS\"[m()!=m()[::-1]::2])", "s1=input()\r\ns2=input()\r\nif s1[::-1]==s2: print(\"YES\")\r\nelse: print(\"NO\")", "s=input()\r\nt=input()\r\ns12=\"\"\r\ni=len(s)-1\r\nwhile i>=0:\r\n s12+=s[i]\r\n i=i-1\r\nif t==s12:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\n\nif len(s) != len(t):\n print('NO')\n exit()\n\nfor j in range(len(s)):\n if s[j] != t[len(s) - 1 - j]:\n print('NO')\n exit()\nprint('YES')", "str = input()\r\nstr1 = input()\r\n\r\nstr_rev = str[::-1]\r\n\r\nif str1 == str_rev :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nk=len(s)\r\nnewstr=\"\"\r\nfor i in range(1,k+1):\r\n newstr=newstr+s[i*(-1)]\r\nif newstr==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s, t = input(), input()\r\ns_list = list(s)\r\ns_list.reverse()\r\ns_str = \"\".join(s_list)\r\nif (s_str == t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "string1 = list(input())\r\nstring2 = list(input())\r\nx = len(string1)\r\ny = len(string2)\r\ntotal_length = x\r\nstring3 = [None] * x\r\ntotal = 0\r\nif x == y:\r\n for i in range(x):\r\n string3[i] = string1[x-1]\r\n x -= 1\r\n string1 = string3\r\n for j in range(y):\r\n if string1[j] == string2[j]:\r\n total += 1\r\nif total == total_length:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# https://codeforces.com/problemset/problem/41/A\n\ndef solve(s, t):\n j = len(t)-1\n for i, e in enumerate(s):\n if e != t[j-i]:\n return 'NO'\n return 'YES'\n\n\ns = input()\nt = input()\nprint(solve(s, t))\n", "def solve():\r\n # Take both strings:\r\n string1 = input()\r\n string2 = input()\r\n\r\n # Reverse second string:\r\n string2 = string2[::-1]\r\n\r\n # If both strings are same, print yes else print no:\r\n print(\"YES\" if string1 == string2 else \"NO\")\r\n\r\nif __name__ == '__main__':\r\n solve()\r\n", "from sys import stdin, stdout\n\ns = stdin.readline().rstrip()\nt = stdin.readline().rstrip()\n\nif s == t[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "#last reverse == first\nprint(\"YNEOS\"[(input()[::-1]!=input())::2])\n\t \t \t\t\t\t\t\t \t \t \t \t \t \t\t", "S1= input()\r\nS2= input()\r\nif S1 == S2[::-1] :\r\n print (\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input()\r\nl=list(x)\r\ny=input()\r\nn=len(x)\r\nl1=[]\r\nfor i in range(n):\r\n l1.append(l[n-i-1])\r\na=''\r\nfor i in l1:\r\n a+=i\r\nif a==y:\r\n print('YES')\r\nelse:print('NO')", "a1, a2 = input(), input()\r\nif a1[::-1] == a2:\r\n print('YES')\r\nelse:\r\n print('NO')", "a = input()\r\nb = input()\r\nprint('YNEOS'[a[::-1]!=b::2])\r\n", "s = str(input())\r\nt = str(input())\r\nst = \"\"\r\nfor i in s:\r\n st = i+st\r\nif st == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "\n\n\ndef solve(e, i):\n\n\tif e == i[::-1]:\n\t\treturn 'YES'\n\telse:\n\t\treturn 'NO'\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n\te= input()\n\ti = input()\n\t\n\tprint(solve(e, i))\n", "s=input()\r\nr_s=input()\r\na=s[::-1]\r\nif a==r_s:\r\n print('YES')\r\nelse:\r\n print('NO')", "s1 = input()\r\ns2 = list(input())\r\ns2.reverse()\r\ns2 = ''.join(s2)\r\nif s2 == s1:\r\n print(\"YES\")\r\nelse:\r\n print('NO')", "s = input()\r\ns1 = input()\r\nflag = 0\r\nfor i in range(len(s1)):\r\n if s[len(s)-1-i] != s1[i]:\r\n print('NO')\r\n flag += 1\r\n break\r\n\r\nif flag == 0:\r\n print('YES')", "st = input()\r\nst1 = input()\r\nst1 = st1[::-1]\r\nif st == st1:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "\r\ns=input()\r\nt=input()\r\nlst=[]\r\nlstx=[]\r\nlsty=[]\r\nfor i in s:\r\n lst.append(i)\r\nfor i in range(len(lst)-1,-1,-1):\r\n lstx.append(lst[i])\r\nw=\"\".join(lstx)\r\nif w==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "def chk(s, t, l):\n for i in range(l):\n # print(s[i], t[l - i - 1])\n if s[i] != t[l - i - 1]:\n return 0\n return 1\n\nif __name__ == \"__main__\":\n s = input()\n t = input()\n # print(s)\n # print(t)\n l_s = len(s)\n l_t = len(t)\n\n if l_s != l_t:\n print(\"NO\")\n elif chk(s, t, l_s) == 1:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\t\t \t\t \t\t\t \t \t \t\t \t \t\t \t", "n=input()\r\nn=list(n)\r\ns=input()\r\ns=list(s)\r\nn.reverse()\r\nif s==n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "a = input()\r\nb = input()\r\nif a == b[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n\"\"\"\r\nprint(a.isalnum(), 'isalnum\\n',\r\n a.isalpha(), 'isalpha\\n',\r\n a.isdecimal(), 'isdecimal\\n',\r\n a.isdigit(), 'isdigit\\n',\r\n a.isidentifier(), 'isidentifier\\n',\r\n a.islower(), 'islower\\n',\r\n a.isnumeric(), 'isnumeric\\n',\r\n a.isprintable(), 'isprintable\\n',\r\n a.isspace(), 'isspace\\n',\r\n a.istitle(), 'istitle\\n',\r\n a.isupper(), 'isupper\\n') \r\n\"\"\"\r\n\r\n", "a=input()\r\ncounterlist=[]\r\nb=[]\r\nd=input()\r\nfor i in range(len(a)):\r\n counterlist.append(i)\r\ncounterlist.sort(reverse=True)\r\nfor i in range(len(counterlist)):\r\n b.append(a[int(counterlist[i])])\r\nc=b[0]\r\nfor i in range(1,len(b)):\r\n c=c+b[i]\r\nif c == d:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nk = input()\r\nr = s[::-1]\r\nif k == r:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def reverse(inp):\r\n res,i = '',len(inp)-1\r\n while i >= 0:\r\n res+=inp[i]\r\n i -= 1\r\n return res\r\ns,t = input(),input()\r\nif s == reverse(t):\r\n print('YES')\r\nelse:\r\n print('NO')", "s1=input()\r\ns2=input()\r\nflag=False\r\ni=0\r\nj=len(s2)-1\r\nwhile i!=len(s1):\r\n if s1[i]!=s2[j]:\r\n print('NO')\r\n flag=True\r\n break\r\n i+=1\r\n j-=1\r\nif flag==False:\r\n print('YES')", "x = input()\nr = input()\n\nif r == x[len(x)::-1]:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "s = input()\r\nt = input()\r\nslist = list(s.strip())\r\ntlist = list(t.strip())\r\nslist.reverse()\r\nif slist == tlist:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n\t", "a = input()\r\nb = input()\r\nlsa = [char for char in a]\r\nlsb = lsa[::-1]\r\nc = \"\".join(lsb)\r\nif b == c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input()\r\ny=input()\r\na=y[::-1]\r\nif x==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# coding=utf-8\r\nn=input()\r\nm=input()\r\nn1=n[::-1]\r\nif n1==m:\r\n print('YES')\r\nelse: print('NO')\r\n \t\t \t \t\t \t \t\t\t\t \t\t\t \t", "word1 = input()\r\nword2 = input()\r\nif(\"\".join(reversed(word1)) == word2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "useri = input()\r\nuserii = input()\r\nnewi = useri[::-1]\r\nif userii == newi:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\nbs = input()\nif s[::-1] == bs:print(\"YES\")\nelse:print(\"NO\")", "def main():\n str1=input()\n str2=input()\n if(str1==str2[::-1]):\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nif __name__=='__main__':\n main()\n", "s1=input()\r\ns2=input()\r\nfor i in range(len(s1)):\r\n if(s1[i]!=s2[-1-i]):\r\n print(\"NO\")\r\n break\r\nelse:\r\n print(\"YES\")", "a = input()\r\nc = ''\r\nfor i in range(-1, len(a)*-1-1, -1):\r\n c+=a[i]\r\nb = input()\r\nif c==b:\r\n print('YES')\r\nelse:\r\n print('NO')", "x=input()\r\ny=input()\r\nc=x[::-1]\r\nif c==y:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")", "l=input()\r\nm=input()\r\nl=l[::-1]\r\nif(l==m):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\nx = True\nif len(s) != len(t):\n print(\"NO\")\n quit()\nfor i in range(len(s)):\n if s[i] != t[-i-1]:\n x = False\nif x: print(\"YES\")\nelse: print(\"NO\")", "x = input()\r\ny = input()\r\nx = list(x)\r\ny = list(y)\r\nx.reverse()\r\nif x == y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def do():\r\n s = str(input())\r\n t = str(input())\r\n\r\n if t[::-1] == s:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\n\r\ndef main():\r\n do()\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "s = input()\r\nt = input()\r\n\r\nif t==s[::-1]: print(\"YES\")\r\nelse: print(\"NO\")", "original = input()\nreverse = input()\nprint('YES' if ''.join(reversed(original)) == reverse else 'NO')\n\t \t \t\t \t\t \t \t \t \t \t\t \t\t \t\t", "def rever(l):\r\n lis=[]\r\n for i in range(len(l)):\r\n lis.append(l[(len(l)-i)-1])\r\n return lis\r\n\r\n\r\nx=input()\r\ny=input()\r\nl1=[]\r\nl2=[]\r\nfor i in x:\r\n l1.append(i)\r\nfor j in y:\r\n l2.append(j)\r\nif(rever(l1)==l2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s1=input()\r\ns2=input()\r\np=[]\r\nq=[]\r\nc=0\r\nif len(s1)==1 and len(s2)==1:\r\n if s1==s2:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n \r\nelif (len(s1)>1 and len(s2)>1) or (len(s1)>1 and len(s2)==1) or (len(s1==1) and len(2)>1):\r\n for i in range (len(s1)):\r\n p.append(s1[i])\r\n for j in range (len(s2)):\r\n q.append(s2[j])\r\n q.reverse()\r\n if p==q:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "s1 = str(input())\r\ns2 = str(input())\r\ns3 = s2[::-1]\r\nflag = 0\r\nfor i in range(len(s1)):\r\n if(s1[i] != s3[i]):\r\n flag = 1\r\n break\r\nif(flag == 1 or len(s1)!=len(s2)):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n", "s = input().lower()\r\nt = input().lower()\r\nlength_t = len(t)\r\nnew_t = ''\r\nfor i in range(0, length_t):\r\n new_t += t[length_t - i-1]\r\n\r\nif s == new_t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\na=''\r\nfor i in range ((len(s)-1),-1,-1):\r\n a = a + s[i]\r\nif a == t :\r\n print ('YES')\r\nelse:\r\n print ('NO')", "s = input()\ns1 = input()\ns2 = ''\nfor i in reversed(s1) :\n\ts2 += i\nif s == s2 :\n\tprint('YES')\nelse :\n\tprint('NO')", "# input \nR = lambda: map(int,input().split())\n\ns = input()\nt = input()\nif t[::-1] == s:\n print('YES')\nelse:\n print('NO')\n", "s = input()\r\nr = input()\r\na = []\r\nfor _ in range(len(r)): a.append(r[_])\r\na.reverse()\r\nprint(\"YES\") if s==\"\".join(a) else print(\"NO\")", "word1 = list(input())\r\nword2 = list(input())\r\n\r\ndef CheckTransl():\r\n for i in range(1,len(word1)+1,1):\r\n if word1[i-1] != word2[-i]:\r\n return \"NO\"\r\n return \"YES\"\r\n\r\nprint(CheckTransl());\r\n\r\n ", "a=input()\r\nb=input()\r\nl=len(a)\r\nL=len(b)\r\nif l!=L:\r\n print(\"NO\")\r\nelse:\r\n for i in range(l):\r\n if a[i]==b[l-1-i]:\r\n flag=1\r\n else:\r\n flag=0\r\n break\r\n if flag==1:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "s = input()\nt = input()\n\nbirlan = []\n\nfor i in s:\n birlan.insert(0, i)\n\nif list(t) == birlan:\n print('YES')\nelse:\n print('NO')\n", "bar = input()\nbir = input()\nprint(\"YES\" if bir==bar[::-1] else \"NO\")\n", "s = input()\nt = input()\nlist=[]\nfor i in range(len(s)-1, -1, -1):\n list.append(s[i])\nrev = ''.join(list)\nif rev == t:\n print('YES')\nelse:\n print('NO')\n\t\t \t \t \t\t\t \t \t\t \t \t\t\t\t\t\t\t \t\t", "berl = input()\nbirl = input()\nlreb = ''\nfor i in range(1,len(berl)+1):\n lreb += berl[-i]\n\nif lreb==birl:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "\"\"\"\r\nt=int(input())\r\nc=0\r\nfor i in range(t):\r\n l=[int(x) for x in input().split()]\r\n if(l.count(1)>1):\r\n c+=1\r\nprint(c)\r\n \r\n\r\nn,k=map(int,input().split())\r\nl=[int(x) for x in input().split()]\r\nc=0\r\nfor i in l:\r\n if(i>=l[k-1] and i!=0 and i>0):\r\n c+=1\r\nprint(c)\r\n \r\nstring = input()\r\nvowels=('a', 'e', 'i', 'o', 'u','y')\r\nstring=string.lower()\r\nfor x in string:\r\n if x in vowels:\r\n string = string.replace(x, \"\")\r\nprint('.',end='')\r\nprint('.'.join(string)) \r\n \r\n\"\"\"\r\ns=input()\r\nt=input()\r\nif(s==t[::-1]):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\nt = input()\ntranslate = s[::-1]\nif translate == t:\n print('YES')\nelse:\n print('NO')", "s = input()\r\nt = input()\r\n\r\nflag = True\r\nfor i in range(len(s)):\r\n if s[i] != t[len(t) - (i+1)]:\r\n flag = False\r\n break\r\n\r\nif flag:\r\n print('YES')\r\n\r\nelse:\r\n print('NO')", "A=list(input())\r\nB=list(input())\r\nif A==B[::-1]:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "# Problem: A. Translation\r\n# Contest: Codeforces - Codeforces Beta Round #40 (Div. 2)\r\n# URL: https://codeforces.com/problemset/problem/41/A\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\n\"\"\" Python 3 compatibility tools. \"\"\"\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\n\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\n\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\n\r\ndef invr():\r\n return(map(int,input().split()))\r\n \r\nline1 = input().strip()\r\nline2 = input().strip()\r\nprint(\"YES\" if line1[:] == line2[::-1] else \"NO\")", "def determine(s: str, t: str) -> str:\r\n return s == t[::-1]\r\ndef output(s: str, t: str) -> str:\r\n if determine(s, t):\r\n return \"YES\"\r\n return \"NO\"\r\n#inputs = list(map(int, input().strip().split()))\r\n#n = inputs[0]\r\n#t = inputs[1]\r\ns1 = str(input())\r\nt = str(input())\r\nprint(output(s1, t))\r\n\r\n\r\n", "str1=input()\r\nstr2=input()\r\nrevstr1=str1[::-1]\r\nif str2==revstr1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = list(input())\r\nt = list(input())\r\nt = t[::-1]\r\nif s == t:\r\n print('YES')\r\n exit()\r\nprint('NO')", "p=list(map(str,input()))\r\nq=list(map(str,input()))\r\ng=[]\r\nfor i in range(len(p)-1,-1,-1):\r\n\tg.append(p[i])\r\nif g==q:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "n=\"\"\r\nn=input()\r\na=\"\"\r\na=input()\r\narr=[]\r\narr2=[]\r\n\r\nfor i in range(len(n)):\r\n arr.append(n[i])\r\n \r\nfor i in range(len(a)):\r\n arr2.append(a[i])\r\narr.reverse()\r\nif(arr2==arr):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "berland= input().lower()\r\nbirland= input().lower()\r\nber= berland[::-1]\r\nif ber==birland:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1=input()\r\nstr2=input()\r\nl=[]\r\nl[:0]=str2\r\nl=reversed(l)\r\nstr3=\"\".join(l)\r\nif str1==str3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def eq_reverse(s, t):\r\n return t == s[::-1]\r\ns, t = input(), input()\r\nif eq_reverse(s, t):\r\n print('YES')\r\nelse:\r\n print('NO')", "ber = input()\r\nbir = input()\r\n\r\nif len(ber) != len(bir):\r\n print(\"NO\")\r\n quit()\r\n\r\nx = len(ber) - 1\r\n\r\nfor y in range(len(ber)):\r\n if ber[y] != bir[x]:\r\n print(\"NO\")\r\n quit()\r\n else:\r\n x = x - 1\r\n\r\nprint(\"YES\")\r\n", "#input number of stones on the table\ns = input()\nt = input()\ncount_s = int(len(s))\ncount_t = int(len(t))\n\n\n#condition\nwhile s != s.lower() or s != s.strip() or s == '' or count_s > 100 or t != t.lower() or t != t.strip() or t == '' or count_t > 100:\n if t != t.lower() or t != t.strip() or t != '' or count_t > 100:\n s = input()\n count_s = int(len(s))\n if t != t.lower() or t != t.strip() or t != '' or count_t > 100:\n t = input()\n count_t = int(len(t))\n\n# reverse string\nreverse_s = s[::-1]\n\n# comparing string\nif reverse_s == t:\n print('YES')\nelse:\n print('NO')\n\t\t\t\t \t\t \t\t \t\t\t\t\t \t \t\t\t\t \t", "word=input()\r\nrev=input()\r\nrev=rev[::-1]\r\nif word==rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "first, second = list(input()), list(input())\r\nif first == second[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a = input()\nb = input()\n\n\nif b == \"\".join(reversed(a)):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "input_str1=input()\r\ninput_str2=input()\r\nbhargavi_str2=input_str2[::-1]\r\nARE_STRINGS_EQUAL=input_str1==bhargavi_str2\r\nif ARE_STRINGS_EQUAL:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t, s = input(), input()\r\nif len(t) != len(s):\r\n print('NO')\r\nelse:\r\n for i in range(len(t)):\r\n if t[i] != s[-i-1]:\r\n print('NO')\r\n l = 1\r\n break\r\n else:\r\n l = 0\r\n if l == 0:\r\n print('YES')", "str1 = input()\r\nstr2 = input()\r\n\r\nif str1[-1] + str1[-2::-1] == str2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n", "s=list(input())\r\nt=list(input())\r\nn=0\r\nif len(s)==len(t):\r\n for i in range(len(s)):\r\n if s[i] == t[-i - 1]:\r\n n += 1\r\n if n == len(s):\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')", "word1 = input()\r\nword2 = input()\r\n\r\ncorrect = word1[::-1]\r\n\r\nif correct == word2:\r\n print('YES')\r\nelse:\r\n print('NO')", "#Link Problem : https://codeforces.com/problemset/problem/41/A\n\nwords_berland = input()\nwords_birland = input()\n\nif words_berland[::-1] == words_birland:\n print('YES')\nelse: \n print('NO')\n\n", "s = input()\r\nt = input()\r\nflag = True\r\nfor i in range(len(s)):\r\n if t[i] != s[len(s)-1-i]:\r\n flag = False\r\n break\r\nif flag:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = input()\r\nn2 = input()\r\n\r\nif n[::-1] == n2:\r\n print('YES')\r\nelse:\r\n print('NO')", "i1 = input()\r\ni2 = input()\r\nif i1[::-1] == i2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "q = input()\r\nrq = input()\r\n\r\nif (q == rq[::-1]): print(\"YES\")\r\nelse: print(\"NO\")", "t = input()\r\ns = input()\r\nflag = 0\r\nl = len(s)\r\nfor i in range (l):\r\n if t[i] != s[l-(i+1)]:\r\n print(\"NO\")\r\n flag = 1\r\n break\r\nif flag == 0:\r\n print(\"YES\")", "a=input()\r\nb=input()\r\ns=a[::-1]\r\nif b==s:\r\n print('YES')\r\nelse:\r\n print('NO')", "S1 = str(input())\r\nS2 = str(input())\r\nif (S1 == S2[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "stro = input()\r\nst = ''\r\npere = input()\r\ncount = len(stro)\r\nfor i in range(count):\r\n a = stro[count - i -1]\r\n st += a \r\nif st == pere:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a = input()\r\nb = input()\r\nword = \"\"\r\nfor i in range(len(b)):\r\n word += b[len(b) - i - 1]\r\nif a == word:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=input()\r\ns2=input()\r\nr_str=\"\"\r\n\r\ni=len(s1)-1\r\nwhile i >= 0:\r\n r_str+=s1[i]\r\n i-=1\r\n\r\n\r\nif r_str == s2 :\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")\r\n\r\n\r\n\r\n\r\n\r\n", "s = input()\r\nt = input()\r\ncorrect = \"YES\"\r\n\r\nif(len(s) == len(t)):\r\n i = 0\r\n while(i < len(s)):\r\n if(s[i] != t[len(t) - i - 1]):\r\n correct = \"NO\"\r\n break\r\n i += 1\r\n\r\nif(len(s) != len(t)):\r\n correct = \"NO\"\r\n\r\nprint(correct)", "a=input()\r\nb=input()\r\nif a==b[len(b):0:-1]+b[0]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "str1 = input()\r\nstr2 = input()\r\nstr3 = str1[::-1]\r\nif(str2 == str3):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "string = input()\r\ns = list(string)\r\nans = input()\r\nn = len(s)\r\nk = ''\r\nfor i in range(n//2):\r\n k = s[i]\r\n s[i] = s[n-i-1]\r\n s[n-i-1] = k\r\nnew_s = ''.join(s)\r\nif(new_s == ans):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "text = input()\ntext2 = input()\nMytext = \"\"\n\nfor a in range(0,len(text) + 1):\n Mytext = Mytext + text[len(text)-a:len(text)-a+1]\n\nif Mytext == text2:\n print(\"YES\")\n\nelse:\n print(\"NO\")\n\nquit()\n \t \t\t\t\t \t \t\t \t \t\t\t\t \t \t", "s = input()\r\nt = input()\r\nword = ''\r\nfor i in range(len(s)-1, -1, -1):\r\n word = (word + s[i])\r\nif word == t:\r\n print('YES')\r\nelse:\r\n print('NO') \r\n", "s=input()\r\nd=input()\r\na=0\r\nif len(s)==len(d):\r\n\tfor i in range(len(s)):\r\n\t\tif s[i]==d[len(s)-i-1]:\r\n\t\t\ta+=1\r\nif a==len(s):\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')\r\n", "a=input()\r\nb=input()\r\na=list(a)\r\nfor i in range(0,len(a)//2):\r\n a[i],a[-1-i]=a[-1-i],a[i]\r\na=''.join(a)\r\nif a==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\na2=input()\r\na1=a[::-1]\r\nif(a2==a1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word1=str(input())\r\nword2=str(input())\r\nif word1!=word2[::-1]:\r\n print('NO')\r\nelse:\r\n print('YES')", "s=input()\r\nr=input()\r\nprint(\"YES\" if s[::-1]==r else \"NO\")", "s1 = input()\r\ns2 = input() \r\ns2 = s2[::-1] # to reverse a string \r\nif (s1 == s2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Aug 3 22:05:04 2020\r\n\r\n@author: Lucky\r\n\"\"\"\r\n\r\ns1 = input()\r\ns2 = input()\r\ns2 = s2[::-1]\r\nif s1 == s2:\r\n print('YES')\r\nelse:\r\n print('NO')", "w = input()\r\nt = input()\r\n\r\nif ''.join(reversed(w)) != t:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "s = input().lower()\nt = input().lower()\n\nif s != '' and t != '' and len(s) <= 100 and len(t) <= 100 :\n if (s[::-1] == t) :\n print('YES')\n else:\n print('NO')", "u = input()\r\nv = input()\r\nre = v[::-1]\r\nif u == re:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nlista=[]\r\nfor a in t:\r\n lista.append(a)\r\nword=\"\"\r\nfor i in range(0,len(lista)):\r\n word+=lista[len(lista)-1]\r\n lista.pop()\r\nif word==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\ns1=''\r\nfor i in range(0,len(s)):\r\n j=len(s)-1-i\r\n s1+=s[j]\r\n\r\nif(s1==t): print('YES')\r\nelse: print('NO')", "s = input()\nt = input()\n\nresult = \"YES\"\n\nif s != t[::-1]:\n\tresult = \"NO\"\n\nprint(result)\n", "if __name__== \"__main__\":\r\n if list(input())==list(input())[::-1]:\r\n print(\"YES\")\r\n else:\r\n print('NO')", "###### Salah_G ######\r\nimport sys\r\nx=str(input())\r\ny=str(input())\r\nc=0\r\nj=0\r\nif len(x)!=len(y):\r\n print(\"NO\")\r\n sys.exit(0)\r\nfor i in range(len(x)-1,-1,-1):\r\n if x[j]==y[i]:\r\n c+=1\r\n j+=1\r\n else :\r\n break\r\n \r\n\r\nif (c==len(x)):\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "start = input()\r\nend = input()\r\nLs = list(start)\r\nLs.reverse()\r\nLe = list(end)\r\nf = True\r\nfor i in range(len(start)):\r\n if Ls[i] != Le[i]:\r\n f = False\r\n break\r\nif f:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = input()\r\ns2 = input()\r\nif len(s1) == len(s2):\r\n s2copy = ''\r\n for i in range(len(s1)-1, -1, -1):\r\n s2copy += s2[i]\r\n if s1 == s2copy:\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')", "rl = input()\nrv = input()\n\nif rv[::-1] == rl: print('YES')\nelse: print('NO')\n \t \t \t \t \t\t \t \t", "\nS = input() \nT = input()\nif S[::-1] == T :\n print(\"YES\")\nelse:\n print(\"NO\") \n", "Berland = input()\r\nBirland = input()\r\n\r\nReverse = ''\r\n\r\nfor i in range(len(Berland), 0, -1):\r\n Reverse += Berland[i - 1]\r\n\r\nif Reverse == Birland:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "i1 = input()\ni2 = input()\n\nflag = 0\nfor i in range(len(i1)):\n\tif(i1[i] != i2[len(i2)-i-1]):\n\t\tprint(\"NO\")\n\t\tflag = 1\n\t\tbreak\n\nif flag == 0:\n\tprint(\"YES\")\n", "print(\"YES\"if input()[::-1]==input()else\"NO\")", "# Translation\r\ns = str(input())\r\nt = str(input())\r\nreverse = ''\r\nfor l in range(len(s) - 1, -1, -1):\r\n reverse += s[l]\r\nif reverse == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = input()\r\nn_reversed = input()\r\nif n_reversed == n[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = input()\r\nnewWord = input()\r\nnewWordLen = len(newWord)\r\nreverseWord = \"\"\r\n\r\nfor i in range(newWordLen - 1, -1, -1):\r\n ele = newWord[i]\r\n reverseWord += ele\r\n\r\nif word == reverseWord:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n", "x = input()\r\ny = input()\r\nk=\"\"\r\nl = len(x)\r\nfor i in range(0,l):\r\n k=x[i]+k\r\nif(y == k):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t = input()\r\ns = input()\r\nt1=list(t)\r\ns1=list(s)\r\n\r\nif list(reversed(s1))==t1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\n#transforma t en su reverso\nlista_t = t[::-1]\nif s == lista_t:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t \t\t \t \t \t\t \t\t\t\t\t \t\t \t\t\t \t", "t = input()\r\ns = input()\r\n\r\nflag = \"YES\"\r\nif len(t) != len(s):\r\n flag = \"NO\"\r\nelse:\r\n for i in range(len(t)):\r\n if t[i] != s[len(t)-i-1]:\r\n flag = \"NO\"\r\nprint(flag)", "#!/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[322]:\n\n\nline1 = list(str(input()))\nline2 = list(str(input()))\n\n\n# In[323]:\n\n\nif line1[::-1] == line2:\n print('YES')\nelse:\n print('NO')\n\n\n# In[ ]:\n\n\n\n\n\n# In[ ]:\n\n\n\n\n\n# In[ ]:\n\n\n\n\n", "a=input()\r\nb=input()\r\nif a[::-1]==b:print('YES')\r\nelse:print('NO')\r\n", "t = input()\r\ns = input()\r\na = []\r\nb = []\r\nfor i in t:\r\n a += [i]\r\nfor j in s:\r\n b += [j]\r\nb.reverse()\r\nif a == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nlen_s = len(s)\r\nlen_t = len(t)\r\nverdict = \"YES\"\r\nif len_s == len_t:\r\n for i in range(len_s):\r\n if s[i] != t[len_t - i - 1]:\r\n verdict = \"NO\"\r\nelse:\r\n verdict = \"NO\"\r\nprint(verdict)", "x = input()\r\nans = input()\r\ntemp = \"\"\r\nfor i in range(len(x)-1,-1,-1):\r\n temp += x[i]\r\nif temp == ans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nstart = 0\r\nend = len(t) - 1\r\nwhile end >= 0 and start < len(s):\r\n if s[start] != t[end]:\r\n break\r\n end -= 1\r\n start += 1\r\nif start == len(s) and end == -1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x= str(input())\r\ny =str(input())\r\ny = y[::-1]\r\nif x == y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def translation(word, word1):\r\n# print(word, str(reversed(word1)), word1[::-1])\r\n if word == word1[::-1]:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n \r\nword = input()\r\nword1 = input()\r\ntranslation(word, word1)", "ch1=input()\r\nch2=input()\r\ndef isreveresed(ch1,ch2):\r\n if len(ch1)==0:\r\n return True\r\n elif len(ch1)!=len(ch2):\r\n return False\r\n elif (ch1[len(ch1)-1]==ch2[0])and (ch1[0]==ch2[len(ch2)-1]):\r\n return isreveresed(ch1[1:len(ch1)-1],ch2[1:len(ch1)-1])\r\n else:\r\n return False\r\nif isreveresed(ch1,ch2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\nt=input()\n\nif(s==t[-1::-1]): # abcd\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t\t\t\t\t \t \t \t \t \t \t\t \t", "s = input()\r\nt = input()\r\ns = list(s)\r\nt = list(t)\r\n\r\nif s == t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nb=input()\r\nx=[]\r\ny=[]\r\nfor i in a:\r\n x.append(i)\r\nfor i in b:\r\n y.append(i)\r\ny=y[::-1]\r\nif x==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\ns=list(s)\r\ns.reverse()\r\nans=\"\"\r\nfor i in s:\r\n ans+=i;\r\n#print(s1)\r\nif(ans==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input();b=input()\r\nfor i in range(len(a)):\r\n if a[i] != b[-(i+1)] :\r\n print('NO')\r\n break\r\n else:\r\n if i+1 == len(a):\r\n print('YES')\r\n else:\r\n continue", "s=input()\r\nt=input()\r\nx=list()\r\nfor i in s:\r\n x.append(i)\r\nx.reverse()\r\ny=\"\".join(x)\r\nif y==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nb=list(a)\r\na=input()\r\nc=list(a)\r\nb.reverse()\r\nif b==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def palindrome(s,t):\r\n rev_s= \"\".join(reversed(s))\r\n if rev_s==t:\r\n return \"YES\"\r\n return \"NO\"\r\ns= input()\r\nt= input()\r\nprint(palindrome(s,t))", "first = str(input())\r\nsec = str(input())\r\nsec = sec[::-1]\r\nif first == sec:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "Berland = input()\nBirland = input()\n\nBirlandTranslation = Berland[::-1]\n\nif BirlandTranslation == Birland:\n print(\"YES\")\nelse:\n print(\"NO\")\n\t\t \t \t\t \t\t \t \t\t\t \t \t", "def main():\n\tif input()[::-1]==input():\n\t\tprint('YES')\n\t\treturn 0\n\tprint('NO')\n\treturn 0\n\nif __name__ == '__main__':\n\tmain()\n", "a = list(input())\r\nb = list(input())\r\ns = \"\"\r\n\r\nb.reverse()\r\n\r\nif(s.join(a) == s.join(b)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "first_word = input()\r\nsecond_word = input()\r\ncorrect_translate = True\r\nfor i in range(len(first_word)):\r\n if first_word[i] != second_word[-(i + 1)]:\r\n correct_translate = False\r\n print(\"NO\")\r\n break\r\nif correct_translate:\r\n print(\"YES\")", "s=input(\"\")\nt=input(\"\")\nlist1=[]\nfor i in range(len((t))-1,-1,-1):\n list1.append(t[i])\nm=''.join(list1)\nif s==m:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n", "s=input()\r\na=input()\r\nn=s[::-1]\r\nif a!=n:\r\n print(\"NO\\n\")\r\n \r\nelse:\r\n print(\"YES\\n\")", "i=list(reversed(input()))\r\nx=list(input())\r\n\r\nif i == x:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\ns = s[::-1]\r\nprint(\"YES\") if s == t else print(\"NO\")\r\n", "a = input()\r\nb = input()\r\nreverse_a = ''\r\nfor i in range(len(a)):\r\n reverse_a += a[-i-1]\r\nif b == reverse_a:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "n = input()\nn1 = input()\nn2 = n[::-1]\nif(n2==n1):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s1 , s2 = input() , input()\r\n\r\nrev = s1[::-1]\r\n\r\nif rev == s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\noutput_str = ''\r\n\r\nfor i in range(len(t)-1, -1, -1):\r\n output_str = output_str + t[i]\r\n\r\nif s == output_str:\r\n print('YES')\r\nelse:\r\n print('NO')", "x = input()\ny = input()\nif y == x[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "print('YES') if input() == ''.join(list(reversed(input()))) else print('NO')", "s = list(input())\r\nd = list(input())\r\nh = []\r\nfor i in range(len(s) - 1, -1, -1):\r\n h.append(s[i])\r\nif h == d:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\r\n\r\ndef reverse(string):\r\n string = list(string)\r\n string.reverse()\r\n return \"\".join(string)\r\n\r\n\r\nstring1 = input()\r\nstring2 = input()\r\n\r\nreverse_string1 = reverse(string1)\r\nreverse_string2 = reverse(string2)\r\n\r\nif string1 == reverse_string2:\r\n print(\"YES\")\r\nelif reverse_string1 == string2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = list(input())\r\nt = list(input())\r\n\r\nt.reverse()\r\nscore = 0\r\n\r\nfor i, q in zip(s, t):\r\n if i == q:\r\n score += 1\r\nif score == len(s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = input()\nanswer = \"\"\ntranslation = input()\nfor i in range(len(n)-1, -1, -1):\n answer = answer + str(n[i])\nif translation == answer:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "n=input()\r\nc=input()\r\nd=n[::-1]\r\nif c==d:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n\t", "a, b = input(), input()\nb = list(b)\nb.reverse()\nb = ''.join(b)\nif a == b:\n print('YES')\nelse:\n print('NO')\n", "word = input()\r\nrev_word = input()\r\nif(word[::-1] == rev_word):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s1 = input()\ns2 = input()\nl1 = len(s1)\nl2 = len(s2)\nl = min(l1, l2)\ncount = 0\nfor i in range(l):\n if s1[i] == s2[l - i - 1]:\n count += 1\nif count == l and l1 == l2:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s=input()\nt=input()\nif t==s[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t \t\t \t \t \t\t\t\t\t\t\t \t\t \t", "s=input()\ns1=input()\nx=s[::-1]\nif(x==s1):\n print(\"YES\")\nelse:\n print(\"NO\")\n \n \n\t \t \t\t \t\t \t \t\t\t \t \t\t", "x = str(input())\r\ny = str(input())\r\n\r\nwordlength = len(x)\r\n\r\nif len(x) == len(y):\r\n\r\n results = []\r\n\r\n for i in range(wordlength):\r\n if x[i] == y[0-(i+1)]:\r\n results.append(\"YES\")\r\n else:\r\n results.append(\"NO\")\r\n\r\n if \"NO\" in results:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")", "def translation(a,b):\r\n if a[::-1] != b:\r\n return 'NO'\r\n else:\r\n return 'YES'\r\n \r\n \r\nx = input()\r\ny = input()\r\nprint(translation(x,y))", "a=list(input())\nb=list(input())\nc=a[::-1]\nif c==b:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n#BOTTOM CODE IS CORRECT BUT RUNTIME ERROR\n# count=0\n# for i in range(len(a)):\n# if a[i]==b[(len(a)-1)-i]:\n# count+=1\n# if count==len(a):\n# print(\"YES\")\n# else:\n# print(\"NO\")\n", "if __name__ == \"__main__\":\n n = input()\n m = input()\n print('YES') if n[::-1] == m else print('NO')\n", "string = input()\r\nrstring = input()\r\ns = \"\"\r\nfor i in string:\r\n s = i + s\r\n\r\nif rstring == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\nfor i in s :\n translation = s[::-1]\nif translation == t:\n print('YES')\nelse:\n print('NO')", "a = input()\r\nb = input()\r\n\r\nresult = a[::-1]\r\n\r\nif result == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nreverse = t[::-1]\r\nif reverse == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\ns=\"\".join(reversed(b))\r\nif s==a:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\n\r\ns1 = len(s)\r\nt1 = len(t)\r\n\r\nreversed_word = s[::-1]\r\n\r\nif s1 == t1:\r\n if t == reversed_word:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input();e=input()\r\nprint(\"YES\") if s == e[::-1] else print(\"NO\")\r\n", "import sys\nimport math\n# import numpy as np\nfrom heapq import heappush, heappop\nimport itertools\nimport bisect\nfrom collections import deque\nfrom collections import Counter\nfrom collections import defaultdict\nfrom decimal import Decimal\n# sys.setrecursionlimit(10**7)\nMOD1 = 10 ** 9 + 7\nMOD2 = 998244353\nMOD = MOD2\nINF = float('inf')\ninput = sys.stdin.readline\ndef ii(): return int(input())\ndef si(): return str(input()[:-1])\ndef li(): return list(input())\ndef mi(): return map(int, input().split())\ndef lmi(): return list(map(int, input().split()))\ndef folmi(n): return [list(map(int, input().split())) for _ in range(n)]\ndef foli(n): return [list(input()[:-1]) for _ in range(n)]\ndef foi(n): return [input()[:-1] for _ in range(n)]\ndef foii(n): return [int(input()[:-1]) for _ in range(n)]\ndef lcm(a, b): return a // math.gcd(a, b) * b\ndef cnt_digits(a): return len(str(a))\n\n###############################################################################\n\n################################################################################\n\n\ndef p(x):\n print(x)\n\n\ndef pmat(mat):\n for i in mat:\n print(i)\n\n\ndef pow(x, n, mod):\n ans = 1\n while n > 0:\n if n % 2 != 0:\n ans *= x % mod\n x = x * x % mod\n n = n // 2\n return ans\n\n\ndef nck(n, r, mod):\n x, y = 1, 1\n for i in range(r):\n x = x * (n - i) % mod\n y = y * (i + 1) % mod\n return x * pow(y, mod - 2, mod) % mod\n\n\ndef make_divisors(n):\n lower_divisors, upper_divisors = [], []\n i = 1\n while i*i <= n:\n if n % i == 0:\n lower_divisors.append(i)\n if i != n // i:\n upper_divisors.append(n//i)\n i += 1\n return lower_divisors + upper_divisors[::-1]\n\n\ndef primes(x):\n if x < 2:\n return []\n primes = [i for i in range(x)]\n primes[1] = 0\n for prime in primes:\n if prime > math.sqrt(x):\n break\n if prime == 0:\n continue\n for non_prime in range(2 * prime, x, prime):\n primes[non_prime] = 0\n return [prime for prime in primes if prime != 0]\n\n\ndef prime_numbers(n):\n if n < 2:\n return []\n m = (n + 1) // 2\n p = [1] * m\n for i in range(1, int((n ** 0.5 - 1) / 2) + 1):\n if p[i]:\n p[2 * i * (i + 1):: 2 * i + 1] = [0] * \\\n (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)\n return {2} | {2 * i + 1 for i in range(1, m) if p[i]}\n\n\ndef prime_factorize(n):\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\n\ndef is_prime(x):\n if x < 2:\n return False\n if x == 2 or x == 3 or x == 5:\n return True\n if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:\n return False\n prime = 7\n step = 4\n while prime <= math.sqrt(x):\n if x % prime == 0:\n return False\n prime += step\n step = 6 - step\n return True\n\n\ndef prime_factorize_count(n): return Counter(prime_factorize(n))\n\n\nclass dsu:\n __slots__ = [\"n\", \"parent_or_size\"]\n\n def __init__(self, n):\n self.n = n\n self.parent_or_size = [-1] * n\n\n def merge(self, a, b):\n x = self.leader(a)\n y = self.leader(b)\n if x == y:\n return x\n if self.parent_or_size[y] < self.parent_or_size[x]:\n x, y = y, x\n self.parent_or_size[x] += self.parent_or_size[y]\n self.parent_or_size[y] = x\n return x\n\n def same(self, a, b):\n return self.leader(a) == self.leader(b)\n\n def leader(self, a):\n path = []\n while self.parent_or_size[a] >= 0:\n path.append(a)\n a = self.parent_or_size[a]\n for child in path:\n self.parent_or_size[child] = a\n return a\n\n def size(self, a):\n return - self.parent_or_size[self.leader(a)]\n\n def groups(self):\n result = [[] for _ in range(self.n)]\n for i in range(self.n):\n result[self.leader(i)].append(i)\n return [g for g in result if g]\n\n\ndef dijkstra(s, n):\n dist = [INF] * (n + 1)\n hq = [(0, s)]\n dist[s] = 0\n seen = [False] * (n + 1)\n while hq:\n v = heappop(hq)[1]\n seen[v] = True\n for to, cost in a[v]:\n if seen[to] == False and dist[v] + cost < dist[to]:\n dist[to] = dist[v] + cost\n heappush(hq, (dist[to], to))\n return dist\n\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 )\n\n\n################################################################################\n\n################################################################################\na = list(si())\nb = list(si())\nb.reverse()\nif a == b:\n p(\"YES\")\nelse:\n p(\"NO\")\n", "N=input()\r\nA=input()\r\nif N==A[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\nif t == s[::-1]: print(\"YES\")\nelse: print(\"NO\")", "def fun(s,t): \r\n if s == t[::-1]:\r\n return 'YES'\r\n return 'NO'\r\ns = input()\r\nt = input()\r\nprint(fun(s,t))\r\n\r\n ", "input1=input()\r\ninput2=input()\r\nif input1[::-1]==input2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "org = input()\r\nrev = input()\r\n\r\nif rev == org[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "p = input()\r\nc = input()\r\ng = \"\"\r\nif (p.islower() and c.islower()):\r\n for i in range(len(p)):\r\n g = g + p[len(p) - 1 - i]\r\n if g == c:\r\n print('YES')\r\n else:\r\n print('NO')\r\n \r\n", "a = input()\r\nb = input()\r\nprint(\"YES\") if(b[::-1]==a) else print(\"NO\")", "s = input()\r\nt = input()\r\nprint('YES' if s == t[::-1] else 'NO')", "ch=input()\r\nsh=input()\r\nif len(ch) == len(sh):\r\n t=True\r\n for i in range(len(ch)):\r\n if ch[i] != sh[len(ch)-1-i]:\r\n t=False\r\n if t:\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')", "def Task41A():\r\n input1 = input()\r\n input2 = input()\r\n length = len(input1)-1\r\n reversed = input1[::-1]\r\n if reversed==input2:\r\n print('YES')\r\n else:\r\n print('NO')\r\nTask41A()", "s = input()\r\nt = input()\r\nnew = \"\"\r\nfor el in s:\r\n new = el + new\r\nif t == new:\r\n print('YES')\r\nelse:\r\n print('NO')", "a = list(input())\r\nb = list(input())\r\nif (a[-1:len(a)*-1-1:-1] == b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "msg=input()\r\nmsg2=input()\r\nif(msg[::-1]==msg2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "berlang = input()\r\nbirlang = input()\r\n\r\nreverselang = berlang[::-1]\r\n\r\nif(reverselang==birlang):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = list(input())\r\nb = list(input())\r\n# print(list(reversed(b)))\r\nif a == list(reversed(b)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "org=list(input())\r\nnew=list(input())\r\nnew.reverse()\r\nif new==org:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "r=input()\r\n\r\nd=input()\r\nif(r[::-1]==d):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\ns_rev = \"\"\r\nfor i in range(len(s)):\r\n\ts_rev += s[len(s)-i-1]\r\nif s_rev == t:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "a=input()\r\nb=a[::-1]\r\nc=input()\r\nif b==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word1 = input()\r\nword2 = input()\r\n\r\nk = word1[::-1]\r\n\r\nif(k == word2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "# coding=utf-8\ns=input()\r\nt=input()\r\nst=''\r\nfor i in range(len(s)):\r\n st=s[i]+st\r\nif st==t:\r\n print('YES')\r\nelse:\r\n print('NO')\n\t\t\t\t\t\t\t \t\t \t\t\t \t\t \t \t \t \t\t", "def is_reverse(x, y):\r\n if len(x) != len(y):\r\n return \"NO\"\r\n\r\n for i in range(len(x)):\r\n if x[i] != y[len(y) - 1 - i]:\r\n return \"NO\"\r\n\r\n return \"YES\"\r\n\r\n\r\na = input()\r\nb = input()\r\nprint(is_reverse(a, b))\r\n", "s=input()\r\na=input()\r\nb=a[::-1]\r\nif(b==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# 8 5\r\n# 10 9 8 7 7 7 5 5\r\n\r\n##x = 0 # NOT COMPETED PROBEM==NEXT ROUND\r\n##y=[] # NOT COMPETED PROBEM==NEXT ROUND\r\n##rks, pos = map(int, input().split()) # NOT COMPETED PROBEM==NEXT ROUND\r\n##for _ in range(rks): # NOT COMPETED PROBEM==NEXT ROUND\r\n## a = int(input()) # NOT COMPETED PROBEM==NEXT ROUND\r\n## y.append(a) # NOT COMPETED PROBEM==NEXT ROUND\r\n## # NOT COMPETED PROBEM==NEXT ROUND\r\n##while y[pos] >= y:\r\n## x += 1\r\n##print(x) \r\n\r\na = input()\r\nb = input()\r\nprint('YES' if a == b[::-1] else 'NO')\r\n", "S=input()\r\nT=input()\r\nN=\"\".join(reversed(T))\r\nif S==N:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nf = s[::-1]\r\nif f==t and len(s)<=100:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s1=input()\r\ns2=input()\r\nk=0\r\nif(len(s1)!=len(s2)):\r\n print('NO')\r\nelse:\r\n for i in range(len(s1)):\r\n if(s1[i]!=s2[len(s2)-1-i]):\r\n print('NO')\r\n k+=1\r\n break\r\n if(k==0):\r\n print('YES')", "s=str(input())\r\nt=str(input())\r\nx=[]\r\nfor i in range(len(s)-1,-1,-1):\r\n x.append(s[i])\r\ny=\"\".join(x)\r\nif y==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "t=list(input().rstrip())\r\nr=list(input().rstrip())\r\nt.reverse()\r\nif(r==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n \r\n", "str1 = list(input())\r\nstr2 = list(input())\r\nstr3 = list(''.join(reversed(str2)))\r\n\r\nif (len(str1) != len (str2)) or (str1 == str2 and str2 != str3) or str1 != str3 :\r\n print(\"NO\")\r\n quit()\r\n\r\nprint(\"YES\")", "t=input()\r\ns=input()\r\nv=(t[::-1][0:len(t)])\r\n\r\nif s == v:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\nflag = False\nfor i in range(len(s)):\n if s[i] == t[-(i + 1)]:\n flag = True\n continue\n else:\n flag = False\n break\nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "import math\r\ns=input()\r\nt=input()\r\ndef solve():\r\n if(len(s)!=len(t)):\r\n print(\"NO\")\r\n return \r\n n=len(s)\r\n for i in range(n):\r\n # print(i,s[i],t[n-i-1])\r\n if(s[i]!=t[n-i-1]):\r\n print(\"NO\")\r\n return \r\n print(\"YES\")\r\nsolve()", "s=input()\r\nt=input()\r\nlis=[]\r\nfor i in str(s):\r\n\tlis.append(i)\r\nlis.reverse()\r\ns1=''.join(lis)\r\nif s1==t:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "def reverse_slicing(s):\r\n return s[::-1]\r\n\r\ninp=input(\"\")\r\nc=input(\"\")\r\n\r\nif __name__ == \"__main__\":\r\n y=reverse_slicing(inp)\r\nif(y==c):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nx = len(s)\r\nif len(s) == len(t):\r\n for i in range(x):\r\n if s[i] != t[x-1-i]:\r\n print(\"NO\")\r\n break\r\n else:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = list(input())\r\nh = input()\r\nr = list(reversed(n))\r\nresult = \"\"\r\nfor i in r:\r\n result += i\r\nif result == h:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input())\r\nr = str(input())\r\nans = s[::-1]\r\n\r\nif (ans==r):\r\n print(\"YES\")\r\n \r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Wed Sep 13 15:05:23 2023\r\n\r\n@author: gzk16\r\n\"\"\"\r\n\r\nword_before = input()\r\nword_after = word_before[::-1]\r\nword_input = input()\r\nif word_after == word_input:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = str(input())\r\nc = str(input())\r\nk = ''\r\np = 0\r\np = min(len(s), len(c))\r\nfor i in range(1, p + 1):\r\n k = k + c[p - i]\r\nif s == k:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "A=str(input())\r\nB=str(input())\r\nans=A[::-1]\r\nif(B==ans):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "inp = input()\r\ninp2 = input()\r\nactual = inp[::-1]\r\nif actual == inp2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x = list(input())\r\nx.reverse()\r\nt = ''.join(x)\r\nif t == input():print('YES')\r\nelse:print('NO')", "a=input()\r\nb=input()\r\nc=0\r\nfor i,j in zip(range(len(a)),range(-1,-(len(b))-1,-1)):\r\n if a[i]==b[j]:\r\n c+=1\r\nif c==len(a)==len(b):\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nc = input()\r\nx = s[::-1]\r\nif c == x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str=list(input())\r\nsecstr=input()\r\nfor i in range(len(str)//2):\r\n temp=str[i]\r\n str[i]=str[len(str)-1-i]\r\n str[len(str)-1-i]=temp\r\nistr=\"\".join(str)\r\nif istr==secstr:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t = input()\r\ns = input()\r\nprint('YES') if t[::-1] == s else print('NO')", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Sep 25 09:40:56 2023\r\n\r\n@author: 25419\r\n\"\"\"\r\n\r\na=input()\r\nb=input()\r\nn=len(a)\r\nm=len(b)\r\nif m!=n:\r\n print('NO')\r\nelse:\r\n for i in range(n):\r\n if a[i]!=b[n-i-1]:\r\n print('NO')\r\n break\r\n elif a[i]==b[n-i-1] and i!=n-1:\r\n continue\r\n else:print('YES')", "string_a = input()[::-1]\r\nstring_b = input()\r\n\r\nprint(\"YES\" if string_a == string_b else \"NO\")", "n=input()\r\ns=input()\r\nd=''.join(reversed(n))\r\nif d==s:\r\n print(\"YES\")\r\nelse:print(\"NO\")", "s = input()\r\nrev_s = input()\r\nif (rev_s==s[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\ndef reverse(s):\r\n\tstr = \"\"\r\n\tfor i in s:\r\n\t\tstr = i + str\r\n\treturn str\r\nif b == reverse(a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s = list(input())\r\nt = input()\r\ns.reverse()\r\nif(''.join(s) == t): print(\"YES\")\r\nelse: print(\"NO\")", "s=input()\r\nt=input()\r\ntemp=s[-1::-1]\r\nif(temp==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def compare(a,d):\r\n if a==d:\r\n return 'YES'\r\n \r\n else:\r\n return 'NO'\r\nn=input()\r\ns=input()\r\ns=s[::-1]\r\n\r\nprint (compare(n,s))", "# URL: https://codeforces.com/problemset/problem/41/A\n\ns = list(input())\nt = list(input())\nt.reverse()\nprint(\"YES\" if s == t else \"NO\")\n", "try:\r\n def f(l1,l2):\r\n if(len(l1)!=len(l2)):\r\n return \"NO\"\r\n else:\r\n rev=\"\"\r\n for i in l2:\r\n rev=i+rev\r\n if rev==l1:\r\n return \"YES\"\r\n return \"NO\"\r\n \r\n l1=input()\r\n l2=input()\r\n print(f(l1,l2))\r\nexcept:\r\n pass\r\n", "word1 = input()\nword2 = input()\ntranslation = \"\"\n \nfor elem in word1[::-1]:\n translation += elem\n \nif translation == word2:\n print(\"YES\")\nelse:\n print(\"NO\")\n ", "s1 = list(input())\r\ns2 = list(input())\r\nn = s1[::-1]\r\nif n == s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s1=str(input())\r\ns2=str(input())\r\nf=1;\r\nfor i in range(len(s1)):\r\n if s1[i]!=s2[-i-1]:\r\n f=0\r\n break\r\nif(f) :\r\n print (\"YES\")\r\nelse :\r\n print (\"NO\")\r\n", "s=input()\r\nt=input()\r\nstr2=\"\"\r\nfor i in range(len(s)):\r\n str2=str2+s[len(s)-1-i]\r\n\r\nif str2==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\n\r\nx = -1\r\ny = 0\r\nz = True\r\n\r\nfor n in range(len(s)):\r\n if s[y] == t[x]:\r\n x -= 1\r\n y += 1\r\n else:\r\n z = False\r\nif z:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "first = input()\nsecond = input()\nfor i in range(len(first)):\n if first[i] != second[-1-i]:\n print('NO')\n break\n elif i == len(first)-1:\n print('YES')", "def is_reverse(a, b):\r\n return a == b[::-1]\r\n\r\na = input().strip()\r\nb = input().strip()\r\n\r\nif is_reverse(a, b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def swaps(one: str, two: str):\r\n twoReversed = two[::-1]\r\n if one == twoReversed:\r\n return 'YES'\r\n else:\r\n return 'NO'\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n one = input()\r\n two = input()\r\n print(swaps(one, two))", "a = input()\r\nb = input()\r\ndef f (a,b):\r\n for i in range(0,len(a)):\r\n if a[i] != b[0-i-1]:\r\n return \"NO\"\r\n return \"YES\"\r\nprint(f(a,b))\r\n\r\n", "wordA = input()\nwordB = input()\nflag = True\nfor i in range(len(wordA)):\n if wordA[i] != wordB[-1 * (i + 1)]:\n print(\"NO\")\n flag = False\n break\nif flag:\n print(\"YES\")\n", "s= input()\r\nt = input()\r\na = s[-1::-1]\r\nif(a==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def translate(s, t):\r\n if s == t[-1::-1]:\r\n return \"YES\"\r\n\r\n return \"NO\"\r\n\r\ndef main():\r\n s = input()\r\n t = input()\r\n print(translate(s, t))\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "num1=input()\r\nnum2=input()\r\nnum3=\"\"\r\nfor i in range(len(num1)-1,-1,-1):\r\n num3=num3+num1[i]\r\nif(num2==num3):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "stringA=input()\nstringB=input()\nif(stringA[::-1]==stringB):\n print(\"YES\")\nelse:\n print(\"NO\")\n\t\t\t\t\t \t\t\t\t\t\t \t\t\t\t \t\t\t\t \t", "s = input()\r\nt = input()\r\nc = len(s)\r\nflag = 0\r\ni = 0\r\nwhile(i<len(s)):\r\n try:\r\n if s[i] != t[c-1]: \r\n flag = 1\r\n break\r\n i+=1\r\n c-=1\r\n except:\r\n flag = 1\r\n break\r\nif flag == 0: print('YES')\r\nif flag == 1: print('NO')", "worda = input()[::-1]\r\nwordb = input()\r\n\r\nif worda == wordb:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "st1=input()\nst2=input()\nif(st1==st2[::-1]):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t\t\t\t \t\t \t\t \t\t \t\t \t\t\t", "x=input()\r\ny=input()[::-1]\r\nprint(\"YES\" if (x==y) else \"NO\")", "# your code goes here\r\ns=str(input())\r\nt=str(input())\r\na = s [::-1]\r\nif(t==a):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "st=input()\r\nrev=st[::-1]\r\ns=input()\r\nif(s==rev):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s = input()[::-1]\nif input() == s:\n print('YES')\nelse:\n print('NO')", "\r\na = input()\r\nx = input()\r\n#print(a)\r\nb = []\r\nc = []\r\nfor i in a:\r\n b.append(i)\r\n#print(b)\r\n#for i in range(0,len(b),2):\r\n# print(i)\r\n# c.append(b[i])\r\nb.reverse()\r\n#print(b)\r\nwynik = ''\r\nfor i in b:\r\n wynik = wynik + i\r\n#print(wynik)\r\nif wynik == x:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "l =input().strip().lower()\r\nb =input().strip().lower()\r\nm = list(l)\r\nh = list(b)\r\nif m[0:]==h[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nv=input()\r\nb=v[::-1]\r\nif b==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# https://codeforces.com/problemset/problem/41/A\n# A. Translation\n\ndef isTranslatable(t: str, s: str) -> str:\n j = len(s)\n if len(t) != j:\n return 'NO'\n j -= 1\n i = 0\n while j >= 0:\n if t[i] != s[j]:\n return 'NO'\n i += 1\n j -= 1\n return 'YES'\n\n\nif __name__ == \"__main__\":\n print(isTranslatable(input(), input()))\n", "def fun():\r\n n=str(input())\r\n k=str(input())\r\n n=\"\".join(reversed(n))\r\n if n==k:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nfun();", "s1=input()\r\ns2=input()\r\nx=\"\".join(reversed(s2))\r\nif x==s1:\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "s1,s2=str(input()),str(input())\r\nprint(\"YES\" if s1[::-1]==s2 else \"NO\")", "m=input()\r\nn=input()\r\nn=list(n)\r\nm=list(m)\r\nn.reverse()\r\nif(n==m):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word1 = input()\r\nword2 = input()\r\na = len(word1)\r\nb = 0\r\nc = len(word2)\r\nif a != c:\r\n print('NO')\r\nelse:\r\n for i in range(a):\r\n j = -1-i\r\n if word1[i] != word2[j]:\r\n b = 1\r\n if b == 1:\r\n print('NO')\r\n elif b == 0:\r\n print('YES')", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Aug 21 10:30:09 2020\r\n\r\n@author: Tanmay\r\n\"\"\"\r\n\r\ns=input()\r\nd=input()\r\nif(s[-1::-1]==d):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input('')\r\nb = input('')\r\nlista = []\r\nz = ''\r\n\r\nfor i in b:\r\n lista.append(i)\r\n\r\nfor j in lista[::-1]:\r\n z = z + j\r\n\r\nif z == a:\r\n print('YES')\r\n\r\nelse:\r\n print('NO')\r\n", "a = input()\r\nb = input()\r\nif a==(b[::-1]):print(\"YES\")\r\nelse:print(\"NO\")\r\n", "# Translation\r\ns1 = input()\r\ns2 = input()\r\nflag = 0\r\nif len(s1) != len(s2):\r\n flag = 1\r\nelse:\r\n for i in range(len(s1)):\r\n if s1[i] != s2[len(s2)-1-i]:\r\n flag = 1\r\nif flag == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "string = input()\r\nstring2 = input()\r\nstring3 = ''\r\nfor i in range(len(string)-1, -1, -1):\r\n string3 += string[i]\r\nif string3 == string2:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = str(input().lower())\r\nt = str(input().lower())\r\nf = s[::-1]\r\nif t==f:\r\n print(\"YES\")\r\nelif t!=f:\r\n print(\"NO\")", "n = input()\r\ns = input()\r\nc = 0\r\np=\"\"\r\n\r\np = p + n[::-1]\r\nif (p == s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\nn2=input()\r\nj=n.count('')-1\r\nx=''\r\nfor i in range(-1,-1*j-1,-1):\r\n x=x+n[i]\r\nif(x==n2):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\r\nt = input()\r\ntotal = 0\r\nfor i in range(1, len(s)+1):\r\n if s[i-1] == t[len(t)-i]:\r\n total += 1\r\nif total == len(s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=str(input())\r\ny=str(input())\r\na=x[::-1]\r\nif(a==y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "x, y = input(), input()[::-1]\r\nprint(\"YES\") if x == y else print(\"NO\")", "def rev(x):\r\n return x[::-1]\r\n\r\na=input()\r\nb=input()\r\nc=rev(a)\r\nif(b==c):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\ntrans = input()\r\nif(s[::-1] == trans):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=input()\r\ns2=input()\r\nn=len(s2)\r\ns3=''\r\nfor i in range(n-1,0,-1):\r\n s3+=s2[i]\r\ns3+=s2[0]\r\nif s3==s1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "string = input()\r\nstring2 = input()\r\nn = len(string)\r\nm = len(string2)\r\nflag = 0\r\nfor i in range(n):\r\n if(string[i] == string2[m-1]):\r\n m = m-1\r\n continue;\r\n else:\r\n flag = 1\r\nif(flag == 0):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1 = input()\r\nstr2 = input()\r\nlist2 = [a for a in str2]\r\nlist3 = list2[::-1]\r\nstr3 = \"\".join(list3)\r\nif str1 == str3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "l1 = list(input())\r\ntempl = list(input())\r\nn = len(templ)\r\nl2 = []\r\nfor i in range(n):\r\n l2.append(templ[n-1-i])\r\nif l1==l2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=str(input())\r\nb=input()\r\nc=0\r\nif len(a)==len(b):\r\n for i in range(len(a)):\r\n if a[i-1]!=b[-i]:\r\n c=1\r\nelse:\r\n c=1\r\nif c==0:\r\n print('YES')\r\nelse:\r\n print('NO')", "a = input()\r\nb = input()\r\ncount = 0\r\nif len(a)==len(b):\r\n for i in range(0,len(a)) :\r\n if a[len(a)-(i+1)]==b[i]:\r\n count+=1\r\nelse:\r\n print('NO')\r\nif count == len(a):\r\n print('YES')\r\nelif 0<=count<len(a) and len(a)==len(b):\r\n print('NO')", "a=input()\r\nb=input()\r\nprint(['NO','YES'][a==b[::-1]])", "s=input()\r\nt=input()\r\nliste=[]\r\nfor i in t:\r\n\tliste.insert(0,i)\r\n\r\nt=\"\".join(liste)\r\nif t!=s:\r\n\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")", "n = input()\r\nm = input()\r\n\r\nrev = n[::-1]\r\nif(m == rev):\r\n print(\"YES\")\r\nelse: print(\"NO\")\r\n\r\n\r\n\r\n\r\n", "a=input()\nx=input()\nb=a[::-1]\nif x==b:\n print(\"YES\")\nelse:\n print(\"NO\")", "# https://codeforces.com/problemset/problem/41/A\n\ndef main():\n s, t = input(), input()\n print(['NO', 'YES'][t == s[::-1]]) \n\nif __name__ == '__main__':\n main()", "a=input()\nb=input()\nb=b[::-1]\nif a==b :\n\tprint('YES')\nelse:\n\tprint('NO')", "#!/usr/bin/python3.5\r\nt = input()\r\ns = input()\r\na = t[::-1]\r\nif (s == a):\r\n\tprint (\"YES\")\r\nelse:\r\n\tprint (\"NO\")", "string1 = input()\nstring2 = input()\nd = list(string1)\ne = list(string2)\nd.reverse()\nif d == e:\n print('YES')\nelse:\n print('NO')\n\t \t \t \t\t \t \t\t \t\t\t \t\t \t", "s=input()\r\nk=input()\r\na=[]\r\nb=[]\r\nfor i in s:\r\n\ta.append(i)\r\nfor i in k:\r\n\tb.append(i)\r\n\r\na.reverse()\r\nif a==b:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "n=list(input())\r\nr_n=input()\r\nr=list(reversed(n))\r\nresult=\"\"\r\nfor i in r:\r\n result+=i\r\nif result==r_n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\na=\"\"\r\nb=0\r\nfor i in s:\r\n b-=1\r\n a+=s[b]\r\nif a==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nm=input()\r\nprint(s==m[::-1] and 'YES' or 'NO')", "l=list(input())\r\nl.reverse()\r\nprint('YES' if l==list(input()) else 'NO')", "s=input()\r\nt=input()\r\ns=s.lower()\r\nt=t.lower()\r\n\r\nif t==s[::-1]:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")", "str1, str2 = input(), input()\r\n\r\nprint(\"YES\") if str2 == str1[::-1] else print(\"NO\")", "word1 = input(\"\")\r\nword2 = input(\"\")\r\nreversedString = \"\".join(reversed(word1))\r\nif reversedString == word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n\r\n", "word=input()\r\ntrans=input()\r\nc=len(word)\r\nc2=len(trans)-1\r\ni=0\r\nfor x in range (len(word)):\r\n\tif word[x]==trans[c2]:\r\n\t\ti+=1\r\n\t\tc2-=1\r\nif i>=len(word):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "s=input()\r\nt=input()\r\n\r\ns1=s[::-1] #reverse the string by slice\r\n\r\nif s1==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#41A Translation\r\n\r\n#check to see if something is spelled backwards \r\n\r\ns = input()\r\nt = input()\r\n\r\nstring = len(s)\r\nreverseString = s[string::-1]\r\n\r\nif reverseString == t:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n\r\n", "\r\n\r\ns = input()\r\ns1 = input()\r\n\r\nif (s1 == s[::-1]):\r\n print (\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "p = input()\r\nl = input()\r\n\r\nif p[::-1] == l:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n ", "i=input()\r\nk=i[::-1]\r\ng=input()\r\nif k==g:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\r\nt = input()\r\n\r\ndef reverse_string(t):\r\n t = t[::-1]\r\n return t\r\n\r\nif s == reverse_string(t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nerror=0\r\nif len(s) != len(t):\r\n error += 1\r\nelse:\r\n for i in range(len(s)):\r\n if s[i] == t[-1-i]:\r\n continue\r\n else:\r\n error += 1\r\n break\r\n\r\nif error == 0:\r\n print('YES')\r\nelse:\r\n print('NO')", "a = input()\r\nb = input()\r\nname = ''\r\nj = len(a) -1\r\nwhile j >=0:\r\n for i in a[j]:\r\n name += i\r\n j -= 1\r\nif name == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=list(input())\r\nb=list(input())\r\nc=0\r\nd=True\r\n\r\nfor i in a:\r\n c-=1\r\n if i == b[c]:\r\n d=True\r\n continue\r\n else:\r\n d=False\r\n break\r\n\r\nif d==True:\r\n print('YES')\r\nelse:\r\n print('NO')", "first = str(input())\r\nsecond = str(input())\r\nsecond = second[::-1]\r\nif(first == second):\r\n print('YES')\r\nelse:\r\n print('NO')", "mainWord = input()\r\nrevWord = input()\r\n \r\nif (revWord == mainWord[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "print('YES' if list(input())[::-1] == list(input()) else 'NO')", "n=input()\r\ns=input()\r\nprint(\"YES\") if n==s[::-1] else print(\"NO\")", "s=input()\r\ns1=input()\r\ns2=s1[::-1]\r\nif s==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "w1=input()\nw2=input()\nif w1 == w2[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "a=list(input())\r\nb=input()\r\na.reverse()\r\nc=''.join(a)\r\nif c==b:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=list(input())\nb=list(input())\na=a[::-1]\nif ''.join(a)==''.join(b):\n print('YES')\nelse:\n print('NO')\n\n \t\t\t\t \t\t \t\t\t\t\t \t\t \t\t \t", "s1=input()\r\ns2=input()\r\na=s1[::-1]\r\nif a==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[ ]:\n\n\n\n\n\n# In[ ]:\n\n\n\n\n\n# In[16]:\n\n\ns=input()\nt=input()\narr=[]\nfor i in range(len(s)) :\n arr.append(s[i])\narr=reversed(arr)\narr=''.join(arr)\nif arr==t :\n print('YES')\nelse :\n print(\"NO\")\n\n", "s=input()\r\nt=input()\r\ns=s[::-1]\r\nprint('YES' if s==t else 'NO')", "s1, s2 = input(), input()\r\nprint('YES' if s2 == s1[::-1] else 'NO')", "s=input()\r\nt=input()\r\nprint([\"NO\",\"YES\"][ t== s[::-1]])", "def main():\r\n s = input()\r\n t = input()\r\n yes = 0\r\n lent = len(t)-1\r\n if(len(s) == len(t)):\r\n for i in range(len(s)):\r\n if(s[i] == t[lent-i]):\r\n yes = 1\r\n else:\r\n yes = 0\r\n break\r\n else:\r\n yes = 0\r\n if(yes == 0):\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n\r\n\r\n\r\nmain()", "s=input()\nt=input()\ncount=0\ntl=list(t)\nsl=list(s)\nif(len(sl) != len(tl)): \n print(\"NO\")\n\nelse:\n for i,l in enumerate(tl):\n if(l == sl[len(sl)-i-1]):\n count+=1\n\n if(count == len(s)):\n print(\"YES\") \n else:\n print(\"NO\")", "s=input()\nt=input()\nk=0\nfor i in range(len(s)):\n\tif s[i]==t[len(t)-1-i]:\n\t\tk+=1\nif k==len(s) and k==len(t):\n\tprint('YES')\nelse:\n\tprint('NO')\n", "def translation(word, wordr):\r\n if word[::-1] != wordr:\r\n return 'NO'\r\n else:\r\n return 'YES'\r\n\r\n\r\na = input()\r\nb = input()\r\nprint(translation(a, b))\r\n", "s1 = input()\r\ns2 = list(input())\r\n\r\nif list(s1) == s2[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\ns1 = str(s)\r\ns_rev = reversed(s1)\r\n\r\nif \"\".join(s_rev) == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nfor c in range(len(t)):\r\n reverse=\"\".join(t[::-1])\r\nif(s==reverse):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word=input()\ntrans=input()\nc=len(word)\nc2=len(trans)-1\ni=0\nfor x in range (len(word)):\n\tif word[x]==trans[c2]:\n\t\ti+=1\n\t\tc2-=1\nif i>=len(word):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\n\t \t \t \t\t\t\t \t\t\t\t \t\t \t", "import sys\r\n\r\n# testcases = int(sys.stdin.readline().strip())\r\n# n = int(sys.stdin.readline().strip())\r\n# input = list(map(int, sys.stdin.readline().strip().split()))\r\ns = sys.stdin.readline().strip()\r\nt = sys.stdin.readline().strip()\r\n\r\nif s[::-1] == t:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")", "#Codeforces\n# A 41 Translation\n\nwordS = input()\nwordT = input()\n\n#Create emtpy list, fill it with letters of word T, use reverse method on list \nreverseT = []\n\nfor letter in wordT:\n reverseT.append(letter)\nreverseT.reverse()\n\n\nif \"\".join(reverseT) == wordS:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n", "name1 = input()\r\nname2 = input()\r\ndef find(name1, name2):\r\n \r\n len1 = len(name1)\r\n len2 = len(name2)\r\n \r\n if(len1!=len2):\r\n return \"NO\"\r\n \r\n for i in range(0,len1):\r\n if(name1[i]!=name2[len1-i-1]):\r\n return \"NO\"\r\n \r\n \r\n return \"YES\"\r\n \r\nf=find(name1,name2)\r\nprint(f)", "a = input()\nr = input()\ns =''\ni = len(a)\n\nwhile i>0 :\n s = s+a[i-1]\n i -= 1\n\nif r == s:\n print('YES')\nelse:\n print('NO')\n", "N = input()\r\nY = input()\r\nif N[::-1] == Y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\nc=\"\"\r\nfor i in reversed(b):\r\n c=c+i\r\nif c==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "li=input()\nl=input()\nn=len(l)\nr=''\nfor i in range(n):\n r=r+l[n-i-1]\nif(li==r):\n print('YES')\nelse:\n print('NO')", "a = input();\r\nb = input();\r\nc = a[-1:-len(a)-1:-1];\r\nif(c==b): print(\"YES\");\r\nelse: print(\"NO\");", "w = input()\r\ns = input()\r\n\r\nt = w[::-1]\r\n\r\nr = True\r\n\r\nfor i in range(len(s)):\r\n\r\n if not s[i] == t[i]:\r\n\r\n r = False\r\n\r\n break\r\n\r\nif r: print('YES')\r\nelse: print('NO')", "def reversing(s, t):\r\n if t == s[::-1]:\r\n return \"YES\"\r\n return \"NO\"\r\n\r\n\r\nm = input()\r\nn = input()\r\nprint(reversing(m, n))\r\n", "s, tr = list(input()), input()\r\n\r\nprint(\"YES\" if s == list(reversed(tr)) else \"NO\")\r\n", "s = input()\r\nt = input()\r\na = [c for c in s]\r\na.reverse()\r\na = \"\".join(a)\r\nif a == t:\r\n print('YES')\r\nelse: print('NO')", "s=input()\r\ns_c=s[::-1]\r\nc=input()\r\nif s_c==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = list(input())\nt = input()\nn = len(s)\nfor i in range(n//2):\n temp = s[i]\n s[i] = s[n - (i+1)]\n s[n - (i+1)] = temp\nnew_s = ''.join(map(str, s))\nif t == new_s:\n print('YES')\nelse:\n print('NO')\n\n", "import sys\r\n\r\n\r\n#sys.stdin = open(\"input.txt\", \"r\")\r\n#sys.stdout = open(\"output.txt\", \"w\")\r\n\r\n\r\ndef main():\r\n m = sys.stdin.readline().rstrip()\r\n n = sys.stdin.readline().rstrip()\r\n if m[0::] == n[::-1]:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "s = str(input())\r\na = str(input())\r\nn = len(s)\r\nk = len(a)\r\nq=0\r\nif(n!=k):\r\n print(\"NO\")\r\nelse:\r\n for i in range(n):\r\n if(s[i]==a[(n-1)-i]):\r\n q+=1\r\n if(q==n):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "print('YES' if input().strip()[::-1]==input().strip() else 'NO')", "word_s = input()\nword_t = input()\n\nlen_word_s = len(word_s)\n\ncount = 0\nif(len_word_s != len(word_t)):\n print(\"NO\")\nelse:\n for i in range(len_word_s):\n if(word_s[len_word_s-i-1] == word_t[i]):\n count += 1\n \n if(count == len_word_s):\n print(\"YES\")\n else:\n print(\"NO\")\n", "s=input()\r\nt=input()\r\ncount=len(t)\r\nfor i in s:\r\n if i!=t[count-1]:\r\n print(\"NO\")\r\n break\r\n else:\r\n count-=1\r\nif count==0:\r\n print(\"YES\")\r\n", "s = str(input())\r\nt = str(input())\r\n\r\nif s == t[::-1]:\r\n print(\"YES\")\r\n raise SystemExit\r\n\r\nprint(\"NO\")\r\n", "s=input()\r\nb=input()\r\nr=s[::-1]\r\nif r==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\r\n# # # # # # # # x=int(input(\"ГОНИ ЧИСЛО: \"))\r\n# # # # # # # # y=int(input(\"ГОНИ ЧИСЛО: \"))\r\n# # # # # # # # y=int(input(\"ГОНИ ЧИСЛО: \"))\r\n\r\n# # # # # # # # x=0\r\n# # # # # # # # while x<1001:\r\n# # # # # # # # print(x)\r\n# # # # # # # # x=x+1\r\n \r\n# # # # # # # # k=['apple', 'banana', 'orange', 'tomato' ]\r\n# # # # # # # # x=-1\r\n# # # # # # # # while x<=3:\r\n# # # # # # # # print(k[x])\r\n# # # # # # # # x=x-1 \r\n# # # # # # # # k=['apple', 'banana', 'orange', 'tomato' ]\r\n# # # # # # # # x=0\r\n# # # # # # # # while x<=3:\r\n# # # # # # # # print(k[x])\r\n# # # # # # # # x=x+1 \r\n\r\n# # # # # # # # x=input()\r\n# # # # # # # # x=int(x)\r\n# # # # # # # # if x%2==0:\r\n# # # # # # # # print('чётное')\r\n# # # # # # # # else:\r\n# # # # # # # # print('нечётное')\r\n# # # # # # # # import time\r\n# # # # # # # # x=0\r\n# # # # # # # # while x<999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999:\r\n# # # # # # # # print(x)\r\n# # # # # # # # x=x+1\r\n# # # # # # # # time.sleep(1)\r\n\r\n# # # # # # # # x=[12,123,54256,65747,567878967,969,89,8,9087,79,79,0,90,9,909]\r\n# # # # # # # # o=0\r\n# # # # # # # # while o!=14:\r\n# # # # # # # # if x[o]%2==0:\r\n# # # # # # # # print(x[o])\r\n# # # # # # # # o=o+1\r\n\r\n# # # # # # # # x=0\r\n# # # # # # # # while x<5:\r\n# # # # # # # # print(x)\r\n# # # # # # # # x=x+1\r\n\r\n# # # # # # # # x=[1,2,3,4,5,6,7,8,9,0]\r\n# # # # # # # # d=0\r\n\r\n# # # # # # # # while d<=9:\r\n# # # # # # # # print(x[d])\r\n# # # # # # # # d=d+1\r\n\r\n# # # # # # # # x=int(input('Размер твоей ноги с двумя нолями в конце: '))\r\n# # # # # # # # z=int(input('Текущий год: '))\r\n# # # # # # # # c=int(input('Размер ноги и годы жизни вместе: '))\r\n# # # # # # # # print(x-(c-z), 'Год рождения')\r\n\r\n# # # # # # # # x=int(input('Размер твоей ноги с двумя нолями в конце: '))\r\n# # # # # # # # z=int(input('Дата рождения: '))\r\n# # # # # # # # c=int(input('Размер ноги и годы жизни вместе: '))\r\n# # # # # # # # print('Текущий год',z+(c-x))\r\n\r\n# # # # # # # # x=open('100.txt', 'w+')\r\n# # # # # # # # q=0\r\n# # # # # # # # while q!=1:\r\n# # # # # # # # x.write('Hello, world\\n')\r\n# # # # # # # # q+=1\r\n\r\n# # # # # # # # x=int(input('ВВеди число больше 100 000 000 000:'))\r\n# # # # # # # # z=0\r\n# # # # # # # # while z!=x:\r\n# # # # # # # # print('*')\r\n# # # # # # # # z=z+1\r\n\r\n# # # # # # # # n=6471598560786075349010\r\n# # # # # # # # x=1\r\n# # # # # # # # while n>0:\r\n# # # # # # # # x*=n\r\n# # # # # # # # print(x)\r\n# # # # # # # # n-=1\r\n\r\n# # # # # # # # x=input('Выбери мат. действие + - / *')\r\n# # # # # # # # if x=='/':\r\n# # # # # # # # t=input('Скока?')\r\n# # # # # # # # t=int(t)\r\n# # # # # # # # d=input('гони число...')\r\n# # # # # # # # d=int(d)\r\n# # # # # # # # print(t/d)\r\n# # # # # # # # if x=='+':\r\n# # # # # # # # g=input('Скока?')\r\n# # # # # # # # g=int(g)\r\n# # # # # # # # f=input('гони число...')\r\n# # # # # # # # f=int(f)\r\n# # # # # # # # print(g+f)\r\n# # # # # # # # if x=='-':\r\n# # # # # # # # h=input('Скока?')\r\n# # # # # # # # h=int(h)\r\n# # # # # # # # l=input('гони число...')\r\n# # # # # # # # l=int(l)\r\n# # # # # # # # print(h-l)\r\n# # # # # # # # if x=='*':\r\n# # # # # # # # c=input('Скока?')\r\n# # # # # # # # c=int(c)\r\n# # # # # # # # m=input('гони число...')\r\n# # # # # # # # m=int(m)\r\n# # # # # # # # print(c*m)\r\n\r\n# # # # # # # # x=499\r\n# # # # # # # # while x<=1500:\r\n# # # # # # # # print(x)\r\n# # # # # # # # x=x+1\r\n\r\n# # # # # # # # x=input('число...')\r\n# # # # # # # # x=int(x)\r\n# # # # # # # # if x%100==18:\r\n# # # # # # # # print(\"OK\")\r\n# # # # # # # # else:\r\n# # # # # # # # print('not OK')\r\n\r\n# # # # # # # # s=[4,7,12,67,56,45,79]\r\n# # # # # # # # for i in s:\r\n# # # # # # # # if i%2==0:\r\n# # # # # # # # print(i)\r\n\r\n# # # # # # # # g=1\r\n# # # # # # # # x=input('chislo')\r\n# # # # # # # # x=int(x)\r\n# # # # # # # # while x!=0:\r\n# # # # # # # # g*=x\r\n# # # # # # # # x-=1\r\n\r\n\r\n# # # # # # # # x=[2,3,6,7,6,75,7,57,5,7,56,8,74,6,57,5,63,6,5,34]\r\n# # # # # # # # for i in x:\r\n# # # # # # # # if i<3:\r\n# # # # # # # # print(i)\r\n\r\n# # # # # # # # r=''\r\n# # # # # # # # x=\"hello\"\r\n# # # # # # # # y=len(x)-1\r\n# # # # # # # # while y>=0:\r\n# # # # # # # # r+=x[y]\r\n# # # # # # # # y-=1\r\n# # # # # # # # print(r)\r\n\r\n# # # # # # # # x=input('кг')\r\n# # # # # # # # x=int(x)\r\n# # # # # # # # if x%2==0:\r\n# # # # # # # # if (x//2)%2==0:\r\n# # # # # # # # print('Ok')\r\n# # # # # # # # else:\r\n# # # # # # # # print('NET')\r\n# # # # # # # # else:\r\n# # # # # # # # print('NET')\r\n\r\n# # # # # # # # r=''\r\n# # # # # # # # x='hello milonka!'\r\n# # # # # # # # y=len(x)-1\r\n# # # # # # # # while y>=0:\r\n# # # # # # # # if x[y]==\" \":\r\n# # # # # # # # r+=\"_\"\r\n# # # # # # # # y=y-1\r\n# # # # # # # # elif x[y]==\"l\":\r\n# # # # # # # # r+='!'\r\n# # # # # # # # y=y-1\r\n# # # # # # # # else:\r\n# # # # # # # # r+=x[y]\r\n# # # # # # # # y=y-1\r\n# # # # # # # # print(r)\r\n\r\n# # # # # # # # # print('hello, world')\r\n\r\n# # # # # # # # # x=input('гони число:')\r\n# # # # # # # # # y=input(\"а то сожру:\")\r\n# # # # # # # # # x=int(x)\r\n# # # # # # # # # y=int(y)\r\n# # # # # # # # # print(y/x)\r\n\r\n# # # # # # # # # s=input('введи имя:')\r\n# # # # # # # # # print('приятно познакомиться '+s)\r\n\r\n# # # # # # # # # s='3'\r\n# # # # # # # # # print(type(s))\r\n# # # # # # # # # s=int(s)\r\n# # # # # # # # # print(type(s))\r\n\r\n# # # # # # # # # a=input('введи число ')\r\n# # # # # # # # # a=int(a)\r\n# # # # # # # # # b=input('2 число ')\r\n# # # # # # # # # b=int(b)\r\n# # # # # # # # # print(+a+b, a*b, a/b, a-b, a%b, a**b)\r\n\r\n# # # # # # # # # s=0\r\n# # # # # # # # # while s<100:\r\n# # # # # # # # # print(s)\r\n# # # # # # # # # s+=1\r\n\r\n# # # # # # # # # d=input('скока бабла? ')\r\n# # # # # # # # # d=int(d)\r\n# # # # # # # # # print(d//50)\r\n\r\n# # # # # # # # # d=input('скока бабла? ')\r\n# # # # # # # # # d=int(d)\r\n# # # # # # # # # print(d*50)\r\n\r\n# # # # # # # # # x=input('возраст: ')\r\n# # # # # # # # # y=input('число: ')\r\n# # # # # # # # # r=input('месяц: ')\r\n# # # # # # # # # x=int(x)\r\n# # # # # # # # # r=int(r)\r\n# # # # # # # # # y=int(y)\r\n# # # # # # # # # if x<18 or y>31 or r>12:\r\n# # # # # # # # # print('иди нафиг')\r\n# # # # # # # # # elif x>18 and x<40:\r\n# # # # # # # # # print('окей летс го')\r\n\r\n# # # # # # # # # x=input('скока бабла? ')\r\n# # # # # # # # # x=int(x)\r\n# # # # # # # # # if x>1000:\r\n# # # # # # # # # print(\"проходите\")\r\n# # # # # # # # # else:\r\n# # # # # # # # # print('валяй отсюда')\r\n\r\n# # # # # # # # # x=input('тебя ударили')\r\n# # # # # # # # # y=input('что ты сделаешь? ударишь, кинешь в него ручкой или нажалуешься училке?')\r\n# # # # # # # # # w=input('напиши числом')\r\n# # # # # # # # # w=int(w)\r\n# # # # # # # # # if w=1:\r\n# # # # # # # # # print('тебя заново обозвали')\r\n# # # # # # # # # elif w=2:\r\n# # # # # # # # # print('тебя наругала училка')\r\n# # # # # # # # # elif w=3:\r\n# # # # # # # # # print('у тебя всё получилось')\r\n\r\n# # # # # # # # x=int(input())\r\n# # # # # # # # if x==12 or x==1 or x==2:\r\n# # # # # # # # print('zima')\r\n# # # # # # # # elif x==3 or x==4 or x==5:\r\n# # # # # # # # print('vesna')\r\n# # # # # # # # elif x==6 or x==7 or x==8:\r\n# # # # # # # # print('leto')\r\n# # # # # # # # elif x==11 or x==10 or x==9:\r\n# # # # # # # # print('oceni')\r\n\r\n# # # # # # # # x=500\r\n# # # # # # # # c=0\r\n# # # # # # # # while x<=1000:\r\n# # # # # # # # c+=x\r\n# # # # # # # # x+=1\r\n# # # # # # # # print(c)\r\n\r\n# # # # # # # # s=0\r\n# # # # # # # # for i in range(1,6):\r\n# # # # # # # # s+=i\r\n# # # # # # # # print(s)\r\n\r\n# # # # # # # # v=0\r\n# # # # # # # # s=0\r\n# # # # # # # # for i in range(1,1001):\r\n# # # # # # # # if i%2!=0:\r\n# # # # # # # # s+=i\r\n# # # # # # # # if i%2!=0:\r\n# # # # # # # # v+=1\r\n# # # # # # # # print(s/v)\r\n\r\n# # # # # # # # x=0\r\n# # # # # # # # for i in range(1,1001):\r\n# # # # # # # # if i%4==0 and i%5!=0:\r\n# # # # # # # # x+=1\r\n# # # # # # # # print(x)\r\n\r\n# # # # # # # # x=int(input())\r\n# # # # # # # # if x==90:\r\n# # # # # # # # print('pryamoy')\r\n# # # # # # # # elif x<90:\r\n# # # # # # # # print('ostriy')\r\n# # # # # # # # elif x>90:\r\n# # # # # # # # print('typoy')\r\n\r\n# # # # # # # # a=int(input())\r\n# # # # # # # # b=int(input())\r\n# # # # # # # # c=int(input())\r\n# # # # # # # # if c**2==a**2+b**2:\r\n# # # # # # # # print('aboba')\r\n# # # # # # # # else:\r\n# # # # # # # # print('idi naxfig')\r\n\r\n# # # # # # # # x=int(input())\r\n# # # # # # # # while x<20 or x==20:\r\n# # # # # # # # print(x)\r\n# # # # # # # # x=x*3\r\n\r\n# # # # # # # # d=int(input('введите число'))\r\n# # # # # # # # x=(d-1)\r\n# # # # # # # # v=(d+1)\r\n# # # # # # # # print(x*v)\r\n\r\n# # # # # # # # x=int(input())\r\n# # # # # # # # v=int(input())\r\n# # # # # # # # print(x**v)\r\n\r\n# # # # # # # # x=int(input())\r\n# # # # # # # # u=int(input())\r\n# # # # # # # # b=int(input())\r\n# # # # # # # # if x==u==b:\r\n# # # # # # # # print(3)\r\n# # # # # # # # elif x==u or x==b or u==b or b==x:\r\n# # # # # # # # print(2)\r\n# # # # # # # # else:\r\n# # # # # # # # print(0)\r\n\r\n# # # # # # # # x=int(input())\r\n# # # # # # # # if x>1000 and x<=9999:\r\n# # # # # # # # print(4)\r\n# # # # # # # # if x>10000 and x<=99999:\r\n# # # # # # # # print(5)\r\n# # # # # # # # if x==100000:\r\n# # # # # # # # print(6)\r\n\r\n# # # # # # # # k=int(input())\r\n# # # # # # # # n=int(input())\r\n# # # # # # # # print(k//n)\r\n# # # # # # # # print(k%n)\r\n\r\n# # # # # # # # s=0\r\n# # # # # # # # d=int(input())\r\n# # # # # # # # c=(d+1)\r\n# # # # # # # # for i in range(1, c):\r\n# # # # # # # # s+=i\r\n# # # # # # # # print(s)\r\n\r\n# # # # # # # # x=int(input())\r\n# # # # # # # # s=0\r\n# # # # # # # # while x>0:\r\n# # # # # # # # print(s+x%10)\r\n# # # # # # # # s+=x//10\r\n\r\n# # # # # # # # x=int(input())\r\n# # # # # # # # s=0\r\n# # # # # # # # while x>0:\r\n# # # # # # # # s+=x%10\r\n# # # # # # # # x=x//10\r\n# # # # # # # # print(s)\r\n\r\n# # # # # # # # x=int(input())\r\n# # # # # # # # c=int(input())\r\n# # # # # # # # while x>0:\r\n# # # # # # # # print(s*x)\r\n\r\n# # # # # # # # import time\r\n# # # # # # # # x='ugiuirregkweНпнhввавfdFDHFDВРаЖ:'\r\n# # # # # # # # v=0\r\n# # # # # # # # while v<=100:\r\n# # # # # # # # print(x, v, '%')\r\n# # # # # # # # time.sleep(0.1)\r\n# # # # # # # # v+=1\r\n\r\n# # # # # # # # v=0\r\n# # # # # # # # c=0\r\n# # # # # # # # x=input()\r\n# # # # # # # # for i in x:\r\n# # # # # # # # if i=='D':\r\n# # # # # # # # c+=1\r\n# # # # # # # # elif i=='A':\r\n# # # # # # # # v+=1\r\n# # # # # # # # if c>v:\r\n# # # # # # # # print('D')\r\n# # # # # # # # elif v>c:\r\n# # # # # # # # print('A')\r\n\r\n# # # # # # # # a=int(input())\r\n# # # # # # # # b=int(input())\r\n# # # # # # # # c=int(input())\r\n# # # # # # # # if a+b==c or a+c==b or b+c==a:\r\n# # # # # # # # print(\"lox\")\r\n# # # # # # # # else:\r\n# # # # # # # # print('ne lox')\r\n\r\n# # # # # # # x=input()\r\n# # # # # # # if 'y' in x and 'e' in x and 's' in x:\r\n# # # # # # # print('hernia')\r\n# # # # # # # else:\r\n# # # # # # # print('net')\r\n\r\n# # # # # # v=0\r\n# # # # # # c=(input())\r\n# # # # # # for i in c:\r\n# # # # # # if i=='7' or i=='4':\r\n# # # # # # v+=1\r\n# # # # # # if v==4 or v==7:\r\n# # # # # # print('hernia.02')\r\n# # # # # # else:\r\n# # # # # # print('Idyot petya')\r\n\r\n# # # k=int(input())\r\n# # # x=[1,2,4,6,8,9,12,14,18]\r\n# # # l=0\r\n# # # r=len(x)-1\r\n# # # while x[r]+x[l]!=k:\r\n# # # if x[l]+x[r]>k:\r\n# # # r-=1\r\n# # # elif x[l]+x[r]<k:\r\n# # # l+=1\r\n# # # print(l,r)\r\n\r\n# # # # x=[1,2,4,6,8,9,12,14,18]\r\n# # # # l=0\r\n# # # # r=1\r\n# # # # while r<=8:\r\n# # # # print(x[l],x[r])\r\n# # # # l+=1\r\n# # # # r+=1\r\n\r\n# # # x=[1,2,4,6,8,9,12,14,18]\r\n# # # for i in range(len(x)): \r\n# # # print(x[i],x[i+1])\r\n\r\n# # # # x=[1,2,1,1]\r\n# # # # r=1\r\n# # # # l=0\r\n\r\n# # # # x={}\r\n\r\n# # # # x['a']=5\r\n# # # # x[\"t\"]=6\r\n# # # # if 'a' in x:\r\n# # # # print(\"ok\")\r\n\r\n# # # s={}\r\n# # # x='khjhjassddasdfttfd'\r\n# # # for i in x:\r\n# # # if i not in s:\r\n# # # s[i]=0\r\n# # # s[i]+=1\r\n# # # for i in s:\r\n# # # print(i,s[i])\r\n\r\n\r\n# # # a=[-5, -6, -7,-8,-3,-5]\r\n# # # q=a[0]\r\n# # # for i in a:\r\n# # # if i>q:\r\n# # # q=i\r\n# # # print(q)\r\n\r\n# x=input()\r\n# s={}\r\n# q=0\r\n# for i in x:\r\n# if i not in s:\r\n# s[i]=0\r\n# s[i]+=1\r\n# for i in s:\r\n# print()\r\n\r\n# # # x = input()\r\n# # # if 'Y' in x or 'y' in x and 'E' in x or 'e' in x and 'S' in x or 's' in x:\r\n# # # print('yes')\r\n# # # else:\r\n# # # print('no')\r\n\r\n# # # s=input()\r\n# # # s=s.upper()\r\n# # # if 'Y' in s and 'E' in s and 'S' in s:\r\n# # # print('yes')\r\n# # # else:\r\n# # # print('no')\r\n\r\n# # # v=0\r\n# # # k=0\r\n# # # x=input()\r\n# # # x=x.upper()\r\n# # # for i in x:\r\n# # # if i ==\"J\":\r\n# # # k+=1\r\n# # # if i ==\"K\":\r\n# # # v+=1\r\n# # # print('j', k)\r\n# # # print('k', v)\r\n\r\n# # # x=input()\r\n# # # print(x[len(x)//2])\r\n\r\n# y=input()\r\n# s=len(y)-1\r\n# while s>=0:\r\n# print(y[s])\r\n# s-=1\r\n\r\n# # # p=\"jhjgguytyrtsweshuiioujihuihuihuihuih\"\r\n# # # k=0\r\n# # # p=p.upper()\r\n# # # for i in p:\r\n# # # if i ==\"H\":\r\n# # # k+=1 \r\n# # # print('H', k)\r\n\r\n# # # x=\"jhjgguytyrtsweshuiioujihuihuihuihuih\"\r\n# # # for i in range(len(x)-1): \r\n# # # print(x[i],x[i+1])\r\n\r\n# # # x=[4,5,3,45,6,53,67,43,42,78]\r\n# # # for i in range(len(x)-1): \r\n# # # print(x[i],x[i+1])\r\n\r\n# # # x=int(input())\r\n# # # c=x//10000 \r\n# # # v=x//1000%10\r\n# # # b=x//100%10\r\n# # # n=x//10%10\r\n# # # m=x%10\r\n# # # print(c+v+b+n+m)\r\n\r\n# # # x=int(input())\r\n# # # x1=x//100000\r\n# # # x2=x//10000%10\r\n# # # x3=x//1000%10\r\n# # # x4=x//100%10\r\n# # # x5=x//10%10\r\n# # # x6=x%10\r\n# # # if x1+x2+x3==x4+x5+x6:\r\n# # # print('UwU')\r\n# # # else:\r\n# # # print('Ne UwU')\r\n\r\n# # # x=input()\r\n# # # a=0\r\n# # # o=0\r\n# # # x=x.upper()\r\n# # # for i in x:\r\n# # # if i=='A':\r\n# # # a+=1\r\n# # # if i=='O':\r\n# # # o+=1\r\n# # # if a%2==0 and o%2!=0:\r\n# # # print('UwU')\r\n# # # else:\r\n# # # print('Ne UwU')\r\n\r\n# # # import random\r\n# # # x=random.randint(1,3)\r\n# # # print(\r\n# # # \"\"\"введи число от 1 до 3 \r\n# # # камень-1\r\n# # # ножницы-2\r\n# # # бумага-3\r\n# # # \"\"\"\r\n# # # )\r\n# # # c=int(input())\r\n# # # if c==x:\r\n# # # if x==1 and c==1: \r\n# # # print(' Комп: Камень<<', '>>ты: Камень')\r\n# # # if x==2 and c==2: \r\n# # # print(' Комп: Ножницы<<', '>>ты: Ножницы')\r\n# # # if x==3 and c==3: \r\n# # # print(' Комп: Бумага<<', '>>ты: Бумага')\r\n# # # print(' Ничья')\r\n# # # if x==1 and c==2 or x==3 and c==1 or x==2 and c==3:\r\n# # # if x==1 and c==2: \r\n# # # print(' Комп: Камень<<', '>>ты: Ножницы')\r\n# # # if x==3 and c==1:\r\n# # # print(' Комп: Бумага<<', '>>ты: Камень') \r\n# # # if x==2 and c==3: \r\n# # # print(' Комп: Ножницы<<', '>>ты: Бумага') \r\n# # # print(' Прогрыш')\r\n# # # if c==1 and x==2 or c==3 and x==1 or c==2 and x==3:\r\n# # # if c==1 and x==2:\r\n# # # print(' Комп: Ножницы<<', '>>ты: Камень')\r\n# # # if c==3 and x==1:\r\n# # # print(' Комп: Камень<<', '>>ты: Бумага')\r\n# # # if c==2 and x==3:\r\n# # # print(' Комп: Бумага<<', '>>ты: Ножницы')\r\n# # # print(' Выйгрыш')\r\n\r\n# # # c=0\r\n# # # x=[4,5,3,45,6,53,67,43,42,78]\r\n# # # for i in range(len(x)-1): \r\n# # # if x[i]*x[i+1]%3==0:\r\n# # # c+=1\r\n# # # print(c)\r\n\r\n# # # c=0\r\n# # # x=[1,2,3,4,2,4,3,2]\r\n# # # for i in range(len(x)-1):\r\n# # # if x[i]-x[i-1]-x[i-2]%2==0:\r\n# # # c+=1\r\n# # # print(c)\r\n\r\n# v=1\r\n# x=int(input())\r\n# c=0\r\n# while c<x:\r\n# c+=1\r\n# v*=c \r\n# print(v)\r\n\r\n# # a=int(input())\r\n# # b=int(input())\r\n# # c=int(input())\r\n# # if a+b==c or a+c==b or b+c==a:\r\n# # print('YES')\r\n# # else:\r\n# # print('NO')\r\n\r\n# a=0\r\n# x=input()\r\n# d=len(x)//2\r\n# for i in x:\r\n# if i==\"a\":\r\n# a+=1\r\n# if a>d:\r\n# print('Yes')\r\n# else:\r\n# print(\"No\")\r\n\r\n# hl=0\r\n# sl=input()\r\n# for i in sl:\r\n# if i=='4' or i=='7':\r\n# hl+=1\r\n# if hl==4 or hl==7:\r\n# print('Yes')\r\n# else:\r\n# print('No')\r\n\r\n# c=0\r\n# x=input()\r\n# for i in x:\r\n# i=int(i)\r\n# if i%2==0:\r\n# c+=i\r\n# print(c)\r\n\r\n# a=int(input())\r\n# b=int(input())\r\n# c=int(input())\r\n# if a==b or c==a or b==c: \r\n# if a==b and a==c:\r\n# print(3)\r\n# else:\r\n# print(2)\r\n# else:\r\n# print(0)\r\n\r\n# o=0\r\n# x=[7,500,60,120,65,90]\r\n# x=str(x)\r\n# for i in x:\r\n# if i=='0':\r\n# o+=1\r\n# print(o)\r\n\r\n# v=0\r\n# x=0\r\n# while x<1000:\r\n# if x%3==0: \r\n# print(v)\r\n# v+=x\r\n# x+=1\r\n\r\n# o=0\r\n# l=0 \r\n# x=input()\r\n# for i in x:\r\n# if i=='0':\r\n# o+=1\r\n# elif i=='1':\r\n# l+=1\r\n# print('0', o)\r\n# print('1', l)\r\n\r\n# v=1\r\n# x=int(input())\r\n# c=0\r\n# while c<x:\r\n# c+=1\r\n# v*=c \r\n# print(v)\r\n\r\n# x=input()\r\n# s={}\r\n# q=0\r\n# for i in x:\r\n# if i not in s:\r\n# s[i]=0\r\n# s[i]+=1\r\n# max=0\r\n# name=\"\"\r\n# for i in s:\r\n# if max<s[i]:\r\n# max=s[i]\r\n# name=i\r\n# print(name, 'Встречается', max, \"раз\")\r\n\r\n# t=int(input())\r\n# for i in range(t):\r\n# # a,b,c=[int(i) for i in input().split(\" \")]\r\n# # if a+b==c or a+c==b or c+b==a:\r\n# # print(\"YES\")\r\n# # else:\r\n# # print(\"NO\")\r\n\r\n# s=int(input())\r\n# for i in range(s):\r\n# a,b,c,d=[int(i) for i in input().split(\" \")]\r\n# w=[b,c,d]\r\n# count=0\r\n# for j in w:\r\n# if a<j:\r\n# count+=1\r\n# print(count)\r\n\r\n# x=0\r\n# t=int(input())\r\n# for i in range(t):\r\n# s=input()\r\n# if s==\"Tetrahedron\":\r\n# x+=4\r\n# if s=='Cube':\r\n# x+=6\r\n# if s=='Octahedron':\r\n# x+=8\r\n# if s=='Dodecahedron':\r\n# x+=12\r\n# if s=='Icosahedron':\r\n# x+=20\r\n# print(x) \r\n\r\nn = input()[::-1]\r\nrn=input()\r\nif n==rn:\r\n print('YES')\r\nelse:\r\n print('NO')", "l=input()\r\ns=input()[-1::-1]\r\nprint('YES' if s==l else 'NO')\r\n\r\n", "n,m=input(),input()\r\nif n==m[::-1]: print('YES')\r\nelse: print('NO')", "a = input()\r\nb = input()\r\n\r\nx = b[::-1]\r\nans = 'NO'\r\nif x == a:\r\n ans = 'YES'\r\n\r\nprint(ans)", "n = input()\r\nm = input()\r\nprint('YES' if n == m[::-1] else 'NO')", "s=input()\r\ns1=input()\r\nr=s1[::-1]\r\nif(s==r):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=str(input())\r\nb=str(input())\r\nlista=list(a)\r\nlistb=list(b)\r\nlista.reverse()\r\nif lista==listb:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = ''.join(reversed(list(input())))\r\n\r\nprint('YES' if s == t else 'NO')", "t=input()\ns=input()\nfor i in range(len(t)):\n\tp=t[::-1]\nif p==s:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "s = input()\r\nt = input()\r\nans = \"\"\r\nfor i in range(len(s)):\r\n if(s[i] == t[len(t)-i-1]):\r\n ans += \"YES\"\r\n else:\r\n ans += \"NO\"\r\n \r\nif \"NO\" in ans:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "s = input().strip()\r\nt = input().strip()\r\n\r\nsl = len(s)\r\ntl = len(t)\r\nnt = ''\r\n\r\nif sl == tl:\r\n\tfor i in range(tl-1, -1, -1):\r\n\t\tnt += t[i]\r\n\tif s == nt:\r\n\t\tprint('YES')\r\n\telse:\r\n\t\tprint('NO')\r\nelse:\r\n\tprint('NO')", "s = str(input())\nt = list(str(input()))\nt.reverse()\nt = ''.join(t)\nif s == t:\n print('YES')\nelse:\n print('NO')\n", "\r\nfirstword=input()\r\nsecondword=input()\r\n\r\nsortedword=secondword[::-1]\r\n\r\nif firstword==sortedword:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x = str(input())\r\nz = str(input())\r\nif z == ''.join(reversed(x)): print(\"YES\")\r\nelse : print (\"NO\")", "def batao(a,b):\r\n b.reverse()\r\n if a==b:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\na= list(input())\r\nb= list(input())\r\nprint(batao(a,b))", "s = str(input())\r\nt = str(input())\r\n\r\ntranslation = \"\"\r\nfor i in range(0,len(s)):\r\n translation += s[len(s)-i-1]\r\n\r\nif t == translation:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "word=input()\r\nword2=word[(len(word)-1)::-1]\r\nif input()==word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\ncomp = ''\nfor i in range(len(s) - 1, -1, -1):\n\tcomp = comp + s[i]\nif comp == t:\n\tprint('YES')\nelse: \n\tprint('NO')\n\t\t\t \t \t \t\t\t\t \t \t\t \t \t\t\t\t\t\t\t", "'''\r\nAuthor : InHng\r\nLastEditTime : 2023-09-29 23:05:39\r\n'''\r\nprint(\"YES\" if input() == input()[::-1] else \"NO\")\r\n", "def reversal(n,j):\r\n if (j==n[::-1]):\r\n print('YES')\r\n else:\r\n print('NO')\r\nn=input()\r\nj=input()\r\nreversal(n,j)\r\n", "def result(m,n):\n\ta=m[::-1]\n\tif a==n:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n\n\n\n\nm=input()\nn=input() \nresult(m,n)\n", "def code(s,t):\r\n if s==t[::-1]:\r\n return \"YES\"\r\n return \"NO\"\r\ns=input()\r\nt=input()\r\nprint(code(s,t))", "n = list(word for word in input())\r\nq = list(w for w in input())\r\nif n[::-1] == q:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "worda=input()\r\nwordb=input()\r\nif(worda[::-1]==wordb):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str3=input()\nstr1=input()\nstr2=str3[::-1]\nif str2==str1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "# -*- coding:utf-8 -*-\r\n\r\ns = str(input())\r\nt = str(input())\r\n\r\nls = list(s)\r\nlt = list(t)\r\n\r\na = 0\r\n\r\nif len(s) == len(t) and 0 < len(s) <= 100 and 0 < len(t) <= 100:\r\n for i in range(len(s)):\r\n if s[i] == t[len(s)-i-1]:\r\n a += 1\r\n\r\n if a == len(s):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\nb=input()\n\nflag=0\nx=len(a)\ny=len(b)\n\nif(x!=y):\n print('NO')\nelse:\n for i in range(x):\n if(a[i]!=b[(x-1)-i]):\n flag=1\n break\n\n if(flag):\n print('NO')\n else:\n print('YES')\n", "s=input()\r\nt=input()\r\nn=\"\"\r\nfor i in t:\r\n n=i+n\r\nif s==n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t = input()\r\ns = input()\r\nn = len(s) -1\r\nfor i in range(len(t)):\r\n\r\n if t[i] == s[n]:\r\n m = 1\r\n else:\r\n m = 0\r\n break\r\n n = n - 1\r\nif m == 0 :\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "s=input()\r\nt=input()\r\ndef reverse(string):\r\n string=list(string)\r\n string.reverse()\r\n return \"\".join(string)\r\nif t==reverse(s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nprint(\"YES\" if s[-1::-1]==t else \"NO\")", "s = input()\r\nt = input()\r\nr = ''\r\nfor i in s:\r\n r = i + r\r\nif r==t: print('YES')\r\nelse: print('NO')", "t = input()\r\nlst = list(input())\r\nlst.reverse()\r\nlst = \"\".join(lst)\r\nif t==lst:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = input()\r\nm = input()\r\nn = n.lower()\r\nm = m.lower()\r\nx = m[::-1]\r\nif n==x:\r\n print('YES')\r\nelse:\r\n print('NO')", "word = input()\r\nreversed_word = input()\r\n\r\ncorrect_reversed_word = word[::-1]\r\n\r\nif reversed_word == correct_reversed_word:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s, t = [list(input()), list(input())]\r\nt.reverse()\r\nprint(['NO', 'YES'][s == t])", "str0 = input()\r\nstr1 = input()\r\nrev_str0 = (list(reversed(str0)))\r\nif str1 == ''.join(rev_str0):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#translation\r\ns=input()\r\nt=input()\r\nif t[-1::-1]==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\ndef reverse(s):\r\n return \"\".join(reversed(s))\r\nreverse2 = reverse(t)\r\nif s == reverse2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nn=input()\r\nm=0\r\nif(len(n)==len(s)):\r\n for i in range(len(s)):\r\n if(s[i]!=n[len(s)-i-1]):\r\n print('NO')\r\n m=1\r\n break\r\n if(m==0):\r\n print('YES')\r\nelse:\r\n print('NO')", "word1 = input()\nword2 = input()\n\ncorrect_word = word1[::-1]\n\nif word2 == correct_word:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "# Translation\no = input()\nt = input()\nif (o[::-1] == t):\n print(\"YES\")\nelse:\n print(\"NO\")", "def reverse(s):\n str = \"\"\n for i in s:\n str = i + str\n return str\n\ns = input()\ns = reverse(s)\nt = input()\n\nif s == t :\n print(\"YES\")\nelse :\n print(\"NO\")\n\n\t \t \t\t\t\t \t \t \t\t \t \t \t", "a=input()\r\np=input()\r\nb=len(a)\r\nc=a[::-1]\r\nif p==c:\r\n print('YES')\r\nelse:\r\n print('NO')", "h=input()\r\no=input()\r\nif h==o[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = input()\ntranslation = input()\n\nif word[-1::-1] == translation:\n print('YES')\nelse:\n print('NO')", "s = input()\r\nans = input()\r\ntrue = s[::-1]\r\nif ans == true :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n", "# https://codeforces.com/problemset/problem/41/a\n# CodeForces submission by Raphaël \"Scoone\" Chauveau\n\n\ndef main():\n normal = input()\n reversed = input()\n\n nlen = len(normal)\n if nlen != len(reversed):\n print('NO')\n return\n\n for i in range(nlen):\n if normal[i] != reversed[nlen - i - 1]:\n print('NO')\n return\n print('YES')\n\n\nif __name__ == '__main__':\n main()\n", "def main():\r\n s=input()\r\n st=input()\r\n if s==st[::-1]:\r\n print('YES')\r\n return\r\n print('NO')\r\n \r\n \r\n \r\n\r\n \r\nmain()", "a = input()\nb = input()\nif b == a[::-1]: print(\"YES\")\nelse: print(\"NO\")\n", "t=input()\r\ns=input()\r\nn=len(t)\r\nc=0\r\nif n==len(s):\r\n\tfor i in range(n):\r\n\t\tif t[i]==s[n-1-i]:\r\n\t\t\tc+=1\r\n\tif c==n:\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")\r\nelse:\r\n\tprint(\"NO\")\r\n\r\n\t\t \t \t\t\t \t \t \t\t \t\t \t\t \t", "s = input()\nt = input()\nx = s[::-1]\nif x==t:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "berland=input()\r\nbirland=input()\r\nprint('YES') if birland==berland[::-1] else print('NO')", "x = (input())\r\ny = (input())\r\n\r\ns1 = x[::-1]\r\ns2 = y[::-1]\r\n\r\nif s1 == y or s2 == x:\r\n print(\"YES\")\r\n# elif s1 != y or s2 != x:\r\n# print(\"NO\")\r\nelse:\r\n print(\"NO\")", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Mar 30 16:33:31 2022\n\n@author: ivcha\n\"\"\"\nn=input()\nm=input()\narr1=[]\narr2=[]\nfor char in n:\n arr1.append(char)\nfor char in m:\n arr2.append(char)\n \narr2.reverse()\n\nif arr1==arr2:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Aug 29 10:33:30 2023\r\n\r\n@author: HyFlu\r\n\"\"\"\r\n\r\nbefore=list(input())\r\nafter=list(input())\r\nbefore.reverse()\r\nif after==before:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\nt1 = \"\"\r\n\r\nl = len(s)\r\nls = list(s)\r\n\r\nfor i in range(0,l):\r\n t1 += str(ls[l - 1 - i])\r\n\r\nif t == t1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nm = t[::-1]\r\nif s == m:\r\n print(\"YES\")\r\nif s != m:\r\n print(\"NO\")", "def reverse_word(word):\n reverse = \"\"\n for i in range(len(word)):\n reverse += word[len(word) - 1 - i]\n return reverse\n\n\ndef main():\n ber_word = input()\n bir_word = input()\n\n if reverse_word(ber_word) == bir_word:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nif __name__ == \"__main__\":\n main()\n", "a, b = input(), input()\nprint(\"YES\" if a[::-1] == b or a == b[::-1] else \"NO\")", "x = input()\ny = input()\nif(x==y[::-1]):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "k=input;print(\"YNEOS\"[k()!=k()[::-1]::2])", "og = list(input())\r\nog.reverse()\r\ncom = list(input())\r\nif og == com:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "print(('NYOE S')[input()==input()[::-1]::2])", "a=input()\r\nb=input()\r\ns=''\r\nfor i in range(len(b)):\r\n\ts+=b[len(b)-i-1]\r\nif a==s:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')\t", "z=input()\r\nx=list(input())\r\nx.reverse()\r\nif list(z)==x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\ns2=input()\r\ns3=list(s)\r\ns1=\"\"\r\nfor i in range(len(s3)-1,-1,-1):\r\n s1=s1+s3[i]\r\nif(s2==s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def main():\n s, t = input(), input()\n\n if len(s) != len(t):\n print(\"NO\")\n else:\n n = len(s)\n\n for i in range(n):\n if s[i] != t[n - i - 1]:\n print(\"NO\")\n return\n\n print(\"YES\")\n\nif __name__ == \"__main__\":\n main()\n", "s=input()\nt=input()\ncount=0\nfor i in range(len(s)):\n\tif s[i]==t[len(t)-i-1]:\n\t\tcount+=1\nif count==len(s):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n \t\t\t\t \t\t \t \t\t \t\t \t\t \t\t\t\t", "n=input()\r\nm=input()\r\nn1=[]\r\nfor x in n:\r\n n1.insert(0, x)\r\n\r\nn=\"\".join(n1)\r\nif m==n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nfor i in range(1,len(t)+1):\r\n if t[len(t)-i] != s[i-1]:\r\n print(\"NO\")\r\n break\r\nelse:\r\n print(\"YES\")", "def birlandish():\r\n\ts = input()\r\n\tt = input()\r\n\tr = ''\r\n\tfor i in range (len(s)):\r\n\t\tr += s[len(s) - i - 1]\r\n\t\r\n\tif r == t:\r\n\t\treturn 'YES'\r\n\treturn 'NO'\r\n\r\nprint(birlandish())", "a = input()\nb = input()\nif len (a) != len(b):\n print('NO') \n exit()\nfor i in range(len(a)):\n if a [i] != b[len(a)-1-i]:\n print('NO') \n exit()\n\nprint('YES')\n\t\t\t\t\t \t \t \t \t\t\t \t\t\t", "\r\n\r\n\r\ndef i():\r\n return(int(input()))\r\ndef l():\r\n return(list(map(int,input().split())))\r\ndef s():\r\n s = input()\r\n return(s)\r\ndef sl():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef m():\r\n return(map(int,input().split()))\r\n\r\nt = s()\r\ntt = s()\r\no = ''\r\n\r\nfor i in range(len(t) - 1, -1, -1):\r\n o += t[i]\r\nif o == tt:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "string1 = input()\r\nstring2 = input()\r\navail = 0\r\nif len(string1) != len(string2):\r\n print(\"NO\")\r\nelse:\r\n n = len(string1)\r\n for i in range(0, n):\r\n if string1[i] != string2[n-1-i]:\r\n avail = 1\r\n print(\"NO\")\r\n break\r\n\r\n if avail == 0:\r\n print(\"YES\")\r\n", "s=str(input())\r\nt=str(input())\r\nx=s[::-1]\r\nc=0\r\nfor i in range(len(s)):\r\n if x[i]==t[i]:\r\n c+=1\r\n else:\r\n c=-1\r\n break;\r\nif c>=1:\r\n print(\"YES\")\r\nif c<=-1:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nif len(s) != len(t): print(\"NO\")\r\nelse:\r\n f = 1\r\n for i in range(0, len(s)):\r\n if s[i] != t[len(s)-1-i]:\r\n f = 0\r\n break\r\n if f: print(\"YES\")\r\n else: print(\"NO\")\r\n", "n = input()\r\nm = input()\r\nif n[::-1] == m :\r\n print (\"YES\")\r\nelse :\r\n print (\"NO\")", "def reverse(t, s):\r\n rev = \"\"\r\n for i in t:\r\n rev = i + rev\r\n if rev == s:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nif __name__ == \"__main__\":\r\n s = input()\r\n t = input()\r\n reverse(t, s)", "def main():\r\n ap = \"\"\r\n bs = \"\"\r\n ap = input()\r\n bs = input()\r\n ct = \"YES\"\r\n csz = len(ap)\r\n\r\n if csz == len(bs):\r\n for ice_cream in range(csz):\r\n if ap[ice_cream] != bs[csz - 1 - ice_cream]:\r\n ct = \"NO\"\r\n break\r\n else:\r\n ct = \"NO\"\r\n \r\n print(ct)\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "s1=input()\r\ns2=input()\r\ns2=list(map(str,s2))\r\ns2.reverse()\r\ns2=\"\".join(s2)\r\nif(s2==s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nk=input()\r\nt=[]\r\nfor b in a :\r\n t.append((b))\r\nt.reverse()\r\nz=\"\".join(t)\r\nif z ==k :\r\n print('YES')\r\nelse:\r\n print(\"NO\")", "s=list(map(str,input())) \r\nt=list(map(str,input()))\r\nl=len(t)\r\nw=[]\r\nc=0\r\nif len(s)!=len(t):\r\n print(\"NO\")\r\nelse:\r\n for i in range(1,l+1):\r\n w.append(t[-i])\r\n for i in range(len(s)):\r\n if s[i]==w[i]:\r\n c+=1\r\n if c==len(s):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "v=input\r\nprint(\"YNEOS\"[v()!=v()[::-1]::2])", "a=input()\r\nb=input()\r\nr = \"YES\" if a[::-1] == b else \"NO\"\r\nprint(r)", "def rev(x):\r\n return x[::-1]\r\ns = str(input())\r\ns = rev(s)\r\nt = str(input())\r\nif t==s :\r\n\tprint(\"YES\")\r\nelse :\r\n\tprint(\"NO\") ", "t=str(input())\r\ns=str(input())\r\nd=t[::-1]\r\nif s==d:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "word = input()\r\nword = word[::-1]\r\n\r\nnext_input = input()\r\nif word == next_input:\r\n print(\"YES\")\r\nelse: \r\n print(\"NO\")", "#!/usr/env python3.9.1\n\ns = input()\nt = input()\n\nif (t[::-1] == s):\n\tprint('YES')\nelse:\n\tprint('NO')", "word = input()\r\nopposite = input()\r\n\r\nresult = 0\r\n\r\nfor x in range(len(word)):\r\n y = len(opposite) - 1 - x\r\n if word[x] == opposite[y]:\r\n result += 1\r\n\r\nif result == len(word):\r\n print(\"YES\")\r\nelse:\r\n print('NO')\r\n", "a = str(input())\r\nc = str(input())\r\nb = a[::-1]\r\nif(b==c):\r\n\tprint (\"YES\")\r\nelse:\r\n\tprint (\"NO\")\r\n", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[1]:\n\n\na=input()\nb=input()\nsr=''\nfor i in range(0,len(a),1):\n sr=a[i]+sr\nif b==sr:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n# In[ ]:\n\n\n\n\n", "s0=input()\r\ns=input()\r\ns1=s[::-1]\r\nif s0==s1:\r\n print('YES')\r\nelse:\r\n print('NO')", "s1 = list(map(str, input()))\r\ns2 = list(map(str, input()))\r\n\r\ns1.reverse()\r\n\r\nif s1 == s2:\r\n print('YES')\r\n\r\nelse:\r\n print('NO')\r\n", "be=input()\r\nbi=input()\r\nif(be[::-1]==bi):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "h = {True: \"YES\", False: \"NO\"}\r\ns = list(input())\r\ns2 = list(input())\r\ns2.reverse()\r\nprint(h[s == s2])\r\n", "s1 = input()\r\ns2 = input()\r\nprint(\"YES\") if s1 == s2[::-1] else print(\"NO\")", "s=input()\r\nt=input()\r\nw=t[::-1]\r\nif w==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nflag = 0\r\nfor i in range( len ( s ) ):\r\n if( s[ i ] != t [ len(t) - 1 - i ] ):\r\n flag = 1\r\n break\r\nif( flag == 0 ):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\"\"\" Translation \"\"\"\r\ns = input()\r\nt = input()\r\nans = 'YES' if s == t[::-1] else 'NO'\r\nprint(ans)", "i = list(input())\r\ng = list(reversed(list(input())))\r\nif i == g:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a=input()\r\nb=input()\r\nb=list(b)\r\na=list(a)\r\nc=a[::-1]\r\nif b==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input();b=input();print('YES' if a[::-1] == b else 'NO')", "x=input()\r\ny=input()\r\nn=len(x)\r\nm=len(y)\r\nq=0\r\nif(n!=m):print(\"NO\")\r\nelse:\r\n for i in range(n):\r\n if(x[i]!=y[n-1-i]):\r\n q=1\r\n print(\"NO\")\r\n break\r\n if(q==0):print(\"YES\")", "s=input()\r\nl=input()\r\nprint(\"YES\"if(s==l[::-1])else\"NO\")", "\ndef perevorot(t):\n return t[::-1]\n\n\nif __name__ == '__main__':\n s=str(input())\n t=str(input())\n if s==perevorot(t):\n print('YES')\n else:\n print('NO')", "x=input()\r\ny=input()\r\nprint('YES' if x==y[::-1] else 'NO')", "s = input().lower()\r\nt = input().lower()\r\ns_list = []\r\nt_list = []\r\nfor i in s:\r\n s_list.append(i)\r\nfor j in t:\r\n t_list.insert(0, j)\r\nif s_list == t_list:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = input()\r\ny = [u for u in n]\r\nb = input()\r\nj = [o for o in b]\r\n\r\na = y[::-1]\r\n\r\nif j == a:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "t = input()\r\nt1 = input()\r\n\r\nif len(t) == len(t1):\r\n i = 0\r\n verificar = 0\r\n while i<len(t):\r\n if t[(i+1)*(-1)] == t1[i]:\r\n verificar+=1\r\n i+=1\r\n if verificar == len(t):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")\r\n", "#problem 41A\r\nstring1=input()\r\nstring2=input()\r\nif string1==string2[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = \"\"\r\nfor i in range(len(a)):\r\n b = b+a[len(a)-i-1]\r\nc = input()\r\nif b==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "import sys\r\ns=input()\r\nt=input()\r\nif len(s)!=len(t):\r\n print(\"NO\")\r\n sys.exit()\r\nfor i in range(len(s)):\r\n if s[i]!=t[len(s)-i-1]:\r\n print(\"NO\")\r\n sys.exit()\r\nprint(\"YES\")", "w = input()\r\nd = input()\r\nif(w[::-1]==d):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def translation():\n original = input()\n reverse = input()\n # print(original[::-1])\n if reverse == (original[::-1]):\n print('YES')\n else:\n print('NO')\n\ntranslation()", "k=input()\r\nl=input()\r\n\r\nif k==l[::-1]:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "#comparamos ambos inputs, si el primero es igual al reverso del segundo\n#imprimimos YES, y en caso de no serlo imprimimos NO\nprint(\"YES\" if input() == input()[::-1] else \"NO\")\n\t \t\t\t \t\t \t \t \t\t\t \t \t\t \t", "# coding=utf-8\r\na = input()\r\nb = input()\r\nn = len(a)\r\nif n == len(b):\r\n for i in range(n):\r\n if a[i] != b[n-1-i]:\r\n print('NO')\r\n break\r\n else:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \t \t\t \t\t \t \t\t\t\t \t\t \t \t\t \t", "#\r\n# Author: eloyhz\r\n# Date: Sep/10/2020\r\n#\r\n\r\n\r\nif __name__ == '__main__':\r\n s = input()\r\n t = list(input())\r\n t.reverse()\r\n r = ''.join(t)\r\n if s == r:\r\n print('YES')\r\n else:\r\n print('NO')\r\n", "s1=input()\r\ns2=input()\r\ns=[]\r\nl=[]\r\nk=[]\r\nfor i in s1:\r\n l.append(i)\r\nfor i in s2:\r\n s.append(i)\r\nj=len(s)-1\r\nwhile(j>=0):\r\n k.append(s[j])\r\n j-=1\r\nif(k==l):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=input()\ns2=input()\ns3=s1[::-1]\nif s3==s2:\n print(\"YES\")\nelse:\n print(\"NO\")", "print('YNEOS'[input()!=input()[::-1]::2])", "m=list(input())\r\nn=list(input())\r\nm.reverse()\r\nif n==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x = input()\r\ny = input()\r\ncorrect = True\r\nfor i in range(len(x)):\r\n if len(x)!=len(y):\r\n correct = False\r\n break\r\n if x[i] != y[(-i)-1]:\r\n correct = False\r\n break\r\nif correct:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=[x for x in input()]\r\nm=[x for x in input()]\r\nm.reverse()\r\nif n==m:print(\"YES\")\r\nelse :print(\"NO\")", "n1 = list(input())\r\nn2 = list(input())\r\n\r\nif n2[::-1]==n1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str=input()\r\nstr2=input()\r\nrev=str[::-1]\r\nif str2==rev:\r\n print(\"YES\\n\")\r\nelse:\r\n print(\"NO\\n\")\r\n", "# -*- coding: utf-8 -*-\r\nfirst_word=input()\r\nsecond_word=input()\r\nfirst_characters=list(first_word)\r\nfirst_characters.reverse()\r\nfirst_word=''.join(first_characters)\r\nif first_word==second_word:\r\n print('YES')\r\nelse:\r\n print('NO')", "# import sys \r\n# sys.stdin = open('input.txt', 'r')\r\n# sys.stdout = open('output.txt', 'w') \r\n\r\n\r\na = input()\r\nb = input()\r\n\r\nif (a[::-1] == b):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "def invert(x):\r\n return x[::-1]\r\nn = str(input())\r\nn2 = str(input())\r\nif (invert(n) == n2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def solution():\r\n\ts1 = input()\r\n\ts2 = input()\r\n\tprint('YES') if s1 == s2[::-1] else print('NO')\r\n\r\nsolution()", "s = input()\r\ns_new = input()\r\n\r\nif s_new == s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=[]\r\ni=0\r\nwhile i<2:\r\n\titem=input()\r\n\tn.append(item)\r\n\ti=i+1\r\nx=n[0][::-1]\r\nif x==n[1]:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "s = list(input())\r\nt = input()\r\ns1 = list(reversed(s))\r\nstr =\"\"\r\nfor i in s1:\r\n str+=i\r\nif str==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "a = input()\r\nb = input()\r\nprint(int(a == b[::-1]) * \"YES\" + int(a != b[::-1]) * \"NO\")\r\n", "word = input('')\nreverse_word = input('')\nword_reverse = word[::-1]\nif word_reverse == reverse_word:\n print('YES')\nelse:\n print('NO')\n\t \t \t \t \t\t\t\t \t \t\t \t", "s = input().replace(\" \", \"\")\r\nt = input().replace(\" \", \"\")\r\n\r\ndef Reverse(word):\r\n i = len(word) - 1\r\n r = \"\"\r\n while i >= 0 :\r\n r += word[i]\r\n i -= 1\r\n return r\r\n\r\nr_s = Reverse(s)\r\n\r\nif r_s == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\narr=[]\r\nrra=[]\r\n\r\nfor i in range(len(s)) :\r\n arr.append(s[i])\r\n\r\nfor i in range(len(t)-1,-1,-1) :\r\n rra.append(t[i])\r\n\r\nif rra==arr:\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "#!/usr/bin/python3\n\nprint('YES') if input().lower() == input().lower()[::-1] else print('NO')\n", "if __name__ == \"__main__\":\r\n str = list(input())\r\n in_revers_word = input()\r\n\r\n reversed_word = []\r\n for i in range(len(str)-1, -1, -1):\r\n reversed_word.append(str[i])\r\n \r\n if \"\".join(reversed_word) == in_revers_word:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n ", "s = input()\r\nt = input()\r\nresult = True\r\nif len(s) == len(t):\r\n for i in range(len(s)):\r\n if s[i] != t[-1-i]:\r\n result = False\r\nelse:\r\n result = False\r\nif result:\r\n print('YES')\r\nelse:\r\n print('NO')", "x=list(input())\r\ny=list(input())\r\nx1=x[::-1]\r\nif x1==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "st = input()\r\nst2 = input()\r\nif len(st) != len(st2):\r\n print('NO')\r\nelse:\r\n ch = 0\r\n for i in range(len(st)):\r\n if st[i] != st2[len(st2)-i-1]:\r\n ch = 1\r\n print('NO')\r\n break\r\n if ch == 0:\r\n print('YES')\r\n", "l=list(input())\r\nl1=list(input())\r\n \r\nif len(l)!=len(l1):\r\n print(\"NO\")\r\n exit(0)\r\ni=0;\r\nlength=len(l)\r\nwhile (i<length):\r\n #print(l[i],l1[length-i-1])\r\n if l[i]!=l1[length-i-1]:\r\n print(\"NO\")\r\n exit(0)\r\n i+=1\r\nprint(\"YES\")", "def reverse(string):\r\n return string[::-1]\r\n\r\nstr1 = input()\r\nstr2 = input()\r\nreversed_str = reverse(str1)\r\n\r\nif str2 == reversed_str:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# will implement with set, dict, list\n\n\ndef input_str():\n arr = input()\n return arr\n\n\ndef input_list():\n return list(input_str())\n\n\ndef print_yn(boolean_exp):\n if boolean_exp:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\ndef final_check(l1, l2):\n if len(l1) == len(l2) and l1 == list(reversed(l2)):\n return True\n else:\n return False\n\n\nif __name__ == \"__main__\":\n l1 = input_list()\n l2 = input_list()\n\n print_yn(final_check(l1, l2))\n", "y=input(\"\") #Enter the Berland String\r\nz=input(\"\") #Enter the Birland String\r\nif len(y)!=len(z):\r\n print(\"NO\")\r\n exit()\r\nsum=0\r\na=[]\r\nb=[]\r\n\r\nfor i in range(0,len(y)):\r\n a.append(y[i])\r\nfor i in range(0,len(z)):\r\n b.append(z[i])\r\n\r\na.reverse()\r\nfor j in range(0,len(y)):\r\n if a[j]==b[j]:\r\n sum=sum+1\r\nif sum==len(y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "Ber=input()\r\nBir=input()\r\nif Ber == Bir[::-1] :\r\n print('YES')\r\nelse: print('NO')\r\n", "a=input()\r\nb=input()\r\nSUM=0\r\nif len(a)==len(b):\r\n for i in range(len(a)):\r\n if a[i]!=b[-i-1]:\r\n SUM+=1\r\n if SUM==0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")", "try:\r\n s = input()\r\n t = input()\r\n m = s[::-1]\r\n if m == t:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nexcept:\r\n pass\r\n", "n1 = input()\r\nn2 = input()\r\n\r\nprint(\"YES\" if n1 == n2[::-1] else \"NO\")", "str1=input()\r\nstr2=input()\r\nans=str1[::-1]\r\nif ans==str2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = input()\r\nw = input()\r\nw = w[::-1]\r\nif n == w:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nb = input ()\nprint('YES' if s == b[::-1] else 'NO')", "word = input()\r\ndrow = input()\r\nreverse = word[::-1]\r\nif drow == reverse:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=str(input())\r\nt=str(input())\r\ns=list(s)\r\nt1=list(t)\r\ns1=list(reversed(s))\r\nif s1==t1:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nlist_s=list(s)\r\nlist_t=list(t)\r\ncount=0\r\nlist_s.reverse()\r\nif(list_s==list_t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nif len(s)<=100 and len(t)<=100:\r\n if t==s[-1::-1]:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "s= input()\r\nt= input()\r\ns= s[::-1]\r\nif s==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\n\r\n#if s == \"\".join(list(t).reverse()):\r\n #$print(\"YES\")\r\n#else:\r\n #print(\"NO\")\r\nmodded_t = list(t)[::-1]\r\nfinal_t = \"\".join(modded_t)\r\n\r\nif s == final_t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n=input()\nm=input()\nres=n[::-1]\na=m[::-1]\nif a==n and res==m:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n \t \t \t\t \t \t\t\t \t \t \t \t", "word = list(input())\r\nrev_word = list(input())\r\nword.reverse()\r\nif word == rev_word:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "'''\r\n# CodeForce Equalize Prices 900 points\r\n\r\n# a = old price / b = new price / k =value input\r\ndef Computer_Game():\r\n\r\n for _ in range(int(input())):\r\n k, n, a, b = map(int, input().split()) # init charge, num turns in game, a,b bat value\r\n max_turns=0\r\n for turns in range(n):\r\n\r\n if k/b > n and (k-a)/b < n-1 and turns == 0:\r\n max_turns=0\r\n break\r\n else:\r\n if k > a:\r\n k -= a\r\n max_turns += 1\r\n elif k > b:\r\n k -= b\r\n if k/b == n-turns:\r\n max_turns = 1\r\n break\r\n else:\r\n max_turns = -1\r\n break\r\n\r\n\r\n print(max_turns)\r\n\r\n\r\n return\r\n\r\n\r\ndef bit_plus_plus():\r\n\r\n summe = 0\r\n for _ in range(int(input())):\r\n\r\n statement = input()\r\n if '+' in statement:\r\n summe += 1\r\n else:\r\n summe -= 1\r\n print(summe)\r\n return\r\n\r\ndef petya_and_strings():\r\n\r\n str_a, str_b = input().lower(), input().lower()\r\n a=(str_a<str_b)\r\n print((str_a>str_b)-(str_a<str_b))\r\n\r\n\r\n return\r\n\r\n\r\n\r\n\r\ndef beautiful_matrix():\r\n\r\n for idx in range(5):\r\n\r\n row_input = list(map(int,input().split()))\r\n if 1 in row_input:\r\n row = idx+1\r\n for idx1, elem in enumerate(row_input):\r\n if elem == 1:\r\n column = idx1+1\r\n\r\n output = abs(3 - row) + abs(3 - column)\r\n print(output)\r\n #for row_num in range(4):\r\n # if 1 in row(row_num)\r\n\r\n return\r\n\r\n\r\ndef helpful_maths():\r\n\r\n\r\n string = sorted(list(input().split('+')))\r\n print('+'.join(string))\r\n\r\n return\r\n\r\n\r\ndef word_capitalization():\r\n\r\n string = input()\r\n string_new = string[0].upper()+string[1:]\r\n print(string_new)\r\n\r\n return\r\n\r\ndef Stones_on_the_Table():\r\n _ = input()\r\n string=list(input())\r\n color_old = ''\r\n color_old_old = ''\r\n take = 0\r\n for color in string:\r\n\r\n if color == color_old:\r\n take += 1\r\n else:\r\n color_old = color\r\n\r\n\r\n print(take)\r\n\r\n return\r\n\r\ndef Boy_or_girl():\r\n print([{*input()}])\r\n string = input()\r\n new_string = ''\r\n for _ in string:\r\n if _ not in new_string:\r\n new_string = new_string + _\r\n if len(new_string) % 2 != 0:\r\n print('IGNORE HIM!')\r\n else:\r\n print('CHAT WITH HER!')\r\n\r\n return\r\n\r\n\r\ndef soldier_and_bananas():\r\n\r\n k,n,w = map(int,input().split())\r\n prize = 0\r\n for num in range(w):\r\n prize = prize + (num+1)*k\r\n\r\n print(prize-n if prize-n > 0 else 0)\r\n return\r\n\r\n\r\ndef bear_and_big_brother():\r\n\r\n a,b = map(int, input().split())\r\n years = 0\r\n while a <= b:\r\n a = a*3\r\n b = b*2\r\n years += 1\r\n\r\n print(years)\r\n\r\n return\r\n\r\n\r\ndef Tram():\r\n passenger = []\r\n cur_pass = 0\r\n for _ in range(int(input())):\r\n\r\n exit_passenger, enter_passenger = map(int,input().split())\r\n cur_pass = cur_pass - exit_passenger + enter_passenger\r\n passenger.append(cur_pass)\r\n\r\n print(max(passenger))\r\n return\r\n\r\n\r\n\r\ndef subtract_one(number):\r\n\r\n if float(number)%10 == 0:\r\n result = number / 10\r\n else:\r\n result = number - 1\r\n\r\n return int(result)\r\n\r\ndef wrong_subtraction():\r\n\r\n n, k = map(int, input().split())\r\n\r\n for _ in range(k):\r\n n = subtract_one(n)\r\n\r\n print(n)\r\n return\r\n\r\ndef wet_shark_and_odd_and_even():\r\n\r\n odd = []\r\n even = []\r\n odd_cnt = 0\r\n n = input()\r\n numbers = list(map(int,input().split()))\r\n for number in numbers:\r\n if number%2 == 0:\r\n even.append(number)\r\n else:\r\n odd.append(number)\r\n odd_cnt += 1\r\n\r\n odd.sort()\r\n k = int(odd_cnt/2)*2\r\n if k > 0:\r\n summe = sum(even) + sum(odd[-k:])\r\n else:\r\n summe = sum(even)\r\n print(summe)\r\n\r\n\r\n return\r\n\r\n\r\n\r\n\r\n\r\ndef sorting(volumes):\r\n\r\n sorting_steps = 0\r\n idx = 0\r\n cnt = 0\r\n while(idx < len(volumes)-1):\r\n a = volumes[idx]\r\n b = volumes[idx+1]\r\n # print(volumes)\r\n if a > b:\r\n volumes[idx] = b\r\n volumes[idx+1] = a\r\n sorting_steps += 1\r\n if idx > 0:\r\n idx -= 1\r\n\r\n else:\r\n cnt = cnt+1\r\n idx = cnt\r\n\r\n else:\r\n idx += 1\r\n return sorting_steps\r\n\r\ndef cubes_sorting():\r\n\r\n for _ in range(int(input())):\r\n\r\n n = int(input())\r\n a = list(map(int,input().split()))\r\n\r\n max_sort = n*(n-1)/2-1\r\n\r\n sorting_steps = sorting(a)\r\n\r\n if sorting_steps > max_sort:\r\n print('NO')\r\n else:\r\n print('YES')\r\n\r\n\r\n return\r\n\r\ndef elephant():\r\n\r\n coord = int(input())\r\n steps_taken = 0\r\n for steps in range(5,0,-1):\r\n if (coord / steps) >= 1:\r\n steps_taken = int(coord / steps) + steps_taken\r\n coord = int(coord % steps)\r\n print(steps_taken)\r\n return\r\n\r\ndef queue_at_the_school():\r\n number, time = map(int,input().split())\r\n queue=list(input())\r\n\r\n i = 0\r\n\r\n while i < time:\r\n idx = 0\r\n while idx < len(queue)-1:\r\n if queue[idx] == 'B' and queue[idx+1] == 'G':\r\n queue[idx] = 'G'\r\n queue[idx+1] = 'B'\r\n idx += 2\r\n else:\r\n idx += 1\r\n i += 1\r\n\r\n print(''.join(queue))\r\n return\r\n\r\ndef nearly_lucky_number():\r\n number = input()\r\n l_number = 0\r\n bla=[sum(i in '47' for i in number) in [4, 7]]\r\n print('4' in number)\r\n for elem in number:\r\n if elem == '7' or elem == '4':\r\n l_number += 1\r\n print('YES' if l_number == 4 or l_number == 7 else 'NO')\r\n\r\n return\r\n\r\ndef word():\r\n string = input()\r\n count = 0\r\n for elem in string:\r\n if elem.isupper():\r\n count += 1\r\n\r\n print(string.upper() if count > len(string)/2 else string.lower())\r\n\r\n return\r\n'''\r\ndef translation():\r\n word_1 = input()\r\n word_2 = input()[::-1]\r\n print([\"NO\", \"YES\"] [word_1 == word_2])\r\n\r\n\r\n return\r\n\r\ndef anton_and_danik():\r\n\r\n games = int(input())\r\n wins=input()\r\n anton_wins = sum(i == 'A' for i in wins)\r\n if anton_wins*2 > len(wins):\r\n print('Anton')\r\n elif anton_wins*2 == len(wins):\r\n print('Friendship')\r\n else:\r\n print('Danik')\r\n\r\n\r\n return\r\n\r\nif __name__ == '__main__':\r\n\r\n translation()\r\n\r\n'''\r\nif __name__ == '__main__':\r\n num_queries = int(input())\r\n\r\n for querie in range(num_queries):\r\n num_products, value_products = map(int, input().split())\r\n price_products = list(map(int, input().split()))\r\n B_Max = min(price_products)+value_products\r\n B_Min = max(price_products)-value_products\r\n if B_Max >= B_Min:\r\n print(B_Max)\r\n else:\r\n print(-1)\r\n'''\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "s=input()\r\nt=input()\r\nn=len(s)\r\nif(s[0:n]==t[::-1]):\r\n print(\"YES\") \r\nelse:\r\n print(\"NO\")", "f = list(input())\r\ns = list(input())\r\n\r\nif list(reversed(f)) == list(s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri May 8 14:08:17 2020\r\n\r\n@author: Manav Jain\r\n\"\"\"\r\n\r\ns1=input()\r\ns2=input()\r\nif(s1==s2[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s=input()\r\nt=input()\r\nc=0\r\nif len(s)==len(t):\r\n for i in range(len(s)):\r\n if s[i]==t[len(s)-1-i]:\r\n c=c+1\r\nif c==len(s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Aug 14 09:59:42 2018\r\n\r\n@author: Minh Tuấn1\r\n\"\"\"\r\n\r\na = input()\r\nb = input()\r\ndef string(an): \r\n ao = an[::-1]\r\n return ao\r\nm = string(a)\r\nif m == b:\r\n print(\"YES\")\r\nelse: \r\n print(\"NO\")", "word = input()\r\ntrans = input()\r\nif trans == word[::-1]:print(\"YES\")\r\nelse: print(\"NO\")", "s = input()\r\ns2 = input()\r\nrev = s[::-1]\r\nif(rev == s2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "'''s=iter(input())\r\nif all(c in s for c in 'hello'):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")'''\r\n'''n,t=map(int,input().split())\r\ns=input()\r\nwhile t:\r\n s=s.replace(\"BG\",\"GB\")\r\n t-=1\r\nprint(s)'''\r\n'''n=int(input())\r\nif all(n%i for i in [4,7,47,744,477]):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")'''\r\n'''s=input();print([s.lower(),s.upper()][sum(x<'['for x in s)*2>len(s)])'''\r\n'''print('NYOE S'[sum(i in'47'for i in input())in(4,7)::2])'''\r\n'''n,m,a=map(int,input().split())\r\nprint(-n//a*(-m//a))'''\r\n'''n=input()\r\nl=sorted(map(int,input().split()))\r\ns=c=0\r\nwhile s<=sum(l):\r\n s+=l.pop()\r\n c+=1\r\nprint(c)'''\r\ns=input()\r\nt=input()\r\nif s[::-1]==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n", "s=input()\r\nt=input()\r\nif len(s)==len(t):\r\n i=0\r\n while i<len(s):\r\n if s[i]==t[-(i+1)]:\r\n i+=1\r\n else:\r\n break\r\n if i<len(s):\r\n print(\"NO\")\r\n else:\r\n print(\"YES\") \r\nelse:\r\n print(\"NO\") \r\n", "s=input()\r\nt=input()\r\nnum = 0\r\nif len(s)==len(t): \r\n for i in range(len(s)):\r\n if s[i]==t[-(i+1)]:\r\n num +=1\r\nif num ==len(s):\r\n print('YES')\r\nelse:\r\n print('NO')", "s=(input())\r\nt=(input())\r\nlang=s[ : :-1]\r\nif lang==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = input()\r\nrev = input()\r\nx = \"\".join(reversed(word))\r\nif x == rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n = input()\r\nt = input()\r\nprint(\"YES\" if n == t[::-1] else \"NO\")", "word = input()\r\nanswer= input()\r\n\r\nnew_word = ''\r\n\r\nfor x in range(len(word) - 1, -1, -1):\r\n new_word += word[x]\r\n\r\nif new_word == answer:\r\n print('YES')\r\n\r\nelse:\r\n print('NO')\r\n\r\n", "s1=str(input())\r\ns2=str(input())\r\nif s1==s2[-1:-len(s2)-1:-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=(input(''))\r\na=list(a)\r\nb=(input(''))\r\nb=list(b)\r\nb.reverse()\r\nif a==b:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a=input()\r\nb=list(\"\".join(input()))\r\nc=list(reversed(a))\r\nif c==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input()\r\ny=input()\r\ng=y[::-1]\r\nif x==g:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "i,o=input(),input()\r\nif i==o[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "x = input()\r\ny = input()\r\nrev = x[::-1]\r\nif(y == rev):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "berland = str(input())\nbirland = str(input())\n\nfor i in range(len(berland)):\n if berland[i] != birland[-i - 1]:\n flag = 1\n break\n else:\n flag = 0\nif flag == 0:\n print('YES')\nelse:\n print('NO')\n\n", "str1 = [ch for ch in input()]\nstr1.reverse()\nstr2 = input()\nprint ('YES' if str2 == \"\".join(str1) else 'NO')", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Wed Mar 16 22:08:35 2022\r\n\r\n@author: Dehong\r\n\"\"\"\r\n\r\nr = input;print(\"YNEOS\"[r()!=r()[::-1]::2])", "s0 = input()\r\ns1 = input()\r\nrev = s0[::-1]\r\nif s1 == rev:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\nt = input()\n\nres = True\ni = 0\nwhile res and i < len(s):\n if s[i] != t[-(i+1)]:\n res = False\n i += 1\n\nif res:\n print('YES')\nelse:\n print('NO')\n", "s1 = input()\r\ns2 = input()\r\nx = 0\r\ny = len(s2) - 1\r\nwhile s1[x] == s2[y]:\r\n x += 1\r\n y -= 1 \r\n if x == len(s1):\r\n print(\"YES\")\r\n break\r\nif x != len(s1):\r\n print(\"NO\") \r\n\r\n", "# 41A: Translation\r\n\r\ns = input()\r\n\r\nif input()==s[::-1]:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "word1 = input()\r\nword2 = input()\r\n\r\nn = len(word1)\r\n\r\nif len(word2) != n:\r\n print('NO')\r\nelse:\r\n correct = True\r\n for i in range(n):\r\n if word1[i] != word2[n-i-1]:\r\n correct = False\r\n break\r\n \r\n print('YES') if correct else print('NO')\r\n", "s=input()\r\ns2=input()\r\nlists=list(s)\r\ns1=\"\"\r\nfor i in range(len(lists)-1,-1,-1):\r\n s1=s1+lists[i]\r\nif(s2==s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# your code goes here\r\ndef translation(s1 : str,s2 : str) -> str:\r\n\ts2=s2[::-1]\r\n\t\r\n\tif s1==s2:\r\n\t\tst='YES'\r\n\telse:\r\n\t\tst='NO'\r\n\treturn st\t\t\t\r\nif __name__ == '__main__':\r\n\ts1=input()\r\n\ts2=input()\r\n\ts=translation(s1,s2)\r\n\tprint(s)", "def isreversed(s, t):\r\n if(len(s) != len(t)):\r\n return 'NO'\r\n i, n = 0, len(s)\r\n while(i < n):\r\n if(s[i] != t[n - i - 1]):\r\n return 'NO'\r\n i += 1\r\n return 'YES'\r\n\r\ns = input()\r\nt = input()\r\nprint(isreversed(s, t), end = '')", "a = input()\r\nb = input()\r\nz = a[::-1]\r\nif b==z:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import bisect\nimport collections\nimport copy\nimport functools\nimport heapq\nimport itertools\nimport math\nimport random\nimport re\nimport sys\nimport time\nimport string\nfrom typing import List\nsys.setrecursionlimit(99999)\n\ndef II():return int(sys.stdin.readline().strip())\ndef IIs():return list(map(int,sys.stdin.readline().strip().split()))\ndef SI():return sys.stdin.readline().strip()\n\nprint(\"NYOE S\"[input()[::-1]==input()::2])", "a=input()\r\nb=input()\r\nc=list(a)\r\nd=list(b)\r\nn=len(a)\r\nm=len(b)\r\ns='YES'\r\nif m!=n:\r\n s='NO'\r\nelse:\r\n for i in range(n):\r\n if c[i]!=d[n-1-i]:\r\n s='NO'\r\n break\r\nprint(s)\r\n \r\n", "s1=str(input())\r\ns2=str(input())\r\nif s2==s1[::-1]:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")\r\n \r\n", "import sys\n\nn = input()\nt = input()\n\nn = n[::-1]\nc = 0\n\nif len(n) != len(t):\n\tprint('NO')\n\tsys.exit()\n\t\n\nfor i in range(len(n)):\n\tif n[i] == t[i]:\n\t\tc += 1\n\t\nif c == len(n):\n\tprint('YES')\nelse:\n\tprint('NO')\n", "m=input()\r\nn=input()\r\nx=''\r\nfor i in range(len(n)-1,-1,-1):\r\n\tx+=n[i]\r\nif m==x:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "n=input()\n\n#b=n[-1:-len(n)-1:-1]\nb=input()\nrev_b=b[-1:-len(b)-1:-1]\n#print(rev_b)\nif rev_b==n :\n print('YES')\nelse :\n print('NO') ", "s = input ()\r\nt = input ()\r\noutput = 'YES'\r\nfor i in range (len (s)):\r\n if s [i] != t [-1 - i]:\r\n output = 'NO'\r\n break\r\nprint (output)", "s=input()\r\nt=input()\r\nc=t[::-1]\r\nif s==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\na=list(t)\r\na.reverse()\r\nb=''\r\nfor l in a:\r\n b=b+l\r\nif(b==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "import sys\r\n\r\nfirst_str = list(sys.stdin.readline())\r\nsecond_str = list(sys.stdin.readline())\r\n\r\nn = len(first_str) - 1\r\nfor i in range(n):\r\n if(second_str[i] != first_str[n - i - 1]):\r\n print(\"NO\")\r\n exit()\r\n \r\nprint(\"YES\")\r\n", "s = input()\ne = input()\nif e == s[::-1]:\n print('YES')\nelse:\n print('NO')", "#задача про замену первой буквы заглавной\r\n#a = input()\r\n#p = a[0]\r\n#if p.isupper():\r\n# print(a)\r\n#else:\r\n# print(p.upper() + a[1:])\r\n# задача про сортировку чисел 1 + 1 + 2 ...\r\n#print('+'.join(sorted(input().split('+'))))\r\n#задача про очередь\r\n# n, t = [int(i) for i in input().split()]\r\n# s = list(input())\r\n# for a in range(t):\r\n# flag = True\r\n# for i in range(n-1):\r\n# if flag:\r\n# if s[i] == \"B\" and s[i+1] == \"G\" :\r\n# s[i], s[i+1] = s[i+1], s[i]\r\n# flag = False\r\n# else:\r\n# flag = True\r\n# print(\"\".join(s))\r\nn, m = input(), input()\r\nif n == m[::-1]: print(\"YES\")\r\nelse: print(\"NO\")\r\n\r\n\r\n", "str1=input().strip()\r\nstr2=input().strip()\r\nstr3=str1[::-1]\r\nif (str2==str3):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nb=input()\r\ncheckk=0\r\nif len(a)!=len(b):\r\n print(\"NO\")\r\nelse:\r\n for x in range(0,len(a)):\r\n if a[x]!=b[len(a)-x-1]:\r\n checkk=1\r\n break\r\n if checkk==0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "x = input()\r\ny = input()\r\nx1=[]\r\ny1=[]\r\ns=0\r\nfor i in range(len(x)):\r\n x1.append(x[i])\r\n\r\nfor i in range(len(y)):\r\n y1.append(y[i])\r\n\r\nfor i in range (len(x)):\r\n if x1[i] == y1[(len(y)-1)-i]:\r\n s+=1\r\nif s == len(x):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nb=a[::-1]\r\nc=input()\r\nif c==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input()\r\ny=input()\r\ny=list(y)\r\nx=list(x)\r\nx.reverse()\r\nprint(\"YES\" if y==x else \"NO\")", "A=input()\r\nB=input()\r\nC=A[::-1]\r\nif C==B:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "pooja=input()\r\najoop=input()\r\nif pooja[::-1]==ajoop:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word_t = input()\r\nword_s = input()\r\nword_t = word_t[::-1]\r\nif word_t == word_s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "ini = input()\r\nfin = input()\r\n\r\nres = \"\"\r\nfor i in range(len(ini)-1, -1, -1):\r\n res += ini[i]\r\n\r\nif res == fin:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "i = list(input())\r\no = list(input())\r\n\r\nif o[::-1] == i:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "orig = input()\r\ntranslated = input()\r\ncorrect = ''.join(list(reversed(orig)))\r\n\r\nif translated == correct:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\r\nt = input()\r\n\r\nyn = \"\"\r\n\r\nfor i in range(len(s)):\r\n # This line checks if the first letter in s is the same as the last one in t and if the second is the same as the second last, and so on\r\n if s[i] == t[len(t)-1-i]:\r\n yn += \"YES\"\r\n else:\r\n yn += \"NO\"\r\n\r\nif \"NO\" in yn:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "x=list(input())\r\ny=list(input())\r\ny.reverse()\r\n\r\nif y==x:\r\n print(\"YES\")\r\n \r\nelse:\r\n print(\"NO\")\r\n \r\n", "# code in berlandish ==== edoc in birlandish\r\ns = input()\r\nt = input()\r\nif s == t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\ns1=s[::-1]\r\nif s1==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\ns1=input()\r\nprint(\"YES\" if s1==s[::-1] else \"NO\")", "if __name__ == '__main__':\r\n\ts = input()\r\n\tt = input()\r\n\ti = -1\r\n\tj = 0\r\n\tfianl = 1\r\n\twhile j < len(s):\r\n\t\tif s[j] != t[i]:\r\n\t\t\tfianl = -1\r\n\t\t\tbreak\r\n\t\tj+=1\r\n\t\ti-=1\r\n\tif fianl == -1:\r\n\t\tprint('NO')\r\n\telse:\r\n\t\tprint('YES')", "a=input()\r\nb=input()\r\nb=list(b)\r\na=list(a)\r\na.reverse()\r\nif a==b:\r\n print('YES')\r\nelse:\r\n print('NO')", "c = input()\r\nb = input()\r\nif c[::-1] == b:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n ", "s = input()\nn = input()\nl = list(s)\nli = list(n)\nl.reverse()\nif l == li:\n print(\"YES\")\nelse:\n print(\"NO\")", "str = input()\r\nrev= input()\r\nif str[::-1] == rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "while True:\r\n s=input()\r\n t=input()\r\n if len(s)>=1 and len(s)<=100 and len(t)>=1 and len(t)<=100:\r\n break\r\nl1=list(s)\r\nl2=list(t)\r\nif l1==l2[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "\r\n\r\n\r\n\r\ndef translation():\r\n\r\n s1 = input()\r\n s2 = input()\r\n\r\n\r\n if len(s1) != len(s2):\r\n print('NO')\r\n else:\r\n for c1,c2 in zip(s1,reversed(s2)):\r\n if c1 != c2:\r\n print('NO')\r\n break\r\n else:\r\n print('YES')\r\n\r\n\r\n\r\ntranslation()\r\n", "s=input()\r\nt=input()\r\nempty=\"\"\r\nfor i in range(len(s)-1,-1,-1):\r\n empty+=s[i]\r\n\r\nif empty==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = list(input())\r\nc = list(input())\r\ncount = len(n)\r\ncount_1 = 0\r\nif len(n) == len(c):\r\n for i in range(count):\r\n if n[i] == c[count - 1]:\r\n count_1 += 1\r\n count -= 1\r\nif count_1 == len(n):\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nl=input()\r\nt=s[::-1];\r\nif t==l:\r\n print('YES');\r\nelse:\r\n print('NO');\r\n", "s = input()\r\nr = input()\r\nif(len(s)!=len(r)):\r\n print(\"NO\")\r\n exit(0)\r\nn = len(s)\r\nfor i in range(0,n):\r\n if s[i]!=r[n-i-1]:\r\n print(\"NO\")\r\n exit(0)\r\nprint(\"YES\")", "a = input()\r\nb = input()\r\ns = \"\"\r\nfor i in range(len(a) - 1 , -1 , -1):\r\n s = s +a[i]\r\n\r\nif s == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def reverse(str):\r\n l = len(str)\r\n res = ''\r\n for i in range(l):\r\n res += str[l - i -1]\r\n return res\r\n\r\ns = input()\r\nt = input()\r\n\r\nif reverse(s) == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "n=input()\r\nn=list(n)\r\ns=input()\r\ns=list(s)\r\nc=0\r\nk=0\r\ntemp=''\r\nif len(n)!=len(s):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(s)):\r\n d=s[-1-i]\r\n temp=temp+d\r\n for i in range(len(n)):\r\n if n[i]==temp[i]:\r\n c=c+1\r\n if c==len(n):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\nc = 0\r\nq = len(b)-1\r\nz = 0\r\nfor i in range(len(a)):\r\n if a[c] == b[q]:\r\n z += 1\r\n else:\r\n z -= 1\r\n q -= 1\r\n c += 1\r\nif z == len(a):\r\n print('YES')\r\nelse:\r\n print('NO')", "g = list(input())\r\nf = list(input())\r\ndef reverse(f):\r\n f.reverse()\r\n return f\r\nif g == reverse(f):\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")", "word = str(input())\r\nword2 = str(input())\r\nprint(\"YES\") if ''.join(reversed(word)) == word2 else print('NO')", "s1 = input()\r\ns2 = input()\r\ns3 = s1[::-1]\r\nif s2 == s3:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "word = input()\ncode = input()\ncode_m = []\n\nfor i in range(len(word) - 1, -1, -1):\n code_m.append(word[i])\n\ncode_m = ''.join(code_m)\n\nif code_m == code:\n print('YES')\nelse:\n print('NO')", "w1 = input()\r\nw2 = input()\r\n \r\nj = 1\r\n \r\nfor i in range(0,len(w1)):\r\n if w1[i] != w2[len(w2)-i-1]:\r\n j = 0\r\n \r\nif j:\r\n print('YES')\r\n \r\nelse:\r\n print('NO')\r\n", "def is_reversed_word(s, t):\r\n i = 0\r\n j = len(t) - 1\r\n\r\n while i < len(s) and j >= 0:\r\n if s[i] != t[j]:\r\n return False\r\n i += 1\r\n j -= 1\r\n\r\n return True\r\ns = input()\r\nt = input()\r\nif is_reversed_word(s, t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\nt=input()[::-1]\nif s == t :\n print('YES')\nelse:\n print('NO')", "s=[]\r\nfor i in range(2):\r\n a=input()\r\n s.append(a)\r\nif s[0][::-1]==s[1][::] :\r\n print('YES')\r\nelse:\r\n print('NO')", "def main():\n #n, m = list(map(int, input().split(' ')))\n s1 = input()\n s2 = input()\n\n is_poly = ''.join(reversed(s2)) == s1\n\n print('YES' if is_poly else 'NO')\n \n\nif __name__ == \"__main__\":\n main()\n", "s = input() # Read the first word\r\nt = input() # Read the second word\r\n\r\nif t == s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def barland(s,t):\r\n if s[::-1]==t:\r\n return \"YES\"\r\n else: return \"NO\"\r\ns = input()\r\nt = input()\r\nprint(barland(s,t))", "s1=input()\r\ns2=input()\r\nif s2==\"\".join(reversed(s1)):\r\n print('YES')\r\nelse:\r\n print('NO')", "s=list(input().strip())\r\nt=input().strip()\r\n\r\ns=s[::-1]\r\n\r\nprint(\"YES\") if(\"\".join(s)==t) else print(\"NO\")", "s=input()\r\nr=input()\r\nt=0\r\nfor i in range(len(s)):\r\n if(s[i]==r[len(r)-1-i]):\r\n continue\r\n else:\r\n print('NO')\r\n t=1\r\n break\r\nif(t==0):\r\n print('YES')", "word1 = input()\r\nword2 = input()\r\nprint(['NO','YES'][word1 == word2[::-1]])\r\n", "\"\"\"\nPROBLEM URL: https://codeforces.com/problemset/problem/41/A\nPROBLEM NAME: Translation\n\nAUTHOR: valisport\nDATE: Thursday 27 May 2021 11:25:39 PM IST\nLANGUAGE: Python 3\n\nREPOSITORY ADDRESS: https://github.com/vikramaditya/progress\n\"\"\"\n\ns = input()\nt = input()\n\ngo = \"\".join(reversed(s))\n\nif go == t:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s=input()\r\nt=input()\r\nh=t[::-1]\r\nif h==s:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "from collections import Counter\nnormal=input()\nberland = input()\nif normal==berland[::-1]:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t\t \t \t \t \t\t \t\t\t \t", "def solve():\r\n \r\n string1 = input()\r\n string2 = input()\r\n\r\n string2 = string2[::-1]\r\n\r\n print(\"YES\" if string1 == string2 else \"NO\")\r\n\r\nif __name__ == '__main__':\r\n solve()", "#!/usr/bin/env python3\n\nif __name__==\"__main__\":\n\ts = input()\n\tt = input()\n\tif s[::-1] == t:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n", "import sys\r\nx = \"\".join(sys.stdin.readlines())\r\nnx = [some for some in x.splitlines()]\r\nif nx[0] == nx[1][::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def rightorwrong(s, t):\n count = 0\n if len(s)!=len(t):\n return \"NO\"\n for i in range(len(s)):\n if s[i]==t[-(i+1)]:\n count+=1\n if count==len(s):\n return \"YES\"\n else: return \"NO\"\n\ns = input().lower()\nt = input().lower()\nprint(rightorwrong(s, t))\n", "a=input()\r\nb=input()\r\nq=(b[::-1])\r\nif q==a:\r\n print('YES')\r\nelse:\r\n print('NO')", "i=input()\r\nm=input()\r\nc=i[::-1]\r\nif c == m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "s1=list(input())\ns2=list(input())\n\ns1.reverse()\nif s1==s2:\n print(\"YES\")\nelse:\n print(\"NO\")", "def correct_translation(berlandish, birlandish):\r\n if len(berlandish) != len(birlandish):\r\n return False\r\n for i in range(len(berlandish)):\r\n if berlandish[i] != birlandish[-(i + 1)]:\r\n return False\r\n return True\r\n\r\nif correct_translation(berlandish=input(), birlandish=input()):\r\n print('YES')\r\nelse:\r\n print('NO')", "x = input().strip()\r\ny = input().strip()\r\na = x[::-1]\r\nif a == y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = input()\r\ns2 = input()[::-1]\r\nres = \"YES\" if s1==s2 else \"NO\"\r\nprint(res)", "f_str, s_str = input(), input()\r\nsl_str = len(s_str)\r\nflag = True\r\n\r\nfor i, ch in enumerate(f_str, 1):\r\n if ch != s_str[sl_str - i]:\r\n flag = False\r\n break\r\n\r\nprint('YES') if flag else print('NO')", "a=input()\nb=input()\ncheck=''\nfor i in range (0,len(a)):\n check=check+a[len(a)-1-i]\nif(check==b):\n print('YES')\nelse:\n print('NO')", "s1 = input()\ns2 = input()\ns3 = ''\nfor i in range(len(s1)-1, -1, -1):\n s3 = s3 + s1[i]\nif s3 == s2:\n print('YES')\nelse:\n print('NO')\n\n", "x=input()\r\ny=input()\r\nrex = x[::-1]\r\nif rex == y :\r\n print(\"YES\")\r\nelif True :\r\n print(\"NO\")", "s1,s2 = input(),input()\r\nprint((\"YES\" if s1 == s2[::-1] else \"NO\"))\r\n", "if __name__ == '__main__':\r\n\ts_1 = input().strip(\" \")\r\n\ts_2 = input().strip(\" \")\r\n\tif s_1[::-1] == s_2:\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")", "print(\"YNEOS\"[(input()[::-1]!=input())::2])", "n=input()\r\nu=input()\r\nif n[::-1]==u:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = input()\r\nt = input()\r\nnrev = \"\".join(reversed(n))\r\nif t == nrev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "try:\r\n n,t = input(),input()\r\n if len(n) > 0 and len(n) <= 100 and n.isupper() == False and len(t) > 0 and len(t) <= 100 and t.isupper() == False:\r\n if n == t[::-1]: print(\"YES\")\r\n else: print(\"NO\")\r\n\r\nexcept: pass", "a = input()\r\nb = input()\r\ni =0\r\nc = 0\r\nwhile i < len(a) and len(a) == len(b):\r\n if a[i] == b[len(a)-i-1]:\r\n c+=1\r\n i+=1\r\nif c == len(a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = str(input())\r\nrevese = str(input())\r\nnew_word = \"\"\r\nstart = len(word)-1\r\ni=0\r\n\r\nfor i in range(start,-1,i-1):\r\n new_word+=word[i]\r\n\r\nprint(\"YES\") if new_word==revese else print(\"NO\")", "a, b = input(), input()\r\nc = [b[-i] for i in range(1, len(b) + 1)]\r\nb = ''\r\nfor i in range(len(c)):\r\n\tb += c[i]\r\nif a == b:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "s = input()\r\nsr = input()\r\nif s == sr[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import sys\r\n \r\nIS_INTERACTIVE = False\r\ninput = input # type: ignore\r\n \r\n# input: function\r\nif not IS_INTERACTIVE:\r\n (*data,) = sys.stdin.read().split(\"\\n\")[::-1]\r\n \r\n def input(): # type: ignore\r\n return data.pop()\r\n \r\n \r\ndef fprint(*args, **kwargs):\r\n print(*args, **kwargs, flush=True)\r\n \r\n \r\ndef eprint(*args, **kwargs):\r\n print(*args, **kwargs, file=sys.stderr)\r\n \r\n \r\nmod = 1000000007\r\n \r\n \r\ndef getList(type=int):\r\n return list(map(type, input().split()))\r\n \r\n \r\ndef getInp(type=int):\r\n return map(type, input().split())\r\n \r\n# Code From Here\r\n\r\ns1 = (input())\r\ns2 = input()\r\nif s1[::-1] == s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "x=input()\r\ny=input()\r\nl=len(x)\r\n\r\nif len(x)==len(y):\r\n s=\"\"\r\n for i in range(l-1,-1,-1):\r\n s+=y[i]\r\n \r\n if s==x:\r\n print(\"YES\")\r\n else:\r\n print (\"NO\")\r\nelse:\r\n print (\"NO\")\r\n ", "s=input()\r\nt=input()\r\nb=\"\"\r\nfor i in range(len(s)-1,-1,-1):\r\n a=s[i]\r\n b=b+a\r\nif b==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def solve(strng1,strng2):\r\n strng = ''.join(reversed(list(strng1)))\r\n if strng == strng2:\r\n return True\r\n else:\r\n return False\r\n\r\ns1 = str(input())\r\ns2 = str(input())\r\nif(solve(s1,s2)==True):\r\n print('YES')\r\nelse:\r\n print('NO')", "\r\nst_1 = input()\r\nst_2 = input()\r\nls_1 = [w for w in st_1]\r\nls_2 = [w for w in st_2]\r\nls = []\r\nwhile ls_1:\r\n ls.append(ls_1.pop())\r\nif ls == ls_2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "n = (str(input()))[::-1]\ny = str(input())\nif n == y:\n print(\"YES\")\nelse:\n print(\"NO\")", "s =input()\r\nt =input()\r\nstr=''\r\nfor i in reversed(s):\r\n str+=i\r\nif str==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nprint('YES' if s[::-1]==t else 'NO')\r\n", "s=input()\r\nt=input()\r\nprint(\"NYOE S\"[1 if s[::-1]==t else 0 ::2])", "a=input()\r\nb=input()\r\ndef f(a,b,):\r\n if b==a[::-1]:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\nprint(f(a,b))", "string = input()\r\nreverse_str = input()\r\nstring = list(string)\r\nts_string = []\r\ni = len(string) - 1\r\nwhile i >= 0:\r\n ts_string.append(string[i])\r\n i-=1\r\nts_string= ''.join(ts_string)\r\nif reverse_str == ts_string:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x = input()\r\ny = input()\r\nif str(x)[::-1] == str(y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def Translation(w1,w2):\r\n if w1[::-1] != w2:\r\n return 'NO'\r\n else:\r\n return 'YES'\r\ny1 = input()\r\ny2 = input()\r\nprint(Translation(y1,y2))", "# coding=utf-8\r\na=input()\r\nb=input()\r\nn=len(a)\r\nif n==len(b):\r\n for i in range(n):\r\n if a[i]!=b[n-1-i]:\r\n print('NO')\r\n break\r\n else:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n \t\t \t \t\t\t\t\t\t\t \t \t \t \t\t\t \t\t", "s1=input()\r\ns3=list(s1)\r\ns2=input()\r\ns4=list(s2)\r\ns4.reverse()\r\nif s3 == s4 :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def rev(s):\r\n l=[]\r\n for c in s:\r\n l=[c]+l\r\n return ''.join(l)\r\ns1=(str(input()))\r\ns2=(str(input()))\r\nif rev(s1)==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "berl =input()\r\nbirl = input()\r\ne= []\r\ni =[]\r\nfor char in berl:\r\n e+=char\r\n#print(e)\r\nfor char in birl:\r\n i+=char\r\n#print(i)\r\nif len(e) != len(i):\r\n print('NO')\r\n exit()\r\nk =0\r\nfor m in range(len(e)):\r\n if e[m] ==i[(len(e)-1) -m]:\r\n k =k+1\r\n continue\r\nif k == len(e):\r\n print('YES')\r\nelse:\r\n print('NO')", "# @author: sgshubham98\r\n# @created: 2020-05-27 14:43:24\r\ns = input()\r\nr = input()\r\nif s == r[::-1]:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s = input()\r\nt = input()\r\ns_list = []\r\ns_listrev = []\r\nfor a in s:\r\n s_list.append(a)\r\n\r\n\r\nfor y in range(1,len(s_list),1):\r\n s_listrev.append(s_list[-y])\r\ns_listrev.append(s_list[0])\r\n\r\nx = \"\".join(s_listrev)\r\nif x == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\n\"\"\"Untitled4.ipynb\n\nAutomatically generated by Colaboratory.\n\nOriginal file is located at\n https://colab.research.google.com/drive/1zJg4WzXbdRMyJfzbkYUJQHOChrqyKcMt\n\"\"\"\n\ns=input()\nt=input()\nt=t[::-1]\nif s==t:\n print('YES')\n raise SystemExit\nprint('NO')\n\n", "# https://codeforces.com/problemset/problem/41/A\r\n\r\nberland = input()\r\nbirland = input()\r\n\r\nif berland == birland[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = input()\r\nr = input()\r\nprint('YES' if n == r[::-1] else 'NO')", "#J\ndef recur(a, b, i, j):\n if (i<len(a) and j>=0):\n if (a[i]==b[j-1]):\n return recur(a, b, i+1, j-1)\n else :\n return 1\n else :\n return 0\na = str(input())\nb = str(input())\ntotal = int(0)\ntotal += recur(a, b, 0, len(b))\nif (total==1):\n print(\"NO\")\nelse :\n print(\"YES\")\n \t\t \t \t \t \t \t \t \t\t\t\t\t \t \t \t", "# cook your dish here\nstartstr=input()\nsecondStr=input()\nrevrseStr=startstr[::-1]\nif revrseStr==secondStr:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "txt = input()\r\nrtxt = input()\r\nreversed_txt = txt[::-1]\r\nif reversed_txt == rtxt:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def solve(string, target):\r\n return \"NO\" if string[::-1] != target else \"YES\"\r\n\r\nstring = input()\r\ntarget = input()\r\nprint(solve(string, target))", "r = input()\r\nv=input()\r\nq=v[::-1]\r\nif(r==q):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s,t=input(),input()\r\nm=0\r\n\r\nfor i,j in list(zip(s,t[::-1])):\r\n \r\n if i==j:\r\n m+=1\r\nif m==len(s):\r\n \r\n print('YES')\r\n \r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\ns_re=\"\"\r\nn=len(s)\r\nfor i in range(n):\r\n s_re=s_re+s[n-1-i]\r\nif s_re==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x = input()\r\ny = input()\r\nrevx = ''.join(reversed(x))\r\nif revx == y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "unos = input()\nunosUnazad = input()\n\n\nif unos == unosUnazad[-1::-1]:\n print(\"YES\")\n \nelse:\n print(\"NO\")\n \n ", "s = input()\r\nt = input()\r\n\r\nif len(s) != len(t):\r\n print(\"NO\")\r\n exit()\r\nmin_len = min(len(s), len(t))\r\nfor i in range(min_len):\r\n if s[i] != t[len(t) - i - 1]:\r\n print(\"NO\")\r\n exit()\r\nprint(\"YES\")\r\n", "word = input()\nRword = input()\n\nif Rword == word[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "num1=input()\r\nnum2=input() \r\nnum3=num2[::-1]\r\nif num1 == num3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t=input()\r\ns=input()\r\nfor i in range(0,len(t)):\r\n if t[i]!=s[len(s)-i-1]:\r\n print(\"NO\")\r\n quit()\r\nprint(\"YES\")", "s=input()\r\nt=input()\r\ns1=\"\"\r\nx=len(s)-1\r\nfor i in range(len(s)):\r\n s1+=s[x]\r\n x-=1\r\nif s1==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "if input()[::-1] == input(): print (\"YES\") \r\nelse: print (\"NO\")", "a=input()\r\nb=input()\r\nif a==b[::-1]:\r\n\tprint (\"YES\")\r\nelse:\r\n\tprint (\"NO\")", "a = input()\r\nb = input()\r\ns = list(a)\r\nk = list(b)\r\nf = 0\r\nif len(s) == len(k):\r\n for i in range (len(s)):\r\n if s[i]!=k[len(s)-i-1]:\r\n f = 1\r\n if f == 0:\r\n print('YES')\r\n else: print('NO')\r\nelse: print('NO')\r\n", "s=input()\r\nsrev=input()\r\nif srev==s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input().strip()\r\nt=input().strip()\r\nprint (\"YES\") if s==t[::-1] else print(\"NO\")", "word = input()\r\nuser = input()\r\ntranslated = word[::-1]\r\nif user == translated:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s=input()\nr=input()\nt=r[::-1]\nif(s==t):\n print(\"YES\") #output\nelse:\n print(\"NO\") #output\n \t\t\t\t\t\t \t \t \t \t\t\t \t \t \t\t", "x = input()\r\ny = input()\r\n\r\nlen_x = len(x)\r\nlen_y = len(y)\r\ntag = 0\r\n\r\nfor i in range(len_x):\r\n j = len_y - 1 - i\r\n if j < 0:\r\n break\r\n if x[i] == y[j]:\r\n tag = 1\r\n else:\r\n tag = 0\r\n break\r\n\r\nif tag == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "t = input()\ns = input()\n\nif t[::-1] == s:print('YES')\nelse:print('NO')\n", "str1=input()\r\nstr2=input()\r\ni=-1\r\nstr3=\"\"\r\nwhile i>=-len(str2):\r\n str3=str3+str2[i]\r\n i=i-1\r\nif str1==str3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "slovo=input()\r\nslovo_1=input()\r\ntest_slovo=''\r\n\r\nfor i in range(1,len(slovo)+1):\r\n test_slovo+=slovo[-i]\r\n\r\nif slovo_1==test_slovo:\r\n print('YES')\r\nelse:\r\n print(\"NO\")", "from sys import stdin\r\ninput=lambda:stdin.readline().strip()\r\ns=input()\r\ns1=input()\r\na=s[::-1]\r\nif s1==a:\r\n print('YES')\r\nelse:\r\n print(\"NO\")\r\n", "def reverse(text):\r\n r_text = ''\r\n index = len(text) - 1\r\n\r\n while index >= 0:\r\n r_text += text[index] #string canbe concatenated\r\n index -= 1\r\n\r\n return r_text\r\ns=str(input())\r\nt=str(input())\r\nz=reverse(s)\r\n\r\nif z==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\np=input()\r\nif s[::-1]==p:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\nn1=input()\r\nn2=n1[::-1]\r\nif n==n2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word1 = input()\nword2 = input()\n\na = reversed(list(word1))\nb =''.join(a)\n\nif word2 == b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "#for taking input\r\nq=input()\r\nr=input()\r\n#line for reversing the text\r\nr=r[::-1]\r\n# print(r) printing the text\r\n\r\nif r==q:#comparing the two inputs\r\n print('YES')\r\nelse:\r\n print('NO')", "\r\n\r\ndef correct_trans(s, t):\r\n if len(s) == len(t):\r\n n = len(s)\r\n else:\r\n return \"NO\"\r\n for i in range(n):\r\n if s[i] != t[n-1-i]:\r\n return \"NO\"\r\n return \"YES\" \r\n\r\nber = input()\r\nbir = input()\r\nprint(correct_trans(ber, bir))\r\n", "o=input()\nm=input()\nif o[::-1]==m:\n print(\"YES\")\nelse: print(\"NO\")\n \t\t \t \t\t \t \t \t \t\t \t \t\t \t", "string_word = str(input())\r\nrev_word = string_word[::-1]\r\nrev_user = str(input())\r\nif rev_user == rev_word:\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\") ", "s=input()\r\ns1=input()\r\ns2=s[::-1]\r\nif s1==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "palabra = input()\nreversa = input()\nreverse = list(palabra)\ncontrario = reverse[::-1]\nultima = list(reversa)\nif contrario == ultima:\n print(\"YES\")\nelse:\n print(\"NO\")\n#hldlhflhflhf\n\t \t \t\t\t \t\t\t \t \t \t \t \t\t", "s=input()\r\nt=input()\r\nis_rev=True\r\n\r\nfor c,d in zip(s,reversed(t)):\r\n if c!=d:\r\n is_rev=False\r\n break\r\nif is_rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = input()\r\ns2 = input()\r\nanswer = 0\r\nif len(s1) != len(s2):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(s1)):\r\n if s1[i] == s2[len(s1)-1-i]:\r\n answer+=1\r\n else:\r\n answer+=0\r\n if answer == len(s1):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "n = input()\nm= input()\nif n[::-1]==m:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "n1=input()\r\nn2=input()\r\nif(n1[::-1]==n2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s= input()\r\nt = input()\r\nans = 0\r\nlength = len(s)\r\nif len(t) != len(s):\r\n print(\"NO\")\r\nelse:\r\n for i in range(length):\r\n if t[length-1-i] == s[i]:\r\n ans = ans+1\r\n if ans == length:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "# # # def input_matrix():\r\n# # # print(\"Enter four floating point numbers:\")\r\n# # # a = []\r\n# # # count = 0\r\n# # # while len(a) < 4:\r\n# # # x = input()\r\n# # # try:\r\n# # # val = float(x)\r\n# # # a.append(val)\r\n# # # except ValueError:\r\n# # # continue\r\n# # # return a\r\n# # #\r\n# # #\r\n# # # print(input_matrix())\r\n# #\r\n# #\r\n# #\r\n# # # def input_matrix():\r\n# # # print(\"Enter four floating point numbers:\")\r\n# # # ##########################\r\n# # # ### START OF YOUR CODE ###\r\n# # # ##########################\r\n# # # a = []\r\n# # # while len(a) < 4:\r\n# # # x = input()\r\n# # # try:\r\n# # # val = float(x)\r\n# # # a.append(val)\r\n# # # except ValueError:\r\n# # # continue\r\n# # # return tuple(''.join(a))\r\n# # #\r\n# # #\r\n# # # print(input_matrix())\r\n# #\r\n# #\r\n# # # def inverse(M):\r\n# # # a = M[0] * M[3] - M[2] * M[1]\r\n# # # if a < 0:\r\n# # # a = a * (-1)\r\n# # # b = [M[3]/a, -M[1]/a, -M[2]/a, M[0]/a]\r\n# # # return b\r\n# # # print(inverse((1.5, 3, 5, 4)))\r\n# #\r\n# #\r\n# # # def f(x):\r\n# # # if x < 0:\r\n# # # x *= -1\r\n# # # x1 = 1\r\n# # # for i in range(len(str(x))):\r\n# # # x1 *= int(str(x)[i])\r\n# # # x = x1\r\n# # # if len(str(x)) != 1:\r\n# # # return f(x) + 1\r\n# # # else:\r\n# # # return 1\r\n# #\r\n# # # def P(i):\r\n# # # ##########################\r\n# # # ### START OF YOUR CODE ###\r\n# # # ##########################\r\n# # # if i == 1 or i == 2 or i == 0:\r\n# # # return 1\r\n# # # else:\r\n# # # return P(i - 2) + P(i - 3)\r\n# # # print(P(8))\r\n# #\r\n# # # def part1and2(dataset, threshold):\r\n# # # summary = []\r\n# # # c = 0\r\n# # # d = 0\r\n# # # f = 0\r\n# # # o = 0\r\n# # # u = 0\r\n# # # t = 0\r\n# # # l = 0\r\n# # # b = 0\r\n# # # h = 0\r\n# # # for i in dataset:\r\n# # # for j in i:\r\n# # # if j[0] > threshold:\r\n# # # if j[1] == \"Cat\":\r\n# # # c += 1 / len(dataset)\r\n# # # if j[1] == \"Dog\":\r\n# # # d += 1 / len(dataset)\r\n# # # if j[1] == \"Fish\":\r\n# # # f += 1 / len(dataset)\r\n# # # if j[1] == \"Other\":\r\n# # # o += 1 / len(dataset)\r\n# # # if j[1] == \"Undecided\":\r\n# # # u += 1 / len(dataset)\r\n# # # if j[1] == \"Turtle\":\r\n# # # t += 1 / len(dataset)\r\n# # # if j[1] == \"Bird\":\r\n# # # b += 1 / len(dataset)\r\n# # # if j[1] == \"Lizard\":\r\n# # # l += 1 / len(dataset)\r\n# # # if j[1] == \"Hamster\":\r\n# # # h += 1 / len(dataset)\r\n# # #\r\n# # # summary.append((c, \"Cat\"))\r\n# # # summary.append((d, \"Dog\"))\r\n# # # summary.append((f, \"Fish\"))\r\n# # # summary.append((o, \"Other\"))\r\n# # # summary.append((u, \"Undefined\"))\r\n# # # if b > 0.0:\r\n# # # summary.append((b, \"Bird\"))\r\n# # # if t > 0.0:\r\n# # # summary.append((t, \"Turtle\"))\r\n# # # if l > 0.0:\r\n# # # summary.append((l, \"Lizard\"))\r\n# # # if h > 0.0:\r\n# # # summary.append((t, \"Hamster\"))\r\n# # # return summary\r\n# #\r\n# # recovered = [{'name': 'Laura', 'tested': [2, 10, 22]}, {'name': 'Sergey', 'tested': [12, 5, 14]}, {'name': 'Thomas', 'tested': [7, 15]}, {'name': 'Angjoo', 'tested': [12, 18, 23]}]\r\n# # # keep = []\r\n# # # for patient in recovered:\r\n# # # for i in patient['tested']:\r\n# # # min = min(patient['tested'])\r\n# # # if min < 5:\r\n# # # keep = keep.append(patient['name'])\r\n# # # print(keep)\r\n# #\r\n# #\r\n# # # PART 1\r\n# #\r\n# #\r\n# # # PART 2\r\n# #\r\n# # inQuarantine = [{'name': 'Anurak', 'since': 2, 'tested': [2], 'symptoms': ['fever', 'cough', 'loss of smell']},\r\n# # {'name': 'Jonas', 'since': 4, 'tested': [6, 4], 'symptoms': ['fever', 'cough']}]\r\n# #\r\n# # day = 0\r\n# # while day <= 30:\r\n# # if day == 3:\r\n# # # add the new patient\r\n# # new_patient = {'name': 'Melanie', 'since': 0, 'tested': [0], 'symptoms': ['fever']}\r\n# # inQuarantine.append(new_patient)\r\n# #\r\n# # for patient in inQuarantine:\r\n# # # update the number of days in quarantine\r\n# # patient['since'] += 1\r\n# #\r\n# # # increment the number of days passed since the patient was tested\r\n# # patient['tested'][0] += 1\r\n# #\r\n# # if day == 1:\r\n# # # update the symptoms\r\n# # if patient['name'] == 'Anurak':\r\n# # patient['symptoms'].replace('')\r\n# # elif patient['name'] == 'Jonas':\r\n# # patient['symptoms'].extend('tiredness')\r\n# #\r\n# # elif day == 2:\r\n# # if patient['name'] == 'Anurak':\r\n# # # correct the typo\r\n# # patient['name'] = 'Anurag'\r\n# #\r\n# # elif patient['name'] == 'Jonas':\r\n# # # add a new test\r\n# # patient['tested'].append(1)\r\n# #\r\n# # if day == 2:\r\n# # # update the symptoms\r\n# # if patient['name'] == 'Anurak':\r\n# # patient['symptoms'].add('fever')\r\n# #\r\n# # if day < 3 or day == 29:\r\n# # # Show the updates\r\n# # print('Day: ', day, inQuarantine)\r\n# # print('-'*80)\r\n# #\r\n# # day += 1\r\n#\r\n# # Команда\r\n# # x = int(input())\r\n# # result = 0\r\n# # count = 0\r\n# # for i in range(x):\r\n# # number = input()\r\n# # z = number.split()\r\n# # count = z.count(\"1\")\r\n# # if count >= 2:\r\n# # result += 1\r\n# # else:\r\n# # result += 0\r\n# # print(result)\r\n#\r\n# # Следующий раунд\r\n# # count = 0\r\n# # z = [int(item) for item in input().split()]\r\n# # x = z[1]\r\n# # y = [int(item) for item in input().split()]\r\n# # place = y[x-1]\r\n# #\r\n# # for i in y:\r\n# # if i == 0:\r\n# # count += 0\r\n# # elif i >= place:\r\n# # count += 1\r\n# # else:\r\n# # count += 0\r\n# # print(count)\r\n#\r\n#\r\n# # Упражнение на строки\r\n# # x = input()\r\n# # vowels = [\"A\", \"O\", \"Y\", \"E\", \"U\", \"I\", \"a\", \"o\", \"y\", \"e\", \"u\", \"i\"]\r\n# # count = 0\r\n# # for i in x:\r\n# # if i in vowels:\r\n# # x = x.replace(i, \"\")\r\n# # x = x.lower()\r\n# # x = '.' + '.'.join(x)\r\n# #\r\n# # print(x)\r\n#\r\n# # Юный Физик\r\n# # x = int(input())\r\n# # b = 0\r\n# # total = 0\r\n# # for i in range(x):\r\n# # z = [int(item) for item in input().split()]\r\n# # b = sum(z)\r\n# # total += b\r\n# # # for i in z:\r\n# # # total = total + i\r\n# # if total == 0:\r\n# # print(\"YES\")\r\n# # else:\r\n# # print(\"NO\")\r\n#\r\n# # Между офисами\r\n# # x = int(input())\r\n# # count_s = 0\r\n# # count_f = 0\r\n# # city = input()\r\n# # for i in range(len(city)-1):\r\n# # if city[i] == \"S\" and city[i+1] == \"F\":\r\n# # count_s += 1\r\n# # elif city[i] == \"F\" and city[i+1] == \"S\":\r\n# # count_f += 1\r\n# # else:\r\n# # count_f += 0\r\n# # count_s += 0\r\n# # if count_s > count_f:\r\n# # print(\"YES\")\r\n# # else:\r\n# # print(\"NO\")\r\n#\r\n# # Красивая матрица\r\n# # z = []\r\n# # y = 0\r\n# # count = 0\r\n# # for i in range(5):\r\n# # x = [int(item) for item in input().split()]\r\n# # z.append(x)\r\n# # for i in z:\r\n# # if 1 in i:\r\n# # count += 1\r\n# # r = count\r\n# # y = i.index(1) + 1\r\n# # else:\r\n# # count += 1\r\n# #\r\n# # print(abs(3-r)+abs(3-y))\r\n#\r\n# # Система регистрации\r\n#\r\n# # x = int(input())\r\n# # list1 = []\r\n# # output = []\r\n# # for i in range(x):\r\n# # word = input()\r\n# # list1.append(word)\r\n# # z = list1.count(word)\r\n# # if z > 1:\r\n# # output.append(word + str(1*(z-1)))\r\n# # else:\r\n# # output.append(\"OK\")\r\n# # for i in output:\r\n# # print(i)\r\n#\r\n#\r\n# # z = input()\r\n# # count = 0\r\n# # for i in z:\r\n# # if i != '':\r\n# # count += 1\r\n# # z = z.replace(i, '')\r\n# # print(z, len(z), count)\r\n# # if len(z) == 0:\r\n# # count -=1\r\n# # if count % 2 == 0:\r\n# # print('CHAT WITH HER!')\r\n# # else:\r\n# # print('IGNORE HIM!')\r\n#\r\n# # Счастливое число\r\n# # x = int(input())\r\n# # count = 0\r\n# # for i in str(x):\r\n# # if i == '4' or i == '7':\r\n# # count += 1\r\n# # else:\r\n# # count = 0\r\n# # if count == len(str(x)):\r\n# # print('YES')\r\n# # elif x % 4 == 0 or x % 7 == 0 or x% 47 == 0:\r\n# # print('YES')\r\n# # else:\r\n# # print('NO')\r\n#\r\n# # foo = input()\r\n# # d = ['h', 'e', 'l', 'o']\r\n# # result = []\r\n# # for c in foo:\r\n# # if c in d:\r\n# # result.append(c)\r\n# # result = ''.join(result)\r\n# # print(result)\r\n# # if 'helo' in result:\r\n# # print('YES')\r\n# # else:\r\n# # print('NO')\r\n#\r\n# # x = [int(item) for item in input().split()]\r\n# # word = list(input())\r\n# # temp = ''\r\n# # for i in range(x[1]):\r\n# # for i in range(0, x[0]-1, 2):\r\n# # print(i)\r\n# # if word[i] == 'B' and word[i+1] == 'G':\r\n# # word[i+1] = 'B'\r\n# # word[i] = 'G'\r\n# # print(''.join(word))\r\n#\r\n#\r\n# # def get_permutations(sequence):\r\n# # if (len(sequence) == 1): return [sequence]\r\n# # result = []\r\n# # for i, v in enumerate(sequence):\r\n# # result += [v + p for p in get_permutations(sequence[:i] + sequence[i + 1:])]\r\n# # return result\r\n# # print(get_permutations('aa'))\r\n#\r\n#\r\n# # import random\r\n# #\r\n# # list1 = []\r\n# # n = random.randint(3, 21)\r\n# # for element in range(n):\r\n# # list1.append(random.randint(1, 100))\r\n# #\r\n# # print(\"My list length is\", n)\r\n# # print(\"List1 (Original list):\")\r\n# # print(list1)\r\n# #\r\n# # list2 = []\r\n# # for i in range(n):\r\n# # if i == 0:\r\n# # list2.append(list1[i] + list1[i+1])\r\n# # elif i == n-1:\r\n# # list2.append(list1[i] + list1[i - 1])\r\n# # else:\r\n# # list2.append(list1[i] + list1[i + 1] + list1[i - 1])\r\n# # print(\"List2(Sum of neighbors of List1):\")\r\n# # print(list2)\r\n# #\r\n# # print('List3 (List1 and List2 merged): ')\r\n# # list3 = []\r\n# # for i in range(n):\r\n# # list3.append(list1[i])\r\n# # list3.append(list2[i])\r\n# # print(list3)\r\n# #\r\n# # print('List3 with odd numbers removed:')\r\n# # for i in list3:\r\n# # if (i % 2) != 0:\r\n# # list3.remove(i)\r\n# # print(list3)\r\n# #\r\n# # list4 = []\r\n# # print('List4 (Summing List3 from two sides): ')\r\n# #\r\n# # x = len(list3)\r\n# # for i in range(x):\r\n# # if i == 0:\r\n# # list4.append(list3[i] + list3[i+1])\r\n# # elif i == n-1:\r\n# # list4.append(list3[i] + list3[i - 1])\r\n# # else:\r\n# # list4.append(list3[i] + list3[i + 1] + list3[i - 1])\r\n# # print(list4)\r\n#\r\n# # import copy\r\n# #\r\n# # def determinantOfMatrix(matrix):\r\n# #\r\n# # total = 0\r\n# # if len(matrix) == 1:\r\n# # return matrix[0][0]\r\n# # elif len(matrix) == 2 and len(matrix[0]) == 2:\r\n# # val = matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]\r\n# # return val\r\n# # else:\r\n# # for i in range(len(matrix)):\r\n# # plus_or_minus = (-1)**i\r\n# # smaller_det = determinantOfMatrix([row[:i] + row[i+1:] for row in (matrix[:0] + matrix[1:])])\r\n# # total += (plus_or_minus * matrix[0][i] * smaller_det)\r\n# #\r\n# # return total\r\n# # print(determinantOfMatrix([[2,3,1],\r\n# # [-4,5,2],\r\n# # [2,1,-4]]))\r\n#\r\n# # def solve(matrix, size):\r\n# # c = []\r\n# # d = 0\r\n# # print(matrix, size)\r\n# # if size == 0:\r\n# # for i in range(len(matrix)):\r\n# # d = d + matrix[i]\r\n# # return d\r\n# # elif len(matrix) == 4:\r\n# # c = (matrix[0] * matrix[3]) - (matrix[1] * matrix[2])\r\n# # print(c)\r\n# # return c\r\n# # else:\r\n# # for j in range(size):\r\n# # new_matrix = []\r\n# # for i in range(size * size):\r\n# # if i % size != j and i >= size:\r\n# # new_matrix.append(matrix[i])\r\n# #\r\n# # c.append(solve(new_matrix, size - 1) * matrix[j] * ((-1) ** (j + 2)))\r\n# #\r\n# # d = solve(c, 0)\r\n# # return d\r\n#\r\n#\r\n# # def print_paths(grid):\r\n# # a, b = 0, 0\r\n# #\r\n# # if grid[0][0] > grid[-1][-1] or (grid[-1][-1] < grid[-2][-1] and grid[-1][-1] < grid[-1][-2]):\r\n# # pass\r\n# #\r\n# # while True:\r\n# #\r\n#\r\n# # Python3 program to Print all possible paths from\r\n# # top left to bottom right of a mXn matrix\r\n#\r\n# #\r\n# # def findPaths(mat, path, i, j):\r\n# # (M, N) = (len(mat), len(mat[0]))\r\n# #\r\n# # # if we have reached the last cell, print the route\r\n# # if i == M - 1 and j == N - 1:\r\n# # print(path + [mat[i][j]])\r\n# # return\r\n# #\r\n# # # include current cell in path\r\n# # path.append(mat[i][j])\r\n# #\r\n# # # move right\r\n# # if 0 <= i < M and 0 <= j + 1 < N:\r\n# # findPaths(mat, path, i, j + 1)\r\n# #\r\n# # # move down\r\n# # if 0 <= i + 1 < M and 0 <= j < N:\r\n# # findPaths(mat, path, i + 1, j)\r\n# #\r\n# # # move up\r\n# # if 0 <= i - 1 < M and 0 <= j < N:\r\n# # findPaths(mat, path, i - 1, j)\r\n# #\r\n# # # move left\r\n# # if 0 <= i < M and 0 <= j - 1 < N:\r\n# # findPaths(mat, path, i - 1, j)\r\n# #\r\n# # # remove current cell from path\r\n# # path.pop()\r\n# #\r\n# #\r\n# # if __name__ == '__main__':\r\n# # mat = [[1,20,30],\r\n# # [4,8,40]]\r\n# # path = []\r\n# #\r\n# # # start from (0, 0) cell\r\n# # x = y = 0\r\n# #\r\n# # findPaths(mat, path, x, y)\r\n#\r\n# # Python3 program to find longest\r\n# # increasing path in a matrix.\r\n#\r\n#\r\n#\r\n#\r\n# # def findPaths(grid, path, i, j):\r\n# # (M, N) = (len(grid), len(grid[0]))\r\n# #\r\n# # # if we have reached the last cell, print the route\r\n# # if i == M - 1 and j == N - 1:\r\n# # print(path + [grid[i][j]])\r\n# # return\r\n# #\r\n# # # include current cell in path\r\n# # path.append(grid[i][j])\r\n# #\r\n# # # move right\r\n# # if 0 <= i < M and 0 <= j + 1 < N:\r\n# # findPaths(grid, path, i, j + 1)\r\n# #\r\n# # # move down\r\n# # if 0 <= i + 1 < M and 0 <= j < N:\r\n# # findPaths(grid, path, i + 1, j)\r\n# #\r\n# # # remove current cell from path\r\n# # path.pop()\r\n# #\r\n# #\r\n# # if __name__ == '__main__':\r\n# # grid = [\r\n# # [1, 2, 3],\r\n# # [4, 5, 6],\r\n# # [7, 8, 9]\r\n# # ]\r\n# #\r\n# # path = []\r\n# #\r\n# # # start from (0, 0) cell\r\n# # x = y = 0\r\n# #\r\n# # findPaths(grid, path, x, y)\r\n#\r\n#\r\n#\r\n#\r\n# import string\r\n#\r\n# ### HELPER CODE ###\r\n# def load_words(file_name):\r\n# '''\r\n# file_name (string): the name of the file containing\r\n# the list of words to load\r\n#\r\n# Returns: a list of valid words. Words are strings of lowercase letters.\r\n#\r\n# Depending on the size of the word list, this function may\r\n# take a while to finish.\r\n# '''\r\n# # inFile: file\r\n# inFile = open(file_name, 'r')\r\n# # wordlist: list of strings\r\n# wordlist = []\r\n# for line in inFile:\r\n# wordlist.extend([word.lower() for word in line.split(' ')])\r\n# return wordlist\r\n#\r\n# def is_word(word_list, word):\r\n# '''\r\n# Determines if word is a valid word, ignoring\r\n# capitalization and punctuation\r\n#\r\n# word_list (list): list of words in the dictionary.\r\n# word (string): a possible word.\r\n#\r\n# Returns: True if word is in word_list, False otherwise\r\n#\r\n# For Example: is_word(word_list, 'bat') returns True\r\n# and is_word(word_list, 'asdf') returns False\r\n# '''\r\n# word = word.lower()\r\n# word = word.strip(\" !@#$%^&*()-_+={}[]|\\:;'<>?,./\\\"\")\r\n# return word in word_list\r\n#\r\n# ### END HELPER CODE ###\r\n#\r\n# WORDLIST_FILENAME = 'words.txt'\r\n#\r\n# class Message(object):\r\n# def __init__(self, text):\r\n# self.text = text\r\n#\r\n# def get_message_text(self):\r\n# self.message_text = self.text\r\n# return self.message_text\r\n#\r\n# def get_valid_words(self):\r\n# self.valid_words = load_words(WORDLIST_FILENAME)\r\n# self.valid_words1 = self.valid_words.copy()\r\n# return self.valid_words1\r\n#\r\n# def shift_letter(self, letter, key):\r\n# self.letter = letter\r\n# self.key = key\r\n# if self.letter.islower() and self.letter.isalpha():\r\n# self.alphabet = ['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\n# return str(self.alphabet[(self.alphabet.index(self.letter) + self.key) % len(self.alphabet)])\r\n# elif self.letter.isupper() and self.letter.isalpha():\r\n# self.alphabet = ['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\n# return str(self.alphabet[(self.alphabet.index(self.letter) + self.key) % len(self.alphabet)])\r\n# else:\r\n# return self.letter\r\n#\r\n# def apply_vigenere(self, key):\r\n# self.keyy1 = key.copy()\r\n# self.encrypted_message = ''\r\n# for i in range(len(self.message_text) - len(key)):\r\n# self.keyy1.append(self.keyy1[i])\r\n# for j in range(len(self.message_text)):\r\n# self.encrypted_message += str(self.shift_letter(self.message_text[j], self.keyy1[j]))\r\n# return self.encrypted_message\r\n#\r\n#\r\n# class PlaintextMessage(Message):\r\n# def __init__(self, text, key):\r\n# self.text = text\r\n# self.keyyy = key\r\n#\r\n# def get_key(self):\r\n# self.key1 = self.keyyy.copy()\r\n# return self.key1\r\n#\r\n# def get_message_text_encrypted(self):\r\n#\r\n# self.message_text = self.text\r\n# return self.apply_vigenere(self.keyyy)\r\n#\r\n# def change_key(self, key):\r\n# self.keyyy = key\r\n#\r\n#\r\n# class CiphertextMessage(Message):\r\n# def __init__(self, text):\r\n# self.text = text\r\n#\r\n# def decrypt_message(self):\r\n# self.message_words = self.text.split()\r\n# self.message_text1 = self.text\r\n# self.message_words1 = []\r\n# self.all_vars = []\r\n# contin = True\r\n# for i in range(1, 13):\r\n# for j in range(1, 13):\r\n# for k in range(1, 13):\r\n# contin = True\r\n# self.keyy = [26 - i, 26 - j, 26 - k]\r\n# self.decrypted_message = ''\r\n# for g in range(len(self.text) - len(self.keyy)):\r\n# self.keyy.append(self.keyy[g])\r\n# self.message_text = ' '.join(self.message_words)\r\n# if '--' in self.message_text1:\r\n# self.message_text = self.message_text.split('--')[0]\r\n# for h in self.apply_vigenere(self.keyy).split():\r\n# if is_word(load_words(WORDLIST_FILENAME), h):\r\n# self.message_words1.append(h)\r\n# else:\r\n# contin = False\r\n# self.message_words1 = []\r\n# break\r\n# else:\r\n# for h in self.apply_vigenere(self.keyy).split():\r\n# if is_word(load_words(WORDLIST_FILENAME), h):\r\n# self.message_words1.append(h)\r\n# else:\r\n# contin = False\r\n# self.message_words1 = []\r\n# break\r\n# if contin:\r\n# self.message_text = self.message_text1\r\n# if i == j == k:\r\n# return ([i], self.apply_vigenere([26 - i, 26 - j, 26 - k]))\r\n# else:\r\n# return ([i, j, k], self.apply_vigenere([26 - i, 26 - j, 26 - k]))\r\n#\r\n# if __name__ == '__main__':\r\n# '''\r\n# Can you find out what this hidden message says?\r\n# Uncomment the next lines to find out!\r\n# '''\r\n# # ciphertext = CiphertextMessage('\"Drmu spna vwvu bz ay nbmhd zmqlxbpcbz boo dkg dpli ky ay nbmhd teapmqhxa kvk ijdwyc, mqcstpjiaswu epvt tctz ay arm xmed sodlv\" [Jysiu Oyomuo]')\r\n# # decrypted = ciphertext.decrypt_message()\r\n# # print(decrypted[1])\r\n# pass\r\n#\r\n#\r\n# c = CiphertextMessage('\"Oz Jzf Eclty Qzc Alddtyr Epded zc Oz Jzf Eclty Qzc Ncpletgp Tybftcj?\" --Yzlx Nszxdvj')\r\n# d = c.decrypt_message()\r\n# print(d)\r\n\r\nword = input()\r\nword1 = input()\r\nif word != word1[::-1]:\r\n print('NO')\r\nelse:\r\n print('YES')", "def translation(w, r):\r\n if w[::-1] != r:\r\n return 'NO'\r\n else:\r\n return 'YES'\r\na = input()\r\nb = input()\r\nprint(translation(a, b))", "n1=input()\r\nn2=input()\r\nm=n2[::-1]\r\nif n1==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def solve(s,t):\r\n j=len(t)-1\r\n for i in range(len(s)):\r\n if not s[i]==t[j]:\r\n print('NO')\r\n return\r\n j-=1\r\n print('YES')\r\n return\r\n\r\ns=list(input())\r\nt=list(input())\r\nsolve(s,t)\r\n\r\n \r\n\r\n\r\n \r\n \r\n \r\n", "if __name__ == \"__main__\":\r\n s=input()\r\n t=input()\r\n temp=s[::-1]\r\n if temp==t:\r\n print(\"YES\")\r\n else:\r\n print('NO')", "a=input()\nb=input()\nc=a[::-1]\nif c==b:\n print('YES')\nelse:\n print('NO')", "'''\nSolution\n\nTo find problems: [https://surya1231.github.io/Codeforces-contest/]\nhttps://codeforces.com/contest/1493/problem/B\n'''\n\n# t = int(input())\n\n# def solve():\n# pass\n\n# while t:\n\n# print( solve() )\n\n# t -= 1\n\na = input()\nb = input()\n\nif a == b[::-1]: print('YES')\nelse: print('NO')", "s = input()\r\nt = input()\r\nres = \"\"\r\nfor i in range(len(s)-1,-1,-1):\r\n res += s[i]\r\n\r\nif t == res:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "k=str(input())\r\nl=str(input())\r\nm=k[::-1]\r\nif(m==l):\r\n print('YES')\r\nelse:\r\n print('NO')", "print(\"YES\") if list(input()) == list(input())[::-1] else print(\"NO\")\n\n \t\t \t\t \t\t\t \t\t \t\t \t \t\n\t \t\t\t \t\t\t\t \t\t \t \t \t \t", "a = input()\r\nt = input()\r\nres = a[::-1]\r\n\r\nif t == res:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "S1 = input()\r\nS2 = input()\r\nif(S2 == S1[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nr = input()\r\n\r\ni = 0\r\nj = len(s) - 1\r\n\r\nif len(s) != len(r):\r\n print('NO')\r\n exit()\r\n\r\nwhile j >= 0:\r\n if s[i] == r[j]:\r\n i += 1\r\n j -= 1\r\n continue\r\n else:\r\n print('NO')\r\n exit()\r\n\r\nprint('YES')\r\nexit()", "n=input()\nn1=input()\nx=n[::-1]\nif(x==n1):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t \t \t\t \t \t \t \t \t\t", "word = str(input())\r\ntrans = str(input())\r\n\r\nif word[::-1] == trans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nz=input()\r\nb=len(a)\r\np=len(z)\r\nif p!=b:\r\n print('NO')\r\nelse:\r\n for i in range(b):\r\n if i==b-1:\r\n if a[i]==z[b-1-i]:\r\n print('YES')\r\n else:\r\n print('NO')\r\n break\r\n else:\r\n if a[i]==z[b-1-i]:\r\n pass\r\n else:\r\n print('NO')\r\n break\r\n \r\n", "a=list(input())\r\na.reverse()\r\nb=list(input())\r\nfor x in range(len(a)):\r\n if a[x] is not b[x]:\r\n print(\"NO\")\r\n exit(0)\r\nprint(\"YES\")", "s=input()\r\nb=input()\r\ns=s[::-1]\r\n# print(s)\r\nif(s==b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\nprint('YES' if input()==s[::-1] else 'NO')\n\n\n", "s = input()\nt = input()\ns_word =list(s)\ns_word.reverse()\n\ntt = ''\nfor i in s_word:\n tt += i\n\nif t == tt:\n print('YES')\nelse:\n print('NO')\n\t \t \t \t \t \t\t \t\t \t\t \t\t\t", "s = list(input())\r\nt = list(input())\r\nif len(s) == len(t):\r\n ans = 'YES'\r\n for i in range(0,len(s)):\r\n if s[i]!=t[len(t)-1-i]:\r\n ans = 'NO'\r\n break\r\n print(ans)\r\nelse:\r\n print('NO')", "x = input()\ny = input()\ny = y[::-1]\nif x == y:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t \t \t \t \t\t \t\t\t \t \t\t \t \t \t", "sor=input()\r\ntran=input()\r\nif(sor[::-1]==tran):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word = input()\r\ntranslation = input()\r\nif translation[::-1].__eq__(word):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\ns1=[]\r\ns2=[]\r\nt1=[]\r\nfor i in s:\r\n s1.append(i)\r\nfor i in t:\r\n t1.append(i)\r\nfor i in range (len(s1)-1,-1,-1):\r\n s2.append(s1[i])\r\nif s2==t1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def rev(s):\n ans=\"\"\n for i in range(len(s)-1,-1,-1):\n ans+=s[i]\n return ans\ns1=input()\ns2=input()\nif(s2==rev(s1)):\n print(\"YES\")\nelse:\n print(\"NO\")", "word1 = input()\r\nword2 = input()\r\ndef function_com (word1 , word2) :\r\n for i in range (0 , len(word1)) :\r\n if word2[i] != word1[len(word1) - 1 - i] :\r\n print(\"NO\")\r\n return\r\n print(\"YES\")\r\n return\r\nif len(word2) != len(word1) :\r\n print(\"NO\")\r\nelse :\r\n function_com(word1 , word2)", "'''\r\nAmirhossein Alimirzaei\r\nTelegram : @HajLorenzo\r\nInstagram : amirhossein_alimirzaei\r\nUniversity of Bojnourd\r\n'''\r\n\r\nm=list(input())\r\nm.reverse()\r\ntmp=list()\r\nfor _ in range(len(m)):\r\n tmp.append(m[_])\r\nx=list(input())\r\nprint(\"YES\" if x==tmp else \"NO\")\r\n", "word = input()\r\ntrans = input()\r\nreal_trans_list = list()\r\n\r\nfor i in word:\r\n real_trans_list.insert(0, i)\r\n\r\nif trans == ''.join(real_trans_list):\r\n print('YES')\r\nelse:\r\n print('NO')", "str1 = input()\nstr2 = input()\nstr3 = str1[::-1]\nif(str2 == str3):\n print(\"YES\")\nelse:\n print(\"NO\")\n\t\t\t \t \t \t \t\t \t\t\t \t\t\t", "txt = input() [::-1]\r\nif txt==input():\r\n answer=\"YES\"\r\nelse:\r\n answer=\"NO\"\r\nprint(answer)", "s = input()\r\nt = input()\r\nx = len(s)\r\ny = len(t)\r\nseta = []\r\nsetb = []\r\nif x == y:\r\n for i in range(x):\r\n seta.append(s[i])\r\n setb.append(t[i])\r\n setb.reverse()\r\n if seta == setb:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")", "word1 = list(input().lower())\r\nword2 = input().lower()\r\nword1.reverse()\r\n\r\nif ''.join(word1) == word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\nt_reversed = ''.join(reversed(t))\r\n\r\nif t_reversed == s:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\na = ''\r\nfor i in range(len(s)):\r\n if s[i] == t[len(t) - 1 - i]:\r\n a = 'YES'\r\n else:\r\n a = 'NO'\r\n break\r\nprint(a)", "n=input()\r\nm=input()\r\nc=0\r\nfor i in range(len(n)):\r\n if (n[i]==m[(len(m)-1)-i]):\r\n c+=1\r\nif c==len(n) or c==len(m):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "before = list(input())\r\nafter = list(input())\r\ncorrect = list(reversed(before))\r\nif after == correct:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "s=list(input())\r\np = list(input())\r\np.reverse()\r\nif s==p:\r\n print('YES')\r\nelse :\r\n print('NO')", "a = input()\nb = input()\nlength = len(a) - 1\nreversed_a = \"\"\nwhile length >= 0:\n reversed_a += a[length]\n length -= 1\n\nif reversed_a == b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "S = input()\r\nt = input()\r\n\r\nr = S[::-1]\r\n\r\nif t == r:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\r\nt=input()\r\nif s==t[::-1]:\r\n print(\"YES\")\r\nelif s!=t[::-1]:\r\n print(\"NO\")\r\nelif s==t:\r\n print(\"No\")", "try:\r\n l1=input() \r\n l2=input() \r\n l3=l1[::-1] \r\n if l2==l3:\r\n print(\"YES\") \r\n else:\r\n print(\"NO\")\r\nexcept:\r\n pass", "word1=input()\r\nword2=input()\r\nword1=word1[::-1]\r\nif word1==word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n \r\n \r\n", "def translate(word,trans):\r\n translated_word = \"\"\r\n for char in word:\r\n translated_word = char + translated_word\r\n if trans == translated_word:\r\n return \"YES\"\r\n return \"NO\"\r\n\r\na = input()\r\nb = input()\r\nprint(translate(a,b))\r\n\r\n", "def reversed4(variable):\r\n res=''.join(reversed(variable))\r\n return res\r\n\r\ns = reversed4(input())\r\nd = input() \r\nif s == d:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\ns1=input()\r\nrev=s[::-1]\r\nif(s1==rev):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x = input()\r\no = input()\r\ny = list(x)\r\nz = list(x)\r\nn = 0\r\nwhile n < int(len(x) / 2):\r\n z[n] = y[-n - 1] \r\n z[-n-1] = y[n]\r\n n += 1\r\nl = ''.join([str(elem) for elem in z])\r\nif o == l:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\np=list(s)\r\nq=list(t)\r\ni=0\r\nr=list()\r\nj=len(t)\r\nwhile i<j:\r\n r.append(q[j-1-i])\r\n i+=1\r\n\r\nif r==p:\r\n print('YES')\r\nelse:\r\n print('NO')", "n=input()\r\nnlan=input()\r\ncount=0\r\nif len(n)==len(nlan):\r\n for i in range(0,len(n)):\r\n if n[i]==nlan[len(n)-1-i]:\r\n count+=1\r\n if count==len(n):\r\n print(\"YES\")\r\n else:print(\"NO\") \r\nelse:\r\n print(\"NO\")", "string1 = str(input())\r\nstring2 = str(input())\r\nif string1 == string2 and string2[::-1] != (string1) and string2 != string1[::-1]:\r\n print(\"NO\")\r\nelif string2[::-1] == (string1):\r\n print(\"YES\")\r\nelif string2 == string1[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n", "s=input()\r\nt=input()\r\nss=''.join(reversed(list(s)))\r\nif ss==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "# print('YES' if input()[: : -1] == input() else 'NO')\r\n\r\n# Way of C\r\ns = input()\r\nt = input()\r\n\r\nln = len(s)\r\nln_t = len(t)\r\n\r\noutput = 'YES'\r\n\r\nif ln == ln_t:\r\n for i in range(ln):\r\n if s[i] != t[ln -i -1]:\r\n output = 'NO'\r\n break\r\nelse:\r\n output = 'NO'\r\n\r\n\r\nprint(output)", "def inverse( s):\r\n n=len(s)\r\n inv=''\r\n for i in range(n):\r\n inv+=s[n-1-i]\r\n\r\n return inv\r\ns1=input();\r\ns2=input();\r\ninv=inverse(s1)\r\n\r\nif inv==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\ns1=input()\nif(s1==s[::-1]):\n print('YES')\nelse:\n print('NO')\n\t\t\t \t\t\t\t \t \t\t \t\t \t\t \t \t\t", "n=input()\r\nk=input()\r\nflag=0\r\nz=n[::-1]\r\nif z==k:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "word=input()\r\nreversedd=input()\r\nif word[::-1]==reversedd:\r\n print('YES')\r\nelse:\r\n print('NO')", "n1=list(input())\r\nn2=list(input())\r\nif n1==n2[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# https://codeforces.com/contest/41/problem/A\r\na = input()\r\nb = input()\r\n# if a == b[::-1]:\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\")\r\n\r\nl = len(a) - 1 \r\ni = 0\r\n\r\nif len(a) != len(b):\r\n print(\"NO\")\r\n\r\nelse:\r\n while i < len(a) and l > -1:\r\n if a[i] != b[l]:\r\n print(\"NO\")\r\n break\r\n l -= 1\r\n i += 1\r\n\r\n else:\r\n print(\"YES\")\r\n\r\n\r\n\r\n", "S = str(input())\r\nt = str(input())\r\nif len(S)>=1 and len(S)<=100 and len(t)>=1 and len(t)<=100:\r\n if S[::-1] == t:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "x1=input()\r\nx2=input()\r\na=x1[::-1]\r\nif x2==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s = input()\r\nt = input()\r\nrev = \"\"\r\n\r\nfor i in range(len(t) - 1, -1, -1):\r\n rev = rev + t[i]\r\n\r\n\r\nif s == rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\nsss = list()\r\n\r\nfor letter in s:\r\n sss.append(letter)\r\n\r\n\r\nsss.reverse()\r\n#print(sss)\r\n\r\nfinalstring = \"\".join(sss)\r\n\r\nif finalstring == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n", "word=input()\r\nreverse=word[::-1]\r\nans=input()\r\nif ans==reverse:\r\n print('YES')\r\nelse:\r\n print('NO')", "source = input()\nreverse = input()\nif source[::-1] == reverse:\n print('YES')\nelse:\n print('NO')", "s = input()\r\nt = input()\r\ns_list = []\r\nt_list = []\r\n\r\nfor i in range(len(s)):\r\n s_list.append(s[i])\r\nfor i in range(len(t)):\r\n t_list.append(t[i])\r\nt_list.reverse()\r\n\r\nx = 0\r\n\r\nif len(s_list) != len(t_list):\r\n print(\"NO\")\r\nelse:\r\n for k in range(len(t_list)):\r\n if t_list[k] == s_list[k]:\r\n x += 0\r\n else:\r\n x += 1\r\n if x == 0:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "#Boy or Girl\r\n'''name=input()\r\ncounter=0\r\nfor c in name:\r\n if name.count(c)==1:\r\n counter+=1\r\nprint(counter)\r\nif counter % 2==0:\r\n print(\"CHAT WITH HER!\")\r\nelse:\r\n print(\"IGNORE HIM!\")'''\r\n \r\n#word\r\n'''word=input()\r\nlowercase=0\r\nuppercase=0\r\nfor i in word:\r\n if(i.islower()):\r\n lowercase+=1\r\n elif(i.isupper()):\r\n uppercase+=1\r\nif lowercase>uppercase:\r\n print(lower(word))\r\nif lowercase<uppercase:\r\n print(word.capitalize())\r\nif lowercase==uppercase:\r\n print(lower(word))\r\n#Magic Numbers'''\r\n'''number=int(input())\r\nif true:\r\n for character in s:\r\n if character.isdigit(1,4)\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")'''\r\n#Translation\r\nword1=input()\r\nword1backwards=input()\r\nif word1backwards==word1[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\n\r\nl=s[::-1]\r\nif l==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\nk=input()\r\nres=n[ : : -1]\r\nif(res==k):\r\n print('YES')\r\nelse:\r\n print(\"NO\")", "s=input()\r\nss=input()\r\nc=-1\r\nfor i in s:\r\n if i==ss[c]:\r\n pass\r\n else:\r\n print(\"NO\")\r\n exit()\r\n c-=1\r\nprint(\"YES\")", "n=input()\r\na=input()\r\nt=n[::-1]\r\nif a==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = input()\r\nm = input()\r\n\r\nanswer = \"YES\"\r\n\r\nfor i in range(0, len(m)):\r\n if n[i] != m[len(m) - i - 1]:\r\n answer = \"NO\"\r\n break\r\n\r\nprint(answer)\r\n\r\n\r\n", "text=input()\r\ntext1=input()\r\ninverse=text[::-1]\r\n\r\nif text1==inverse:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\") ", "s=input()\r\nd=input()\r\na=s[::-1]\r\nif a==d:\r\n print('YES')\r\nelse:\r\n print('NO')", "result = \"\"\r\ns = input()\r\nt = input()\r\ncompare = \"\"\r\nfor x in range(len(s)):\r\n compare += s[(len(s)-1)-x]\r\nif compare == t:\r\n result = \"YES\"\r\nelse:\r\n result = \"NO\"\r\nprint(f\"{result}\")", "\"\"\"https://codeforces.com/problemset/problem/41/A\"\"\"\r\n\r\n\r\na = input()\r\nb = input()\r\nprint([\"NO\", \"YES\"][a == b[::-1]])", "a=input('')\r\nc=a[::-1]\r\nb=input('')\r\nif c ==b:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "q=input()\r\nw=input()\r\nif w==q[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nr = s[::-1]\r\nprint('YES') if t == r else print('NO')", "str=input()\nt=input()\nif(str==\"\".join(reversed(t))):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t \t\t\t \t \t\t\t\t\t\t \t \t\t \t", "def main():\n a_str = input()\n z_str = input()\n temp = ''\n for i in range(-1, -1*len(a_str)-1, -1):\n # print(i, a_str[i])\n temp += a_str[i]\n if temp == z_str:\n print('YES')\n else:\n print('NO')\nif __name__ == '__main__':\n main()\n", "\r\n# Online Python - IDE, Editor, Compiler, Interpreter\r\n\r\n\r\n\r\na = input()\r\nb = input()\r\nif(a[:]==b[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "inp1 = input()\r\ninp2 = input()\r\nif inp1 == inp2[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\nb=input()\nc=b[::-1]\n#for i in range(b):\nif c == a:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n \t \t\t \t\t\t\t \t \t\t\t\t\t\t \t \t\t", "l=input()\r\ns=input()\r\nk=s[::-1]\r\nif(l==k):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1=input()\r\nstr2=input()\r\nrev=str1[::-1]\r\nif rev==str2:print(\"YES\")\r\nelse:print(\"NO\")", "word = input()\r\nrword = input()\r\ntrue = 0\r\nfor i in range(len(word)):\r\n if word[i] != rword[-i-1]:\r\n break\r\n else:\r\n true+=1\r\n\r\nprint(\"YES\") if true == len(word) else print(\"NO\")\r\n", "a=input()\r\nb=input()\r\nn=len(a)\r\nx=0\r\nif len(a)!=len(b):\r\n print('NO')\r\nelse:\r\n for i in range(n):\r\n if a[i]==b[-i-1]:\r\n x+=1\r\n if x==n:\r\n print('YES')\r\n else:\r\n print('NO')\r\n", "s = input()\r\nt = input()\r\nn = len(s)\r\nr = True\r\nif len(s) == len(t):\r\n for i in range(n):\r\n if s[i] != t [n - 1 - i]:\r\n r = False\r\n break\r\nelse:\r\n r = False\r\n\r\nif r:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\nfor i in range(0, len(s)):\r\n if s[i] != t[-(i + 1)]:\r\n print(\"NO\")\r\n exit()\r\nprint(\"YES\")", "word = input()\r\ntranslated_word = input()\r\n\r\nword_len = len(word)\r\ntranslated_word_len = len(translated_word)\r\n\r\ntranslation_is_correct = True\r\n\r\nfor i in range(word_len):\r\n if word[i] != translated_word[translated_word_len - i - 1]:\r\n translation_is_correct = False\r\n\r\nif translation_is_correct:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a = input()\r\nb = input()\r\nprint(\"YNEOS\"[b != a[::-1]::2])", "mainStr = input()\r\ntranslatedStr = input()\r\nstr=\"\"\r\ni=len(translatedStr) - 1\r\nwhile(i >= 0):\r\n str += translatedStr[i]\r\n i -= 1\r\nif(str == mainStr) :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nx = s[::-1]\r\n\r\n\r\nif len(s) <= 100:\r\n if t == x:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nc = True\r\n\r\n\r\nfor i in range(min(len(s), len(t))):\r\n if s[i] != t[len(t)-1-i]:\r\n c= False\r\n break\r\n\r\nif c== True:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\np=\"\"\r\nfor i in range(len(t)-1,-1,-1):\r\n p+=t[i]\r\nif s==p:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def reverse(word):\r\n return word[::-1]\r\nword1 = input()\r\nword2 = input()\r\nif word1==reverse(word2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "# x2 = list(map(int, input(\"\").strip().split()))[:n]\r\n\r\n\r\ndef main():\r\n \"\"\"Main function\"\"\"\r\n s = input(\"\")\r\n t = input(\"\")\r\n new_string, length, integer = \"\", len(s), len(s)\r\n for i in range(length-1):\r\n integer -= 1\r\n new_string += s[integer]\r\n new_string += s[0]\r\n #print(new_string)\r\n if new_string == t:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n\r\n\r\nprint(main())\r\n", "# cook your dish here\r\ns=input()\r\np=input()\r\nr=s[::-1]\r\nif(r==p):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input().lower()\r\ny=input().lower()\r\n\r\nif x[slice(-1,-(len(x)+1),-1 )]==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nt2=t[::-1]\r\nif s==t2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t1=input()\r\nt2=input()\r\nt3=t1[::-1]\r\nif(t3==t2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\ns=a[-1:0:-1]+a[0]\r\nif(s==b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = input()\r\ns2 = input()\r\ncheck = True\r\nif len(s1) != len(s2):\r\n print('NO')\r\nelse:\r\n for i in range(0, len(s1)):\r\n if s1[i] != s2[len(s1) - 1 - i] :\r\n check = False\r\n break\r\n if check == True: \r\n print('YES')\r\n else: \r\n print('NO')", "x=(input())\r\ny=(input())\r\nk=\"\"\r\nfor i in x:\r\n k=i+k\r\nif k==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=str(input())\r\nl=str(input())\r\nr=n[::-1]\r\nif r==l:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\na = input()\r\nif(s[::-1]==a):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "def fun():\r\n inp = input()\r\n out = input()\r\n if(out[::-1] == inp):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n return\r\nfun()", "n = input()\r\nb = input()\r\nif n==b[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = input()\nrev = input()\nprint('YES' if rev == ''.join(list(reversed(word))) else 'NO')", "s = input()\r\nt = input()\r\n\r\nans = \"YES\"\r\nfor i in range(len(s)):\r\n if s[i] != t[len(t)-1-i]:\r\n ans = \"NO\"\r\n break\r\n\r\nprint(ans)", "import sys\na=input()\nb=input()\nc=list(a)\nd=list(b)\nd.reverse()\ni=0\nif len(c)!=len(d) :\n\tprint('NO')\nelse:\n\twhile i<len(a):\n\t\tif c[i]==d[i]:\n\t\t\ti+=1\n\t\t\tcontinue\n\t\telse:\n\t\t\tprint('NO')\n\t\t\tbreak\n\t\t\tsys.exit(0)\n\telse:\n\t\tprint('YES')\n", "x = input()\ny = input()\nfor i in range(len(x)):\n if x[i] == y[-(i+1)]:\n continue\n else:\n print(\"NO\")\n raise SystemExit(0)\nprint(\"YES\")", "\r\ndef check_correct_translation(s, t):\r\n\tif(len(s) != len(t)):\r\n\t\treturn False\r\n\r\n\tfor i in range(len(s)):\r\n\t\tif(s[i] != t[-(1+i)]):\r\n\t\t\treturn False\r\n\treturn True\r\n\r\n\r\ndef main():\r\n\ts = input()\r\n\tt = input()\r\n\r\n\r\n\tif(check_correct_translation(s, t)):\r\n\t\tprint('YES')\r\n\telse:\r\n\t\tprint('NO')\r\n\r\n\r\nif __name__ == '__main__':\r\n\tmain()", "s=input()\r\nrs=input()\r\nrsc=''\r\nfor i in range(1,len(s)+1):\r\n rsc=rsc+s[-i]\r\nif rs==rsc:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nw=\"\"\r\nsLen=len(s)\r\nfor x in range(sLen) :\r\n y=sLen-1-x\r\n w+=s[y]\r\nif w == t :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s1=input()\r\ns2=input()\r\na=s1[::-1]\r\nif s2==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1=input()\r\nstr2=input()\r\nx=len(str1)\r\nFlag=True\r\nif len(str1)==len(str2):\r\n for i in range(x):\r\n if str1[i]!=str2[x-i-1]:\r\n Flag=False\r\nelse:\r\n Flag=False\r\n\r\n\r\nif Flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input(\"\")\r\nt=input(\"\")\r\nk=t[::-1]\r\nif k==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "k = input()\r\nm = input()\r\nl = k[-1::-1]\r\nif (m == l):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def is_translation(s, t):\r\n return s[::-1] == t\r\n\r\ns = input().strip()\r\nt = input().strip()\r\nresult = \"YES\" if is_translation(s, t) else \"NO\"\r\nprint(result)\r\n", "a = input()\r\nb = input()\r\nc = \"\"\r\nfor i in a:\r\n c = i + c\r\nif b == c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a1=input()\r\na2=input()\r\nans=''\r\nfor i in a1:\r\n ans=i+ans\r\nif(ans==a2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=[x for x in input()]\r\nt=[x for x in input()]\r\nn=len(t)\r\nt=[t[x] for x in range(n-1,-1,-1)]\r\nif t==s:\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n\r\n", "##Перевод\r\ns=input().lower()\r\ns=list(' '.join(s).split())\r\nt=input().lower()\r\nt=list(' '.join(t).split())\r\nt.reverse()\r\nif t==s:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\nt=input()\np=t[::-1]\nif s==p:\n print(\"YES\")\nelse:\n print(\"NO\")", "import sys\r\n\r\ns = list(input())\r\nt = list(input())\r\nt.reverse()\r\n\r\nfor i in range(len(s)):\r\n if s[i] != t[i]:\r\n print('NO')\r\n sys.exit(0)\r\n\r\nprint('YES')\r\n\r\n\r\n", "S=str(input())\nt=str(input())\n\nls=len(S)\nlt=len(t)\ntemp=0\nif(ls!=lt):\n\ttemp=0\nelse:\n\tfor i in range(ls):\n\t\tif(S[i]==t[ls-1-i]):\n\t\t\ttemp+=1\t\nif(temp==ls):\n\tprint('YES')\nelse:\n\tprint('NO')\n\t", "a=str(input())\r\nx=str(input())\r\nb=a[::-1]\r\nif(b==x):\r\n print(\"YES\");\r\nelse:\r\n print(\"NO\");", "def Slova (slovo1):\r\n x = slovo1 [ : : -1]\r\n return x\r\nslovo2 = input()\r\nif Slova(input()) != slovo2:\r\n print (\"NO\")\r\nelse :\r\n print (\"YES\")", "c = input()\r\nw = input()\r\nif c[::-1] == w:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\nz=0\r\nfor i in range(len(a)):\r\n if a[i]==b[(len(b))-i-1]:\r\n z=0\r\n else:\r\n z=1\r\n break\r\nif z!=1:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n ", "s = input()\nk = input()\na = list(reversed(s))\nres = \"\"\nfor i in a:\n res += i\nif res == k:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a = input()\r\nb = input()\r\nc= b[::-1]\r\nla = len(a)\r\nlb = len(b)\r\nif (la>lb or la<lb):\r\n print(\"NO\")\r\nelse:\r\n if(a == c):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "a = input()\nb = input()\ncnt = 0\nc = len(b) - 1\n\nwhile c > -1:\n if len(a) == len(b):\n if a[cnt] == b[c]:\n c -= 1\n cnt += 1\n if c == -1:\n print(\"YES\")\n break\n else : \n print(\"NO\")\n break \n else :\n print(\"NO\")\n break", "a=input()\r\nb=input()\r\nl1=len(a)\r\nl2=len(b)\r\nn=0\r\nif l1==l2:\r\n for i in range(l1):\r\n if a[i]!=b[l1-1-i]:\r\n print('NO')\r\n n=1\r\n break\r\n if n==0:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \r\n", "b=input()\r\nif input() == b[::-1]:\tprint(\"YES\")\r\nelse:\tprint(\"NO\")", "txt = input()\nbirtxt = input()\ntxt1 = txt[::-1]\nif txt1 == birtxt:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri May 21 22:23:25 2021\r\n\r\n@author: TSSPDCL\r\n\"\"\"\r\n\r\nstr1=input()\r\nstr2=input()\r\nif str2[::]==str1[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word_s = input()\r\nword_t = input()\r\n\r\nif (word_s[::-1] == word_t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def translation(word, wordr):\r\n if word[::-1] != wordr:\r\n return 'NO'\r\n else:\r\n return 'YES'\r\n\r\n\r\nA = input()\r\nB = input()\r\nprint(translation(A, B))", "s=input()\r\ns1=input()\r\nprint(\"YES\" if s==s1[::-1] else \"NO\")", "N=input()\r\nX=input()\r\nif(N[::-1]==X):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def reverse(w1):\r\n w2=[]\r\n for i in range (len(w1)-1,-1,-1):\r\n w2.append(w1[i])\r\n return w2\r\n\r\na=input()\r\nb=input()\r\nc=list(a)\r\nd=list(b)\r\nif c!=reverse(d):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n \r\n", "# Write your code here\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split())))\r\ndef insr():\r\n s = input().strip()\r\n return(list(s[:len(s)]))\r\ndef invr():\r\n return(map(int,input().split()))\r\n\r\ns = insr()\r\nt = insr()\r\n\r\nif(s == t[::-1]):\r\n print('YES')\r\nelse:\r\n print('NO')", "string = input()\r\nnew_string = \"\"\r\nfor x in range(len(string) - 1, -1 , -1):new_string += string[x]\r\nprint(\"YES\" if new_string == input() else \"NO\")", "a,b = input(),input()\r\nprint(a == b[::-1] and 'YES' or True and 'NO')", "str1 = input()\r\nstr2 = input()\r\n\r\nstr1 = ''.join(reversed(str1))\r\n\r\nif str1 == str2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\ns1=input()\r\nr=s[::-1]\r\nif r==s1:\r\n print('YES')\r\nelse:\r\n print('NO')", "def check(a,b):\n a = list(a)\n a.reverse()\n a = ''.join(a)\n if a == b:\n print('YES')\n else:\n print('NO')\n \na = input()\nb = input()\ncheck(a,b)\n#huuhuhhhuhuhhuhu\n\t\t \t\t \t \t\t\t\t \t\t \t\t\t \t\t \t", "\r\nstr = input()\r\ns2 = input()\r\ns1 = \"\"\r\nfor i in range(len(str)-1, -1, -1):\r\n ch = str[i]\r\n s1 = s1 + ch\r\nif s1 == s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s1 = input()\ns2 = input()\nif s2[::-1]==s1:\n\tprint('YES')\nelse:\n\tprint('NO')\n", "def reverse(x):\r\n return x[::-1]\r\nans = reverse(input())\r\ncompare = input()\r\nif ans == compare:\r\n print(\"YES\")\r\nelse: print(\"NO\")", "def translation(w,w1):\r\n if (w[::-1]!= w1):\r\n return \"NO\"\r\n else:\r\n return \"YES\"\r\n\r\nx = input()\r\ny = input()\r\nprint(translation(x,y))", "berlandWord = input()\r\nbirlandWord = input()\r\n\r\nif birlandWord == \"\".join(reversed(list(berlandWord))):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def translator(s,t):\r\n for i in range(len(s)):\r\n if s[i] == t[-1-i]:\r\n continue\r\n else:\r\n return 'NO'\r\n break\r\n \r\n return 'YES'\r\n\r\nprint(translator(input(),input()))", "a = input()\nb = input()\nok = True\n\nif len(a) != len(b):\n ok = False\nelse:\n for i in range(len(a)):\n if a[i] != b[len(b) - i - 1]:\n ok = False\n break\n\nif ok:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \t\t\t\t \t \t \t\t \t\t \t \t \t \t\t\t", "s = input()\nt = input()\nslist = list(s)\ntlist = list(t)\nyes = True\nfor i in range(len(slist)):\n if (slist[i] != tlist[len(tlist) - 1 - i]):\n yes = False\nif (yes):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n\n\n\n\n\n\n", "s =input()\nr =input()\nif s == r[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "# import sys\r\n# sys.stdin = open('input.txt','r')\r\n# sys.stdout = open('output.txt','w')\r\n\r\n\r\na = input()\r\nb = input()\r\n\r\na = list(a)\r\nb = list(b)\r\nnew = []\r\nfor i in range(len(a)-1,-1,-1):\r\n\tnew.append(a[i])\r\n\r\nif b == new:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "str1=input()\r\nstr3=input()\r\nstr2=str1[::-1]\r\nif (str3==str2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s= list(input())\nt = input()\nprint(\"YES\" if t == \"\".join(list(reversed(s))) else \"NO\")", "k=input()\r\ndk=input()\r\nrk=k[::-1]\r\nif rk==dk:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "w1 =input()\r\nw2 =input()\r\nw=\"\"\r\nfor i in w2:\r\n w=i+w\r\nif w1==w:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nn=len(s)\r\nm=len(t)\r\nif m!=n:\r\n print('NO')\r\nelse: \r\n ans='YES'\r\n for i in range(n):\r\n if s[i]!=t[n-1-i]:\r\n ans='NO'\r\n print(ans)", "a=input()\r\nv=input()\r\nif a==v[::-1]:print('YES')\r\nelse:print('NO')", "word = list(input().lower())\r\nword2 = list(input().lower())\r\nword.reverse()\r\nif word2 == word:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import re\r\ns = input()\r\nt = re.findall(\"\\w\",input())\r\ntt = \"\".join([t[len(t)-1-i] for i in range(0,len(t))])\r\nif tt == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "c = str(input())\r\nd = str(input())\r\nreverse = c[::-1]\r\nif(d==reverse):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t=input()\r\ns=input()\r\np=t[::-1]\r\nif s==p:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')\r\n", "def is_correct_Birlandish(word,reverse):\r\n if word[::-1] == reverse: print (\"YES\")\r\n else: print (\"NO\")\r\n\r\nif __name__ == \"__main__\":\r\n berlandish = input()\r\n birlandish = input()\r\n is_correct_Birlandish(berlandish,birlandish)\r\n", "A=input()\r\nB=input()\r\nB=B[::-1]\r\nif A==B:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt =input()\r\n\r\nfor i in range(1,len(s)+1):\r\n\tif t[-i] != s[i-1]:\r\n\t\tprint('NO')\r\n\t\tbreak\r\nelse:\r\n\tprint('YES')", "text=input()\r\ntext2=input()\r\nlist=[]\r\nl=''\r\nfor i in text:\r\n list.insert(0,i)\r\nfor i in list:\r\n l+=i\r\nif(l==text2):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \r\n", "s=input()\r\nr=input()\r\nrev=s[::-1]\r\nif rev==r:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\nfor i in range(len(a)):\r\n if a[i] != b[-i-1]:\r\n print(\"NO\")\r\n exit()\r\nprint(\"YES\")", "s = input()\r\nt = input()\r\nprint((\"NYOE S\")[s[::-1] == t::2])\r\n", "s = input()\r\nt = input()\r\nprint('YES' if t == s[::-1] else 'NO')", "a = input()\r\nb = input()[::-1]\r\nprint('YES') if a == b else print('NO')", "t = input()\ns=input()\n\nif t[::-1] == s:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "s = input()\r\nt = input()\r\n\r\nt_is_s = True\r\n\r\nif len(s) == len(t):\r\n head = 0\r\n tail = len(t)\r\n while(head < len(s)):\r\n if s[head] != t[tail-1]:\r\n t_is_s = False\r\n break\r\n else:\r\n head += 1\r\n tail -= 1\r\nelse:\r\n t_is_s = False\r\n\r\n\r\nif t_is_s:\r\n print('YES')\r\nelse:\r\n print('NO')", "myStr1=input()\r\nmyStr2= input()\r\nb= list(myStr1)\r\nb.reverse()\r\nc= \"\".join(map(str, b))\r\nif c==myStr2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word = input('')\nreverse = input('')\nif reverse == word[::-1]:\n print('YES')\nelse:\n print('NO')\n\t \t \t\t\t\t\t\t\t \t\t\t \t\t\t \t\t \t\t\t\t", "s=input()\r\nk=input()\r\nprint(\"YES\" if k==s[::-1] else \"NO\")", "s = input()\r\nt = input()\r\nflag = 0\r\nfor i in range(len(s)):\r\n if s[i] != t[-(i+1)]:\r\n flag = 1\r\n break\r\nprint(\"YES\" if flag==0 else \"NO\")", "s=str(input())\r\nt=str(input())\r\nn1=s[::-1]\r\nif(t==n1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "Trans_1 = input()\nTrans_2 = input()\nprint( \"YES\" if Trans_2 == Trans_1 [::-1] else \"NO\")\n \t \t \t \t\t\t \t \t\t\t \t \t \t\t \t", "# Translation\r\n# by hoanghust\r\n\r\ns = input()\r\nt = input()\r\nt_reverse = \"\"\r\n\r\nfor i in range(len(t)):\r\n\t\tt_reverse += t[-1-i]\r\n\r\nif s == t_reverse:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "def is_translation(a, b):\r\n return a == b[::-1]\r\n \r\n \r\nif __name__ == '__main__':\r\n a = input().strip()\r\n b = input().strip()\r\n if is_translation(a, b):\r\n print(\"YES\") \r\n else:\r\n print(\"NO\")", "n=input()\r\na= input()\r\n\r\nif(a[::-1]==n):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = \"\"\r\nfor i in range(2):\r\n s += input()\r\ns = list(s)\r\nt = s.copy()\r\nt.reverse()\r\nif s == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nwhile not ((1 <= len(s) <= 100) and (s.islower()) and (not ' ' in s)):\r\n s = input()\r\n\r\nt = input()\r\nwhile not ((1 <= len(t) <= 100) and (t.islower()) and (not ' ' in t)):\r\n t = input()\r\n\r\ntmp = 0\r\n\r\nif not len(s) == len(t):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(s)):\r\n if s[i] == t[len(s)-i-1]:\r\n tmp += 1\r\n \r\n if tmp == len(s):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Thu Nov 1 21:40:11 2018\r\n\r\n@author: Acer\r\n\"\"\"\r\n\r\nword1 = input()\r\nword2 = input()\r\nn = len(word1)\r\nk = len(word2)\r\nif n == k:\r\n i = sum(word1[j] == word2[n - 1 - j] for j in range(n))\r\n if i == n:\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')\r\n ", "word_in_Berlandish=input()\r\nword_in_Birlandish=input()\r\nif 0<len(word_in_Berlandish)<=100 and 0<len(word_in_Birlandish)<=100:\r\n if word_in_Berlandish==word_in_Birlandish[::-1]:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "print('YNEOS'[(list(reversed(input()))!=list(input()))::2])\r\n\r\n", "s = input()\r\nt = input()\r\n[print(f\"YES\") if s==t[::-1] else print(f\"NO\")]", "word1 = input()\nword2 = input()\nif len(word1) != len(word2):\n print(\"NO\")\n exit(0)\nsize = len(word1)\ni = 0\nj = size - 1\nflag = True\nfor _ in range(size):\n if word1[i] != word2[j]:\n flag = False\n break\n i += 1\n j -= 1\n\nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")", "s=input()\r\nt=input()\r\nt1=\"\".join(reversed(s))\r\nif t==t1:\r\n \r\n print('YES')\r\nelse:\r\n print('NO') ", "s = input()\r\nt = input()\r\nn = \"\"\r\ni = len(s) - 1\r\nwhile i >= 0:\r\n n += s[i]\r\n i-=1\r\nif n == t:print(\"YES\")\r\nelse:print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Sep 21 14:46:24 2021\r\n\r\n@author: wlt52\r\n\"\"\"\r\n\r\na = input()\r\nb = input()\r\n\r\nimport sys\r\n\r\nif len(a) != len(b):\r\n print('NO')\r\n sys.exit()\r\n\r\nfor i in range(len(a)):\r\n if a[i] != b[-i-1]:\r\n print('NO')\r\n sys.exit()\r\n \r\nprint('YES')", "s1 = input()\ns2 = input()\nif s2 == s1[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s=str(input())\r\nk=str(input())\r\nif(s==k[::-1]):print(\"YES\")\r\nelse:print(\"NO\")", "if input()==input()[::-1]:\r\n print('YES')\r\nelse:print('NO')", "m=input()\r\nn=input()\r\np=m[len(n)::-1]\r\nif(n==p):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Jul 24 10:05:29 2023\r\n\r\n@author: lakne\r\n\"\"\"\r\n\r\ns = input()\r\nt = input()\r\n\r\ns_translated = s[::-1]\r\n\r\nif s_translated == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n1 = input()\nn2 = input()\nif n1 == n2[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "original = input()\ntranslation = input()\n\nflag = 1\nj = int(len(translation)) - 1\nfor i in range(0, len(original)):\n if original[i] != translation[j]:\n flag=0\n break\n j-=1\n\nif flag ==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n'''\ncode\nedoc\n\nYES\n\nabb\naba\n\nNO\n\ncode\ncode\n\nNO\n'''", "from heapq import *\r\n\r\ndef int_raw():\r\n return int(input())\r\n\r\ndef ss_raw():\r\n return input().split()\r\n\r\ndef ints_raw():\r\n return list(map(int, input().split()))\r\n\r\nS =input()\r\nT=input()\r\ndef main():\r\n if list(reversed(S))==list(T):\r\n return \"YES\"\r\n else:\r\n return \"NO\" \r\nprint(main())\r\n", "n=input\r\nprint(\"YNEOS\"[n()!=n()[::-1]::2])", "def translation(s,t):\n n = \"\"\n for i in range(len(s)-1,-1,-1):\n n+=s[i]\n if n == t:\n print(\"YES\")\n else:\n print(\"NO\")\ndef main():\n translation(input(\"\"),input(\"\"))\nmain()\n", "fStr = str(input())\r\nsStr = str(input())\r\n\r\nif fStr[::-1] == sStr:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nflag=1\r\nfor i in range(len(s)):\r\n if s[i]!=t[len(t)-i-1]:\r\n print(\"NO\")\r\n flag=0\r\n break\r\nif flag==1:\r\n print(\"YES\")", "x = input()\r\ny = input()\r\ncx=0\r\ncy=len(y)-1\r\nif len(x)>len(y):\r\n print (\"NO\")\r\nelif len(y)>len(x):\r\n print(\"NO\")\r\nelif len(x)==len(y):\r\n k=0\r\n u=len(y)\r\n while(cx < u):\r\n if x[cy]==y[cx]:\r\n k+=1\r\n cy-=1\r\n cx+=1\r\n else:\r\n cy-=1\r\n cx+=1\r\n if k==len(x):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\nq=a[::-1]\r\ne=b[::-1]\r\nif q==b or e==a:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=input()\r\nb=input()\r\nout=''\r\nfor i in range(-1,-len(a)-1,-1):\r\n\tout+=a[i]\r\nif out==b:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "s=input()\ns1=input()\ns2=s[::-1]\n\nif s1==s2:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "#!/usr/bin/python3\r\n\"\"\"\r\nAfnan\r\n27/04/2022\r\ntranslation 800\r\n\"\"\"\r\n\r\nfrom unittest import TestCase\r\nfrom typing import NamedTuple\r\n\r\n\r\nclass Args(NamedTuple):\r\n \"\"\" input arguments \"\"\"\r\n\r\n line1: str\r\n line2: str\r\n\r\n\r\ndef get_args():\r\n \"\"\" get input arguments \"\"\"\r\n\r\n line1 = input()\r\n line2 = input()\r\n\r\n return Args(line1, line2)\r\n\r\n\r\nclass Test(TestCase):\r\n \"\"\" test cases \"\"\"\r\n\r\n def testanswer(self):\r\n \"\"\" test answers \"\"\"\r\n\r\n self.assertEqual(answer(\"abc\", \"cba\"), \"YES\")\r\n\r\n\r\ndef answer(line1, line2):\r\n \"\"\" 2 strings, reverse equal to each other \"\"\"\r\n\r\n return \"YES\" if line1[::-1] == line2 else \"NO\"\r\n\r\n\r\ndef main():\r\n \"\"\" do stuff \"\"\"\r\n\r\n args = get_args()\r\n print(answer(args.line1, args.line2))\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n", "source = input()\r\ntranslation = input()\r\nif source[::-1] == translation:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "g = list(input())\r\nm = input()\r\nv = list(reversed(g))\r\ns=\"\"\r\nfor i in v:\r\n s+=i\r\nif s==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\nl=list(a)\r\nl.reverse()\r\ns=\"\"\r\nfor i in range(len(a)):\r\n s+=l[i]\r\nif(s==b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=input()\r\ns2=input()\r\nw=''.join(reversed(s1))\r\nif(s2==w):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word1=input().lower()\nword2=input().lower()\ntemp=word1[len(word1):0:-1]\ntemp=temp+word1[0]\nif temp==word2:\n print(\"YES\")\nelse:\n print(\"NO\")", "y=input()\r\nx=input()\r\nx1=x[::-1]\r\nif y==x1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\nss=input()\nprint(('NO','YES')[ss==s[::-1]])\n \t\t\t\t \t \t\t \t \t\t \t \t\t\t", "n=input()\r\nt=input()\r\ndata1=n[::-1]\r\nif t==data1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = input()\r\ns2 = input()\r\nif s2 == s1[:][::-1] :\r\n answer ='YES'\r\nelse :\r\n answer ='NO'\r\nprint(answer)", "s=input()\r\nt=input()\r\nv=\"YES\"\r\nif len(s)!=len(t):\r\n v=\"NO\"\r\nelse:\r\n n=len(s)\r\n for i in range(n):\r\n if s[i]!=t[(n-1)-i]:\r\n v=\"NO\"\r\n break\r\nprint(v)\r\n \r\n", "word = input()\r\nreversed = input()\r\nwordarray = []\r\nreversedarray= []\r\nfor i in range(len(word)):\r\n wordarray.append(word[i])\r\nfor j in range(len(reversed)):\r\n reversedarray.append(reversed[j])\r\nreversedarray.reverse()\r\nif wordarray == reversedarray :\r\n print(\"YES\") \r\nelse:\r\n print(\"NO\")\r\n", "# coding=utf-8\na=input()\r\nb=input()\r\ns=0\r\nif len(a)!=len(b):\r\n print('NO')\r\nelse:\r\n for i in range(len(a)):\r\n if a[i]==b[len(a)-1-i]:\r\n s+=1\r\n if s==len(a):\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\n\n \t \t \t\t \t\t\t \t \t \t \t\t\t\t", "user_input = input(\" \")\r\nda = input(\" \")\r\n\r\nif da == user_input[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "ans1 = str(input())\r\nans2 = str(input())\r\n\r\nif ans1[::-1] == ans2:\r\n print('YES')\r\nelse:\r\n print('NO')", "x = input()\r\nx = ''.join(reversed(x))\r\ny = input()\r\nif x == y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input())\r\nt = str(input())\r\nif t == s[::-1]:print(\"YES\")\r\nelse:print(\"NO\")", "a,b = input(),input()\r\n\r\nif a == b[::-1]:print(\"YES\")\r\nelse:print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nrev1=s[::-1]\r\nif t==rev1:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nz=s[::-1]\r\nif (z==t):\r\n print('YES')\r\nelse:\r\n print('NO')", "def solve(word, reverse):\r\n if len(word) != len(reverse):\r\n return \"NO\"\r\n n = len(word)\r\n for i in range(n):\r\n if word[i] != reverse[n - i - 1]:\r\n return \"NO\"\r\n return \"YES\"\r\n\r\ndef main():\r\n word = input().strip()\r\n reverse = input().strip()\r\n print(solve(word, reverse))\r\n\r\nif __name__ == \"__main__\":\r\n main()", "t=input()\r\ns=input()\r\nm=s[::-1] \r\nif t==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word1 = input()\r\nword2 = input()\r\n\r\nword1reverse = \"\"\r\n\r\ni = len(word1) - 1\r\n\r\nwhile i >= 0:\r\n word1reverse += word1[i]\r\n i -= 1\r\n\r\nif word1reverse == word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "disco=list(input())\r\nnightlife=list(input())\r\nnightlife.reverse()\r\nif disco==nightlife:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "#Gustavo De Los Ríos Alatorre\n#Problema C. Translation\n#En este problema en particular se usó una aproximación que intenta imitar el sorting.\n#Sin embargo en este caso no se busca un ordenamiento de menor a mayor, sino que únicamente\n#Se quiere reorganizar el 1er string introducido(a) para que este aparezca en reversa y sea comparado con\n# con el segundo string(b).\n#para esto se utiliza un método de slice que inicia al final del string y va hacia atrás.\n#Haciendo así que el texto introducido aparezca en reversa. \n\na = input() #String1\nb = input() #String2\n\ndef revA(a,b):\n result = \"\" #String donde guardo el resultado\n revA = a [::-1] #slice en reversa. \n if revA == b: #Confirmación de que el segundo string sea igual al inverso.\n result = \"YES\"\n elif revA != b: #Respuesta en caso de que sea distinto. \n result = \"NO\"\n return result #regresa el resultado. \n\nprint(revA(a,b)) #Llámamos la función e imprimimos. \n \t\t \t\t \t \t \t\t \t \t\t\t \t\t\t \t", "str=input()\r\nrev=input()\r\nrev_str=str[::-1]\r\nif(rev==rev_str):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n", "a=input()\r\nb=list(input())\r\nb.reverse()\r\nb1=''.join(b)\r\nif a==b1:print('YES')\r\nelse:print('NO')", "a, b = input(), input()\nif a == ''.join(reversed(b)):\n print('YES')\nelse:\n print('NO')", "s = input()\r\nt = input()\r\nl1 = len(s)\r\nl2 = len(t)\r\nisSame = True\r\nif l1 == l2:\r\n for i in range(0,l1):\r\n if s[i] != t[l1-i-1]:\r\n isSame = False\r\nelse:\r\n isSame = False\r\nif isSame == True:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\n\r\n\r\ndef birlandish(str1, str2):\r\n return \"YES\" if str1 == str2[::-1] else \"NO\"\r\n\r\nprint(birlandish(s, t))\r\n", "j = list(map(str,input()))\r\nk = list(map(str,input()))\r\nk.reverse()\r\nif(j==k):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\nif s == \"\".join(list(reversed(t))):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s1 = input()\r\ns2 = input()\r\n\r\nl = []\r\nfor i in range(len(s2)):\r\n l.append(s2[i])\r\nrev = ''\r\nfor i in range(len(l)):\r\n rev += l[-1]\r\n k = l.pop(-1)\r\n\r\nif s1 == rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "n=input()\r\nn1=input()\r\nd=n[::-1]\r\nif d==n1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "in1 = input()\r\nin2 = input()\r\nstring = \"\"\r\n\r\nfor x in range (1, len(in1) + 1):\r\n string += in1[-x]\r\n\r\nif string == in2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input();s=input();print(['NO','YES'][s==a[::-1]])", "Ber = input()\r\nBer = [str(x) for x in Ber]\r\nBer.reverse()\r\nBir = ''.join(Ber)\r\nTrans = input()\r\nif Bir == Trans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = input()\r\nc = input()\r\nnn = n[::-1]\r\n\r\nif(nn==c):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\nss = []\r\nfor i in reversed(range(len(b))):\r\n ss.append(b[i])\r\nif \"\".join(ss) == a:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nrs=s[::-1]\r\nif rs==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "if __name__ == '__main__':\r\n str1 = input()\r\n str2 = input()\r\n\r\n if(str2 == str1[::-1]):\r\n print('YES')\r\n else:\r\n print('NO')", "s = input()\r\nt = input()\r\nout = \"\"\r\n\r\nif (len(s) < 1) or (len(s) > 100):\r\n print(\"Error_1\")\r\n\r\nif (len(t) < 1) or (len(t) > 100):\r\n print(\"Error_2\")\r\n\r\nfor loop_cntr in range (len(s)-1,-1,-1):\r\n out += s.__getitem__(loop_cntr)\r\n\r\nif t == out:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "s1=input()\r\ns2=input()\r\nlength=len(s1)\r\nflag=1\r\nif len(s1)==len(s2):\r\n for i in range(0,length):\r\n if s1[i]!=s2[length-1-i]:\r\n flag=0\r\n break\r\nelse:\r\n flag=0\r\nif flag:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\nb=input()\nt=s[::-1]\nif b==t:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n \t\t\t \t\t \t \t \t\t\t \t\t\t\t \t \t\t \t", "def is_reversed(s, t):\n return s == t[::-1]\n\n# Example usage:\ns = input().strip()\nt = input().strip()\n\nif is_reversed(s, t):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \t\t\t\t\t \t\t\t \t \t\t \t\t \t \t\t", "a=input()\r\nb=input()\r\na=list(a)\r\na.reverse()\r\na=\"\".join(a)\r\nif a==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "count=0\r\nm=str(input())\r\nn=str(input())\r\nif len(m)==len(n):\r\n for i in range(len(m)):\r\n if m[i]==n[len(m)-i-1]:\r\n count=count+1\r\n \r\n else:\r\n break\r\n \r\n if count==len(m):\r\n print('YES')\r\n else:\r\n print(\"NO\")\r\n\r\nelse:\r\n print(\"NO\")\r\n\r\n ", "i = input() ; j =input() ; print(\"YES\" if i[::-1]==j else \"NO\")", "s=input().lower()\r\nt=input().lower()\r\nif t==s[::-1]:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "try:\r\n s=input()\r\n t=input()\r\n s=list(s)\r\n s.reverse()\r\n s=''.join(s)\r\n\r\n if s==t:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nexcept expression as identifier:\r\n pass", "import sys\r\ninput = sys.stdin.readline\r\n\r\ns = input()[:-1]\r\nt = input()[:-1]\r\nn = len(s)\r\nflag = True if n == len(t) else False\r\nfor i in range(n):\r\n if not flag:\r\n break\r\n if s[i] != t[n-1-i]:\r\n flag = False\r\n\r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "flag = 0\ns = str(input())\nt = str(input())\nif len(s) != len(t) :\n print (\"NO\")\nelse :\n length = len(s)\n for i in range(0,length,1) :\n if s[i] != t[length-i-1] :\n flag = 1\n break\n if flag == 0 :\n print (\"YES\")\n else :\n print (\"NO\")\n\t \t\t\t \t \t\t \t\t \t\t\t \t\t \t", "lang1=input()\r\nlang2=input()\r\ndef reverse(st):\r\n i=0\r\n j=len(st)-1\r\n st=list(st)\r\n while(i<j):\r\n st[i],st[j]=st[j],st[i]\r\n i+=1\r\n j-=1\r\n return ''.join(x for x in st)\r\n\r\nif(str(lang1)==str(reverse(lang2))):\r\n print('YES')\r\nelse:\r\n print('NO')", "i=input()\r\nj=input()\r\n\r\nk=i[::-1]\r\nif k==j :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "z=list(map(str,input()))\r\nz.reverse()\r\n#print('z=',z)\r\nc=list(map(str,input())) \r\n#print('c=',c)\r\nif z==c:\r\n print('YES')\r\nelse:\r\n print('NO') \r\n", "import sys\n\ndef main():\n first_word = sys.stdin.readline().strip()\n snd_word = sys.stdin.readline().strip()\n for (c1, c2) in zip(first_word, snd_word[::-1]):\n if c1 != c2: \n return \"NO\"\n return \"YES\"\n\nprint(main())\n", "s = input()\r\nz = input()\r\nprint(\"YES\" if s == z[::-1] else \"NO\")", "import sys\ninput = sys.stdin.readline\n\ndef insr():\n s = input()\n return(list(s[:len(s) - 1]))\n\na = insr()\nb = insr()\n\ndef translate():\n res = True\n if len(a) != len(b):\n res = False\n return res\n for x in range(len(a)):\n if a[x] != b[len(a) - 1 - x]:\n res = False\n break\n return res\n\nres = translate()\nprint(\"NO\" if res == False else \"YES\")\n", "s=input()\r\nt=input()\r\ne=s[::-1]\r\nif(t==e):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "berlandish = input()[::-1]\r\nbirlandish = input()\r\nif berlandish == birlandish:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\ns = list(s)\r\ns.reverse()\r\nss = \"\".join(s)\r\nprint(\"YES\") if ss == t else print(\"NO\")", "data=input()\ndata2=input()\nif data==data2[::-1]:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "s=input()\nt=input()\nn1=len(s)\nn2=len(t)\nif (n1!=n2):\n print(\"NO\")\nelse:\n flag=0\n for i in range(n1):\n if (s[i]!=t[n1-i-1]):\n print(\"NO\")\n flag=1\n break\n if flag==0:\n print(\"YES\")\n\n\n\n\t \t \t \t\t \t \t\t \t \t\t \t\t", "word=input()\r\nword1=input()\r\nreversed_word=''\r\nfor i in reversed(word):\r\n reversed_word+=i\r\nif reversed_word==word1:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nreverse=''\r\nfor i in s:\r\n\treverse=i+reverse\r\nif len(s)!=len(t):\r\n\tprint('NO')\r\nelif reverse==t:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "'''\r\n\r\nThe translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if he translated the word correctly.\r\n\r\nInput\r\nThe first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.\r\n\r\nOutput\r\nIf the word t is a word s, written reversely, print YES, otherwise print NO.\r\n\r\n'''\r\n\r\n\r\nword_s = input(\"\").lower().strip()\r\nword_t = input(\"\").lower().strip()\r\n\r\nif word_t == word_s[::-1]:\r\n\tprint(\"YES\")\r\nelif word_t != word_s[::-1]:\r\n\tprint(\"NO\")", "norm = input()\r\nreverse = input()\r\nif reverse[::-1] == norm:\r\n print(\"YES\")\r\nelse:\r\n print('NO')", "n = input()\r\ntest = input()\r\nr=n[len(n)::-1]\r\nif r == test: print(\"YES\") \r\nelse: 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 \r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n\r\n \r\n \r\n\r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n\r\n \r\n", "a = input()\r\nb = input()\r\nif len(a) != len(b):\r\n print('NO')\r\nelse:\r\n index = 0\r\n while index < len(a) and a[index] == b[len(a)-index-1]:\r\n index += 1\r\n if index != len(a):\r\n print('NO')\r\n else:\r\n print('YES')", "text_one = input()\r\ntext_two = input()\r\nif len(text_one) != len(text_two):\r\n\tprint('NO')\r\nelse:\r\n\tfor i in range(len(text_one)):\r\n\t\tif text_one[i] != text_two[-(i+1)]:\r\n\t\t\tprint('NO')\r\n\t\t\tbreak\r\n\telse:\r\n\t\tprint('YES')", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Nov 26 20:56:39 2019\r\n\r\n@author: Zheng Jiajia\r\n\"\"\"\r\nword=list(input())\r\ntrans=str(input())\r\nright=word[::-1]\r\ncheck=''.join(right)\r\n\r\nif trans==check:\r\n print('YES')\r\nelse:\r\n print('NO')", "n=input()\r\nb=input()\r\nif n[::-1]==b[0:]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def translate(s1, s2):\r\n if s1 == s2[::-1]:\r\n return \"YES\"\r\n return \"NO\"\r\n\r\ns1 = input()\r\ns2 = input()\r\nprint(translate(s1, s2))", "i1=input()\r\ni2=input()\r\nprint(\"YES\") if(i1==i2[::-1]) else print(\"NO\")\r\n", "a = input()\r\nb = input()\r\nif b == a[::-1]: print('YES')\r\nelse: print('NO')", "n = list(input())\r\nk = input()\r\nr = list(reversed(n))\r\nresult=\"\"\r\nfor i in r:\r\n result+=i\r\nif result==k:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "def reverse(s, t):\r\n\tn = len(s)\r\n\tm = len(t)\r\n\tif n != m:\r\n\t\treturn False\r\n\tfor i in range(n):\r\n\t\tif s[i] != t[n-i-1]:\r\n\t\t\treturn False\r\n\treturn True\r\n\r\ns = input()\r\nt = input()\r\n\r\nif reverse(s, t):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "a = input()\r\nb = input()\r\nif list(reversed(a)) == list(b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\np=s[-1::-1]\r\nif(t==p):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1=input()\r\nstr2=input()\r\nrev=str1[::-1]\r\nif(str2==rev):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s = input()\r\nr = input()\r\nif s[::-1] == r:\r\n print(\"YES\")\r\nelse:print(\"NO\")\r\n", "x=input()\r\nprint(\"YES\" if input() == x[::-1] else \"NO\") ", "def solve(s,c):\r\n t = s[::-1]\r\n if t == c:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n return t\r\ninp1 = input()\r\ninp2 = input()\r\nprint(solve(inp1,inp2))", "s = str(input())\r\nstr = str(input())\r\nelement = list(s)\r\nlst = list(str)\r\nt = []\r\nfor i in element[::-1]:\r\n t.append(i)\r\nif lst == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def translate():\r\n n1 = input()\r\n n2 = input()\r\n if n1[::-1] == n2:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n \r\nprint(translate())", "s=input()\r\nn=input()\r\nc=list(s)\r\nc.reverse()\r\nS=''.join(c)\r\nif S==n:\r\n print('YES')\r\nelse:\r\n print('NO') ", "s = input()\r\nt=input()\r\nl=[]\r\nfor i in range(len(s)-1, -1,-1):\r\n l.append(s[i])\r\na = \"\"\r\nfor i in l:\r\n a=a+i\r\nif t==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\ns_rev = ''.join(reversed(s))\r\nt = input()\r\nif t == s_rev:\r\n print('YES')\r\nelse:\r\n print('NO')", "t = str(input())\nl = str(input())\n\nBerland = []\nBirland = []\n\nfor y in t:\n Berland.append(y)\n \nfor x in l[::-1]:\n Birland.append(x)\n \nif Berland == Birland:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n\n\n\n\n", "s = input()\nt = input()\n\nres = \"YES\" if t == s[::-1] else \"NO\"\nprint(res)\n", "s = input()\r\nt = input()\r\na = list ()\r\n\r\ns= \"\".join( reversed( s) )\r\n\r\nif ( s == t) :\r\n print (\"YES\")\r\nelse :\r\n print (\"NO\")", "word=input()\r\nreverse=input()\r\nword_reverse=''\r\na=list(reverse)\r\na.reverse()\r\n\r\nfor item in a:\r\n\tword_reverse=word_reverse+item\r\n\t\r\n\r\nif word_reverse==word:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')\r\n", "a = str(input())\r\nb = str(input())\r\nprint(\"YES\" if a == b[::-1] else \"NO\")", "word1=input()\r\nword2=input()\r\nprint('YES'if word1[::-1]==word2 else \"NO\")", "#41A\r\ns = input()\r\nt = input()\r\n\r\nk=''\r\nfor i in range(len(s)-1,-1,-1):\r\n k = k + s[i]\r\nif(t==k):\r\n print('YES')\r\nelse:\r\n print('NO')", "string1=input()\r\nstring2=input()\r\nreverse=string1[::-1]\r\nif(string2==reverse):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s = input()\r\nt = input()\r\ncounter = 0\r\nif len(s) == len(t):\r\n for i in range (len(s)):\r\n if s[i] == t[-i - 1]:\r\n counter += 1\r\n if counter == len(s):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\nelse:\r\n print(\"NO\")\r\n", "s= list(input().strip())\r\nt= list(input().strip())\r\n\r\ni = len(s) // 2\r\n\r\nfor a in range(i):\r\n s[a], s[len(s)-1-a] = s[len(s)-1-a], s[a]\r\nif s == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\nsame = True\r\n\r\nif len(s) != len(t):\r\n same = False\r\nelse:\r\n for i in range (0, len(s)):\r\n if s[i] != t[len(s) - i - 1]:\r\n same = False\r\n break\r\n\r\nif same:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Jun 27 15:48:15 2023\n\n@author: yesenia\n\"\"\"\n\na = input()\nb = input()\n\nif a == b[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "str1=input()\r\nstr2=input()\r\nx=str2[::-1]\r\nif(x==str1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "p=input()\r\nq=input()\r\nr=p[::-1]\r\nif r==q:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s1=input()\r\ns2=input()\r\na=len(s1)\r\nb=len(s2)\r\nif(a==b):\r\n k=0\r\n i=0\r\n j=-1\r\n while(a>0):\r\n if(s1[i]!=s2[j]):\r\n k=1\r\n break\r\n i+=1\r\n j-=1\r\n a-=1\r\n if(k==1):\r\n print('NO')\r\n else:\r\n print('YES')\r\nelse:\r\n print('NO')", "word=input()\r\nrevword=input()\r\ninre=word[::-1]\r\nif revword==inre:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=input()\r\ns2=input()\r\nrev=s1[::-1]\r\nif rev==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\ns1=''\r\ni=len(s)-1\r\nwhile (i>-1):\r\n s1+=s[i]\r\n i-=1\r\nif (s1==t):\r\n print('YES')\r\nelse:\r\n print('NO')", "a, b = input(), input()\n\nprint('YES') if a == b[::-1] else print('NO')\n", "s = input()\r\nt = input()\r\n\r\nreversedT =\"\"\r\n\r\nfor i in t[::-1]:\r\n reversedT += i\r\n\r\nif s == reversedT:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nres=s[::-1]\r\nif res==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\ndef checkReverse(s,t):\r\n if t == s[::-1]:\r\n return 'YES'\r\n else:\r\n return 'NO'\r\nprint(checkReverse(s,t))", "\"\"\"\n\"\"\"\n\n\nclass Translation:\n def solve(self, word1, word2):\n\n rev = \"\"\n for i in reversed(range(len(word1))):\n rev += word1[i]\n return \"YES\" if rev == word2 else \"NO\"\n\n\nif __name__ == \"__main__\":\n word1 = input()\n word2 = input()\n\n t = Translation()\n\n print(t.solve(word1, word2))\n", "i1=input()\r\ni2=input()\r\nres=i1[::-1]\r\nif res==i2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nreverse = \"\"\r\nfor char in s:\r\n reverse = char + reverse\r\nif reverse == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "str1 = input()\r\nstr2 = input()\r\nrev =''.join(reversed(str1))\r\nif(rev == str2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\na1=list(a)\r\na1.reverse()\r\nb1=list(b)\r\nif a1==b1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nt = t[::-1]\r\nif (s==t):\r\n\t print('YES\\n')\r\nelse:\r\n\t print('NO\\n')", "a = input()\r\nb = input()\r\nh = 0\r\nc = []\r\nfor i in range(1, len(a) + 1):\r\n c.append(a[-i])\r\nfor i in range(0, len(a)):\r\n if b[i] != c[i]:\r\n print(\"NO\")\r\n h += 1\r\n break\r\nif h == 0:\r\n print(\"YES\")\r\n", "word_1 = list(input())\r\nword_2 = list(input())\r\nif word_1[::-1] == word_2: print(\"YES\")\r\nelse: print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nlist = []\r\nstr =''\r\nfor x in s:\r\n list.insert(0,x)\r\nif(str.join(list)==t):\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\n\r\nnew_s = []\r\nfor i in s:\r\n new_s.append(i)\r\n\r\nnew_s.reverse()\r\n\r\nanswer = \"\"\r\nanswer = answer.join(new_s)\r\n\r\nif answer == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# Coded By Block_Cipher\r\n\r\nimport math\r\nimport os\r\nimport random\r\nimport re\r\nimport sys\r\n\r\na = input()\r\nb = input()\r\n\r\nnew_b = b[::-1]\r\n\r\nif (a==new_b):\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "a = input()\r\nb = input()\r\na = list(a)\r\na.reverse()\r\nif b == ''.join(a):\r\n print('YES')\r\nelse:\r\n print('NO')", "def f(h,n):\r\n if t == n[::-1]:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n\r\n\r\n\r\n\r\nt = input()\r\nb = input()\r\nprint(f(t,b))", "s = input()\r\nt = input()\r\nt = list(t)\r\ny = []\r\nfor i in range(len(t)):\r\n y.append(t[len(t)-i-1])\r\nt = \"\".join(y)\r\n\r\nif s == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nans = 1\r\n\r\ni=0\r\nwhile i< len(s) and i < len(t) :\r\n if s[i] != t[len(t) - i-1] :\r\n ans = 0\r\n i += 1\r\nif ans == 1:\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "word1 = input()\r\nword2 = input()\r\nprint(\"YES\") if word1[::-1] == word2 else print(\"NO\")\r\n", "t=input()\r\nt1=input()\r\n\r\nt3=t[::-1]\r\n\r\nif(t1==t3):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\nm=input()\r\nr=n[::-1]\r\nif r==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "l=input()\r\nr=list(input())\r\na=r[::-1]\r\ns=\"\"\r\nfor i in a:\r\n s+=i\r\nif(l == s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "# https://codeforces.com/problemset/problem/41/A\r\n\r\nt = input()\r\ns = input()\r\n\r\nif t == s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "firstWord = input()\r\nsecondWord = input()\r\n\r\nisTranlatedCorrect = firstWord == secondWord[::-1]\r\n\r\nif isTranlatedCorrect:\r\n print('YES')\r\nelse:\r\n print('NO')", "z=input()\r\nx=input()\r\nj=z[::-1]\r\nif x==j:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def fun(l,s):\r\n if l==s[::-1]:\r\n print('YES')\r\n else:\r\n print('NO')\r\n \r\n \r\n\r\nT = (input())\r\nS = (input())\r\n# T = int(input())\r\n# for i in range(T):\r\n# # var=input()\r\n# # st=input()\r\n# # val=int(input())\r\n# # ms= list(map(int, input().split()))\r\n# ls= list(map(int, input().split()))\r\n# fun(ls)\r\nfun(T,S)\r\n", "s=input()\r\nt=input()\r\nst=t[::-1]\r\nif(s==st):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "sTR= input().strip()\r\nt= input().strip()\r\nif sTR==t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\n\r\ny = \"\"\r\n\r\nfor i in range(len(s)):\r\n if s[i] == t[len(t)-1-i]:\r\n y += \"YES\"\r\n else:\r\n y += \"NO\"\r\n\r\nif \"NO\" in y:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "[A, B] = [[x for x in input()], [x for x in input()]]\r\nB.reverse()\r\nprint('YES' if A == B else 'NO')\r\n", "palabra=input()\r\nreves=input()\r\nlista=[]\r\nfor i in range(len(reves)):\r\n lista.append(reves[len(reves)-(i+1)])\r\n\r\npalabraReves=''.join(lista)\r\nprint('YES' if palabraReves==palabra else 'NO')\r\n", "a = [*(str(input()))]\r\nareverse = a[::-1]\r\nb = [*(str(input()))]\r\n\r\nif b == areverse:\r\n print(\"YES\")\r\n \r\nelse :\r\n print(\"NO\")", "a = input()\r\nb = input()\r\nc = \"\"\r\ni = len(a)-1\r\nwhile i >= 0 :\r\n c = c+a[i]\r\n i-=1\r\nif b == c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "# Traslation\r\nfirst = input()\r\nsecond = input()\r\nif second == first[-1::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word=input()\r\nword2=input()\r\nif word[::-1]==word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n ", "S = input()\r\nA = input()\r\nif S[::-1] == A:\r\n print('YES')\r\nelse: print('NO')", "s = input()\r\nt = input()\r\nans = \"\"\r\nif s == t[::-1]:\r\n ans = \"YES\"\r\nelse:\r\n ans = \"NO\"\r\nprint(ans)", "def main():\n\ts1 = input()\n\ts2 = input()\n\tif len(s1) != len(s2) :\n\t\treturn \"NO\"\n\tif len(s1) == len(s2):\n\t\tfor i in range (len(s1)):\n\t\t\tif s1[i] == s2[len(s1)-i-1]:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\treturn \"NO\"\n\treturn \"YES\"\t\nprint(main())", "n=input()\r\nm=input()\r\n\r\nl1=list(n)\r\nl2=list(m)\r\n\r\nl1.reverse()\r\n\r\nif l1==l2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nt1=t[::-1]\r\nif(s==t1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s=input();t=input()\r\nch=''\r\nfor i in range(len(s)-1,-1,-1):\r\n ch+=s[i]\r\nif(ch==t):\r\n print('YES')\r\nelse :\r\n print('NO')", "# import sys\n# sys.stdin=open('input.in','r')\n# sys.stdout=open('output.out','w')\ns=input()\nn=input()\nk=s[::-1]\t\nif k==n:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "def _41A(words):\r\n\r\n return('YES' if \"\".join(reversed(words[1])) == words[0] else 'NO')\r\n\r\nif __name__ == \"__main__\":\r\n\r\n words = []\r\n for index in range(2):\r\n words.append(input())\r\n print(_41A(words))\r\n", "s = input()\r\nt = input()\r\ns2 = s[::-1]\r\n\r\nif s2 == t :\r\n print(\"YES\")\r\nelse:\r\n print (\"NO\")", "def translation():\r\n x = input()\r\n y = input()\r\n x_reverse = []\r\n for i in x:\r\n x_reverse.append(i)\r\n x_reverse.reverse()\r\n x_after = (\"\".join(x_reverse))\r\n if y == x_after:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\ntranslation()", "def solve(name1, name2):\r\n\r\n len1 = len(name1)\r\n len2 = len(name2)\r\n\r\n if len1 != len2:\r\n return \"NO\"\r\n\r\n for i in range(0,len1):\r\n if name1[i] != name2[len1-i-1]:\r\n return \"NO\"\r\n\r\n return \"YES\"\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n name1 = input()\r\n name2 = input()\r\n print(solve(name1,name2))", "def solution(S, S2):\r\n \r\n if S[::-1] == S2:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n\r\ndef main():\r\n S = str(input())\r\n S2 = str(input())\r\n\r\n print(solution(S, S2))\r\n\r\n\r\nmain()", "def rev(a):\r\n return a[::-1]\r\na=input(\"\")\r\nb=input(\"\")\r\nc=rev(a)\r\nif (c==b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nla=len(a)\r\nb=input()\r\nlb=len(b)\r\nx=1\r\nif la!=lb:\r\n x=0\r\nelse:\r\n for i in range(la):\r\n if a[i]!=b[la-i-1]:\r\n x=0\r\n break\r\nif x==1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "s = input()\r\nt = input()\r\nt_translated = t[::-1]\r\nprint('YES' if s == t_translated else 'NO')\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Wed Nov 16 18:56:55 2022\r\n\r\n@author: SaltLyy\r\n\"\"\"\r\n\r\ns=input()\r\ns1=input()\r\ns2=s[::-1]\r\nif s1==s2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = list(input())\r\nt = input()\r\ns.reverse()\r\nr = \"\".join(s)\r\nif r == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "s1=input()\r\ns2=input()\r\nprint(\"YES\" if s1==s2[::-1] else \"NO\")", "a=input()\r\nb=input()\r\nc=\"\"\r\nfor i in b:\r\n c=i+c\r\nif a==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=input()\r\ns2=\"\".join(reversed(input()))\r\nif s1 == s2:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\t", "s = input()\r\nt = input()\r\n\r\ni = 0\r\ncek = \"YES\"\r\nwhile( i < len(s) ):\r\n if(s[i:i+1] != t[len(t)-i-1:len(t)-i]):\r\n cek = \"NO\"\r\n break\r\n i+=1\r\nprint(cek)\r\n", "import sys\r\nx, y = sys.stdin.read().split('\\n')[:-1]\r\nprint(('NO', 'YES')[x == y[::-1]], sep='\\n', end=None)\r\n", "s = list(reversed(input()))\r\nz = list(input())\r\nif s == z:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\ndef fjo(s):\r\n if len(s)==1:\r\n return s\r\n elif len(s)==2:\r\n return s[::-1]\r\n else:\r\n return s[-1]+fjo(s[1:len(s)-1])+s[0]\r\nif fjo(s)==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "lst = []\n\nfor i in range(2) :\n lst.append(input())\n\nstrng = lst[0]\nrevstr = lst[1]\n\nrevstr = revstr[::-1]\n\nif strng == revstr :\n print(\"YES\")\n \nelse :\n print(\"NO\")", "s = str(input())\r\nl = list(s)\r\nl.reverse()\r\nt = str(input())\r\nj =''.join(l)\r\nif j == t:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "n=input()\r\nt=input()\r\nn1=[]\r\nn1+=n\r\nn1=n1[::-1]\r\nx=''.join(n1)\r\nif x==t:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n", "t = input()\r\n\r\ns = input()\r\nstr = \"\"\r\nfor i in t:\r\n str = i + str\r\n\r\nif str == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "ch=input()\r\nsh=input()\r\nif len(sh)!=len(ch):\r\n print(\"NO\")\r\nelse:\r\n i=0\r\n while i<len(ch):\r\n if ch[i]!=sh[len(ch)-1-i]:\r\n print(\"NO\")\r\n break\r\n i+=1\r\n if i == len(ch):\r\n print(\"YES\")\r\n", "s = input()\r\nt = input()\r\nflag = \"YES\"\r\nif len(s) == len(t):\r\n for c in range(0, len(s), 1):\r\n if s[c] != t[len(t) - 1 - c]:\r\n flag = \"NO\"\r\nelse:\r\n flag = \"NO\"\r\nprint(flag)", "# import sys\r\n# sys.stdin = open(\"input.txt\", \"r\")\r\n# Submissing starts here -----\r\n\r\ns1 = input()\r\ns2 = input()\r\nsimilar = True\r\nif (len(s1)!=len(s2)): similar=False\r\nelse:\r\n for i in range(len(s1)):\r\n if(s1[i]!= s2[len(s1)-i-1]):\r\n similar = False\r\n break \r\nif similar: print(\"YES\")\r\nelse: print(\"NO\")", "word1 = input()\r\nword2 = input()\r\nc = word1[::-1]\r\nif c == word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "a = input()\r\nb = []\r\nfor i in range(len(a)):\r\n b.append(a[i])\r\nb.reverse()\r\nb = ''.join(b)\r\nc = input()\r\nif b == c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\nprint(\"YES\" if a == b[::-1] else \"NO\")\n# Sat Oct 23 2021 16:13:22 GMT+0000 (Coordinated Universal Time)\n", "def tran(s, t):\r\n if(s == t[::-1]):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\nst = input()\r\nst2 = input()\r\ntran(st, st2)", "s = input()\r\nt = input()\r\nx = \"\"\r\nfor _ in range(len(s)):\r\n if s[_] == t[len(t)-1-_]:\r\n x += \"YES\"\r\n else:\r\n x += \"NO\"\r\nif \"NO\" in x:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n\r\n", "s = input()\nt = input()\nf = 0\nfor a in range(len(s)):\n if not(s[a] == t[len(t)-a-1]):\n f = 1\nif f == 1:\n print(\"NO\")\nelse:\n print(\"YES\")\n", "s=input()\r\nt=input()\r\nl=len(s)\r\nfor i in range(0,l):\r\n if t[i]!=s[-i-1]:\r\n print(\"NO\")\r\n break\r\nelse:\r\n print(\"YES\")", "word = input()\r\ntrans = str(input())\r\nanswer = True\r\nfor i in word:\r\n\r\n if i == trans[-1]:\r\n trans = trans[:-1]\r\n else:\r\n answer = False\r\n break\r\n\r\nif answer == True:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")\r\n\r\n \r\n", "word = input()\r\nword2 = input()\r\n\r\nword = word.lower()\r\nword2 = word2.lower()\r\n\r\nif word == word2[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input();t=input()\r\nprint('YES') if t==s[::-1] else print('NO')\r\n \r\n", "_1 = '236a'\r\n# count = 0\r\n# l = [list(map(int, input().split())) for i in range(5)]\r\n# for i in range(5):\r\n# for j in range(5):\r\n# if l[i][j] == 1:\r\n#\r\n# if i > 2:\r\n# count += i - 2\r\n# elif i < 2:\r\n# count += 2 - i\r\n# if j > 2:\r\n# count += j - 2\r\n# elif j < 2:\r\n# count += 2 - j\r\n# print(count)\r\n_2 = '339a'\r\n# n = list(map(str, input().split('+')))\r\n# n.sort()\r\n# print('+'.join(n))\r\n_3 = '266a'\r\n# count = 0\r\n# t = 0\r\n# n1 = int(input())\r\n# n = list(str(input()))\r\n# for i in range(1,n1,1):\r\n# if n[i] == n[i-1]:\r\n# count +=1\r\n# print(count)\r\n_4 = '96a'\r\n# flag = False\r\n# flag1 = False\r\n# p0=0\r\n# p1=0\r\n# l = list(str(input()))\r\n# for i in l:\r\n# if i == '0':\r\n# p0 += 1\r\n# if p0 >= 7:\r\n# flag = True\r\n# else:\r\n# p0 = 0\r\n# for i in l:\r\n# if i == '1':\r\n# p1 += 1\r\n# if p1 >= 7:\r\n# flag1 = True\r\n# else:\r\n# p1 = 0\r\n# if flag == True or flag1 == True:\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\")\r\n_5 = '236a'\r\n# l = list(str(input()))\r\n# if len(set(l)) % 2 == 0:\r\n# print(\"CHAT WITH HER!\")\r\n# else:\r\n# print(\"IGNORE HIM!\")\r\n_6 = '281a'\r\n# l = list(str(input()))\r\n# t = l[0].upper()\r\n# print(t + ''.join(l[1:]))\r\n_7 = '546a'\r\n# s = 0\r\n# a,b = map(int, input().split())\r\n# while a <= b:\r\n# a*=3\r\n# b*=2\r\n# s+=1\r\n# print(s)\r\n_8 = '116a'\r\n# t = 0\r\n# l1 = []\r\n# n = int(input())\r\n# l = [list(map(int, input().split())) for i in range(n)]\r\n# for i in range(n):\r\n# t += l[i][1]\r\n# t -= l[i][0]\r\n# l1.append(t)\r\n# print(max(l1))\r\n_9 = '977a'\r\n# n,k = map(int, input().split())\r\n# for i in range(k):\r\n# if n % 10 == 0:\r\n# n/=10\r\n# else:\r\n# n-=1\r\n# print(int(n))\r\n_10 = '266b'\r\n# n = str(input())\r\n# l = list(n)\r\n# low = 0\r\n# up = 0\r\n# for i in l:\r\n# if i.islower():\r\n# low += 1\r\n# else:\r\n# up += 1\r\n# if low >up:\r\n# print(n.lower())\r\n# elif low < up:\r\n# print(n.upper())\r\n# else:\r\n# print(n.lower())\r\n_11 = '110a'\r\n# n = list(str(input()))\r\n# l=[]\r\n# for i in range(len(n)):\r\n# if n[i] == '4' or n[i] == '7':\r\n# l.append(i)\r\n# if len(l) == 4 or len(l) == 7:\r\n# print('YES')\r\n# else:\r\n# print('NO')\r\n_12 = '41a'\r\n\r\nn = str(input())\r\nn1 = str(input())\r\nif n1 == n[::-1]:\r\n print('YES')\r\nelse:\r\n print(\"NO\")\r\n", "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\nx = insr()\r\ny = insr()\r\n\r\ny.reverse()\r\n\r\nif x == y:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "st1 = list(input())\r\nst2 = list(input())\r\nst1.reverse()\r\nif st1 == st2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "org = input()\r\ntra = input()\r\nrevOrg = \"\"\r\nfor i in range(len(org)-1,-1,-1):\r\n revOrg = revOrg + org[i]\r\nif revOrg == tra:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=input()\r\ns2=input()\r\nif len(s1)!=len(s2):\r\n print(\"NO\")\r\nelse:\r\n flag=\"YES\"\r\n n=len(s1)\r\n for i in range(n):\r\n if s1[i]!=s2[n-i-1]:\r\n flag=\"NO\"\r\n break\r\n print(flag)", "n=str(input())\r\nt=str(input())\r\nx=n[::-1]\r\nif(t==x):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def str_rev(x):\r\n return x[::-1]\r\ndef main():\r\n s = input()\r\n t = input()\r\n if len(s) != len(t):\r\n print(\"NO\")\r\n else:\r\n t = str_rev(t)\r\n if s == t:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nif __name__ == '__main__':\r\n main()", "inp = input()\r\nreverse_inp = input()\r\n\r\nif inp == reverse_inp[::-1]:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")", "s = input().strip()\nt = input().strip()\n\nif len(s) != len(t):\n print(\"NO\")\nelse:\n for i in range(len(s)):\n if s[i] != t[len(t)-i-1]:\n print(\"NO\")\n break\n else:\n print(\"YES\")\n\n \t\t \t\t \t \t\t\t \t\t \t \t \t \t", "s = input('')\r\nt = input('')\r\n\r\nk = s[::-1]\r\n\r\nif s == t and k == t:\r\n print('YES')\r\n exit()\r\n\r\nif s == t:\r\n print('NO')\r\nelif t == k:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\r\n\r\n\r\n", "n=input()\r\nm=input()\r\nb=len(n)\r\na=''.join(reversed(m))\r\n\r\nif n==a:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "n = input()\r\nm = input()\r\nc = n[::-1]\r\nif c==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "l1 = input()\r\nl2 = input()\r\nif len(l1) != len(l2):\r\n\tprint('NO')\r\n\tquit()\r\nfor i in range(len(l1)):\r\n\tif l1[i] != l2[-i-1]:\r\n\t\tprint('NO')\r\n\t\tquit()\r\nelse: print('YES')\r\n", "m=input()\r\nn=input()\r\nk=m[::-1]\r\nif k==n:\r\n print(\"YES\")\r\nelse:print(\"NO\")", "w = input()\r\nw1 = input()\r\nif w1 == w[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=str(input())\r\nti=str(input())\r\nt=''\r\nfor i in s:\r\n t=i+t\r\nif(t==ti):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = [\"NO\", \"YES\"]\nprint(s[input()==input()[::-1]])", "def main(s1, s2):\r\n if s2 == s1[::-1]: return \"YES\"\r\n return \"NO\"\r\n \r\ns1 = input()\r\ns2 = input()\r\nprint(main(s1, s2))\r\n", "def solution():\n berlandish, birlandish = input(), input()\n if len(berlandish) != len(birlandish):\n print(\"NO\")\n return\n\n for i, c in enumerate(berlandish):\n if c != birlandish[len(birlandish) - i - 1]:\n print(\"NO\")\n return\n\n print(\"YES\\n\")\n\n\nif __name__ == \"__main__\":\n solution()\n", "d = (input()[::-1] == input())\r\nif d == True: print(\"YES\")\r\nelse:print(\"NO\")", "a = input()\r\nb = input()\r\nt = 1\r\nfor i in range(len(a)):\r\n\tif a[i] != b[len(b)-i-1] :\r\n\t\tt = 0\r\n\t\tbreak\r\nif t == 1 :\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')\r\n", "first_word = input()\r\nsecond_word = input()\r\n\r\naux = \"\"\r\n\r\nfor i in second_word:\r\n aux = i + aux\r\n\r\nprint(\"YES\" if first_word == aux else \"NO\")\r\n \r\n ", "s = str(input())\r\ntmp = list(input())\r\nt = \"\"\r\ntmp.reverse()\r\nfor i in tmp:\r\n t+=i\r\nif s == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = input()\r\ntranslation = input()\r\n\r\nif word == translation[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=input()\r\nb=input()\r\nc=len(a)\r\nd=[]\r\nfor i in range(c-1,-1,-1):\r\n k=a[i]\r\n d.append(k)\r\nf=list(b)\r\nif f==d:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "\r\ns = input()\r\nt = input()\r\n\r\nif len(s) != len(t):\r\n print(\"NO\")\r\n\r\nelse:\r\n\r\n i = 0\r\n j = len(s) - 1\r\n same = True\r\n\r\n while i < len(s):\r\n\r\n if not s[i] == t[j]:\r\n same = False\r\n break\r\n \r\n i+=1\r\n j-=1\r\n\r\n if same:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "while True:\r\n try:\r\n a = input()\r\n except EOFError:\r\n break\r\n b = input()\r\n if len(a) != len(b):\r\n print(\"NO\")\r\n continue\r\n bandera = 1\r\n for value in range(len(a)):\r\n if a[value] != b[len(a)-value-1]:\r\n bandera = 0\r\n break\r\n if bandera:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n \r\n", "s = str(input())\r\nt = str(input())\r\nif s==t[::-1]:\r\n print ('YES')\r\nelse:\r\n print ('NO')", "def mod():\r\n x=input()\r\n c=input()\r\n z=list(x)\r\n p=list(z.__reversed__())\r\n if c==(\"\".join(p)):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n\r\nmod() ", "s=str(input())\r\nr=str(input())\r\nj=0\r\nfor i in range(-1,-(len(s)+1),-1):\r\n if s[i]==r[j]:\r\n f=0\r\n else:\r\n f=1\r\n break\r\n j=j+1\r\nif f==0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nq = input()\r\nif q == a[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nr=input()\r\nl=s[ : :-1]\r\nif(l==r):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\na.lower()\r\nb.lower()\r\nif(b[::-1]==a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\ns1=input()\nif s1[::-1]==s:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t\t \t \t\t \t\t \t\t\t\t\t \t \t\t", "s = input()\r\nt = input()\r\nrt = \"\"\r\ni = -1\r\nfor _ in range(len(t)):\r\n rt+=t[i]\r\n i-=1\r\nif s == rt:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "if(input() == \"\".join(reversed(input()))):\n print(\"YES\")\nelse:\n print(\"NO\")", "s = input()\r\nt = input()\r\nt_list = []\r\nfor letter in t:\r\n t_list.append(letter)\r\nt_list.reverse()\r\nif \"\".join(t_list) == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "str = input()\r\natr = input()\r\nflag=1\r\natr = atr[::-1]\r\nfor i in range(len(str)):\r\n if str[i] == atr[i]:\r\n flag=1\r\n continue\r\n else:\r\n flag=0\r\n print(\"NO\")\r\n break\r\nif(flag==1):\r\n print(\"YES\")", "x = input()\ny = input()\na =\"\".join(reversed(x))\nif a == y:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a=[i for i in input()]\r\nb=[i for i in input()]\r\nb.reverse()\r\nif a==b:print(\"YES\")\r\nelse:print(\"NO\")", "n=input()\r\nm=input()\r\n#print(n,m)\r\nif n[::-1]==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = str(input())\r\nt = str(input())\r\n\r\nif sorted(s) == sorted(t) and t == s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input()\r\ny=input()\r\nz=[]\r\na=len(x)\r\nfor i in range(0,a):\r\n z.append(x[a-i-1])\r\nc=\"\".join(z)\r\nif(c==y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "forward = input()\r\nbackward = input()\r\nif forward[::-1] == backward:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "palabra=input()\r\npalabra2=input()\r\nif palabra[::-1]==palabra2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Sep 27 10:32:01 2021\r\n\r\n@author: cheeh\r\n\"\"\"\r\nl=list(input())\r\nl.reverse()\r\nk=list(input())\r\nif k==l:\r\n print('YES')\r\nelse:\r\n print(\"NO\")", "string1 = input()\r\nstring2 = input()\r\nrev_string2 = \"\"\r\n\r\nif len(string1) == len(string2):\r\n for i in range(len(string1)-1,-1,-1):\r\n rev_string2 += string2[i]\r\n\r\nif string1 == rev_string2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input()\r\ny=input()\r\nl=len(x)\r\nn=len(y)\r\nif l!=n:\r\n print('NO')\r\nelse:\r\n c=0\r\n i=0\r\n while i<l:\r\n if x[i]==y[l-i-1]:\r\n c+=1\r\n i+=1\r\n if c==l:\r\n print('YES')\r\n else:\r\n print('NO')", "s = input()\r\n\r\nn_s= s[::-1]\r\n\r\nt= input()\r\n\r\n\r\nif n_s == t:\r\n print('YES')\r\nelse:\r\n print(\"NO\")\r\n", "s1 = input()\r\ns2 = input()[::-1]\r\nprint('YES' if s1 == s2 else 'NO')\r\n\r\n", "n = str(input()).lower()\r\nn1 = n[::-1]\r\nb = str(input()).lower()\r\nif n1 == b:\r\n print('YES')\r\nelse:\r\n print('NO')", "c=input()\nd=input()\nif d==c[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t \t\t\t\t \t \t\t \t \t\t\t", "s = input()\r\nt = input()\r\nl = [*s]\r\nfor i in range(0,len(s)//2):\r\n m = l[i]\r\n l[i] = l[len(s)-i-1]\r\n l[len(s)-i-1] = m\r\nif l == [*t]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \r\n", "s=str(input())\r\ns2=str(input())\r\nk=[]\r\nl=[]\r\nfor i in range(len(s)):\r\n k.append(s[-i-1])\r\nfor z in range(len(s2)): \r\n l.append(s2[z])\r\nif l==k :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") \r\n", "s1 = input()\r\ns2 = input()\r\n\r\nf = True\r\n\r\nif len(s1) == len(s2):\r\n for i in range(len(s1)):\r\n if s1[i] != s2[(len(s1)-1)-i]:\r\n f = False\r\n\r\nelse:\r\n f = False\r\n\r\nif f == False:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "Entrada = list(input())\r\nLista_Inversa = list()\r\ni = -1\r\nwhile i > -len(Entrada) - 1:\r\n Caracter = Entrada[i]\r\n Lista_Inversa.append(Caracter)\r\n i -= 1\r\nResultado_Comparacion = list(input())\r\nif Resultado_Comparacion == Lista_Inversa:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nk=input()\r\nk=''.join(reversed(k))\r\nif k==s:\r\n print(\"YES\\n\")\r\nelse:\r\n print(\"NO\\n\")\r\n", "v=input()\r\nx=input()\r\ny=v[::-1]\r\n\r\nif x==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "berlandish = input() # s\r\nbirlandish = input() # t\r\n\r\nprint('YES') if berlandish == birlandish[::-1] else print('NO')\r\n", "S=input()\r\nS1=input()\r\nS2=S1[::-1]\r\nif S==S2:\r\n print('YES')\r\nelse:\r\n print('NO')", "import sys\r\ndef get_string(): \r\n return sys.stdin.readline().strip()\r\n\r\ns, t = get_string(), get_string()\r\nprint(\"YES\" if s == t[::-1] else \"NO\")", "b=input()\r\nc=input()\r\nif c==(b[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = str(input())\nb = str(input())\nif a[::-1] == b:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "s = input()\r\nt = input()\r\n\r\nslist = []\r\ntlist = []\r\n\r\nslist[:0] = s\r\ntlist[:0] = t\r\n\r\nx = len(slist)\r\nflag = 0\r\n\r\nif x == len(tlist):\r\n for i in range(x):\r\n if slist[i]!=tlist[x-1-i]:\r\n print(\"NO\")\r\n break\r\n flag = flag + 1\r\n if flag == x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "st=str(input());st2=str(input());strrev=st[::-1];print('YES')if st2==strrev else print('NO')", "a=input()\r\nb=input()\r\nsum=0\r\nc=''\r\nfor i in b:\r\n sum=sum+1\r\nfor i in range(sum-1,-1,-1):\r\n c=c+b[i]\r\nif a==c:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=str(input())\r\nj=str(input())\r\ne=s[::-1]\r\nif(e==j):\r\n print('YES')\r\nelse:\r\n print('NO')", "w1 = input()\nw2 = input()[::-1]\nif(w1 == w2):\n print(\"YES\")\nelse:\n print(\"NO\") ", "\r\nlista = []\r\nfor i in range(0,2):\r\n entrada = input()\r\n lista.append(entrada)\r\n\r\nelemento = lista[1]\r\nelemento = elemento[::-1]\r\n\r\nif elemento == lista[0]:\r\n print(\"YES\")\r\n\r\nif elemento != lista[0]:\r\n print(\"NO\")", "First_word = input()\r\nSecond_word = input()\r\n\r\nnaujas = \"\"\r\n\r\nfor ch in Second_word[::-1]:\r\n naujas += ch\r\n\r\nif First_word == naujas:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input()\r\ny=input()\r\nz=\"\"\r\nnum=len(x)\r\nfor i in range(1,num+1):\r\n z+=x[-i]\r\n\r\nif z==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\nm=input()\r\nl=list(n)\r\nl.reverse()\r\nst=''\r\nfor i in l:\r\n st=st+i\r\nif st==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "first = list(input())\r\nsecond = list(input())\r\nnewS = second[::-1]\r\n\r\nif \"\".join(first) == \"\".join(newS):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nval = 'YES' if s == t[::-1] else 'NO'\r\nprint(val)\r\n", "a = input()\r\nb = input()\r\n\r\na = reversed(a)\r\naa =\"\"\r\nfor i in a:\r\n aa =aa + i \r\n \r\nif aa==b:print(\"YES\")\r\nelse:print(\"NO\")", "s= input()\r\nn= input()\r\nif n==s[::-1]:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")\r\n\r\n\r\n\r\n \r\n ", "q=input()\r\nt=input()\r\nif q[::-1]==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# t=int(input())\r\n# for i in range(t):\r\n# n=int(input())\r\n# (ma=listap(int,input().split()))\r\n# w=a[0]\r\n# if(w==0):\r\n# print(0)\r\n# else:\r\n# d=w\r\n# for i in range(1,n):\r\n# d -=1\r\n# d+=a[i]\r\n# w+=a[i]\r\n# if(d==0):\r\n# break\r\n# print(t) \r\n \r\n# t=int(input())\r\n# for i in range(t):\r\n# x,y,n=map(int,input().split())\r\n# count=0\r\n# for i in range(n+1):\r\n# if((x^i)<(y^i)):\r\n# count+=1\r\n# print(count) \r\n# w=int(input())\r\n# flag=0\r\n# for i in range(1,w):\r\n# if((w-i)%2==0 and i%2==0):\r\n# flag=1\r\n# break\r\n# if(flag==1):\r\n# print(\"YES\")\r\n# else:\r\n# # print(\"NO\") \r\n# w=int(input())\r\n# if(w>2 and w%2==0):\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\") \r\n# n=int(input())\r\n# d={}\r\n# b=set()\r\n# for i in range(n):\r\n# c=input()\r\n# if c not in b:\r\n# d[c]=1\r\n# b.add(c)\r\n# print(\"OK\")\r\n# else:\r\n# print(c+str(d[c]))\r\n# d[c]+=1 \r\n# def factorial(N):\r\n# if(N==0 or N==1):\r\n# return 1\r\n# return(N*factorial(N-1))\r\n# N=int(input())\r\n# print(factorial(N)) \r\n# def dist(s): for finding the year which has no repeated element\r\n# s=str(s)\r\n# for i in range(len(s)):\r\n# for j in range(i + 1,len(s)): \r\n# if(s[i] == s[j]):\r\n# return False\r\n# return True\r\n# n=int(input())\r\n\r\n# while(True):\r\n# n=n+1\r\n# if(dist(n)==True):\r\n# print(n)\r\n# break\r\n# t=int(input())\r\n# for i in range(t):\r\n# n,k=map(int,input().split())\r\n# a=list(map(int,input().split()))\r\n# d=max(a)+k\r\n# c=min(a)-k\r\n# e=d-c\r\n# print(e) \r\n# n=int(input())\r\n# for i in range(n):\r\n# n=input()\r\n# a=n[0]\r\n# b=n[-1]\r\n# c=len(n)\r\n# f=(c-2)\r\n# e=a+str(f)+b \r\n# if(c>10):\r\n# print(e)\r\n# else:\r\n# print(n)\r\n# n=int(input())\r\n# c=0\r\n# for i in range(n):\r\n# a=list(map(int,input().split()))\r\n# d=sum(a)\r\n# if(d>=2):\r\n# c+=1\r\n# print(c)\r\n# n,k=map(int,input().split())\r\n# a=list(map(int,input().split()))\r\n# b=0\r\n# for i in range(len(a)):\r\n \r\n# if(a[i]==0):\r\n# # print(0)\r\n# b = b\r\n# elif(a[i]>=a[k-1]):\r\n# b+=1\r\n# # d=len(b) \r\n# print(b) \r\n# t=int(input())\r\n# for i in range(t):\r\n# n=input()\r\n# c=len(n) \r\n# print(c)\r\n# t=int(input())\r\n# for i in range(t):\r\n# x,y=map(int,input().split())\r\n# if(x==y):\r\n# x-=1\r\n# print(x,y)\r\n# elif(x>y):\r\n# x=x-1\r\n# y=y\r\n# print(x,y)\r\n# else:\r\n# y=y\r\n# x=x-1\r\n# print(x,y)\r\n# m,n=map(int,input().split())\r\n# d=m*n//2\r\n# print(d)\r\n# k,n,w=map(int,input().split())\r\n# d=0\r\n# for i in range(1,w+1):\r\n# d+=(k*i)\r\n# e=d-n\r\n# if(e>0):\r\n# print(e)\r\n# else:\r\n# print(0)\r\n# x=int(input())\r\n# d=x//5\r\n# e=x%5 \r\n# if(e==0):\r\n# print(d)\r\n# else:\r\n# print(d+1)\r\n# t=int(input())\r\n# x=0\r\n# for i in range(t):\r\n# a=input()\r\n# m=\"++X\"\r\n# o=\"X++\"\r\n# n=\"--X\"\r\n# p=\"X--\"\r\n# if(m in a or o in a):\r\n# x+=1\r\n# else:\r\n# x-=1\r\n# # print(x)\r\n# import math\r\n# n=int(input())\r\n# sum=0\r\n# for i in range(1,n+1):\r\n# sum=sum+(pow(-1,i)*i)\r\n# print(math.floor(sum)) \r\n# t=int(input())\r\n# for i in range(t):\r\n# a,b=map(int,input().split())\r\n# e=(a//2)*(b//2)\r\n# o=(a-(a//2))*(b-(b//2))\r\n# print(e+o) \r\n# for _ in range(int(input())):\r\n # n,m=map(int,input().split())\r\n # a=set(list(map(int,input().split())))\r\n\r\n# import math\r\n# t=int(input())\r\n# for i in range(t):\r\n# n,d=map(int,input().split())\r\n# a=list(map(int,input().split()))\r\n# risk_count=0\r\n# for i in range(n):\r\n# if(a[i]>=80 or a[i]<=9):\r\n# risk_count+=1\r\n \r\n# print(math.ceil(risk_count/d)+math.ceil((n-risk_count)/d))\r\n# # d=len(a)-count \r\n# n=int(input())\r\n# for i in range(n):\r\n# a=list(map(int,input().split()))\r\n# c=sum(a)/n\r\n# print(format(c,\".12f\"))\r\n# d1,v1,d2,v2,p=map(int,input().split())\r\n# a=0\r\n# c=0\r\n# if(d1==d2 and d1==1):\r\n# while(a<p):\r\n# c+=1\r\n# a+=(v1+v2)\r\n# print(c)\r\n# else:\r\n# c=(min(d1,d2)-1)\r\n# while(a<p):\r\n# if(d1>d2):\r\n# a+=v2\r\n# d2+=1\r\n# elif(d2>d1):\r\n# a+=v1\r\n# d1+=1\r\n# elif(d1==d2):\r\n# a+=(v1+v2)\r\n# c+=1\r\n# print(c)\r\n# t=int(input())\r\n# for i in range(t):\r\n# n,k=map(int,input().split())\r\n# a=[]\r\n# for i in range(1,n+1):\r\n# a.append(i)\r\n# if(n%2==0):\r\n# for i in range(n):\r\n# if(i%2==0):\r\n# a[i]=-a[i]\r\n# else:\r\n# a[i]=+a[i]\r\n# else:\r\n# for i in range(n):\r\n# if(i%2==0):\r\n# a[i]=+a[i]\r\n# else:\r\n# a[i]=-a[i]\r\n# print(a)\r\n# sum=0\r\n# cnt=0\r\n# for i in range(n):\r\n# sum+=a[i]\r\n# if(sum>0):\r\n# cnt+=1\r\n# print(cnt)\r\n# if(cnt>k):\r\n# for i in range(n,-1,-2):\r\n# if(a[i]<0):\r\n# a[i]=-a[i]\r\n# else:\r\n# a[i]=-a[i] \r\n# cnt-=1\r\n# # print(a)\r\n# elif(cnt<k):\r\n# for i in range(n):\r\n# if(a[i]>0):\r\n# a[i]=-a[i]\r\n# else:\r\n# a[i]=-a[i]\r\n# cnt+=1\r\n# elif(cnt==k):\r\n# break \r\n# print(a) \r\n# a=input()\r\n# b=input()\r\n# def solve(a,b):\r\n# a=a.lower()\r\n# b=b.lower()\r\n# c=0\r\n# for i in range(len(a)):\r\n# if(a[i]>b[i]):\r\n# return 1\r\n# elif(a[i]<b[i]):\r\n# return -1\r\n# else:\r\n# c+=1\r\n# if(c==len(a)):\r\n# return 0\r\n# print(solve(a,b))\r\n# n=int(input())\r\n# a=list(map(int,input().split()))\r\n# sum=0\r\n# for i in range(n):\r\n# sum=sum+a[i]\r\n# c=sum/n\r\n# print(c)\r\n# a=int(input())\r\n# if(a%2==0):\r\n# d=a//2\r\n# print(d)\r\n# else:\r\n# e=-((a//2)+1)\r\n# print(e)\r\n# for _ in range(int(input())):\r\n# n=int(input())\r\n# a=input()\r\n# x=\"trygub\"\r\n# b=set(x)\r\n# arr=[0]*256\r\n# i=0\r\n# while(a and i<len(a)):\r\n# if a[i] in b:\r\n# arr[ord(a[i])]+=1\r\n# a=a[:i]+a[i+1:]\r\n# else:\r\n# i+=1\r\n \r\n# y=\"bugryt\"\r\n# for i in y:\r\n# a+=i*arr[ord(i)]\r\n# print(a)\r\n# n=input()\r\n# a=list(n.split('+'))\r\n# # print(a)\r\n# a.sort()\r\n# # print(a)\r\n# print(\"+\".join(a))\r\n# n=input()\r\n# a=n[0]\r\n# a=a.capitalize()\r\n# b=n[1:]\r\n# # print(b)\r\n# c=a+b\r\n# print(c)\r\n# A=list(map(int,input().split()))\r\n# N=len(A)\r\n# def leaders(A,N):\r\n# for i in range(N):\r\n# flag=0\r\n# j=i+1\r\n# for j in range(N):\r\n# if(A[i]<=A[j]):\r\n# flag=1\r\n# break\r\n# if(flag==0):\r\n# print(A[i])\r\n# print(leaders(A,N)) \r\n# a=input()\r\n# b=set(a)\r\n# # print(b)\r\n# if(len(b)%2==0):\r\n# print(\"CHAT WITH HER!\")\r\n# else:\r\n# print(\"IGNORE HIM!\") \r\n# n=int(input())\r\n# s=input()\r\n# c=0\r\n# for i in range(1,n):\r\n# if(s[i]==s[i-1]):\r\n# c+=1\r\n# print(c)\r\n# def kthSmallest(A, n, k): \r\n# A.sort() \r\n# return A[k-1] \r\n# A=list(map(int,input().split()))\r\n# n = len(A) \r\n# k = int(input())\r\n# print(\"K'th smallest element is\",kthSmallest(A, n, k))\r\n# a=[4,3,1,2]\r\n# d=3\r\n# b=list(a) \r\n# c=a[d:]+a[:d]\r\n# print(c)\r\n# t=int(input())\r\n# for i in range(t):\r\n# n=int(input())\r\n# a=list(map(int,input().split()))\r\n # arr=[]\r\n # low=0\r\n # high=n-1\r\n # while(low<=high):\r\n # arr.append(a[low])\r\n # arr.append(a[high])\r\n # low=low+1\r\n # high=high-1\r\n # print(*arr[:n]) \r\n# t=int(input())\r\n# for i in range(t):\r\n# n=int(input())\r\n# a=input()\r\n# if (a[0]=='2'and a[-3:]=='020')or(a[:2]=='20' and a[-2:]=='20'):\r\n# print(\"YES\")\r\n# elif (a[:3]=='202' and a[-1]=='0')or a[:4]=='2020'or a[-4:]=='2020':\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\") \r\n # if(s==2020):\r\n # print(\"YES\")\r\n # elif(s.count(2)>2 and s.count(0)>2):\r\n # print(\"YES\")\r\n # else:\r\n # print(\"NO\")\r\n# temparray=[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,-1,-1,-1,-1,-1,-1]\r\n# t=int(input())\r\n# for i in range(t):\r\n# n=int(input())\r\n# c=temparray[n-1]\r\n# print(c)\r\n##########-----majority element\r\n \r\n \r\n# def majorityElement(A,N):\r\n# m = -1\r\n# i = 0\r\n# for j in range(N):\r\n# if i == 0:\r\n# m = A[j]\r\n# i = 1\r\n# elif m == A[j]:\r\n# i = i + 1\r\n# else:\r\n# i = i - 1\r\n# return m\r\n# def majorityElement(A,N):\r\n# for i in range(N):\r\n# count = 1\r\n# for j in range(N):\r\n# if (A[j] == A[i]):\r\n# count+=1\r\n# if (count > N//2):\r\n# return A[i]\r\n# return -1 \r\n# N=int(input())\r\n# A=list(map(int,input().split())) \r\n# print(majorityElement(A,N))\r\n\r\n# from collections import Counter\r\n# def majorityElement(a,n):\r\n# x=Counter(a)\r\n# return x\r\n# print(majorityElement([2,3,4,2,1,3],2))\r\n \r\n\r\n\r\n# import itertools\r\n# t=int(input()) \r\n# for _ in range(t):\r\n# n=int(input())\r\n# a=input()\r\n# b=input()\r\n# if a==b:\r\n# print(\"EQUAL\")\r\n# else:\r\n# x=(list(itertools.permutations(a,n)))\r\n# y=(list(itertools.permutations(b,n)))\r\n# cx=cy=0\r\n# # print(len(xx))\r\n# for i in range(len(x)):\r\n# if x[i]>y[i]:\r\n# cx+=1\r\n# else:\r\n# cy+=1\r\n# # print(cx,cy)\r\n# if cx>cy:\r\n# print(\"RED\")\r\n# elif(cx<cy):\r\n# print(\"BLUE\")\r\n# else:\r\n# print(\"EQUAL\")\r\n# t=int(input())\r\n# for i in range(t):\r\n# n=int(input())\r\n# w=input()\r\n# a=0\r\n# for i in range(n-1,-1,-1):\r\n# if(w[i]!=')'):\r\n# break\r\n# a+=1\r\n# if(a>(n-a)):\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\")\r\n# t=int(input())\r\n# for i in range(t):\r\n# n=int(input())\r\n# while(True):\r\n# a=str(n)\r\n# a=set(a)\r\n# l=len(a)\r\n# c=0\r\n# for i in a:\r\n# if(i!='0' and n%int(i)!=0):\r\n# break\r\n# c+=1\r\n# if(c==l):\r\n# print(n)\r\n# break\r\n# n+=1\r\n# t=int(input())\r\n# for i in range(t):\r\n# n=input()\r\n# a=n.count(\"(\")\r\n# b=n.count(\")\")\r\n# d=n.count(\"?\")\r\n# if(a==b and d==0):\r\n# print(\"YES\")\r\n# elif(n[0]==\")\"):\r\n# print(\"NO\")\r\n# elif((a+b)==d):\r\n# print(\"yes\")\r\n# else:\r\n# print(\"NO\") \r\n# s= input()\r\n# upper=0\r\n# lower=0\r\n# for i in range(len(s)):\r\n# #to lower case letter\r\n# if(s[i]>='a' and s[i]<='z'):\r\n# lower+=1\r\n# #to upper case letter\r\n# elif(s[i]>='A' and s[i]<='Z'):\r\n# upper+=1\r\n# if(lower>upper or lower==upper):\r\n# s=s.lower()\r\n# elif(lower<upper):\r\n# s=s.upper()\r\n# else:\r\n# s.lower\r\n# print(s)\r\n# t=int(input()) \r\n# for i in range(t):\r\n# n=int(input())\r\n# if(n==1 or n==2):\r\n# print(0)\r\n# else:\r\n# d=((n-1)//2)\r\n# print(d)\r\n# t=int(input())\r\n# for i in range(t):\r\n# a,b=map(int,input().split())\r\n# if(a>b):\r\n# print(b, abs((a-b))//2)\r\n# else:\r\n# print(a, abs((a-b))//2)\r\n# def reverse_ankit(num):\r\n# sum=0\r\n# s=1\r\n# if num<0:\r\n# s=-1\r\n# num=num*-1\r\n# while num>0:\r\n# d=num%10\r\n# sum=sum*10+d\r\n# num=num//10\r\n# if not -2147483648<sum<2147483647:\r\n# return 0\r\n# return s*sum\r\n# print(reverse_ankit(-123)) \r\n# FOR TAKING MATRIX DIRECTLY\r\n\r\n# A= []\r\n\r\n# x = y = 0\r\n\r\n# for i in range(5):\r\n\r\n# matrix = input().split()\r\n\r\n# A.append(matrix)\r\n\r\n# for j in range(0, 5):\r\n\r\n# if(A[i][j] == \"1\"):\r\n\r\n# x = i-2\r\n\r\n# y = j-2\r\n\r\n# print(abs(x) + abs(y))\r\n# a,b=map(int,input().split())\r\n# c=0\r\n# while(True):\r\n# c=c+1\r\n# a=a*3\r\n# b=b*2\r\n# if( a>b):\r\n# print(c)\r\n# break\r\n# n,k=map(int,input().split())\r\n# for i in range(k):\r\n# if(n%10==0):\r\n# n=n//10\r\n# else:\r\n# n=n-1\r\n# print(n)\r\n# def sum(a,b):\r\n# while b!=0:\r\n# carry=a&b\r\n# a=a^b\r\n# b=carry<<1\r\n# return a\r\n# print(sum(5,3))\r\n# def findPairs(self, arr, n):\r\n# a=arr[0]\r\n# l=arr[n-1]\r\n # arr1=arr[0,n-1]\r\n # print(arr1)\r\n # sum=0\r\n # for i+1 in arr:\r\n # a=a+i\r\n # for i in arr[0,n-1]:\r\n# arr=[1,2,3,4,5,6]\r\n# n=6\r\n# a=arr[0]\r\n# l=arr[n-1]\r\n# arr1=arr[1:n]\r\n# arr2=arr[0:n-1]\r\n# arr3=[]\r\n# arr4=[]\r\n\r\n# for j in arr1:\r\n# b=a+j\r\n# arr3.append(b)\r\n# # print(arr3) \r\n# for i in arr2:\r\n# d=l+i \r\n# arr4.append(d)\r\n# # print(arr4)\r\n# for k in range(n-1):\r\n# for m in range (n-1):\r\n# if(arr3[k]==arr4[m]):\r\n# print((arr3[k]),(arr4[m]))\r\n# n=int(input())\r\n# if(n%2!=0):\r\n# print(\"yes\")\r\n# else:\r\n# print(\"no\")\r\n# array1=[1,5,9]\r\n# array2=[2,3,6,7]\r\n# arr3=array1+array2\r\n# arr3.sort()\r\n# n=len(arr3)\r\n# if(n%2!=0):\r\n# print(arr3[n//2])\r\n# else:\r\n# print(((arr3[n//2]+arr3[n//2-1])/2))\r\n# num=int(input())\r\n# if num>1:\r\n# for i in range(2,(num//2)+1):\r\n# if(num%i==0):\r\n# print(\"not p\")\r\n# break\r\n# else:\r\n# print(\"yes\")\r\n# else:\r\n# print(\"not\") \r\n# n= int(input())\r\n# if(n%5==0):\r\n# print(n//5)\r\n# else:\r\n# print((n//5)+1)\r\n# for _ in range(int(input())):\r\n# n=int(input())\r\n# an=list(map(int,input().split()))\r\n# if sum(an)%2==1:\r\n# print('NO')\r\n\r\n# elif an.count(1)%2==1:\r\n# print('NO')\r\n# elif an.count(2)%2==0:\r\n# print('YES')\r\n# elif an.count(1)-2>0 :\r\n# print('YES')\r\n# elif an.count(1)%2==0 and an.count(1)!=0:\r\n# print('YES')\r\n\r\n# else:\r\n# print(\"NO\")\r\n# t = int(input())\r\n# for i in range(t):\r\n# def find(a, b):\r\n# x = a%b\r\n# ans = b-x\r\n# print(ans)\r\n# a, b = [int(j) for j in input().split()]\r\n# if (a % b == 0):\r\n# print(0)\r\n# elif(b>a):\r\n# print(b-a)\r\n# else:\r\n# find(a,b)\r\n# s=\"hello world\"\r\n# a=s.split() \r\n# # for spliting the string into form of index\r\n# print(a)\r\n# print(len(a[-1]))\r\n# for _ in range(int(input())):\r\n# n=int(input())\r\n# arr=list(map(int,input().split()))\r\n# x=[]\r\n# for i in arr:\r\n# if i%2!=0:\r\n# x.append(i)\r\n# for i in arr:\r\n# if i%2==0:\r\n# x.append(i)\r\n# print(*x)\r\n# n=int(input())\r\n# a=list(map(int,input().split()))\r\n# total=(n*(n+1)//2)\r\n# d=sum(a)\r\n# print(total-d)\r\n# n=int(input())\r\n# print(n)\r\n# while n!=1:\r\n# if n%2==0:\r\n# n=n//2\r\n# print(n)\r\n# else:\r\n# n=(n*3)+1\r\n# print(n)\r\n\r\n\r\n\r\n# longest repition \r\n# n=list(input())\r\n# count=0\r\n# max=0\r\n# for i in range(len(n)-1):\r\n# if n[i] == n[i+1]:\r\n# count += 1\r\n# if max<=count:\r\n# max=count\r\n# elif n[i] != n[i+1]:\r\n# count=0\r\n# print(max+1) \r\n\r\n\r\n# Input: s = \"a1c1e1\"\r\n# Output: \"abcdef\" \r\n# \r\n# class Solution:\r\n # def replaceDigits(self, s: str) -> str:\r\n # n = len(s)\r\n # res = \"\"\r\n # for i in range(n):\r\n # if i % 2 == 0:\r\n # res += s[i]\r\n # else:\r\n # res += chr(ord(s[i-1]) + int(s[i]))\r\n # return res\r\n# Given a string s, return true if the s can be palindrome after deleting at most one character from it.\r\n# class Solution:\r\n# def validPalindrome(self, s: str) -> bool:\r\n# l, r = 0, len(s) - 1\r\n# while l < r:\r\n# if s[l] != s[r]:\r\n# s1, s2 = s[l:r], s[l+1:r+1]\r\n# return s1[::-1] == s1 or s2[::-1] == s2\r\n# l += 1\r\n# r -= 1\r\n# return True\r\n# s = \"0P\"\r\n# d = \"\"\r\n# for i in s:\r\n# if ((ord(i) >= 97 and ord(i) <= 122) or (ord(i) >= 65 and ord(i) <= 90)):\r\n \r\n# d += i\r\n# d=d.lower()\r\n# if(d==d[::-1]):\r\n# print(True)\r\n# else:\r\n# print(False) \r\n# if(only_alpha.lower()==only_alpha[::-1]):\r\n# print(True)\r\n# else:\r\n# print(False)\r\n\r\ns = input()\r\nt = input()\r\nif(t==s[::-1]):\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", "n = input()\r\nline = \"\".join(input().split())\r\nprint(\"YES\") if n[::-1] == line else print(\"NO\")\r\n", "a=input()\r\nb=input()\r\ndef rev_fun(re):\r\n a=len(re)\r\n re_b=\"\"\r\n for i in range(a,0,-1):\r\n re_b+=re[i-1]\r\n \r\n return re_b\r\nc=rev_fun(b)\r\nprint(\"YES\" if a==c else \"NO\")\r\n \r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sun Nov 20 20:42:42 2022\r\n\r\n@author: Lenovo\r\n\"\"\"\r\n\r\ns1 = input()\r\ns2 = input()\r\nn1 = len(s1)\r\nn2 = len(s2)\r\ni = 0\r\nj = n2 -1\r\n\r\nwhile i<n1 and j>=0:\r\n if s1[i] != s2[j]:\r\n print('NO')\r\n break\r\n i += 1\r\n j -= 1\r\n\r\nif i == n1:\r\n print('YES')", "def translation(a, b):\r\n return \"YES\" if a==b[::-1] else \"NO\"\r\n\r\na = input()\r\nb = input()\r\nprint(translation(a, b))", "s1=input()\ns2=input()\ns=s1[::-1]\nif(s2==s):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\t\t\t \t\t \t\t\t\t \t\t\t \t \t", "s=input()\r\nt=input()\r\n\r\na=len(s)\r\nb=len(t)\r\n\r\nif(a==b):\r\n x=t[b::-1]\r\n if(x==s):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")", "r = input()\nr1 = input()\n\nif r1 == r[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "x=input()\r\ny=input()\r\nk=[]\r\nn=len(x)\r\nfor i in range(0,n):\r\n k.append(x[n-i-1])\r\nc=\"\".join(k)\r\nif(c==y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nlst = []\r\nfor i in range(len(s)-1, -1, -1):\r\n lst.append(s[i])\r\n \r\nt1 = ''\r\nfor i in lst:\r\n t1 = t1 + i\r\n \r\nif (t == t1):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\nt = input()\n\nn = len(s)\nrisultato = True\nif (n != len(t)):\n print('NO')\nelse:\n for i in range(n):\n if (s[i] != t[n-1-i]):\n risultato = False\n break\n\n print('YES') if (risultato) else print('NO')", "m=input()\r\nk=input()\r\nres=m[::-1]\r\nans=k[::-1]\r\nif ans==m and res==k:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\r\nt=input()\r\nlx=''\r\nc=-1\r\nk=0\r\nwhile True:\r\n lx=lx+s[c]\r\n c=c-1\r\n k=-c\r\n if k==(len(s)+1) :\r\n break\r\nif lx==t:\r\n print(\"YES\")\r\nelse:\r\n print('NO')\r\n ", "print([\"NO\",\"YES\"][input()==''.join(reversed(input()))])\r\n\r\n\"\"\" c=''\r\na=input()\r\nfor i in range(len(a)-1,-1,-1):\r\n c+=a[i]\r\nprint([\"NO\",\"YES\"][input()==c]) \"\"\"", "a = list(input())\r\nb = input()\r\nr = len(a)\r\nc = \"\"\r\nfor i in range(r-1,-1,-1):\r\n c+=str(a[i])\r\nif c == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "m=input()\r\nn=input()\r\nz=m[::-1]\r\nif(n==z):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = input()\r\nt1 = input()\r\n\r\nyn1 = \"\"\r\n\r\nfor i in range(len(s1)):\r\n # This line checks if the first letter in s is the same as the last one in t and if the second is the same as the second last, and so on\r\n if s1[i] == t1[len(t1)-1-i]:\r\n yn1 += \"YES\"\r\n else:\r\n yn1 += \"NO\"\r\n\r\nif \"NO\" in yn1:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "print(*map(lambda x: 'YES' if ''.join(reversed(input())) == input() else 'NO', range(1)))", "def translation():\r\n berland = input()\r\n birland = input()\r\n return \"YES\" if birland[-1::-1] == berland else \"NO\"\r\n\r\n\r\nprint(translation())", "j = input()\r\nk = input()\r\np = 0\r\n\r\nif len(j) == len(k):\r\n for i in range(len(j)):\r\n if j[i] != k[len(j)-1-i]:\r\n p = 0\r\n break\r\n else:\r\n p = 1\r\n\r\n\r\nif p == 0:\r\n print(\"NO\")\r\nelif p == 1:\r\n print(\"YES\")\r\n", "f = str(input())\r\nl = str(input())\r\n\r\nif f == l[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "def check(word1, word2):\r\n\tif(len(word1) != len(word2)):\r\n\t\tprint(\"NO\")\r\n\t\treturn\r\n\r\n\tcount = 0\r\n\tfor i in word2[::-1]:\r\n\t\tif i != word1[count]:\r\n\t\t\tprint(\"NO\")\r\n\t\t\treturn\r\n\t\tcount+=1\r\n\r\n\tprint(\"YES\")\r\n\r\nber_word = input()\r\nbir_word = input()\r\ncheck(ber_word, bir_word)\r\n\r\n\r\n\r\n", "a=input()\r\nprint([\"NO\",\"YES\"][a[::-1]==input()])", "s=input()\r\nt=input()\r\na=[x for x in t]\r\na.reverse()\r\nb=''.join(a)\r\nif s==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "ber, bir = [input() for _ in range(2)]\nprint(\"YES\" if bir == ber[::-1] else \"NO\")\n", "import sys\r\nx=str(input())\r\ny=str(input())\r\np=len(x)\r\nq=len(y)\r\nz=0\r\nif p==q:\r\n for i in range(p):\r\n if x[i]==y[p-i-1]:\r\n z=1\r\n else:\r\n print('NO')\r\n sys.exit(0)\r\nif z==1:\r\n print('YES')\r\nelif p!=q:\r\n print('NO')", "def getLines(num):\r\n inputLines = []\r\n for i in range(0,num):\r\n line = input()\r\n if line:\r\n inputLines.append(line)\r\n else:\r\n break\r\n return inputLines\r\n \r\ndef notZeroPow(num,p):\r\n return True if num >= 1 and num <= pow(10,p) else False\r\n \r\n \r\nlines = getLines(2)\r\n\r\nw = lines[1]\r\ns = lines[0]\r\nwt = s[::-1]\r\n\r\nprint(\"YES\" if wt == w else \"NO\")", "s = input()\r\nr = input()\r\nif len(s) != len(r):\r\n print(\"NO\")\r\n exit(0)\r\nfor i in range(0, len(s)):\r\n if s[i] != r[len(r) - i - 1]:\r\n print(\"NO\")\r\n exit(0)\r\nprint(\"YES\")", "s = input()\r\nt = input()\r\nxx = reversed(list(s))\r\nxx = \"\".join(xx)\r\nif xx == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\n\r\n# If word t is reverse of s, then print YES\r\nif s == t[::-1]:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "def main():\r\n\r\n s = input()\r\n arr = input()\r\n\r\n stin = []\r\n sting =[]\r\n\r\n for i in s:\r\n stin.append(i)\r\n for i in arr:\r\n sting.append(i)\r\n\r\n stin.reverse()\r\n count=0\r\n if len(stin)==len(sting):\r\n for i in range(len(stin)):\r\n if stin[i]==sting[i]:\r\n count+=1\r\n\r\n if count==len(stin):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\nmain()\r\n", "text = str(input())\r\ntext2 = str(input())\r\nif text2 == text[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\ns = [x for x in s]\r\nt = input()\r\nt = [x for x in t]\r\n\r\nif t == s[::-1]:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "n=input()\r\nm=input()\r\nprint(\"YES\") if m==(n[::-1]) else print(\"NO\")\r\n", "data = []\nwhile True:\n try:\n line = input()\n except EOFError:\n break\n data.append(line)\nprint('YES' if data[0][::-1]== data[1] else 'NO')\n", "def main():\r\n t = input()\r\n s = input()\r\n i = 0\r\n j = len(s)-1\r\n flag = True\r\n while i < len(t):\r\n if t[i] != s[j]:\r\n print('NO')\r\n flag = False\r\n break\r\n i += 1\r\n j -= 1\r\n if flag:\r\n print('YES')\r\nmain() ", "s=input()\r\nt=input()\r\nprint( \"YES\" if t==s[::-1] else \"NO\")", "s = input()\r\nt = input()\r\nif len(s) != len(t):\r\n print(\"NO\")\r\nelse:\r\n f = 0\r\n for i in range(len(s)):\r\n if s[i] == t[-(i+1)]:\r\n f += 1\r\n if f == len(s):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "stringInput = input()\r\nstringReverse = input()\r\nif stringReverse == stringInput[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = list(input())\r\nt = list(input())\r\nt.reverse()\r\nif s == t: print('YES')\r\nelse: print('NO')", "def main(str1,str2):\r\n translate = [sym for sym in str1]\r\n translate.reverse()\r\n translate1 = ''\r\n for sym in translate: translate1+=sym\r\n if translate1==str2:\r\n return \"YES\"\r\n return \"NO\"\r\n\r\nprint(main(input(),input()))", "s= input()\r\ncomp = input()\r\n\r\nrevs = s[: :-1]\r\n\r\nif revs ==comp:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "bir=input()\r\nber=input()\r\nif bir == ber[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "st1=input()\r\nst2 = input()\r\nst3= st2[::-1]\r\nif st3==st1:\r\n\tprint(\"YES\")\r\n\t\r\nelse:\r\n\tprint(\"NO\")\r\n\t\r\n", "s=input()\r\nt=input()\r\nrev =s[::-1]\r\nif t==rev:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\ns_1 = \"\"\r\nfor i in range(len(s)-1,-1,-1):\r\n s_1 += s[i]\r\nif s_1 == input():\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x = input()\r\nz = input()\r\nif x==z[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = input()\r\nm = input()\r\no = list()\r\nKC = len(n)\r\nfor i in range(len(n)):\r\n KC -= 1\r\n SH = str(n[KC])\r\n o.append(SH)\r\no = ''.join([str(a) for a in o])\r\n\r\nif m == o:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\ng=input()\r\nst=list(s)\r\na = st[::-1]\r\nans = (\"\".join(a))\r\nif (ans == g):\r\n print(\"YES\\n\")\r\nelse:\r\n print(\"NO\\n\")", "l,r = input(),input()\r\nif l[::-1] == r:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = 0\r\nn = input()\r\nn1 = n[::-1]\r\nn2 = input()\r\nif n1 == n2:\r\n print(\"YES\")\r\nelse:\r\n print('NO')", "# 2\r\n# s = input()\r\n# arr = s.split(\"+\")\r\n# map_object = map(int, arr)\r\n# list_of_integers = list(sorted(map_object))\r\n# s_upd = \"\"\r\n# for i in range(0, len(list_of_integers) - 1):\r\n# s_upd += str(list_of_integers[i]) + \"+\"\r\n# print(s_upd + str(list_of_integers[len(list_of_integers) - 1]))\r\n\r\n# 8\r\ns = input()\r\nt = input()\r\ns = \"\".join(reversed(s))\r\nif t == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n# upper = 0\r\n# lower = 0\r\n# s = input()\r\n#\r\n# for i in range(0, len(s)):\r\n# if s[i] >= 'a':\r\n# lower = lower + 1\r\n# else:\r\n# upper = upper + 1\r\n#\r\n# if upper > lower:\r\n# for i in range(0, len(s)):\r\n# if s[i] >= 'a':\r\n# s[i] -= 32\r\n#\r\n# else:\r\n# for i in range(0, len(s)):\r\n# if 'A' <= s[i] <= 'Z':\r\n# s[i] += 32\r\n#\r\n# print(s)\r\n", "def f():\r\n pr,dr = input(),input()\r\n pl = [x for x in pr]\r\n pl.reverse()\r\n pr = \"\".join(pl)\r\n if pr == dr:\r\n return \"YES\"\r\n return \"NO\"\r\nprint(f())", "a, b = input(), input()\r\n\r\ndef main(a, b):\r\n for e1, e2 in zip(a, reversed(b)):\r\n if e1 != e2:\r\n return False\r\n return True\r\n\r\nprint('YES' if main(a, b) else 'NO')", "str1=input()\r\nstr2=input()\r\nstr22=str2[::-1]\r\nif(str1==str22):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\ns1=input()\r\ns123=s1[::-1]\r\nif(s==s123):\r\n print(\"YES\",end=\"\")\r\nelse:\r\n print(\"NO\",end=\"\")", "a = str(input())\r\nb = str(input())\r\nif a[::-1] == b:\r\n result = 'YES'\r\nelse:\r\n result = 'NO'\r\nprint(result)\r\n", "def flip(word): \r\n reverse = \"\"\r\n for c in word:\r\n reverse = c + reverse\r\n return reverse\r\n\r\nnormal = input()\r\nreversely = input()\r\n\r\nif flip(normal) == reversely:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=list(input())\ns2=input()\ns1=s1[::-1]\ns1=''.join(s1)\nif(s1==s2):\n print('YES')\nelse:\n print('NO')", "s1 = input().strip()\r\ns2 = input().strip()\r\nn = len(s1)\r\ncounter = 0\r\nfor i in range(0, n):\r\n if s1[i] == s2[-i-1]:\r\n counter += 1\r\n else:\r\n break\r\n\r\nif counter == len(s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n", "a = input()\r\nb = input()\r\nc = \"\"\r\nfor i in range(-1,-len(a)-1,-1):\r\n c += a[i]\r\nif c == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "word = input()\r\nword_list = list(word)\r\ndrow = input()\r\ndrow_list = list(drow)\r\nword_list.reverse()\r\n\r\nif drow_list == word_list :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "f_w = input()\r\ns_w = input()\r\n\r\nreversed_f_w = ''\r\nfor char in f_w:\r\n reversed_f_w = char + reversed_f_w\r\n\r\nif reversed_f_w == s_w:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "k=input()\r\nl=input()\r\nc=0\r\nfor i,j in list(zip(k,l[::-1])):\r\n if i==j:\r\n c=c+1\r\nif c==len(k):\r\n print('YES')\r\nelse:\r\n print('NO')", "import sys\r\n\r\nLI = lambda: list(map(int, sys.stdin.readline().split()))\r\nMI = lambda: map(int, sys.stdin.readline().split())\r\nSI = lambda: sys.stdin.readline().strip('\\n')\r\nII = lambda: int(sys.stdin.readline())\r\n\r\n# sys.stdin = open(\"input.txt\", \"r\")\r\n\r\n\r\na = SI()\r\nb = SI()\r\n\r\nif a[::-1] == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "c=input()\r\nc1=input()\r\nc1=c1[::-1]\r\nif(c1==c):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def isTranslated(first, second):\n if first == second[::-1]:\n return \"YES\"\n else:\n return \"NO\"\n \n\ndef main():\n firstString = input()\n secondString = input()\n \n print(isTranslated(firstString, secondString))\n\nif __name__ == \"__main__\":\n main()", "s=input()\r\nt=input()\r\nf=s[::-1]\r\nif f==t:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "Berlandish = input()\r\nBirlandish = input()\r\ncount = 0\r\nfor i in range(len(Berlandish)):\r\n if len(Berlandish) == len(Birlandish):\r\n if Berlandish[i] == Birlandish[-i-1]:\r\n count += 1\r\nif count == len(Berlandish):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "m=input()\r\nn=input()\r\nx=n[::-1]\r\nfor i in range(len(m)):\r\n if m[i]==x[i]:\r\n continue\r\n else:\r\n print(\"NO\")\r\n break\r\n \r\nelse:\r\n print(\"YES\")\r\n ", "s1 = input().upper()\r\ns2 = input().upper()\r\nif s1 == s2[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "lst = []\nfor i in range(2):\n lst.append(input())\n \nfirst = lst[0]\nsecond = lst[1]\n\nreverse = second[::-1]\n\nif first == reverse:\n print('YES')\nelse:\n print('NO')\n ", "str1=input()\r\nstr2=input()\r\nstr3=\"\"\r\nfor i in range(len(str1)-1,-1,-1):\r\n str3=str3+str1[i]\r\nif str2==str3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "flang = input()\r\nslang = input()\r\n\r\n\r\nmlist = 0\r\nfor i in range(len(flang)):\r\n if flang[i] == slang[(i+1)*(-1)]:\r\n mlist += 1\r\n else :\r\n break\r\nif mlist == len(flang):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "str1 = input()\r\nstr2 = input()\r\nrev = str1[::-1]\r\nif str2 == rev:\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "#####--------------Template Begin-------------------####\r\nimport math\r\nimport sys\r\nimport string\r\n#input = sys.stdin.readline\r\ndef ri(): #Regular input\r\n\treturn input()\r\ndef ii(): #integer input\r\n\treturn int(input())\r\ndef li(): #list input\r\n\treturn input().split()\r\ndef mi(): #map input\r\n\treturn list(map(int, input().split()))\r\n#####---------------Template Ends-------------------######\r\ns=ri()\r\nt=ri()\r\nif s==t[::-1]:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "word = list(input())\nreversed_word = list(input())\nif reversed_word[::-1]==word:\n print('YES')\nelse:\n print('NO')", "def reverse(string):\r\n string = list(string)\r\n string.reverse()\r\n return \"\".join(string)\r\n\r\na=input()\r\nb=input()\r\nif(b==reverse(a)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "if __name__ == \"__main__\":\r\n s = input().strip()\r\n t = input().strip()\r\n rev = ''\r\n\r\n for i in s:\r\n rev = i + rev\r\n if rev == t:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "\nBerlandish = input()\nBirlandish = input()\n\n\n\nprint(\"YES\" if Berlandish[::-1] == Birlandish else \"NO\")\n", "s = input()\r\nt = input()\r\nrev = s[-1::-1]\r\nif(t==rev):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "n = input()\r\nl = input()\r\nm = ''\r\nfor i in range(len(n)-1,-1,-1):\r\n m += n[i]\r\nif m == l:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def main():\r\n s = input()\r\n t = input()\r\n print(\"YES\" if t == s[::-1] else \"NO\")\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n", "nom_normal = input()\nnom_inverse = input()\n\nn=len(nom_inverse) \nn_normal = len(nom_normal)\n\ncompteur_nom = 0\n\nif (n_normal == n): \n for j in range(n):\n if nom_inverse[j]==nom_normal[n-j-1]:\n compteur_nom+= 1 \n else:\n print('NO')\n break\nelse : \n print('NO')\n\nif compteur_nom==n:\n print('YES')\n \n", "def main():\r\n entrada = input()\r\n entrada2 = input()\r\n if entrada == entrada2[::-1]:\r\n return print(\"YES\")\r\n return print(\"NO\")\r\n\r\nif __name__ == \"__main__\":\r\n main()", "s=input()\r\nss=input()\r\nif(s[::-1][:]==ss): print(\"YES\")\r\nelse: print(\"NO\")\r\n \r\n", "def reverse(s, t):\n return s == t[::-1]\n\ns = input().strip()\nt = input().strip()\n\nif reverse(s, t):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \t \t\t\t \t\t\t\t \t \t\t \t \t \t \t", "s1 = input()\r\ns2= input()\r\nc = s1[::-1]\r\n\r\nif c==s2:\r\n \r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nr = input()\n\ns = s[::-1]\n\nif r==s:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t\t \t\t\t\t \t \t\t\t \t\t \t \t \t\t\t \t\t \t", "str1=input()\r\nstr2=input()\r\nrev=\"\"\r\nfor i in str2:\r\n rev=i+rev\r\nif(str1==rev):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\nb=input()\na=list(a)\na.reverse()\na=''.join(a)\nif a==b:\n print('YES')\nelse:\n print('NO')\n", "str1 = input()\r\nstr2 = input()\r\nans = str1[::-1]\r\nif ans == str2:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "x = input()\r\ny = input()\r\nreverse = \"\".join(reversed(x))\r\nif y == reverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str=input()\nstr1=input()\nif(str[::-1]==str1):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t\t \t \t \t \t\t \t\t \t \t\t \t \t \t", "s1=input()\r\ns2=input()\r\nk=s1[::-1]\r\np=s2[::-1]\r\nif k == s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input())\r\nt = str(input())\r\nwhile len(s) < 1000 and len(t) < 1000:\r\n if s == t[::-1]:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n break", "s1 = input()\r\ns2 = input()\r\ns3 = s1[::-1]\r\nif(s3==s2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t = input()\r\ns = input()\r\nprint(\"YES\" if (''.join(reversed(t))==s )else \"NO\")", "str1=list(input())\r\nstr2=input()\r\nstr1.reverse()\r\nstr3=''.join(str1)\r\nif str2==str3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=list(input())\r\nt=list(input())\r\nsize=len(s)\r\n\r\ncnt=0\r\nif len(s)!=len(t):\r\n print('NO')\r\nelse:\r\n for i in range(size):\r\n if s[i]==t[size-i-1]:\r\n cnt+=1\r\n else:\r\n print('NO')\r\n break\r\n\r\n if cnt==size:\r\n print('YES')", "a=input()\r\nb=input()\r\nb=list(b)\r\nb.reverse()\r\nb=\"\".join(b)\r\nif a==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "Slovo=input()\r\nreversedSlovo=input()\r\nSlovo=Slovo[::-1]\r\nif Slovo==reversedSlovo:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=list(input())\r\nb=list(input())\r\na.reverse()\r\nif((\"\").join(a)==(\"\").join(b)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt =input()\r\ns = list(s)\r\nt = list(t)\r\ncount = 0\r\nif len(s)!= len(t):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(s)):\r\n if s[i]==t[len(s)-(i+1)]:\r\n count = count +1\r\n else:\r\n count = count\r\n if count == len(s):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\ncondition=True\r\nif t==s[::-1]:\r\n condition=False\r\n print('YES')\r\nif condition:\r\n print('NO')", "a=input()\r\nb=input()\r\nn=len(a)\r\nd=0\r\nif n==len(b):\r\n\tfor i in range(n):\r\n\t\tif a[i]==b[n-i-1]: d+=1\r\nif d==n: print(\"YES\") \r\nelse: print(\"NO\")", "s=input()\r\nm=input()\r\nk=s[::-1]\r\nif(m==k):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\na1 = input()\r\nif a[::-1] == a1:\r\n print('YES')\r\nelse:\r\n print('NO')", "n=input()\r\nc=input() \r\nc=list(c)\r\nc=reversed(c)\r\nx=\"\"\r\nfor i in c:\r\n x+=i\r\nif n==x:\r\n print(\"YES\") \r\nelse:\r\n print(\"NO\")", "str1 = input()\r\nstr2 = input()\r\n\r\n\r\nprint(\"YES\" if str1 == str2[::-1] else \"NO\")", "inp=input()\r\nresult=\"\"\r\nfor ch in inp:\r\n result=ch+result\r\nif result==input():\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = str(input())\r\ns2 = str(input())\r\na = []\r\nfor cur in s2:\r\n a.append(cur)\r\na.reverse()\r\nnew = \"\"\r\nfor cur in a:\r\n new+=cur\r\nif s1 == new:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "d = input()\ne = input()\nf = []\nfor i in d:\n f.append(i)\nf.reverse()\nprint(\"YES\" if \"\".join(f) == e else \"NO\")\nquit()\n \t\t\t \t\t \t \t\t\t\t\t \t \t \t", "s=str(input())\r\ns1=str(input())\r\nif s[::-1]==s1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def solve():\n x=input()\n y = input()\n if len(x) != len(y): \n print(\"NO\")\n return\n for i in range(len(x)):\n if x[i] != y[len(x)-i-1]:\n print(\"NO\")\n return\n print(\"YES\")\n return\n\n\n\n\nsolve()", "ab=input() [::-1]\r\nac=input()\r\nif ab==ac:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\ns2=input()\r\ns1=s[::-1]\r\nprint(\"YES\") if s1==s2 else print(\"NO\")\r\n\r\n", "import sys\r\ndef I(): return int(sys.stdin.readline().rstrip())\r\ndef LI(): return list(map(int, sys.stdin.readline().rstrip().split()))\r\ndef MI(): return map(int, sys.stdin.readline().rstrip().split())\r\ndef SI(): return sys.stdin.readline().rstrip()\r\n\r\n\r\ndef main():\r\n s = SI()\r\n r = SI()\r\n sr = s[::-1]\r\n if sr == r:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\nif __name__ == \"__main__\":\r\n main()", "s3=input()\ns2=input()\ns=s3[::-1]\nif(s2==s):\n print(\"YES\")\nelse:\n print(\"NO\")\n\t \t\t\t\t \t\t \t\t\t \t \t\t\t\t\t\t \t \t", "s1, s2 = input(), input()\r\n\r\n\r\ndef reversed1(variable):\r\n res = ''\r\n for i in range(len(variable) - 1, -1, -1):\r\n res += variable[i]\r\n return res\r\n\r\n\r\nn = reversed1(s1)\r\nif n == s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "ber=input()\r\nbir=input()\r\nif bir==ber[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "lst=[]\r\nt_lst=[]\r\ns = input()\r\nt = input()\r\nz = len(s)\r\n#\r\n\r\nwhile True:\r\n for i in s:\r\n lst.insert(1 - z, i)\r\n z -= 1\r\n if len(lst) == len(s):\r\n break\r\nfor i in t:\r\n t_lst.append(i)\r\nif lst == t_lst:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "n = input()\nn1 = input()\nif (n1==n[::-1]):\n print(\"YES\")\nelse:\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\n# Check if t is the reverse of s and vice versa\r\nif s == t[::-1] and t == s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=list(input())\r\nc=[]\r\nfor i in t:\r\n\tc.insert(0,i)\r\nc=\"\".join(c)\r\nif(s==c):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\r\nt=input()\r\nr=\"\"\r\nfor i in reversed(s):\r\n r=r+i\r\nif r==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "text = input()\r\nres = input()\r\nprint(\"YES\" if(list(reversed(text)) == list(res)) else \"NO\")", "w1=input()\r\nw2=input()\r\ndef tr(w1,w2):\r\n if len(w1)!=len(w2):\r\n return 'NO'\r\n for i in range(len(w1)):\r\n if w1[i]!=w2[-1-i]:\r\n return 'NO'\r\n return 'YES'\r\nprint(tr(w1,w2))", "s, t = list(input()), list(input())\r\nk = 0\r\nif len(s) == len(t):\r\n for i in range(len(s)):\r\n if s[i] == t[-(1+i)]:\r\n k += 1\r\nif k == len(s):\r\n print('YES')\r\nelse:\r\n print('NO')", "# n=int(input())\r\n# for i in range(n):\r\n# a,b= map(int, input().split())\r\nn = input()\r\n\r\ns = input()\r\n\r\ni = 0\r\nj = len(s)-1 \r\nwhile i < len(s):\r\n if n[i] != s[j]:\r\n print('NO')\r\n exit()\r\n \r\n i += 1\r\n j -= 1\r\n \r\nprint('YES')", "s=input()\r\nt=input()\r\ni=-1\r\nj=0\r\nc=0\r\nwhile(j<len(t)):\r\n if s[i]!=t[j]:\r\n c=1\r\n break\r\n j=j+1\r\n i=i-1\r\nif c==0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a,b=input(),input()[::-1]\r\nprint(\"YES\" if a==b else \"NO\")", "s=input()\r\nm=input()\r\nprint('YES' if s==m[::-1] else 'NO')", "word = input()\r\nrevword = input()\r\nfor i in range(len(word)):\r\n if word[i] != revword[-i - 1]:\r\n print(\"NO\")\r\n quit()\r\nprint(\"YES\")\r\n", "string = str(input())\r\ntransString = str(input())\r\nlststr = list(string)\r\nrevstring = \"\"\r\nfor i in range((len(lststr) - 1) , -1 , -1):\r\n revstring += lststr[i]\r\nif revstring == transString :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "T = input().lower()\r\nR = input().lower()\r\n\r\n\r\nM = T[::-1]\r\n\r\n\r\nif R == M:\r\n \r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\na = 0\r\ntry:\r\n for i in range(0,len(s)):\r\n if s[i] == t[-i - 1]:\r\n pass\r\n else:\r\n a += 1\r\nexcept:\r\n a += 1\r\n\r\nif a == 0:\r\n print('YES')\r\nelse:\r\n print('NO')", "s1=list(input())\r\ns2=list(input())\r\ns2=s2[::-1]\r\nprint(\"YES\"if s1==s2 else\"NO\")", "def rev(s):\r\n str=\"\"\r\n for i in s:\r\n str=i+str\r\n return str\r\n\r\ns1=input()\r\ns2=input()\r\ns2=rev(s2)\r\nif s1==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def main():\n s1, s2 = input(), input()\n print(\"YES\" if s1 == s2[::-1] else \"NO\")\n\nif __name__ == '__main__':\n main()", "s1=input()\r\ns2=input()\r\nl=list(s1)\r\nl.reverse()\r\ns=\"\".join(l)\r\nif s==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=str(input())\r\na=str(input())\r\nb=s[len(s)-1::-1]\r\nif(b==a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def fd70000000():\n # n_t = list(map(int, input().split()))\n s = input()\n t = input()\n if s == t[::-1]:\n return print('YES')\n else:\n return print('NO')\n \n # return print('900*1.17')\nfd70000000()\n", "# cook your dish here\r\nj=input()\r\nk=input() \r\nl=\" \"\r\nl=k[::-1]\r\nif( j == l):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input ()\r\nt = input ()\r\ni = 0\r\ntext = ''.join(reversed(s))\r\nif text == t:\r\n print ('YES')\r\nif text != t:\r\n print ('NO')\r\n", "x=str(input())\r\ny=str(input())\r\nt=x[::-1]\r\nif(t==y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s = str(input())\nss = str(input())\ni = 0\nf = True\nwhile(i < len(s)):\n\tif s[i] != ss[-i - 1]:\n\t\tprint('NO')\n\t\tf = False\n\t\tbreak\n\ti += 1\nif f:\n\tprint('YES')", "s = input()\r\nt = input()\r\n\r\narr = []\r\nfor i in range(len(t) - 1, -1 , -1):\r\n\tarr.append(t[i])\r\n\t\r\nnew_str = \"\".join(arr)\r\nif s == new_str:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n\t", "s=input()\r\nt=input()\r\nrs=[]\r\nfor i in s:\r\n rs.append(i)\r\nrs.reverse()\r\nif ''.join(rs)==t:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "w1 = input()\r\nw2 = input()\r\n\r\nw2 = w2[::-1]\r\nprint(\"YES\") if w1 == w2 else print(\"NO\")", "Sword = input()\nTword = input()\n\nlist = [Sword , Tword]\nfor i in list:\n if(len(i) <= 100):\n if i.isspace() == False:\n for char in i:\n k = char.islower() \n if k == True: \n break \n if(k != 1):\n print('NO : there is no lowercase Latin letters')\n quit()\n else :\n print('NO : there is unnecessary spaces')\n quit()\n else :\n print('NO : the lenght exceed 100 symbols')\n quit()\n\nif(Sword == Tword[::-1]):\n print('YES')\nelse :\n print('NO')\n\n", "a=input()\r\nb=input()\r\nc=len(a)\r\ne=len(b)\r\nd=0\r\nif c!=e:\r\n print(\"NO\")\r\nelse:\r\n for i in range(c):\r\n if a[i]==b[c-i-1]:\r\n d+=1\r\n if d==c:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "n =input()\r\nt =input()\r\n\r\nreverse_str = n [::-1]\r\n\r\n#print(reverse_str)\r\n\r\nif reverse_str==t:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\nc=\"\"\r\nfor i in range(len(a)):\r\n c=c+a[len(a)-i-1]\r\nif c==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\na=''\r\nfor i in range(len(s)):\r\n a+=s[-1*i-1]\r\nif a==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "x=input()\r\nz=input()\r\ny=x[::-1]\r\n\r\nif z == y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word=input()\r\nt=input()\r\nx=list(reversed(word))\r\nreverse_word=\"\"\r\nfor letter in x:\r\n reverse_word+=letter\r\nif t==reverse_word:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nx = input()\r\nt=''\r\n\r\nfor i in range(len(s)-1, -1, -1):\r\n t = t+s[i]\r\nif x==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "str1=input()\r\nstr2=input()\r\nl=str1[::-1]\r\nif(l==str2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input(\"\")\r\nb = input(\"\")\r\n\r\nc = \"\"\r\ni = len(a)\r\n\r\nwhile i > 0:\r\n c = c + a[i-1]\r\n i = i - 1\r\n \r\nif c == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def reverseString(s, t):\n if s == t[::-1]:\n return \"YES\"\n else:\n return \"NO\"\n\nif __name__ == \"__main__\":\n s = str(input())\n t = str(input())\n res = reverseString(s, t)\n print(res)\n", "texto1 = input()\r\ntexto2 = input()\r\n\r\ndef comparar(texto1,texto2):\r\n for i in range(0,len(texto1)):\r\n if texto1[0+i] != texto2[(len(texto2)-1)-i]:\r\n print(\"NO\")\r\n return\r\n print(\"YES\")\r\n\r\ncomparar(texto1,texto2)", "s = str(input())\r\ns1 = str(input())\r\nprint('YES' if s1==s[::-1] else 'NO') ", "# Read the two input words\r\ns = input().strip()\r\nt = input().strip()\r\n\r\n# Check if the reversed version of s is equal to t\r\nif s[::-1] == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "t=input()[::-1]==input()\r\nif t==False:\r\n print('NO')\r\nelse:\r\n print('YES')\r\n#print(' '.join([str(i) for i in a]))", "s = str(input())\r\nt = str(input())\r\nrev= \"\".join(reversed(s))\r\nif rev == t :\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")\r\n", "n=str(input())\r\nm=str(input())\r\na=n[::-1]\r\nif(a==m):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\nstr = input()\nstr1 = input()\n\nif str1 == str[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t \t\t \t \t \t\t\t \t \t\t", "t=input()\r\ns=input()\r\nb=''\r\nfor i in range(len(t)-1,-1,-1):\r\n b=b+t[i]\r\nif s==b:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \r\n", "s = str(input())\nt = str(input())\n\nbol = True\nif len(t) == len(s):\n for j in range(len(t)):\n if s[j] != t[len(t)-j-1]:\n bol = False\nelse:\n bol = False\n\nif bol == True:\n print('YES')\nelif bol == False:\n print('NO')\n\t\t\t \t\t \t \t\t\t\t\t \t\t \t\t\t\t\t\t\t\t", "def checkTranslation(word1, word2):\r\n if len(word1) != len(word2):\r\n return \"NO\"\r\n length = len(word1)\r\n for i in range(length):\r\n index = length - 1 - i\r\n if word1[i] != word2[index]:\r\n return \"NO\"\r\n return \"YES\"\r\n\r\n\r\nword1 = input()\r\nword2 = input()\r\nprint(checkTranslation(word1, word2))\r\n", "s = str(input())\r\nt = str(input())\r\n\r\nflag = 0\r\nif len(s) != len(t):\r\n print(\"NO\")\r\n\r\nelse:\r\n for i in range(len(s)):\r\n if t[len(s) - i - 1] != s[i]:\r\n print(\"NO\")\r\n flag = 1\r\n break\r\n if flag == 0:\r\n print(\"YES\")\r\n ", "import math\r\nimport os\r\nimport sys\r\n\r\nimport re\r\n\r\nimport itertools\r\nimport functools\r\nimport operator\r\n\r\na, b = input(), input()\r\nif a == b[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "chaine1=input()\r\nchaine2=input()\r\ni=0\r\nverif=True\r\nif len(chaine1)!=len(chaine2):\r\n print(\"NO\")\r\nelse:\r\n \r\n \r\n for i in range(len(chaine1)):\r\n if chaine1[i].upper()!=chaine2[len(chaine2)-i-1].upper():\r\n verif=False\r\n break\r\n \r\n if verif==True:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n ", "\r\ndef string():\r\n\treturn(list(input().split()))\r\n\r\n\r\ns=string()\r\nss=string()\r\nn=len(s[0])\r\nnn=len(ss[0])\r\nif n!=nn:\r\n\tprint(\"NO\")\r\n\texit()\r\nfor i in range(n):\r\n\tif s[0][i]==ss[0][n-i-1]:\r\n\t\tcontinue\r\n\telse:\r\n\t\tprint(\"NO\")\r\n\t\texit()\r\n\r\nprint(\"YES\")", "'''t = input()\r\np = []\r\nfor i in t:\r\n for h in t:\r\n if i == h:\r\n p.append(i)\r\n\r\no = 0\r\nfor i in p:\r\n t = t.replace(p[o], '')\r\n o+=1\r\nprint(t)'''\r\na = input()\r\nb = input()\r\nif a == b[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\n# Sat Oct 23 2021 16:46:00 GMT+0000 (Coordinated Universal Time)\n", "n = input()\r\nn0 = input()\r\nidl = n[::-1]\r\nif n0 == idl:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\r\n\r\ndef rev(s):\r\n\ta = \"\"\r\n\tfor i in range(1,len(s)+1):\r\n\t\ta += s[-i]\r\n\treturn a\r\n\r\n\r\n\r\ndef main():\r\n\ts = input()\r\n\tl = input()\r\n\r\n\ts = rev(s)\r\n\tif s == l:\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")\r\n\r\nmain()\r\n", "s, t = input(), input()\r\ns = ''.join(list(s)[::-1])\r\nprint(\"YES\" if s == t else \"NO\")\r\n", "n=input()\r\nn2=input()\r\nif n2==n[::-1]:print(\"YES\")\r\nelse:print(\"NO\")", "def palind(str1,str2):\r\n return str1[::-1]==str2\r\nt=palind(input(),input())\r\nif(t==True):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n ", "s=input()\nt=input()\nrs=\"\"\nfor i in range(len(s)-1,-1,-1):\n\trs+=s[i]\nif (t==rs):\n\tprint(\"YES\\n\")\nelse:\n\tprint(\"NO\\n\")\n\t\t \t \t \t \t\t \t\t\t\t \t\t \t", "l1 = input()\nl2 = input()\nif l2[::-1]==l1:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\t\t \t \t \t\t \t \t \t\t\t\t \t \t\t", "t=input()\r\ns=input()\r\nt_rev=t[::-1]\r\nif s==t_rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\ns1 = \"\"\r\n\r\nfor i in range(0, len(s)):\r\n s1 += s[len(s)-1-i]\r\n\r\nif s1 == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input()\r\ny=input()\r\nif \"\".join(list(reversed(x)))==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def execution(string):\r\n reverseString = \"\"\r\n for x in range(len(string)):\r\n indexer = len(string) - 1\r\n reverseString += string[indexer - x]\r\n return reverseString \r\n\r\ns = input()\r\nt = input()\r\nif s == execution(t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\n\ndef a_translation(word, translation):\n for i in range(len(word)):\n if word[i]!=translation[-i-1]:\n return 'NO'\n return 'YES'\n\n\nword = input()\ntranslation = input()\nprint(a_translation(word,translation))", "def main():\n a=input()\n b=input()\n if a==b[::-1]:\n print(\"YES\")\n else:\n print(\"NO\")\nif __name__ == '__main__':\n main()", "#Translation\r\ns=input()\r\nt=input()\r\nif t==s[::-1]:\r\n\tprint (\"YES\")\r\nelse: print(\"NO\")", "s=str(input())\r\np=str(input())\r\nif s==p[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a,b=list(input()),list(input())\r\nprint(\"YES\") if a==b[::-1] else print(\"NO\")\r\n", "s = list(input().lower())\r\nt = input().lower()\r\ns.reverse()\r\ns = ''.join(s)\r\n\r\nif t == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nflag = True\r\ni = 0\r\nj = len(t) - 1\r\nwhile i < len(s):\r\n if s[i] != t[j]:\r\n flag = False\r\n break\r\n i += 1\r\n j -= 1\r\nif flag:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=input()\r\nb=input()\r\nif(len(a)!=len(b)):\r\n print(\"NO\")\r\nelse:\r\n f=0\r\n for i in range(len(a)):\r\n if a[i]!=b[len(a)-i-1]:\r\n print(\"NO\")\r\n break\r\n else:\r\n f+=1\r\n if f==len(a):\r\n print(\"YES\")", "t=input()\ns=input()\nif(s==t[::-1]):\n print(\"YES\")\nelse:\n print(\"NO\") \n \t \t\t \t\t \t \t \t \t\t\t \t\t\t\t\t", "a=str(input())\r\nb=str(input())\r\nc=\"\".join(reversed(a)) \r\nif(b==c):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") \r\n\r\n", "# coding=utf-8\nx=input()\r\ny=input()\r\nx=x[::-1]\r\nif x==y:\r\n print ('YES')\r\nelse:\r\n print ('NO')\n\t\t \t \t \t \t\t \t\t\t\t\t\t\t", "s=input()\r\nss=s[::-1]\r\nt=input()\r\nif ss==t:print('YES')\r\nelse:print('NO')", "st=list(input())\r\nnd=list(input())\r\nnd.reverse()\r\nif st==nd:\r\n print('YES')\r\nelse:\r\n print('NO') ", "berlandish = input()\nbirlandish = input()\nif berlandish[::-1] == birlandish:\n print('YES')\nelse:\n print('NO')\n\t \t\t \t\t\t\t \t\t \t\t \t\t \t\t \t\t", "s = input();\r\nn = input();\r\nprint(\"YES\" if (n == s[::-1]) else \"NO\");\r\n", "s = input()\r\nt = input()\r\n\r\ns = list(s)\r\nt = list(t)\r\nt.reverse()\r\n\r\nif t == s:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\r\n\r\n", "s1=input()\r\ns2=input()\r\nans=''\r\nfor i in s1:\r\n ans=i+ans\r\nif(ans==s2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "sri=input()\r\nkim=input()\r\njk=sri[::-1]\r\nif jk==kim:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "n = input ()\r\nf = input ()\r\nl=[]\r\nfor i in range(len(n)):\r\n l.append(n[i])\r\nl.reverse()\r\nd=\"\".join(i for i in l)\r\nif d==f:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "st1 = input()\r\nst2 = input()\r\nf = True\r\nfor i in range(len(st1)):\r\n if f and st1[i] == st2[len(st2) - 1 - i]:\r\n f = True\r\n else:\r\n f = False\r\n break\r\nif f:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = input(\"\")\r\nreverse = input(\"\")\r\nword_r = ''\r\nfor i in word:\r\n word_r = i + word_r\r\nif word_r == reverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word=input(\"\")\r\nre_word=input(\"\")\r\nlist=[]\r\nfor m in word:\r\n list.append(m)\r\nlist.reverse() \r\nnew=\"\".join(list)\r\nif new ==re_word:\r\n print('YES')\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nse=list(s)\r\np=[]\r\nfor i in range(len(s)-1,-1,-1):\r\n p.append(se[i])\r\npe=\"\".join(p)\r\npe=str(pe)\r\nif (pe==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "bir=input()\r\nber=input()\r\nbur=\"\"\r\nfor musk in bir:\r\n bur=musk+bur\r\nif bur==ber:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "print((input()==input()[::-1])*\"YES\" or \"NO\")", "text1 = input()\ntext2 = input()\nlentext = len(text1)\nreversetext = \"\"\nfor x in range(lentext+1):\n reversetext = reversetext + text1[lentext-x:lentext-x+1]\nif text2 == reversetext:\n print(\"YES\")\nelse:\n print(\"NO\")\nquit()\n \t \t\t \t \t\t \t \t \t \t\t", "og = list(input())\r\ncp = list(input())\r\nif og[::-1] == cp:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t = str(input())\r\ns = str(input())\r\nif s == t[::-1]:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")\r\n\r\n", "# input the two strings\r\ns = str(input())\r\nt = str(input())\r\n# check if we reversed one and they are equal print YES\r\nif t==s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word_line1 = input()\r\nword_line2 = input()\r\nc=0\r\n\r\nfor i in range(0,len(word_line1)):\r\n if word_line1[i] == word_line2[len(word_line2)-i-1]:\r\n c+=1\r\n \r\nif c== len(word_line1):\r\n print('YES')\r\nelse:\r\n print('NO') ", "n=input()\nif input()[::-1]==n: print(\"YES\")\nelse: print(\"NO\")\n \t \t\t\t \t\t\t \t\t \t \t\t\t \t \t", "def solve(str_one,str_two):\n str_two_reversed = \"\"\n for i in range(len(str_two)-1,-1,-1):\n str_two_reversed += str_two[i]\n \n if str_two_reversed == str_one:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\n\nsolve(input(),input())", "x=input()\ny=input()\nz=x[::-1]\nif(z==y):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n \t\t\t\t\t \t \t \t\t \t \t \t\t", "k=list(input())\r\nl=list(input())\r\nk.reverse()\r\nif k==l:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=str(input())\r\na=\" \".join(a)\r\na=a.split()\r\nc=[\"*\"]*len(a)\r\nb=str(input())\r\nd=len(a)\r\nfor k in range (d):\r\n d=d-1\r\n c[k]=a[d]\r\nf=str(\"\".join(c))\r\nif b==f:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nif len(s) != len(t):\r\n print(\"NO\")\r\nelse:\r\n flag = 0 \r\n for i in range(len(s)):\r\n if (s[i]!=t[len(s)-i-1]):\r\n print(\"NO\")\r\n flag = 1\r\n break\r\n if flag == 0:\r\n print(\"YES\")", "w1=input()\r\nw2=input()\r\nif w2 == w1[::-1]:\r\n print('YES')\r\nelse:\r\n print(\"NO\")\r\n", "s1 = str(input())\ns2 = str(input())\nif s2==s1[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "st=input()\r\nf=input()\r\ns=f[::-1]\r\nif s==st:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\nif t == s[::-1]:print(\"YES\")\r\nelse:print(\"NO\")", "a=input()\r\nb=input()\r\ns=list(b)\r\nt=list(a)\r\ns.reverse()\r\nflag=0\r\nif s==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=str(input())\r\nk=str(input())\r\nd=k[::-1]\r\nif d==n:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "jamaya=\"elpepe\"\npalabra1=input()\npalabra2=input()[::-1]\nlista1=[]\nlista2=[]\nlista1.append(palabra1)\nlista2.append(palabra2)\nif lista1 == lista2:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t \t \t \t \t\t \t\t \t \t \t", "s=input()\nt=input()\nn=len(s)\nm=len(t)\n\n\n\n\nif m==n :\n ch='p'\n for i in range(n):\n if s[i] != t[n-1-i] :\n ch='n'\n break\n\n print(\"YES\") if ch=='p' else print(\"NO\") \n\nelse :\n print(\"NO\")\n", "string = input()\r\nstring_ = input()\r\nif(string_==string[::-1]):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "import sys\r\nimport math\r\nfrom functools import cmp_to_key\r\nfrom collections import defaultdict\r\ninput = sys.stdin.readline\r\n\r\ns = input().strip()\r\nr = input().strip()\r\nprint(\"YES\" if s[::-1] == r else \"NO\")", "word1 = input()\r\nword2 = input()\r\ni = 0\r\nj = -1\r\nwhile(i < len(word1)):\r\n equal = True\r\n if(word1[i] == word2[j]):\r\n i += 1\r\n j -= 1\r\n else:\r\n equal = False\r\n break\r\nif equal:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nx=s[::-1]\r\nif t==x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "c=input()\r\nt=input()\r\nfor i in range(len(c)-1,-1,-1):\r\n if i==len(c)-1:\r\n f=c[i]\r\n else:\r\n f=f+c[i]\r\nif t==f:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n ", "a = input()\r\nb = input()\r\nprint([\"NO\", \"YES\"][a == b[::-1]])\r\n\r\n", "a = list(input())\r\nb = []\r\nfor i in a[::-1]:\r\n b.append(i)\r\ne = input()\r\nd = ''\r\nfor i in b:\r\n d = d + i\r\nprint(\"YES\") if d == e else print(\"NO\")", "firstword = input()\r\nsecondword = input()\r\nif firstword[::-1] == secondword:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\ns1=t[::-1]\r\nif s==s1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO \")", "g=input()\r\nh=input()\r\nif g==h[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = [letter for letter in str(input())]\nt = str(input())\ns.reverse()\ns2 = ''.join(s)\n\nif s2 == t:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s = input()\r\nt = input()\r\nflag = True\r\n\r\nif len(s)==len(t):\r\n i = 0\r\n while i<len(s):\r\n if s[i]!=t[len(s)-i-1]:\r\n flag = False\r\n i += 1\r\nelse:\r\n flag = False\r\n\r\nprint(\"YNEOS\"[not flag::2])", "import sys\ndef get_string(): return sys.stdin.readline().strip()\ndef get_ints(): return list(map(int, sys.stdin.readline().strip().split()))\n\na = get_string()\nb = get_string()\nif a == b[-1::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "s=input()\r\nd=input()\r\nl1=[]\r\nl2=[]\r\na=len(s)\r\nb=len(d)\r\ni=0\r\nflag=0\r\nwhile(a):\r\n l1.append(s[a-1])\r\n a=a-1\r\nwhile(b):\r\n l2.append(d[i])\r\n i=i+1\r\n b=b-1\r\nfor j in range(len(s)):\r\n if(l1[j]!=l2[j]):\r\n flag=1\r\n break\r\nif(flag==0):\r\n print(\"YES\")\r\nelse:\r\n print('NO')", "i=input;print('NYOE S'[''.join(list(reversed(i())))==i()::2])", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Wed Aug 4 14:26:39 2021\r\n\r\n@author: nijhum\r\n\"\"\"\r\n\r\ns=str(input())\r\nt=str(input())\r\nm=s[::-1]\r\nif t==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n##doing it manually\r\n# d=-1\r\n# c=0\r\n# e=len(s)\r\n# for i in range(e):\r\n# if s[i]==t[d]:\r\n# c+=1\r\n# d=d-1\r\n# if d<-e:\r\n# break\r\n# if c==e:\r\n# print('YES')\r\n# else:\r\n# print(\"NO\")", "s = input()\nt = input()\ny= ''\nfor i in range(len(s)-1,-1,-1):\n y += s[i]\nif y == t:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s = input()\nt = input()\naux = \"\"\nfor i in range(len(s)):\n aux += s[len(s) - 1 - i]\nif aux == t:\n print(\"YES\")\nelse:\n print(\"NO\")", "\r\na = input()\r\nb = input()\r\n\r\nres=True\r\nfor i in range(0, len(a)):\r\n if a[i]!=b[len(b)-i-1]:\r\n print(\"NO\")\r\n res=False\r\n break\r\n \r\nif res:\r\n print(\"YES\")", "txt_1 = input()\r\ntxt_2 = input()\r\ndef rev(x):\r\n return x [::-1]\r\nif txt_1 == rev(txt_2):\r\n print(\"YES\")\r\nelse:\r\n print('NO')", "##n = input()\r\n##summ = n.count(\"l\")\r\n##word = ['h','e','l','o']\r\n##a = 0\r\n##for i in range(len(n)):\r\n## for j in range(len(word)):\r\n## if(len(n) == 5) :\r\n## if(n[i] == word[j]):\r\n## a = 0\r\n## else:\r\n## if(summ > 1):\r\n## if(n[i] == word[j]):\r\n## a += 1\r\n## else:\r\n## a = 0\r\n##if(a >= 1):\r\n## print(\"YES\")\r\n##elif(a == 0):\r\n## print(\"NO\")\r\n\r\nn = input()\r\nm = input()\r\na = 0\r\nif(len(n) == len(m)):\r\n for i in range(len(n)):\r\n if(n[i] == m[-1-i]):\r\n a += 1\r\nif(a == len(n)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n\r\n", "word = input()\nrword = input()\nif word == rword[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "a = input()\r\n\r\nb = input()\r\n\r\nc = 0\r\n\r\nif len(a) != len(b):\r\n print('NO')\r\nelse:\r\n for i in range(1, len(a)+1):\r\n if a[i-1] == b[-i]:\r\n c += 1\r\n if c == len(a):\r\n print('YES')\r\n else:\r\n print('NO')", "sai = input()\r\ntan = input()\r\nif sai == tan[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a = input()[::-1]\nb = input()\nif a==b:\n print('YES')\nelse:\n print('NO')\n \n \n \n\n\n\n", "t1=input()\nt2=input()\nif t1[::-1]==t2 or t2[::-1]==t1:\n\tprint('YES')\nelse:\n\tprint('NO')", "t=input()\ns=input()\nx=t[::-1]\n#print(x)\nif s==x:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "import sys\r\n\r\nline1 = str(sys.stdin.readline())\r\nline2 = str(sys.stdin.readline())\r\nlista = []\r\nlista2 = []\r\nfor i in line1:\r\n if i != '\\n':\r\n lista.append(i)\r\nlista.reverse()\r\nfor j in line2:\r\n if j != '\\n':\r\n lista2.append(j)\r\n\r\nif lista == lista2:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")\r\n\r\n", "\r\n# Taking input for the first line\r\n# Taking input for the first line\r\nline1 = map(str, input().split())\r\n\r\n# Taking input for the second line\r\nline2 = map(str, input().split())\r\n\r\n# Converting the map objects to lists\r\nline1_list = list(line1)\r\nline2_list = list(line2)\r\na = str(line2_list[0])\r\nif a[::-1] == line1_list[0]:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n\r\n# x=-1\r\n# list_word = []\r\n# for i in line2_list[0]:\r\n# real = (line2_list[0][x])\r\n# list_word[0].append(real)\r\n# x-=1\r\n# print(real)\r\n# v = int(len(list_word)-1)\r\n# print(list_word)\r\n", "import io\r\nimport os\r\n#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n\r\ns = input(); t = input()\r\nprint('YES') if s == t[::-1] else print('NO')\r\n", "import string\r\ndef translate(fworld,sworld):\r\n rstring=fworld[len(fworld)-1::-1]\r\n if rstring==sworld:\r\n print('YES')\r\n else:\r\n print('NO')\r\nfworld=str(input())\r\nsworld=str(input())\r\ntranslate(fworld,sworld)", "s = str(input())\nt = str(input())\nprint('YES' if s[::-1] == t else 'NO')\n\t \t\t\t \t\t\t\t\t \t\t\t \t \t \t\t", "s=input()\r\nt=input()\r\nans=\"\"\r\nfor i in s:\r\n ans=i+ans\r\nif(t==ans):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = [str(i) for i in input()]\r\nb = [str(j) for j in input()]\r\nif a == b[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input()\r\nc=input()\r\nc=c[::-1]\r\nif x==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = str(input())\r\nb = str(input())\r\nc =a[::-1]\r\nif (c==b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "berlandish = input()\r\nbirlandish = input()\r\n\r\nif birlandish == berlandish[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\n\r\ns_list = list(s)\r\nt_list = list(t)\r\n\r\nval = False\r\n\r\nif len(s_list) == len(t_list):\r\n for i in range(0, len(s)):\r\n if s_list[i] == t_list[len(t_list) - (i+1)]:\r\n val = True\r\n else:\r\n val = False\r\n break\r\n\r\n\r\nelse:\r\n val = False\r\n\r\nif val == True:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n", "t = input()\r\nl = input()\r\n\r\ns = str()\r\n\r\nfor i in range(1,len(l)+1):\r\n s += l[i-i*2]\r\n\r\nif t == s:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "n=str(input())\r\nd=str(input())\r\nn=n[::-1]\r\nif n==d:\r\n print('YES')\r\nelse:\r\n print('NO')", "a = input()\r\nd = input()\r\n\r\nc = list(reversed(a))\r\ng = \"\"\r\nfor i in c:\r\n g+=i\r\nif d == g:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "w1 = input()\r\nw2 = input()\r\n\r\nif len(w1) != len(w2):\r\n print(\"NO\")\r\nelse:\r\n status = True\r\n for i in range(len(w1)):\r\n if w1[i] != w2[len(w2)-1-i]:\r\n status = False\r\n break\r\n \r\n if status == True:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n \r\n \r\n\r\n ", "x= input(\"\").lower()\r\ny=input(\"\").lower()\r\nz= x[ : : -1]\r\nif z == y:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "#!/usr/bin/python3\n\nprint('YES' if input() == ''.join(reversed(list(input()))) else 'NO')\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Sep 11 20:58:45 2023\r\n\r\n@author: Zinc\r\n\"\"\"\r\n\r\na=input()\r\nb=input()\r\nre_a=a[::-1]\r\nif re_a==b: \r\n print('YES')\r\nelse: \r\n print('NO')", "p=input().lower()\r\nt=input().lower()\r\ntemp=\"\"\r\nc=len(t)\r\nfor i in range(c):\r\n temp+=t[c-1-i]\r\nif(temp==p):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nk=s[::-1]\r\nif t==k:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\nn = str()\r\nfor i in range(len(s)):\r\n n += s[-(i + 1)]\r\nif t == n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str=input()\r\nstr1=input()\r\nk=str[::-1]\r\nif(k==str1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\na = ''\r\nfor i in range(1,len(s)+1):\r\n a+=s[-i]\r\n \r\n\r\nif t == a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=input()\nt1=input()\nif t1==s1[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n#sskskfkshfkshskskskskhshsksdftdt\n\n \t \t\t \t\t \t\t\t \t\t\t \t\t\t \t", "m = input()\r\nn = input()\r\nif len(m) != len(n):\r\n print('NO')\r\nelse:\r\n if m[::-1] == n:\r\n print('YES')\r\n else:\r\n print('NO')", "s=str(input())\r\nr=str(input())\r\nt=s[len(s)::-1]\r\nif r==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a, b=input(), input()\r\nif len(a)!=len(b):\r\n print(\"NO\")\r\nelse:\r\n i, j=0, len(a)-1\r\n while i<len(a):\r\n if a[i]!=b[j]:\r\n print('NO')\r\n quit()\r\n i+=1\r\n j-=1\r\n print(\"YES\")", "z=input()\r\np=input()\r\nk=z[::-1]\r\nif(k==p):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str=list(input())\r\nm=list(input())\r\ns=str[::-1]\r\nif s==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\ns1=s.lower()\r\ns2=\"\"\r\nfor i in s1:\r\n s2=i+s2\r\nif s2==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def main():\r\n PL = list(input());\r\n RL = list(input());\r\n RL.reverse();\r\n if (PL == RL): print(\"YES\")\r\n else: print(\"NO\")\r\n \r\nmain()\r\n", "s = input()\r\nt = input()\r\n\r\nflag = True\r\nfor i in range(len(s)):\r\n if s[i] != t[-1-i]:\r\n flag = False\r\n break\r\n\r\n# print('YES' if flag else 'NO')\r\nprint('YES' if flag == True else 'NO') ", "s = input()\r\nl = input()\r\nif len(s) != len(l):\r\n print(\"NO\")\r\nelse:\r\n for r in range(len(s)):\r\n if s[r] != l[len(s) - r - 1]:\r\n print(\"NO\")\r\n quit()\r\n print(\"YES\")\r\n", "a = input(\"\")\r\nb = input(\"\")\r\nrever1 = a[::-1]\r\nrever2 = b[::1]\r\nif rever1 == rever2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\nb = input()\nif(len(a)!=len(b)):\n print(\"NO\")\nelse:\n n =len(a)\n for i in range(len(a)):\n if(a[i]!=b[n-i-1]):\n print(\"NO\")\n exit()\n print(\"YES\")\n", "slv = input()\r\nslvr = input()\r\nif slv[::-1] == slvr:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "t1=input()\nt2=input()\nif t1[::-1]==t2:\n print('YES')\nelse:\n print(\"NO\")\n", "s = input()\r\nt = input()\r\na = t[-1:0:-1] + t[0]\r\nif s == a:\r\n print('YES')\r\nelse:\r\n print('NO')", "# https://codeforces.com/problemset/problem/41/A\n\n\nS = input()\nR = input()\n\nif ''.join(R[::-1]) == S:\n print('YES')\nelse:\n print('NO')\n", "def is_reverse_word(s, t):\r\n if len(s) != len(t):\r\n return \"NO\"\r\n\r\n return \"YES\" if s == t[::-1] else \"NO\"\r\n\r\n# Read the input\r\ns = input().strip()\r\nt = input().strip()\r\n\r\n# Check if t is the reverse of s\r\nresult = is_reverse_word(s, t)\r\n\r\n# Print the result\r\nprint(result)\r\n", "s :str = input()\r\nt :str = input()\r\n\r\n\r\n\r\ndef solve(s , t) :\r\n s = list(s)\r\n t = list(t)\r\n s.reverse()\r\n return \"YES\" if s == t else \"NO\"\r\n\r\nprint(solve(s, t ))\r\n", "a = input()\r\nb = input()\r\nc = b[::-1]\r\ncout = int(0)\r\nif len(a)!=len(b):\r\n print(\"NO\")\r\nelse:\r\n for i in range(0, len(a)):\r\n if ord(a[i])==ord(c[i]):\r\n cout+=1\r\n if cout==len(a):\r\n print(\"YES\")\r\n else:print(\"NO\")", "first = input()\r\nsecond = input()\r\nis_true = True\r\nif len(first) == len(second):\r\n for i in range(len(first)):\r\n if first[i] != second[0-i-1]:\r\n is_true = False\r\n break\r\nelse:\r\n is_true = False\r\nif is_true:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s1 = input()\ns2 = input()\ns2_r = \"\"\nfor i in reversed(range(len(s2))):\n s2_r = s2_r + s2[i]\nif s1 == s2_r:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t\t \t \t\t \t\t \t\t \t\t\t\t \t\t\t", "s = input()\r\nt = input()\r\na = t[::-1]\r\nif a == s:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()[::-1]\r\nl = input()\r\nif s==l:print(\"YES\")\r\nelse: print(\"NO\")", "word = input()\r\nwordR = input()\r\nif(wordR[::-1]==word):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Sep 28 13:15:53 2020\r\n\r\n@author: PREET MODH\r\n\"\"\"\r\n\r\n\r\ns=list(input())\r\nt=list(input())\r\nt.reverse()\r\nif t==s:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = [x for x in input()]\r\nt = input()\r\nnew = \"\".join(s[::-1])\r\n\r\nif t == new:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input\r\nprint(\"YNEOS\"[a()!=a()[::-1]::2])", "x=str(input(\"\"))\r\ny=str(input(\"\"))\r\ny=list(y)\r\ny.reverse()\r\nr=\"\".join(y)\r\n\r\nif(x==r):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#41A\r\nword = input()\r\nreverse = input()\r\nif reverse == word[::-1] :\r\n print('YES')\r\nelse :\r\n print('NO')", "# benzene_ <>\r\n\r\na=input()\r\nb=list(input())\r\nb=b[::-1]\r\nc=''.join(b)\r\n\r\nif a==c:\r\n print(\"YES\")\r\n \r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 28 21:11:47 2020\n\n@author: Rahul Kumar\n\"\"\"\n\n\n\ndef check_str(s, t, length):\n j = length-1\n for i in range(0, length):\n if t[i] == s[j]:\n j -= 1\n else:\n return \"NO\"\n return \"YES\"\n\nif __name__ == \"__main__\":\n s = list(input())\n t = list(input())\n\n if len(s) != len(t):\n print(\"NO\")\n else:\n print(check_str(s, t, len(s)))", "import re\r\ntxt = input()\r\nans=input()\r\nst = txt[::-1]\r\nif(st==ans):\r\n print('YES')\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n\r\n", "inp1 = str(input())\r\ninp2 = str(input())\r\nif inp2 == inp1[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\ns2 = input()\r\nif(s2[::-1]==s):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = list(input())\nr = list(input())\n\nif s[::-1]==r:\n\tprint('YES')\nelse:\n\tprint('NO')", "a,b=input(),input()\r\nprint('YES') if (a == b[::-1]) else print('NO')\r\n", "Berland=input()\nBirland=input()\nif Birland==Berland[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n\t \t \t\t \t\t \t \t\t \t \t\t \t\t", "s = str(input())\r\nt = str(input())\r\nrev = ''.join(reversed(t))\r\nif len(s) or len(t)<=100:\r\n if rev == s:\r\n print(\"YES\")\r\n else: print(\"NO\")\r\n \r\nelse:\r\n print(\"ERROR\")", "a = input()\r\nb = input()\r\n\r\nreverse = True\r\n\r\nfor i in range(len(a)):\r\n if not a[i] == b[-(i+1)]:\r\n reverse = False\r\n break\r\n\r\nif reverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "t = input()\ns = input()\n\n\noutput = \"YES\"\n\nt_len = len(t)\ns_len = len(s)\n\nif t_len == s_len:\n for i in range(t_len):\n j = t_len - 1 - i\n\n if t[i] != s[j]:\n output = \"NO\"\n break\nelse:\n output = \"NO\"\n\nprint(output)", "x1=input()\r\nx2=input()\r\n\r\nxx = x1[::-1]\r\n\r\nif(xx==x2):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "a=input()\r\nb=input()\r\ns=0\r\nif len(a)==len(b):\r\n for i in range(len(a)):\r\n if a[i]==b[-1-i]:\r\n s=s+1\r\nif len(a)!=len(b):\r\n print(\"NO\")\r\nelif s==len(a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word = input()\r\nrev_word = word[::-1]\r\nword_2 = input()\r\n\r\nif (word_2 == rev_word):\r\n print(\"YES\") \r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n ", "str1 = str(input())\r\nstr2 = str(input())\r\n\r\nsize = int(str1.__len__())\r\nsize1 = int(str2.__len__())\r\n\r\n\r\nif size == size1:\r\n for x in range(size):\r\n if str1[x] == str2[size1 - 1]:\r\n size1 -= 1\r\n flag = 1\r\n pass\r\n else:\r\n flag = 0\r\n break\r\n if flag == 1:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\nelse:\r\n print(\"NO\")", "s = input()\r\ns1 = input()\r\nprint(\"YES\" if s1 == s[::-1] else \"NO\")\r\n", "input1=list(input())\r\ninput2=list(input())\r\ninput2.reverse()\r\nprint(\"YES\"if(input2==input1)else\"NO\")", "s = input()\r\nt = input()\r\nans = \"YES\"\r\nif (len(t) != len(s)):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(s)):\r\n if (s[i] != t[len(t)-1-i]):\r\n ans = \"NO\"\r\n print(ans)\r\n", "def reverse(str): \r\n str = str[::-1] \r\n return str\r\nk=input()\r\nka=input()\r\nkaka=reverse(k)\r\nif ka==kaka:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')\r\n", "# http://codeforces.com/problemset/problem/41/A\n\n\ns1 = input()\ns2 = input()\n\ns = ''\n\nfor i in range(len(s1)):\n s += s1[-(i+1)]\n\nif s == s2:\n print(\"YES\")\nelse:\n print(\"NO\")", "a = input()\r\nb = input()\r\ntxt = a[::-1]\r\nif b != txt:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "\r\ns1=input()\r\ns2=input()\r\nk=len(s1)\r\nl=0\r\nfor i in range(k):\r\n if len(s1)!= len(s2):\r\n print('NO')\r\n break\r\n if s1[i]==s2[k-1-i]:\r\n l=l+1\r\n if l==(k):\r\n print('YES')\r\n break\r\n else:\r\n print('NO')\r\n break\r\n", "word = input()\r\ndrow = input()\r\nbackwards = ''.join(i for i in reversed(word))\r\nif backwards == drow:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\nrev_a = a[::-1]\r\nrev_b = b[::-1]\r\nif rev_b==a and rev_a==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word1 = input()\r\nword2 = input()\r\n\r\nprint(\"YES\") if word1 == word2[::-1] else print(\"NO\")", "w1=input()\r\nw2=input()\r\nif w1[::-1]==w2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\ns2 = s[::-1]\r\ns1 = input()\r\nif(s2==s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "x = list(input())\r\ny = input()\r\nx = x[::-1]\r\nx = \"\".join(x)\r\nif x==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=str(input())\r\ns1=str(input())\r\ns2=s[::-1]\r\nif s1==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "true_word=list(input())\r\nword=list(input())\r\nm=true_word.reverse()\r\nif word==true_word:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "from math import*\r\ns1=input()\r\ns2=input()\r\nif s1==s2[len(s2)-1::-1]:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s = str(input())\r\na = str(input())\r\nb = len(s)\r\nif a == s[b::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "d = input()\r\nr = input()\r\nif r == d[::-1]:\r\n print ('YES')\r\nelse:\r\n print ('NO')\r\n", "s=input()\r\nt=input()\r\nlist1=list(s)\r\nlist1.reverse()\r\nu=\"\"\r\nfor ele in list1:\r\n\tu+=ele\r\nif t==u:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\nprint(['NO', 'YES'][all(a[i] == b[min(len(a), len(b)) - 1 - i] for i in range(min(len(a), len(b))))])", "n=input().lower()\r\nt=input().lower()\r\nif(n==t[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def tl(w, x):\r\n if w[::-1] != x:\r\n return 'NO'\r\n else:\r\n return 'YES'\r\n\r\n\r\na = input()\r\nb = input()\r\nprint(tl(a, b))", "s1 = input()\r\nlist1 = []\r\nfor char in s1:\r\n list1.append(char)\r\ns2 = input()\r\nlist2 = []\r\nfor char in s2:\r\n list2.append(char)\r\nlist2.reverse()\r\nif list1 == list2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word = input(\"\")\r\nword2 = input(\"\")\r\narray = []\r\n\r\nfor i in word:\r\n array.append(i)\r\n\r\narray.reverse()\r\nstring = \"\".join(array)\r\n\r\nif word2 == string:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")\r\n", "t=input()\r\nn=input()\r\na=\"\".join(list(n)[::-1])\r\nif a==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t=input()\r\ns=input()\r\nprint(\"YES\" if t in s[::-1] else \"NO\")", "n=input()\r\nm=input()\r\nx=n[::-1]\r\nif m==x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = input()\r\ndrow = input()\r\nprint('YES' if word[::-1] == drow else 'NO')\r\n", "values = []\r\nfor i in range(2):\r\n inp = input()\r\n values.append(inp)\r\ns = values[0]\r\nt = values[1]\r\nif s == t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nd=input()\r\nc=0\r\nfor i in range(1,len(s)+1):\r\n if(s[i-1]==d[-i]):\r\n c+=1\r\n else:\r\n break\r\nif(c==len(s)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Thu Sep 29 16:06:41 2022\r\n\r\n@author: 86158\r\n\"\"\"\r\nlist1 = list(input())\r\nlist2 = list(input())\r\nlist1.reverse()\r\nif list2 == list1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# author : Leandro\r\n# problem : https://codeforces.com/problemset/problem/41/A\r\n# platform : Codeforces\r\n# date : 2021-05-21\r\n\r\na = input()\r\nb = input()\r\n\r\nprint('YES' if a == b[::-1] else 'NO')\r\n", "s=input()\r\nsr=input()\r\nsrr=''.join(reversed(sr))\r\nif(s==srr):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "string1 = input()\r\nstring2 = input()\r\nif(string2 == string1[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "ber=input()\r\nbir=input()\r\n\r\nif ber[::-1]==bir:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\r\ns_rev=input()\r\nif(s[::-1]==s_rev):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "### s = [int(x) for x in input().split(\" \")]\r\n\r\na = input()\r\nb = input()\r\n\r\nif a[::-1] == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nso = \"\"\r\nfor i in s:\r\n\tso = i+so\r\nif(so == t):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "lang = list(input())\r\nlang.reverse()\r\nlang = ''.join(lang)\r\na_lang = input()\r\nif a_lang == lang:\r\n print('YES')\r\nelse:\r\n print('NO')", "t = input()\r\ns = input()\r\nr = \"YES\" if s == t[::-1] else \"NO\"\r\nprint(r)", "arr1=list(map(str,input()))\r\narr2=list(map(str,input()))\r\narr1.reverse()\r\nif arr1 == arr2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nn=input()\r\nl1=list(a)\r\nl2=list(n)\r\nl2.reverse()\r\nif l1 == l2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "first=input()\r\nsecond=input()\r\nf=0\r\nif len(first) == len(second):\r\n for i in range(len(first)):\r\n if first[i]==second[-i-1]:\r\n f+=1\r\n else:\r\n f=0\r\n if f==len(first):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")", "string = input()\r\nreversed_string = input()\r\n\r\nif reversed_string == string[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "t = input()\r\ns = input()\r\ns = s[::-1]\r\nif(t == s):\r\n\tprint (\"YES\")\r\nelse:\r\n\tprint (\"NO\")", "n=input()\r\np=input()\r\nq=n[::-1]\r\nif p==q:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = list(input())\nt = list(input())\n\ndef reverse_inplace(list):\n for i in range(len(list)//2):\n j = -i -1\n list[i], list[j] = list[j], list[i]\n return list\n\nt = reverse_inplace(t)\n\nif t == s:\n print('YES')\nelse:\n print('NO')", "# coding=utf-8 \r\n# Created by TheMisfits \r\nfrom sys import stdin\r\n_input = stdin.readline\r\n_int, _str = int, str\r\ndef solution():\r\n s = _input().rstrip('\\n')\r\n s_2 = _input().rstrip('\\n')[::-1]\r\n if s == s_2:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nsolution()", "def solve():\r\n s = input()\r\n t = input()\r\n m = len(s)\r\n n = len(t)\r\n\r\n if m != n:\r\n print(\"NO\")\r\n return\r\n\r\n for i in range(m):\r\n if s[i] != t[m-i-1]:\r\n print(\"NO\")\r\n break\r\n else:\r\n print(\"YES\")\r\n\r\n\r\nT = 1\r\nfor _ in range(T):\r\n solve()\r\n", "s = input ()\r\nt = input ()\r\n\r\nn1 = len (s)\r\nn2 = len (t)\r\n\r\nflag = True\r\n\r\nif (n1 == n2) :\r\n j = n2 - 1\r\n for i in range (n1) :\r\n c1 = s[i]\r\n c2 = t[j]\r\n j = j - 1\r\n\r\n if (c1 != c2) :\r\n print (\"NO\")\r\n flag = False\r\n break\r\nelse :\r\n print (\"NO\")\r\n flag = False\r\n\r\nif (flag) :\r\n print (\"YES\")\r\n", "thing = input(\"\")\r\nreverse = input(\"\")\r\nif reverse == thing[::-1]: \r\n print(\"YES\")\r\nelse: print(\"NO\")", "s=input()\nt=input()\np=s[::-1]\nif(p==t):\n print('YES')\nelse:\n print('NO')\n \n \n \t \t \t\t\t\t \t \t \t\t \t\t \t", "string=input()\r\nrev_string=input()\r\nstring=string[::-1]\r\nif string==rev_string:\r\n print('YES')\r\nelse:\r\n print('NO')", "right = input()\r\nleft = input()\r\nl = False\r\nfor i in range(len(right)):\r\n if right[i] == left[-i-1]:\r\n l = True\r\n else:\r\n l = False\r\n break\r\nif l == True:\r\n print('YES')\r\nelse:\r\n print('NO')", "def translation(w, r):\n pal = \"\"\n for i in range(len(w)-1,-1,-1):\n pal += w[i]\n if pal == r: print('YES')\n else: print('NO')\n\ndef main():\n w = input()\n r = input()\n translation(w, r)\nmain()\n", "s = str(input())\r\nt = str(input())\r\nrev = ''.join(reversed(s))\r\nif rev == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nr=input()\r\nt=r[::-1]\r\nif len(s)== len(r):\r\n if(s.find(t)==-1):\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n \r\nelse:\r\n print(\"NO\")\r\n", "n=input()\r\nm=input()\r\nif n==\"\".join(reversed(m)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s= input()\r\nt= input()\r\nif t[::-1] == s:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")", "s=input();f=input();print('YES' if s==f[::-1] else 'NO')", "s = input()\r\nl = input()\r\n\r\ni,j = 0, len(l)-1\r\nflag = True\r\nwhile i<len(s) and j>=0:\r\n if s[i] != l[j]:\r\n flag = False\r\n break\r\n else:\r\n i+=1\r\n j-=1\r\n\r\nif flag == True:\r\n print('YES')\r\nelse:\r\n print('NO ') ", "word=input()\r\ntranslated=input()\r\nlenght=len(translated)\r\nreverse=str()\r\n\r\nfor i in range(lenght-1,-1,-1):\r\n reverse=reverse+translated[i]\r\n\r\nif reverse==word:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=list(input())\r\nt=list(input())\r\ns.reverse()\r\nprint([\"NO\",\"YES\"][t==s])\r\n", "s=input()\r\nt=input()\r\nif t==s[::-1]:print(\"YES\")\r\nelse:print(\"NO\")", "S=input()\r\nS1=input()\r\nS1=S1[::-1]\r\nif S==S1:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = str(input())\nb = str(input())\nt = n[::-1]\nif b == t:\n print('YES')\nelse:\n print('NO')\n \n\n ", "s = input()\r\nst = ''\r\nfor x in range(len(s)):\r\n st = s[x] +st\r\n\r\nt = input()\r\n\r\nif t == st:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=input()\r\nrev=input()\r\nif a[::-1]==rev:\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "wrd1 = input()\r\nwrd2 = input()\r\nif wrd1[::-1]==wrd2:\r\n print('YES')\r\nelse:\r\n print('NO')", "mystr = input()\r\nop = \"\"\r\nmystr2 = input()\r\nfor i in mystr:\r\n op = i+op\r\nif(mystr2==op):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "f = [i for i in input()]\r\ns = [i for i in input()]\r\ns.reverse()\r\nprint(\"YES\") if \"\".join(f) == \"\".join(s) else print(\"NO\")", "m=input()\r\nn=input()\r\nflag=0\r\nfor i in range (len(m)) :\r\n if(m[i]!=n[-(i+1)]):\r\n flag=1\r\n break\r\nif(flag==1):\r\n print(\"NO\")\r\nelse :\r\n print(\"YES\")\r\n", "s = input()\r\nb = input()\r\na = s[-1::-1]\r\nif(b==a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nrs = input()\r\nif s == rs[-1::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "m=input()\r\nn=input()\r\nk=n[::-1]\r\nif m==k:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\nv=input()\r\nif n==v[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "ch=input()\r\nch1=input()\r\nif ch[::-1]==ch1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1=input()\r\nstr2=input()\r\n\r\nif (str1[::]==str2[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "def answer():\r\n s=list(input())\r\n t=list(input())\r\n if len(s)!=len(t): return \"NO\"\r\n i=0\r\n t.reverse()\r\n while i<len(s):\r\n \r\n if s[i]!=t[i]: return \"NO\"\r\n i+=1\r\n return \"YES\"\r\nprint(answer())", "x,y=input(),input()\r\ny=y[::-1]\r\nif y==x:print(\"YES\")\r\nelse:print(\"NO\")", "s=input()\r\ns_rev=input()\r\nif s_rev[::-1]==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x = input()\r\ny = input()\r\na= len(x)\r\nxr=\"\"\r\n\r\nwhile a>0:\r\n xr+=x[a-1]\r\n a-=1\r\n\r\nif xr == y:\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n \r\n ", "s=input()\r\nt=input()\r\nl=len(s)\r\np=\"\"\r\nfor i in range(1,len(s)+1):\r\n p+=s[l-i]\r\n if p==t:\r\n k=\"YES\"\r\n else:\r\n k=\"NO\"\r\nprint(k)", "s1 = input()\r\ns2 = input()\r\n\r\nprint(\"YES\" if s1 == s2[::-1] else \"NO\")", "s=input()\nt= input()\ndef reverse(n):\n if len(n) == 1:\n return n\n else:\n return reverse(n[1:])+n[0]\nif t == reverse(s):\n print('YES')\nelse:\n print('NO')\n\t\t \t\t \t\t \t\t\t \t \t\t \t", "s = input()\ns1 = input()\nif s[::-1] == s1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "words = [input().replace(' ' , ''),input().replace(' ' , '')]\r\nif (words[0][::-1] == words[1]): print(\"YES\")\r\nelse: print(\"NO\")", "\r\nimport sys\r\n\r\nnative_input = input\r\ninput = lambda: sys.stdin.readline().strip()\r\n\r\n\r\n\r\n\r\n\r\n\r\ndef solve():\r\n a = input()\r\n b = input()\r\n\r\n print('YES' if a == b[::-1] else 'NO')\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nsolve()", "from bisect import bisect, bisect_left\r\nfrom cgitb import small\r\nfrom collections import deque\r\nfrom io import BytesIO\r\nfrom itertools import count, starmap\r\nimport math\r\nfrom mimetypes import init\r\nimport numbers\r\nfrom os import dup, read, fstat\r\nfrom sys import setrecursionlimit, stdout\r\nfrom time import perf_counter, time\r\nfrom math import gcd,log2, sqrt\r\nfrom tkinter import N\r\nfrom traceback import print_tb\r\nfrom turtle import pos, st\r\nfrom unittest import result\r\nPATH_INPUT = r\"C:\\Users\\APDCL\\VSCode\\codechef\\input.txt\"\r\nPATH_OUTPUT = r\"C:\\Users\\APDCL\\VSCode\\codechef\\output.txt\"\r\nMOD = 1000000007\r\n#N = 1000001\r\nalphabets = \"abcdefghijklmnopqrstuvwxyz\"\r\n#digits = \"0123456789\"\r\n#vowels = \"aeiou\"\r\n#consonants = \"bcdfghjklmnpqrstvwxyz\"\r\ndef left_binary_search(numbers, target, start, end):\r\n position = bisect_left(numbers, target, start, end + 1) \r\n if position == 0:\r\n if numbers[0] == target:\r\n return 0\r\n else:\r\n return -1\r\n if position > end:\r\n return -1\r\n else:\r\n if numbers[position] == target:\r\n return position\r\n else:\r\n return -1\r\n\r\n\"\"\"\r\ndef right_binary_search(numbers, target, start, end):\r\n position = bisect(numbers, target, start, end + 1) # bisect and bisect_right works similar \r\n if position == 0:\r\n return -1\r\n if position == end + 1:\r\n if numbers[end] == target:\r\n return end\r\n else:\r\n return -1\r\n return position - 1\r\n\r\n\r\n\"\"\"\r\n\r\n\"\"\"\r\n\r\ndef prime_check(n):\r\n if n < 2:\r\n return False\r\n if n == 2:\r\n return True\r\n if n & 1 == 0:\r\n return False\r\n for i in range(3, int(sqrt(n) + 1), 2):\r\n if n % i == 0:\r\n return True\r\n return False\r\n\r\n\"\"\"\r\n\r\n\"\"\"\r\n#sieve for primes\r\n\r\n\r\nis_prime = [True] * N\r\nis_prime[0] = False\r\nis_prime[1] = False\r\nfor i in range(2, int(sqrt(N))):\r\n add = i + i\r\n while add < N:\r\n if is_prime[add]:\r\n is_prime[add] = False\r\n add += i\r\n\"\"\"\r\n\"\"\"\r\n# Factorial \r\n\r\nfact = [1] * N\r\n\r\nfor i in range(1, N):\r\n fact[i] = i\r\nfor i in range(2, N):\r\n fact[i] = (fact[i] * fact[i - 1]) % MOD\r\n\r\n#Bionomial Coefficient\r\n\r\ndef ncr(n, r):\r\n num = den = 1\r\n num = fact[n]\r\n den = (fact[n - r] * fact[r]) % MOD\r\n return (num * pow(den, MOD - 2, MOD)) % MOD\r\n\r\n\"\"\"\r\n\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\nfo = open(PATH_OUTPUT, \"w\")\r\ndef f_print(*output, sep = \"\\n\"):\r\n for i in output:\r\n fo.write(str(i) + sep)\r\n if sep != \"\\n\":\r\n fo.write(\"\\n\")\r\ndef f_print_list(output, sep = \" \"):\r\n for i in output:\r\n fo.write(str(i) + sep)\r\n if sep != \"\\n\":\r\n fo.write(\"\\n\")\r\ndef f_print_2Dlist(output, row = 1, column = 1, sep = \" \"):\r\n for i in range(row):\r\n for j in range(column):\r\n fo.write(str(output[i][j]) + sep)\r\n fo.write(\"\\n\")\r\n\"\"\"\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\ndef f_print_list(output, sep = \" \"):\r\n for i in output:\r\n stdout.write(str(i) + sep)\r\n if sep != \"\\n\":\r\n stdout.write(\"\\n\")\r\ndef f_print_2Dlist(output, row = 1, column = 1, sep = \" \"):\r\n for i in range(row):\r\n for j in range(column):\r\n stdout.write(str(i) + sep)\r\n stdout.write(\"\\n\")\r\n\r\n\r\na = f_input()\r\nb = f_input()\r\nif a == b[::-1]:\r\n f_print(\"YES\")\r\nelse:\r\n f_print(\"NO\")\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n \r\n \r\n#end = time.perf_counter()\r\n#fprint(end - start)\r\n#fo.close()", "i=input()\r\no=input()\r\nr=i[::-1]\r\nif o==r:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# Har har mahadev\r\n# author : @ harsh kanani\r\n\r\ns = input()\r\ns1 = input()\r\nif s==s1[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "if input() == input()[::-1]: print(\"YES\")\nelse: print(\"NO\")\n", "original = input()\r\ntranslated = input()\r\n\r\nif original == translated[::-1]: print(\"YES\")\r\nelse: print(\"NO\")", "s=input()\ns2=input()\ncounter=0\nif len(s)!=len(s2):\n print(\"NO\")\n exit()\nfor i in range(len(s)):\n if s[i]==s2[len(s)-1-i]:\n counter+=1\nif counter == len(s):\n print(\"YES\")\nelse:\n print(\"NO\") \n", "name1=input().lower()\r\nname2=input().lower()\r\nc=0;\r\nnumber_name2=len(name2)-1\r\nfor i in range(0,len(name1)):\r\n if name1[i]!=name2[number_name2]:\r\n c+=1\r\n number_name2-=1 \r\nif c==0:\r\n print(\"YES\") \r\nelse:\r\n print(\"NO\") \r\n", "s=input(\"\")\r\nt=input(\"\")\r\ns1=s.lower()\r\nt1=t.lower()\r\nc1=set(s1)\r\nc2=set(t1)\r\nif (len(c1)!=len(c2)):\r\n print(\"NO\")\r\nelse:\r\n if(s1==t1[::-1]):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n", "s=input()\r\nt=input()\r\na=[]\r\ns=list(s)\r\ns.reverse()\r\na=list(t)\r\nif(s==a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "berland = str(input())\r\nbirland = str(input())\r\nif berland[::-1]==birland:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "print( \"YES\" if (input() == input()[::-1]) else \"NO\")", "a = input()\r\nb = input()\r\nprint(\"YES\") if a[::-1]==b else print(\"NO\")", "string=str(input())\r\na=input()\r\nif string[::-1] == a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n=input()\ngm=input()\nres=n[::-1]\na=gm[::-1]\nif a==n and res==gm:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t \t \t \t \t\t \t \t\t \t \t\t\t \t", "a=input()[::-1]\r\nprint('YES' if a==input() else 'NO')\r\n", "s=input()\r\nq=input()\r\nr=s[::-1]\r\nif(q==r):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s=input()\r\nreverse=input()\r\nlst=list(s)\r\nrev=[]\r\nfor i in range(len(s)-1,-1,-1):\r\n rev.append(lst[i])\r\nans=''.join(rev)\r\nif reverse==ans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input())\r\nt = str(input())\r\nn = len(s)\r\nnew = \"\"\r\nfor i in range(n):\r\n b = s[n-1]\r\n c = s[-i-1]\r\n new = new+c\r\nif new == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nb=input()\r\ns=\"\"\r\nfor x in range(len(b)-1,-1,-1):\r\n s+=b[x]\r\n\r\nif s==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\ns1 = input()\r\nprint('YES' if s1[::-1] == s else 'NO')", "x = input()\r\ny = input()\r\n\r\nc = x[::-1] # to reverse\r\n\r\nif y == c :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "stren = input()\r\nstrper = input()\r\n\r\ndef reversd_string(str) :\r\n return str[::-1]\r\n\r\n\r\nif reversd_string(strper) == stren :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n\r\n\r\n", "a = input()\r\nb = input ()\r\nlist1 = list(a)\r\nlist2 = list(b)\r\nc = ''\r\nfor i in range (0,len(b)):\r\n c = list2[i] + c\r\nif a == c :\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nt=list(t)\r\ns=list(s)\r\nif list(reversed(s)) == t :\r\n print('YES')\r\nelse :\r\n print(\"NO\")", "print('YES' if list(input()) == list(reversed(input())) else 'NO')\r\n", "# your code goes here\nimport sys \n\ninp = sys.stdin\nout = sys.stdout \n\nstring = inp.readline().strip()\ntrans = inp.readline().strip()\nrev = string[::-1]\n\t\nif(rev == trans):\n\tout.write('YES')\nelse: \n\tout.write('NO')\n \t \t \t \t \t \t \t\t\t\t\t\t \t", "s=input()\r\nf=input()\r\nif s[::-1]==f:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def main() :\r\n print(yes_No(is_Correctly_Translated(input_Berland_Word(), input_Birland_Word())))\r\n\r\n\r\ndef is_Correctly_Translated(berland_word, birland_word) :\r\n return berland_word == birland_word[::-1]\r\n\r\n\r\ndef input_Berland_Word() :\r\n return input()\r\n\r\ndef input_Birland_Word() :\r\n return input()\r\n\r\n\r\ndef yes_No(bool) :\r\n return [\"NO\", \"YES\"][bool]\r\n\r\n\r\nmain()", "s= input()\r\nt=input()\r\ncheck= s[::-1]\r\nif check==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nl = len(s)\r\nx = l *(-1)\r\ni = -1\r\nst=\"\"\r\nwhile i >= x:\r\n st += s[i]\r\n i-=1\r\nif st == t : print(\"YES\")\r\nelse:print(\"NO\")", "s, t = input(), input()\r\n\r\nprint('YES' if ''.join(list(reversed(s))) == t else 'NO')\r\n", "def core():\r\n str1 = input()\r\n str2 = input()\r\n if len(str1) != len(str2):\r\n print(\"NO\")\r\n return\r\n n = len(str1)\r\n i = 0\r\n for i in range(0,n):\r\n if str1[i] != str2[-(i+1)]:\r\n print(\"NO\")\r\n return\r\n print(\"YES\")\r\ncore()", "s1 = input()\r\ns2 = input()\r\ni2 = len(s1) - 1\r\ni1 = 0\r\nflag = True\r\nif len(s1) != len(s2):\r\n print('NO')\r\nelse:\r\n for i in range(len(s1)):\r\n if s1[i2] != s2[i1]:\r\n flag = False\r\n i1 += 1\r\n i2 -= 1\r\n if flag:\r\n print('YES')\r\n else:\r\n print('NO')", "s , t = str(input()) , str(input())\r\narr = list(s)\r\nar = list(t)\r\narr.reverse()\r\nif arr == ar:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# s = input()\r\n# s2 = s.split('+')\r\n# for i in range(len(s2) - 1):\r\n# for j in range(len(s2) - 1 - i):\r\n# if int(s2[j]) > int(s2[j + 1]):\r\n# s2[j], s2[j + 1] = s2[j + 1], s2[j]\r\n# print('+'.join(s2))\r\n\r\n#\r\n# t = int(input())\r\n# for i in range(t):\r\n# a = input()\r\n# a2 = a.split()\r\n# for f in range(len(a2) - 1):\r\n# for j in range(len(a2) - 1 - f):\r\n# if int(a2[j]) > int(a2[j + 1]):\r\n# a2[j], a2[j + 1] = a2[j + 1], a2[j]\r\n# print(a2[1])\r\n\r\n\r\n# n = int(input())\r\n# string = input()\r\n# n1 = string.count('n')\r\n# n0 = string.count('r')\r\n# print(' 1' * n1, '0 ' * n0)\r\n\r\n#\r\n# a = input()\r\n# a2 = a.split()\r\n# for i in range(len(a2) - 1):\r\n# for j in range(len(a2) - 1 - i):\r\n# if int(a2[j]) > int(a2[j + 1]):\r\n# a2[j], a2[j + 1] = a2[j + 1], a2[j]\r\n# print(int(a2[2]) - int(a2[0]))\r\n\r\n\r\n# # Рудольф и переразиние верёвки\r\n# t = int(input())\r\n# for i in range(t):\r\n# n = int(input())\r\n# ans = 0\r\n# for j in range(n):\r\n# a, b = map(int, input().split())\r\n# if a > b:\r\n# ans += 1\r\n# print(ans)\r\n\r\n\r\n# # Рудольф и крестики-нолики-плюсики\r\n# t = int(input())\r\n# for i in range(t):\r\n# a = []\r\n# for j in range(3):\r\n# a.append(input())\r\n# ans = 'DRAW'\r\n# if a[0][0] == a[1][1] and a[1][1] == a[2][2] and a[0][0] != '.':\r\n# ans = a[0][0]\r\n# if a[0][2] == a[1][1] and a[1][1] == a[2][0] and a[0][2] != '.':\r\n# ans = a[0][2]\r\n# for j in range(3):\r\n# if a[j][0] == a[j][1] and a[j][1] == a[j][2] and a[j][0] != '.':\r\n# ans = a[j][0]\r\n# for h in range(3):\r\n# if a[0][h] == a[1][h] and a[1][h] == a[2][h] and a[0][h] != '.':\r\n# ans = a[0][h]\r\n# print(ans)\r\n\r\n\r\n\r\n# n = int(input())\r\n# n2 = list(map(int, input().split()))\r\n# d = {}\r\n# for i in n2:\r\n# if i not in d:\r\n# d[i] = 1\r\n# else:\r\n# d[i] += 1\r\n#\r\n# namber = max(d.values())\r\n# minNamber = 9999\r\n# a = []\r\n# for i, j in d.items():\r\n# if j == namber:\r\n# a.append(i)\r\n#\r\n# minA = min(a)\r\n# s = ''\r\n# for i in n2:\r\n# if i != minA:\r\n# s = s + str(i) + ' '\r\n#\r\n# print(s + (str(minA) + ' ') * d[minA])\r\n\r\n\r\n\r\ns = list(input())\r\nt = list(input())\r\n\r\nt.reverse()\r\nif s == t:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n", "# s = list(str(input()).lower())\n# t = str(input().lower())\n# reversed_s = ''\n# for i in reversed(s):\n# reversed_s += i\n#\n# if reversed_s != t:\n# print('NO')\n# else:\n# print('YES')\n\ns = input().lower()\nt = input().lower()\n\nif t == s[::-1]:\n print('YES')\nelse:\n print('NO')\n\n", "s=input()\nt=input()\na=0\nif len(s)==len(t):\n for i in range(len(s)):\n if s[i]!=t[-i-1]:\n a+=1\n print('YES' if a==0 else 'NO')\nelse:\n print('NO')", "string = input()\r\n\r\nreverse = input()\r\nnew_str = \"\"\r\nfor i in range(len(string) - 1 , -1 , -1) :\r\n new_str += string[i]\r\n\r\n\r\nif reverse == new_str :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n", "eng = input()\ngne = input()\n\nif eng == gne[::-1]:\n print('YES')\nelse:\n print('NO')", "s = input()\r\nt = input()\r\nl = [str(x) for x in str(s)]\r\nl.reverse()\r\nk = ''.join(l)\r\nif t==k:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input())\r\nss = str(input())\r\nrs = s[::-1]\r\nif(ss == rs):print(\"YES\")\r\nelse:print(\"NO\")", "import collections\r\nclass solution:\r\n def ans(word,t_word):\r\n if word == t_word[::-1]:\r\n return 'YES'\r\n return 'NO'\r\n\r\n\r\n\r\n\r\nword = str(input())\r\nt_word = str(input())\r\nres = solution.ans(word,t_word)\r\nprint(res)\r\n", "s1=input()\r\ns2=input()\r\nx=s1[::-1]\r\nif x==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\ndef is_reverse_same(s, t):\n reversed_t_list = reversed(list(t))\n\n same_count = 0\n for index, val in enumerate(reversed_t_list):\n if index <= len(s) - 1:\n if val == s[index]:\n same_count += 1\n\n if same_count == len(s):\n return \"YES\"\n return \"NO\"\n\n\ndef main():\n s = input()\n t = input()\n result = is_reverse_same(s, list(t))\n print(result)\n\nmain()\n", "a=input()\nb=input()\nif(a[::-1]==b):print(\"YES\")\nelse:print(\"NO\")", "#Mers\r\na = input ()\r\nb = input ()\r\na = a [::-1]\r\nif a == b :\r\n print ( \"YES\" )\r\nelse :\r\n print ( \"NO\" ) \r\n", "n=input()\r\na=list(n)\r\na.reverse()\r\nm=input()\r\nb=''.join(a)\r\nif b==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nc = input()\r\nb = a[-1::-1]\r\nif(c == b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x = input()\ny = input()\nif y == \"\".join(reversed(x)):\n print(\"YES\")\nelse:\n print(\"NO\")\n\t \t \t\t\t\t \t \t\t\t\t\t\t \t\t\t \t", "s1=input()\r\ns2=input()\r\ni=0\r\nj=len(s2)-1\r\nc=0\r\nwhile(i<len(s1) and j>=0):\r\n if(s1[i]==s2[j]):\r\n c+=1\r\n i+=1\r\n j-=1\r\nif(c==len(s1)):\r\n print('YES')\r\nelse:\r\n print('NO')", "ss = input()\r\ntt = input()\r\ninversed_index = -1\r\n\r\nflag = 'YES'\r\nfor s in ss:\r\n if s != tt[inversed_index]:\r\n flag = 'NO'\r\n break\r\n inversed_index -=1\r\n \r\nprint(flag)\r\n ", "a=input()\r\nb=input()\r\nlen_a=len(a)\r\nlen_b=len(b)\r\nflag=1\r\nif len_a!=len_b:\r\n print(\"NO\")\r\nelse:\r\n for i in range(len_a):\r\n if a[i]!=b[len_a-i-1]:\r\n print(\"NO\")\r\n flag=0\r\n break\r\nif flag and len_a==len_b:\r\n print(\"YES\")", "s=input()\r\nt=input()\r\na=t[-1::-1]\r\nif (a==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n", "w=input()\r\nx=input()\r\na=list(w)\r\nb=list(x)\r\na.reverse()\r\n\r\nif a==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "\"\"\"\r\n@auther:Abdallah_Gaber \r\n\"\"\"\r\nword1= input()\r\nword2= input()\r\n\r\nword = word1[::-1]\r\nif word == word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "x=input()\ny=input()\nif x[::-1]==y:\n print(\"YES\")\nelse:\n print(\"NO\")\n\t\t\t\t\t \t \t\t\t \t\t\t \t \t", "def reverse(string):\r\n string=string[::-1]\r\n return string\r\nstr=input()\r\nstr2=input()\r\nif (str2==reverse(str)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "d=str(input())\r\nf=str(input())\r\nif d[::-1]==f:\r\n print('YES')\r\nelse:\r\n print('NO')", "word1 = input()\r\nword2 = input()\r\nT = 1\r\ni = 0 \r\na = -1\r\nj = (-len(word1)) \r\nwhile a >= j and i < len(word1):\r\n if word1[i] != word2[a]:\r\n print(\"NO\")\r\n T = 0\r\n break\r\n i+=1\r\n a-=1\r\nif T == 1:\r\n print(\"YES\")", "# import sys\r\n# sys.stdin = open(\"test.in\",\"r\")\r\n# sys.stdout = open(\"test.out\",\"w\")\r\na=list(input())\r\nb=list(input())\r\nif a==b[::-1]:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')\t", "e1 = input()\r\nee1 = []\r\nee2 = []\r\nfor i in e1:\r\n ee1.append(i)\r\ne2 = input()\r\nfor i in e2:\r\n ee2.append(i)\r\nf1 = []\r\n\r\nfor i in range(len(ee1)-1,0 , -1):\r\n f1.append(ee1[i])\r\nf1.append(ee1[0])\r\n\r\nif f1 == ee2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nb=input()\r\nw=0\r\nfor i in range(len(a)):\r\n if a[i]!=b[-i-1]:\r\n w=1\r\n break\r\nif w==0:\r\n print(\"YES\")\r\nelif w==1:\r\n print(\"NO\")\r\n \r\n", "string = input()\nstring1 = input()\ncheck = string1[::-1]\n\nif string==check :\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t\t \t \t\t\t \t\t \t\t \t \t \t\t\t", "n = list(input())\r\nn_1 = input()\r\n\r\nn_1 = list(reversed(n_1))\r\n\r\nif n == n_1 :\r\n print('YES')\r\nelse :\r\n print('NO')", "a=list(input())\r\nb=list(input())\r\nx=b[::-1]\r\nif(a==x):\r\n print('YES')\r\nelse:\r\n print('NO')", "\"\"\"a\"\"\"\ninput1 = input()\ninput2 = input()\nans = input1[::-1]\nprint(\"YES\") if input2 == ans else print(\"NO\")\n", "t1=input()\r\nt2=input()\r\n\r\nt1=t1[::-1]\r\n\r\nif t1==t2:\r\n print('YES')\r\n\r\nelse:\r\n print('NO')", "name = input()\r\nword = input()\r\nif(name[::-1]==word):\r\n print('YES')\r\nelse:\r\n print('NO')", "f = input()\r\ns = input()\r\nfc = -1\r\nsc = 0\r\nc = len(f)\r\nr = ''\r\nwhile c>0:\r\n if f[fc] == s[sc]:\r\n r = 'YES'\r\n else:\r\n r = 'NO'\r\n break\r\n fc -= 1\r\n sc += 1\r\n c -= 1\r\nprint(r)\r\n", "eng= input()\r\nbosdi= input()\r\nA=[]\r\nfor i in eng:\r\n A.append(i)\r\nA.reverse()\r\ntest=''.join(A)\r\n\r\nif test==bosdi:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\ns1 = input()\nn = len(s)\ntr = \"\"\nfor i in range(n - 1, -1, -1):\n tr = tr + s[i]\n\nif tr == s1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "t = input()\ns = input()\ndef translation_function(t):\n t = t[::-1]\n return t\n\nif translation_function(t) == s:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \t\t \t \t\t \t\t\t\t\t\t\t\t\t \t\t \t", "s = input()\r\nt = input()\r\ns = ' '.join(s)\r\ns = list(s.split())\r\ns.reverse()\r\nt = ' '.join(t)\r\nt = list(t.split())\r\nif s == t:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n", "ber = input()\r\nbir = input()\r\n\r\nidx = -1\r\nflag = 0\r\nfor i in range(len(ber)):\r\n if ber[i]!=bir[idx]:\r\n flag = 1\r\n break\r\n else:\r\n idx-=1\r\nif flag == 0:\r\n print('YES')\r\nelse:\r\n print('NO')", "def translation(s, t):\r\n s = list(s)\r\n t = list(t)\r\n if s == t[::-1]:\r\n return 'YES'\r\n else:\r\n return 'NO'\r\n \r\nif __name__ == \"__main__\":\r\n s = input()\r\n t = input()\r\n print(translation(s, t))", "inp=input()\r\ninp2=input()\r\nrvrse=inp[::-1]\r\nif inp2==rvrse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[30]:\n\n\ns = input()\nt = input()\ntw = s[::-1]\nif t == tw:\n print('YES')\nelse:\n print('NO')\n\n \n \n\n\n# In[ ]:\n\n\n\n\n", "word1 = input()\r\nword2 = input()\r\nword3 = \"\"\r\n\r\nfor i in range(len(word2)-1, -1, -1):\r\n ch = word2[i]\r\n word3 = word3 + ch\r\n\r\nif (word1 == word3):print(\"YES\")\r\nelse:print(\"NO\")", "n = input()\r\nm = input()\r\n\r\nnew_n = list(n)\r\nnew_n.reverse()\r\nnew = ''.join(new_n)\r\nif new == m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\nb = input()\ni = 0\nj = len(b)-1\nwhile i<len(a) and j>-1:\n if a[i]==b[j]:\n i+=1\n j-=1\n else:\n break\nif i<len(a) or j>-1:\n print(\"NO\")\nelse:\n print(\"YES\")\n", "x=list(input())\r\ny=reversed(list(input()))\r\nflag=True\r\nfor i ,j in zip(x,y):\r\n if i!=j:\r\n flag=False\r\nprint(\"YES\") if flag==True else print(\"NO\")", "n=input()\r\nc=input()\r\ns=n[::-1]\r\nif(c==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "from math import *\r\nfrom typing import *\r\n\r\nif __name__ == '__main__':\r\n w = str(input())\r\n tw = str(input())\r\n \r\n if w[::-1] == tw and w == tw[::-1]: print(\"YES\")\r\n else: print(\"NO\")", "# LUOGU_RID: 111021228\na = input()\nb = input()\nif a[::-1] == b:\n print(\"YES\")\nelse:\n print(\"NO\")", "n=str(input())\r\nm=str(input())\r\nx=n[::-1]\r\nif x==m:\r\n print(\"YES\");\r\nelse: print(\"NO\")", "word1=input()\r\nword2=input()\r\nlist1=list(word1)\r\ntuple1=tuple(word1)\r\na=len(word1)\r\nfor i in range(a):\r\n\tlist1[i]=tuple1[-i-1]\r\nword1=''.join(list1)\r\nif word1==word2:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "word = input()\nword2 = input()\n\nif word[::-1] == word2:\n print('YES')\nelse:\n print('NO')\n\n \t \t \t \t\t\t \t\t\t\t\t \t \t", "s=input()\r\ns1=input()\r\nt=s[::-1]\r\nif(t==s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "text=input()\r\nre_text=input()\r\nli_re_text=list(re_text) #re_text is a list now\r\nli_text=list(text)\r\nli_text.reverse() #li_text is reversed\r\nif li_text==li_re_text:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a = input()\r\nb = input()\r\nif len(a) == len(b):\r\n good = True\r\n for i in range(len(b)):\r\n if a[i] != b[len(a)-1-i]:\r\n good = False\r\n print(['NO','YES'][int(good)])\r\nelse:\r\n print('NO')\r\n", "def reverse(x):\r\n return x[::-1]\r\ns = input()\r\nt = input()\r\nprint(\"YES\" if t == reverse(s) else \"NO\")", "str1 = input()\r\nstr2 = input()\r\nif len(str1) != len(str2):\r\n print(\"NO\")\r\n exit()\r\nfor i in range(0, len(str1)):\r\n if str1[i] != str2[len(str1)-i-1]:\r\n print(\"NO\")\r\n exit()\r\nprint(\"YES\")", "onci=input()\nmati=input()\nif onci[::-1]==mati:\n print(\"YES\")\nelse: print(\"NO\")\n \t \t \t\t \t\t\t\t \t\t\t\t\t\t\t \t\t", "s = input()\r\ns2 = input()\r\nprint('YES') if s == s2[::-1] else print('NO')", "m=input()\r\nn=input()\r\nif(m[::-1]==n):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = str(input())\r\nb = input()\r\nc =''\r\nh = []\r\ni = len(a)-1\r\nwhile i>=0:\r\n h.append(a[i])\r\n i-=1\r\nfor i in h:\r\n c = c+i\r\nif c == b:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input().replace(\" \", \"\").lower()\nt = input().replace(\" \", \"\").lower()\n\nls= len(s)-1\nlt=len(t)-1\n\n\nif(ls != lt):\n print(\"NO\")\nelse :\n\n ls=0 \n while(lt >= 0):\n \n if(s[ls] != t[lt]):\n print(\"NO\")\n break\n ls=ls+1\n lt=lt-1\n\n if(lt<0):\n print(\"YES\")\n\n\n \n", "n = input()\r\nm = input()\r\ns = ''\r\nfor i in range(len(n)-1,-1,-1):\r\n s = s + n[i]\r\nif s == m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a =input()\r\nb = input()\r\narr = []\r\nfor i in a:\r\n arr.append(i)\r\narr.reverse()\r\na = ''\r\nfor i in arr:\r\n a = a + i\r\nif a == b:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n", "n=input()\r\np=input()\r\np=p[::-1]\r\nif(n==p):\r\n print(\"YES\")\r\nelse:\r\n print (\"NO\")", "s=input()\r\np=input()\r\ndef reverse(s):\r\n str = \"\"\r\n for i in s:\r\n str = i + str\r\n return str\r\nif(p==reverse(s)):\r\n print(\"YES\\n\");\r\nelse:\r\n print(\"NO\\n\");", "a = input()\nb = input()\nif len(a) != len(b):\n print('NO')\n exit()\nfor i in range(len(a)):\n if a[i] != b[len(a)-1-i]:\n print('NO')\n exit()\n\nprint('YES')\n\t\t \t \t\t \t \t \t \t\t \t\t\t", "m,n=input(),input()\r\nif m==n[::-1]:print('YES')\r\nelse:print(\"NO\")\r\n", "s=input()\r\nt=input()\r\ncount=0\r\nfor i in range(0,len(s)):\r\n if(s[i]==t[len(t)-i-1]):\r\n count=count+1\r\n else:\r\n print('NO')\r\n break\r\nif(count==len(s)):\r\n print('YES')", "s = input()\r\nt = input()\r\nj,c=0,0\r\nif len(s)==len(t):\r\n for i in range(len(s)-1,-1,-1):\r\n if s[i]==t[j]:\r\n c += 1\r\n j += 1\r\n if c==len(s):\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nst=s[::-1]\r\nif (t==st):\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "n=input()\r\nx=input()\r\nsrt=n[::-1]\r\nif(x==srt):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=str(input())\nb=str(input())\nif s==b[::-1]:\n print(\"YES\")\nelif(s==b):\n print(\"NO\")\nelse:\n print(\"NO\")\n\n \t \t \t \t \t\t \t \t \t\t\t\t\t", "text1 = input()\ntext2 = input()\ntext1 = list(text1)\ntext2 = list(text2)\ntext2.reverse()\nif text1 == text2:\n print(\"YES\")\nelse:\n print(\"NO\")", "s=input()\r\ns1=input()\r\ny=s[::-1]\r\nif y==s1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=str(input())\r\nx=str(input())\r\nif s[::-1]==x:\r\n print('YES')\r\nelse:\r\n print('NO')", "berlandWord, birlandWord = input(), input()\r\nreverseBerland = \"\"\r\nfor x in berlandWord[len(berlandWord)-1::-1]:\r\n reverseBerland += x\r\nif reverseBerland == birlandWord:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\na=s[::-1]\r\nif a==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nif(s[::-1]==t): print('YES')\r\nelse: print('NO')", "oj = input()\r\nbj = input()\r\n\r\nif bj == oj[::-1]:\r\n print(\"YES\")\r\n \r\nelse: \r\n print(\"NO\")", "word = input()\r\nreverse = word[::-1]\r\n\r\ntrans = input()\r\n\r\nif trans == reverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a = input()\r\nb = input()\r\nprint('YES' if a[::-1] == b else 'NO')", "s = input() # Read the first word\r\nz = input() # Read the second word\r\n\r\n# Check if t is the reverse of s\r\nif z == s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\ns1 = input()\r\nfor i in range(len(s)):\r\n if s[i] != s1[-(i + 1)]:\r\n print('NO')\r\n break\r\nelse:\r\n print('YES')", "x=input()\r\ny=input()\r\ncount=0\r\nn=len(x)\r\nm=len(y)\r\nif(n!=m):\r\n print(\"NO\")\r\nelse:\r\n for i in range(n):\r\n if(x[i]==y[n-i-1]):\r\n count+=1\r\n if(count==n):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n ", "w1, w2 = input(), input()\r\n\r\nif len(w1) == len(w2):\r\n for i in range(len(w1)):\r\n if not w1[i] == w2[len(w2)-1-i]:\r\n print(\"NO\")\r\n exit(0)\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def translation(word1, word2):\r\n if word1[::-1] != word2:\r\n return 'NO'\r\n else:\r\n return 'YES'\r\nprint(translation(input(),input()))", "a=str(input())\r\nb=str(input())\r\nc=b[::-1]\r\nif(a==c):\r\n print('YES')\r\nelse:\r\n print('NO')", "s = list(input())\r\nt = list(input())\r\ns.reverse()\r\ncount = 0\r\nfor i,j in zip(s, t):\r\n\tif i == j:\r\n\t\tcount += 1\r\nif count == len(s):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n\r\n\t", "word1 = input()\r\nword2 = input()\r\n\r\nif len(word1) != len(word2):\r\n print('NO')\r\n exit(0)\r\n\r\nfor i in range(len(word1)):\r\n if word1[i] != word2[len(word1) - 1 - i]:\r\n print('NO')\r\n break\r\nelse:\r\n print(\"YES\")\r\n", "w1 = input()\r\nw2 = input()\r\n\r\nif w1 == w2[-1:-(len(w2)+1):-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "x = input()\nxNeg = ['']*len(x)\n\nfor i in range(len(x)):\n xNeg[i]=x[-(i+1)]\n \ny = input()\n\nif y == ''.join(xNeg):\n print (\"YES\")\nelse:\n print (\"NO\")", "n=input()\r\np=input()\r\nprint(\"YES\") if n[::-1]==p else print(\"NO\")", "s = input()\r\na = input()\r\n\r\nfor i in range(len(s)):\r\n if s[i] == a[-i-1]:\r\n f = 1\r\n else:\r\n f = 0\r\n break\r\nif f == 1:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\nj=len(s)-1\r\ni=0\r\na=True\r\nif len(s)!=len(t):\r\n a=False\r\nelse:\r\n while i<len(s):\r\n if s[i]!=t[j]:\r\n a=False\r\n break\r\n else:\r\n i+=1\r\n j-=1\r\nif a:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\ns=list(s)\r\ns.reverse()\r\ns1=''.join(i for i in s)\r\nif(s1==t):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\r\nt1=input()\r\nt=\"\".join(reversed(s))\r\nif t1==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n1 = input()\r\nn2 = input()\r\nb1 = ''\r\nb2 = len(n2)\r\nfor i in range(b2-1,-1,-1):\r\n b1 = b1+n2[i]\r\nif b1 == n1:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \r\n", "from sys import stdin, stdout\r\nfrom collections import *\r\nfrom math import gcd, ceil, floor\r\n\r\n\r\ndef st():\r\n return list(stdin.readline().strip())\r\n\r\n\r\ndef li():\r\n return list(map(int, stdin.readline().split()))\r\n\r\n\r\ndef mp():\r\n return map(int, stdin.readline().split())\r\n\r\n\r\ndef inp():\r\n return int(stdin.readline())\r\n\r\n\r\ndef pr(n):\r\n return stdout.write(str(n) + \"\\n\")\r\n\r\n\r\nmod = 1000000007\r\nINF = float('inf')\r\nY = \"YES\"\r\nN = \"NO\"\r\n\r\n\r\ndef solve():\r\n # solve\r\n s1 = input()\r\n s2 = input()\r\n print(Y if s2 == s1[::-1] else N)\r\n\r\n\r\nfor test in range(1):\r\n solve()\r\n", "a=input()\r\nb=input()\r\nar=a[::-1]\r\nif ar==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\r\na=input()\r\nb=list(input())\r\n\r\nx=[i for i in a[::-1]]\r\n\r\nprint(\"YES\" if b==x else \"NO\")\r\n\r\n", "s1=input()\r\ns2=input()\r\ns3=''\r\nfor i in s1:\r\n s3=i+s3\r\nif(s2==s3):\r\n print('YES')\r\nelse:\r\n print('NO')", "a=input()\nb=input()\nrev=b[::-1]\nif a==rev:\n print(\"YES\")\nelse:\n print(\"NO\")", "import sys\ns = sys.stdin.readline().strip()\nt = sys.stdin.readline().strip()\nif s[::-1] == t:\n print('YES')\nelse:\n print('NO')\n", "s = input()\r\nt = input()\r\nw = s[::-1]\r\nif w == t :\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "x = input()\r\ny = input()\r\nn = \"\"\r\nfor i in range(len(x)-1,-1,-1):\r\n n += x[i]\r\nif n == y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nn,fl=-1,0\r\nfor i in range(len(s)):\r\n if s[i]!=t[n]:\r\n fl=1\r\n n-=1\r\n break\r\n n-=1\r\nif fl==0:\r\n print('YES')\r\nelse:\r\n print('NO')", "\"\"\"n=int(input())\r\nif n==2 or n%2==1:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\"\"\"\r\n\r\n\"\"\"n=int(input())\r\nfor i in range(n):\r\n str=input()\r\n l=len(str)\r\n if l<=10:\r\n print(str)\r\n else:\r\n x=\"{}\".format(l-2)\r\n print(str[0]+x+str[-1])\"\"\"\r\n\"\"\"n=int(input())\r\nx=0\r\nfor i in range(n):\r\n a,b,c=input().split()\r\n if a==\"1\" and b==\"1\" :\r\n x+=1\r\n elif a==\"1\" and c==\"1\":\r\n x+=1\r\n elif b==\"1\" and c==\"1\":\r\n x+=1\r\nprint(x)\"\"\"\r\n\"\"\"n,k=map(int,input().split())\r\nscores=list(map(int,input().split()))\r\nz=0\r\nfor points in scores:\r\n if points>=scores[k-1] and points!=0:\r\n z+=1\r\nprint(z)\"\"\"\r\n\"\"\"n,m=map(int,input().split())\r\nprint((n*m)//2)\"\"\"\r\n\"\"\"n=int(input())\r\nX=0\r\nfor i in range(n):\r\n oper=input()\r\n if oper==\"++X\" or oper==\"X++\":\r\n X+=1\r\n elif oper==\"--X\" or oper==\"X--\":\r\n X-=1\r\nprint(X)\"\"\"\r\n\"\"\"\r\nfor i in range(1,6):\r\n m=list(map(int,input().split()))\r\n #r,c=0,0\r\n for j in range(1,6):\r\n if m[j-1]==1:\r\n print(abs(i-3)+abs(j-3))\r\n break\"\"\"\r\n# ip1=input()\r\n# ip2= input()\r\n# ip1=ip1.lower()\r\n# ip2=ip2.lower()\r\n# if ip1>ip2:\r\n# print(1)\r\n# elif ip1<ip2:\r\n# print(-1)\r\n# elif ip1==ip2:\r\n# print(0)\r\n#231A\r\n# hlp=input()\r\n# lst=[]\r\n# for w in hlp :\r\n# if w!='+':\r\n# lst.append(w)\r\n# lst.sort()\r\n# # print(lst)\r\n# hlp=\"\"\r\n# for i in lst[:-1]:\r\n# hlp+=i+'+'\r\n# print(hlp+lst[-1])\r\n# c=input()\r\n# print(c[0].upper()+c[1:])\r\n# ch=input()\r\n# set=set(ch)\r\n# n=0\r\n# for s in set:\r\n# n+=1\r\n# #print(set)\r\n# if n&1:\r\n# print(\"IGNORE HIM!\")\r\n# else:\r\n# print(\"CHAT WITH HER!\")\r\n# n=int(input())\r\n# str=input()\r\n# count=0\r\n# for i in range(n-1):\r\n# if str[i]==str[i+1]:\r\n# count+=1\r\n# print(count)\r\n# a,b=map(int,input().split())\r\n# count=0\r\n# while(a<=b):\r\n# count+=1\r\n# a=a*3\r\n# b=b*2\r\n# print(count)\r\n# k,n,w=map(int,input().split())\r\n# tc=0\r\n# for i in range(1,w+1):\r\n# tc+=k*i\r\n# if tc<n:\r\n# print(0)\r\n# else: \r\n# print(tc-n)\r\n# x=int(input())\r\n# count=0\r\n# if x%5==0:\r\n# count=x//5\r\n# else:\r\n# count=x//5+1\r\n# print(count)\r\n# str=input()\r\n# c1=0\r\n# for letter in str:\r\n# if letter.isupper():\r\n# c1+=1\r\n# if (len(str)-c1)>=c1:\r\n# print(str.lower())\r\n# else:\r\n# print(str.upper())\r\n# n,k=map(int,input().split())\r\n# while(k>0):\r\n# ld=n%10\r\n# if ld==0:\r\n# n=n//10\r\n# else:\r\n# n=n-1\r\n# k-=1\r\n# print(n)\r\n# n=int(input())\r\n# c1=0\r\n# while(n>0):\r\n# r=n%10\r\n# if r==4 or r== 7:\r\n# c1+=1\r\n# n=n//10\r\n# if c1==4 or c1==7:\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\")\r\n# n=int(input())\r\n# passengers_in_tram=0\r\n# ans=0\r\n# while n>0:\r\n# a,b=map(int,input().split())\r\n# #temp=passengers_in_tram\r\n# passengers_in_tram=(passengers_in_tram-a)+b\r\n# ans=max(passengers_in_tram,ans)\r\n# #print(ans)\r\n# n-=1\r\n# print(ans)\r\ns=input()\r\nt=input()\r\nif s==t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nx=t[::-1]\r\n\r\nif s==x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "w=input()\r\nc=input()\r\nif c[::-1]==w:\r\n print('YES')\r\nelse: print('NO')", "x=input()\ny=input()\ne=0\nif len(x)!=len(y):\n print(\"NO\")\nelse:\n for i in range(len(x)):\n if x[i]==y[len(y)-i-1]:\n e=e+1\n if e==len(y):\n print(\"YES\")\n if e!=len(y):\n print(\"NO\")", "s, tr = input(), input()\r\n\r\nprint(\"YES\" if s == tr[::-1] else \"NO\")\r\n", "s1=input()\r\ns2=input()\r\ns3=\"\".join(reversed(s2))\r\nif s1==s3:\r\n print('YES')\r\nelse:\r\n print('NO')", "x=list(input())\r\ny=list(input())\r\n\r\ny.reverse()\r\n#print(y)\r\nif x==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nresult = \"\"\r\nfor i in reversed(s):\r\n result = result+i\r\nif t==result:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=[str(x) for x in input()]\ns2=[str(x) for x in input()]\nemp1=[]\nemp2=[]\ndef str_to_char(emp,s):\n\n for i in s:\n for _ in i:\n emp.append(_)\n \nstr_to_char(emp1,s1)\nstr_to_char(emp2,s2)\nif emp1==emp2[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n", "str1=input()\r\nstr2=input()\r\nprint(\"YES\") if(str1==str2[::-1]) else print(\"NO\")", "s=input()\r\nvr=input()\r\nS=s[::-1]\r\nif vr==S:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "text1 = input()\r\ntext2 = input()\r\ntxt = text2[::-1]\r\nif(text1==txt):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "st1 = input()\r\nst2 = input()\r\ni = \"\"\r\nfor j in range(len(st1)-1,-1,-1):\r\n\ti = i+st1[j]\r\nif i==st2:\r\n\tprint(\"YES\")\r\nelse:print(\"NO\")\t\t", "a = input()\r\nb = input()\r\nn=len(a)\r\nif(n!=len(b)):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(a)):\r\n if(a[i] == b[len(a)-i-1]):\r\n n-=1\r\n if(n==0):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n ", "z=input;\r\nprint(\"YNEOS\"[z()!=z()[::-1]::2])", "a = input()\r\nb = input()\r\nc=[]\r\ni=0\r\nwhile(i<len(a)):\r\n c.append(a[i])\r\n i = i + 1\r\nc.reverse()\r\nd = \"\".join(c)\r\nif b==d:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\r\ns1 = input()\r\ns2 = input()\r\ns3 = \"\"\r\nfor i in range(len(s2)-1,-1,-1):\r\n s3 = s3+s2[i]\r\nif(s3==s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# n=int(input())\r\n# o1=\"No\"\r\n# for i in range(n):\r\n# x=int(input())\r\n# y=str(input())\r\n# y1=list(y)\r\n# print(y1)\r\n# for j in range(x):\r\n# if y[j]=='Q':\r\n# for a in y[j:]:\r\n# if a=='A':\r\n# o1=\"Yes\"\r\n# y1.remove(a)\r\n# else:\r\n# o1=\"No\"\r\n# print(o1)\r\n# ___________________________________________ yet\r\n# n=int(input())\r\n# sum=0\r\n# for i in range(n):\r\n# x=\"no\"\r\n# line1=input().split()\r\n# sum=int(line1[0])\r\n# if (int(line1[1])+int(line1[2]))==sum:\r\n# x=\"yes\" \r\n# sum=int(line1[2])\r\n# if (int(line1[0])+int(line1[1]) )==sum:\r\n# x=\"yes\"\r\n# sum=int(line1[1])\r\n# if (int(line1[0])+int(line1[2])==sum):\r\n# x=\"yes\"\r\n# print(x)\r\n# ___________________________________________________________Done \r\n# n=int(input())\r\n# for i in range(n):\r\n# x=input().split()\r\n# t1=x[0]\r\n# t2=x[1]\r\n# max='>'\r\n# if t1==t2:\r\n# max='='\r\n# if t2[-1]=='S'and t1[-1]=='S':\r\n# if len(t1)>len(t2):\r\n# max='<'\r\n# if t2[-1]=='L' and t1[-1]=='L':\r\n# if len(t2)>len(t1):\r\n# max='<'\r\n# if t2[-1]=='L' and t1[-1]=='M':\r\n# max='<'\r\n# if t2[-1]=='L' and t1[-1]=='S':\r\n# max='<'\r\n# if t2[-1]=='M' and t1[-1]=='S':\r\n# max='<'\r\n# print(max)\r\n# ___________________________________________________________Done\r\n# w=int(input())\r\n# x=w/2\r\n# y=w/2\r\n# if w>2:\r\n# if x%2==0 and y%2==0:\r\n# print(\"YES\")\r\n# else:\r\n# x+=1\r\n# y-=1\r\n# if x%2==0 and y%2==0:\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\")\r\n# else:\r\n# print(\"NO\")\r\n# ____________________________________________________________________Done\r\n# n=int(input())\r\n# a=''\r\n# b=''\r\n# for i in range(n):\r\n# x=str(input())\r\n# w=len(x)\r\n# if w<=10:\r\n# print(x)\r\n# else:\r\n# for j in x:\r\n# if j in x[0] :\r\n# a=j\r\n# b=j\r\n# if j in x[-1]:\r\n# b=j \r\n# o=(a+str(len(x)-2)+b)\r\n# print(o)\r\n# ________________________________________Done\r\n# n=int(input())\r\n# o=0\r\n# for i in range(n):\r\n# c0=0\r\n# c1=0\r\n# x=input().split()\r\n# for i in x:\r\n# if i=='0':\r\n# c0+=1\r\n# else:\r\n# c1+=1\r\n# if c1>=2:\r\n# o+=1\r\n# print(o)\r\n# _______________________________________________________________Done\r\n# a= input().split()\r\n# n=int(a[0])\r\n# x=int(a[1])\r\n# c=0\r\n# k=input().split()\r\n# k1=[]\r\n# for d in k:\r\n# d=int(d)\r\n# k1.append(d)\r\n# count=0\r\n# for i in k1:\r\n# count+=1\r\n# if count==x:\r\n# x=i\r\n# break\r\n# for j in k1:\r\n# if j>0 and j>=x:\r\n# c+=1\r\n# print(c) \r\n# _______________________________________________________Done\r\n# n=input().split()\r\n# a=int(n[0])\r\n# b=int(n[1])\r\n# x=0\r\n# r=a*b\r\n# c=0\r\n# for i in range(r):\r\n# if r-2>=x:\r\n# x+=2\r\n# c+=1\r\n# print(c)\r\n# _______________________________________________________________Done\r\n# x=0\r\n# n=int(input())\r\n# for i in range(n):\r\n# s=input()\r\n# if '++' in s:\r\n# x+=1\r\n# elif '--'in s:\r\n# x-=1\r\n# print(x)\r\n# _____________________________________________________________________Done\r\n\r\n# x=input().lower()\r\n# y=input().lower()\r\n# if x<y:\r\n# print(-1)\r\n# elif y<x:\r\n# print(1)\r\n# else:\r\n# print(0)\r\n# ___________________________________________________________________Done\r\n# n=input().split(\"+\")\r\n# x1=[]\r\n# x2=[]\r\n# x3=[]\r\n# c=[]\r\n# for i in n:\r\n# if i =='1':\r\n# x1.append(i)\r\n# elif i=='2':\r\n# x2.append(i)\r\n# elif i=='3':\r\n# x3.append(i)\r\n# for i in x1:\r\n# c.append(int(i))\r\n# for i in x2:\r\n# c.append(int(i))\r\n# for i in x3:\r\n# c.append(int(i))\r\n# count=0\r\n# for i in c:\r\n# count+=1\r\n# if count!=len(c):\r\n# print(int(i),end=\"+\")\r\n# else:\r\n# print(int(i),end=\"\")\r\n#________________________________________________________________Done\r\n# w=input()\r\n# count=1\r\n# for i in w:\r\n# if count==1:\r\n# x=i.capitalize()\r\n# count+=1\r\n# print(x+w[1:])\r\n# __________________________________________________________________Done\r\n# m=input()\r\n# m1=''\r\n# o=''\r\n# for i in m:\r\n# if i not in m1:\r\n# m1+=i\r\n# if len(m1)%2==0:\r\n# o=\"CHAT WITH HER!\"\r\n# else:\r\n# o=\"IGNORE HIM!\"\r\n# print(o)\r\n# ________________________________________________________________________Done\r\n# n=input()\r\n# s=input()\r\n# s2=[]\r\n# for i in s:\r\n# s2.append(i)\r\n# s1=s[0]\r\n# o=0\r\n# c=0\r\n# for i in s2[1:]:\r\n# if i==s2[c]:\r\n# o+=1\r\n# s1=i\r\n# c+=1 \r\n# print(o)\r\n# _____________________________________________________________________Done\r\n# n=input().split()\r\n# a=int(n[0])\r\n# b=int(n[1])\r\n# for i in range(100):\r\n# a*=3\r\n# b*=2\r\n# if a>b:\r\n# print(i+1)\r\n# break\r\n# _________________________________________________________________________Done\r\n# n=int(input())\r\n# c=0\r\n# c2=0\r\n# for i in range(n):\r\n# x=input().split()\r\n# for j in range(len(x)):\r\n# if x[j]==\"1\":\r\n# c+=1\r\n# if (x.count(\"1\")>=2):\r\n# c2+=1\r\n# print(c2) \r\n#__________________________________________________________________________Done \r\n# f=input().split()\r\n# cost=int(f[0])\r\n# dollars=int(f[1])\r\n# numofbanana=int(f[2])\r\n# x=0\r\n# y=0\r\n# for i in range(1,numofbanana+1):\r\n# x=cost*i\r\n# y+=x \r\n# m=dollars-y\r\n# if m>=0:\r\n# print(0)\r\n# else:\r\n# print(abs(m))\r\n#___________________________________________________________________Done\r\n# n=int(input())\r\n# c=0\r\n# x=0\r\n# y=n\r\n# l=[5,4,3,2]\r\n# i=5\r\n# while y>0:\r\n# x=n/i\r\n# c+=1\r\n# y=y-i\r\n# else:\r\n# i-=1 \r\n# print(c)\r\n# _______________________________________________________________Done\r\n# word=input()\r\n# l=0\r\n# u=0\r\n# for i in word:\r\n# if i ==i.upper():\r\n# u+=1\r\n# else:\r\n# l+=1\r\n# if l>=u:\r\n# word=word.lower()\r\n# else:\r\n# word=word.upper()\r\n# print(word)\r\n# _____________________________________________________________________Done\r\n# n=input().split()\r\n# a=int(n[0])\r\n# b=int(n[1])\r\n# for i in range(b):\r\n# if a%10==0:\r\n# a=int(a)/10\r\n# else:\r\n# a=int(a)-1\r\n# print(int(a))\r\n# _______________________________________________________________Done\r\n# n=input()\r\n# yes=0\r\n# no=0\r\n# for i in n:\r\n# if i=='7' or i=='4':\r\n# yes+=1\r\n# else:\r\n# no+=1\r\n\r\n# if yes==7 or yes==4:\r\n# print(\"YES\")\r\n# else:\r\n# print(\"NO\")\r\n#_______________________________________________________________Done\r\n# n=int(input())\r\n# x=input()\r\n# a=0\r\n# d=0\r\n# for i in x:\r\n# if i=='A':\r\n# a+=1\r\n# else:\r\n# d+=1\r\n# if a>d:\r\n# print(\"Anton\")\r\n# elif d>a:\r\n# print(\"Danik\")\r\n# else:\r\n# print(\"Friendship\")\r\n# __________________________________________________________________Done\r\nw1=input()\r\nw2=input()\r\nx=int(len(w2))-1\r\no=0\r\no1=0\r\nfor i in w1:\r\n if str(i)==str(w2[x]):\r\n o+=1\r\n else:\r\n o1+=1\r\n x-=1\r\nif o1==0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n \r\n \r\n \r\n \r\n ", "a = [*input()]\r\nb = [*input()]\r\n\r\na = a[::-1]\r\nfor i in range(len(a)):\r\n if a[i] !=b[i]:\r\n print('NO')\r\n break\r\nelse:\r\n print('YES')\r\n\r\n", "def reverse (s) :\r\n if len(s) == 0:\r\n return s\r\n else:\r\n return (reverse( s[1:] ) + s[0])\r\n\r\ns = input()\r\nt = input()\r\nprint (\"YES\") if reverse(s) == t else print (\"NO\")", "x = input()\r\ny = input()\r\na = [i for i in x]\r\nb = [j for j in y]\r\nb.reverse()\r\nif a == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "lang1 = input()\r\nlang2 = input()\r\nlang3 = \"\"\r\nfor i in range(len(lang1)-1,-1,-1):\r\n lang3 = lang3+lang1[i]\r\n\r\nif lang2 == lang3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "text1 = input()\r\ntext = input()\r\ncopy = text1[::-1]\r\nif copy == text:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "str_1 = input()\r\nstr_2 = input()\r\nreverse_str_1 = \"\"\r\n\r\nfor i in range(len(str_1)-1, 0, -1):\r\n reverse_str_1 = reverse_str_1 + str_1[i]\r\n\r\nreverse_str_1 = reverse_str_1 + str_1[0]\r\n\r\nif reverse_str_1 == str_2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Thu Jun 25 21:45:06 2020\r\n\r\n@author: pc612\r\n\"\"\"\r\n\r\ns = input()\r\na = input()\r\nif s == a[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "slovbe = str(input())\r\nslovbi = str(input())\r\nslovbi = \"\".join(reversed(slovbi))\r\nif slovbi == slovbe:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "k=input()\r\nk1=input()\r\nif k[::-1]==k1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nm=[]\r\nfor i in range(len(a)-1,-1,-1):\r\n m.append(a[i])\r\nb=input()\r\nfor i in range(len(m)):\r\n if m[i]!=b[i]:\r\n print(\"NO\")\r\n exit()\r\nprint(\"YES\")\r\n ", "x = input()\r\nc = input()\r\nk = len(x)\r\nv = len(c)\r\nflag = 'YES'\r\nif k != v:\r\n flag = 'NO'\r\nelse:\r\n for i in range(k):\r\n if x[i] != c[k - 1 - i]:\r\n flag = 'NO'\r\nprint(flag)", "def reverse(s):\r\n str1 = \"\"\r\n for i in range(len(s)-1, -1, -1):\r\n str1 += s[i]\r\n return str1\r\ns = input()\r\nt = input()\r\ns = reverse(s)\r\nif s == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nn=len(s)\r\nm=len(t)\r\nb=0\r\nif n==m:\r\n for i in range(n):\r\n if s[i]!=t[n-1-i]:\r\n print(\"NO\")\r\n break\r\n else:\r\n b=b+1\r\n if b==n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "S=input()\r\nS1=input()\r\nk=len(S)\r\nk1=len(S1)\r\nc=0\r\nS3=[str(S[i]) for i in range(k) ]\r\nS2=[str(S1[i]) for i in range(k1) ]\r\nS2.reverse()\r\nif S3!=S2 :\r\n c=1\r\n \r\nif c==1 :\r\n print('NO')\r\nelse :\r\n print('YES')\r\n \r\n\r\n", "string=input()\r\nstring1=input()\r\nstring2=string[::-1]\r\nif string1==string2:\r\n print('YES')\r\nelse :\r\n print(\"NO\")", "ber = input()\r\nbir = input()\r\ntranslated = list(bir)\r\ntranslated.reverse()\r\nresult = ''.join(translated)\r\nif result == ber:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input().strip()\r\nt = input().strip()\r\n\r\ni = 0\r\nj = len(t) - 1\r\n\r\nwhile i < len(s) and j >= 0:\r\n if s[i] != t[j]:\r\n print(\"NO\")\r\n exit()\r\n i += 1\r\n j -= 1\r\n\r\nif i == len(s) and j == -1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "# LUOGU_RID: 100088519\na=input()\nb=input()\nif a==b[::-1]:print(\"YES\")\nelse:print(\"NO\")", "s1=input()\r\ns2=input()\r\nd=False\r\nif len(s1)==len(s2):\r\n e=len(s1)\r\n for i in range(e):\r\n if s1[i]==s2[e-i-1] :\r\n d=False\r\n else :\r\n d=True\r\n break\r\nelse: d=True\r\n \r\nif d :\r\n print(\"NO\")\r\nelse :\r\n print(\"YES\")\r\n\r\n\r\n \r\n \r\n ", "def translation(stringA: str, stringB: str) -> str:\r\n \r\n if len(stringA) != len(stringB):\r\n return \"NO\"\r\n\r\n i = 0\r\n j = len(stringB)-1\r\n\r\n while i < len(stringA) and j >= 0:\r\n if stringA[i] != stringB[j]:\r\n return \"NO\"\r\n i += 1\r\n j -= 1\r\n\r\n return \"YES\"\r\n\r\ndef main():\r\n string1 = input().strip()\r\n string2 = input().strip()\r\n print(translation(string1, string2))\r\n\r\nmain()\r\n", "def string_reverse(str1):\n\n rstr1 = ''\n index = len(str1)\n while index > 0:\n rstr1 += str1[ index - 1 ]\n index = index - 1\n return rstr1\nstr = input( )\nstr2 = input( )\nstr1 = string_reverse(str)\nif( str1== str2):\n\tprint('YES')\nelse:\n\tprint('NO')\n\t\t\t \t \t \t \t \t \t \t\t\t \t\t\t\t\t", "a=input()[::-1]\r\nb=input()\r\nif(a==b) :print(\"YES\")\r\nelse: print(\"NO\")", "be = input()\r\ntbi = input()\r\nrbi = ''\r\nfor i in range(-1,-len(be)-1,-1):\r\n rbi += be[i]\r\nif tbi == rbi:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "st1=input()\r\nst2=input()\r\nif(st1[::-1]==st2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\n\na = str(input())\na_rever = str(input())\nprint(\"YES\" if a[::-1] == a_rever else \"NO\")", "s=input()\r\nc=input()\r\nk=s[::-1]\r\nif k==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "'''\r\nCreated on 10/05/2020\r\n\r\n@author: Gon\r\n'''\r\n\r\ns = input()\r\nt = input()\r\n\r\nif s == t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "string1 = input()\r\nstring2 = input()\r\n\r\nif string1 == string2[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nfor i in range(len(s)):\r\n if s[i]!=t[-1*(i+1)]:\r\n print(\"NO\")\r\n break\r\n elif i==len(s)-1:\r\n print(\"YES\")\r\n", "word = input()\r\ntran = [n for n in input()]\r\ntran.reverse()\r\nre_tran = ''.join(tran)\r\nif re_tran == word:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=str(input())\r\nb=str(input())\r\nif len(a)!=len(b):\r\n print('NO')\r\nelse:\r\n l=len(a)\r\n k=0\r\n for i in range(l):\r\n if a[i]!=b[l-i-1]:\r\n k=1\r\n break\r\n if k==1:\r\n print('NO')\r\n else:\r\n print('YES')", "\r\nl=str(input())\r\nl2=str(input())\r\nj=len(l2)-1\r\ni=0\r\nflag=0\r\nwhile j>=0 and i<len(l):\r\n\r\n if l2[j]!=l[i]:\r\n flag=1\r\n break\r\n j-=1\r\n i+=1\r\nif flag==0:\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 \r\n", "s = str(input())\r\ns2 = str(input())\r\nli = [char for char in s]\r\nli.reverse()\r\nx = ''.join(li)\r\nif(x == s2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "R = lambda: map(int, input().split())\n\nprint(\"YES\" if input() == input()[::-1] else \"NO\")\n", "n=input()\r\nm=input()\r\na=m[::-1]\r\nif a==n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nif(len(s)<=100 and len(t)<=100):\r\n if(len(s)==len(t)):\r\n t_len = len(t)\r\n check = True\r\n for i in range(len(s)):\r\n if(s[i]!=t[(t_len-1)-i]):\r\n check = False\r\n\r\n if(check):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n \r\n else:\r\n print(\"NO\")\r\n", "l=list(input())\r\nl2=list(input())\r\nl.reverse()\r\nif(l==l2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\nd=b[::-1]\r\nif a==d:\r\n print('YES')\r\nelse:\r\n print(\"NO\")", "l = list(input());\r\nl1 = list(input());\r\nl1.reverse();\r\nprint([\"NO\", \"YES\"][l == l1]);\r\n", "text_1 = input()\r\ntext_2 = input()\r\ntext_1 = text_1[::-1]\r\nif text_1 == text_2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\nt=input()\na=s[::-1]\nif a==t:\n print(\"YES\")\nelse:\n print(\"NO\")\n\t\t \t \t\t\t \t \t\t \t \t \t \t\t\t", "s = input()\r\nt = input()\r\nt_rev = t[::-1]\r\nprint('YES') if t_rev == s else print('NO')", "def main():\n first = input()\n second = input()\n if len(first) != len(second):\n print(\"NO\")\n else:\n index = 0\n diff = False\n while index <= len(first) - 1:\n if first[index] != second[len(second) - 1 - index]:\n diff = True\n break\n index += 1\n if diff == False:\n print(\"YES\")\n else:\n print(\"NO\")\nmain()\n", "s=input()\r\nt=input()\r\n\r\nc=0\r\nct=0\r\nm=0\r\nfor i in range (len(s)):\r\n \r\n ct-=1\r\n if s[c]==t[ct]:\r\n c+=1\r\n m+=1 \r\n else:\r\n print(\"NO\")\r\n break\r\n\r\n\r\nif m==len(s):\r\n print(\"YES\")\r\n \r\n ", "n=input()\r\nr=input()\r\nf=0\r\nfor i in range(len(n)):\r\n if n[i]==r[len(r)-1-i]:\r\n f=1\r\n else:\r\n f=0\r\n break\r\nif f==1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n \r\n", "a = input('')\r\nb = input('')\r\nc = ''\r\n\r\nfor x in range( len(a),0,-1 ):\r\n\tc += a[x-1]\r\n\r\nif b == c:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "n = input()\r\nb = input()\r\nif n == \"\".join(reversed(b)):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "def main ():\n word, rev_word = list(input()), list(input())[::-1]\n if word == rev_word:\n print('YES')\n else:\n print('NO')\n\n\n\nmain()\n\n\n\n", "s = input()\nt = input()\n\na =[]\nfor i in t:\n a.append(i)\na = a[::-1]\nb = ''\nfor i in a:\n b += i\nif b == s:\n print('YES')\nelse:\n print('NO')", "# a, b, c = map(int, input().split())\r\na = input()\r\nb = input()\r\n\r\nif a[::-1] == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "s = input()\nt = input()\n\na = t[::-1]\n\nif s == a:\n print('YES')\nelse:\n print(\"NO\")\n\n\n\t \t\t \t\t \t \t\t\t\t \t\t\t\t\t\t\t\t\t\t", "t1=input()\r\nt2=input()\r\nif t2[::-1]==t1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "print('YES' if str(input()) == str(input())[::-1] else 'NO')\r\n", "x = input()\ny = input()\nprint(\"YES\") if x == y[::-1] else print(\"NO\")\n \t \t\t \t \t \t\t \t\t \t \t", "s1=input()\r\ns2=input()\r\nrev=s2[::-1]\r\nif s1==rev:\r\n print('YES')\r\nelse:\r\n print('NO')", "'''\r\nfrom tkinter import *\r\nfrom tkinter import messagebox as mb\r\nfrom tkinter import filedialog\r\nw=Tk()\r\nw.title('window')\r\n\r\nw.geometry('500x200')\r\nrv=BooleanVar()\r\nrv1=IntVar()\r\ncv=DoubleVar()\r\ncv1=DoubleVar()\r\ncv2=DoubleVar()\r\ncv3=DoubleVar()\r\ncolor='white'\r\nsum=0\r\ndef color1():\r\n if rv1.get() == 0:\r\n color='blue'\r\n l.config(bg=color)\r\n elif rv1.get() == 1:\r\n color='red'\r\n l.config(bg=color)\r\n elif rv1.get()==2:\r\n color='green'\r\n l.config(bg=color)\r\ndef tasks():\r\n sum=cv.get()+cv1.get()+cv2.get()+cv3.get()\r\n l1.config(text=sum) \r\nr=Radiobutton(text= 'radiobutton 1',variable = rv,value = 1)\r\nr.place(x=10,y=3)\r\nr1=Radiobutton(text='radiobutton 2',variable = rv,value = 0)\r\nr1.place(x=100,y=3)\r\nrb=Radiobutton(text='blue',variable = rv1,value = 0,command=color1)\r\nrb.place(x=3,y=40)\r\nrb1=Radiobutton(text='red',variable = rv1,value = 1,command=color1)\r\nrb1.place(x=3,y=60)\r\nrb2=Radiobutton(text='green',variable = rv1,value = 2,command=color1)\r\nrb2.place(x=3,y=80)\r\nl=Label(width='30',height='10',bg='white')\r\nl.place(x=3,y=100)\r\nc1=Checkbutton(text='1 task',variable=cv,onvalue = 2.5,offvalue = 0,command = tasks)\r\nc1.place(x=300,y=20)\r\nc2=Checkbutton(text='2 task',variable=cv1,onvalue = 5,offvalue = 0,command = tasks)\r\nc2.place(x=300,y=40)\r\nc3=Checkbutton(text='3 task',variable=cv2,onvalue = 7.5,offvalue = 0,command = tasks)\r\nc3.place(x=300,y=60)\r\nc4=Checkbutton(text='4 task',variable=cv3,onvalue = 10,offvalue = 0,command = tasks)\r\nc4.place(x=300,y=80)\r\nl1=Label()\r\nl1.place(x=300,y=100)\r\n\r\ndef Loadfile():\r\n filename = filedialog.Open(w, filetypes = [('*.txt files', '.txt')]).show()\r\n if filename =='':\r\n return\r\n t.delite('1.0', 'end')\r\n t.insert('1.0', open(filename, 'rt').read())\r\ndef Savefile():\r\n filename = filedialog.SaveAs(w, filetypes = [('*.txt files', '.txt')]).show()\r\n if filename =='':\r\n return\r\n if not filename.endswith(\".txt\"):\r\n filename+=\".txt\"\r\n open(filename, 'wt').write(textbox.get('1.0', 'end'))\r\ndef quit():\r\n global w\r\n answer=mb.askyesno(\"quit?\",\"Quit?\")\r\n if answer==True:\r\n w.destroy()\r\npanel = Frame(w,height = 60,bg='gray')\r\npanel.pack(side='top', fill = 'x')\r\ntextframe = Frame(width=340, height = 600)\r\ntextframe.pack(side ='bottom',fill= 'both')\r\nt=Text(textframe,wrap = 'word')\r\nt.pack(side = 'left',fill='both')\r\nscroll = Scrollbar(textframe)\r\nscroll.pack(side = 'right',fill = 'y')\r\nscroll['command'] = t.yview\r\nt['yscrollcommand'] = scroll.set\r\nload=Button(panel,bg='purple',text='load',command = Loadfile)\r\nload.place(x=10,y=10,width=40,height=40)\r\nsave=Button(panel,bg='purple',text='save',command = Savefile)\r\nsave.place(x=50,y=10,width=40,height=40)\r\nquit=Button(panel,bg='purple',text='quit', command = quit)\r\nquit.place(x=600,y=10,width=40,height=40)\r\nw.mainloop()\r\n\r\ndef red():\r\n lb.config(text=code[0])\r\n lb2.config(text=color[0])\r\ndef ora():\r\n lb.config(text=code[1])\r\n lb2.config(text=color[1])\r\ndef ye():\r\n lb.config(text=code[2])\r\n lb2.config(text=color[2])\r\ndef gr():\r\n lb.config(text=code[3])\r\n lb2.config(text=color[3])\r\ndef blu():\r\n lb.config(text=code[4])\r\n lb2.config(text=color[4])\r\ndef blue2():\r\n lb.config(text=code[5])\r\n lb2.config(text=color[5])\r\ndef vio():\r\n lb.config(text=code[6])\r\n lb2.config(text=color[6])\r\nw.geometry('205x380')\r\nw.resizable(False,False)\r\nlb=Label(text='',font ='Arial,14', bg='#ffffff', width=20, height=2)\r\nlb.pack()\r\nlb2=Label(text='',font ='Arial,14', bg='#ffffff', width=20, height=2)\r\nlb2.pack()\r\ncode=['#FF0000','#FFA500', '#FFFF00' ,'#008000', '#0000FF', '#000080', '#4B0082']\r\ncolor=['красный', 'оранжевый', 'желтый', 'зелёный', 'голубой', 'синий', 'фиолетовый']\r\nbr=Button(bg=code[0], width=25, height=2, command=red)\r\nbr.pack()\r\nbo=Button(bg=code[1], width=25, height=2, command=ora)\r\nbo.pack()\r\nby=Button(bg=code[2], width=25, height=2, command=ye)\r\nby.pack()\r\nbb1=Button(bg=code[3], width=25, height=2, command=gr)\r\nbb1.pack()\r\nb1=Button(bg=code[4], width=25, height=2, command=blu)\r\nb1.pack()\r\nbv=Button(bg=code[5], width=25, height=2, command=blue2)\r\nbv.pack()\r\nb12=Button(bg=code[6], width=25, height=2, command=vio)\r\nb12.pack()\r\n\r\n\r\nimport random\r\nimport time\r\n\r\n\r\nsize = 500\r\nc=Canvas(w, width=size, height=size)\r\nc.pack()\r\nwhile True:\r\n col=choice(['pink', 'orange', 'purple', 'yellow', 'lime'])\r\n x0=randint(0, size)\r\n y0= randint(0, size)\r\n d= randint(0, size/5)\r\n c.create_oval(x0,y0,x0+d,y0+d,fill=col)\r\n w.update()\r\n\r\ndef Intro():\r\n print(Вы находитесь в земле, полной драконов.\r\nПеред собой, ты видишь две пещеры.\r\nВ одной пещере дракон дружелюбен и поделится с тобой своим сокровищем.\r\nДругой дракон жадный и голодный, и хочет тебя съесть.)\r\ndef choose():\r\n while True:\r\n a=int(input())\r\n if a!= 1 and a!=2:\r\n continue\r\n else:\r\n return a\r\ndef check_cave(choose):\r\n print(Вы приближаетесь к пещере...)\r\n time.sleep(2)\r\n print('Она тёмная и жуткая...)\r\n time.sleep(2)\r\n print('Большой дракон выпрыгивает прямо перед вами!')\r\n print('Он открывает свои челюсти и…')\r\n print('')\r\n time.sleep(2)\r\n b=random.randint(1,2)\r\n if b==choose:\r\n print('Это добрый!')\r\n else:\r\n print(\"Это злой!!!\")\r\ncheck=1\r\nwhile check==1:\r\n Intro()\r\n check_cave(choose())\r\n check=int(input('1-yes,0-no'))\r\n \r\nname=input()\r\nprint(\"Привет, я\",(name),\".\\nЯ изучаю Python.\\nЯ уже прошел много тем, а сейчас я прохожу строки.\")\r\nS=\"python\"\r\nS2=S * 7\r\nS3=S + S2\r\nprint(S,\"\\n\",S2,\"\\n\",S3)\r\n\r\ns=input()\r\nf=s[0]\r\nl=s[-1]\r\nn=s[1:-1]\r\n\r\nprint(l + n + f)\r\n\r\ns=input()\r\nns=s[::-1]\r\nprint(s,'->',ns)\r\n\r\ns=input()\r\ns1=s.find(' ')\r\nfw=s[:s1]\r\ns2=s.rfind(' ')\r\nsw=s[s1+1:s2]\r\ntw=s[s2+1:]\r\nns=sw.replace('a','A')\r\nprint(fw.count('a'))\r\nprint(ns)\r\nprint(len(tw))\r\n\r\ndef shifr(plaintext, key):\r\n alphabet=\"абвгдеёжзийклмнопрстуфхцчшщъыьэюя\"\r\n ciphrtext=\"\"\r\n for letter in plaintext:\r\n new_letter = (alphabet.find(letter.lower()) +key % len(alphabet))\r\n ciphrtext=ciphrtext + alphabet[new_letter]\r\n return ciphrtext\r\ndef deshifr(plaintext, key):\r\n alphabet=\"абвгдеёжзийклмнопрстуфхцчшщъыьэюя\"\r\n ciphrtext=\"\"\r\n for letter in plaintext:\r\n new_letter = (alphabet.find(letter.lower()) -key % len(alphabet))\r\n ciphrtext=ciphrtext + alphabet[new_letter]\r\n return ciphrtext\r\nwhile True:\r\n print('1 or 0?')\r\n g=input()\r\n if g=='1':\r\n word=input('слово ')\r\n k=int(input('сдвиг '))\r\n print(shifr(word, k))\r\n if g=='0':\r\n word=input('слово ')\r\n k=int(input('сдвиг '))\r\n print(deshifr(word, k))\r\n print('Continue?')\r\n x=input()\r\n if x!='yes':\r\n break\r\n\r\ns=input()\r\nif s.lower()=='up':\r\n print(s.upper())\r\nelif s.lower()=='down':\r\n print(s.lower())\r\nelse:\r\n print('EROR')\r\ns=input()\r\nif s.isupper()==False and s.islower()==False and s.isalnum()==True and s.isalpha()==False and s.isdigit()==False:\r\n print('good')\r\nelse:\r\n print('bad')\r\n\r\na=int(input())\r\nif a>2 and a%2==0:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \r\nk=0\r\nn=int(input())\r\nfor i in range(n):\r\n a=input()\r\n if a=='Tetrahedron':\r\n k+=4\r\n if a=='Cube':\r\n k+=6\r\n if a=='Octahedron':\r\n k+=8\r\n if a=='Dodecahedron':\r\n k+=12\r\n if a=='Icosahedron':\r\n k+=20\r\nprint(k)\r\n\r\nm=0\r\nnm=0\r\na=input().split()\r\nk=int(a[0])\r\ns=int(a[1])\r\nm=min(k,s)\r\nnm=abs(k-s)\r\nprint(m,nm//2)\r\n\r\nq=int(input())\r\nfor i in range(q):\r\n n,a,b=[int(k) for k in input().split()]\r\n if b<a*2:\r\n m=n//2\r\n s=b*m\r\n if n%2!=0:\r\n s+=a\r\n else:\r\n s=n*a\r\n print(s)\r\n\r\na=['*10','//10','/10','%10','*1','//1','/1','%1']\r\nb=['*10','//10','/10','%10','*1','//1','/1','%1']\r\nfrom tkinter import *\r\nfrom random import randint\r\ndef intDivBy10(): \r\n global numF\r\n numF //= 10\r\n num.config(text=str(numF))\r\ndef modOper10(): \r\n global numF\r\n numF %= 10\r\n num.config(text=str(numF))\r\ndef divBy10(): \r\n global numF\r\n numF /= 10\r\n num.config(text=str(numF))\r\ndef mulBy10(): \r\n global numF\r\n numF *= 10\r\n num.config(text=str(numF))\r\ndef intDivBy1(): \r\n global numF\r\n numF //= 1\r\n num.config(text=str(numF))\r\ndef modOper1(): \r\n global numF\r\n numF %= 1\r\n num.config(text=str(numF))\r\ndef divBy1(): \r\n global numF\r\n numF /= 1\r\n num.config(text=str(numF))\r\ndef mulBy1(): \r\n global numF\r\n numF *= 1\r\n num.config(text=str(numF))\r\ndef cancelOper():\r\n global numF\r\n global numF01\r\n numF = numF01\r\n num.config(text=str(numF))\r\n\r\n\r\n\r\n\r\n \r\ndef a1(): \r\n if numF==a[0]:\r\n num.config(text='YES')\r\ndef a2(): \r\n fhg\r\ndef a3(): \r\n fgh\r\ndef a4(): \r\n fgh\r\ndef a5(): \r\n fgh\r\ndef a6(): \r\n fgh\r\ndef a7(): \r\n fgh\r\ndef a8():\r\n fgh\r\nroot = Tk()\r\nroot.geometry('460x300')\r\nroot.title('N-я цифра числа')\r\nnumF=a[randint(0, 7)]\r\nnumF01=numF\r\nnum=Label(root, text=str(numF), font='Verdana 48')\r\nnum.grid()\r\nbtn10_1 = Button(root, text='// 10', width=7, font='Verdana 18', command=intDivBy10)\r\nbtn10_1.grid()\r\nbtn10_2 = Button(root, text='% 10', width=7, font='Verdana 18', command=modOper10)\r\nbtn10_2.grid()\r\nbtn10_3= Button(root, text='/ 10', width=7, font='Verdana 18', command=divBy10)\r\nbtn10_3.grid()\r\nbtn10_4 = Button(root, text='* 10', width=7, font='Verdana 18', command=mulBy10)\r\nbtn10_4.grid()\r\nbtn1_1 = Button(root, text='// 1', width=7, font='Verdana 18', command=intDivBy1)\r\nbtn1_1.grid()\r\nbtn1_2 = Button(root, text='% 1 ', width=7, font='Verdana 18', command=modOper1)\r\nbtn1_2.grid()\r\nbtn1_3 = Button(root, text='/ 1 ', width=7, font='Verdana 18', command=divBy1)\r\nbtn1_3.grid()\r\nbtn1_4 = Button(root, text='* 1 ', width=7, font='Verdana 18', command=mulBy1)\r\nbtn1_4.grid()\r\nbtn_cancel = Button(root, text='Отмена', font='Verdana 18',\r\n command=cancelOper)\r\nbtn_cancel.grid()\r\n\r\ndef player_move(event):\r\n x=y=0\r\n key=event.keysym\r\n if key==\"Up\":\r\n y=-4\r\n if key==\"Down\":\r\n y=4\r\n if key==\"Left\":\r\n x=-4\r\n if key==\"Right\":\r\n x=4\r\n cv.move(player,x,y)\r\n for wall in walls:\r\n if player in cv.find_overlapping(wall[0], wall[1], wall[2], wall[3]):\r\n cv.move(player,-x,-y)\r\n for e in exits:\r\n if player in cv.find_overlapping(e[0], e[1], e[2], e[3]):\r\n cv.create_text(400, 350, text='WIN!',fill='purple')\r\n\r\n \r\n \r\n \r\nfrom tkinter import *\r\nw=Tk()\r\nw.title('labs')\r\ncv=Canvas(w, height=304, width=480)\r\ncv.pack()\r\nlevel=[\"wwwwwwwwwwwwwwwwwwwwwwwww\",\r\n \"w w\",\r\n \"wwww ww wwwwwwwwww w w\",\r\n \"wwww wwwwwwwwwwww ww w\",\r\n \"w w wwwwwwwwww w wwww\",\r\n \"w ww www ww ww www ww\",\r\n \" wwwww wwww wwwwww\",\r\n \"www www w wwwwwww\",\r\n \"w wwwwww ww wwwwww\",\r\n \"wwww wwwwwwwwwww wwwwww\",\r\n \"wwww wwwwwwwwwww wwwwww\",\r\n \"w wwwwww\",\r\n \"ww wwwwwwwwwwwwwwwwwwwww\",\r\n \"wweewwwwwwwwwwwwwwwwwwwww\"]\r\n\r\nplayer=cv.create_rectangle(17,17,31,31,fill='lime')\r\nwalls=[]\r\nexits=[]\r\nx=0\r\ny=0\r\nfor i in level:\r\n for m in i:\r\n if m=='w':\r\n cv.create_rectangle(x,y,x+16,y+16,fill='black')\r\n walls.append((x,y,x+16,y+16))\r\n if m=='e':\r\n cv.create_rectangle(x,y,x+16,y+16,fill='red')\r\n exits.append((x,y,x+16,y+16)) \r\n x+=16\r\n y+=16\r\n x=0\r\ncv.bind_all('<Key>', player_move)\r\nfrom math import ceil\r\nm, n=[int(i) for i in input().split()]\r\nx=m*n\r\ny=x//2\r\nprint(y)\r\nx=0\r\nn=int(input())\r\nfor i in range(n):\r\n c=input()\r\n if '+' in c:\r\n x+=1\r\n elif '-' in c:\r\n x-=1\r\nprint(x)\r\n\r\nm, n=[int(i) for i in input().split()]\r\nfor i in range(n):\r\n if str(m)[-1]=='0':\r\n m=m//10\r\n else:\r\n m-=1\r\nprint(m)\r\n\r\nfrom math import ceil\r\nm, o, c=[int(i) for i in input().split()]\r\ns, a, b=[int(i) for i in input().split()]\r\nn=int(input())\r\ng=m+o+c\r\nh=s+a+b\r\nx=ceil(g/5)\r\ny=ceil(h/10)\r\nj=x+y\r\nif j>n:\r\n print('NO')\r\nelse:\r\n print('YES')\r\nn=int(input())\r\nprint(25)\r\n\r\ns=input()\r\nb=input()\r\nif s.lower()>b.lower():\r\n print('1')\r\nelif b.lower()>s.lower():\r\n print('-1')\r\nelse:\r\n print('0')\r\n\r\ns=input()\r\nif '1111111' in s or '0000000' in s:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\nn=int(input())\r\nk=0\r\nfor i in range(n):\r\n m, o=[int(i) for i in input().split()]\r\n if o-m>=2:\r\n k+=1\r\nprint(k)\r\n'''\r\nx=''\r\ns=input()\r\nb=input()\r\nfor i in range(1,len(s)+1):\r\n x=x+s[-i]\r\nif x==b:\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", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Mar 24 10:05:49 2023\r\n\r\n@author: Srusty Sahoo\r\n\"\"\"\r\n\r\ns=input()\r\nt=input()\r\nif t==\"\".join(reversed(s)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "line1 = list(str(input()))\r\nline2 = list(str(input()))\r\nif list(reversed(line1)) != line2:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "s = input()\r\nt = input()\r\ncheck = True\r\nif len(s) == len(t):\r\n for i in range(len(s)):\r\n if s[i] != t[-i-1]:\r\n check = False\r\nelse:\r\n check = False\r\nif check:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#code\r\na = input()\r\nb = a[::-1]\r\nprint(\"YES\" if(b==input()) else \"NO\")", "s=input()\r\nt=input()\r\nq=t[::-1]\r\nif q==s:\r\n print('YES')\r\nelse:\r\n print('NO')", "# Read input\ns = input().strip()\nt = input().strip()\n\n# Check if t is the reverse of s\nif t == s[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \t \t\t \t \t\t \t\t \t\t \t \t \t\t\t\t", "s=input()\r\nt=input()\r\nprint(['NO','YES'][s==t[::-1]])\r\n", "string = input()\nrevstring = input()\nif(string[::-1] == revstring[::]):\n print(\"YES\")\nelse:\n print(\"NO\")", "texta= input()\r\ntext = texta[::-1]\r\ntextb= input()\r\nif text== textb:\r\n print('YES')\r\nelse:\r\n print('NO')", "s1 = input()\r\ns2 = input()\r\nn = len(s1)\r\nn2 = len(s2)\r\nc = 0\r\nif n == n2:\r\n for i in range(n):\r\n if s1[i] == s2[(n - 1) - i]:\r\n continue\r\n else:\r\n c += 1\r\n if c > 0:\r\n print('NO')\r\n else:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\r\n", "s=input()\nt=input()\na=[]\nfor i in range(len(s)):\n a.append(s[len(s)-1-i])\nb=''.join(a)\nif t==b:\n print('YES')\nelse:\n print('NO') \n\n", "str = input()\nstrev = input()\nrev = str[::-1]\n\n\nif rev==strev:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t \t\t\t \t \t \t\t\t \t \t\t \t \t \t", "# x = int(input(\"Marks in First Exam: \"))\r\n# y = int(input(\"Marks in Second Exam: \"))\r\n# z = int(input(\"Marks in Third Exam: \"))\r\n# a = x + y + z\r\n# b = a/3\r\n# print(b)\r\na = input()\r\nb = input()\r\na = a[::-1]\r\nif(a==b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "s = input()\nt = input()\ncount = 0\nif len(s) == len(t):\n for i in range(len(s)):\n if s[i] == t[-1-i]:\n count += 1\n else:\n count = 0\n if count == len(s):\n print('YES')\n else:\n print('NO')\nelse:\n print('NO')\n\n", "s=input()\r\nc=input()\r\nif s==c[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\" NO\") ", "s=input()\r\nt=input()\r\nc=\"\"\r\nfor i in s:\r\n c=i+c\r\nif(c==t):\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\nres = 'NO'\r\nif s == t[::-1]:\r\n res = 'YES'\r\nprint(res)\r\n", "n = input()\r\na = input()\r\nr = ''\r\nfor i in range(len(n) - 1, -1, -1):\r\n r = r + n[i]\r\nif r == a:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "#https://codeforces.com/problemset/problem/41/A\n\nprint('YES') if input()==''.join(reversed(input())) else print('NO') ", "s1=input()\ns2=input()\nbol=True\nif len(s1)!=len(s2):\n\tprint(\"NO\")\nelse:\n\tfor i in range(len(s1)):\n\t\tif s1[i]!=s2[len(s1)-i-1]:\n\t\t\tbol=False\n\t\t\tbreak\n\tif bol==False:\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n\n\n\n\n\n\t\t \t\t\t\t \t \t\t \t\t\t\t\t\t\t \t\t\t \t", "a = list(input()); b = list(input())\r\nb.reverse()\r\nprint([\"NO\", \"YES\"][a == b])", "c1 = str(input())\r\nc2 = str(input())\r\nc3 = []\r\nc4 = []\r\nfor x in c1:\r\n c3.append(x)\r\nfor x in c2:\r\n c4.append(x)\r\n\r\nrev = ''.join(reversed(c4))\r\nsh = ''.join(c3)\r\nif rev == sh:\r\n print(\"YES\")\r\n \r\nelse:\r\n print(\"NO\")", "str1 = input()\nstr2 = input()\n\nif str2 == str1[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "str=input()\r\nn=input()\r\nx=str[::-1]\r\nif x==n:\r\n print ( \"YES\")\r\nelse:\r\n print(\"NO\")", "p=input()\r\nq=input()\r\nr=''.join(list(reversed(p)))\r\nprint('YES' if q==r else 'NO')", "a=input()\r\nb=input()\r\nl=len(a)\r\nif len(a)==len(b):\r\n for i in range (l):\r\n if a[i]!=b[(l-1)-i]:\r\n print(\"NO\")\r\n break\r\n else:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\nb = input()\nif a[::-1] == b:\n\tprint('YES')\nelse:\n\tprint('NO')", "#!/bin/python3\nline = input()\nliner = input()\n\nif line == liner[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s=input();print(\"YES\"if input()==s[::-1]else\"NO\")", "s, t=input(), input()\nif t==s[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n# Thu Oct 28 2021 18:34:50 GMT+0000 (Coordinated Universal Time)\n", "import sys\ninput = sys.stdin.readline\n\n'''\n\n'''\n\ndef good(s, t):\n return s[::-1] == t\n\ns = input().rstrip()\nt = input().rstrip()\n\nif good(s, t):\n print(\"YES\")\nelse:\n print(\"NO\")", "T=input()\r\nS=input()\r\nif(T==S[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "str = input()\r\nrev = input()\r\nstr = str[::-1] #reversing the string\r\nif str == rev:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = input()\r\nx = n[::-1]\r\nm = input()\r\nif m == x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nlist1=[]\r\nfor i in s:\r\n list1.append(i)\r\n \r\nlist1.reverse()\r\n\r\nt=input()\r\nlist2=[]\r\nfor k in t:\r\n list2.append(k)\r\n \r\nif(list1==list2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nfor i in range(1, len(s)+1):\r\n if s[i-1] == t[-i]:\r\n ans = \"YES\"\r\n else:\r\n ans = \"NO\"\r\n break\r\nprint(ans)", "s1 = input()\r\ns2 = input()\r\n\r\nlen1 = len(s1)\r\nlen2 = len(s2)\r\n\r\nif len1 != len2:\r\n print(\"NO\")\r\nelse:\r\n hasDif = False\r\n i1 = 0\r\n i2 = len2 - 1\r\n while i1 < len1:\r\n if s1[i1] != s2[i2]:\r\n hasDif = True\r\n break\r\n\r\n i1 += 1\r\n i2 -= 1\r\n\r\n if hasDif:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n", "def fun(string1,string2):\r\n lent=len(string1)\r\n for i in range(lent):\r\n if(string1[i]==string2[-1-i]):\r\n pass\r\n\r\n else:\r\n return \"NO\"\r\n\r\n return \"YES\"\r\n\r\nif __name__ == '__main__':\r\n string1=input()\r\n string2=input()\r\n print(fun(string1,string2))", "n=[str(i) for i in input()]\r\nt=[str(i) for i in input()]\r\nn.reverse()\r\nif n==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "input_str1 = input()\r\ninput_str2 = input()\r\nreversed_str = input_str1[::-1]\r\n\r\nif reversed_str == input_str2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a = input()\r\nb = input()\r\n\r\nans = 'YES'\r\n\r\nnew = ['']*len(a)\r\nfor i in range(len(a)):\r\n new[i] = a[len(a) - i - 1]\r\n\r\nfor i in range(len(a)):\r\n if new[i] != b[i]:\r\n ans = 'NO'\r\n break\r\n\r\nprint(ans)", "n=input()\r\nt=input()\r\nn1=\"\".join([n[len(n)-1-i] for i in range(len(n))])\r\nif t==n1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\nc=0\r\nif len(a)!=len(b):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(a)):\r\n if a[i]==b[len(a)-i-1]:\r\n c+=1\r\n if c==len(a):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n \r\n \r\n", "\r\ns = input()\r\nss = input()\r\na = list(reversed(s))\r\nb = \"\".join(a)\r\nif b == ss:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "s=input()\r\nt=input()\r\nif t==s[::-1]: print('YES')\r\nelse: print('NO')\r\n", "n=input()\r\nb=input()\r\nl=b[::-1]\r\nif n==l:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = str(input())\nt = str(input())\nreversedi = list(s)\nfor i in range(0,int(len(reversedi) / 2)):\n reversedi[i],reversedi[(len(reversedi) - 1) - i] = reversedi[(len(reversedi) - 1) - i],reversedi[i]\n \n\na = \"\"\nfor i in reversedi:\n a += i\n\nif (a == t):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "def solve(st1, st2):\r\n chars1 = [*st1]\r\n chars2 = [*st2]\r\n index = len(chars2)-1\r\n for x in chars1:\r\n if (x != chars2[index]):\r\n return \"NO\"\r\n index = index-1\r\n continue\r\n return \"YES\"\r\n\r\nstr1 = str(input())\r\nstr2 = str(input())\r\n\r\nprint(solve(str1, str2))", "a=input()\r\nb=input()\r\na=a[-1: :-1]\r\nif(a==b):print(\"YES\")\r\nelse:print(\"NO\")", "s = str(input()).lower()\r\nb = str(input()).lower()\r\na = []\r\nc = []\r\nc.append(s)\r\na.append(b[::-1])\r\nif c == a:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\r\n#number 1\r\n#n = int(input())\r\n#b = str(input()).upper()\r\n#if b.count('A') > b.count('D'):\r\n# print('Anton')\r\n#elif b.count('A') < b.count('D'):\r\n# print('Danik')\r\n#else:\r\n# print('Friendship')\r\n", "berland=input()\r\nbirland=input()\r\nif (berland[0:len(berland)]==birland[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\nk=[]\r\nn=len(a)\r\nfor i in range(0,n):\r\n k.append(a[n-i-1])\r\nc=\"\".join(k)\r\nif(c==b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nd=input()\r\nif a==d[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s1 = input()\r\ns2 = input()\r\nn1 = len(s1)\r\nn2 = len(s2)\r\ni = 0\r\nj = n2 - 1\r\ncount = 0\r\nif len(s1) == len(s2):\r\n while i < n1 and j >= 0:\r\n if s1[i] == s2[j]:\r\n i += 1\r\n j -= 1\r\n count += 1\r\n else:\r\n break\r\n if count == n1:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\nelse:\r\n print(\"NO\")", "a = str(input())\r\nb = str(input())\r\nc = b[::-1]\r\nif(a == c):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nx=input()\r\nif s[::-1] == x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\ndef my_function(t):\r\n\r\n if t[::-1] == s:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n\r\nmytxt = my_function(t)\r\n\r\nprint(mytxt)\r\n", "s = input()\r\nw = input()\r\nif w == s[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nList=[0] *len(s)\r\nList_1=[0]*len(s)\r\nif len(s)==len(t) :\r\n\tfor i in range(len(s)) :\r\n\t\tList[i] =s[i] \r\n\t\tList_1[i]=t[i]\r\n\tList.reverse()\r\n\tcount=0\r\n\tfor k in range(len(s)) :\r\n\t\tif List[k] ==List_1[k]:\r\n\t\t\tcount+=1\r\n\tif count==len(s) :\r\n\t\tprint(\"YES\") \r\n\telse:\r\n\t\tprint(\"NO\") \r\nelif len(s)!=len(t) :\r\n\tprint(\"NO\") ", "a=list(input())\r\nb=input()\r\nd=a[::-1]\r\nc=''.join(d)\r\nif c==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def reverse(string):\r\n string = string[::-1]\r\n return string\r\ns=input()\r\nt=input()\r\nif(reverse(s)==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nresult=input()\r\nif result==s[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\nt=input()\nS=list(s)\nS.reverse()\nk=''\nfor i in range(len(S)):\n k+=S[i]\nif k==t:\n print(\"YES\")\nelse:\n print(\"NO\")", "in_mess_a = input()\r\nin_mess_b = input()\r\n\r\nreverse_a = in_mess_a[::-1]\r\ncount = 0\r\nif len(in_mess_a) == len(in_mess_b):\r\n for i in range(len(in_mess_a)):\r\n if reverse_a[i] == in_mess_b[i]:\r\n count+=1\r\nif count == len(in_mess_a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\nb1 = ' '\r\ni = 0\r\nif(len(a)!= len(b)):\r\n print(\"NO\")\r\nelse:\r\n for j in reversed(b):\r\n if(j != a[i]):\r\n break\r\n i += 1\r\n if(i != len(a)):\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n", "str=input()\r\nstr1=input()\r\ntemp=str[::-1]\r\nif str1==temp:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nk = \"\"\r\nfor j in range(len(s)-1,-1,-1):\r\n k += s[j]\r\nif k == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=list(input())\r\nb=list(input())\r\na.reverse()\r\nif a==b :print('YES')\r\nelse:print('NO')\r\n", "def solve4(s,a):\r\n f=\"\".join(list(reversed(a)))\r\n if s==f:return(\"YES\")\r\n return(\"NO\")\r\ns=str(input())\r\na=str(input())\r\nprint(solve4(s,a))", "string1=input()\r\nstring2=input()\r\nn=len(string2)\r\ntemp=\"\"\r\nfor i in range(n):\r\n temp+=string2[-i-1]\r\nif string1==temp:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "sf, sr = input(), input()\r\nif sf[::-1] == sr:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = list(input())\r\nn = list(input())\r\nb = ''\r\nc = ''\r\nd = len(a)\r\nfor i in range(d):\r\n b += a[i]\r\nfor i in range(len(n)-1,-1,-1):\r\n c += n[i]\r\nif b == c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "first=input()\r\nfirst=list(first)\r\nsecond=input()\r\nanswer=\"YES\"\r\nif len(first)==len(second):\r\n for x in range(len(second)):\r\n letter=first.pop()\r\n if letter!=second[x]:\r\n answer=\"NO\"\r\nelse:\r\n answer=\"NO\"\r\nprint(answer)", "s = input()\ns1 = []\n\nt = input()\n\nfor i in s:\n s1.append(i)\n\ns1.reverse()\n\ns = \"\".join(s1)\n\nif s == t:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "str1=input()\r\nstr2=input()\r\nrev=\"\"\r\nl=len(str1)\r\nt=l-1\r\nfor i in range(t,-1,-1):\r\n rev+=str1[i]\r\nif rev==str2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "import math\r\n\r\na = {}\r\n#n = int(input())\r\nc = 0\r\nb = input()\r\ni = 0\r\nj = 0\r\n\r\narr = input()\r\n\r\n\r\n#for i in range(n):\r\n# a.append([int(j) for j in input().split()])\r\n \r\n#a, b, c = map(int, input().split())\r\n\r\nc = len(b)\r\nfor i in range(c):\r\n if arr[i] != b[c - i - 1]:\r\n print(\"NO\")\r\n break\r\n j += 1\r\n\r\nif j == c:\r\n print(\"YES\")\r\n ", "s = input()\r\nt = input()\r\n\r\nif len(s) < 1 or len(s) > 100:\r\n pass\r\n\r\nelse:\r\n if s == t[::-1]:\r\n print(\"YES\")\r\n\r\n else:\r\n print(\"NO\")", "a = input()\r\nb = list(input())\r\nb.reverse()\r\nb = \"\".join(b)\r\nif a == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "if(list(input()) == list(reversed(input()))):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def main():\r\n s = input() \r\n t = input() \r\n vex = list(t) \r\n vex.reverse() \r\n t = ''.join(map(str, vex))\r\n #print(t)\r\n if t ==s:\r\n print('YES') \r\n else:\r\n print('NO')\r\n\r\nif __name__=='__main__':\r\n main()", "og = list(input())\r\nog = [ch for ch in og]\r\n\r\nnew = []\r\nfor i in range (1, len(og)+1):\r\n new.append(og[-i])\r\n\r\nog2 = list(input())\r\nog2 = [ch for ch in og2]\r\n\r\nif new == og2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "def reverse(s):\n str = \"\"\n for i in s:\n str = i + str\n return str\nstr1 = input()\nstr2 = input()\nif str2 == reverse(str1):\n print('YES')\nelse:\n print('NO')\n\t\t \t\t\t \t \t\t\t\t \t \t \t\t\t", "x=str(input())\r\ny=str(input())\r\ny=y[::-1]\r\nif x==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "k=input()\r\nl=input()\r\nif(k[::-1]==l[::]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import sys\r\nfrom array import array # noqa: F401\r\n\r\n\r\ndef input():\r\n return sys.stdin.buffer.readline().decode('utf-8')\r\n\r\n\r\ns = input().rstrip()\r\nt = input().rstrip()[::-1]\r\nprint('YES' if s == t else 'NO')\r\n", "s=input()\r\ns1=input()\r\nrs=s[::-1]\r\nif rs==s1:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "x=list(input())\r\ny=list(input())\r\nz=list(reversed(x))\r\nif z==y:\r\n print('YES')\r\nelse:\r\n print('NO')", "org = input()\r\nrev = input()\r\n\r\norg = org[::-1]\r\nif org == rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=(input())\r\nt=(input())\r\nr=t[::-1]\r\nif r==s:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n ", "str_1 = input()\r\nstr_2 = input()\r\nstr_r = str_1[::-1]\r\nif str_2 == str_r:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "my_word = input()\r\nmy_reversed_word = input()\r\n\r\nword_reverse = my_word[::-1]\r\nif my_reversed_word == word_reverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "k = input()\r\nh = input()\r\ns = k[::-1]\r\nif(h==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\ns1 = input()\r\ns2 = ''\r\nfor i in range(len(s)):\r\n s2 = s[i] + s2\r\nif s2 == s1:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a = input ()\nb = input ()\nif a == b [::-1]:\n print (\"YES\")\nelse :\n print (\"NO\")\n \n \t\t \t \t \t \t\t\t\t \t \t\t\t \t \t\t\t\t", "class input_t:\r\n t = \"\"\r\n s = \"\"\r\n\r\nclass output_t:\r\n pass\r\n\r\n\r\ndef test_input():\r\n f = input_t()\r\n import random\r\n t = random.randint(1,10)\r\n for i in range(t):\r\n word = chr(random.randint(ord('a'), ord('z')))\r\n f.s+= word\r\n return f\r\n\r\ndef read_input():\r\n f = input_t\r\n f.s = input()\r\n f.s = f.s[::-1]\r\n f.t = input()\r\n return f\r\n\r\ndef solve(in_data):\r\n g = in_data\r\n if g.s == g.t :\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\n\r\n\r\n\r\ndef write_output(out_data):\r\n pass\r\n\r\ndef main():\r\n #in_data = test_input()\r\n #print(\"in_data:\", in_data)\r\n in_data = read_input()\r\n #print(\"in_data:\", in_data)\r\n out_data = solve(in_data)\r\n #print(\"out_data:\", out_data)\r\n #write_output(out_data)\r\n\r\nif __name__ == \"__main__\":\r\n main()", "i = input()\r\nn = input()[::-1]\r\nif i == n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nx=input()\r\na=s[::-1]\r\nif a==x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# count = 0\r\n# def something(count):\r\n# if(count == 5):\r\n# return\r\n# else:\r\n# count = count + 1 \r\n# print(\"Aarnick\")\r\n# something(count) \r\n# something(count)\r\n\r\n#n = list(map(str, input().split(\" \")))\r\n\r\ns = input()\r\nt = input()\r\nif s == t[::-1]:\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\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n ", "y = \"\"\r\ninp = input();\r\ninp2=input();\r\nfor i in range(len(inp)-1,-1,-1):\r\n y+=inp[i];\r\nif(inp2==y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=(input())\r\nb=input()\r\nc=list(b)\r\nc.reverse()\r\nd=\"\".join(c)\r\nif a==d:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Mar 17 11:39:50 2021\n\n@author: noname\n\"\"\"\n\na = str(input())\nb = str(input())\n\nif a == b[::-1]:\n print('YES')\nelse:\n print('NO')", "s = str(input())\r\na = str(input())\r\ns = s[::-1]\r\nif s == a and len(s)<=100 and len(s)>0:\r\n print(\"YES\")\r\nelif len(s)>100:\r\n print(\"NO\") \r\nelse:\r\n print(\"NO\") ", "str0 = input (\"\")\r\nstr1= input(\"\")\r\nstr2 = str0[::-1]\r\nif str2 == str1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "txt1 = str(input())\r\ntxt2 = str(input())\r\ntxtfinal = []\r\n\r\nfor i in range(1, len(txt1)+1):\r\n txtfinal.append(txt1[-i])\r\ntxtfinal = ''.join(txtfinal)\r\n\r\nif txtfinal == txt2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "import sys \r\n\r\ndef gets(): return sys.stdin.readline().strip()\r\n\r\nif gets() == ''.join(reversed(gets())):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def is_translation(a, b):\r\n return a == b[::-1]\r\n\r\n\r\nif __name__ == '__main__':\r\n a = input().strip()\r\n b = input().strip()\r\n print (\"YES\" if is_translation(a, b) else \"NO\")\r\n", "s = input()\r\nt = input()\r\nrev = s[len(s)::-1]\r\nprint(\"YES\" if t == rev else \"NO\")", "st1=input()\r\nst2=input()\r\nrev=st1[::-1]\r\nif(rev==st2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=list(input())\r\ns.reverse()\r\nif(\"\".join(s)==input()):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# your code goes here\r\ns = input()\r\nt = input()\r\nq = s[::-1]\r\nif q == t:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint('NO')", "def reverse(s): \r\n str = \"\" \r\n for i in s: \r\n str = i + str\r\n return str\r\nt=input()\r\ns=input()\r\nif(t==reverse(s)):\r\n \tprint(\"YES\")\r\nelse:\r\n \tprint(\"NO\")\r\n", "t = input()\r\ns = input()[::-1]\r\nprint(\"YES\") if t==s else print(\"NO\")", "n1 = input()\r\nn2 = input()\r\nif n1==n2[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a = input()\r\nb = input()\r\na = list(a)\r\nfor i in range(0,(len(a)//2)):\r\n a[i],a[len(a) - i -1] = a[len(a)-i-1],a[i]\r\n\r\nempty = ''\r\nfor i in range(0,len(a)):\r\n empty += a[i]\r\n\r\nif b == empty:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n ", "def f(x,y):\r\n if x == y[::-1]: return 'YES'\r\n return 'NO'\r\nprint(f(input(),input()))", "try:\r\n s = input()\r\n t = input()\r\n reversed = ''.join(reversed(s))\r\n if(reversed == t):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\nexcept: pass", "def string_rev(input_str):\r\n return input_str[::-1]\r\nname1 = str(input())\r\nname2 = str(input())\r\nname3 = string_rev(name2)\r\n\r\nif(name3 == name1):\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")", "a=[]\r\nb= input()\r\nfor i in range(len(b)):\r\n a.append(b[i])\r\nc=[]\r\nd= input()\r\nfor i in range(len(d)-1,-1,-1):\r\n c.append(d[i])\r\nif(c==a):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "print(['NO','YES'][(''.join(reversed(input())))==input()])\r\n", "s = input()\r\nt = input()\r\n\r\na = list(s)\r\nb = ''.join(a[::-1])\r\n\r\nif b == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=list(input())\r\nx=list(input())\r\ns.reverse()\r\nif s==x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "x=str(input())\r\nz=str(input())\r\nx_inverse=x[::-1]\r\nif z==x_inverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=str(input()); t=input()\r\nx=list(s);x.reverse(); a=\"\".join(x)\r\nif (t == a):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n\r\n", "string = input()\r\nb = input()\r\nif string[::-1]==b:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "n=input()\r\nm=input()\r\nres=''\r\nfor i in range(len(m)-1,-1,-1):\r\n res+=m[i]\r\nif res==n:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=input()\r\nb=input()\r\nprint([\"NO\",\"YES\"][a.lower()[::-1]==b.lower()])\r\n\r\n \r\n", "S = input()\r\nT = input()\r\nTr = ''\r\nfor i in range(0, len(T)):\r\n\tTr = T[i] + Tr\r\nif S == Tr: print('YES')\r\nelse: print('NO')", "a = input().lower()\nb = input().lower()\nprint(\"YES\" if a==''.join(reversed(b)) else \"NO\")", "def translation(word,wordr):\r\n if word[::-1]!=wordr:\r\n return'NO'\r\n else:\r\n return'YES'\r\na=input()\r\nb=input()\r\nprint(translation(a,b))", "straight=input()\r\nreverse=input()\r\n\r\nif straight[0:]==reverse[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input())\r\nt = str(input())\r\nm = s[::-1]\r\nif m == t:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n", "# Read input words\r\nword_s = input().strip()\r\nword_t = input().strip()\r\n\r\n# Check if word_s is the reverse of word_t\r\nif word_s == word_t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nflag = 1\r\nfor i in range(len(s)):\r\n if s[i]!=t[len(t)-1-i]:\r\n flag = 0\r\n break\r\nif flag ==1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "n=input()\r\nm=input()\r\ns=n[::-1]\r\nif(m==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Jun 21 19:56:40 2022\r\n\r\n@author: Isaac\r\n\"\"\"\r\n\r\ns = input()\r\nt = input()\r\ns1 = s[::-1]\r\nif t == s1:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nflag=\"YES\" if s[::-1]==t else \"NO\"\r\nprint(flag)\r\n", "input1 = input()\ninput2 = input()\nif input2 == input1[::-1]:\n print(\"YES\")\nelse: \n print(\"NO\")\nquit()\n \t\t \t \t\t\t \t\t \t \t\t \t \t \t", "a=input()\r\nc=input()\r\nb=(a[::-1])\r\nif(c==b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "L=input()\r\nE=input()\r\nif(L[::-1]==E):\r\n print('YES')\r\nelse:\r\n print('NO')", "# let's not use the built-in function, reverse()\ndef main():\n s = input()\n t = input()\n\n if len(t) != len(s):\n print(\"NO\")\n return\n\n for i in range(len(s)):\n if s[i] != t[len(t) - 1 - i]:\n print(\"NO\")\n return\n\n print(\"YES\")\n \n\nif __name__ == \"__main__\":\n main()\n", "s=list(input())\r\nt=list(input())\r\ns.reverse()\r\nif s==t: print(\"YES\")\r\nelse: print(\"NO\")", "s=input()\nt=input()\ntq=''\nfor i in range(len(t)):\n tq+=t[len(t)-i-1]\nif s==tq:\n print('YES')\nelse:\n print('NO')", "str1_arr = [c for c in input()]\r\nstr2_arr = [a for a in input()]\r\nstr2_arr.reverse()\r\nif str1_arr == str2_arr:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1 = input()\r\nstr2 = input()\r\nres = \"\"\r\nfor i in str1:\r\n res = i + res\r\nif res == str2:\r\n print(\"YES\")\r\nelse:\r\n print('NO')", "normalT = str(input())\nreverseT = str(input())\nreverseR = []\nfor x in range(len(reverseT)):\n reverseR.append(reverseT[x])\nreverseR2 = str()\nfor x in range(len(reverseR)-1,-1,-1):\n reverseR2 += reverseR[x]\nif(normalT == reverseR2):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "i = input()\r\nj = input()\r\nif i[::-1] == j:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "a=input()\r\nb=input()\r\n\r\nif len(a)!=len(b):\r\n print(\"NO\")\r\nelse:\r\n t=0\r\n for x in range(len(a)):\r\n if a[x]==b[-(x+1)]:\r\n t+=1\r\n if t==len(a):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "n=str(input())\r\ne=str(input())\r\ns=n[::-1]\r\nif(e==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def main():\n s = input()\n t = input()\n s_rev = \"\".join(reversed(s))\n # s_rev = s[::-1]\n if s_rev == t:\n print(\"YES\")\n else:\n print(\"NO\")\n\nif __name__ == \"__main__\":\n main()", "T=input()\r\nP=input()\r\nif(T==P[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\ns = input()\nS = input()\n\nif(all([s[::1]==S[::-1]])):\n print('YES')\nelse:\n print('NO')", "s = input()\r\nst = input()\r\nx = s[::-1]\r\nif st == x :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "string=input()\nrevstr=input()\nnewstr=''\nfor i in range(len(string)-1,-1,-1):\n\tnewstr+=string[i]\nif revstr==newstr:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "s=input()\r\ns=s[::-1]\r\nif s==input():\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\r\nt = input()\r\nt2 = s[::-1]\r\nif(t == t2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# check if input a ( code ) is revesly = to input b (edoc)\r\nmy_list = []\r\n\r\nfor _ in range(2):\r\n user_input = input()\r\n my_list.append(user_input)\r\n\r\n\r\nreversed_word = my_list[1]\r\nif my_list[0] != reversed_word[::-1]:\r\n print('NO')\r\n\r\nelif my_list[0] == reversed_word[::-1]:\r\n print('YES')\r\n\r\n\r\n\r\n# print(my_list)\r\n# print(my_list[::-1])\r\n# print(my_list[1].reversed())\r\n# if my_list[0] == my_list[1::-1]:\r\n# print(True)", "a = input()\nb = input()\nlst = []\nfor i in b:\n lst.append(i)\nlst.reverse()\nif ''.join(lst)==a:\n print('YES')\nelse:\n print('NO')", "s=input()\nt=input()\nrev=s[::-1]\nif(rev==t):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t \t\t\t \t\t \t \t \t\t\t \t\t \t\t", "s = input()\r\na = input()\r\nl = s [::-1]\r\nif l == a:\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")\r\n", "s = input()\r\nt = input()\r\n\r\ndef solve(s,t):\r\n return \"YES\" if s[::-1]==t else \"NO\"\r\n \r\nprint(solve(s,t))", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sun Oct 18 08:42:11 2020\r\n\r\n@author: 赵泽华\r\n\"\"\"\r\n\r\ns=str(input())\r\nt=str(input())\r\n\r\ntrans=list(s)\r\ntrans.reverse()\r\ntranslate=str(\"\".join(trans))\r\n\r\nif translate==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def is_reverse(s, t):\r\n return t == s[::-1]\r\n\r\n# Read input\r\ns = input()\r\nt = input()\r\n\r\n# Check if t is the reverse of s\r\nresult = \"YES\" if is_reverse(s, t) else \"NO\"\r\n\r\n# Print the output\r\nprint(result)\r\n", "input_list = []\r\nnum = 0\r\nwhile True:\r\n if num == 2:\r\n break\r\n line = input()\r\n # line = line.split()\r\n # line = list(map(int, line))\r\n input_list.append(line)\r\n num += 1\r\n\r\n# input_list.__delitem__(0)\r\n\r\nrev = input_list[0][::-1]\r\n\r\nif input_list[1] == rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "inp1 = input()\r\ninp2 = input()\r\n\r\none = list()\r\ntwo = list()\r\nfor letter in inp1:\r\n one.append(letter)\r\nfor letter in inp2:\r\n two.append(letter)\r\none.reverse()\r\nif one == two:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\r\n\r\n\r\n", "word=input()\r\ntranslation=input()\r\ncom=word[::-1]\r\nif com==translation:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def Bitplus():\r\n n = int(input())\r\n x = 0\r\n for i in range(n):\r\n a = input()\r\n if \"+\" in a:\r\n x += 1\r\n else:\r\n x -= 1\r\n print(x)\r\n\r\ndef GiftSetidk():\r\n n = int(input())\r\n for i in range(n):\r\n all = input().split(\" \")\r\n x = int(all[0])\r\n y = int(all[1])\r\n a = int(all[2])\r\n b = int(all[3])\r\n counter = 0\r\n count = True\r\n while count:\r\n if x >= a and y >= b:\r\n x -= a\r\n y -= b\r\n counter += 1\r\n elif x >= b and y >= a:\r\n x -= b\r\n y -= a\r\n counter += 1\r\n else:\r\n count = False\r\n print(counter)\r\n\r\n\r\ndef Team():\r\n n = int(input())\r\n problemcount = 0\r\n for i in range(n):\r\n count = 0\r\n answer = input().split(\" \")\r\n for i in range(len(answer)):\r\n answer[i] = int(answer[i])\r\n for i in answer:\r\n if i == 1:\r\n count += 1\r\n if count >= 2:\r\n problemcount += 1\r\n print(problemcount)\r\n\r\ndef NextRound():\r\n nk = input().split(\" \")\r\n n = int(nk[0])\r\n k = int(nk[1])\r\n print(n, k)\r\n scores = input().split(\" \")\r\n count = 0\r\n for i in range(n):\r\n scores[i] = int(scores[i])\r\n five = scores[k]\r\n for i in range(n):\r\n if scores[i] >= five and scores[i] > 0:\r\n count += 1\r\n print(count)\r\n\r\n\r\ndef Beautifulmatrix():\r\n steps = 0\r\n matrixes = []\r\n for i in range(5):\r\n i = [input().split(\" \")]\r\n matrixes += i\r\n for i in range(5):\r\n for j in range(5):\r\n matrixes[i][j] = int(matrixes[i][j])\r\n for i in range(5):\r\n for j in range(5):\r\n if matrixes[i][j] > 0:\r\n x = j\r\n y = i\r\n break\r\n while x != 2 or y != 2:\r\n if x > 2:\r\n x -= 1\r\n steps += 1\r\n elif x < 2:\r\n x += 1\r\n steps += 1\r\n elif y > 2:\r\n y -= 1\r\n steps += 1\r\n elif y < 2:\r\n y += 1\r\n steps += 1\r\n print(steps)\r\n\r\n\r\ndef HelpfulMahts():\r\n s = input().split(\"+\")\r\n s.sort()\r\n print(\"+\".join(s))\r\n\r\ndef WordCapitalization():\r\n word = input()\r\n List = []\r\n for i in word:\r\n List.append(i)\r\n List[0] = List[0].upper()\r\n s = \"\"\r\n for i in List:\r\n s += i\r\n print(s)\r\n\r\ndef Stonesonthetable():\r\n n = int(input())\r\n stones = []\r\n rrg = input()\r\n counter = 0\r\n for i in rrg:\r\n stones.append(i)\r\n for i in range(n - 1):\r\n if stones[i] == stones[i + 1]:\r\n counter += 1\r\n print(counter)\r\n\r\ndef BearandBigBrother():\r\n inpuut = input().split(\" \")\r\n a = int(inpuut[0])\r\n b = int(inpuut[1])\r\n year = 0\r\n while a <= b:\r\n a *= 3\r\n b *= 2\r\n year += 1\r\n print(year)\r\n\r\ndef Wrongsubtraction():\r\n nk = input().split(\" \")\r\n n = int(nk[0])\r\n k = int(nk[1])\r\n for i in range(k):\r\n p = str(n)\r\n if p[len(p) - 1] == \"0\":\r\n n //= 10\r\n else:\r\n n -= 1\r\n print(n)\r\n\r\nimport string\r\ndef Word():\r\n word = input()\r\n lower = 0\r\n upper = 0\r\n for i in word:\r\n if i in string.ascii_lowercase:\r\n lower += 1\r\n else:\r\n upper += 1\r\n if upper > lower:\r\n word = word.upper()\r\n else:\r\n word = word.lower()\r\n print(word)\r\n\r\ndef QueueattheSchool():\r\n nt = input().split(\" \")\r\n n = nt[0]\r\n t = int(nt[1])\r\n a = input()\r\n b = []\r\n ref = \"\"\r\n for i in a:\r\n b.append(i)\r\n for k in range(t):\r\n whre = []\r\n for i in range(len(b) - 1):\r\n if b[i] == \"B\" and b[i + 1] != \"B\":\r\n whre.insert( 0,i)\r\n for j in whre:\r\n b.pop(j)\r\n b.insert(j + 1, \"B\")\r\n for i in b:\r\n ref += i\r\n print(ref)\r\n\r\ndef Nearlyluckynumber():\r\n n = input()\r\n if n.count(\"7\") + n.count(\"4\") == 7 or n.count(\"7\") + n.count(\"4\") == 4:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n\r\ndef Translation():\r\n s = input()\r\n t = input()\r\n n = []\r\n for i in t:\r\n n.insert(0, i)\r\n t = \"\"\r\n for i in n:\r\n t += i\r\n if t == s:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\nTranslation()", "s = input()\r\nt = input()\r\n\r\n# Check if the translation is correct\r\nif s[::-1] == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "name1 = input()\r\nname2 = input()\r\n\r\nname3 = name1[::-1]\r\n\r\nif name3 == name2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "s=str(input())\r\nt=str(input())\r\na=\"\"\r\nfor i in range(len(s)):\r\n a+=s[len(s)-i-1]\r\nif(t==a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = 2\r\nlis = []\r\nfor i in range(n):\r\n lis.append(str(input()))\r\nl1 = str(lis[0])\r\nl2 = str(lis[1])\r\nl1 = list(l1)\r\nl2 = list(l2)\r\nl1.reverse()\r\nif list(l1) == l2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a = input(); a = list(a)\r\nb = input(); b = list(b)\r\nif a == b[::-1]: print(\"YES\")\r\nelse: print(\"NO\")", "s = input()\nt = input()\nflag = 0\nfor i in range(len(s)):\n if s[i] != t[len(t)-i-1]:\n flag = 1\n break\n\nif flag:\n print(\"NO\")\nelse:\n print(\"YES\")", "s11=input()\ns2=input()\nif(s11==s2[::-1]):\n print(\"YES\")\nelse:\n print(\"NO\")\n \n\t\t\t\t\t \t\t \t\t\t \t \t\t \t \t\t \t\t", "s=str(input())\r\nt=str(input())\r\nn=0\r\nx=len(s)\r\nif len(s)!=len(t):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(s)):\r\n if s[i]==t[x-1]:\r\n n=n+1\r\n x=x-1\r\n else:\r\n print(\"NO\")\r\n break\r\nif n==len(s):\r\n print(\"YES\")", "a = input()\r\nb = input()\r\nt = True\r\nfor i in range(len(a)):\r\n if a[i] != b[len(b) - 1 - i]:\r\n t = False\r\n break\r\n\r\nif t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1 = input()\r\nstr3 = input()\r\nstr2=\"\"\r\nfor i in str1:\r\n str2=i+str2\r\nif str2==str3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "if __name__ == '__main__':\r\n a=input().strip('')\r\n b=input().strip('')\r\n if b==a[::-1]:\r\n print('YES')\r\n else:\r\n print('NO')", "if input() == input()[::-1]:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "s = input()\r\nrs = input()\r\nrs = rs[::-1]\r\n\r\nif s == rs:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s, t = input(), input()\r\nif len(s) == len(t):\r\n print(['NO', 'YES'][all(s[i] == t[-i - 1] for i in range(len(s)))])\r\nelse:\r\n print('NO')", "def solve(s, t):\r\n if s == t[::-1]:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n\r\nberlandish = input()\r\nbirlandish = input()\r\nresult = solve(berlandish, birlandish)\r\nprint(result)\r\n", "w = input()\r\nif \"\".join(reversed(input()))==w:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "txt = input()\r\ntxt1 = input()\r\n\r\nrevtxt = txt[::-1]\r\n\r\nif txt1 == revtxt:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x =input()\r\ny=input()\r\nz=x[::-1]\r\n\r\nif y==z:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "l = list(input())\r\nt = list(input())\r\n\r\nl.reverse()\r\n\r\nif l == t :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def main():\r\n p=list(i for i in input())\r\n q=list(i for i in input())\r\n\r\n if(\"\".join(p)==\"\".join(q)[::-1]):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()", "n = list(input())\r\na = list(input())\r\na1 = n[::-1]\r\nif a1 == a:\r\n print('YES')\r\nelse:\r\n print('NO')", "def reverse(x):\r\n\treturn x[::-1]\r\n\r\ns = str(input())\r\nt = str(input())\r\n\r\nif (reverse(s) == t):\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "from sys import stdin\r\n\r\ns = stdin.readline().split()[0]\r\nt = stdin.readline().split()[0]\r\n\r\nif t == s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word1 = input()\r\nword2 = input()\r\ncounter=0\r\ny= len(word2)-1\r\nfor i in range (0,len(word1)):\r\n if word1[i] == word2[y] :\r\n counter = counter +1\r\n y= y-1\r\nif counter == len(word1) :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "if __name__ == '__main__':\n s1 = input()\n s2 = input()\n\n rev_s1 = s1[::-1]\n\n if rev_s1 == s2:\n print('YES')\n else:\n print('NO')\n", "s=input()\r\nt=input()\r\nflag=0\r\nfor i in range(len(s)):\r\n\tif s[i]==t[len(t)-i-1]:\r\n\t\tflag+=1\r\nif flag==len(s):\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "str = input()\r\nstr2 = input()\r\nnew = str[::-1]\r\nif str2 == new:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\na=[s[len(s)-1-i] for i in range(len(s))]\r\nif t==\"\".join(a):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "test= input()\r\nrev= input()\r\nif test[::-1] == rev:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')\r\n\r\n", "n=input()\r\na=input()\r\nk=len(n)\r\nr=''\r\nfor i in range(k):\r\n r=r+n[k-1]\r\n k=k-1\r\nif r==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "os=input()\r\nrs=input()\r\nos=list(os)\r\nos.reverse()\r\nos=''.join(os)\r\nif os==rs:\r\n print('YES')\r\nelse:\r\n print('NO')", "def main() :\r\n w = input()\r\n t = input()\r\n tp = \"\".join(reversed(t))\r\n if tp == w :\r\n print('YES')\r\n else :\r\n print('NO') \r\n\r\n\r\n\r\nmain()\r\n", "s = input()\nt = input()\nspisok = list(reversed(s))\nstroka = \"\".join(map(str, spisok))\nif t == stroka:\n print('YES')\nelse:\n print('NO')\n", "s=input()\r\nt=input()\r\nx=\"\"\r\nfor i in range(len(s)):\r\n\tx=x+s[len(s)-i-1]\r\nif x==t:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "lst1 = list(input())\r\nlst2 = list(input())\r\nlst1.reverse()\r\nif lst2 == lst1:\r\n print('YES')\r\nelse:\r\n print('NO')", "list1 = list(input())\r\nlist2 = list(input())\r\nlist2.reverse()\r\n\r\nif list1==list2:\r\n print(\"YES\")\r\nelse:\r\n print('NO')", "from sys import exit\r\nberword = input()\r\nbirword = input()\r\n\r\nberword = berword[::-1]\r\nif berword == birword:\r\n print(\"YES\")\r\n exit(0)\r\n\r\nprint(\"NO\")\r\n", "def ber_to_bir(berlandish, birlandish):\r\n for i in range(int(len(berlandish))):\r\n if berlandish[i] != birlandish[-1-i]:\r\n return False\r\n return True\r\n\r\n\r\nberlandish = input()\r\nbirlandish = input()\r\n\r\nif ber_to_bir(berlandish, birlandish):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "list_1 = input()\r\nlist_2 = input()\r\nlist_1 = list([x for x in list_1])\r\nlist_2 = list([x for x in list_2])\r\nlist_2.reverse()\r\nif list_2 == list_1:\r\n print(\"YES\")\r\nelse:\r\n print('NO')", "s=input()\r\nz=input()\r\nr=s[::-1]\r\nif z==r:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "Word = str(input())\r\nTranslation = str(input())\r\nReversal = Word[::-1]\r\nif Reversal == Translation:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "txt1=str(input())\r\ntxt =str(input()) \r\nif txt1[::-1]==txt:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def translate(s,t):\r\n s.lower()\r\n t.lower()\r\n w=''.join(reversed(s))\r\n if(t==w):\r\n print('YES')\r\n else:\r\n print('NO')\r\nif __name__=='__main__':\r\n s=input()\r\n t=input()\r\n res=translate(s,t)\r\n \r\n", "a=input()\r\nb=list(input())\r\nb=b[::-1]\r\nc=\"\"\r\nfor i in b:\r\n c+=i\r\nif a==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input())\nt = str(input())\ntext = \"\"\nfor x in range (len (s)):\n text = text + s[len(s)-1-x:len(s)-x]\nif t == text:\n print(\"YES\")\nelse :\n print(\"NO\")\n\nquit()\n\t\t \t \t \t\t \t \t \t \t\t\t\t\t\t", "a = input()\r\nb = input()\r\nc = []\r\nfor i in range(len(a)):\r\n c.append(a[i])\r\nc.reverse()\r\nif ''.join(c)==b:\r\n print('YES')\r\nelse:\r\n print('NO')", "word_s = input().strip()\r\nword_t = input().strip()\r\nif word_s == word_t[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "N=list(input())\r\nM=list(input())\r\nN.reverse()\r\nif N==M:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def reversed1(variable):\r\n res=''\r\n for i in range(len(variable)-1,-1,-1):\r\n res+=variable[i]\r\n return res\r\n\r\nn = reversed1(input())\r\n\r\nf = input()\r\nif n ==f:\r\n print('YES')\r\nelse:\r\n print('NO')", "import sys\r\nx = sys.stdin.readline().strip()\r\ny = list(sys.stdin.readline().strip())\r\nn = len(y)\r\nm = ''\r\nfor c in range(n-1,-1,-1):\r\n m += y[c]\r\nif x == m:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = list(input())\r\nt = list(input())\r\nt.reverse()\r\nprint('YES') if s == t else print('NO')\r\n", "n = input()\r\n\r\ns = input()\r\n\r\na = n[::-1]\r\nif(a==s):\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "s = input()\nt = input()\n\nyes = True\nj = 0\nfor i in range(len(t) - 1, -1, -1):\n if t[i] != s[j]:\n yes = False\n break\n j += 1\n\nif yes:\n print('YES')\nelse:\n print('NO')\n", "d=input()\r\ne=input()\r\ns=d[::-1]\r\n\r\nif (s==e):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\n\r\na = list(a)\r\na = a[::-1]\r\na = ''.join(a)\r\n\r\nif a == b:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "print(\"YES\") if input()==input()[::-1] else print(\"NO\")", "firstString = input(\"\")\r\nsecondString = input(\"\") \r\nreversSecondString = \"\"\r\nfor i in range(0,len(secondString)+1):\r\n reversSecondString+=secondString[-i]\r\nif reversSecondString[1:]==firstString:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "inP1 = input()\r\ninP2 = input()\r\n\r\ndecision = \"No\"\r\nfor i in range(len(inP1)):\r\n if(inP1[i]==inP2[-1-i]):\r\n decision = \"YES\"\r\n else:\r\n decision = \"NO\"\r\n break\r\nprint(decision) ", "n=input()\r\nm=input()\r\ns=\"\".join(reversed(n))\r\n\r\nif m==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#文字列入力はするな!!\r\n#carpe diem\r\n\r\n'''\r\n ██╗ ██╗ ███╗ ███╗ ██╗ ████████╗\r\n ██║ ██║ ████╗ ████║ ██║ ╚══██╔══╝\r\n═════════██╠════════██╠═══██╔████╔██╠═══██╠══════██╠══════════\r\n ██║ ██║ ██║╚██╔╝██║ ██║ ██║\r\n ███████╗ ██║ ██║ ╚═╝ ██║ ██║ ██║\r\n ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\r\n'''\r\n\r\n#文字列入力はするな!!\r\n#carpe diem\r\n\r\nfor _ in range(1):\r\n s1=input();s2=input()\r\n if len(s1)!=len(s2):\r\n print('NO')\r\n continue\r\n flag=True\r\n n=len(s2)\r\n for i in range(n):\r\n if s1[i]!=s2[n-i-1]:\r\n flag=False\r\n break\r\n \r\n if flag:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\n \r\n\r\n#carpe diem \r\n#carpe diem", "y=list(input())\r\nf=input()\r\ny.reverse()\r\nfb=''.join(y)\r\nif fb==f:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\r\nt = input()\r\nx = 1\r\nif len(t) != len(s):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(s)):\r\n if s[i] == t[len(s)-i-1]:\r\n x =x*1\r\n else:\r\n x = x*0\r\n if x == 0:\r\n print('NO')\r\n else:\r\n print('YES')", "T=input(\"\")\r\nT1=input(\"\")\r\nif(T1==T[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\nb=input()\nx=a[::-1]\nif x==b:\n print('YES')\nelse :\n print('NO') \n\t\t\t\t \t\t\t\t\t\t \t\t\t \t \t\t \t \t", "a=input()\r\nb=input()\r\nrev=b[::-1]\r\nif a==rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\ns1=\"\"\r\nfor i in s:\r\n s1=i+s1\r\nif(s1==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\ny = input()\nif s[::-1] == y:\n\tprint (\"YES\")\nelse:\n\tprint (\"NO\")\n\t\t \t\t \t\t \t\t \t \t \t\t\t \t \t", "s1=input()\r\ns2=input()\r\nif s1.count(\" \")==0 and s2.count(\" \")==0:\r\n if s1==s2[::-1]:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "s1=input()\r\ns2=input()\r\nif s1==s2[::-1]:print('YES')\r\nelse:print('NO')", "st1=input()\r\nst2=input()\r\nst2=st2[::-1]\r\nprint(\"YES\") if st1==st2 else print(\"NO\")", "import sys\r\ndata = [x.rstrip() for x in sys.stdin]\r\nword = str(data[0])\r\nrevWord = str(data[1])\r\nif word[::-1] == revWord:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "i = input()\r\nj = input()\r\nm=0\r\n\r\nif i[::-1] == j:\r\n m +=1\r\n\r\nif m==1:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=input()\r\nb=input()\r\nif len(a)!=len(b):\r\n print('NO')\r\n exit()\r\nflage=0\r\nfor i in range(len(a)):\r\n if a[i]!=b[len(b)-i-1]:\r\n flage=1\r\n \r\nif flage ==0:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\r\n", "n=input()\nm=input()\ns=len(n)\nif len(m)!=s:\n print('NO')\nelse:\n \n flag=False\n for i in range(s):\n if n[i]!=m[s-1-i]:\n flag=True\n break\n if flag:\n print('NO')\n else:\n print('YES')\n", "#Check if the given word is the reverse of a given word\r\n\r\na=list(input())\r\nb=list(input())\r\nfor i in range(len(a)//2):\r\n temp=a[i]\r\n a[i]=a[len(a)-i-1]\r\n a[len(a)-i-1]=temp\r\nprint('YES') if a==b else print('NO')\r\n", "st = input()\r\nst1 = input()\r\nre = st[::-1]\r\nif re==st1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a = input()\r\nb = input()\r\nc = 0\r\nfor i in range(len(a)):\r\n if(a[i] == b[len(b) - 1- i]):\r\n c = c + 1\r\nif(c == len(a)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n ", "s=input()\ns1=input()\nans=s[::-1]\nif(s1==ans):\n print(\"YES\")\nelse:\n print(\"NO\")\n\t \t \t\t \t \t \t \t\t \t \t\t \t \t\t", "str1 = input()\r\nstr2 = input()\r\nl1 = list(str1)\r\nl1.reverse()\r\nl2 = list(str2)\r\nif l1 == l2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "str1 = input()\r\nstr2= input()\r\nar = [i for i in str1]\r\nar2 = []*len(ar)\r\ni =0\r\nj = len(str1)-1\r\nwhile i<len(str1):\r\n ar2.append(ar[j])\r\n j-=1\r\n i+=1\r\n \r\nstr3 =\"\".join(ar2) \r\nif(str3 == str2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#41A\r\n\r\ns = str(input())\r\nt = str(input())\r\ncount = 0\r\n\r\nletters_of_s = []\r\nletters_of_t = []\r\n\r\nfor x in s:\r\n letters_of_s.append(x)\r\n\r\nfor x in t:\r\n letters_of_t.append(x)\r\n\r\nhigh_range = len(s) / 2\r\nhigh_range = int(high_range)\r\n\r\n\r\ni = 0\r\nj = len(s) - 1\r\n\r\nwhile i < high_range:\r\n while j >= high_range:\r\n letters_of_s[i], letters_of_s[j] = letters_of_s[j], letters_of_s[i]\r\n j = j - 1\r\n break\r\n i = i + 1\r\n\r\nfor i in range(len(t)):\r\n if letters_of_s == letters_of_t:\r\n count = count + 1\r\n\r\nif count == len(s):\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")\r\n", "a = str(input())\nc= str(input())\nb = a[::-1]\n\nif ( b==c):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "word = input()\r\nreverse = input()\r\nresult = 'YES'\r\n\r\nfor i in range(len(word)):\r\n if word[i] != reverse[-1-i]:\r\n result = 'NO'\r\n break\r\n \r\nprint(result)\r\n\r\n\r\n", "def main():\r\n first_word = input()\r\n second_word = input()\r\n if first_word[::-1] == second_word:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\nmain()", "t=input()\ns=input()\nif(t[::-1]==s[::1]):\n print(\"YES\")\nelse:\n print(\"NO\")\n\t \t \t\t \t\t \t\t\t \t\t\t\t \t\t\t \t \t", "word1 = list(input())\r\nword2 = input()\r\n\r\nword1.reverse()\r\n\r\nword = \"\".join(word1)\r\n\r\n\r\nif(str(word) == str(word2)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s =input()\r\nt = input()\r\nrs = s[::-1]\r\nif rs == t:\r\n print ('YES') \r\nelse :\r\n print ('NO')", "a=input()\nb=input()\nb_list=[]\na_list=[]\nfor i in range(len(a)):\n a_list.append(a[i])\nfor i in range(len(b)):\n b_list.append(b[i])\nb_list.reverse()\nif a_list==b_list:\n print(\"YES\")\n exit()\nprint(\"NO\")\n \t \t\t \t\t \t \t \t", "s=input()\r\nt=input()\r\nif len(s)!=len(t):\r\n print('NO')\r\nelse:\r\n num=0\r\n for i in range(len(s)):\r\n if s[i]==t[-(i+1)]:\r\n num+=1\r\n else:\r\n num+=0\r\n if num==len(s):\r\n print('YES')\r\n else:\r\n print('NO')\r\n", "# Problem 41 A - Translation\r\n\r\n# input\r\ns = input()\r\nt = input()[::-1]\r\n\r\n# check\r\nif s==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "w1, w2, yes = input(), input(), True\r\n\r\nfor i in range(len(w1)):\r\n if w1[i] != w2[-(i + 1)]:\r\n yes = False\r\n break\r\n\r\nif yes:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\r\ns2 = input()\r\nf = s[::-1]\r\nif f == s2:\r\n print('YES')\r\nelse: print('NO')", "def reverse(s):\r\n str = \"\"\r\n for i in s:\r\n str = i + str\r\n return str\r\n \r\n\r\n\r\ns = input()\r\nl = input()\r\nif(l == reverse(s)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n\r\n", "__author__ = 'Colin Bethea'\n\ndef main(original, new):\n if original[::-1] == new:\n return 'YES'\n else:\n return 'NO'\n \nif __name__ == \"__main__\":\n original = input()\n new = input()\n print(main(original, new))\n", "s=input()\r\nt=input()\r\nlist=[]\r\nlist1=[]\r\nfor i in s:\r\n x=list.append(i)\r\n\r\ny=list.reverse()\r\n\r\nfor j in t:\r\n list1.append(j)\r\n\r\nif list==list1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "kata1 = input()\r\nkata2 = input()\r\nif kata2 == kata1[::-1]:\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "a = [n for n in input()]\r\nb = [n for n in input()]\r\nb.reverse()\r\nif a == b:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\ns1=[]\r\nt1=[]\r\nfor _ in s:\r\n s1.append(_)\r\nfor _ in t:\r\n t1.append(_)\r\nb=s1[::-1]\r\nif t1==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "import sys\r\n\r\n# sys.stdin = open(\"input.txt\", \"r\")\r\n# sys.stdout = open(\"output.txt\", \"w\")\r\n\r\n\r\ndef main():\r\n print([\"NO\", \"YES\"][sys.stdin.readline().rstrip() == sys.stdin.readline().rstrip()[::-1]])\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n\r\n\r\n# трамвай - 1\r\n# n = 3\r\n", "\"\"\"\r\nTake a string.\r\nconvert it into a list.\r\nReverse the list.\r\nTurn that string into a list.\r\nDetermine if the original string is the same as\r\nthe reversed string.\r\n\"\"\"\r\ninputString = input()\r\ntranslationAttempt = input()\r\n\r\nmyList = list(inputString)\r\n\r\nmyList.reverse()\r\nnewString = \"\".join(myList)\r\n\r\nif newString == translationAttempt:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a = str(input())\r\nb =str(input())\r\na = a.lower()\r\nb = b.lower()\r\nif a[::-1] == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=[]\r\ns=''\r\nwhile True:\r\n try:\r\n a.append(input())\r\n except:\r\n break\r\ng=a[0][::-1]\r\nif g==a[1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "Berland = input()\r\nBirland = input()\r\n\r\nprint(\"YES\" if Berland == Birland[::-1] else \"NO\")", "first = input()\nsecond = input()\ntsrif = first[::-1]\nif second == tsrif:\n print('YES')\nelse:\n print('NO')\n\n", "t = str(input())\r\ns= str(input())\r\nt= list(t)\r\ns = list(s)\r\nm= len(t)\r\ncond = True\r\nfor i in t:\r\n if(len(s) != len(t)):\r\n cond= False\r\n break\r\n if(i != s[m-1]):\r\n cond =False\r\n m-=1\r\nif(cond):\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")\r\n\r\n", "# https://codeforces.com/problemset/problem/41/A\r\noriginal_word = input();\r\ntranslated_word = input();\r\n\r\nif translated_word == original_word[::-1]:\r\n print('YES');\r\nelse:\r\n print('NO');\r\n", "s=input()\r\nt=input()\r\nn=len(s)\r\nm=len(t)\r\nif n!=m:\r\n print(\"NO\")\r\nelse:\r\n for i in range(n-1,-1,-1):\r\n if s[i]!=t[n-1-i]:\r\n print(\"NO\")\r\n break\r\n else:\r\n print(\"YES\")", "a=input()\r\nb=input()\r\nn=len(a)\r\n\r\nif(len(a)!=len(b)):\r\n print(\"NO\")\r\n\r\nelse:\r\n\r\n s=a[::-1]\r\n if(s==b):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Fri Nov 8 19:38:42 2019\r\n\r\n@author: jk Jin\r\n\"\"\"\r\n\r\ns1 = input()\r\ns2 = input()\r\nn = len(s1)\r\nm = len(s2)\r\nstat = 0\r\nif m != n:\r\n print('NO')\r\nelse:\r\n for i in range(n):\r\n if s1[i]!=s2[n-1-i]:\r\n stat = 1\r\n print('NO')\r\n break\r\n if stat == 0:\r\n print('YES')", "s = input()\nt = input()\nw = t[::-1]\nif w == s:\n print(\"YES\")\nelse:\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\nret = True\r\nfor i in range(len(s)):\r\n if(s[i] != t[len(t) - 1 - i]):\r\n ret = False\r\n\r\nif(ret == True):\r\n print('YES')\r\nelse:\r\n print('NO')", "def main():\r\n str1=input()\r\n str2=input()\r\n str3=str1[::-1]\r\n if str3==str2:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()", "li = input()\nle = input()\n\nif le == li[::-1]:\n print('YES')\nelse:\n print('NO')\n", "s = input()\nt = input()\n\ni = -1\ns_new = s[-1::]\nwhile ( i != - (len(s))):\n s_new += s[i-1:i]\n i -= 1\n\nif s_new == t :\n print(\"YES\")\nelse:\n print(\"NO\")", "s=input()\r\ntrans=input()\r\nnum=list(s)\r\nnew=[]\r\nfor i in range(len(num)):\r\n new.insert(i,num[-1-i])\r\n new.insert(i+1,num[i])\r\n \r\ncomp=\"\".join(new[:len(new)//2])\r\nif comp==trans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nc=input()\r\nb=a[::-1]\r\nif c==b:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "s=str(input())\r\ns1=str(input())\r\na=s[::-1]\r\nif(a==s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") \r\n", "s=list(input())\r\nt=list(input())\r\nlength=len(s)\r\ni=0\r\nm=int(length/2)\r\nwhile i<m:\r\n x=s[i]\r\n s[i]=s[length-1-i]\r\n s[length-1-i]=x\r\n i+=1\r\nif s==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "first = input()\r\nsecond = input()\r\nb=''\r\nfor i in range(len(first)-1 ,-1,-1):\r\n b+=first[i]\r\n\r\nif (second == b):\r\n print(\"YES\")\r\nelse:\r\n print('NO')", "a = input()\r\nb = input()\r\nc = \"\"\r\nfor i in range(len(a) - 1, -1, -1):\r\n c += a[i]\r\nif c == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = input()\r\nres = input()\r\nif n[::-1] == res:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input().lower()\r\ny=input().lower()\r\ng=\"\"\r\nfor l in (x):\r\n g=l+g\r\nif g==y:\r\n print (\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nb=input()\r\nx=len(a)\r\nd=a[::-1]\r\nif(b==d):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "t=input()\r\ns=input()\r\na=\"\"\r\nfor i in range(len(t)-1,-1,-1):\r\n a=a+t[i]\r\nif a==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n \r\n \r\n \r\n \r\n", "a = input(\"\")\r\nb = input(\"\")\r\ni = len(b)-1\r\nc = \"\"\r\nwhile i>=0:\r\n c=c+(b[i])\r\n i = i -1\r\n\r\nif a==c:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n", "orinput=list(input())\r\nreinput=list(input())\r\nreinput.reverse()\r\ndef convert(s): \r\n \r\n # initialization of string to \"\" \r\n str1 = \"\" \r\n \r\n # using join function join the list s by \r\n # separating words by str1 \r\n return(str1.join(s))\r\nortest=convert(orinput)\r\nretest=convert(reinput) \r\nif ortest == retest :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n\r\n\r\n\r\n \r\n", "str = input()\r\nestr=input()\r\nnstr=str[::-1]\r\n\r\nif(estr==nstr):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "X = input()\r\nY = input()\r\nR = X[::-1]\r\nif(Y==R):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = list(input())\r\nreverseword = list(reversed(input()))\r\nif word == reverseword:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=list(input())\r\nt=list(input())\r\nt.reverse()\r\nif len(s)==len(t):\r\n j=0\r\n for i in range(len(s)):\r\n if s[i]==t[i]:\r\n j=j+1\r\n elif s[i]!=t[i]:\r\n print(\"NO\")\r\n break\r\n if j==len(s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "stringOne = input()\r\nstringTwo = input()\r\nif stringOne == stringTwo[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=list(input())\r\nb=input()\r\nc=list(reversed(a))\r\nd=\"\"\r\nfor i in c:\r\n d=d+i\r\nif d==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 =input()\r\ns2 = input()\r\nif len(s1) != len(s2):\r\n print(\"NO\")\r\nelse:\r\n validation = 0\r\n for i in range(len(s1)):\r\n if s1[i] == s2[(len(s1) - 1) - i]:\r\n validation += 1\r\n if validation == len(s1):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\n\r\nlist_1 = []; list_1.extend(a)\r\nlist_2 = []; list_2.extend(b)\r\n\r\nif list_1[::-1] == list_2:\r\n print('YES')\r\nelse:\r\n print('NO')", " \r\n\r\n#___________________________Afsan Habib_________________________#\r\n\r\nimport sys\r\nfrom collections import Counter\r\nfrom heapq import heapify, heappush, heappop\r\nimport copy\r\nfrom functools import lru_cache\r\nimport math\r\nfrom itertools import combinations, product, permutations\r\nfrom collections import Counter, defaultdict, deque\r\nfrom queue import PriorityQueue\r\nfrom bisect import bisect_left, bisect_right\r\n\r\n\r\n# import io,os\r\n# stdin = open(\"testcase.txt\")\r\n# def input():\r\n# return stdin.readline().strip()\r\n# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n \r\nmod = 10**9+7\r\n\r\n#______________Start class FastIO___________#\r\n\r\nclass FastIO:\r\n\r\n @classmethod\r\n def input(cls):\r\n from sys import stdin\r\n x = stdin.buffer.readline().decode().strip()\r\n return x\r\n\r\n @classmethod\r\n def integer_list(cls):\r\n return list(map(int, cls.input().split()))\r\n\r\n @classmethod\r\n def print(cls, s, end = \"\\n\"):\r\n from sys import stdout\r\n stdout.write(str(s) + end)\r\n\r\n @classmethod\r\n def flush(cls):\r\n from sys import stdout\r\n stdout.flush()\r\n\r\n#______________End class FastIO___________#\r\n\r\n \r\n\r\n\r\n#___________Start Input Functions___________#\r\n\r\ndef int_num():\r\n return (int(input()))\r\n\r\ndef int_list():\r\n return list(map(int, input().split()))\r\n \r\ndef string_list():\r\n return list(map(str, input().split()))\r\n \r\ndef hetro_list():\r\n return list(input().split())\r\n\r\ndef pprint(matrix):\r\n for i in range(len(matrix)):\r\n print(*matrix[i])\r\n \r\ndef insr():\r\n s = input()\r\n return (list(s[:len(s) - 1]))\r\n \r\ndef int_map():\r\n return(map(int,input().split()))\r\n \r\n#___________End Input Functions___________#\r\n\r\n\r\n\r\n\r\n#___________Start Solve Functions___________#\r\n\r\n# n = int(FastIO.input())______lst = FastIO.integer_list()\r\n\r\ndef solve():\r\n\ts=input()\r\n\ts1=input()\r\n\r\n\tif s==s1[::-1]:\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")\r\n\r\n \r\n#___________End Solve Functions___________#\r\n \r\n\r\n\r\n\r\n#___________Start Main Functions___________#\r\n\r\ndef main():\r\n\t\tsolve()\r\n\r\n\t\treturn\r\n\r\n\r\n \r\nif __name__ == \"__main__\":\r\n main()\r\n#___________End Main Functions___________#\r\n", "s=input()\r\nt=input()\r\nS=list(s)\r\nT=list(t)\r\nS.reverse()\r\ns_1=''.join(S)\r\nif s_1==t:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\ntest = True\r\nl=len(s)-1\r\ni=0\r\nif len(s) == len(t):\r\n while test == True and i <=l:\r\n if t[l-i] != s[i]:\r\n test = False\r\n else:\r\n i=i+1 \r\nif test == True and len(s) == len(t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import sys\r\nn=sys.stdin.readline()[:-1]\r\nt=sys.stdin.readline()[:-1]\r\nif n==t[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "berlandish = input()\r\nbirlandish = input()\r\n\r\nif berlandish[::-1] == birlandish:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# Wadea #\r\n\r\nn = str(input())\r\nm = str(input())\r\n\r\nlst = list(n)\r\nlst.reverse()\r\nf = \"\"\r\nfor i in lst:\r\n f += i\r\nif m == f:\r\n print(\"YES\")\r\nelse:print(\"NO\")\r\n", "s = input()\r\nt = input()\r\n\r\nt_is_s = True\r\n\r\n# eliminate words of different legths\r\n\r\nif len(s) == len(t):\r\n head = 0\r\n tail = len(t)\r\n while(head < len(s)):\r\n if s[head] != t[tail-1]:\r\n t_is_s = False\r\n # they are different, so the words don't match and there is no reason to keep looping\r\n break\r\n else:\r\n head += 1\r\n tail -= 1\r\nelse:\r\n t_is_s = False\r\n\r\n# Output\r\n# If the word t is a word s, written reversely, print YES, otherwise print NO.\r\nif t_is_s:\r\n print('YES')\r\nelse:\r\n print('NO')", "first_word = input()\r\nsecond_word = input()\r\nprint(\"YES\" if list(first_word) == list(reversed(second_word)) else \"NO\")", "s=input()\r\nt=input()\r\ntrans=s[::-1]\r\nif(trans == t ):\r\n print('YES')\r\nelse:\r\n print('NO')", "string = input()\r\ntranslatedString = input()\r\ntranslation = string[::-1]\r\nif translatedString == translation:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "c=(input())\r\nd=(input())\r\ntem=d[::-1]\r\nif c==tem:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "shilpa = input()\r\n\r\nshipla = input()\r\n\r\nreddy = shilpa[::-1]\r\n\r\nif(reddy == shipla):\r\n \r\n print(\"YES\")\r\n \r\nelse:\r\n \r\n print(\"NO\")", "stroka1=input()\r\nstroka2=input()\r\nstroka_reverse = stroka1[::-1]\r\nif stroka_reverse == stroka2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = list(input())\r\nt = list(input())\r\nstr1 = list()\r\nfor i in range(len(t)-1,-1,-1):\r\n str1.append(t[i])\r\nif str1 == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word_f = input().lower()\r\nword_s = input().lower()\r\nif word_s == word_f[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nrev_s = s[::-1]\r\nt = input()\r\n\r\nif rev_s == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=str(input())\r\nt=str(input())\r\ns=0\r\nif len(a)==len(t):\r\n for i in range(len(a)):\r\n if a[i]==t[-i-1]:\r\n s=s+1\r\n if s==len(a):\r\n print('YES')\r\n else:\r\n print('NO') \r\nelse:\r\n print('NO')\r\n", "word1 = input()\nword2 = input()\nif word1 == \"\".join(reversed(word2)):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "ber = list(input())\nbir = str(input())\nber.reverse()\nb = ''.join(str(i) for i in ber)\nif(b == bir):\n print(\"YES\") \nelse:\n print(\"NO\") \n \n\n \t \t\t\t\t\t\t\t \t \t \t \t \t \t \t \t\t", "#41A\r\nimport sys\r\na=input()\r\nb=input()\r\nc=[]\r\nd=[]\r\ncount=0\r\nn=0\r\nfor i in a:\r\n c.append(i)\r\n count+=1\r\nfor i in b : \r\n d.append(i)\r\nd.reverse()\r\nfor x in range(count):\r\n if c[x]==d[x]:\r\n n+=1\r\n \r\n else:\r\n \r\n print('NO')\r\n sys.exit(0)\r\nprint('YES')\r\nsys.exit(0)", "import sys\r\ninput = sys.stdin.readline\r\n\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\n\r\na = ''.join([x for x in insr() if x != ' '])\r\nb = ''.join([x for x in insr() if x != ' '][::-1])\r\nprint('YES' if a == b else 'NO')\r\n", "import sys\r\n\r\n\r\ndef get_data():\r\n data = sys.stdin.readline().split()\r\n return data\r\n \r\ndef solve_problem():\r\n inp = get_data()[0]\r\n output = get_data()[0]\r\n ind = -1\r\n flag = True\r\n for i in inp:\r\n if i != output[ind]:\r\n flag = False\r\n break\r\n ind -= 1\r\n if flag == True:\r\n print('YES')\r\n else:\r\n print('NO')\r\n \r\nif __name__ == '__main__':\r\n solve_problem()\r\n ", "def check_reversed_word(string1,string2):\n if string1 == string2[::-1]:\n return 'YES'\n else:\n return 'NO'\n\nstring1 =input()\nstring2 = input()\nprint(check_reversed_word(string1,string2))", "S1=input()\r\nS2=input()\r\nn1,n2 = len(S1),len(S2)\r\nif n1!=n2:\r\n print('NO')\r\nelse:\r\n sb = 0\r\n for i in range (n1):\r\n if (S1[i]!=S2[n1-1-i]):\r\n sb=1\r\n if (sb==0):\r\n print('YES')\r\n else:\r\n print ('NO')", "s = input()\nt = input()\nn = ''\nfor i in range(len(s)-1,-1,-1):\n n += s[i]\n\nif n==t:\n print(\"YES\")\nelse:\n print(\"NO\")", "n = input()\r\nk = input()\r\na = n[::-1]\r\nif k == a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "text_1 = str(input())\r\ntext_2 = str(input())\r\n\r\ntext2_index = len(text_2)-1\r\nmatch = True\r\n\r\nfor char in text_1:\r\n if char != text_2[text2_index]:\r\n match = False\r\n break\r\n text2_index -= 1\r\n\r\nif match:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\ns2=input()\r\nnew_s= s[::-1]\r\nif s2==new_s:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = str(input())\r\nt = str(input())\r\n\r\nfor i in range(len(s)):\r\n if s[i] == t[-i-1]:\r\n result = \"YES\"\r\n else:\r\n result = \"NO\"\r\n break\r\n \r\nprint(result)", "# Tasks\r\n# - Create a script to `WORDLIST` problem using the .in and .out files\r\n# - IMPLEMENT ROT13, ROT47, ETC...\r\n# - Implement combinations(arr, r) -> returns all possible combinations or a generator\r\n# --------------------\r\n# 158 B - Taxi\r\n# n = int(input())\r\n# A = list(map(int, input().split()))\r\n# A.sort(reverse=True)\r\n# count = 0\r\n# # write your greedy code here...\r\n# print(count)\r\n# --------------------\r\nprint('YES' if input()[::-1]==input() else 'NO')\r\n", "s = input()\r\nt = input()\r\n\r\n#reverse\r\nreversed_status = False\r\nif t == s[::-1]:\r\n reversed_status = True\r\n\r\n#lowercase\r\nlowercase_status = False\r\nif s.islower():\r\n lowercase_status = True\r\n#no spaces\r\nno_space_status = False\r\nfor i in s:\r\n if i != \" \":\r\n no_space_status = True\r\n#not empty\r\nnot_empty_status = False\r\nif s != \"\":\r\n not_empty_status = True\r\n#not exceed 100 symbol\r\nnot_exceed_100_status = False\r\nif len(s) <= 100:\r\n not_exceed_100_status = True\r\n\r\nif reversed_status and lowercase_status and no_space_status and not_empty_status and not_exceed_100_status:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a = input()\r\nb = input()\r\nb1 = a[slice(-1,-(len(a)+1),-1)]\r\nif(b == b1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\nt=input()\nif(len(s)!=len(t)):\n\tprint(\"NO\")\nelse:\n\tc=0\n\tn=len(s)\n\tfor i in range(n):\n\t\tif(s[i]==t[n-i-1]):\n\t\t\tc+=1\n\tif(c==len(s)):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n \t \t\t\t \t\t\t \t\t \t\t\t\t\t \t \t", "s=str(input())\r\nt=str(input())\r\ns1=list(s)\r\ns1.reverse()\r\ns2=''.join(s1)\r\nif str(s2)==str(t):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\ni=-1\r\nX=[]\r\nwhile -1*i<=len(s):\r\n X.append(s[i])\r\n i-=1\r\nT=''.join(X)\r\nif t==T:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\ns1 = ''\r\nfor i in range(len(s) - 1, -1, -1):\r\n s1 += s[i]\r\nfor i in range(len(s1)):\r\n if s1[i] != t[i]:\r\n print('NO')\r\n break\r\nelse:\r\n print('YES')", "string1 = input()\nstring2 = input()\n\nif string1[::-1] == string2:\n print('YES')\nelse:\n print('NO')", "a=input()\nb=input()\n\nfor i in range(len(a)):\n\tif b[i]==a[-(i+1)]:\n\t\tflag=1\n\t\tcontinue\n\telse:\n\t\tflag=0\n\t\tbreak\nif flag==1:\n\tprint('YES')\nelse:\n\tprint('NO')\t\t\t\n\n", "s = input()\r\nt = input()\r\nmy_list = []\r\nnew_list = []\r\nfor i in s:\r\n my_list.append(i)\r\nfor v in t:\r\n new_list.append(v)\r\nif my_list == new_list[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s,p=input(), input()\r\nif s[::-1]==p:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "t=input()\r\ns=input()\r\nm=s[::-1]\r\nif m==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "w1 = input()\r\nw2 = input()\r\nw3 = ''.join([c for c in reversed(w2)])\r\n\r\nif w1 == w3:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "x = input()\r\ny = input()\r\nprint('YES' if x == y[::-1] else 'NO')", "s=input()\r\nt=input()\r\nn=len(s)\r\nif n!=len(t):\r\n print('NO')\r\n exit()\r\nfor i in range(n):\r\n if s[i]!=t[n-i-1]:\r\n print('NO')\r\n exit()\r\nprint('YES')\r\n", "# -*- coding: utf-8 -*-\n# Leonardo Deliyannis Constantin\n# http://codeforces.com/problemset/problem/41/A\n\ndef reverse(a):\n return a[::-1]\n\ndef main():\n s = input()\n t = input()\n print(\"YES\" if s == reverse(t) else \"NO\") \n \nif __name__ == '__main__':\n while True:\n try:\n main()\n except EOFError:\n break\n", "x = input()\r\nb = input()\r\nif b == x[::-1]:\r\n print('YES')\r\nelse:print('NO')", "originalString = input()\r\nreverseString = input()\r\nif originalString[::-1] == reverseString:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nv=s[::-1]\r\nif(t==v):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input().strip()\r\nt = input().strip()\r\n\r\nif s == t[::-1]:\r\n result = \"YES\"\r\nelse:\r\n result = \"NO\"\r\nprint(result)\r\n", "o=input()\r\np=input()\r\nif o[::-1]==p:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word=input()\r\nword_2=input()\r\ntranslate=word[-1::-1]\r\nprint([\"NO\",\"YES\"][word_2==translate])", "s=input()\r\ns1=input()\r\ns2=''\r\nfor i in range(len(s)):\r\n s2=s2+s[len(s)-i-1]\r\nif s1==s2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "'''a=int(input())\r\nif a>2 and a%2==0:\r\n print('YES')\r\nelse:\r\n print('No')''' \r\n'''print(result) \r\nb=input()\r\nresult=0\r\nfor i in b:\r\n result+=int(i)\r\nprint(result)''' \r\n'''n=int(input())\r\nresult=''\r\nwhile n!=0:\r\n result+=str(n%10)\r\n n=n//10\r\nprint(result)'''\r\n'''for i in range(int(input())):\r\n a=input()\r\n if len(a)>10:\r\n print(a[0]+str(len(a)-2)+a[-1])\r\n else:\r\n print(a)'''\r\n'''s=input().lower()\r\nt=input().lower()\r\nif s<t:\r\n print(-1)\r\nelif s>t:\r\n print(1)\r\nelse:\r\n print(0)'''\r\n'''s=input()\r\nt=''\r\nif s.find('1111111')==-1 and s.find('0000000')==-1:\r\n print('NO')\r\nelse:\r\n print('YES')'''\r\n'''s=int(input())\r\nresult=0\r\nfor i in range(s):\r\n a=input().split()\r\n p=int(a[0])\r\n q=int(a[1])\r\n if q-2-p>=0:\r\n result+=1\r\nprint(result) '''\r\ns=input()\r\nt=input()\r\nif s==t[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n", "if __name__ == '__main__':\r\n s = input()\r\n t = input()\r\n t_list = []\r\n for letter in t:\r\n t_list.append(letter)\r\n t_list.reverse()\r\n t_rev = ''.join(t_list)\r\n if s == t_rev:\r\n print('YES')\r\n else:\r\n print('NO')\r\n", "####TRANSLATION\r\nS = str(input())\r\nT = str(input())\r\nif S==T[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def reverse(x):\r\n return x[::-1]\r\n\r\ns=(input())\r\nt=(input())\r\nr=reverse(s)\r\nif r==t:\r\n print(\"YES\\n\")\r\nelse:\r\n print(\"NO\\n\")", "a = input()\r\nb = input()\r\nb = b[::-1]\r\nprint(\"YES\" if a == b else \"NO\")", "s=input()\r\nt=input()\r\nb=list(map(str,s))\r\nc=list(map(str,t))\r\nb.reverse()\r\nif b==c:\r\n\tprint('YES')\r\nelse:\r\n\tprint('NO')", "entry = input()\r\nentry2 = input()\r\nout = entry[::-1]\r\n\r\n\r\n\r\n\r\nif out==entry2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "k=input()\r\nk1=input()\r\nt = k[::-1]\r\nif k1==t:\r\n\tprint (\"YES\")\r\nelse:\r\n\tprint (\"NO\")\r\n", "s = str(input())\r\nt = str(input()) \r\nif (t[::-1]) == s :\r\n print (\"YES\")\r\nelse: \r\n print (\"NO\")\r\n\r\n\r\n ", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Dec 3 21:50:51 2019\n\n@author: wwy\n\"\"\"\n\nword1 = input()\nword2 = input()\nreverse = []\nfor i in range(len(word1)):\n letter = word1[len(word1)-i-1]\n reverse.append(letter)\ntranslated = ''.join(reverse)\nif translated == word2:\n print('YES')\nelse:\n print('NO')", "s=input()\nt=input()\nif t[::-1]==s:\n print(\"YES\")\nelse:\n print(\"NO\")", "s=input()\r\n\r\nd=input()\r\nt=s[::-1]\r\nif(t==d):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\ns1 = []\r\nt1 = []\r\n\r\ns1[:0] = s\r\nt1[:0] = t\r\n\r\nif t1 == list(reversed(s1)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s= input()\r\nt= input()\r\nf= s[::-1]\r\nif f==t:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=input()\r\nt=input()\r\nn=\"\"\r\nfor i in range(len(s)-1,-1,-1):\r\n n=n+s[i]\r\nif t==n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s,t=input(),input()\r\nif (t==s[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word = list(input().lower())\r\nword2 = list(input().lower())\r\nword.reverse()\r\nif word == word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "expression1 = input()\r\nexpression2 = input()\r\n\r\n\r\ndef check(expression1,expression2):\r\n if len(expression2) != len(expression2):\r\n print(\"NO\")\r\n return\r\n else:\r\n for i in range(len(expression1)):\r\n if expression1[i] == expression2[-i-1]:\r\n continue\r\n else:\r\n print(\"NO\")\r\n return\r\n print(\"YES\")\r\n return\r\n\r\ncheck(expression1,expression2)", "berland = input()\r\nbirland = input()\r\n\r\nprint(\"YES\" if berland[::-1] == birland else \"NO\")", "def translation(word1, word2):\r\n reversed_word = word1[::-1]\r\n return reversed_word == word2\r\n\r\n\r\nif __name__ == '__main__':\r\n if translation(input(), input()):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")", "def solve():\r\n string=input()\r\n rev=input()\r\n\r\n if string[len(string)-1:0:-1]+string[0]==rev:\r\n print(\"YES\")\r\n return\r\n \r\n print(\"NO\")\r\nsolve()", "s1= str(input())\r\ns2= str(input())\r\nres=s2[::-1]\r\nif s1 == res :\r\n print('YES')\r\nelse:\r\n print('NO')", "word = input()\r\nsecondWord = input()\r\nchanged = word[::-1] #''.join(reversed(word))\r\nif changed == secondWord:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "a=str(input())\r\nb=str(input())\r\n\r\nf=b[len(b)::-1]\r\nif f==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "S=input()\r\nT=input()\r\nif len(S)!=len(T):\r\n print(\"NO\")\r\nelse:\r\n flag=0\r\n L=len(S)\r\n for i in range(L):\r\n if S[i]!=T[L-i-1]:\r\n print(\"NO\")\r\n flag=1\r\n break\r\n if flag==0:\r\n print(\"YES\")\r\n", "def sol():\r\n s = input()\r\n t = input()\r\n \r\n return \"YES\" if s == t[::-1] else \"NO\"\r\n\r\nprint(sol())\r\n", "a = input()\r\nb = input()\r\nprint(\"YES\" if a == b[::-1] else \"NO\")\n# Sat Oct 23 2021 16:05:55 GMT+0000 (Coordinated Universal Time)\n", "A = (input())\r\nB = (input())\r\nif A == B[::-1]:\r\n print(\"YES\")\r\nelif A != B[::-1]:\r\n print(\"NO\")\r\nelif A == B[::-1]:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nans=\"YES\"\r\nif(len(s)!=len(t)):\r\n ans=\"NO\"\r\nelse:\r\n for i in range(0,len(s)):\r\n if(s[i]!=t[len(s)-1-i]):\r\n ans=\"NO\"\r\nprint(ans)\r\n", "def is_reversed(a: str, b: str) -> bool:\n if len(a) != len(b):\n return False\n\n for i in range(len(a)):\n if a[i] != b[-i - 1]:\n return False\n\n return True\n\n\nprint((\"NO\", \"YES\")[int(is_reversed(input(), input()))])\n", "print(\"YES\" if input() == \"\".join(list(reversed([x for x in input()]))) else \"NO\")", "n=input()\r\nb=input()\r\nk=n[::-1]\r\nif(k==b):print(\"YES\")\r\nelse:print(\"NO\")", "s = input()\r\nt = input()\r\n\r\nisT= True\r\n\r\nif len(s)==len(t):\r\n for i in range(len(s)):\r\n if s[i] != t[len(s)-i-1]:\r\n isT = False\r\n break\r\nelse:\r\n isT=False\r\n\r\nif isT:\r\n print(\"YES\")\r\nelse: \r\n print(\"NO\")", "a=input()\r\nc=input()\r\nb=''\r\nfor i in range((len(a))-1,-1,-1):\r\n b=b+a[i]\r\nif c==b:\r\n print('YES') \r\nelse:\r\n print('NO') ", "s=input()\r\nt=input()\r\ns=''.join(reversed(s))\r\nif(s==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def word():\r\n a=input()\r\n b=input()\r\n if a[::-1] == b:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\nprint(word())\r\n", "s=input()\r\nt=input()\r\na=[]\r\nfor i in s[(len(s)-1)::(-1)]:\r\n a.append(i)\r\nr=\"\".join(a)\r\nif r in t and t in r:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\ns1=[]\r\nt=list(input())\r\nl=len(s)\r\nfor i in range(l-1,-1,-1):\r\n\ts1.append(s[i])\r\nif s1 == t:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "word1 = input()\r\nword2 = input()\r\nif list(reversed(word2)) == list(word1):\r\n print('YES')\r\nelse:\r\n print('NO')", "ber=input()\r\ntrans=input()\r\n\r\nif ber[::-1]==trans:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\na=input()\r\nx=list(s)\r\nx.reverse()\r\nz=\"\".join(x)\r\nif a==z:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "S = input()\r\nT = input()\r\nAux = ''\r\nfor k in S:\r\n Aux = k + Aux\r\nif str(T)==str(Aux):\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nl=list(input())\r\na=\"\"\r\nfor i in range(len(l)-1,-1,-1):\r\n a+=l[i]\r\nif s==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = input()\r\nword_2 = input()\r\nd = word[::-1]\r\nif d==word_2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "i=input()\r\no=input()\r\ns=0\r\nwhile s<len(i):\r\n if i[s] != o[len(o)-1-s]:\r\n print(\"NO\")\r\n break\r\n else:\r\n s+=1\r\nif s==len(i):\r\n print(\"YES\")", "line1 = input()\r\nline2 = input()\r\nreverse = False\r\nlength = int(len(line1))\r\nif len(line1) != len(line2):\r\n reverse = False\r\nelse:\r\n for i in range(len(line1)):\r\n\r\n if line1[i] == line2[-1 -i]:\r\n reverse = True\r\n else:\r\n reverse = False\r\n break\r\n\r\nif reverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nq = input()\r\n\r\nans = 'YES'\r\n\r\n# if len(s) != len(q):\r\n# ans = 'NO'\r\n# else:\r\n# for i in range(len(s)):\r\n# if s[i] == q[len(s) - i - 1]:\r\n# ans = 'YES'\r\n# else:\r\n# ans = 'NO'\r\n# break\r\n \r\n# print(ans)\r\n\r\nq = q[::-1]\r\n\r\nif s != q:\r\n ans = 'NO'\r\n\r\nprint(ans)", "a=input()\r\na=a[::-1]\r\nc=input()\r\nif(a==c):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input()).lower()\r\nt = str(input()).lower()\r\n\r\ns_list = list(s)\r\ns_list.reverse()\r\n\r\nst = ''.join(s_list)\r\n\r\nif st == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def inverse():\r\n string_org = input()\r\n string_inv = input()\r\n if string_org[::-1] == string_inv:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\n\r\nif __name__ == '__main__':\r\n inverse()\r\n", "n=input()\r\nm=input()\r\nr=n[::-1]\r\nif(m==r):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "one = list(input())\r\ntwo = list(input())\r\ntwo.reverse()\r\nif one==two:\r\n print('YES')\r\nelse:\r\n print('NO')", "str1 = input()\r\nstr2 = input()\r\nstr1 = list(str1)\r\nif \"\".join(str1[::-1]) == str2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "berland = input()\r\nbirland = input()\r\n\r\ntranslate = []\r\nfor char in berland[::-1]: \r\n translate.append(char)\r\n \r\ntranslated = ''.join(translate)\r\n\r\nif translated == birland:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t= input()\r\ns = input()\r\na = list(reversed(s))\r\ns = ''.join(a)\r\ncount = 0\r\nif t == s :\r\n print('YES')\r\nelse : print('NO')", "str1 =input()\r\nstr2=input()\r\nstr2=str2[::-1] \r\nprint('YES' if str1 == str2 else 'NO')\r\n", "a=input()\r\nb=input()\r\nr=a[ : : -1]\r\nif(b==r):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input())\r\nreverse = s[::-1]\r\nnew = str(input())\r\n\r\nif(new == reverse): \r\n print(\"YES\")\r\nelse: \r\n print(\"NO\")", "word_s = input()\r\nword_t = input()\r\nif word_s[::-1] == word_t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "w_ber=input()\r\nw_bir=input() \r\nfor i in range(len(w_ber)):\r\n if w_ber[i]!=w_bir[-(i+1)]:\r\n print('NO')\r\n break\r\nelse:\r\n print('YES')\r\n", "s = input()\r\nt = input()\r\ns_ = s[::-1]\r\nif s_ == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=input()\r\nb=input()\r\nc=\"\"\r\nfor i in range(len(a)-1,-1,-1):\r\n c=c+a[i]\r\nif c==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "li1=list(input())\r\nli2=list(input())\r\nli2.reverse()\r\nif li1==li2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nrev_s = ''.join(reversed(s))\r\nif rev_s == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "n = input()\r\nm = input()\r\na = []\r\nb = []\r\nfor element in n:\r\n a.append(element)\r\nfor element in m:\r\n b.append(element)\r\nb.reverse()\r\nif a == b:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=str(input())\r\nr=str(input())\r\nx=[]\r\nfor i in range(1,len(s)+1):\r\n x.append(s[-i])\r\nt=\"\".join(x)\r\nif(t==r):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "st=input()\r\nst2=input()\r\nrev=st[::-1]\r\nif(st2==rev):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input()\r\nx=len(a)\r\nok=0\r\nfor i in range (0,x):\r\n num=(i+1)*-1\r\n if a[i]==b[num] :\r\n continue\r\n else:\r\n print(\"NO\")\r\n ok=1\r\n break\r\nif ok==0:\r\n print(\"YES\")", "n = input()\r\nm = input()\r\nl = -1\r\nc = 0\r\nif len(n) == len(m) :\r\n for i in range(len(n)) :\r\n if n[i] != m[l] :\r\n c = 1\r\n l-=1\r\nelse :\r\n c = 1\r\nif c == 1:\r\n print('NO')\r\nelse :\r\n print('YES')\r\n", "def main():\n a, b = input(), input()\n if a[::-1] == b:\n print(\"YES\")\n else:\n print(\"NO\")\n\nt = 1\n# t = int(input())\nwhile t:\n main()\n t-=1", "s = input()\r\nb = input()\r\nif s== b[::-1] :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s, t, t0 = input(), input(), ''\r\n\r\nfor i in range(len(s)):\r\n t0 += s[ (i+1) * -1 ]\r\n\r\nif t == t0:\r\n print('YES')\r\nelse:\r\n print('NO')", "a=input()\r\nb=input()\r\nd=''.join(reversed(a))\r\nif b==d:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\r\nstring = input()\r\nrevString = input()\r\n\r\nif revString==string[::-1]:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")\r\n", "s=input().lower()\r\nt=input().lower()\r\nh=s[::-1]\r\nif t==h:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "s = input()\r\ns1 = input()\r\nif s[::1] == s1[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\n# Sat Oct 23 2021 16:00:04 GMT+0000 (Coordinated Universal Time)\n\n# Sat Oct 23 2021 16:02:04 GMT+0000 (Coordinated Universal Time)\n", "a = input()\r\nb = input()\r\nstr = ''\r\nfor i in a:\r\n str = i+str\r\nif str == b:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = str(input())\na = str(input())\ninput = s\nstringlength=len(s)\nslicedString=s[stringlength::-1]\nif ( a==(slicedString)):\n print (\"YES\")\nelse :\n print (\"NO\")\n\n \t\t\t \t \t\t \t \t\t \t \t\t \t \t", "s=input()\r\nt=input()\r\ns=\"\".join(reversed(s))\r\n# print(s)\r\nif s == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "k=input()\r\nw=input()\r\ni=0\r\nj=len(w)-1\r\nwhile (j>=0):\r\n if(w[j]==k[i]):\r\n j-=1\r\n i+=1\r\n else:\r\n print(\"NO\")\r\n exit()\r\nprint(\"YES\")", "s=input()\r\nss=input()\r\nif s==ss[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "word_1 = input()\r\nword_2 = input()\r\nreversed_word = word_1[::-1]\r\nif word_2 == reversed_word :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")\r\n\r\n", "s, t = input(), input()\r\n\r\nif (len(s) != len(t)):\r\n print(\"NO\")\r\n quit()\r\n\r\nfor index in range(len(s)):\r\n if s[index] != t[len(s) - index - 1]:\r\n print(\"NO\")\r\n quit()\r\n \r\nprint(\"YES\")", "s1=input()\r\ns2=input()\r\ns3=\"\"\r\nfor i in range(len(s1)-1,-1,-1):\r\n s3=s3+s1[i]\r\nif s2==s3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x = input()\r\ny = input()\r\nk = list(y)\r\nk.reverse()\r\ns = ''.join(k)\r\nif(x==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = input()\r\nt = input()\r\nprint(['NO', 'YES'][s == ''.join(list(reversed(t)))])", "s=input(); print('YES' if s[::-1]==input() else 'NO')", "# The translation from the Berland language into the Birland language is not an easy task.\r\n# Those languages are very similar: a berlandish word differs from a birlandish word with \r\n# the same meaning a little: it is spelled (and pronounced) reversely. For example, \r\n# a Berlandish word code corresponds to a Birlandish word edoc. However, \r\n# it's easy to make a mistake during the «translation». \r\n# Vasya translated word s from Berlandish into Birlandish as t. Help him: \r\n# find out if he translated the word correctly.\r\n\r\n# Input\r\n# The first line contains word s, the second line contains word t. \r\n# The words consist of lowercase Latin letters. The input data do not\r\n# consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.\r\n\r\n# Output\r\n# If the word t is a word s, written reversely, print YES, otherwise print NO.\r\n\r\nmainWord = input()\r\nrevWord = input()\r\n\r\nif (revWord == mainWord[::-1]):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nnew = ''.join(reversed(s))\r\nif new == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "def rev(s1,s2):\r\n return s1==s2[::-1]\r\ns1=input()\r\ns2=input()\r\nif(rev(s1,s2)):\r\n print('YES')\r\nelse:\r\n print('NO')", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Mar 29 03:06:43 2020\n\n@author: mac\n\"\"\"\n\n\ns1 = input()\ns2 = input()\n\nif s1 == s2[::-1]:\n print('YES')\nelse:\n print('NO')", "x = input()\r\ny = input()\r\na = (x[::-1])\r\nif (y == a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nt = t[::-1]\r\nif s==t:print(\"YES\")\r\nelse:print(\"NO\")", "def reverse(s):\n str=\"\"\n for i in s:str=i+str\n return str\ns,t=input(),input();print([\"NO\",\"YES\"][reverse(s)==t])", "a=input()\r\nb=input()\r\np=13\r\nfor i in range(len(a)):\r\n if a[i]==b[-1-i]:\r\n p=1\r\n else:\r\n p=0\r\n print(\"NO\")\r\n break\r\nif p==1:\r\n print(\"YES\")", "s= input()\r\nt= input()\r\nif s[::-1]==t:\r\n print(\"YES\")\r\nelse: print(\"NO\")", "import math\r\nfrom collections import defaultdict\r\nfrom collections import Counter \r\nimport itertools\r\n\r\ndef solve(s,t):\r\n if s[::-1] == t:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n \r\ns = input()\r\nt = input()\r\nprint(solve(s,t))", "import sys\r\nn=sys.stdin.readline().strip()\r\nt=sys.stdin.readline().strip()\r\nif t==n[::-1]:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n\r\n\r\n", "st1 = input()\r\nst2 = input()\r\nst2 = st2[::-1]\r\nif st1 == st2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def reverse(s):\r\n if len(s) == 0:\r\n return s\r\n else:\r\n return reverse(s[1:]) + s[0]\r\n\r\na = reverse(input())\r\nb = input()\r\n\r\nif a == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\ntt = t[::-1]\r\n#print(tt)\r\nif s == tt:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def is_correct(s1, s2):\r\n if s1 == s2[::-1]:\r\n return \"YES\"\r\n return \"NO\"\r\ns1 = input()\r\ns2 = input()\r\nprint(is_correct(s1, s2))", "def sol():\n s=str(input()).lower().strip()\n t=str(input()).lower().strip()\n if len(s)<=100 and len(t)<=100:\n str1=\"\"\n for i in s:\n str1 = i + str1\n if str1==t:\n return \"YES\"\n else:\n return \"NO\"\n\nif __name__=='__main__':\n print(sol())\n", "str1=input()\r\nstr2=input()\r\nlist1=list(str1)\r\nlist2=list(str2)\r\nlist2.reverse()\r\nif list1==list2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Tue Aug 25 13:12:49 2020\r\n\r\n@author: Yogesh Panjwani\r\n\"\"\"\r\n\r\ns=input()\r\nt=input()\r\ns=s[::-1]\r\nif s==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\ntrans = ''\r\n\r\nfor i in range(len(s)):\r\n\r\n trans= trans+s[len(s)-1-i:len(s)-i]\r\n\r\nif t == trans:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "import math\r\nimport os\r\nimport random\r\nimport re\r\nimport sys\r\n\r\ns = input()\r\nt = input()\r\nif t == s[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "def my_reverse(word: str) -> str:\n drow = \"\"\n for i in range(len(word), 0, -1):\n drow += word[i-1]\n return drow\n\n\ndef solve():\n s, t = input(), input()\n print(\"YES\") if s == my_reverse(t) else print(\"NO\")\n\n\nif __name__ == \"__main__\":\n solve()\n", "m=list(input())\r\nn=list(input())\r\nif m[::-1]==n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def translation(word,wordr):\r\n if word[::-1]!=wordr:\r\n return 'NO'\r\n else:\r\n return 'YES'\r\nlik=input()\r\nsam=input()\r\nprint(translation(lik,sam))", "e =input()\r\ne1 =input()\r\ne1 =e1[::-1]\r\nif e == e1:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "# coding=utf-8\ns=input()\r\nt=input()\r\nq=0\r\nm=len(s)\r\nn=len(t)\r\nif m==n:\r\n for i in range(m):\r\n if s[i]==t[(m-i-1)]:\r\n q+=1\r\n if q==len(s):\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')\r\n\r\n\n \t\t \t \t\t\t \t \t\t \t \t\t\t\t", "user_inp1=input(\"\")\r\nuser_inp2=input(\"\")\r\nreverse=\"\"\r\nfor i in user_inp2:\r\n reverse=i+reverse\r\nif reverse==user_inp1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=str(input())\r\ns=str(input())\r\nj=n[::-1]\r\nif j==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\ns=input()\r\nxd=list(n)\r\nxd.reverse()\r\nss=''.join(xd)\r\nnghia=0\r\nfor i in range (len(n)):\r\n if(s[i]!=ss[i]):\r\n nghia=1\r\n print(\"NO\")\r\n break\r\nif nghia==0: print(\"YES\")", "s=input()\r\nt=input()[::-1]\r\nif s.lower()==t.lower():\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "#import sys\n#\n#count=0\n#\n#for line in sys.stdin:\n# count +=1\n# if count > 1:\n# if len(line.strip('\\n')) <= 10:\n# print(line.strip('\\n'))\n# if len(line.strip('\\n')) > 10:\n# print(line[0] + str((len(line.strip('\\n')))-2) + line[-2])\n\n#vowels = [\"A\", \"a\", \"O\", \"o\", \"Y\", \"y\", \"E\", \"e\", \"U\", \"u\", \"I\", \"i\"]\n#output = \"\"\n#\n#string = input()\n#for char in range(len(string)):\n# if string[char] in vowels:\n# pass\n# else:\n# output += \".\"\n# output += string[char].lower()\n#print(output)\n\n\n#import sys\n#\n#count=0\n#\n#for line in sys.stdin:\n# count +=1\n# if count == 2:\n# a = line.strip('\\n').split()\n# a.sort()\n# print(a)\n# if count == 3:\n# b = line.strip('\\n').split()\n# b.sort()\n# print(b)\n# if count == 4:\n# c = line.strip('\\n').split()\n# c.sort()\n# print(c)\n#\n#count=0\n#\n#def removeFirstDouble(a, b):\n# if a[0] == b[0]:\n# a.remove(a[0])\n# b.remove(b[0])\n#\n#removeFirstDouble(a,b)\n#print(a)\n\n\n#print(string[::-1])\n\nimport sys\n\ncount=0\n\nfor line in sys.stdin:\n count +=1\n if count == 1:\n a = line.strip('\\n')\n if count == 2:\n b = line.strip('\\n')\n\nif a == b[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n\n\n", "a = [i for i in input()]\r\nb = [i for i in input()]\r\na.reverse()\r\nif b == a:\r\n print('YES')\r\nelse:\r\n print('NO')", "str0=input()\r\nex=input()\r\nstr1=str0[::-1]\r\nif ex==str1:\r\n print('YES')\r\nelse:\r\n print('NO')", "x=input;print(\"YNEOS\"[x()!=x()[::-1]::2])", "def isLucky(s,t):\r\n if len(s)!=len(t):\r\n return False\r\n return s==t[::-1]\r\n\r\ns=input()\r\nt=input()\r\nif isLucky(s,t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def translate():\r\n if len(s) != len(t):\r\n return \"NO\"\r\n length = len(s)\r\n for i in range(length):\r\n if s[i] != t[length-i-1]:\r\n return \"NO\"\r\n else:\r\n return \"YES\"\r\n\r\n\r\nif __name__ == '__main__':\r\n s = input()\r\n t = input()\r\n print(translate())\r\n\r\n", "str1 = input()\r\nstr2 = input()\r\n\r\nif (str1[::-1]) == str2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def solution():\n s, t = input(), input()\n\n result = True\n if len(s) != len(t):\n result = False\n else:\n i, j = 0, len(t) - 1\n while i < len(s):\n if s[i] != t[j]:\n result = False\n break\n\n i += 1\n j -= 1\n\n answer = \"YES\" if result else \"NO\"\n print(answer)\n\n\nif __name__ == \"__main__\":\n solution()\n", "\r\nn = input()\r\nr = input()\r\n\r\nif n[::-1] == r:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n#print (n)\r\n\r\n#txt = \"Hello World\"[::-1]\r\n#print(txt)", "a=input()\r\nb=input()\r\nc=len(a)\r\nd=len(b)\r\nr=0\r\nif c!=d:\r\n print('NO')\r\nelse:\r\n for i in range(c):\r\n if a[i]==b[c-i-1]:\r\n r+=1\r\n else:\r\n break\r\n if r==c:\r\n print('YES')\r\n else:\r\n print('NO')", "word = input()\r\nrev_word = input()\r\n\r\nif rev_word == \"\".join(reversed(word)):\r\n\tprint(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = str(input())\r\nb = str(input())\r\nc = a[::-1]\r\nif len(a)==len(b):\r\n if b==a[::-1]:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Mon Oct 19 18:00:30 2020\r\n\r\n@author: Lenovo\r\n\"\"\"\r\n\r\ns=list(input())\r\nt=list(input())\r\ns.reverse()\r\nif s==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nk=[]\r\nfor i in range(len(t)):\r\n k.append(t[len(t)-i-1])\r\nn=\"\".join(k)\r\nif n==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\ny = s[::-1]\r\nif t == y:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\nt=input()\ncount=0\n\nif len(s)==len(t):\n for i in range(len(s)): \n if s[i] == t[-1-i]:\n count+=1\n\nif count == len(s):\n print(\"YES\")\nelse: \n print(\"NO\") \n\n\n\n\n", "s = input()\r\nt = input()\r\nm = list(reversed(s))\r\nm = ''.join(m)\r\nif m == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def Problem():\r\n S1=input()\r\n S2=input()\r\n Test=True\r\n for i in range(len(S1)):\r\n if(S1[i]!=S2[len(S2)-1-i]):\r\n Test=False\r\n break\r\n if Test:\r\n print('YES')\r\n else:\r\n print('NO')\r\nProblem()", "s=input()\na=input()\ns=s[::-1]\nif(s == a):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n \t \t \t\t\t\t\t\t\t\t \t\t\t \t \t\t\t", "w1 = input()\r\nw2 = input()\r\nsize = len(w2)\r\nflag = True\r\nfor i in range(size):\r\n if w1[i] != w2[size - i - 1]:\r\n flag = False\r\n break\r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "A = input()\r\nB = input()\r\npoczatek = 0\r\nkoniec = len(A) - 1\r\nwarunek = True\r\n\r\nif len(A) == len(B):\r\n\r\n for x in range(len(A)):\r\n if A[poczatek] != B[koniec]:\r\n warunek = False\r\n poczatek += 1\r\n koniec -= 1\r\n if warunek == True:\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')\r\n", "n= (input())\r\nt= (input())\r\ns=t[::-1]\r\nif n == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "'''\n\nWelcome to GDB Online.\nGDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,\nC#, OCaml, 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'''\nt=input()\nt2=input()\nre=t[::-1]\nif t2 == re:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n ", "s=input()\r\nt=input()\r\ny=\"\"\r\nfor i in range(len(s)):\r\n if s[i]==t[len(t)-1-i]:\r\n y+=\"YES\"\r\n else:\r\n y+=\"NO\"\r\nif \"NO\" in y:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n", "def translation(w,w1):\r\n if w[::-1]!=w1:\r\n return 'NO'\r\n else:\r\n return'YES'\r\n\r\n\r\nx=input()\r\ny=input()\r\nprint(translation(x,y))\r\n", "n1 = input()\r\nn2 = input()\r\n\r\nt = len(n2) - 1\r\ncount = 0\r\nfor i in range(len(n1)):\r\n if (n1[i] == n2[t]):\r\n count += 1\r\n t -= 1\r\n\r\nif count == len(n1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\ns=input()\r\nif a[::-1]==s:print(\"YES\")\r\nelse:print(\"NO\")", "s = input() \r\nt = input()\r\nj = list(t)\r\nk = list(s)\r\nk.reverse()\r\nif k == j:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "v=input;print(\"YNEOS\"[v()!=v()[::-1]::2])\r\n#hi codeforces\r\n#", "x = input()\r\ny = input()\r\nreversedString = \"\"\r\nif(len(x) == len(y)):\r\n reversedString = x[::-1]\r\nif(reversedString == y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "print((lambda x,y: \"YES\" if(x[::-1] == y) else \"NO\")(input(), input()))\r\n", "s = input()\r\nt = input()\r\n\r\nprint([\"NO\", \"YES\"][s == t[::-1]])", "def translation(s,t):\r\n for i in range(len(s)):\r\n if s[i] != t[len(t)-1-i]:\r\n return \"NO\"\r\n return \"YES\"\r\n\r\ndef main():\r\n s = str(input())\r\n t = str(input())\r\n ans = translation(s,t)\r\n print(ans)\r\n \r\nmain()", "a = input()\r\nb = input()\r\nq = 0\r\nif len(a) == len(b):\r\n for i in range(len(a)):\r\n if a[i] != b[len(a) - 1 - i]:\r\n q += 1\r\n break\r\n if q == 1:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\nt_arr = list(t)\nt_arr.reverse()\nt_final = ''.join(t_arr)\nif s == t_final:\n print('YES')\nelse:\n print('NO')\n", "word = input() #code\r\nreversed = input() #edoc\r\nno_times = len(word)\r\ntest = (\"\")\r\nx = 1\r\nfor i in range(no_times):\r\n test = test + word[len(word) - x]\r\n x = x + 1\r\nif reversed == test:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word=input()\r\nword1=input()\r\nreversed_word=''\r\ninde=-1\r\nfor i in word:\r\n reversed_word+=word[inde]\r\n inde-=1\r\nif reversed_word==word1:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\nt = input()\n\ncont = len(s)\nis_diff = False\nfor character in t:\n cont -= 1\n if character != s[cont]:\n is_diff = True\n break\n\nprint(\"NO\") if is_diff else print(\"YES\")\n\t \t\t\t \t\t \t \t\t \t \t\t \t\t \t\t \t", "text1 = input()\ntext2 = input()\n\nif text1 == text2[::- 1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n# this worked the first time\n\t \t \t\t \t \t\t \t \t \t \t\t\t\t", "ai = input()\r\nan = input()\r\nif ai == an[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "one = input()\r\ntwo = input()\r\nif two == one[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\nn1=input()\r\nif(n1==n[::-1]):\r\n print('YES')\r\nelse:\r\n print('NO')", "print('YES' if ''.join([_ for _ in reversed(input())]) == input() else 'NO')", "def reverse(s):\r\n s = s[::-1]\r\n return s\r\n \r\na=input()\r\nb=input()\r\nif reverse(b)==a:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "from sys import stdin\r\n\r\ndef main():\r\n inp=stdin\r\n palabra1=inp.readline().strip()\r\n palabra2=inp.readline().strip()\r\n comparar=''\r\n for i in range(len(palabra1)-1,-1,-1):\r\n comparar+=palabra1[i]\r\n if comparar==palabra2:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nmain()\r\n \r\n", "def main():\r\n word1 = input()\r\n word2 = input()\r\n\r\n if(word2[::-1] == word1):\r\n return \"YES\"\r\n return \"NO\"\r\n\r\nprint(main())\r\n", "arr1 = input()\r\narr2 = input()\r\n\r\nif len(arr1) != len(arr2):\r\n print(\"NO\")\r\nelse:\r\n i = 0\r\n j = len(arr1)-1\r\n msg = \"YES\"\r\n while i < len(arr1):\r\n if arr1[i] == arr2[j]:\r\n i += 1\r\n j -= 1\r\n else:\r\n msg = \"NO\"\r\n break\r\n print(msg)", "s=str(input(\"\"))\r\nt=str(input(\"\"))\r\nresult=\"NO\"\r\nif(t[-1::-1]==s):\r\n result=\"YES\"\r\nprint(result)", "i = input()\nj = input()\nprint('YES' if i[::-1] == j else 'NO')", "s = str(input())\r\nt = str(input())\r\nw = len(s)\r\ny = ''.join(reversed(s))\r\nflag = True\r\nfor i in range(w):\r\n if t[i] != y[i]:\r\n flag = False\r\n break\r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n", "\r\nprint([\"YES\",\"NO\"][input()!=input()[::-1]])", "t = input()\r\ns = input()\r\nif len(t) != len(s):\r\n print('NO')\r\nelse:\r\n valid = True\r\n for i in range(len(t)):\r\n if t[i] != s[len(t)-i-1]:\r\n valid = False\r\n if valid:\r\n print('YES')\r\n else:\r\n print('NO')\r\n", "def trans (a,b):\r\n x=len(b)\r\n for i in range (0,x):\r\n if a[i]==b[x-1-i]:\r\n continue\r\n else:\r\n return False\r\n return True \r\n \r\n\r\na=input()\r\nb=input()\r\nif trans (a,b):\r\n print (\"YES\")\r\nelse:\r\n print (\"NO\")", "source=input()\r\ntranslation=input()\r\nif(source[::-1]==translation):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "num=input(\"\")\r\nn=input(\" \")\r\nif(num==n[::-1]):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "ber=str(input())\r\nbir=str(input())\r\n\r\nif ber==bir[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "text1 = list(input())\ntext2 = list(input())\ntext2.reverse()\nif text1 == text2:\n print(\"YES\")\nelse:\n print(\"NO\")", "def A41(string1,string2):\r\n reversed_string = string1[::-1]\r\n if reversed_string == string2:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\nstring1 = input()\r\nstring2 = input()\r\nA41(string1,string2)\r\n", "x=input()\r\ny=list(input())\r\ny.reverse()\r\nz=\"\".join(y)\r\nif z==x:\r\n\tprint(\"YES\")\r\nelse:print(\"NO\")\t", "s = input()\nt = input()\ntl = len(t)-1\n\nans = 1\n\nfor i in range(len(s)):\n if(s[i] != t[tl]):\n ans = 0\n break\n tl -= 1\n\nif(ans == 1):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \t \t \t \t \t\t \t \t\t \t\t\t \t\t\t \t \t", "word1 = input()\r\nword2 = input()\r\n\r\nword3 = word2[::-1]\r\n\r\nif (word1 == word3):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\nrev=\"\"\r\nfor i in s[::-1]:\r\n rev+=i\r\nif(rev==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sun Oct 24 15:39:01 2021\r\n\r\n@author: Nikiq\r\n\"\"\"\r\n\r\ns = input()\r\ns = s[::-1]\r\n#[::-1] reverses a string, s.reverse() reverses a list\r\n#print(s)\r\nn = input()\r\nif s == n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "k=input()\np=input()\nrev=k[::-1]\nif rev==p:\n print('YES')\nelse:\n print('NO')\n\n \t\t\t \t\t\t\t \t\t \t \t\t\t \t \t \t", "s=input()\r\nt=input()\r\nif (len(s) != len(t)):\r\n print(\"NO\")\r\n quit()\r\n\r\nfor i in range(len(s)):\r\n if s[i] != t[len(s) - i - 1]:\r\n print(\"NO\")\r\n quit()\r\n \r\nprint(\"YES\")\r\n", "a = input()\r\nb = input()\r\ns1 = a[:len(a)//2]\r\ns2 = a[len(a)//2:]\r\nif(s2[::-1]+s1[::-1] == b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "S=input()[::-1]\r\nA=input()\r\nif(S==A):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\nb=input()\nrev=a[::-1]\nif rev==b:\n\tprint('YES')\nelse:\n\tprint('NO')\n", "ber_code = input()\r\nbir_code = input()\r\nprint(\"YES\" if ber_code==bir_code[::-1] else \"NO\")", "s=input();t=input();print([\"NO\",\"YES\"][s[::-1]==t])", "s=input()\r\nt=input()\r\ns1=s[::-1]\r\nif(t==s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = input()\r\ns2 = input()\r\nl = list()\r\ns = \"\"\r\ni = len(s1)-1\r\nwhile not i == -1:\r\n l.append(s1[i])\r\n i = i - 1\r\nfor k in l:\r\n s = s + k\r\nif s2 == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s = [i for i in input()]\r\nt = input()\r\ns.reverse()\r\nif ''.join(s) == t:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "def solve():\r\n print([\"NO\", \"YES\"][input() == input()[::-1]])\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\nif __name__ == \"__main__\":\r\n main()", "\r\n\r\n\r\ns=input();r=input()\r\ntxts = [x for x in str(s)]; txtr = [x for x in str(r)]\r\n\r\nh=0\r\nfor i in range(len(txts)):\r\n if txts[i] != txtr[-(i+1)]:\r\n print(\"NO\")\r\n h+=1\r\n break\r\n\r\nif h==0:\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\r\n", "import sys\nimport math\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"./output.txt\", \"w\")\n\nstring1 = input()\nstring2 = input()\nif (string1 == string2[::-1]):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "first_word=input()\r\nsecond_word=input()\r\nif first_word==second_word[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n", "s=[* input()]\nt=[* input()]\nt.reverse()\nif s==t:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s=input()\nt=list(reversed(list(input())))\nfor letter_s,letter_t in zip(s,t):\n if letter_s!=letter_t:\n print(\"NO\")\n break\nelse:\n print(\"YES\")", "s = input()\r\n\r\nt = input()\r\n\r\ncorrect = True\r\ni = 0\r\nj = len(t) - 1\r\nwhile i < len(s):\r\n if s[i] != t[j]:\r\n correct = False\r\n break\r\n i += 1\r\n j -= 1\r\n\r\nif correct:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "s = input()\r\nt = input()\r\nout = ''\r\nlis = list(s)\r\n\r\nfor id in reversed(lis):\r\n out = out +id\r\nif t == out:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nprint('NO' if len(s) != len(t) or t[::-1] != s else 'YES')\r\n", "word = list(map(str, input()))\r\nre_word = list(map(str, input()))\r\nre_word.reverse()\r\nprint('YES' if word == re_word else 'NO')", "##i1 = input('').lower()\n##i2 = input('').lower()\n##if i1< i2:\n## print('-1')\n##elif i1 > i2:\n## print('1')\n##else:\n## print('0')\n\n##line = input('')\n##verdict = 'NO'\n##for i in range(0, len(line), 1):\n## if line[i:i+7]== line[i]*7:\n## verdict = 'YES'\n##print(verdict)\n\n##n = int(input(''))\n##t = 0\n##numrooms = 0\n##while t != n:\n## p, q = [int(t) for t in input('').split(' ')]\n## if p + 2 <= q:\n## numrooms = numrooms + 1\n## t = t+1\n##print(numrooms)\n\ns = input('')\nt = input('')\nif t == s[::-1]:\n print(\"YES\")\nelse:\n print('NO')\n", "nor=[char for char in input()]\r\nron=[char for char in input()]\r\nron.reverse()\r\nif nor==ron:\r\n print('YES')\r\nelse:\r\n print('NO')", "A=input()\r\nB=input()\r\nA1=A[::-1]\r\nif A1==B:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t = input()\r\ns = input()\r\n\r\nif(s==\"\".join(reversed(t))):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \r\n ", "s = input()\r\ntt = input()\r\nss=\"\"\r\nfor c in s:\r\n ss = c + ss\r\nif(ss == tt):\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\nt = input()\n\nreversed = (t[::-1])\nif s == reversed:\n print (\"YES\")\nelse: \n print (\"NO\")", "z=input()\r\nx=str(input())\r\na=z[::-1]\r\nif(a==x):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "import sys\r\ninput = sys.stdin.readline\r\noutput = sys.stdout.write\r\n\r\n\r\ndef main():\r\n word = input().rstrip()\r\n translated = input().rstrip()\r\n state = True\r\n l = len(word)\r\n r = len(translated)\r\n if l != r:\r\n output('NO')\r\n else:\r\n for i in range(l):\r\n if word[i] == translated[l - i -1]:\r\n continue\r\n else:\r\n state = False\r\n break\r\n if state:\r\n output('YES')\r\n else:\r\n output('NO')\r\n\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n\r\n", "a = input()\r\nb = input()\r\nif a == b[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\n# Sat Dec 18 2021 20:30:41 GMT+0000 (Coordinated Universal Time)\n", "def reverse(list):\n if len(list)==1:\n return list\n else:\n return list[-1]+reverse(list[:-1])\nx=input()\ny=input()\na=reverse(x)\nif y==a:\n print(\"YES\")\nelse:\n print(\"NO\")", "s1 = list(input())\ns2 = list(input())\nl = []\nisCorrect = True\nif len(s1) == len(s2):\n for i in range(len(s1)):\n if s1[i] != s2[len(s1)-i-1]:\n isCorrect = False\n break\nelse:\n isCorrect = False\nif isCorrect:\n print(\"YES\")\nelse:\n print(\"NO\")", "inp = input()\r\ninp2 = input()\r\nif inp == inp2[::-1]:\r\n print('YES')\r\nelif inp != inp2[::-1]:\r\n print(\"NO\")\r\n \r\n ", "s1=input()\r\ns2=input()\r\ng1=list(s1)\r\ng2=list(s2)\r\ng2.reverse()\r\nif g1 == g2 :\r\n print('YES')\r\nelse:\r\n print('NO')", "n=input(\"\")\r\nz=input(\"\")\r\nm=n[::-1]\r\nif(m==z):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nb=input('')\r\nl1=[x for x in str(a)]\r\nl2=[x for x in str(b)]\r\n\r\n\r\nl2.reverse()\r\n\r\nif l1==l2:\r\n print('YES')\r\nelse:\r\n print('NO') \r\n", "s=input();t=input();print([\"NO\",\"YES\"][t==s[::-1]])", "def reverse (word):\n if word == \"\":\n return \"\"\n else:\n return word[-1] + reverse (word[:-1]) \n\ns = input()\nt = input()\nif reverse(s) == t:\n print(\"YES\")\nelse:\n print(\"NO\")\n\t \t \t \t \t\t\t\t \t \t\t\t \t \t\t", "print(['NO','YES'][input()[::-1]==input()])", "x = input()\r\ny = input()\r\nif len(x) != len(y):\r\n print(\"NO\")\r\n exit()\r\nif len(x) > 100:\r\n print(\"NO\")\r\n exit()\r\nc = 0\r\nn = 0\r\np = -1\r\nwhile c < len(x):\r\n if x[c] == y[p]:\r\n n += 1\r\n c += 1\r\n p -= 1\r\nif n == len(x):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\nx=input()\nb=a[::-1]\nif list(x)==list(b):\n print('YES')\nelse:\n print('NO')\n", "a = input()\nb = input()\nif (len(a) != len(b)):\n\tprint(\"NO\")\nelse:\n\tf = 1\n\tfor i in range(len(a)):\n\t\tif (a[i] != b[len(a)-i-1]):\n\t\t\tf = 0\n\t\t\tbreak\n\tif (f):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")", "s=input()\r\nt=input()\r\na=t[::-1]\r\nb=\"\"\r\nb1=\"\"\r\nif len(a)==len(s):\r\n for i in s:\r\n b+=i\r\n for j in a:\r\n b1+=j\r\n if b==b1:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")", "def berlandish(s, t):\n if s == t[::-1]:\n return \"YES\"\n else:\n return \"NO\"\n\n\n# Press the green button in the gutter to run the script.\nif __name__ == '__main__':\n s = input()\n t = input()\n\n result = berlandish(s, t)\n print(result)\n\n \t \t \t\t\t \t \t\t \t \t \t \t \t", "n=input()\nm=input()\nk=m[::-1]\nif k==n:\n print(\"YES\")\nelse:\n print(\"NO\")", "def is_reverse(s, t):\r\n if len(s) != len(t):\r\n return False\r\n\r\n for i in range(len(s)):\r\n if s[i] != t[len(t) - 1 - i]:\r\n return False\r\n\r\n return True\r\n\r\ns = input().strip()\r\nt = input().strip()\r\n\r\n\r\nresult = \"YES\" if is_reverse(s, t) else \"NO\"\r\nprint(result)\r\n", "s = str(input())\r\nt = str(input())\r\na = ''\r\nfor i in range (-1,-(len(s)+1),-1):\r\n a = a + s[i]\r\nif a == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "print([\"YES\", \"NO\"][input()!=\"\".join(list(reversed(input())))])", "text_1 = list(input())\r\ntext_2 = list(input())\r\ntext_revers = text_1[::-1]\r\n\r\nif text_2 == text_revers:\r\n print('YES')\r\nelse:\r\n print('NO')", "word1=input()\r\nword2=input()\r\ntest=\"\"\r\nfor i in reversed(range(len(word1))):\r\n test+=word1[i]\r\nif test==word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "string1=input()\r\nstring2=input()\r\nstring2=list(string2)\r\nn=len(string2)\r\ni=0\r\nt=n/2\r\nwhile i<t:\r\n a=string2[i]\r\n string2[i]=string2[n-i-1]\r\n string2[n-i-1]=a\r\n i+=1\r\nstring2=\"\".join(string2)\r\nif string2==string1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = list(input())\r\nb = list(input())\r\nprint(\"YES\" if ''.join(a) == ''.join(reversed(b)) else \"NO\")", "ber = list(input())\r\nbir = list(input())\r\nif bir == list(reversed(ber)):\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\n\r\nprint(\"YES\" if (s[::-1] == t) else \"NO\")", "s=input()\r\nt=input()\r\nn=len(s)\r\nl=[]\r\nfor i in range(n):\r\n l.append(s[i])\r\nl.reverse()\r\ns=''.join(l)\r\nif s==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = list(input())\ns_real = []\nt = list(input())\nfor x in s:\n s_real.insert(0,x)\nif s_real == t:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n", "str = input(\"\")\r\nout = input(\"\")\r\nans = str[::-1]\r\n\r\nif ans == out:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n\r\n", "T = []\r\n\r\ns = input()\r\nt = input()\r\n\r\nfor i in t:\r\n T.append(i)\r\n\r\nT.reverse()\r\n\r\nreversedT = \"\".join(T)\r\n\r\nif s == reversedT:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def solve(n1, n2):\r\n \r\n len1 = len(n1)\r\n len2 = len(n2)\r\n\r\n if(len1!=len2):\r\n return \"NO\"\r\n\r\n for i in range(0,len1):\r\n if(n1[i]!=n2[len1-i-1]):\r\n return \"NO\"\r\n\r\n return \"YES\"\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n n1 = input()\r\n n2 = input()\r\n print(solve(n1,n2))", "be = input()\r\nbi = input()\r\n\r\nt = bi[::-1]\r\n\r\nif be == t :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "s=str(input())\r\nt=str(input())\r\nlst=\"\"\r\nfor i in t:\r\n lst=i+lst\r\nif lst==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "inp = input()\nout = input()\nif inp[::-1] == out:\n print('YES')\nelse:\n print('NO')\n\n\n", "e=input()\r\nn=input()\r\nif e == n[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "x=input()\r\ny=input()\r\nx1=x[::-1] \r\nif x1==y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "print(\"YES\" if input() == input()[::-1] else \"NO\")\n# word_backwards = input()\n#\n# r = reversed(word_backwards)\n# if word == r:\n# print(\"YES\")\n# else:\n# print(\"NO\")", "\r\ndef f(x):\r\n i=1\r\n l=\"\"\r\n while (i<len(x)+1):\r\n l+=x[-i]\r\n i+=1\r\n return l\r\n \r\n\r\ns=input()\r\nx=f(s)\r\nt=input()\r\nif t==x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "n=input()\nt=input()\nx=''\nfor i in t:\n x=i+x\nif x==n:\n print(\"YES\")\nelse:\n print(\"NO\")", "n = input()\r\nn1 = input()\r\nn = n[::-1]\r\nif n==n1 :\r\n print('YES')\r\nelse:\r\n print('NO')\r\n ", "s1=list(input())\r\ns2=list(input())\r\ns2=s2[::-1]\r\nif(s1==s2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word=input()\r\nreverse=input()\r\n\r\nif word[::-1]==reverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def solve(s1, s2):\r\n\tn = len(s1)\r\n\tif(len(s1) != len(s2)):\r\n\t\tprint(\"NO\")\r\n\t\treturn\r\n\tfor i in range(n):\r\n\t\tif(s1[i] != s2[n-i-1]):\r\n\t\t\tprint(\"NO\")\r\n\t\t\treturn\r\n\tprint(\"YES\")\r\n\r\ns1 = input()\r\ns2 = input()\r\nsolve(s1, s2)\r\n", "word = input()\r\nword\r\nreverse = input()\r\ni = 0\r\nnegative = 0\r\nif len(word) != len(reverse):\r\n negative = 1\r\nwhile i < len(word):\r\n if word[i] == reverse[len(reverse) - 1 - i]:\r\n i = i + 1\r\n else:\r\n negative = 1\r\n break\r\nif negative == 1:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "a=input()\r\nt=input()\r\nc=list()\r\nd=list()\r\nfor i in range(0,len(a)):\r\n c.append(a[i])\r\nfor j in range(0,len(t)):\r\n d.append(t[j])\r\nc.reverse()\r\nif(c==d):\r\n print('YES')\r\nelse :print('NO')\r\n \r\n\r\n\r\n", "st_inp1=input()\nst_inp2=input()\ntranslation=[]\n\nfor n in range(len(st_inp1)-1, -1, -1):\n\ttranslation.append(st_inp1[n])\nif st_inp2==''.join(translation):\n\tprint('YES')\nelse:\n\tprint('NO')\n", "s = input()\r\nt = input()\r\nn = len(s)\r\nflag = 0\r\nif len(t) == n:\r\n flag = 1\r\n for i in range(n):\r\n if s[i] != t[-1-i]:\r\n flag = 0\r\n break \r\nprint([\"NO\", 'YES'][flag])", "t = input().split()\r\ns = input().strip()\r\nr = \"\"\r\nfor i in t:\r\n r += i[::-1]\r\n \r\nif r == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "if __name__ == '__main__':\r\n s = input()\r\n s = list(s)\r\n s1 = input()\r\n s1 = list(s1)\r\n s.reverse()\r\n if s == s1:\r\n print('YES')\r\n else:\r\n print('NO')\r\n", "s = input()\r\nt = input()\r\ni = len(s)-1\r\nu = \"\"\r\nwhile (i>=0):\r\n u += s[i]\r\n # print(u)\r\n i = i-1\r\n \r\nif u == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input(\"\")\r\nk =input(\"\")\r\nt =''.join(reversed(s))\r\nif k == t :\r\n print(\"YES\")\r\nelse :\r\n print(\"NO\")", "word1 = str(input())\r\nword2 = str(input())\r\n\r\nif len(word1) != len(word2):\r\n\tprint(\"NO\")\r\n\tquit()\r\n\r\nfor i in range(len(word1)):\r\n\tif word1[i] != word2[len(word1)-1-i]:\r\n\t\tprint(\"NO\")\r\n\t\tquit()\r\nprint(\"YES\")", "s1 = str(input())\r\ns = str(input())\r\nstringlength=len(s)\r\nslicedString=s[stringlength::-1]\r\n#print(s1)\r\n#print (slicedString)\r\nif slicedString == s1:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nsarr = [x for x in s]\r\n\r\nt = input()\r\ntarr = [x for x in t]\r\ntarr1 = tarr[::-1]\r\n\r\nif len(tarr1)!=len(sarr):\r\n print(\"NO\")\r\nelse:\r\n for i in range(len(tarr1)):\r\n if tarr1[i]!=sarr[i]:\r\n print(\"NO\")\r\n break \r\n else:\r\n print(\"YES\")", "var, car = input(), input()\r\nif car == var[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nl=input()\r\ns1=s[::-1]\r\nif l==s1:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "def fnc(a,b):\n if len(a)!=len(b):\n return 'NO'\n else:\n n=len(a)\n for i in range(len(a)):\n if a[i]!=b[n-1-i]:\n return 'NO'\n return 'YES'\n \n \na=input()\nb=input()\nprint(fnc(a,b))", "import sys\r\n\r\nsona = sys.stdin.readline().strip()\r\nsona_1 = sys.stdin.readline().strip()\r\n\r\ntahti = len(sona)\r\nk = 0\r\nl = -1\r\nvastus = 'NO'\r\nwhile 1:\r\n if sona[k] != sona_1[l]:\r\n break\r\n else:\r\n k += 1\r\n l -= 1\r\n if k == tahti:\r\n vastus = 'YES'\r\n break\r\n\r\n\r\n \r\n#valjund = ''.join(map(str,sona))\r\n\r\n#sys.stdout.write(valjund) \r\nsys.stdout.write(vastus)", "s = input()\nt = input()\ntranslation = \"\"\nfor x in range(len(s)):\n translation = translation + s[len(s)-1-x:len(s)-x]\nif t == translation:\n print(\"YES\")\nelse:\n print(\"NO\")\n\nquit()\n\t\t \t \t \t \t\t \t \t\t \t \t\t \t", "def take_input():\r\n s = input()\r\n t = input()\r\n return s, t\r\n\r\n\r\ndef reverse_matching(s, t):\r\n reversed_t = t[::-1]\r\n # print(reversed_t)\r\n print()\r\n if s == reversed_t:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n\r\ndef main():\r\n s, t = take_input()\r\n reverse_matching(s, t)\r\n\r\n\r\nmain()\r\n", "word = input()\r\nword_reversed = list(reversed(input()))\r\n\r\nif(word==\"\".join(word_reversed)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#n,t = [int(x) for x in input().split()]\ns = input()\nt = input()\n\nif s[::-1] == t:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\n\n", "a = str(input())\nb = str(input())\np = 1\nif len(a) != len(b):\n print(\"NO\")\n exit(0)\nfor i in range(len(a)):\n if a[int(i)] != b[int(len(a)) - int(i) - 1]:\n p = 0\nif p == 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "n=input()\r\nm=input()\r\nl=[x for x in n]\r\nls=[]\r\nnum=len(l)\r\nfor i in range(num):\r\n ls.append(l[-1-i])\r\nnew=''.join(ls)\r\nif new==m:\r\n print('YES')\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nflag=True\r\nj=len(t)-1\r\nfor i in range(len(s)):\r\n # print(s[i])\r\n # print(t[j])\r\n if t[j]!=s[i]:\r\n flag=False\r\n break\r\n j-=1\r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "inputo=input()\ninput2=input()\nif inputo==input2[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n\nquit()\n\t\t\t \t \t \t \t \t \t\t \t \t \t\t \t\t\t", "str1=input()\nstr2=input()\n\nif (str1[::-1]==str2):\n print(\"YES\")\nelse:\n print(\"NO\")", "n = input()[::-1]\r\nm = input()\r\nif n==m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input().strip()\r\nt=input().strip()\r\nr=t[::-1]\r\nif s==r:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "ans = [\"NO\", \"YES\"]\r\ns = input()\r\ns_hat = input()\r\n\r\nprint(ans[s[::-1] == s_hat])", "bandau = input()\nlucsau = input()\nif lucsau == bandau[::-1]: print(\"YES\")\nelse: print(\"NO\")\n \t \t\t\t\t\t\t \t \t\t\t\t\t \t \t \t\t \t\t\t", "inp1 = input()\r\ninp2 = input()\r\n\r\nb = inp1 == inp2[::-1]\r\nif(b):\r\n print (\"YES\")\r\nelse:\r\n print(\"NO\")", "a=input()\r\nc=input()\r\nb=''\r\nfor i in range(1,len(a)+1):\r\n b+=a[-i]\r\nif b==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "#!/usr/bin/env python\n# coding=utf-8\n'''\nAuthor: Deean\nDate: 2021-11-03 23:44:43\nLastEditTime: 2021-11-03 23:46:58\nDescription: Translation\nFilePath: CF41A.py\n'''\n\n\ndef func():\n s1, s2 = input().strip(), input().strip()\n return \"YES\" if s1[::-1] == s2 else \"NO\"\n\n\nif __name__ == '__main__':\n ans = func()\n print(ans)\n", "def translate(s, t):\r\n reverse_t = t[::-1]\r\n if s == reverse_t:\r\n return True\r\n else:\r\n return False\r\n\r\ns = input()\r\nt = input()\r\nif translate(s, t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\ns = list(s)\nt = input()\nt = list(t)\n\nsl = list(reversed(s))\n\nif t == sl:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t \t\t\t \t \t\t\t \t \t \t \t \t", "y=input()\r\nz=input()\r\nq=y[::-1]\r\nif(z==q):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "k=input()\r\nk1=input()\r\nq = k[::-1]\r\nif k1==q:\r\n\tprint (\"YES\")\r\nelse:\r\n\tprint (\"NO\")", "word=str(input())\r\ndrow=str(input())\r\nsum=int(0)\r\ncheck=bool(True)\r\n\r\nfor i in range (len(word)):\r\n if(word[len(word)-1-i]!= drow[i]):\r\n check=False\r\n break\r\nif(check==True):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "first_word = input()\nsecond_word = input()\n\nlist_letters = list(x for x in first_word)\n\nlist_letters.reverse()\n\nreversed_word = ''\nfor x in list_letters:\n\treversed_word += x\n\nif reversed_word == second_word:\n\tprint('YES')\nelse:\n\tprint('NO')\n", "word = input()\r\nreverseWord = input()\r\n\r\ntranslateStatue = 1\r\n\r\ni = 0\r\nj = len(reverseWord)-1\r\n\r\nwhile i < len(word):\r\n if len(word) != len(reverseWord) or word[i] != reverseWord[j]:\r\n translateStatue = 0\r\n break\r\n j -=1\r\n i +=1\r\n\r\nif translateStatue == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\nt=input()\n\nm=s[::-1]\nif m==t:\n\tprint('YES')\nelse:\n\tprint('NO')", "# tests = int(input())\n\n# for i in range(tests):\n\n\n\na = input()\nb = input()\n\n\n\nif a==b[::-1]:\n print(\"YES\")\n\n\nelse:\n print(\"NO\")", "n = input()\r\nk = input()\r\n\r\nsame = True\r\nfor i in range(len(n)):\r\n if n[-(i+1)] != k[i]:\r\n same = False\r\n break\r\n\r\nif same:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\nre = ''\r\nfor i in s:\r\n re = i+re\r\nif re == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "x=input()\ny=input()\nd=0\nif len(x)==len(y):\n for i in range(len(x)):\n if x[i]==y[len(x)-1-i]:\n d+=1\nif d==len(x):\n print('YES')\nelse:\n print('NO')\n", "n=input()\r\ns=input()\r\nif n == s[::-1] : print(\"YES\")\r\nelse:print(\"NO\")\r\n", "str_fir = input()\r\nstr_sec = input()\r\n\r\nstr_rec = \"\"\r\n\r\nfor i in range(len(str_sec) - 1, -1, -1):\r\n str_rec += str_sec[i]\r\n\r\nif str_fir == str_rec:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input())\r\nt = str(input())\r\nu = ''.join(reversed(s))\r\nif u == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n", "input1 = input(\"\")\r\ninput2 = input(\"\")\r\ninput2reversed = \"\"\r\nfor i in range(1, len(input2) + 1):\r\n input2reversed += input2[-i]\r\nif input2reversed == input1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1= input()\r\nstr2= input()\r\nstr3= \" \"\r\nfor f in range(len(str1)):\r\n if str1[f] == str2[len(str2)-1-f]:\r\n str3 = str3+\"YES\"\r\n else:\r\n str3=str3+\"NO\"\r\nif \"NO\" in str3:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "word1 = str(input())\r\nword2 = str(input())\r\nreverse = \"\"\r\ni = len(word1)-1\r\nwhile i >= 0:\r\n reverse += word1[i]\r\n i -= 1\r\nif reverse == word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nif(s.lower()==t[::-1].lower()):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nn=input()\r\nr=\"\"\r\nfor x in n:\r\n r=x+r\r\nif(s==r):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "w=input(\"\")\r\nr=input(\"\")\r\n\r\nwl=w.lower()\r\nrl=r.lower()\r\n\r\nrr=w[::-1]\r\n\r\nif rl==rr:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def rev(a):\r\n\tb=a[::-1]\r\n\treturn b\r\na,b=input(), input()\r\nif rev(a)==b:\tprint(\"YES\")\r\nelse: print(\"NO\")\r\n", "\r\nn = str(input())\r\nx= str(input())\r\n\r\na=\"\".join(reversed(n))\r\nif(a==x):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") \r\n\r\n", "s = list(input())\nt = list(input())\n\nr = s[::-1]\nif t == r:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "x = str(input())\r\ny = str(input())\r\nz = x[::-1]\r\n\r\nif(z==y):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "\r\ndef solve():\r\n berlandish = input()\r\n birlandish = input()\r\n return \"YES\" if berlandish[::-1] == birlandish else \"NO\"\r\n\r\n\r\nprint(solve())\r\n", "s=input()\r\nrev=input()\r\nans=rev[::-1]\r\nif(ans==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nb=input()\r\ns=\"\"\r\nfor i in a:\r\n\ts=i+s\r\nif s==b:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "a = list(input())\r\nb = input()\r\na.reverse()\r\nword =\"\"\r\nfor items in a:\r\n word += items\r\nif word==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# Translation\ns = input()\nt = input()\nx = 1\nans = \"YES\"\nfor i in range(len(s)):\n if s[i] != t[len(t)-x]:\n ans = \"NO\"\n x += 1\nprint(ans)\n", "s=list(input())\r\nt=list(input())\r\ns=s[::-1]\r\nif s==t:\r\n print('YES')\r\nelse:\r\n print('NO')", "m=input()\r\nn=input()\r\nx=n[::-1]\r\nif(m==x):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "word = str(input())\r\nreverse = str(input())\r\nmark = 0\r\nif len(word) != len(reverse):\r\n print('NO')\r\nelse:\r\n for i in range(len(word)):\r\n if word[i] != reverse[-i-1]:\r\n mark += 1\r\n if mark >= 1:\r\n print('NO')\r\n else:\r\n print('YES')", "def str2list(stringa):\r\n lista = list()\r\n for i in range(len(stringa)):\r\n lista.append(stringa[i])\r\n return lista\r\n\r\n\r\na = input()\r\nb = input()\r\na = str2list(a)\r\na.reverse()\r\na = ''.join(map(str, a))\r\nif a == b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=list(input())\r\nt=list(input())\r\nr=s[::-1]\r\nif r==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\narr = [''] * len(b)\r\nfor i in range(len(b)):\r\n arr[i] = b[i]\r\narr.reverse()\r\nfor i in range(len(a)):\r\n if arr[i] != a[i]:\r\n print(\"NO\")\r\n exit()\r\nprint(\"YES\")", "#41/A\r\n#Translation\r\n#Status: IDK\r\n\r\nm = str(input())\r\nn = str(input())\r\n\r\nif m[::-1] == n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "wordc=input()\r\nwordr=input()\r\nlis1=list(wordc)\r\nlis1.reverse()\r\nlis2=list(wordr)\r\nif lis1==lis2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "word = input()\r\ntrans = input()\r\nn = len(word)\r\nm = len(trans)\r\nif m != n:\r\n\tprint('NO')\r\nelse:\r\n\ti = 0\r\n\twhile i < n:\r\n\t if word[i] != trans[n-i-1]:\r\n\t print('NO')\r\n\t break\r\n\t elif i == (n-1) and word[i] == trans[n-i-1]:\r\n\t print('YES')\r\n\t i += 1", "string1 = input(\"\")\r\nstring2 = string1[::-1]\r\nstring3 = input(\"\")\r\nif string2 == string3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "if(str(input())==str(input()[::-1])):print(\"YES\")\nelse:print(\"NO\")\n", "s = input()\na = input()\nif(s==a[::-1]):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t\t \t \t\t \t\t \t\t\t \t", "text = input()\r\ntranslated = input()\r\ncheck = text[::-1]\r\nif translated == check:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") ", "\r\n\r\ndef check(w1, w2):\r\n\tfor i in range(0,len(w1)):\r\n\t\tif w1[i] != w2[len(w2) - 1- i]:\r\n\t\t\treturn False\r\n\treturn True\r\ndef main():\r\n\tword1 = input()\r\n\tword2 = input()\r\n\tif check(str(word1), str(word2)):\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")\r\n\r\n\r\nmain()", "s = input()\r\nt = input()\r\ntcheck = \"\"\r\nn = len(s)\r\nfor i in range(1,n+1):\r\n tcheck += s[n-i]\r\n \r\nif tcheck == t: print(\"YES\")\r\nelse:print(\"NO\")", "s=list(input())\r\nl=list(input())\r\ns.reverse()\r\nif s==l:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = [x for x in input()]\r\nb = [x for x in input()]\r\nb.reverse()\r\nprint(\"YES\" if a == b else \"NO\")", "# el franco\ns = input()\nt = input()\np = \"\"\np = t[::-1]\nif (s==p):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t \t \t\t\t \t\t\t \t \t \t\t \t \t", "x=input(\"\")\r\ny=input(\"\") \r\nl=[]\r\n\r\no=0\r\nfor i in x: \r\n l.insert((-1-o),i)\r\n o+=1\r\nxn=\"\"\r\nfor q in l:\r\n xn=xn+str(q)\r\nif xn==y:\r\n print(\"YES\") \r\nelse:\r\n print(\"NO\") ", "Be=input(\"\")\r\nbi=input(\"\")\r\nrev=bi[::-1]\r\nif rev==Be:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n = input()\r\nnr = input()\r\nnr = str(nr)\r\nn = str(n)\r\nrever = n[::-1]\r\nif rever == nr:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = list(input())\r\nb = list(input())\r\nc = a.copy()\r\nc.reverse()\r\nif b == c:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a=input()\nb=input()\n\nprint('YES'if a ==b[::-1]else 'NO')\n", "a=input()\r\nb=input()\r\nb2=\"\"\r\nfor i in range(1,len(b)+1):\r\n b2+=b[-i]\r\nif a==b2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\n\r\nn,k = len(a),len(b)\r\nif (n!=k):\r\n\tprint(\"NO\")\r\n\texit()\r\nfor i in range(n):\r\n\tif a[i] != b[n-i-1]:\r\n\t\tprint(\"NO\")\r\n\t\texit()\r\nprint(\"YES\")\r\n", "n=input()\r\nk=input()\r\nres=n[::-1]\r\nans=k[::-1]\r\nif ans==n and res==k:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "a = input()\r\nb = input()\r\nc = list(a)\r\nb = str(list(b))\r\nd = []\r\nfor i in range(len(c) - 1, -1, -1):\r\n d.append(c[i])\r\nd = str(d)\r\nif b == d:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "x=input()\ny=input()\nx=x.lower()\ny=y.lower()\nif x[::-1]==y or x==y[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n ", "string1=input()\r\nstring2=input()\r\nif(string1[::-1]==string2):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word1 = input()\r\nword2 = input()\r\nif word2 == word1[::-1]: print(\"YES\")\r\nelse: print(\"NO\")", "one = input()\ntwo = input()\nif(one==two[::-1]):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \t\t\t \t\t\t \t\t\t\t\t \t \t\t\t \t \t\t\t\t", "s=input()\r\nt=input()\r\nprint(\"YES\") if s==t[::-1] else print(\"NO\")\r\n ", "# Read the two words\r\ns = input()\r\nt = input()\r\n\r\n# Check if the reverse of s is equal to t\r\nif s[::-1] == t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "# coding=utf-8\r\ndef app(m,n):\r\n if m[::-1]==n:\r\n return True\r\n else:\r\n return False\r\nm=input()\r\nn=input()\r\nif app(m,n):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\t\t \t\t \t \t \t\t \t\t\t \t\t\t", "a=input()\r\nb=input()\r\nif b==a[::-1]:\r\n print(\"yes\".upper())\r\nelse:\r\n print(\"no\".upper())\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "print(\"YES\") if ''.join(reversed(input())) == input() else print(\"NO\")", "n=input()\r\no=[]\r\nfor i in n:\r\n o.append(i)\r\nm=input()\r\nk=[]\r\nfor i in m:\r\n k.append(i)\r\no.reverse()\r\nif o==k:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "import sys\r\nimport io\r\n\r\ndef run(test,res):\r\n x = io.StringIO()\r\n with io.StringIO(test) as sys.stdin:\r\n with x as sys.stdout:\r\n work()\r\n z = x.getvalue().strip()\r\n sys.stdout = sys.__stdout__\r\n print(z == test)\r\n print(res)\r\n print(z)\r\n\r\ndef work():\r\n s = input().lower()\r\n t = input().lower()\r\n z = s[::-1]\r\n print(\"YES\" if (z == t) else \"NO\")\r\n\r\ndef test():\r\n run(\"\"\"code\r\nedoc\"\"\", \"YES\")\r\n run(\"\"\"abb\r\naba\"\"\", \"NO\")\r\n run(\"\"\"code\r\ncode\"\"\", \"NO\")\r\n\r\nif len(sys.argv) > 1:\r\n test()\r\nelse:\r\n work()\r\n", "s1=input()\r\ns2=input()\r\nres=s1[::-1]\r\nif(s2==res):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nk=input()\r\n\r\n\r\ncount=0\r\nif(len(s) != len(k)):\r\n print('NO')\r\nelse:\r\n i=0\r\n j=len(s)-1\r\n while(i < len(s)):\r\n\r\n if(s[i] == k[j]):\r\n count=count+1\r\n i=i+1\r\n j=j-1\r\n\r\n else:\r\n i=i+1\r\n j=j-1\r\n\r\n \r\n if(count == len(s)):\r\n print('YES')\r\n\r\n else:\r\n print('NO')\r\n \r\n\r\n\r\n", "n=str(input())\r\ns=n[len(n)::-1]\r\nt=str(input())\r\nif t==s:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "f = input().strip()\r\ns = input().strip()\r\nout = \"YES\"\r\nlength = len(f)\r\nif length == len(s):\r\n for k in range(length):\r\n if f[k] != s[length - 1 - k]:\r\n out = \"NO\"\r\n break\r\nelse:\r\n out = \"NO\"\r\nprint(out)\r\n", "s=list(input())\r\nt=input()\r\nf=[0]*len(s)\r\n\r\ni=0\r\nwhile i<len(s):\r\n f[i]=s[len(s)-i-1]\r\n i=i+1\r\n\r\nif ''.join(f)==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "y=tuple(input().strip())\r\ny1=input()\r\ny2=y1[::-1]\r\ny3=tuple(y2.strip())\r\nif y==y3:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "def main():\r\n x = input().rstrip()\r\n y = input().rstrip()\r\n \r\n a = \"YES\" if x == y[::-1] else \"NO\"\r\n print(a)\r\n \r\n \r\n \r\nif __name__ == \"__main__\":\r\n main()", "t=input()\r\ns=input()\r\nu=t[::-1]\r\nif u==s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "text = str(input())\r\ncheck = str(input())\r\ntextre = ''\r\nfor i in text:\r\n textre = i + textre\r\nif check == textre:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n ", "bir=input()\r\niki=input()\r\nyeni=\"\"\r\nfor i in range(len(iki)):\r\n yeni=yeni+iki[-1-i]\r\n\r\nif yeni==bir:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s=input()\r\nt=input()\r\n\r\nx=''\r\n\r\nfor i in range (len(s)-1,-1,-1):\r\n x+=s[i]\r\nif t==x:\r\n print('YES')\r\nelse:\r\n print('NO')", "#n, a = input().split()\n\n#a = input().split()\n\nk = input()\nn = input()\n#k = [i for i in k]\n#k = [input().split() for i in range(int(a))]\n#n = input().split()\n\n#n = [i for i in n[0]]\n\n'''\ncont = [\n'a', 'b', 'c', 'd', 'e', 'f', 'g',\n'h', 'i', 'j', 'k', 'l', 'm', 'n',\n'o', 'p', 'q', 'r', 's', 't', 'u',\n'v', 'w', 'x', 'y', 'z'\n]\n'''\n#n = a[1]\n#a = a[0]\n\ns = ''\nfor i in range(len(k)-1,-1,-1):\n s += k[i]\nif s == n:\n print('YES')\nelse:\n print('NO')\n\n", "a=input();c=input()\r\nprint('YES') if a==c[::-1] else print('NO')", "berlandish_word = input()\r\nbirlandish_word = input()\r\nlist = [i for i in birlandish_word]\r\nlist.reverse()\r\nlist = \"\".join(list)\r\nif list == berlandish_word:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "list1 = list(input())\r\nlist2 = list(input())\r\nnum1 = len(list1) + 1\r\nif list2 == list1[-1:-num1:-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input().strip().lower()\nt = input().strip().lower()\n\nif s[::-1] == t:\n print('YES')\nelse:\n print('NO')", "s = input()\r\nt = input()\r\n\r\nfor i in range(0, len(s)):\r\n if s[i] != t[len(t) - i - 1]:\r\n print(\"NO\")\r\n break\r\n\r\nif s[len(s) - 1] == t[0] and i == len(s) - 1:\r\n print(\"YES\")\r\n", "str1 = input()\r\nstr2 = input()\r\nx = 0\r\n\r\n\r\n\r\nfor i in range(len(str1)):\r\n if str1[i] != str2[len(str2)-1 - i]:\r\n x = 1\r\n\r\nif(x == 0):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a=list(str(input()))\r\nb=list(str(input()))\r\nb=b[::-1]\r\nprint([\"NO\",\"YES\"][a==b])", "x=str(input())\r\ny=str(input())\r\nn=x[::-1]\r\nif(y==n):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "m=[i for i in input()]\r\nn=[i for i in input()]\r\nprint (\"YES\" if n==m[::-1] else \"NO\")", "# cook your dish here\ns=input()\nt=input()\ns1=\"\"\nfor i in s:\n s1=i+s1\nif s1==t:\n print(\"YES\")\nelse:\n print(\"NO\")", "s=input()\r\nt=input()\r\nb=\"\"\r\nfor i in range(-1,-len(s)-1,-1):\r\n b+=s[i]\r\nif(t==b):\r\n print('YES')\r\nelse:\r\n print('NO')", "n=list(input())\r\nm=list(input())\r\ns=0\r\nif len(m)==len(n):\r\n for i in range(0,len(n)):\r\n if m[i]==n[-i-1]:\r\n s=s+1\r\n if s==len(m):\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')", "f = input()\r\nd = input()\r\nif f[:] == d[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "word = input(\"\")\r\nopp = input(\"\")\r\n\r\nword_len = len(word)\r\nsliced_word =word[word_len::-1]\r\nif opp == sliced_word:\r\n\tprint(\"YES\")\r\n\r\nelse:\r\n\tprint(\"NO\")\r\n", "str1 = input()\nstr2 = input()\nif str1 != str2[::-1]:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n#Para este problema utilice una funcion de python la cual puede hacer un reverse de un string , asi mismo tambien puede hacer reverse de arrays pero seria con .reverse, apartir de esto solo hice una comparacion para saber si ambos strings eran iguales o no\n\t\t \t \t\t \t \t \t\t \t\t\t\t \t \t\t", "n=input()\r\nm=input()\r\nb=m[::-1]\r\nif n==b:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# A. Translation\r\ns = input().lower()\r\nt = input().lower()\r\ntranslation = s[-1::-1]\r\nif(t == translation): print(\"YES\")\r\nelse: print(\"NO\")", "s = input()\r\nt = input()\r\nj = len(t) - 1\r\nk = 0\r\n\r\nfor i in s:\r\n j -= 1\r\n if i == t[j+1]:\r\n k = 1\r\n continue\r\n else:\r\n k = 0\r\n print(\"NO\")\r\n break\r\n\r\nif k == 1:\r\n print(\"YES\")", "a=input()\r\nb=list(input())\r\nc=\"\"\r\nfor i in range(len (b)):\r\n c+=b[-(i+1)]\r\n\r\nif a==c:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")", "import sys\r\ninput=sys.stdin.readline\r\n\r\na=input().rstrip()\r\nb=input().rstrip()\r\nprint('YES' if a[::-1]==b else 'NO')", "s = str(input())\r\nt = str(input())\r\n\r\nif len(s) != len(t) :\r\n print(\"NO\")\r\nelse :\r\n count = 0\r\n for i in range(len(s)):\r\n if s[i] == t[len(s)-(i+1)]: count+=1\r\n\r\n\r\n if count == len(s) :print(\"YES\") \r\n else : print(\"NO\")", "ber = input()\r\nbir = input()\r\n\r\ndef stringReversal(string):\r\n if len(string) == 1:\r\n return string[0]\r\n \r\n return stringReversal(string[1:]) + string[0]\r\nreverse_string = stringReversal(ber)\r\nif reverse_string == bir:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = str(input())\r\ns2 = str(input())\r\n\r\ns2 = s2[::-1]\r\nif (s2 == s1):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n1 = input()\r\nn2 = input()\r\n\r\nlist1 = []\r\nlist2 = []\r\n\r\nfor i in n1:\r\n list1.append(i)\r\nfor i in n2:\r\n list2.append(i)\r\n \r\nlist1.reverse()\r\n\r\nif list1 == list2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input() \r\ns1=input() \r\nd=s1[::-1]\r\nif s==d:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "def solve(str1, str2):\r\n #print(reversed(str2))\r\n \r\n if str1 == str2[::-1]:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n\r\n\r\nstr1 = input()\r\nstr2 = input()\r\nprint(solve(str1, str2))", "def translation():\r\n i = input()\r\n j = input()\r\n i = i[::-1] \r\n if(i == j):\r\n print('YES')\r\n else:\r\n print('NO')\r\n \r\n\r\ndef main():\r\n translation()\r\n\r\nif __name__ == \"__main__\":\r\n main()", "a = input()\r\nb = input()\r\ncount=0\r\nif len(a)==len(b):\r\n for i in range(0,len(a)):\r\n if a[i]==b[len(b)-(i+1)]:\r\n count+=1\r\nif count==len(a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\r\nss = input()\r\nif ''.join(reversed(s))==ss:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "in1 = input()\r\nin2 = input()\r\nlis = list(in1)\r\nl = []\r\nfor i in range(len(in1)-1,-1,-1):\r\n l.append(in1[i])\r\nans = ''.join(l)\r\nif ans==in2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s=list(input())\r\ns.reverse()\r\nif list(input())==s:\r\n print('YES')\r\nelse:\r\n print('NO')", "str=input()\nstr2=input()\nrev=str2[::-1]\nif rev==str:\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t \t \t\t \t \t\t \t\t\t \t \t \t", "a=list(input())\r\nb=list(input())\r\nc=[]\r\nfor i in range(len(a)-1,-1,-1):\r\n c.append(a[i])\r\nif b==c:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "Be = input()\r\nBi = input()\r\n\r\nLv = [*Be]\r\nLv.reverse()\r\nOBi = \"\".join(Lv)\r\n\r\nif OBi == Bi:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word1 = input()\r\nword2 = input()\r\nchangeword = \"\"\r\nfor i in range(len(word1)):\r\n changeword += word1[len(word1)-(i+1)]\r\nif changeword == word2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = list(input())\r\nc = list(input())\r\nb = a.copy()\r\nb.reverse()\r\nif c == b:print('YES')\r\nelse:print('NO')\r\n", "s=input()\r\nt=input()\r\nss=[s[i] for i in range(len(s)-1,-1,-1)]\r\nst=\"\"\r\nfor i in range(len(s)):\r\n st+=ss[i]\r\nif (st==t):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1 = [str(item) for item in input()]\r\nstr2 = [str(item) for item in input()]\r\nstr2_rev = str2[::-1]\r\nif str1 == str2_rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\nt=input()\ny=t[::-1]\nif s==y:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "d=input()\r\ne=input()\r\ns=\"\"\r\nfor k in range(len(d)-1,-1,-1):\r\n s+=d[k]\r\nif(e==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "A=list(input())\r\nB=input()\r\nA.reverse()\r\nif ''.join(A)==B:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a1 = input()\r\na = input()\r\nprint(\"YES\") if a1 == a[::-1] else print(\"NO\")", "s = input()\r\n\r\nt = input()\r\n\r\nm = ''\r\n\r\nfor i in range(len(s), 0, -1):\r\n m += s[i-1]\r\nif m == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "n=list(input())\r\nm=list(input())\r\nreversedd=[]\r\nfor i in range(len(n)):\r\n reversedd.append(n.pop())\r\nif m==reversedd:\r\n print('YES')\r\nelse:\r\n print('NO')", "ber = input()\nbir = input()\n\nif ber[::-1] == bir:\n print(\"YES\")\nelse:\n print(\"NO\")", "words=list(input())\r\ntrans=[]\r\ni=len(words)-1\r\nwhile i>=0:\r\n\ttrans.append(words[i])\r\n\ti+=-1\r\ntranslation=\"\".join(trans)\r\nif translation==input():\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "def calculate(s, t):\r\n if s.__len__() != t.__len__():\r\n return \"NO\"\r\n if s != t[::-1]:\r\n return \"NO\"\r\n return \"YES\"\r\n\r\n\r\ns = input()\r\nt = input()\r\nprint(calculate(s, t))", "def split(word):\r\n return [char for char in word]\r\na = split(input())\r\nb = split(input())\r\n\r\na.reverse()\r\nif b == a:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nif s[::-1].capitalize()==t.capitalize():\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "first_word = list(input())\r\nsecond_word = list(input())\r\ntranslation = True\r\nfor i in range(len(first_word)):\r\n if second_word[i] != first_word[len(first_word)-(i+1)]:\r\n translation = False\r\n if translation == False:\r\n break\r\nif translation == True:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "t = input()\r\nt = t[::-1]\r\ns = input()\r\nif t == s: print(\"YES\")\r\nelse: print(\"NO\")", "S = input()\r\nT = input()\r\nif S == T[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=input()\r\ns2=input()\r\nIS_FLIPPED=False\r\nfor i in range(0,len(s1)):\r\n if(len(s1)!=len(s2)):\r\n print('NO')\r\n break\r\n if(s1[i] ==s2[len(s1)-1-i]):\r\n IS_FLIPPED=True\r\n else:\r\n print('NO')\r\n IS_FLIPPED =False\r\n break\r\nif(IS_FLIPPED):\r\n print('YES')", "val = input()\nval2 = input()\nif val == val2[::-1]:\n print(\"YES\")\nelse :\n print(\"NO\")", "a=input()\r\nb=input()\r\nbool=0\r\nif len(a)!=len(b):\r\n print('NO')\r\nelse:\r\n for i in range(len(a)):\r\n if a[i]!=b[len(a)-i-1]:\r\n bool=1\r\n break\r\n if bool==0:\r\n print('YES')\r\n else:\r\n print('NO')\r\n", "t=input()\r\nj=input()\r\nif j==t[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "a, b = list(input()), list(input())\r\nb.reverse()\r\nprint(\"YES\" if a == b else \"NO\")\r\n", "\r\n\r\ndef solution():\r\n st1 = input()\r\n st2 = input()\r\n if st1[::-1] == st2:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\nif __name__ == '__main__':\r\n solution()\r\n\r\n\r\n", "def find(s1,s2):\r\n if s1[::-1]!=s2:\r\n return \"NO\"\r\n else:\r\n return \"YES\"\r\ns=input()\r\nt=input()\r\nprint(find(s,t))", "s = str(input())\r\nt = str(input())\r\nif len(s) != len(t):\r\n print(\"NO\")\r\nelse:\r\n ok = True\r\n for i in range(len(s)):\r\n if s[i] != t[len(s) - i - 1]:\r\n ok = False\r\n break\r\n if ok:\r\n print(\"YES\")\r\n else:\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\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "t = input()\r\ns = input()\r\nif t == \"\".join(reversed(s)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=input()\r\nb=input()\r\nc=len(a)\r\nd=str()\r\nfor l in a:\r\n c=c-1\r\n d=d+a[c]\r\nif b==d:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nrevt=\"\"\r\nfor i in range(len(t)):\r\n revt+=t[-i-1]\r\nif(s==revt):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sun Sep 18 15:59:38 2022\r\n\r\n@author: lenovo\r\n\"\"\"\r\n\r\ns=input()\r\nt=input()\r\nprint('YES'if s==t[::-1] else 'NO')", "word_1=list(input())\r\nword_2=list(input())\r\nword_2.reverse()\r\nif word_1 == word_2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n ", "s=input()\r\nt=input()\r\nc=0\r\nif len(s)==len(t):\r\n\tfor i in range(len(s)):\r\n\t\tif s[i]==t[-i-1]:\r\n\t\t\tc+=1\r\n\tif c==len(s):\r\n\t\tprint('YES')\r\n\telse:\r\n\t\tprint('NO')\r\nelse:\r\n\tprint('NO')", "print('YES' if input().strip() == input().strip()[::-1] else 'NO')", "string=input()\r\ncase=input()\r\ncaseLst=list(case)\r\ncaseLst.reverse()\r\ncaseString=\"\".join(caseLst)\r\nif string==caseString:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s=input()\r\nd=input()\r\nif d==s[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "forward_text = input()\r\nforward_text = list(forward_text)\r\nreverse_text = input()\r\nreverse_text = list(reversed(reverse_text))\r\n\r\n#print(forward_text)\r\n#print(reverse_text)\r\n\r\nif forward_text == reverse_text:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "s = input()\nst = input()\nif s == st[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n\t \t\t\t \t\t\t \t\t\t \t \t \t\t\t\t\t\t\t\t", "berlandish=str(input())\r\nbirlandish=str(input())\r\nif birlandish[::-1]==berlandish:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input()\r\nb = input()\r\n\r\nreverse = b[::-1]\r\n\r\nif reverse == a or b == a[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nrv=input()\r\nrf=s[::-1]\r\nif(rv==rf):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "m=str(input())\r\nn=m[::-1]\r\no=str(input())\r\nif n==o:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n", "s, t = input(), input()\r\n\r\na = 'YES'\r\n\r\nfor let1, let2 in zip(s, t[::-1]):\r\n if let1 != let2:\r\n a = 'NO'\r\n\r\nprint(a)", "a=str(input())\r\nb=str(input())\r\nif len(a)==len(a):\r\n l=[]\r\n for i in range(len(b)):\r\n l.append(b[i])\r\n l.reverse()\r\n b=\"\".join(l)\r\n if a==b:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")\r\n", "'''\r\nAuthor : Shubhanshu Jain;\r\n'''\r\n\r\nimport math\r\nimport random;\r\nmod =1000000007\r\nr1 = lambda : int(input());\r\nrm = lambda : map(int,input().split());\r\nrls = lambda : list(rm())\r\n\r\ns1 = input();\r\ns2 = input();\r\nif(s1[::-1]==s2):\r\n print(\"YES\");\r\nelse:\r\n print(\"NO\")", "s = input()\r\nt = input()\r\n\r\nt_list = []\r\nfor i in t:\r\n t_list.append(i)\r\n\r\nt_list.reverse()\r\n\r\nt = ''\r\nfor j in t_list:\r\n t = t + j\r\n\r\nif s == t:\r\n print('YES')\r\nelse:\r\n print('NO')", "word = input()\r\ntranslated = input()\r\nreversed = word[::-1]\r\nif translated == reversed:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "p=input().strip()\r\nq=input().strip()\r\nif p==q[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "a=str(input())\r\nb=str(input())\r\nc=a[::-1]\r\nif(b==c):\r\n print('YES')\r\nelse:\r\n print('NO')", "inp = input()\r\ninp2 = input()\r\nres = True\r\nfor i, j in zip(range(len(inp)), range(len(inp2)-1, -1, -1)):\r\n if inp[i] != inp2[j]:\r\n res = False\r\n break\r\n\r\nif res:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "z=input()\r\ny=input()\r\nx=y[::-1]\r\nif x==z:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "first = input()\r\nsecond = input()\r\nif second == first[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "s= list(input())\ns.reverse()\nt = input()\nt1 = \"\".join(s)\nprint(\"YES\" if t == t1 else \"NO\")", "s=input()\r\nt=input()\r\nl=\"\"\r\nfor i in s:\r\n l=i+l\r\nif l==t:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "a = input(\"\")\r\nb = input(\"\")\r\noutput = True\r\n\r\nfor x in range(0,len(a)):\r\n if a[x] != b[-x-1]:\r\n output = False\r\n break\r\n\r\nif output:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n", "first = input()\r\nsecond = input()\r\nif first == second[len(second)::-1]:\r\n print('YES')\r\nelse: print('NO')", "s=input()\r\na=input()\r\nr=s[::-1]\r\nif(r==a):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n ", "def e(s,t):\r\n sr=s[::-1]\r\n if sr==t:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\ns=input()\r\nt=input()\r\nprint(e(s,t))", "s=input()\r\nh=input()\r\nif s==h[::-1]:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\r\nt = input()\r\nprint(\"\".join(reversed(s)) == t and \"YES\" or \"NO\")", "s = input()\r\nt = input()\r\n\r\nprint('YES' if t[::-1] == s else 'NO')", "a,b = input(), input()\nif len(a)!=len(b):\n print(\"NO\")\n exit(0)\nl = [i for i in range(len(a)) if a[i]==b[-i-1]]\nprint('YES' if len(l)==len(a) else 'NO')", "def inverso(t):\r\n inverso_t = ''\r\n quant_t = len(t)\r\n for letra in range (quant_t-1, -1, -1):\r\n inverso_t += t[letra]\r\n if inverso_t == s:\r\n return 'YES'\r\n else:\r\n return 'NO'\r\n\r\ns = str(input(''))\r\nt = str(input('')) \r\nprint(inverso(t))\r\n\r\n", "s=input()\r\ns1=input()\r\nnew_s=''\r\nfor i in range(len(s1)-1,-1,-1):\r\n new_s=new_s+s1[i]\r\n# print(new_s)\r\nif(new_s==s):\r\n print('YES')\r\nelse:\r\n print('NO')", "str1 = input()\r\nstr2 = input()\r\n\r\nn = len(str1)\r\nm = len(str2)\r\nj = n - 1\r\nc = 0\r\nfor i in range(n):\r\n if(m != n):\r\n break\r\n if str1[i] != str2[j]:\r\n c = 1\r\n j -= 1\r\nif m != n:\r\n print(\"NO\")\r\nelif c == 1:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")", "a = input()\nb = input()\nx = list(b)\nx.reverse()\nx = \"\".join(x)\nif a == x:\n print(\"YES\")\nelse:\n print(\"NO\")", "l=list(input())\r\ns=input()\r\nl.reverse()\r\nans=''.join(l)\r\nif s==ans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "str1=input()\nstr2=input()\nif(str1[::-1]==str2):\n print(\"YES\")\nelse:\n print(\"NO\")\n \t\t\t\t\t \t\t \t \t \t \t \t", "s = input()\r\nr=input()\r\nrr = r[::-1]\r\n\r\nif(s==rr):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = str(input())\r\ninv = str(input())\r\nprint('YES' if s == inv[::-1] else 'NO')", "s= input()\r\nt=input()\r\nn = \"\"\r\nfor i in s:\r\n n = i + n\r\nif t==n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "t = input()\ns = input()\n\ntReverse = \"\"\nfor letter in t:\n tReverse = letter+ tReverse\n\nif tReverse == s:\n print(\"YES\")\nelse:\n print(\"NO\")\n\t \t \t\t\t \t\t \t \t\t\t \t \t \t\t", "s = str(input())\r\nt = str(input())\r\nn = len(s)\r\nres = \"YES\"\r\nif len(s)!=len(t): \r\n\tres=\"NO\"\r\nelse:\r\n\tfor i in range(n):\r\n\t\tif s[i] != t[n-i-1]:\r\n\t\t\tres = \"NO\"\r\n\t\t\tbreak;\r\nprint(res)", "s=input()\nt=input()\nans=s[::-1]\nif ans==t:\n print(\"YES\")\nelse:\n print(\"NO\")", "word = str(input())\nbackwords_word = str(input())\n\n# word = word[::-1]\nbackwords_word = backwords_word[::-1]\n\nif backwords_word == word:\n\n print(\"YES\")\n\nelse:\n\n print(\"NO\")\n", "def solve(s, t):\r\n len1 = len(s)\r\n len2 = len(t)\r\n\r\n if(len1!=len2):\r\n return \"NO\"\r\n\r\n for i in range(0,len1):\r\n if(s[i]!=t[len1-i-1]):\r\n return \"NO\"\r\n\r\n return \"YES\"\r\n\r\nif __name__ == \"__main__\":\r\n s = input()\r\n t = input()\r\n print(solve(s,t))", "s=input()\r\ns1=input()\r\nsrev=s[::-1]\r\nif srev==s1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "s1 = list(input())\r\ns2 = list(input())\r\n\r\ns1Reverse = s1[::-1]\r\ns2 = \"\".join(s2)\r\ns1Reverse = \"\".join(s1Reverse)\r\n\r\nif s2 == s1Reverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1 = input()\r\ns2 = input()\r\nm = True\r\nfor i in range(len(s1)):\r\n if s1[i]!=s2[-i-1]:\r\n m = False\r\n break\r\nif m:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "word = input()\r\ntransword = input()\r\nt = word[::-1]\r\nif t == transword:\r\n print('YES')\r\nelse:\r\n print('NO')", "s=input()\r\nt=input()\r\nk=0\r\nfor i in range(len(s)):\r\n if s[i]!=t[-(i+1)]:\r\n k=k+1\r\n print('NO')\r\n break\r\nif k==0 :\r\n print('YES')\r\n ", "wordIn = input()\r\nwordOut = input()\r\n\r\nexpectedWord = []\r\ni = len(wordIn)\r\n\r\nwhile i > 0:\r\n expectedWord.append(wordIn[i - 1])\r\n i = i - 1\r\n\r\nexpecWord = ''.join(expectedWord)\r\n\r\nif expecWord in wordOut:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "t = list(input())\r\ns = list(reversed(input()))\r\nif t == s:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nr=input()\r\nm=r[::-1]\r\nif(s==m):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\nrev = t[::-1]\nif rev == s:\n print(\"YES\")\nelse:\n print(\"NO\")\n\t\t\t \t \t\t \t \t \t \t\t \t \t\t \t", "def palendrom(word,word2):\r\n reversed = word[::-1]\r\n if reversed == word2:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n\r\ndef main():\r\n word = input(\"\")\r\n word2 = input(\"\")\r\n palendrom(word,word2)\r\n \r\n\r\n \r\nmain()", "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Thu Aug 19 11:42:47 2021\r\n\r\n@author: rupert\r\n\"\"\"\r\n\r\norg_str = input()\r\ncomp_str = input()\r\norg_lst = [org_str[i] for i in range(len(org_str))]\r\nnew_lst = org_lst[::-1]\r\nnew_str = ''.join(new_lst)\r\nif new_str == comp_str:\r\n print('YES')\r\nelse:\r\n print('NO')", "s = input()\nt = input()\n\nif len(s) != len(t):\n\tprint(\"NO\")\n\texit()\n\nfor i in range(len(s), 0, -1):\n\tif s[i-1] != t[-1 * i]:\n\t\tprint(\"NO\")\n\t\texit()\n\t\n\nprint(\"YES\")", "s1=input() \r\ns2=input() \r\ns=s1[::-1]\r\nif (s2==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s1=input()\r\ns2=input()\r\nt=s2[::-1]\r\nif t==s1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "one=list(input())\r\ntwo=list(input())\r\none.reverse()\r\nif(one==two):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "n=input()\r\nm=input()\r\nk=m[::-1]\r\nif k==n:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "\r\nword = input()\r\ntranslated_word = input()\r\n\r\ncorrect_word = \"\".join([letter for letter in reversed(list(word))])\r\n\r\nif translated_word == correct_word:\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n", "s=input()\r\nt=input()\r\nti=s[::-1]\r\nif t==ti:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n", "from sys import stdin, stdout\r\n\r\ns = list(stdin.readline())[:-1]\r\nt = list(stdin.readline())[:-1]\r\n\r\ns.reverse()\r\n\r\nstdout.write('YES' if s == t else 'NO')", "cin=str(input())\r\ncin2=str(input())[::-1]\r\n\r\nif len(cin)!=len(cin2):\r\n print(\"NO\")\r\n\r\nelif cin==cin2:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")", "inp=input()\r\nreverse=inp[::-1]\r\nx=input()\r\nif x== reverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s=input()\r\nt=input()\r\nn=len(s)\r\nm=len(t)\r\na=0\r\nif n==m:\r\n for i in range(n):\r\n if s[i]==t[n-i-1]:\r\n a+=1\r\n if a==n:\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')\r\n\r\n", "a=input()\r\nb=input()\r\nc=''\r\nfor j in reversed(b):\r\n c+=j\r\nif a==c:\r\n print('YES')\r\nelse:\r\n print('NO')", "def translation(berland, birland):\n if len(berland) == len(birland):\n for i in range(len(berland)):\n if berland[i] != birland[len(birland)-1-i]:\n return False\n return True\n return False\n\nif __name__ == \"__main__\":\n ber = input()\n bir = input()\n if translation(ber, bir):\n print(\"YES\")\n else:\n print(\"NO\")\n", "s=input()\r\nt=input()\r\nr=\"\".join((reversed(s)))\r\n\r\nif r==t :\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n", "from math import *\nimport sys\n\np = input()\na = input()\n\nif (a==p[::-1]):\n print('YES')\nelse:\n print('NO')\n\n\t \t \t\t \t \t \t \t \t \t \t \t\t", "s_1 = list(input())\r\ns_2 = list(input())\r\n\r\nprint(\"YES\" if s_1 == list(reversed(s_2)) else \"NO\")", "firin=input()\r\nrev=firin[::-1]\r\nsecin=input()\r\nif secin == rev:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "n=input()\r\nm=input()\r\no=n[::-1]\r\n\r\n\r\nif(m==o):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "s = input()\nt = input()\n\nb = str()\n\nfor i in range(len(s)-1, -1, -1):\n b = b + s[i]\nif t == b:\n print('YES')\nelse:\n print('NO')\n", "s=input()\r\nr=input()\r\nn=s[::-1]\r\nif(n==r):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")", "s1 = input()\r\ns2 = input()\r\n\r\nif len(s1) != len(s2):\r\n\tprint(\"NO\")\r\n\texit()\r\ni = 0\r\nj = len(s2) - 1\r\n\r\nwhile i < len(s1) and j >= 0 :\r\n\tif s1[i] == s2[j]:\r\n\t\ti += 1\r\n\t\tj -= 1\r\n\telse:\r\n\t\tbreak\t\t\r\n# print(i, j)\r\nif i == len(s1) and j == -1:\r\n\tprint(\"YES\")\r\n\t\r\nelse:\r\n\tprint(\"NO\")\r\n", "s=input()\r\nrs=input()\r\nif rs==\"\".join(reversed(s)):\r\n print('YES')\r\nelse:\r\n print('NO')", "string_1, string_2 = str(input()), str(input())\r\nif string_1 == string_2[::-1]: print('YES')\r\nelse: print('NO')", "s = input()\r\ns1 = input()\r\nif s[::1] == s1[::-1]:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\n# Sat Oct 23 2021 16:08:42 GMT+0000 (Coordinated Universal Time)\n", "r = input;print(\"YNEOS\"[r() != r()[::-1]::2])", "palabra = input()\r\npalabra2 = input()\r\n\r\ncadena = []\r\ncadena1 = []\r\ncadena2 = []\r\n\r\nj=len(palabra)-1\r\n\r\nfor letra in palabra:\r\n cadena.append(letra)\r\n\r\ni=len(cadena)-1\r\n\r\nwhile i >= 0:\r\n cadena1.append(cadena[i])\r\n i-=1\r\n\r\nfor letra in palabra2:\r\n cadena2.append(letra)\r\n\r\n\r\nif cadena1 == cadena2:\r\n print(\"YES\")\r\n\r\nelse:\r\n print(\"NO\")", "# https://codeforces.com/problemset/problem/41/A\r\n# Входные данные\r\n# В первой строке записано слово s, во второй строке записано слово t.\r\n# Слова состоят из маленьких латинских букв. Входные данные не содержат лишних\r\n# пробелов. Слова непустые, и их длины не превосходят 100 символов.\r\n\r\n# Выходные данные\r\n# Если слово t является словом s, записанным наоборот, выведите YES,\r\n# иначе выведите NO.\r\n\r\n# Примеры\r\n# входные данные\r\n# code\r\n# edoc\r\n# выходные данные\r\n# YES\r\n# входные данные\r\n# abb\r\n# aba\r\n# выходные данные\r\n# NO\r\n# входные данные\r\n# code\r\n# code\r\n# выходные данные\r\n# NO\r\nlist1 = list(input().lower())\r\nlist2 = list(input().lower())\r\nlist2.reverse() # перекидаю список2 у зворотньому напрямку\r\nif list1 == list2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n# print(list1, list2)\r\n", "s = input()\r\nn = input()\r\nprint(\"YES\" if s==n[::-1] else \"NO\")", "s=input()\r\nl=input()\r\nd=l[::-1]\r\nif(d==s):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")", "ch=input()\r\nch1=input()\r\nreverse=ch1.upper()[::-1]\r\nif ch.upper()==reverse:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")" ]
{"inputs": ["code\nedoc", "abb\naba", "code\ncode", "abacaba\nabacaba", "q\nq", "asrgdfngfnmfgnhweratgjkk\nasrgdfngfnmfgnhweratgjkk", "z\na", "asd\ndsa", "abcdef\nfecdba", "ywjjbirapvskozubvxoemscfwl\ngnduubaogtfaiowjizlvjcu", "mfrmqxtzvgaeuleubcmcxcfqyruwzenguhgrmkuhdgnhgtgkdszwqyd\nmfxufheiperjnhyczclkmzyhcxntdfskzkzdwzzujdinf", "bnbnemvybqizywlnghlykniaxxxlkhftppbdeqpesrtgkcpoeqowjwhrylpsziiwcldodcoonpimudvrxejjo\ntiynnekmlalogyvrgptbinkoqdwzuiyjlrldxhzjmmp", "pwlpubwyhzqvcitemnhvvwkmwcaawjvdiwtoxyhbhbxerlypelevasmelpfqwjk\nstruuzebbcenziscuoecywugxncdwzyfozhljjyizpqcgkyonyetarcpwkqhuugsqjuixsxptmbnlfupdcfigacdhhrzb", "gdvqjoyxnkypfvdxssgrihnwxkeojmnpdeobpecytkbdwujqfjtxsqspxvxpqioyfagzjxupqqzpgnpnpxcuipweunqch\nkkqkiwwasbhezqcfeceyngcyuogrkhqecwsyerdniqiocjehrpkljiljophqhyaiefjpavoom", "umeszdawsvgkjhlqwzents\nhxqhdungbylhnikwviuh", "juotpscvyfmgntshcealgbsrwwksgrwnrrbyaqqsxdlzhkbugdyx\nibqvffmfktyipgiopznsqtrtxiijntdbgyy", "zbwueheveouatecaglziqmudxemhrsozmaujrwlqmppzoumxhamwugedikvkblvmxwuofmpafdprbcftew\nulczwrqhctbtbxrhhodwbcxwimncnexosksujlisgclllxokrsbnozthajnnlilyffmsyko", "nkgwuugukzcv\nqktnpxedwxpxkrxdvgmfgoxkdfpbzvwsduyiybynbkouonhvmzakeiruhfmvrktghadbfkmwxduoqv", "incenvizhqpcenhjhehvjvgbsnfixbatrrjstxjzhlmdmxijztphxbrldlqwdfimweepkggzcxsrwelodpnryntepioqpvk\ndhjbjjftlvnxibkklxquwmzhjfvnmwpapdrslioxisbyhhfymyiaqhlgecpxamqnocizwxniubrmpyubvpenoukhcobkdojlybxd", "w\nw", "vz\nzv", "ry\nyr", "xou\nuox", "axg\ngax", "zdsl\nlsdz", "kudl\nldku", "zzlzwnqlcl\nlclqnwzlzz", "vzzgicnzqooejpjzads\nsdazjpjeooqzncigzzv", "raqhmvmzuwaykjpyxsykr\nxkysrypjkyawuzmvmhqar", "ngedczubzdcqbxksnxuavdjaqtmdwncjnoaicvmodcqvhfezew\nwezefhvqcdomvciaonjcnwdmtqajdvauxnskxbqcdzbuzcdegn", "muooqttvrrljcxbroizkymuidvfmhhsjtumksdkcbwwpfqdyvxtrlymofendqvznzlmim\nmimlznzvqdnefomylrtxvydqfpwwbckdskmutjshhmfvdiumykziorbxcjlrrvttqooum", "vxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaivg\ngviayyikkitmuomcpiakhbxszgbnhvwyzkftwoagzixaearxpjacrnvpvbuzenvovehkmmxvblqyxvctroddksdsgebcmlluqpxv", "mnhaxtaopjzrkqlbroiyipitndczpunwygstmzevgyjdzyanxkdqnvgkikfabwouwkkbzuiuvgvxgpizsvqsbwepktpdrgdkmfdc\ncdfmkdgrdptkpewbsqvszipgxvgvuiuzbkkwuowbafkikgvnqdkxnayzdjygvezmtsgywnupocdntipiyiorblqkrzjpzatxahnm", "dgxmzbqofstzcdgthbaewbwocowvhqpinehpjatnnbrijcolvsatbblsrxabzrpszoiecpwhfjmwuhqrapvtcgvikuxtzbftydkw\nwkdytfbztxukivgctvparqhuwmjfhwpceiozsprzbaxrslbbqasvlocjirbnntajphenipthvwocowbweabhtgdcztsfoqbzmxgd", "gxoixiecetohtgjgbqzvlaobkhstejxdklghowtvwunnnvauriohuspsdmpzckprwajyxldoyckgjivjpmbfqtszmtocovxwgeh\nhegwxvocotmzstqfbmpjvijgkcyodlxyjawrpkczpmdspsuhoiruavnnnuwvtwohglkdxjetshkboalvzqbgjgthoteceixioxg", "sihxuwvmaambplxvjfoskinghzicyfqebjtkysotattkahssumfcgrkheotdxwjckpvapbkaepqrxseyfrwtyaycmrzsrsngkh\nhkgnsrszrmcyaytwrfyesxrqpeakbpavpkcjwxdtoehkrgcfmusshakttatosyktjbeqfycizhgniksofjvxlpbmaamvwuxhis", "ycnahksbughnonldzrhkysujmylcgcfuludjvjiahtkyzqvkopzqcnwhltbzfugzojqkjjlggmvnultascmygelkiktmfieok\nkoeifmtkiklegkmcsatlunvmggkjjlqjozgufzbtlhwncqzpokvqzykthaijvjdulufcgclymjusyyhrzdlnonhgubskhancy", "wbqasaehtkfojruzyhrlgwmtyiovmzyfifslvlemhqheyaelzwnthrenjsbmntwaoryzwfbxmscmypvxlfmzpnkkjlvwvmtz\nztmvwvljkknpzmflxvpymcsmxbfwzyroawtnmbsjnerhtnwzleayehqhmelvlsfifyzmvoiytmwglrhyzurjofktheasaqbw", "imippqurprbhfugngtgifelytadegwrgaefnfhbjjnmzikvjaccotqzemufqieqldgnbmviisgkynzeldlhqxuqphjfmyij\njiymfjhpquxqhldleznykgsiivmbngdlqeiqfumezqtoccajvkizmnjjbhfnfeagrwgedatylefigtgngufhbrpruqppimi", "bikydffiuisckpvzqlteqfhegsagimodb\nbdomigasgehfqetlqzvpkcsiuiffdykib"], "outputs": ["YES", "NO", "NO", "YES", "YES", "NO", "NO", "YES", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "NO", "YES", "YES", "YES", "YES", "NO", "YES", "NO", "YES", "YES", "NO", "YES", "YES", "YES", "NO", "NO", "YES", "YES", "NO", "YES", "YES", "YES"]}
UNKNOWN
PYTHON3
CODEFORCES
3,021
e6b16af4f70ea70aaebdec8c6ceac0a5
New Year and Curling
Carol is currently curling. She has *n* disks each with radius *r* on the 2D plane. Initially she has all these disks above the line *y*<==<=10100. She then will slide the disks towards the line *y*<==<=0 one by one in order from 1 to *n*. When she slides the *i*-th disk, she will place its center at the point (*x**i*,<=10100). She will then push it so the disk’s *y* coordinate continuously decreases, and *x* coordinate stays constant. The disk stops once it touches the line *y*<==<=0 or it touches any previous disk. Note that once a disk stops moving, it will not move again, even if hit by another disk. Compute the *y*-coordinates of centers of all the disks after all disks have been pushed. The first line will contain two integers *n* and *r* (1<=≤<=*n*,<=*r*<=≤<=1<=000), the number of disks, and the radius of the disks, respectively. The next line will contain *n* integers *x*1,<=*x*2,<=...,<=*x**n* (1<=≤<=*x**i*<=≤<=1<=000) — the *x*-coordinates of the disks. Print a single line with *n* numbers. The *i*-th number denotes the *y*-coordinate of the center of the *i*-th disk. The output will be accepted if it has absolute or relative error at most 10<=-<=6. Namely, let's assume that your answer for a particular value of a coordinate is *a* and the answer of the jury is *b*. The checker program will consider your answer correct if for all coordinates. Sample Input 6 2 5 5 6 8 3 12 Sample Output 2 6.0 9.87298334621 13.3370849613 12.5187346573 13.3370849613
[ "import math\r\n\r\n# input is a circle with centre (x1,y1)\r\n# and the 2nd centre has x-coordinate x2\r\n# find the y-coordinate of the 2nd circle, larger than y1, when it touches the 1st circle\r\ndef touch_y(x1, y1, x2):\r\n if abs(x1-x2) > 2*r: # no intersection\r\n return r\r\n x_touch_offset = abs(x1 - x2)/2.0\r\n y_touch = y1 + 2*math.sqrt(r*r - x_touch_offset*x_touch_offset)\r\n return y_touch\r\n\r\n# n^2 complexity, loop over the input xi and find the maximal y coordinate of a touching circle with the already computed solutions\r\n# finally, print out the list of y coordinates\r\ndef solve(xi, r):\r\n solution = []\r\n for x in xi:\r\n if len(solution) == 0:\r\n solution = [r]\r\n else:\r\n max_y = 0\r\n for i in range(len(solution)):\r\n max_y = max(max_y, touch_y(xi[i], solution[i], x))\r\n solution.append(max_y)\r\n print(' '.join([str(s) for s in solution]))\r\n\r\n\r\nn_and_r = input()\r\nr = float(n_and_r.split(' ')[1])\r\nxi = [float(n) for n in input().split(' ')]\r\nsolve(xi, r)\r\n", "# [https://www.dropbox.com/sh/i9cxj44tvv5pqvn/AADey7NNgaV3vJKC8dGet_Kma/C?dl=0&preview=C.py&subfolder_nav_tracking=1 <- https://codeforces.com/blog/entry/56713 <- https://codeforces.com/problemset/problem/908/C <- https://algoprog.ru/material/pc908pC]\r\n\r\nimport math\r\n(n, r) = map(int, input().split())\r\nx = list(map(int, input().split()))\r\n\r\ny = []\r\nfor i in range(n):\r\n y.append(\r\n max([r] + [math.sqrt(4 * r * r - (x[i]-x[j])*(x[i]-x[j])) + y[j]\r\n for j in range(i) if abs(x[i]-x[j]) <= 2 * r])\r\n )\r\nprint(*y)", "import math\r\n\r\nn, r = [int(i) for i in input().split()]\r\nx = [int(i) for i in input().split()]\r\nres = [r]\r\nfor i in range(1,n):\r\n y = r\r\n for j in range(0,i):\r\n if abs(x[j] - x[i]) <= 2*r:\r\n y = max(y, math.sqrt((2*r)**2 - (x[i] - x[j])**2) + res[j])\r\n res.append(y)\r\n \r\nfor i in range(n):\r\n print(res[i], end = ' ')\r\n \r\n ", "n, r = map(int, input().split())\r\nx = [int(i) for i in input().split()]\r\nc = []\r\n\r\n\r\nfor i in range(n):\r\n k = r\r\n for x1, j in c:\r\n d = abs(x[i] - x1)\r\n if d <= 2 * r:\r\n k = max(k, j + (4 * r ** 2 - d * d) ** 0.5)\r\n c.append([x[i], k])\r\n print(k)\r\n", "n,r=map(int,input().split())\r\ny=[]\r\nx=list(map(int,input().split()))\r\nfor xi in x:\r\n yi=r\r\n for tx,ty in zip(x,y):\r\n if xi-2*r<=tx<=xi+2*r:\r\n dy=(4.0*r**2-(tx-xi)**2)**0.5\r\n yi=max(yi,ty+dy)\r\n y.append(yi)\r\nprint(*y)", "n,r = map(int,input().split())\r\na = [int(i) for i in input().split()]\r\ns = []\r\narr = []\r\ns.append(r)\r\narr.append(a[0])\r\nfor i in range(1,n):\r\n an=r\r\n f = False\r\n temp = -1\r\n for j in range(len(arr)):\r\n if(arr[j]<=(a[i]+2*r) and arr[j]>=(a[i]-2*r)):\r\n an = max(an,s[j]+(pow(2*r,2)-pow((a[i]-arr[j]),2))**(0.5))\r\n f = True\r\n s.append(an)\r\n arr.append(a[i])\r\nfor j in range(len(s)):\r\n print(s[j],end=' ')", "import math\r\nn,r=map(int,input().split())\r\na=list(map(int,input().split()))\r\na.append(0)\r\nb=[0 for i in range(n)]\r\nb[0]=a[0]\r\nfor i in range(1,n+1):\r\n w=r\r\n for j in range(1,i):\r\n dx=abs(a[j-1]-a[i-1])\r\n if dx>2*r:continue\r\n w=max(w,b[j-1]+math.sqrt(4*r*r-dx*dx))\r\n b[i-1]=w\r\nprint(*b)", "import math\r\n\r\ndef get_n():\r\n return int(input())\r\n\r\ndef get_int_vector():\r\n return [int(x) for x in input().split()]\r\n\r\ndef list2string(list):\r\n result = []\r\n for i in list:\r\n result.append(str(i))\r\n return ':'.join(result)\r\n\r\ndef string2vector(string):\r\n return [int(x) for x in string.split(':')]\r\n\r\nn, r = get_int_vector()\r\nfinal = []\r\nfor x in get_int_vector():\r\n center = [x, None]\r\n for pair in final:\r\n if (x-r >= pair[0]-r and x-r <= pair[0]+r) or (x+r >= pair[0]-r and x+r <= pair[0]+r):\r\n y = pair[1] + math.sqrt(4*r**2-(x-pair[0])**2)\r\n if center[1] == None or center[1] < y:\r\n center[1] = y\r\n if center[1] == None:\r\n center[1] = r\r\n print(\"{:.7f}\".format(center[1]))\r\n final.append(center)\r\n", "#Python is love <3\r\nimport math\r\nn,r=map(int,input().split())\r\nx=list(map(int,input().split()))\r\ny=[]\r\nfor i in range(n):\r\n y.append(\r\n max([r] + [math.sqrt(4 * r * r - (x[i]-x[j])*(x[i]-x[j])) + y[j]\r\n for j in range(i) if abs(x[i]-x[j]) <= 2 * r])\r\n )\r\nprint(*y,sep=' ')\r\n\r\n", "n,r=map(int,input().split())\r\na=list(map(int,input().split()))\r\nst=[]\r\nfor i in a:\r\n left,right,cen=i-r,i+r,-1\r\n for j in st:\r\n if (not(j[0]>right or j[1]<left)) and cen< ((2*r)**2 - ((j[0]+j[1])/2 - i)**2 )**0.5 + j[2]:\r\n cen=((2*r)**2 - ((j[0]+j[1])/2 - i)**2 )**0.5 + j[2]\r\n k=j\r\n if cen==-1:\r\n st.append((left,right,r))\r\n c=r\r\n else:\r\n c=cen\r\n st.append((left,right,cen ))\r\n # print(st)\r\n # print\r\n print(c,end=\" \")\r\n \r\n \r\n \r\n ", "n,r = list(map(int,input().split()))\r\npoints = list(map(int,input().split()))\r\nx,y = [0 for i in range(n)],[0 for i in range(n)]\r\nfor i in range(n):\r\n x[i] = points[i]\r\n y[i] = r\r\n for j in range(i):\r\n if abs(x[j]-x[i])<=2*r:\r\n ans = 4*(r**2)\r\n d = abs(x[j]-x[i])\r\n d = d**2\r\n ans = ans-d\r\n ans = ans**0.5\r\n y[i] = max(y[i],y[j]+ans)\r\nprint(*y)", "# Collaborated with Rudransh Singh\n\nfrom math import sqrt\nn, r = input().split()\nn = int(n)\nr = int(r)\nx = []\narr = []\ninpArr = input().split(\" \")\nfor i in inpArr:\n x.append(int(i))\n \nfor i in range(n):\n arr.append(r)\n for j in range(i):\n if (abs(x[j] - x[i]) <= (r * 2)):\n arr[i] = max(arr[i], (arr[j] + sqrt((r*r*4)-((x[j] - x[i])*(x[j] - x[i]))) ))\narr1 = []\nfor i in arr:\n arr1.append(str(i))\nprint(\" \".join(arr1))\n\t\t \t \t \t\t \t \t\t \t\t \t \t \t \t", "def list_output(s): \r\n print(' '.join(map(str, s)))\r\n \r\ndef list_input(s='int'):\r\n if s == 'int':\r\n return list(map(int, input().split())) \r\n elif s == 'float':\r\n return list(map(float, input().split()))\r\n return list(map(str, input().split()))\r\n\r\nn, r = map(int, input().split())\r\nxs = list(map(int, input().split()))\r\n\r\nimport math\r\nys = list()\r\nfor i in range(n):\r\n hit = False\r\n ymax = r\r\n for j in range(i):\r\n if 2*r >= abs(xs[i] - xs[j]):\r\n hit = True\r\n ynew = ys[j] + math.sqrt(4.0 * r**2 - (xs[i] - xs[j])**2)\r\n ymax = max(ymax, ynew)\r\n ys.append(ymax)\r\nprint(' '.join(map(str, ys)))", "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\n\r\nN,R = map(int, input().split())\r\nA = list(map(int, input().split()))\r\n\r\nside = (R+R)**2\r\nans=[]\r\nfor a in A:\r\n pre = (a,-R)\r\n y1 = R\r\n for x,y in ans:\r\n if abs(a-x)<=2*R:\r\n t = abs(a-x)**2\r\n height = (side-t)**0.5+y\r\n y1 = max(y1,height)\r\n\r\n ans.append((a,y1))\r\n \r\nprint(*[y for x,y in ans])\r\n\r\n\r\n", "from math import sqrt\n\nfirst_line = input().split(' ')\nsecond_line = input().split(' ')\n\nRADIO = float(first_line[1])\nX_POSITIONS = [float(x) for x in second_line]\n\n\ndef stop_point(x0, y0, x_i):\n delta = 4 * RADIO ** 2 - (x_i - x0) ** 2\n if delta >= 0:\n y_i = y0 + sqrt(delta)\n else:\n y_i = RADIO\n return y_i\n\n\ndisks = []\n\nfor x in X_POSITIONS:\n max_y = RADIO\n for c in disks:\n y = stop_point(c[0], c[1], x)\n max_y = y if y > max_y else max_y\n disk = (x, max_y)\n disks.append(disk)\n\nprint(' '.join([str(y) for x, y in disks]))", "n,r = map(int,input().split())\r\nx_coord = list(map(int,input().split()))\r\nd = {}\r\nfor i in x_coord:\r\n final = r\r\n\r\n for j in range(i-r,i+r+1):\r\n check = d.get(j,[-1,-1])\r\n if check[0] > 0:\r\n potential = check[1] + ((4*r*r)-((i-check[0])**2))**.5\r\n final = max(potential,final)\r\n for j in range(i-r,i+r+1):\r\n d[j] = (i,final)\r\n print(final)", "from math import sqrt\r\nn, r = input().split(' ')\r\nn = int(n)\r\nr = float(r)\r\nx = [float(num) for num in input().split(' ')]\r\ny = [0] * n\r\nfor i in range(n):\r\n\ty[i] = r\r\n\tfor j in range(i):\r\n\t\tif abs(x[j] - x[i]) <= 2 * r:\r\n\t\t\tp = sqrt(4 * r * r - ((x[j] - x[i]) * (x[j] - x[i])))\r\n\t\t\ty[i] = max(y[i], y[j] + p)\r\n\tprint(y[i], end = ' ')\r\n", "from math import sqrt\r\nn,r = map(int,input().split())\r\nbubbles_x=list(map(int,input().split()))\r\n\r\nbubbles_y=[]\r\nfor i in range(n):\r\n if i==0:\r\n bubbles_y.append(r)\r\n continue\r\n else:\r\n current_bubble = bubbles_x[i]\r\n check_order_bubbles=bubbles_x[0:i]\r\n length = r\r\n for j,current_conflicting_bubble in enumerate(check_order_bubbles):\r\n temp = abs(current_bubble-current_conflicting_bubble)\r\n # print(temp)\r\n if temp>r*2:\r\n continue\r\n elif temp==r*2:\r\n length = max(length,(bubbles_y[j]))\r\n else:\r\n length = max(length,(bubbles_y[j]+sqrt(((2*r)**2)-(temp**2))))\r\n\r\n bubbles_y.append(length)\r\nprint(*bubbles_y)\r\n ", "import time\n\nn, r = 0, 0\nx = []\ny = []\n\n\ndef calc_y(x, x1, y1):\n dx = abs(x - x1)\n if dx > 2*r:\n return r\n dy = (4 * r**2 - dx ** 2) ** (1/2)\n return y1 + dy\n\ndef let_fall_disk(i):\n global n, r, x, y\n return max([calc_y(x[i], x[j], y[j]) for j in range(i)] + [r])\n\ndef let_fall_disks():\n global n, r, x, y\n for i in range(n):\n y += [let_fall_disk(i)]\n\ndef get_values():\n global n, r, x, y\n n, r = (int(a) for a in input().split())\n x = [int(a) for a in input().split()]\n\ndef main():\n get_values()\n if len(x) != n:\n return\n let_fall_disks()\n print(\" \".join([str(e) for e in y]))\n\nmain()", "# coding = utf-8\r\n\r\nmaxN = int(1e5 + 3)\r\neps = 1e-10\r\nx = [0 for k in range(maxN)]\r\ny = [0 for k in range(maxN)]\r\nn = 0\r\nr = 0\r\nd = 0\r\ndef read():\r\n global x,n,r,d\r\n n,r = (int(k) for k in input().split())\r\n r = float(r)\r\n d = 2*r\r\n x = [float(k) for k in input().split()]\r\ndef doit():\r\n for i in range(n):\r\n this_y = r\r\n for j in range(i):\r\n dx = abs(x[i]-x[j])\r\n if dx < d+eps:\r\n new_y = y[j] + (d**2-dx**2)**0.5\r\n if new_y > this_y:\r\n this_y = new_y\r\n y[i] = this_y\r\ndef main():\r\n read()\r\n doit()\r\n print(*y[:n])\r\nmain()", "import math\nn, r = [int(x) for x in input().split()]\nx = [int(x) for x in input().split()]\nans = []\nfor i in range(n):\n t = r\n for j in range(i):\n a = abs(x[i] - x[j])\n if a <= 2 * r:\n t2 = (2 * r)**2\n t2 -= a**2\n t2 = math.sqrt(t2) + ans[j]\n t = max(t, t2)\n ans.append(t)\nfor k in ans:\n print(k)\n\t \t\t\t\t \t\t\t \t\t \t\t\t \t\t\t\t \t\t\t\t\t", "import math\n\ndef getDy(r, dx):\n\tif 4 * r * r - dx * dx < 0: \n\t\treturn None\n\treturn math.sqrt(4 * r * r - dx * dx)\n\nn, r = map(int, input().split(\" \"))\nxs = [int(x) for x in input().split(\" \")]\n\ndisks = []\n\nfor x in xs:\n\thighestY = -1\n\tfor disk in disks:\n\t\tif disk[\"x\"] - 2 * r <= x <= disk[\"x\"] + 2 * r:\n\t\t\tdy = getDy(r, abs(disk[\"x\"] - x))\n\t\t\tif dy is not None:\n\t\t\t\thighestY = max(highestY, disk[\"y\"] + dy)\n\n\tif highestY == -1:\n\t\tdisks.append({ \"x\": x, \"y\": r })\n\telse:\n\t\tdisks.append({ \"x\": x, \"y\": highestY })\n\nprint(\" \".join([str(disk[\"y\"]) for disk in disks]))\n\n \t\t \t\t \t\t\t \t \t\t \t \t \t\t\t\t\t", "import math\r\nn,r=map(int,input().split())\r\nx=list(map(int,input().split()))\r\ny=[]\r\nfor i in range(n):\r\n en=r\r\n for j in range(i):\r\n dx = math.fabs(x[j]-x[i])\r\n if dx <= 2*r :\r\n en = max(en , y[j] + math.sqrt(4*r*r - dx*dx))\r\n y.append(en)\r\nfor i in y:\r\n print(i,end=\" \")\r\n", "n,r = [int(i) for i in input().split()]\n\ninp = [int(i) for i in input().split()]\n\ndisks = []\n\nimport math\n\nfor i in inp:\n\n mxY=r\n\n for j in disks:\n #print(j)\n\n if 2*r >= abs(j[0]-i) :\n y = j[1] + math.sqrt(4*r*r - (j[0]-i)*(j[0]-i))\n\n mxY = max(mxY,y)\n\n disks.append([i,mxY])\n #print([i,mxY])\nfor i in disks:\n print (i[1],end = ' ')", "import math\r\n\r\nn, r = list( map( int, input().split() ) )\r\nx = list( map( int, input().split() ) )\r\ny = [10**100] * n\r\n\r\nfor i in range(n):\r\n\r\n d_y = 0\r\n\r\n for j in range( i ):\r\n\r\n if 4*r*r - (x[i]-x[j])*(x[i]-x[j]) < 0:\r\n continue\r\n\r\n tmp_y = y[j]+math.sqrt( 4*r*r - (x[i]-x[j])*(x[i]-x[j]) )\r\n\r\n dist = (x[i]-x[j])*(x[i]-x[j]) + (d_y-x[i])*(d_y-x[i])\r\n\r\n d_y = max( d_y, tmp_y )\r\n\r\n y[i] = max( r, d_y )\r\n\r\n #print( \"i := %d, x = %f, y = %f\" % ( i, x[i], y[i] ) )\r\n\r\nfor i in range(n):\r\n print( y[i], end=' ' )\r\n", "import math\n\n\nif __name__ == '__main__':\n\tn, r = [int(s) for s in input().split()]\n\td = 2*r\n\tdd = d**2\n\n\tx_coords = [int(s) for s in input().split()]\n\n\t# очевидно первый диск упадет на ось Х\n\ty_coords = [r, ]\n\n\tfor i in range(1, n):\n\t\tcurrent_x = x_coords[i]\n\t\tcondidates = []\n\n\t\t# Возможные кандидаты на столкновение\n\t\tfor j in range(i):\t\t\t\n\t\t\tif abs(current_x - x_coords[j]) <= d:\n\t\t\t\tcondidates.append(j)\n\n\t\tif len(condidates) == 0:\n\t\t\t# диск не касается других, сразу падает на ось Х\n\t\t\ty_coords.append(r)\n\t\telif len(condidates) == 1:\n\t\t\t# на пути диска возможно только одно касание\n\t\t\t# сразу считаем координаты\n\t\t\tx1 = x_coords[condidates[0]]\n\t\t\ty1 = y_coords[condidates[0]]\t\t\t\n\t\t\tdy = math.sqrt(dd - (current_x - x1)**2)\n\t\t\ty_coords.append(y1 + dy)\n\t\telse:\n\t\t\t# на пути несколько дисков\n\t\t\t# считаем точки касания с каждым и берем с наибольшим значением у\n\t\t\ty_condidates = []\n\t\t\tfor condidate in condidates:\n\t\t\t\tx1 = x_coords[condidate]\n\t\t\t\ty1 = y_coords[condidate]\n\t\t\t\tdy = math.sqrt(dd - (current_x - x1)**2)\n\t\t\t\ty_condidates.append(y1+dy)\n\n\t\t\ty_coords.append(max(y_condidates))\n\n\tprint(' '.join([str(y) for y in y_coords]))", "#Problem Set C: Collaborated with no one\n\nimport math\n\nn_r = list(map(int, input().split()))\n\nn = n_r[0]\nradii = n_r[1]\n\nx_list = list(map(int, input().split()))\n\ntemp_arr = []\nfor i in range(n):\n temp_arr.append(max([radii] + [math.sqrt(4*radii**2 - (x_list[i]-x_list[j])**2) + temp_arr[j]\n for j in range(i) if abs(x_list[i]-x_list[j]) <= 2*radii])\n )\n\nfor i in temp_arr:\n print(i, end= \" \")\n \t\t\t\t\t\t \t \t\t\t \t \t\t", "n,r=map(int,input().split())\r\ny=[]\r\nx=list(map(int,input().split()))\r\nfor xi in x:\r\n yi=r\r\n for tx,ty in zip(x,y):\r\n if xi-2*r<=tx<=xi+2*r:\r\n dy=(4.0*r**2-(tx-xi)**2)**0.5\r\n yi=max(yi,ty+dy)\r\n y.append(yi)\r\nprint(*y)\r\n\r\n'''def ycor(a,b,x,r):\r\n return b+(4.0*r**2-(x-a)**2)**0.5\r\nn,r=map(int,input().split())\r\nc=list(map(int,input().split()))\r\na=[]\r\nfor i in range(n):\r\n x=c[i]\r\n var=[-1,-1,-1]\r\n if len(a)>0:\r\n for j in a:\r\n if x-(2*r)<=j[0]<=x+(2*r):\r\n y=ycor(j[0],j[1],x,r)\r\n inter=(y+j[1])/2 #We are choosing the maximum value for y coordinate of falling circle. We are not choosing maximum value of y coordinate of already fallen circles( obviously only those circles are considered which have potential to touch currently falling circle). If intersection point of falling circle with some circle is higher than intersection point with some other circle, then y coordinate of falling circle will be higher for the higher intersection one. Easy visualization. \r\n if inter>var[0]:\r\n var[0]=inter\r\n var[1]=x\r\n var[2]=y\r\n if var[0]==-1:\r\n a.append([x,r])\r\n else:\r\n a.append([var[1],var[2]])\r\ns=\"\"\r\nl=len(a)\r\ny=[]\r\nfor i in a:\r\n y.append(i[1])\r\nprint(*y)'''\r\n", "import math\nn,r = map(int,input().split())\nans = [0.0]*n\na = list(map(float,input().split()))\nfor i in range(n):\n maxx = r\n for j in range(i):\n if abs(a[i]-a[j]) > 2*r: continue\n maxx = max(maxx,ans[j]+math.sqrt(4*r*r-(a[i]-a[j])*(a[i]-a[j])))\n ans[i] = maxx\nfor i in range(n):\n print(ans[i],end=' ')\n\n", "n, r = map(int, input().split())\r\ndata = list(map(int, input().split()))\r\nsave = []\r\nfor i in range(n):\r\n ans = r\r\n for j in save:\r\n d = abs(data[i] - j[0])\r\n if d <= 2 * r:\r\n ans = max(ans, j[1] + (4 * r**2 - d**2)**0.5)\r\n save.append([data[i], ans])\r\n print(ans, end=\" \")\r\n \r\n\r\n", "from math import sqrt\n\n\ndef main():\n n, r = map(float, input().split())\n d = r * 2.\n d2 = d * d\n l = []\n for x in map(float, input().split()):\n le, ri, h = x - d, x + d, r\n for u, v in l:\n if le <= u <= ri:\n w = x - u\n y = v + sqrt(d2 - w * w)\n if h < y:\n h = y\n l.append((x, h))\n print(h,end=' ')\n\n\nif __name__ == '__main__':\n main()\n", "import math\r\nn, r = map(int, input().split())\r\nxs = list(map(int, input().split()))\r\nys = [r]*n\r\nfor i in range(1, n):\r\n for j in range(i):\r\n if xs[j] > xs[i] + 2*r or xs[j] < xs[i] - 2*r:\r\n continue\r\n y = ys[j] + math.sqrt(4*r*r - (xs[j]-xs[i])*(xs[j]-xs[i]))\r\n if y > ys[i]:\r\n ys[i] = y\r\nprint(\" \".join(map(str, ys)))\r\n", "def f(x1, x2, y2):\r\n t = 4 * r * r - (x1 - x2) ** 2\r\n if t >= 0:\r\n return y2 + t ** .5\r\n return r\r\nn, r = map(int, input().split())\r\nprint(r)\r\n*a, = map(int, input().split())\r\ncor = [[a[i], r] for i in range(n)]\r\nfor i in range(1, n):\r\n cor[i][1] = max(f(cor[i][0], cor[j][0], cor[j][1]) for j in range(i))\r\n print(cor[i][1])", "n,m=[float(i) for i in input().split()]\r\nl=[float(i) for i in input().split()]\r\nal=[]\r\nfor i in range(len(l)):\r\n ans=m\r\n for j in range(i):\r\n if abs(l[i]-l[j])<=2*m:\r\n ans=max(ans,al[j]+(4*m*m-(l[i]-l[j])**2)**0.5)\r\n al.append(ans)\r\nfor i in al:\r\n print(i,end=\" \")\r\n \r\n", "import sys\r\n\r\ninput = lambda: sys.stdin.readline().strip(\"\\r\\n\")\r\n\r\nn, r = map(int, input().split())\r\nx = list(map(int, input().split()))\r\ny = [0] * n\r\n\r\nfor i in range(n):\r\n cur = r\r\n for j in range(i):\r\n if 2 * r >= abs(x[i] - x[j]):\r\n cur = max(cur, y[j] + ((4*r*r - (x[i] - x[j])**2)**0.5))\r\n y[i] = cur\r\nprint(*y)\r\n", "n, r = list(map(int, input().split()))\r\ndisks = list(map(int, input().split()))\r\n#print(n, r)\r\n#print(disks)\r\n\r\natline = [[disks[0], r]]\r\n\r\nfor i in range(1, n):\r\n sup = r\r\n thisd = disks[i]\r\n for disk in atline:\r\n dx = disk[0] - thisd\r\n if abs(dx) > 2*r:\r\n continue\r\n y = disk[1] + (4*r*r - dx*dx)**(.5)\r\n sup = max(sup, y)\r\n atline += [[thisd, sup]]\r\n\r\ns = \"\"\r\nfor d in atline:\r\n s += str(d[1]) + \" \"\r\n\r\nprint(s)", "import math\nimport sys\nn, r = list(map(int, input().split(' ')))\nx = list(map(int, input().split(' ')))\ny = list()\n\nfor i in range(0, n):\n\ty.append(r)\n\tfor j in range(0, i):\n\t\tif 2*r == abs(x[i]-x[j]):\n\t\t\ty[i] = max(y[i], y[j])\n\t\telif 2*r > abs(x[i]-x[j]):\n\t\t\ty[i] = max(y[i], y[j] + math.sqrt(2*r*2*r - abs(x[i]-x[j])*abs(x[i]-x[j])))\nfor i in range(0, n):\n\tsys.stdout.write(str(y[i]) + ' ')", "import itertools\r\n\r\n(n,r) = [int(x) for x in input().split()]\r\n\r\nA = [int(x) for x in input().split()]\r\n\r\nans = []\r\n\r\nfor i in range(0, n):\r\n y = r\r\n for j in range(0, i):\r\n if (abs(A[i] - A[j]) <= 2*r):\r\n y = max(y, ans[j]+ ( (2*r)**2 - (A[j]-A[i])**2 )**0.5)\r\n ans.append(y)\r\n\r\n[print(x, end=' ') for x in ans]\r\n", "k, r = map(int, input().split())\r\nS = list(map(int, input().split()))\r\nUsed = []\r\nAnswer = []\r\n\r\nfor i in S:\r\n delta = r\r\n for j in range(len(Used)):\r\n\r\n if abs(i - Used[j]) <= 2 * r:\r\n rass = abs(i - Used[j])\r\n delta = max(delta, Answer[j] + ((2 * r)**2 - rass**2)**0.5)\r\n\r\n Answer.append(delta)\r\n Used.append(i)\r\nprint(' '.join(map(str, Answer)))", "from math import sqrt\r\nn,r=map(int,input().split())\r\n \r\na=list(map(int,input().split()))\r\n \r\ny=[[a[0],r]]\r\nfor i in range(1,n) :\r\n\tk = r\r\n\tfor j in range(len(y)) :\r\n\t\tif abs(a[i] - y[j][0]) <= 2*r :\r\n\t\t\tk = max(k, sqrt( (4*r*r) - ((a[i] - y[j][0])**2)) + y[j][1] ) \r\n\r\n\r\n\ty.append([a[i],k])\r\n\r\n\r\nprint(*[y[i][1] for i in range(len(y))] ,sep = ' ')\r\n", "import math\ndef C1():\n n, r = map(int, input().split())\n x_cord = [int(x) for x in input().split()]\n\n y_cord = []\n # y cordinate of contacted Disk\n contactedDisk = 0\n for i, x in enumerate(x_cord):\n if len(y_cord) == 0:\n y_cord.append(r)\n else:\n y_cord.append(r)\n for j in range(i):\n diff = abs(x_cord[i] - x_cord[j])\n if diff <= 2 * r:\n y_cord[i] = max(y_cord[i], math.sqrt(4*r*r - diff ** 2) + y_cord[j])\n\n\n for i in y_cord:\n print(i, end= \" \")\n\n\nif __name__=='__main__':\n C1()\n\t \t\t\t\t \t\t\t\t\t\t\t\t \t\t \t \t \t", "from collections import defaultdict as dd\r\nfrom collections import deque\r\nimport bisect\r\nimport heapq\r\nfrom math import sqrt\r\n\r\ndef ri():\r\n return int(input())\r\n\r\ndef rl():\r\n return list(map(int, input().split()))\r\n\r\n\r\ndef solve():\r\n n, r = rl()\r\n r = r * 1.0\r\n X = rl()\r\n \r\n prev = [] # y-coord of center in stopped position\r\n for x in X:\r\n highest = r\r\n for i, y2 in enumerate(prev):\r\n x2 = X[i]\r\n if abs(x2 - x) > 2 * r:\r\n continue\r\n y = sqrt(4*r*r - (x - x2)**2) + y2\r\n highest = max(highest, y)\r\n\r\n\r\n prev.append(highest)\r\n\r\n print (*prev)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nmode = 's'\r\n\r\nif mode == 'T':\r\n t = ri()\r\n for i in range(t):\r\n solve()\r\nelse:\r\n solve()\r\n", "from math import sqrt, fabs\n\nn, r = map(int, input().split())\n# xs = list(map(int, input().split()))\n# ans = [r for _ in range(n)]\npos = [[float(x)for x in input().split(' ')], [r]*n]\n# print(pos)\nfor i in range(n):\n maxp = pos[1][i]\n for j in range(i):\n mind = fabs(pos[0][i] - pos[0][j])\n if mind <= 2*r:\n maxp = max(maxp, pos[1][j]+sqrt(4*r**2-mind**2))\n pos[1][i] = maxp\nprint(\" \".join(map(str, pos[1])))\n\n \t\t\t\t\t \t \t\t\t\t\t \t \t \t \t\t", "from math import *\r\na,r = map(int,input().split())\r\nx = list(map(int,input().split()))\r\ny = [0]*a\r\nfor i in range(a):\r\n h = r\r\n for j in range(i):\r\n if abs(x[i]-x[j])<=2*r:\r\n h = max(h,sqrt((2*r)**2 - (x[i]-x[j])**2)+y[j])\r\n y[i] = h\r\n print(h, end = \" \")", "def main():\r\n _, r = map(int, input().split())\r\n a = [int(i) for i in input().split()]\r\n balls = []\r\n for i in a:\r\n pos = r\r\n for x, y in balls:\r\n if abs(x-i) <= 2*r:\r\n pos = max(pos, ((4*r*r - (x-i)**2)**0.5)+y)\r\n balls.append([i, pos])\r\n print(pos, end=\" \")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()", "n, r = map(int, input().split())\r\nx, y = list(map(int, input().split())), [r] * n\r\ndef f(xi, xj, yj):\r\n d = abs(xi - xj)\r\n return r if d > 2 * r else yj + (4 * r ** 2 - d ** 2) ** 0.5\r\nfor i in range(1, n):\r\n y[i] = max(f(x[i], x[j], y[j]) for j in range(i))\r\nprint(' '.join(map(str, y)))", "n,r=map(int,input().split())\r\nm=list(map(int,input().split()))\r\np=[]\r\nfrom math import fabs\r\nfor x in m:\r\n loc=r\r\n for el,y in p:\r\n if fabs(x-el)<=2*r:\r\n z=(4*r**2-fabs(x-el)**2)**0.5\r\n if z+y>loc:\r\n loc=z+y\r\n p.append([x,loc])\r\n[print(i,end=' ') for x,i in p]", "n,r=map(int,input().split())\r\na=list(map(int,input().split()))\r\ny=[]\r\nfor i in a:\r\n ini=r\r\n for x,j in y:\r\n if abs(x-i)<=2*r:\r\n ini=max(ini,((4*r*r-(x-i)**2)**0.5)+j)\r\n y.append([i,ini])\r\n print(ini,end=\" \")", "num_disks, radius = list(map(int, input().strip().split()))\nx_locs = list(map(int, input().strip().split()))\n\nlocs = []\nfor x_loc in x_locs:\n max_y = radius\n for x, y in locs:\n base = ((radius * 2) ** 2 - (x_loc - x) ** 2)\n if base < 0:\n continue\n new_y = base ** 0.5 + y\n if new_y > max_y:\n max_y = new_y\n locs.append((x_loc, max_y))\n print(max_y)\n", "from math import sqrt\r\n\r\nn, r = map(int, input().split())\r\nx_list = list(map(int, input().split()))\r\n\r\ny_list = []\r\n\r\nfor i in range(n):\r\n y_val = r\r\n for j in range(i):\r\n if abs(x_list[i] - x_list[j]) <= 2*r:\r\n y_curr = sqrt(4*r*r - (x_list[i]-x_list[j])*(x_list[i]-x_list[j])) + y_list[j]\r\n y_val = max(y_val, y_curr)\r\n y_list.append(y_val)\r\n\r\nprint(\" \".join(map(str, y_list)))\r\n", "n, r=[int(k) for k in input().split()]\r\nw=[int(k) for k in input().split()]\r\nw=w[::-1]\r\nz=[(w.pop(), r)]\r\nwhile w:\r\n x=w.pop()\r\n mx=r\r\n for j in z:\r\n if abs(x-j[0])<=2*r:\r\n mx=max(mx, j[1]+(4*r**2-(x-j[0])**2)**0.5)\r\n z.append((x, mx))\r\nprint(\" \".join([str(k[1]) for k in z]))", "import sys\n\nn,r = map(int,sys.stdin.readline().split())\nx = list(map(int,sys.stdin.readline().split()))\ny = [r]\nfor i in range(1,n):\n m=r\n for j in range(i):\n temp = 4*r*r -(x[i] - x[j])**2\n if temp >= 0:\n m = max(m,temp**0.5+y[j])\n y.append(m)\n\nfor i in range(n):\n print(y[i], end=' ')\nprint()\n", "n, r = map(int, input().split())\r\ns = list(map(int, input().split()))\r\nl = [r]\r\nfor i in range(1, len(s)):\r\n b = r\r\n for j in range(i-1, -1, -1):\r\n if abs(s[i]-s[j]) <= 2*r:\r\n b = max(b, (l[j] + (4*r*r - (s[i]-s[j])**2)**0.5))\r\n l.append(b)\r\nprint(*l)", "import math\nn,r = tuple(map(int,input().split()))\n\ncircles = list(map(int,input().split()))\n\noutput = []\n\nfor x in circles:\n\tinit = r\n\tfor xt,y in output:\n\t\tif abs(xt-x) <= 2*r:\n\t\t\tinit = max(init,((4*r*r-(x-xt)**2)**0.5)+y)\n\tprint(init,end=\" \")\n\toutput.append([x,init])\n", "\r\nimport math\r\nlength, radius = list(map(int, input().split()))\r\n\r\n\r\nball_pos = dict() # (left, right) => (x, y)\r\n\r\nballs = list(map(int, input().split()))\r\n\r\n\r\ndef main():\r\n res_y = []\r\n \r\n for x in balls:\r\n left, right = x - radius, x + radius\r\n stop_x, stop_y = getTouchBall(ball_pos, left, right)\r\n \r\n ball_pos[(stop_x - radius, stop_x + radius)] = (stop_x, stop_y)\r\n res_y.append(stop_y)\r\n\r\n for y in res_y:\r\n print(y, end=\" \")\r\n\r\n\r\ndef getTouchBall(pos_mapping, left, right):\r\n \r\n res_x, res_y = -1, -1\r\n for l, r in pos_mapping.keys():\r\n if l <= left <= r or l <= right <= r:\r\n x, y = pos_mapping.get((l, r)) \r\n stop_x, stop_y = getCurBallPos((left + right) // 2, x, y)\r\n\r\n if stop_y > res_y:\r\n res_x, res_y = stop_x, stop_y\r\n \r\n if res_y == -1:\r\n return (left + right) // 2, (right - left) // 2\r\n return res_x, res_y\r\n\r\ndef getCurBallPos(x, touch_x, touch_y):\r\n del_x = abs(x - touch_x)\r\n del_y = math.sqrt(4 * radius**2 - del_x**2)\r\n \r\n\r\n return x, touch_y + del_y\r\n \r\n\r\nmain()", "from math import sqrt\r\n\r\nn,r = map(int,input().split(\" \"))\r\nx = list(map(int,input().split(\" \")))\r\n\r\ncenter = [(r,x[0])]\r\ncenter_ans = str(r)\r\n\r\nfor i in range(1,n):\r\n\tcenter_tmp = []\r\n\tfor j in range(i):\r\n\t\tdif_x = abs(center[j][1]-x[i])\r\n\t\tif dif_x > 2*r:\r\n\t\t\tcenter_tmp.append((r,x[i]))\r\n\t\t\tcontinue\r\n\t\telse:\r\n\t\t\tdif_y = float(sqrt((4 * (r**2) - (dif_x ** 2))))\r\n\t\t\ty = float(center[j][0])+dif_y\r\n\t\t\tcenter_tmp.append((y,x[i]))\r\n\r\n\tcenter.append(max(center_tmp))\r\n\tcenter_ans += (\" \" + str((center[i][0])))\r\n\t\t\t\r\nprint(center_ans)\r\n\r\n\r\n\r\n\r\n", "n, r = map(int, input().split())\r\nx = list(map(int, input().split()))\r\n\r\ny = [0]*n\r\ny[0] = r\r\n\r\nfor i in range(1, n):\r\n temp = r\r\n for j in range(i):\r\n s = 4*r*r-abs(x[j]-x[i])*abs(x[j]-x[i])\r\n if s >= 0:\r\n temp = max(temp, s**.5+y[j])\r\n y[i] = temp\r\n\r\nfor i in range(n):\r\n y[i] = str(y[i])\r\n \r\nprint(' '.join(y))\r\n", "# this is directly from: https://codeforces.com/contest/908/submission/46821547\n# you can disregard this answer if desired\n\nn, r = map(int, input().split())\ny = []\nx = list(map(int, input().split()))\nfor xi in x:\n yi = r\n for tx, ty in zip(x, y):\n if xi - 2 * r <= tx <= xi + 2 * r:\n dy = (4.0 * r ** 2 - (tx - xi) ** 2) ** 0.5\n yi = max(yi, ty + dy)\n y.append(yi)\nprint(*y)\n\n\t\t\t\t \t\t\t \t\t \t\t\t\t\t \t\t \t\t \t", "n, r = map(int, input().split())\nx = list(map(int, input().split()))\ny = [r] * n\nfor i in range(n):\n for j in range(i):\n if not (abs(x[i] - x[j]) > 2 * r):\n y[i] = max(y[i], (4 * r ** 2 - (x[i] - x[j]) ** 2) ** 0.5 + y[j])\nfor i in y:\n print(i, end=' ')\n\t \t\t \t\t\t \t\t \t \t\t \t \t\t \t \t\t \t", "f = lambda: map(int, input().split())\r\nn, r = f()\r\np, d = [], 2 * r\r\nfor x in f():\r\n y = r\r\n for a, b in p:\r\n if abs(a - x) <= d: y = max(y, b + (d * d - (a - x) ** 2) ** 0.5)\r\n p.append((x, y))\r\nfor x, y in p: print(y)", "# import io, os\r\n# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\nimport sys\r\ninput=sys.stdin.readline\r\nMOD = 1000000007\r\nMOD2 = 998244353\r\nii = lambda: int(input().strip('\\n'))\r\nsi = lambda: input().strip('\\n')\r\ndgl = lambda: list(map(int,input().strip('\\n')))\r\nf = lambda: map(int, input().strip('\\n').split())\r\nil = lambda: list(map(int, input().strip('\\n').split()))\r\nls = lambda: list(input().strip('\\n'))\r\nlet = 'abcdefghijklmnopqrstuvwxyz'\r\nn,r=f()\r\nl=il()\r\nans=[r]\r\nfor i in range(1,n):\r\n mx=r\r\n for j in range(i):\r\n if abs(l[j]-l[i])<=(2*r):\r\n mx=max(mx,ans[j]+(4*r*r-(l[i]-l[j])**2)**0.5)\r\n ans.append(mx)\r\nprint(*ans)", "n,r=list(map(int,input().split()))\r\nx=list(map(int,input().split()))\r\ny=[r]*n\r\nfor i in range(1,n):\r\n for j in range(i):\r\n d=abs(x[i]-x[j])\r\n if d<=2*r:\r\n y[i]=max(y[i],y[j]+(4*r*r-d*d)**(0.5))\r\nprint(*y)", "import sys\r\ninput = sys.stdin.readline\r\n\r\nn, r = map(int, input().split())\r\n\r\nd = []\r\nx = 4*r*r\r\nfor i in map(int, input().split()):\r\n e = []\r\n for a, b in d:\r\n if i-2*r <= a <= i+2*r:\r\n e.append((i, ((x-(i-a)**2)**0.5 + b)))\r\n if len(e) == 0:\r\n d.append((i, r))\r\n else:\r\n e.sort(key=lambda x:x[1])\r\n d.append(e[-1])\r\nprint(' '.join(map(str, [i[1] for i in d])))\r\n", "n,r=map(int,input().split())\r\nx=list(map(float,input().split()))\r\nptns=[]\r\n\r\nfor i in range(n):\r\n ty=r\r\n for x1,y1 in ptns: \r\n rast=abs(x1-x[i])\r\n if rast<=2*r:\r\n ny=y1+(4*r*r-rast*rast)**0.5\r\n if ny>ty: ty=ny\r\n ptns.append([x[i],ty])\r\n print(ty)\r\n", "from math import sqrt\r\nn,r=map(int,input().split())\r\ndx,dy=[],[]\r\nxs=list(map(int,input().split()))\r\nfor i in range(n):\r\n a=1\r\n y=0\r\n for j in range(i):\r\n if abs(xs[i]-dx[j])<=2*r:\r\n a=0\r\n y=max(round(dy[j]+sqrt((2*r)**2-(xs[i]-dx[j])**2),6),y)\r\n if a:\r\n dy.append(r)\r\n else:\r\n dy.append(y)\r\n dx.append(xs[i])\r\nfor i in dy:\r\n print(i,end=' ')", "from math import pow, sqrt\n\nn, r = [int(x) for x in input().split()]\n\nxs = [int(x) for x in input().split()]\nys = []\n\ndef yoff(bottom_x: int, top_x: int) -> int:\n return sqrt(pow(2*r, 2) - pow(abs(bottom_x - top_x), 2))\n\nfor i in range(n):\n y = r\n for j in range(i):\n if abs(xs[i] - xs[j]) <= 2*r:\n y = max(ys[j] + yoff(xs[j], xs[i]), y)\n # print(f'{i}(x:{xs[i]}) on {j}(x:{xs[j]}): y = {y:.2f}')\n ys.append(y)\n \n\nprint(' '.join([str(y) for y in ys]))", "# CF 908/C : Disc Falling\r\nn,r = map(int, input().split())\r\nx_data = list(map(int, input().split()))\r\ny_data = []\r\n\r\n\r\nfor i in range(n):\r\n y=r\r\n for j in range(i):\r\n if abs(x_data[j]-x_data[i])<=2*r:\r\n y = max(y, ( 4*r*r - (x_data[i]-x_data[j])**2 )**(0.5)+y_data[j] )\r\n y_data.append(y) \r\nprint(*y_data)\r\n\r\n", "from collections import deque\nfrom sys import stdin, stderr\nlines = deque(line.strip() for line in stdin.readlines())\n\ndef nextline():\n return lines.popleft()\n\ndef types(cast, sep=None):\n return tuple(cast(x) for x in nextline().split(sep=sep))\n\ndef ints(sep=None):\n return types(int, sep=sep)\n\ndef strs(sep=None):\n return nextline().split(sep=sep)\n\ndef main():\n # lines will now contain all of the input's lines in a list\n n, r = ints()\n xs = ints()\n ys = []\n hypot = 2 * r\n for i in range(n):\n y = r\n for j in range(i):\n if abs(xs[i] - xs[j]) <= hypot:\n x = xs[i] - xs[j]\n y = max((hypot*hypot - x*x)**.5 + ys[j], y)\n ys.append(y)\n print(' '.join(str(y) for y in ys))\n\nif __name__ == '__main__':\n main()\n", "R = lambda: map(int, input().split())\r\n\r\nn, r = R()\r\nxs = list(R())\r\nys = []\r\nfor i in range(n):\r\n ys.append(max([((2 * r) ** 2 - abs(xs[i] - xs[j]) ** 2) ** 0.5 + ys[j] for j in range(i) if abs(xs[i] - xs[j]) <= 2 * r], default=r))\r\nprint(*ys)", "I=lambda:input().split(\" \")\r\na=I()\r\ny=I()\r\nc=[]\r\nfor i in range(int(a[0])):\r\n f=int(a[1])\r\n g=2*f\r\n h=int(y[i])\r\n for j in c:\r\n d=abs(h-j[0])\r\n if d<=g:\r\n f=max(f,j[1]+(g*g-d*d)**.5)\r\n c.append([h,f])\r\nfor i in c:print(i[1])", "n, r=map(int, input().split())\r\ns=list(map(int, input().split()))\r\nv=[]\r\nfor i in range(n):\r\n ans=r\r\n for k in range(i):\r\n y=0\r\n if abs(s[k]-s[i])<=2*r:\r\n if s[k]==s[i]:\r\n y=v[k]+2*r\r\n elif s[k]==s[i]:\r\n y=v[k]\r\n else:\r\n y=v[k]+(4*(r**2)-(s[k]-s[i])**2)**0.5\r\n if y>ans:\r\n ans=y\r\n v.append(ans)\r\nprint(*v)\r\n\r\n\r\n ", "import math as m\n\nnDiscs, r = [int(x) for x in input().split()]\n\nx = [int(x) for x in input().split()]\ny = []\n\nfor i in range(len(x)):\n tempY = [r]\n for j in range(i):\n diffX = abs(x[i] - x[j])\n if diffX <= (2 * r):\n addY = m.sqrt((4 * r * r) - (diffX * diffX))\n tempY.append(y[j] + addY)\n y.append(max(tempY))\n\nfor i in range(len(y)):\n print(y[i], end=' ')\nprint()\n\n\t\t \t \t\t\t\t \t \t \t\t \t \t\t\t \t", "n, r = map(int, input().split())\r\na = [*map(int, input().split())]\r\nans = [r] * n\r\nfor i in range(n):\r\n for j in range(i):\r\n if abs(a[j] - a[i]) <= 2 * r:\r\n ans[i] = max(ans[i], ((4 * r * r - (a[j] - a[i]) ** 2) ** 0.5) + ans[j])\r\n print(ans[i], end = \" \")\r\nprint()\r\n", "n, r = map(int, input().split())\r\nA = list(map(int, input().split()))\r\nB = []\r\nB.append([r, A[0]-r, A[0]+r])\r\nprint(r, end = ' ')\r\nfor i in range(1, n):\r\n B = sorted(B, key=lambda l: l[0], reverse=True)\r\n m = 0\r\n k = 0\r\n for j in B:\r\n if j[1]-r<=A[i]<=j[2]+r:\r\n k = j[0]+(4*r*r-(abs(A[i]-j[1]-r))**2)**0.5\r\n if k>m:\r\n m=k\r\n if m==0:\r\n B.append([r, A[i]-r, A[i]+r])\r\n print(round(r, 11), end = ' ')\r\n else:\r\n B.append([(round(m, 11)), A[i]-r, A[i]+r])\r\n if m%1==0:\r\n print(int(m), end = ' ')\r\n else:\r\n print(round(m, 11), end = ' ')\r\n\r\n", "a=input().split(\" \")\r\ny=input().split(\" \")\r\nc=[]\r\nfor i in range(int(a[0])):\r\n f=int(a[1])\r\n g=2*f\r\n for j in c:\r\n d=abs(int(y[i])-j[0])\r\n if d<=g:\r\n f=max(f,j[1]+(g**2-d**2)**.5)\r\n c.append([int(y[i]),f])\r\nfor i in c:print(i[1])", "# @Date: 29-Dec-2017\n# @Last modified time: 29-Dec-2017\nn,r=map(int,input().split())\nx=[ int(i) for i in input().split() ]\nans_y=[r]\n\nfor i in range(1,n):\n\n curr_x= x[i] # x co ordinate of this check if it overlaps with any of the earlier ones\n # print(\"Now checking:\",curr_x)\n stat=True\n pos=[]\n index_of_check=0\n for j in range(0,i):\n if x[j]-2*r <= curr_x <= x[j]+2*r :\n # print(\"Found an overlapping circle\")\n pos.append(j)\n stat=False\n\n if stat:\n # print(\"This can go to zero\")\n ans_y.append(r)\n continue\n else:\n y_max = 0 \n for j in pos:\n # print(\"Found overlap\")\n #index_of_check:\n x_c = x[j]\n y_c = ans_y[j]\n \n delta_x = (curr_x - x_c)**2\n delta_y = (4*(r**2)-delta_x)**(0.5)\n new_y = delta_y + y_c\n\n y_max = max(new_y,y_max)\n ans_y.append(y_max)\n # print(\"Found new_y\",new_y ,\" for curr_x\",curr_x)\n\n\nfor i in ans_y:\n print(i,end=\" \")\n", "n, r = map(int, input().split())\r\n\r\nrad = list(map(int, input().split()))\r\n\r\ny = []\r\n\r\nfor i in range(n):\r\n y.append(r)\r\n for j in range(i):\r\n d = abs(rad[i] - rad[j])\r\n if d > 2 * r:\r\n continue\r\n inc = (4 * r ** 2 - d ** 2) ** (1 / 2)\r\n y[i] = max(y[i], y[j] + inc)\r\n\r\nprint(' '.join(map(str, y)))", "n,r=list(map(int, input().split()))\r\na=list(map(int, input().split()))\r\nr_2=(2*r)**2\r\nc=[]\r\nfor i in range(n):\r\n if i==0:\r\n c.append(r)\r\n else:\r\n x2=a[i]\r\n k=[]\r\n for j in range(i):\r\n x1=a[j]\r\n y1=c[j]\r\n if abs(x2-x1)<=2*r:\r\n k.append((r_2-(x2-x1)**2)**0.5+y1)\r\n if len(k)==0:\r\n c.append(r)\r\n else:\r\n c.append(max(k))\r\nprint(*c)", "import math\nfrom collections import namedtuple\nDisk = namedtuple('Disk', ['x', 'y'])\n\nn, r = tuple(map(int, input().split()))\ndisks = list(map(int, input().split()))\n\nactive = []\n\nfor x in disks:\n possible_y = [r]\n for a in active:\n if abs(a.x - x) <= 2 * r:\n dy = math.sqrt(4 * (r ** 2) - (abs(a.x - x) ** 2))\n possible_y.append(a.y + dy)\n active.append(Disk(x, max(possible_y)))\n\ny_coords = [str(a.y) for a in active]\nprint(' '.join(y_coords))", "import math\r\n\r\nn, r = map(int, input().split())\r\nlst = list(map(int, input().split()))\r\nballs = []\r\nfor i in range(n):\r\n x = lst[i]\r\n ans = [x, r]\r\n for ball in balls:\r\n x_0 = ball[0]\r\n y_0 = ball[1]\r\n if abs(x_0 - x) <= 2 * r:\r\n h = math.sqrt(4 * r * r - abs(x_0 - x) * abs(x_0 - x))\r\n if ans[1] < y_0 + h:\r\n ans = [x, y_0 + h]\r\n balls.append(ans)\r\nfor j in balls:\r\n print(j[1])", "from sys import stdin, setrecursionlimit\r\n\r\n\r\ndef solve():\r\n n, r = (int(s) for s in stdin.readline().split())\r\n mas = [int(s) for s in stdin.readline().split()]\r\n\r\n prev_x, prev_y = mas[0], r\r\n drop_mas = [(prev_x, prev_y)]\r\n\r\n ans = [prev_y]\r\n\r\n for i in range(1, n):\r\n cur_x = mas[i]\r\n cur_y = r\r\n for j in range(len(drop_mas)):\r\n if abs(cur_x-drop_mas[j][0]) <= 2*r:\r\n cur_y = max(cur_y, (abs(4*r**2-(cur_x-drop_mas[j][0])**2))**0.5+drop_mas[j][1])\r\n\r\n drop_mas.append((cur_x, cur_y))\r\n ans.append(cur_y)\r\n\r\n print(' '.join(str(s) for s in ans))\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()\r\n", "import math\n\nn, r = input().split(' ')\nn = int(n)\nr = float(r)\npos = [[float(x) for x in input().split(' ')], [r]*n] # pos = [xs, ys]\n\nfor i in range(n):\n maxy = pos[1][i]\n for j in range(i):\n mindist = math.fabs(pos[0][i] - pos[0][j])\n if mindist <= 2*r:\n maxy = max(maxy, pos[1][j]+math.sqrt(4*r*r - mindist*mindist))\n pos[1][i] = maxy\n\nprint(\" \".join([str(y) for y in pos[1]]))\n", "n, r =map(int, input().split())\r\nl = list(map(int, input().split()))\r\nans = [r] * n\r\nfor i in range(n):\r\n for j in range(i):\r\n if 4 * r ** 2 - (max(l[i], l[j]) - min(l[i], l[j])) ** 2 >= 0:\r\n y = 4 * r ** 2 - (max(l[i], l[j]) - min(l[i], l[j])) ** 2\r\n ans[i] = max(ans[i], ans[j] + y ** 0.5)\r\nprint(*ans)" ]
{"inputs": ["6 2\n5 5 6 8 3 12", "1 1\n5", "5 300\n939 465 129 611 532", "5 1\n416 387 336 116 81", "3 10\n1 100 1000", "2 1\n2 20", "3 2\n10 10 100"], "outputs": ["2 6.0 9.87298334621 13.3370849613 12.5187346573 13.3370849613", "1", "300 667.864105343 1164.9596696 1522.27745533 2117.05388391", "1 1 1 1 1", "10 10 10", "1 1", "2 6.0 2"]}
UNKNOWN
PYTHON3
CODEFORCES
83