{"document_id":"0dac5885cba74e7ca6be","document_content":"# \nimport collections, atexit, math, sys, bisect \n\nsys.setrecursionlimit(1000000)\ndef getIntList():\n return list(map(int, input().split())) \n\ntry :\n #raise ModuleNotFoundError\n import numpy\n def dprint(*args, **kwargs):\n print(*args, **kwargs, file=sys.stderr)\n dprint('debug mode')\nexcept Exception:\n def dprint(*args, **kwargs):\n pass\n\n\n\ninId = 0\noutId = 0\nif inId>0:\n dprint('use input', inId)\n sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u81f3\u6587\u4ef6\nif outId>0:\n dprint('use output', outId)\n sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u81f3\u6587\u4ef6\n atexit.register(lambda :sys.stdout.close()) #idle \u4e2d\u4e0d\u4f1a\u6267\u884c atexit\n \nN, = getIntList()\n#print(N)\nS = input()\n\nX, Y = getIntList()\n\ndd = ( (0,1), (0,-1), (-1,0), (1,0))\npp = 'UDLR'\nzz = {}\nfor i in range(4):\n zz[ pp[i]] = dd[i]\n\n\nif abs(X) + abs(Y) >N:\n print(-1)\n return\n\nif abs(X+Y-N)%2==1:\n print(-1)\n return\n \nfromLeft = [None for i in range(N)]\nfromRight = fromLeft.copy()\n\nx0 = 0\ny0 = 0\nfor i in range(N):\n x = S[i]\n fromLeft[i] = (x0,y0)\n g = zz[x]\n x0+= g[0]\n y0+= g[1]\n\nif x0==X and y0==Y:\n print(0)\n return\n\nx0 = 0\ny0 = 0\nfor i in range(N-1,-1,-1):\n x = S[i]\n fromRight[i] = (x0,y0)\n g = zz[x]\n x0+= g[0]\n y0+= g[1]\n\n\nup = N\ndown = 0\ndprint(fromLeft)\ndprint(fromRight)\nwhile down+1 n or k % 2 != n % 2:\n\t\tprint(-1)\n\t\treturn\n\n\tprefixLR = [0] * (n + 1)\n\tprefixUD = [0] * (n + 1)\n\n\tfor i in range(n):\n\t\tprefixLR[i+1] = prefixLR[i]\n\t\tprefixUD[i+1] = prefixUD[i]\n\t\tif s[i] == 'L':\n\t\t\tprefixLR[i+1] -= 1\n\t\telif s[i] == 'R':\n\t\t\tprefixLR[i+1] += 1\n\t\telif s[i] == 'D':\n\t\t\tprefixUD[i+1] -= 1\n\t\telse:\n\t\t\tprefixUD[i+1] += 1\n\n\tleft = 0\n\tright = n\n\n\twhile left < right:\n\t\tmid = left + (right - left) \/\/ 2\n\t\tif doable(n,x,y,mid, prefixLR, prefixUD):\n\t\t\tright = mid\n\t\telse:\n\t\t\tleft = mid + 1\n\n\tprint(left)\n\t\ndef __starting_point():\n\tmain()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fb8bcd81f25c4ab7ac39","document_content":"n = int(input())\ns = input()\np,q = input().split()\nif p[0] == '-':\n x = -1*int(p[1:])\nelse:\n x = int(p)\nif q[0] == '-':\n y = -1*int(q[1:])\nelse:\n y = int(q)\ncur = [0,0]\nif(abs(x)+abs(y) > n):\n print(-1)\nelif((x+y)%2 != n%2):\n print(-1)\nelse:\n end = n\n for i in range(n):\n if s[i] == \"R\":\n cur[0] += 1\n if s[i] == \"L\":\n cur[0] -= 1\n if s[i] == \"U\":\n cur[1] += 1\n if s[i] == \"D\":\n cur[1] -= 1\n if(abs(x-cur[0])+abs(y-cur[1]) >= n-i):\n end = i\n break\n if end == n:\n print(0)\n else:\n m = [0]*(end+1)\n start = n\n for i in range(end,-1,-1):\n if s[i] == \"R\":\n cur[0] -= 1\n if s[i] == \"L\":\n cur[0] += 1\n if s[i] == \"U\":\n cur[1] -= 1\n if s[i] == \"D\":\n cur[1] += 1\n while(abs(x-cur[0])+abs(y-cur[1]) <= start-i):\n start -= 1\n if s[start] == \"R\":\n x -= 1\n if s[start] == \"L\":\n x += 1\n if s[start] == \"U\":\n y -= 1\n if s[start] == \"D\":\n y += 1\n m[i] = start-i+1\n minn = n\n for i in m:\n minn = min(minn,i)\n print(minn)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6db87319260af8fa432b","document_content":"\ndef valid(step, tx, ty, nx, ny, s, d):\n fx = 0\n fy = 0\n for i in range(len(s)):\n # insert\n c = s[i]\n fx += d[c][0]\n fy += d[c][1]\n if i >= step:\n # remove\n c = s[i-step]\n fx -= d[c][0]\n fy -= d[c][1]\n if i >= step-1:\n diff = abs(nx-fx-tx) + abs(ny-fy-ty)\n if diff <= step and (step - diff) % 2 == 0:\n return True\n return False\n\n\ndef main():\n d = {\n \"U\": (0, 1),\n \"D\": (0, -1),\n \"L\": (-1, 0),\n \"R\": (1, 0)\n }\n nx = 0\n ny = 0\n\n n = int(input())\n s = input()\n tx, ty = [int(x) for x in input().split(\" \")]\n\n diff = abs(tx) + abs(ty)\n if diff > len(s) or (diff-len(s)) % 2 == 1:\n print(-1)\n return\n\n for c in s:\n nx += d[c][0]\n ny += d[c][1]\n if (nx, ny) == (tx, ty):\n print(0)\n return\n l = 0\n r = len(s)\n ans = r\n\n while l < r:\n m = (l+r)\/\/2\n if valid(m, tx, ty, nx, ny, s, d):\n ans = m\n r = m\n else:\n l = m+1\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a009145a459e0c565156","document_content":"n=int(input())\ns=list(input())\na,b = list(map(int, input().split()))\nL=s.count('L')\nU=s.count('U')\nR=s.count('R')\nD=s.count('D')\nx=0\ny=0\nxmin=0\nymin=0\nminn=2*n\nwhile x+y<2*n:\n if abs(a-(R-L))+abs(b-(U-D))>y-x and y!=n:\n i=s[y]\n if i=='L':\n L-=1\n elif i=='R':\n R-=1\n elif i=='D':\n D-=1\n elif i=='U':\n U-=1 \n y+=1\n elif abs(a-(R-L))+abs(b-(U-D))<=y-x or y==n:\n if y-xlen(s):\n print(-1)\nelif (len(s)-(abs(a)+abs(b)))%2!=0:\n print(-1)\nelse:\n print(minn)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"90c99e5c4d44dad768e4","document_content":"import sys\n\nn=int(input())\nS=input()\nx,y=list(map(int,input().split()))\n\nif abs(x)+abs(y)>n or (abs(x)+abs(y))%2!=n%2:\n print(-1)\n return\n\nnow=[0,0]\nLISTL=[(0,0)]\nfor s in S:\n if s==\"R\":\n now[0]+=1\n elif s==\"L\":\n now[0]-=1\n elif s==\"U\":\n now[1]+=1\n else:\n now[1]-=1\n\n LISTL.append((now[0],now[1]))\n\nLISTR=[(0,0)]\nnow=[0,0]\nfor s in S[::-1]:\n if s==\"R\":\n now[0]+=1\n elif s==\"L\":\n now[0]-=1\n elif s==\"U\":\n now[1]+=1\n else:\n now[1]-=1\n\n LISTR.append((now[0],now[1]))\n\ndef su(a,b,x,y):\n return abs(x-(a[0]+b[0]))+abs(y-(a[1]+b[1]))\n\nANS=0\nfor i in range(n+1):\n for j in range(max(0,ANS-i),n+1):\n if su(LISTR[i],LISTL[j],x,y)<=n-i-j:\n #print(i,j)\n if ANS= 0 and free % 2 == 0\nresult = n + 1\nptr = n + 1\nfor i in reversed(list(range(n))):\n while ptr - 1 >= i and canChange(i, ptr - 1):\n ptr -= 1\n result = min(result, ptr - i)\nif ptr == n + 1:\n print(-1)\nelse:\n print(result)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9e221ceb626ab0b9a231","document_content":"n=int(input())\n#a=list(map(int,input().split()))\n#b=list(map(int,input().split()))\n\ns=list(input())\nx,y=list(map(int,input().split()))\n\nit=[0,0,0,0]\n\nfor i in range(len(s)):\n if s[i]=='U':\n s[i]=0\n elif s[i]=='R':\n s[i]=1\n elif s[i]=='D':\n s[i]=2\n else:\n s[i]=3\n it[s[i]]+=1\n\ndef distance(x,y,xx,yy):\n return abs(x-xx)+abs(y-yy)\n\ndef yes(steps,ost,x,y):\n xx=steps[1]-steps[3]\n yy=steps[0]-steps[2]\n return distance(x,y,xx,yy)<=ost\n\n\n\nans=0\n\n\nif distance(x,y,0,0)>n or (x+y+n)%2==1:\n print(-1)\nelif yes(it,0,x,y):\n print(0)\nelse:\n i=-1\n cur_ans=0\n max_ans=0\n\n steps=[0,0,0,0]\n \n while yes(steps,n-cur_ans,x,y):\n i+=1\n steps[s[i]]+=1\n cur_ans+=1\n\n steps[s[i]]-=1\n i-=1\n cur_ans-=1\n max_ans=cur_ans\n\n j=n\n ok=True\n\n while j>0 and ok:\n j=j-1\n steps[s[j]]+=1\n cur_ans+=1\n \n while i>=0 and not yes(steps,n-cur_ans,x,y):\n steps[s[i]]-=1\n i-=1\n cur_ans-=1\n \n if yes(steps,n-cur_ans,x,y) and cur_ans>max_ans:\n max_ans=cur_ans\n ok=(i>=0) or yes(steps,n-cur_ans,x,y)\n\n print(n-max_ans)\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5a992b52de3edf27be10","document_content":"import sys\nfin = sys.stdin.readline\n\nn = int(fin())\ncommands = list(fin())[:-1]\nx, y = [int(elem) for elem in fin().split(' ')]\n\nmove_map = {'L': (-1, 0), 'R': (1, 0), 'U': (0, 1), 'D': (0, -1)}\n\nif (x + y) % 2 != n % 2:\n print(-1)\n return\n\ncuml_coord = [None] * n\ncuml_x, cuml_y = 0, 0\nfor i, command in enumerate(commands):\n dx, dy = move_map[command]\n cuml_x += dx\n cuml_y += dy\n cuml_coord[i] = (cuml_x, cuml_y)\n\nleft, right = 0, 0\nmin_len = 2**32 - 1\norg_x, org_y = cuml_coord[-1]\nif org_x == x and org_y == y:\n min_len = 0\n\nwhile right <= n - 1:\n if left == 0:\n left_cuml = 0, 0\n else:\n left_cuml = cuml_coord[left - 1]\n right_cuml = cuml_coord[right]\n movable_x, movable_y = right_cuml[0] - left_cuml[0], \\\n right_cuml[1] - left_cuml[1]\n fixed_x, fixed_y = org_x - movable_x, org_y - movable_y\n sub_length = right - left + 1\n # print(fixed_x, fixed_y, left, right)\n # print(x - fixed_x, y - fixed_y)\n if (abs(x - fixed_x) + abs(y - fixed_y)) <= sub_length \\\n and (abs(x - fixed_x) + abs(y - fixed_y)) % 2 == sub_length % 2:\n min_len = min(min_len, sub_length)\n if left != right:\n left += 1\n else:\n right += 1\n else:\n right += 1\nif min_len == 2**32 - 1:\n print(-1)\nelse:\n print(min_len)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e081dda47a8ed4985ab9","document_content":"import math as ma\nimport sys\nfrom decimal import Decimal as dec\nfrom itertools import permutations\n\n\ndef li():\n\treturn list(map(int , sys.stdin.readline().split()))\n\n\ndef num():\n\treturn map(int , sys.stdin.readline().split())\n\n\ndef nu():\n\treturn int(sys.stdin.readline())\n\n\ndef find_gcd(x , y):\n\twhile (y):\n\t\tx , y = y , x % y\n\treturn x\n\nn=nu()\ns=input()\nx,y=num()\nuu=[0]*n\nrr=[0]*n\npu=[]\npr=[]\nfor i in range(n):\n\tif(s[i]==\"U\"):\n\t\tuu[i]=1\n\tif(s[i]==\"D\"):\n\t\tuu[i] = -1\n\tif(s[i]==\"R\"):\n\t\trr[i]=1\n\tif(s[i]==\"L\"):\n\t\trr[i]=-1\n\npu.append(uu[0])\npr.append(rr[0])\nfor i in range(1,n):\n\tpu.append(pu[i-1]+uu[i])\nfor i in range(1,n):\n\tpr.append(pr[i-1]+rr[i])\npu=[0]+pu\npr=[0]+pr\nzu=pu[len(pu)-1]\nzr=pr[len(pr)-1]\nif((abs(x-zr)+abs(y-zu))==0):\n\tprint(0)\n\treturn\nif((abs(x)+abs(y))%2!=n%2 or (abs(x)+abs(y))>n):\n\tprint(-1)\n\treturn\n\nlo=1\nhi=n\nwhile(lo<=hi):\n\tmid=(lo+hi)\/\/2\n\tfl=False\n\tfor i in range(0,n-mid+1):\n\t\tlu=zu-pu[i+mid]+pu[i]\n\t\tlr=zr-pr[i+mid]+pr[i]\n\t\tif((abs(x-lr)+abs(y-lu))<=mid):\n\t\t\tfl=True\n\t\t\tbreak\n\tif(fl==True):\n\t\thi=mid-1\n\telse:\n\t\tlo=mid+1\nprint(lo)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f98f89dbdffd5266fb52","document_content":"n = int(input().strip())\ns = str(input().strip())\nx,y = list(map(int,input().strip().split()))\nsumx = []\nsumy = []\n\nsx = 0\nsy = 0\nsumx.append(sx)\nsumy.append(sy)\nfor i in s:\n if(i=='U'):\n sy+=1\n elif(i=='D'):\n sy-=1\n elif(i=='R'):\n sx+=1\n elif(i=='L'):\n sx-=1\n sumx.append(sx)\n sumy.append(sy)\n\n#print(\"sxy\",sx, sy)\n\ndef check(mid):\n i=0\n while(i+mid<=n):\n dx = sumx[i+mid]-sumx[i]\n dy = sumy[i+mid]-sumy[i]\n cx = sx-dx\n cy = sy-dy\n #print(\"cxy\",cx,cy)\n gdx = x-cx\n gdy = y-cy\n t=abs(gdx)+abs(gdy)\n #print(\"t\",t)\n if(t%2==mid%2 and t<=mid):\n return True\n i+=1\n return False\n\nhi = n\nlo = 0\nmid=(hi+lo)\/\/2\nwhile(hi-lo>1):\n mid=(hi+lo)\/\/2\n #print(\"mid\", mid)\n if(check(mid)):\n hi=mid\n else:\n lo=mid\n#print(lo)\nif(check(lo)):\n print(lo)\nelif(check(mid)):\n print(mid)\nelif(check(hi)):\n print(hi)\nelse:\n print(-1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"25bbdfbfbe43bdec9e6f","document_content":"def check(x, y, fx, fy, num_moves):\n\tif ((abs(fx - x) + abs(fy - y))-num_moves) <= 0 and ((abs(fx - x) + abs(fy - y))-num_moves)%2 == 0:\n\t\treturn True\n\treturn False \n\nN = int(input())\nmm = {'U':0,'D':1,'L':2,'R':3}\n\ndpmat = [[0] for i in range(4)]\n\nops = str(input())\n\nfor op in ops:\n\tdpmat[0].append(dpmat[0][-1])\n\tdpmat[1].append(dpmat[1][-1])\n\tdpmat[2].append(dpmat[2][-1])\n\tdpmat[3].append(dpmat[3][-1])\n\t\n\tdpmat[mm[op]][-1] = dpmat[mm[op]][-1]+1\n\n\nfpos = list(map(int,input().split())) \nif N < fpos[0]+fpos[1]:\n\tprint(\"-1\")\nelse :\n\tx,y = 0,0\n\n\tans = 10e10\n\n\twhile y <= N and x <= y:\n\t\tif y == 0 and x == 0:\t\n\t\t\tnum_moves = 0\n\t\t\txr = dpmat[3][N]\n\t\t\txl = dpmat[2][N]\n\t\t\tyu = dpmat[0][N]\n\t\t\tyd = dpmat[1][N]\n\t\telse:\n\t\t\tnum_moves = y-x+1\n\t\t\txr = dpmat[3][x-1] + dpmat[3][N] - dpmat[3][y]\t\n\t\t\txl = dpmat[2][x-1] + dpmat[2][N] - dpmat[2][y]\t\n\t\t\tyu = dpmat[0][x-1] + dpmat[0][N] - dpmat[0][y]\t\n\t\t\tyd = dpmat[1][x-1] + dpmat[1][N] - dpmat[1][y]\t\n\t\t\n\t\tif check(xr-xl, yu-yd, fpos[0], fpos[1], num_moves) == True:\n\t\t\tx += 1\n\t\t\tans = min(ans, num_moves)\n\t\telse:\n\t\t\tif x==0:\n\t\t\t\tx += 1\t\n\t\t\ty += 1\n\tif ans == 10e10:\n\t\tprint(\"-1\")\n\telse:\n\t\tprint(max(0,ans))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f8e4da938de46d7cc754","document_content":"3\nfrom collections import Counter\n\ndef readint():\n return int(input())\n\n\ndef readline():\n return [int(c) for c in input().split()]\n\n\ndef update(pos, mv, d):\n if mv == 'U':\n pos[1] += d\n elif mv == 'D':\n pos[1] -= d\n elif mv == 'L':\n pos[0] -= d\n elif mv == 'R':\n pos[0] += d\n\n\ndef can(u, v, length):\n d = abs(u[0] - v[0]) + abs(u[1] - v[1])\n if d % 2 != length % 2:\n return False\n return length >= d\n\n\ndef ok(length, n, x, y, s):\n pos = [0, 0]\n for i in range(length, n):\n update(pos, s[i], 1)\n\n l, r = 0, length\n while True:\n if can(pos, [x, y], length):\n return True\n if r == n:\n break\n update(pos, s[l], 1)\n l += 1\n update(pos, s[r], -1)\n r += 1\n\n return False\n\n\ndef main():\n n = readint()\n s = input()\n x, y = readline()\n\n if not ok(n, n, x, y, s):\n print(-1)\n return\n\n l, r = -1, n\n while r - l > 1:\n mid = (l + r) \/\/ 2\n if ok(mid, n, x, y, s):\n r = mid\n else:\n l = mid\n \n print(r)\n\n \n\n\ndef __starting_point():\n main()\n\n\n\"\"\"\n#include \n\nusing namespace std;\n\nconst int N = int(1e5) + 9;\n\nstring s;\nint n;\nint x, y;\n\nvoid upd(pair &pos, char mv, int d){\n\tif(mv == 'U')\n\t\tpos.second += d;\n\tif(mv == 'D')\n\t\tpos.second -= d;\n\tif(mv == 'L')\n\t\tpos.first -= d;\n\tif(mv == 'R')\n\t\tpos.first += d;\n}\n\nbool can(pair u, pair v, int len){\n\tint d = abs(u.first - v.first) + abs(u.second - v.second);\n\tif(d % 2 != len % 2) return false;\n\treturn len >= d;\n}\n\nbool ok(int len){\n\tpair pos = make_pair(0, 0);\n\tfor(int i = len; i < n; ++i)\n\t\tupd(pos, s[i], 1);\n\n\tint l = 0, r = len;\n\twhile(true){\n\t\tif(can(pos, make_pair(x, y), len))\n\t\t\treturn true;\n\t\t\n\t\tif(r == n) break;\n\t\tupd(pos, s[l++], 1);\n\t\tupd(pos, s[r++], -1);\t\t\n\t}\n\t\n\treturn false;\n}\n\nint main() {\n\t\/\/freopen(\"input.txt\", \"r\", stdin);\n\t\n\tcin >> n;\n\tcin >> s;\n\tcin >> x >> y;\n\t\n\tif(!ok(n)){\n\t\tputs(\"-1\");\n\t\treturn 0;\n\t}\n\t\n\tint l = -1, r = n;\n\twhile(r - l > 1){\n\t\tint mid = (l + r) \/ 2;\n\t\tif(ok(mid)) r = mid;\n\t\telse l = mid;\n\t}\n\t\n\tcout << r << endl;\n return 0;\n}\n\"\"\"\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"636b09dc057951af95fb","document_content":"d = {\n\t'U': (0, 1),\n\t'D': (0, -1),\n\t'L': (-1, 0),\n\t'R': (1, 0)\n}\n\n\ndef compute_delta(s, head_idx, tail_idx):\n\tx = y = 0\n\tfor i in range(head_idx, tail_idx):\n\t\tx, y = x + d[s[i]][0], y + d[s[i]][1]\n\treturn x, y\n\n\ndef compute_rest(s, n, head_idx, tail_idx):\n\tx = y = 0\n\tfor i in range(0, head_idx):\n\t\tx, y = x + d[s[i]][0], y + d[s[i]][1]\n\tfor i in range(tail_idx, n):\n\t\tx, y = x + d[s[i]][0], y + d[s[i]][1]\n\treturn x, y\n\n\nn = int(input())\ns = input()\nx_d, y_d = list(map(int, input().split()))\n# n = 5\n# s = 'RURUU'\n# x_d, y_d = -2, 3\nx_t, y_t = compute_delta(s, 0, n)\n\n# if x_d == x_t and y_d == y_t:\n# print(0)\n\nl, r = 0, n\ncurrent_sol = -1\nwhile l <= r:\n\t# print(l, r)\n\tlocal_len = (r + l) \/\/ 2\n\n\tx_l, y_l = compute_rest(s, n, 0, local_len)\n\t# print('local_len: ', local_len)\n\tis_possible = False\n\tdiff = abs(x_d - x_l) + abs(y_d - y_l)\n\tif diff <= local_len and (diff + local_len) % 2 == 0:\n\t\tis_possible = True\n\t# print('\\t', x_l, y_l, abs(x_d - x_l), abs(y_d - y_l), local_len, is_possible)\n\tfor i in range(local_len, n):\n\t\tif is_possible:\n\t\t\tbreak\n\t\td_old, d_new = d[s[i]], d[s[i - local_len]]\n\t\tx_l, y_l = x_l - d_old[0] + d_new[0], y_l - d_old[1] + d_new[1]\n\t\t# print('\\t', x_l, y_l, abs(x_d - x_l), abs(y_d - y_l), local_len)\n\t\tdiff = abs(x_d - x_l) + abs(y_d - y_l)\n\t\tif diff <= local_len and (diff + local_len) % 2 == 0:\n\t\t\tis_possible = True\n\t# print(l, r, local_len, current_sol, is_possible)\n\tif is_possible:\n\t\tcurrent_sol = local_len\n\t\tr = local_len - 1\n\telse:\n\t\tl = local_len + 1\nprint(current_sol)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2db661f761671d4c5703","document_content":"d = {\n\t'U': (0, 1),\n\t'D': (0, -1),\n\t'L': (-1, 0),\n\t'R': (1, 0)\n}\n\n\ndef compute_delta(s, head_idx, tail_idx):\n\tx = y = 0\n\tfor i in range(head_idx, tail_idx):\n\t\tx, y = x + d[s[i]][0], y + d[s[i]][1]\n\treturn [x, y]\n\n\nn = int(input())\ns = input()\ndsc = list(map(int, input().split()))\ntotal = compute_delta(s, 0, n)\n\nl, r = 0, n\ncurrent_sol = -1\nwhile l <= r:\n\tlocal_len = (r + l) \/\/ 2\n\tinitial_diff = compute_delta(s, 0, local_len)\n\tlocal = [total[0] - initial_diff[0], total[1] - initial_diff[1]]\n\tis_possible = False\n\tdiff = abs(dsc[0] - local[0]) + abs(dsc[1] - local[1])\n\tif diff <= local_len and (diff + local_len) % 2 == 0:\n\t\tis_possible = True\n\tfor i in range(local_len, n):\n\t\tif is_possible:\n\t\t\tbreak\n\t\td_old, d_new = d[s[i]], d[s[i - local_len]]\n\t\tlocal = [local[0] - d_old[0] + d_new[0], local[1] - d_old[1] + d_new[1]]\n\t\tdiff = abs(dsc[0] - local[0]) + abs(dsc[1] - local[1])\n\t\tif diff <= local_len and (diff + local_len) % 2 == 0:\n\t\t\tis_possible = True\n\tif is_possible:\n\t\tcurrent_sol = local_len\n\t\tr = local_len - 1\n\telse:\n\t\tl = local_len + 1\nprint(current_sol)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8213b70d77ab7d545e57","document_content":"# -*- coding: utf-8 -*-\n\n\"\"\"\ncreated by shhuan at 2018\/11\/3 11:30\n\n\nsearch for minimum steps, consider binary search\n\n\"\"\"\n\nN = int(input())\nops = [x for x in input()]\n\nX, Y = list(map(int, input().split()))\n\ndd = abs(X) + abs(Y)\nlops = len(ops)\n# if dd > lops or (lops - dd) % 2 != 0:\n# print(-1)\n# return\n\n\n[ll, lr, lu, ld, rl, rr, ru, rd] = [[0 for _ in range(lops + 2)] for _ in range(8)]\n\nl, r, u, d = 0, 0, 0, 0\nfor i in range(lops):\n op = ops[i]\n if op == 'L':\n l += 1\n elif op == 'R':\n r += 1\n elif op == 'U':\n u += 1\n else:\n d += 1\n ll[i+1] = l\n lr[i+1] = r\n ld[i+1] = d\n lu[i+1] = u\n\nl, r, u, d = 0, 0, 0, 0\nfor i in range(lops-1, -1, -1):\n op = ops[i]\n if op == 'L':\n l += 1\n elif op == 'R':\n r += 1\n elif op == 'U':\n u += 1\n else:\n d += 1\n rl[i] = l\n rr[i] = r\n rd[i] = d\n ru[i] = u\n\ndef check(lsub):\n for i in range(lops-lsub+1):\n # j-i+1 == lsub, j < lops => i+lsub-1 i < lops-lsub+1\n j = i + lsub - 1\n\n # l, r, u, d of lops [0, i-1], ll[i]={'L' of 0,...,i-1}\n l0, r0, u0, d0 = ll[i], lr[i], lu[i], ld[i]\n\n # l, r, u, d of ops [j+1, N-1], rr[j]={'R' of lops-1,...,j}\n l1, r1, u1, d1 = rl[j+1], rr[j+1], ru[j+1], rd[j+1]\n\n x = (r0+r1) - (l0+l1)\n y = (u0+u1) - (d0+d1)\n\n dx = abs(X-x)\n dy = abs(Y-y)\n\n if dx + dy <= lsub and (lsub-dx-dy) % 2 == 0:\n return True\n\n return False\n\n\nsl, sr = 0, lops + 1\nwhile sl < sr:\n m = (sl + sr) \/\/ 2\n if check(m):\n sr = m\n else:\n sl = m + 1\n\nsl = -1 if sl > lops else sl\nprint(sl)\n\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e6636013e2608ba64b2d","document_content":"# -*- coding: utf-8 -*-\n\n\"\"\"\ncreated by shhuan at 2018\/11\/3 11:30\n\n\nsearch for minimum steps, consider binary search\n\n\"\"\"\n\nN = int(input())\nops = [x for x in input()]\n\nX, Y = list(map(int, input().split()))\n\ndd = abs(X) + abs(Y)\nlops = len(ops)\nif dd > lops or (lops - dd) % 2 != 0:\n print(-1)\n return\n\n\n[ll, lr, lu, ld, rl, rr, ru, rd] = [[0 for _ in range(lops + 2)] for _ in range(8)]\n\nl, r, u, d = 0, 0, 0, 0\nfor i in range(lops):\n op = ops[i]\n if op == 'L':\n l += 1\n elif op == 'R':\n r += 1\n elif op == 'U':\n u += 1\n else:\n d += 1\n ll[i+1] = l\n lr[i+1] = r\n ld[i+1] = d\n lu[i+1] = u\n\nl, r, u, d = 0, 0, 0, 0\nfor i in range(lops-1, -1, -1):\n op = ops[i]\n if op == 'L':\n l += 1\n elif op == 'R':\n r += 1\n elif op == 'U':\n u += 1\n else:\n d += 1\n rl[i] = l\n rr[i] = r\n rd[i] = d\n ru[i] = u\n\ndef check(lsub):\n for i in range(lops-lsub+1):\n # j-i+1 == lsub, j < lops => i+lsub-1 i < lops-lsub+1\n j = i + lsub - 1\n\n # l, r, u, d of lops [0, i-1], ll[i]={'L' of 0,...,i-1}\n l0, r0, u0, d0 = ll[i], lr[i], lu[i], ld[i]\n\n # l, r, u, d of ops [j+1, N-1], rr[j]={'R' of lops-1,...,j}\n l1, r1, u1, d1 = rl[j+1], rr[j+1], ru[j+1], rd[j+1]\n\n x = (r0+r1) - (l0+l1)\n y = (u0+u1) - (d0+d1)\n\n dx = abs(X-x)\n dy = abs(Y-y)\n\n if dx + dy <= lsub and (lsub-dx-dy) % 2 == 0:\n return True\n\n return False\n\n\nsl, sr = 0, lops + 1\nwhile sl < sr:\n m = (sl + sr) \/\/ 2\n if check(m):\n sr = m\n else:\n sl = m + 1\n\nsl = -1 if sl > lops else sl\nprint(sl)\n\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2bc301f1a8cbb88cf249","document_content":"n = int(input())\ndirs = input()\ngoal = list(map(int, input().split(' ')))\n\n\ndef can(start, end, steps):\n dist = abs(start[0] - end[0]) + abs(start[1] - end[1])\n return dist <= steps and (steps - dist) % 2 == 0\n\n\nif not can((0, 0), goal, n):\n print(-1)\n return\n\ndiffs = {\n 'U': (0, 1),\n 'D': (0, -1),\n 'L': (-1, 0),\n 'R': (1, 0),\n}\n\npos = [(0, 0)] + [None] * n\nfor i, dir in enumerate(dirs):\n old_pos = pos[i]\n diff = diffs[dir]\n pos[i+1] = (old_pos[0] + diff[0], old_pos[1] + diff[1])\n\nfinal_pos = pos[n]\n\n# best (minimum) segment to override to get to the solution\nbest = (abs(final_pos[0] - goal[0]) + abs(final_pos[1] - goal[1])) \/\/ 2\n\nif best == 0:\n print(0)\n return\n\nstart = 0\nend = best\n\ncurrent_best = float('inf')\n\nwhile end <= n:\n # exclude segment and check if can reach without\n cur_pos = (\n pos[start][0] + final_pos[0] - pos[end][0],\n pos[start][1] + final_pos[1] - pos[end][1],\n )\n\n if can(cur_pos, goal, end - start):\n current_best = min(current_best, end - start)\n if current_best == best:\n break\n start += 1\n else:\n end += 1\n\nprint(current_best)\n\n\n# min_steps = abs(goal[0]) + abs(goal[1])\n# if min_steps > n or (min_steps - n) % 2 != 0:\n# print(-1)\n# return\n\n# cur_pos = [0, 0]\n# for dir in dirs:\n# if dir == 'U':\n# cur_pos[1] += 1\n# if dir == 'D':\n# cur_pos[1] -= 1\n# if dir == 'L':\n# cur_pos[0] -= 1\n# if dir == 'R':\n# cur_pos[0] += 1\n\n# pos_diff = [goal[0] - cur_pos[0], goal[1] - cur_pos[1]]\n\n# vertical = abs(pos_diff[1]) > abs(pos_diff[0])\n# up = pos_diff[1] > 0\n# right = pos_diff[0] > 0\n# replacement_steps = (abs(pos_diff[0]) + abs(pos_diff[1])) \/\/ 2\n# diagonal_walk = replacement_steps - \\\n# abs(abs(pos_diff[1]) - abs(pos_diff[0])) \/\/ 2\n\n# start, end = 0, 0\n# covered = {'U': 0, 'D': 0, 'L': 0, 'R': 0}\n# while end < n:\n# new_dir = dirs[end]\n# covered[new_dir] += 1\n# remaining = covered.copy()\n# end += 1\n\n# if vertical:\n# if up:\n# pass\n# else:\n# pass\n# else:\n# if right:\n# pass\n# else:\n# pass\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7b0701c5bb62659d68fd","document_content":"#!\/usr\/bin\/env python3\n\nimport itertools\n\ndef solve(L, n, px, py, x, y):\n for i in range(n):\n j = i + L\n if j > n:\n break\n dx = px[i] + px[-1] - px[j] - x\n dy = py[i] + py[-1] - py[j] - y\n if abs(dx) + abs(dy) <= L:\n return True\n return False\n\ndef main(args):\n n = int(input())\n d = input()\n x, y = list(map(int, input().split()))\n py = [0] + [1 if c == 'U' else (-1 if c == 'D' else 0) for c in d]\n px = [0] + [1 if c == 'R' else (-1 if c == 'L' else 0) for c in d]\n if abs(x+ y)%2 != n%2:\n print(-1)\n return 0\n py = list(itertools.accumulate(py))\n px = list(itertools.accumulate(px)) \n if px[-1] == x and py[-1] == y:\n print(0)\n return 0\n if abs(x) + abs(y) > n:\n print(-1)\n return 0\n left = 0\n right = n\n while left + 1 < right:\n mid = (left + right) \/\/ 2\n if solve(mid, n, px, py, x, y):\n left, right = left, mid\n else:\n left, right = mid, right\n print(right)\n return 0\n\ndef __starting_point():\n import sys\n return(main(sys.argv))\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a40fb47dce012717287f","document_content":"def go(pos,k):\n if 'U'==k:\n pos[1]+=1\n elif 'D'==k:\n pos[1]-=1\n elif 'L'==k:\n pos[0]-=1\n else:\n pos[0]+=1\n return pos\n\ndef relapos(a,b): #\u8fd4\u56deb\u7684\u5750\u6807\u51cfa\u7684\u5750\u6807\n c=[b[0]-a[0],b[1]-a[1]]\n return c\n\ndef stdis(a,b):\n return abs(b[1]-a[1])+abs(b[0]-a[0])\n \n\nn=int(input())\ns=input()\nx,y=[int(i) for i in input().split()]\nposs=[[0,0]] #\u7b2cn\u6b21\u64cd\u4f5c\u540e\u7684\u4f4d\u7f6e\npos=[0,0]\nfor i in range(0,n):\n poss.append(tuple(go(pos,s[i])))\nif abs(x)+abs(y)>n or abs(n-x-y)%2!=0:\n print(-1)\nelse:\n lpos=poss[-1]\n dd=stdis(lpos,[x,y])\n if dd==0:\n print(0)\n else:\n q1=(dd-1)\/\/2\n q2=n\n j=True\n lpos1=[0,0]\n while q2-q1!=1:\n q=(q2+q1)\/\/2\n for k1 in range(n-q+1):\n r=relapos(poss[k1],poss[k1+q])\n lpos1[0]=lpos[0]-r[0]\n lpos1[1]=lpos[1]-r[1]\n if stdis(lpos1,[x,y])<=q:\n q2=q\n break\n else:\n q1=q\n print(q2)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"329ac6525277870f9bf0","document_content":"n = int(input())\nsubtract = lambda t1, t2: (t1[0] - t2[0], t1[1] - t2[1])\nadd = lambda t1, t2: (t1[0] + t2[0], t1[1] + t2[1])\ndef conv(ch):\n\tif ch == 'L':\n\t\treturn (-1, 0)\n\telif ch == 'R':\n\t\treturn (1, 0)\n\telif ch == 'U':\n\t\treturn (0, 1)\n\telif ch == 'D':\n\t\treturn (0, -1)\n\nops = [conv(ch) for ch in input()]\nx, y = list(map(int, input().split()))\nlsum = [ops[0]] * n\nfor i in range(1, n):\n\tlsum[i] = add(lsum[i - 1], ops[i])\nrsum = [ops[n - 1]] * n\ni = n - 2\nwhile i >= 0:\n\trsum[i] = add(rsum[i + 1], ops[i])\n\ti = i - 1\n\ndef check(L):\n\t\n\tfor i in range(0, n - L + 1):\n\t\tmoves = (x, y)\n\t\tif i > 0:\n\t\t\tmoves = subtract(moves, lsum[i - 1])\n\t\tif i + L < n:\n\t\t\tmoves = subtract(moves, rsum[i + L])\n\t\tturns = abs(moves[0]) + abs(moves[1])\n\t\tif (turns <= L and (L - turns) % 2 == 0):\n\t\t\treturn True;\n\treturn False;\n\nif abs(x) + abs(y) > n or (abs(x) + abs(y) - n) % 2 != 0:\n\tprint((-1));\nelse:\n\tst, en = 0, n\n\twhile st < en:\n\t\tmd = (st + en) \/\/ 2\n\t\tif check(md):\n\t\t\ten = md\n\t\telse:\n\t\t\tst = md + 1\n\tprint(st)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"17a3fc800da83b2d708c","document_content":"def check(length: int):\n nonlocal n, x, y, cur, hor, ver\n hor = 0\n ver = 0\n for i in range(length, n):\n upd(i)\n for i in range(n - length + 1):\n if abs(x - hor) + abs(y - ver) <= length:\n return True\n if i + length < n:\n upd(i)\n minus_upd(i + length)\n return False\n\n\ndef upd(pos: int):\n nonlocal s, ver, hor\n if s[pos] == 'U':\n ver += 1\n elif s[pos] == 'D':\n ver -= 1\n elif s[pos] == 'R':\n hor += 1\n else:\n hor -= 1\n\n\ndef minus_upd(pos: int):\n nonlocal s, ver, hor\n if s[pos] == 'U':\n ver -= 1\n elif s[pos] == 'D':\n ver += 1\n elif s[pos] == 'R':\n hor -= 1\n else:\n hor += 1\n\n\nn = int(input())\ns = list(input())\nx, y = map(int, input().split())\nif (x + y) % 2 != n % 2 or abs(x) + abs(y) > n:\n print(-1)\n return\n\nver = 0\nhor = 0\ncur = 0\nfor i in range(n):\n upd(i)\n\nleft = -1\nr = n\nwhile r - left > 1:\n length = (r + left) \/\/ 2\n if check(length):\n r = length\n else:\n left = length\n\nprint(r)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"947dbd2b9892d0cacc9e","document_content":"n=int(input())\na=input()\nx,y=map(int,input().split())\nlocs=[(0,0)]\nfor i in range(n):\n if a[i]==\"U\":\n locs.append((locs[-1][0],locs[-1][1]+1))\n elif a[i]==\"D\":\n locs.append((locs[-1][0],locs[-1][1]-1))\n elif a[i]==\"R\":\n locs.append((locs[-1][0]+1,locs[-1][1]))\n else:\n locs.append((locs[-1][0]-1,locs[-1][1]))\nif abs(x)+abs(y)>n or (x+y-n)%2==1:\n print(-1)\nelif locs[-1]==(x,y):\n print(0)\nelse:\n a=0\n b=0\n best=n\n end=locs[-1]\n while True:\n c,d=locs[a][0]+end[0]-locs[b][0],locs[a][1]+end[1]-locs[b][1]\n if abs(c-x)+abs(d-y)<=b-a:\n best=min(best,b-a)\n a+=1\n else:\n b+=1\n if b>n:\n print(best)\n break","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"93dd66700a70a5ffe3d8","document_content":"import functools\n\nn = int(input())\ndct = {'U': (0, 1), 'D': (0, -1), 'L': (-1, 0), 'R': (1, 0)}\nmoves_list = list([dct[x] for x in [*input()]])\ndest_x, dest_y = list(map(int, input().split()))\n\n\ndef add_vectors(a, b):\n return a[0] + b[0], a[1] + b[1]\n\n\ndef subtract_vectors(a, b):\n return a[0] - b[0], a[1] - b[1]\n\n\ntotal = functools.reduce(add_vectors, moves_list)\n\n\ndef czy(dl) -> bool:\n sumo = total\n for v in moves_list[:dl]:\n sumo = subtract_vectors(sumo, v)\n for i in range(1, n - dl + 2):\n (dx, dy) = list(map(abs, subtract_vectors((dest_x, dest_y), sumo)))\n if dx + dy <= dl and (dx + dy) % 2 == dl % 2:\n return True\n if i + dl - 1 >= n:\n break\n sumo = subtract_vectors(sumo, moves_list[i + dl - 1])\n sumo = add_vectors(sumo, moves_list[i - 1])\n return False\n\n\npocz = 0\nkon = n\nwhile pocz < kon:\n sr = (pocz + kon) \/\/ 2\n if czy(sr):\n kon = sr\n else:\n pocz = sr + 1\n\nif czy(pocz):\n print(pocz)\nelse:\n print(-1)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"73f174d9c7a84ae01238","document_content":"n = int(input())\na = list(map(int, input().split()))\nres = 0\nnew_a = []\nfor i in range(n):\n if a[i] % 2 == 0:\n if a[i] > 0:\n res += a[i]\n else:\n new_a.append(a[i])\na = new_a\na.sort()\nres += a[-1]\na.pop()\nwhile len(a) > 1:\n if a[-1] + a[-2] > 0:\n res += a[-1] + a[-2]\n a.pop()\n a.pop()\n else:\n break\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"01d11ad95205ce524c17","document_content":"n = int(input())\nA = list(map(int, input().split()))\ndp = [[-9999999999, -9999999999]]\nfor elem in A:\n dp += [[0, 0]]\n if elem % 2 == 0:\n dp[-1][0] = max(dp[-2][0] + elem, dp[-2][0], elem)\n dp[-1][1] = max(dp[-2][1] + elem, dp[-2][1])\n else:\n dp[-1][0] = max(dp[-2][1] + elem, dp[-2][0])\n dp[-1][1] = max(dp[-2][0] + elem, dp[-2][1], elem)\nprint(dp[-1][1])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cbd0925243e60fd71ab1","document_content":"#!\/bin\/python3\nimport sys\nimport math\nn = int(input())\na = list(map(int, input().split()))\neven = 0\nodds = []\nfor i in range(n):\n if a[i] % 2 == 0 and a[i] > 0:\n even += a[i];\n elif a[i] % 2 == 1:\n odds.append(-a[i]);\nodds.sort()\nmaxsum = -odds[0]\ni = 1\ncursum = -odds[0];\nwhile i < len(odds):\n cursum += -(odds[i])\n i += 1\n if i >= len(odds):\n break;\n cursum += -(odds[i])\n i+=1\n maxsum = max(maxsum, cursum)\nprint(maxsum + even)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9a30401c9b91fb99b805","document_content":"n = int(input())\na = list(map(int, input().split()))\n\nf = 0\nfor i in range(n):\n if a[i] >= 0:\n f += a[i]\n\nif f % 2:\n print(f)\nelse:\n m = 10 ** 9\n for i in range(n):\n if a[i] % 2:\n m = min(m, abs(a[i]))\n \n print(f - m)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"909ca153c0b0a8e524a7","document_content":"n = int(input())\na = list(map(int, input().split()))\nc = list([x for x in a if x % 2 == 0 and x > 0])\nb = list([x for x in a if x % 2 != 0])\nb = sorted(b, reverse=True)\nmm = int(-1e10)\ns = 0\nfor i in range(len(b)):\n s += b[i]\n if i % 2 == 0:\n mm = max(mm, s)\n# print(c)\nprint(sum(c) + mm)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d6004a539cc8dfc5a5a9","document_content":"def max(a, b):\n\tif a > b:\n\t\treturn a\n\telse:\n\t\treturn b\n\ndef min(a, b):\n\tif a < b:\n\t\treturn a\n\telse:\n\t\treturn b\n\ndef __starting_point():\n\tn = int(input())\n\tA = input().split(' ')\n\tans, count, Min, Max = 0, 0, 1000000000, -100000000000\n\tfor i in range(n):\n\t\tnow = int(A[i])\n\t\tif now % 2 == 0:\n\t\t\tans += max(now, 0)\n\t\telse:\n\t\t\tif (now < 0):\n\t\t\t\tMax = max(Max, now)\n\t\t\telse:\n\t\t\t\tMin = min(Min, now)\n\t\t\t\tans += now\n\n\tif ans % 2 == 0:\n\t\tans = max(ans - Min, ans + Max)\n\tprint(ans)\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8eb119abc04f2d35b9f2","document_content":"N = int( input() )\nA = list( map( int, input().split() ) )\ndp = [ [ - int( 1e9 ) for i in range( 2 ) ] for j in range( N + 1 ) ]\ndp[ 0 ][ 0 ] = 0\nfor i in range( N ):\n for j in range( 2 ):\n if abs( A[ i ] ) & 1:\n dp[ i + 1 ][ j ] = max( dp[ i ][ j ], dp[ i ][ j ^ 1 ] + A[ i ] )\n else:\n dp[ i + 1 ][ j ] = max( dp[ i ][ j ], dp[ i ][ j ] + A[ i ] )\nprint( dp[ N ][ 1 ] )\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"34bae675df1195d88e80","document_content":"n = int(input())\na = list(map(int, input().split()))\na.sort(key=lambda x: -x)\ns_p = sum([x for x in a if x > 0])\nif s_p % 2 == 1:\n print(s_p)\nelse:\n m_p = list([x for x in a if x > 0 and x % 2 == 1])\n m_n = list([x for x in a if x < 0 and x % 2 == 1]) \n if len(m_p) > 0 and len(m_n) > 0:\n s_p += max(-min(m_p), max(m_n))\n elif len(m_p) == 0 and len(m_n) > 0:\n s_p += max(m_n)\n else:\n s_p += -min(m_p)\n print(s_p)\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"89c4822f766c21fda6a9","document_content":"_ = input()\nv = [int(x) for x in input().split()]\n\nneg_par = []\nneg_impar = []\npoz_par = []\npoz_impar = []\n\nfor x in v:\n if x < 0:\n if x % 2 == 0:\n neg_par.append(x)\n else:\n neg_impar.append(x)\n else:\n if x % 2 == 0:\n poz_par.append(x)\n else:\n poz_impar.append(x)\n\nneg_par.sort()\nneg_impar.sort()\npoz_par.sort()\npoz_impar.sort()\n\nres = sum(poz_par)\nif len(poz_impar) > 0:\n if len(poz_impar) % 2 == 1:\n res += sum(poz_impar)\n else:\n if len(neg_impar) > 0 and neg_impar[-1] + poz_impar[0] > 0:\n res += sum(poz_impar)\n res += neg_impar[-1]\n else:\n res += sum(poz_impar[1:])\nelse:\n res += neg_impar[-1]\nprint(res)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f3a31a66b2aec3527d50","document_content":"input()\na=[int(x) for x in input().split()]\n\noc=0\nps=0\npmo=1e6\nnmo=-1e6\n\nfor x in a:\n if x>0:\n ps+=x\n if x%2==1 and x>0 and pmo>x:\n pmo=x\n if x%2==1 and x>0: \n oc+=1\n if x%2==1 and x<0 and nmo= 0:\n if a[i] % 2 == 1:\n m1 = a[i]\n i += 1\ns = sum(a[:i])\nif s % 2 == 1:\n print(s)\nelse:\n while i < n and a[i] % 2 == 0:\n i += 1\n if i < n: m2 = a[i]\n print(max(s-m1,s+m2))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f072742df8fe17ffd0ea","document_content":"n = int(input())\nlst = [int(x) for x in input().split(\" \")]\n\neven = list([x for x in lst if x % 2 == 0])\nodd = list([x for x in lst if x % 2 != 0])\n\neven_sum = 0\nfor i in even:\n if i > 0:\n even_sum += i # always take all even sums\n\nodd = reversed(sorted(odd))\n\npossible = []\nrolling = 0\nfor i in odd: # there must be at least one odd number\n rolling += i\n possible.append(even_sum + rolling)\n\npossible = reversed(sorted(possible))\nfor i in possible: # print highest sum\n if i % 2 != 0:\n print(i)\n break\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3c144ece937b440e6dbc","document_content":"import math\nn = int(input())\n\nl = list(map(int, input().split(\" \")))\nli = []\nfor i in l:\n if(i > 0):\n li.append(i)\ns = sum(li)\nfound = False\nif(s%2 == 0):\n m = 10000\n for i in li:\n if i < m and i%2==1:\n m = i\n found = True\n if(found): \n m2 = -10000\n for i in l:\n if i > m2 and i < 0 and i%2 == 1:\n m2 = i\n if(abs(m2) > m):\n print(s-m)\n else:\n print(s+m2)\n else:\n m2 = -10000\n for i in l:\n if i > m2 and i < 0 and i%2 == 1:\n m2 = i\n print(s+m2)\nelse:\n print(s)\n \n \n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"07b9fd57d83130ecc551","document_content":"n = int(input())\na = [int(i) for i in input().split()]\notrmax = -10**4 - 1\npolmin = 10**4 +1\nsm = 0\nfor i in a:\n\tif i<0:\n\t\tif i>otrmax and i%2==1:\n\t\t\totrmax = i\n\telse:\n\t\tif i=0:\n sum1+=a[i]\n if a[i]%2==0:\n b.append(a[i])\n else:\n c.append(a[i])\n else:\n sum2+=a[i]\n if a[i]%2==0:\n d.append(a[i])\n else:\n e.append(a[i])\nif sum1%2==1 and sum1>0:\n print(sum1)\nelse:\n if len(e)>0:\n if len(c)>0:\n print(max(sum1+e[-1],sum1-c[0]))\n else:\n print(sum1+e[-1])\n else:\n if len(c)>0:\n print(sum1-c[0])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8cd4fa7aa9f2929921de","document_content":"n=int(input())\na=list(map(int,input().split()))\ns=0\nb=0\nc=0\nfor i in a:\n if i>0:\n s+=i\n if i%2!=0:\n if b>0:\n b=min(b,i)\n if b==0:\n b=i\n if i<0 and i%2!=0:\n if c<0:\n c=max(c,i)\n if c==0:\n c=i\nif s%2!=0:\n print(s)\nelse:\n if (abs(c)0:\n sumpos+=i\n if iabs(maxNegOdd):\n sumpos+=maxNegOdd\n else:\n sumpos-=maxPosODD\nprint(sumpos)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"77267788c7256a57ea2c","document_content":"n = int(input())\na = list(map(int, input().split(\" \")))\n\nminus_odd = -10001\nplus_odd = 10001\ntotal = 0\n\nfor i in a:\n if i % 2:\n if i < 0:\n minus_odd = max(minus_odd, i)\n else:\n plus_odd = min(plus_odd, i)\n\n if i > 0:\n total += i\n\nif total % 2 == 0:\n if minus_odd == -10001:\n print(total - plus_odd)\n elif plus_odd == 10001:\n print(total + minus_odd)\n else:\n if -minus_odd > plus_odd:\n print(total - plus_odd)\n else:\n print(total + minus_odd)\n\nelse:\n print(total)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"81376262dde50c44ec5c","document_content":"n = int(input())\na = list(map(int, input().split()))\na.sort(reverse=True)\ns = 0\nfor i in range(n):\n if a[i] > 0: s += a[i]\n else: break\nif s % 2: print(s)\nelse:\n mx = -100000\n for i in range(n):\n if a[i] < 0 and a[i] % 2: mx = max(a[i], mx)\n mn = 100000\n for i in range(n):\n if a[i] >= 0 and a[i] % 2: mn = min(a[i], mn)\n #print(mx, mn)\n print(max(s + mx, s - mn))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"692a5315a7adebbb7708","document_content":"n = int(input())\nnums = list(map(int, input().split()))\n\npos = [x for x in nums if x > 0]\nneg = [x for x in nums if x < 0]\n\ns1 = sum(pos)\nif s1 % 2 == 1:\n print(s1)\n return\n\npodd = [x for x in pos if x % 2 == 1]\nnodd = [x for x in neg if x % 2 == 1]\n\n\nif podd:\n min_podd = min(podd)\n if not nodd:\n s1 -= min_podd\n else:\n max_nodd = max(nodd)\n if min_podd + max_nodd > 0:\n s1 += max_nodd\n else:\n s1 -= min_podd\nelse:\n s1 += max(nodd)\n\n\nprint(s1)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"50e1f3ab74824630da83","document_content":"n = int(input())\nnums = [int(i) for i in input().split()]\nresult = 0\nmin_positive = 10001\nmax_negative = -10001\nfor i in nums:\n if i > 0:\n result += i\n if i % 2 == 1:\n if 0 < i < min_positive:\n min_positive = i\n elif max_negative < i < 0:\n max_negative = i\nif result % 2 == 0:\n if abs(max_negative) > min_positive:\n result -= min_positive\n else:\n result += max_negative\nprint(result)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a296de3a762c4aec2307","document_content":"n = int(input())\na = list(map(int,input().split()))\ns=0\nneg = -10000\npos = 10000\nfor i in range(n):\n\tif a[i]%2:\n\t\tif a[i]<0:\n\t\t\tneg = max(a[i],neg)\n\t\telse:\n\t\t\tpos = min(a[i],pos)\n\tif a[i]>0:s += a[i]\nif neg%2 == 0: neg = 10000\nif pos%2 == 0: pos = 10000\nif s%2==0:\n\ts-=min(abs(neg),pos)\nprint(s)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b4e42c5a50177b0a06cf","document_content":"#! \/bin\/python\nn = int(input())\ntab = list(map(int, input().split()))\ntab = sorted(tab, reverse=True)\n# print(tab)\nmaxi = 0\ntmpOdd = 0\nmaxOdd = 0\noddFirst = True\nfor i in tab:\n if i % 2 == 0 and i > 0:\n maxi += i\n elif i %2 == 1:\n tmpOdd += i\n if tmpOdd % 2 == 1:\n if maxOdd < tmpOdd or oddFirst:\n oddFirst = False\n maxOdd = tmpOdd\nmaxi += maxOdd\nprint(maxi)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3ccfa8538e8d4f6f0f9a","document_content":"n=int(input())\ns=input()\ns=s.split()\nl=[]\no=[]\non=[]\nsum=0\nfor i in s:\n\tte=int(i)\n\tl.append(te)\n\tif(te>0 and te%2==1):\n\t\to.append(te)\n\telif(te>0 and te%2==0):\n\t\tsum+=te\n\telif(te<0 and te%2==1):\n\t\ton.append(te)\no.sort(reverse=True)\non.sort(reverse=True)\nko=0\nfor i in on:\n\tif(i%2==1):\n\t\tko=i\n\t\tbreak\n\nj=2\nsumo=0\nif(len(o)>0):\n\tsumo=o[0]\nwhile(j0 and ko<0):\n\t\tprint(max(sum+sumo,sum+sumo+ko+o[-1]))\n\telif(len(on)>0 and ko==0):\n\t\tprint(sum+sumo)\n\telse:\n\t\tprint(sum+sumo)\n\n\t\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"652bf47d95c3c26ad21f","document_content":"h, n = list(map(int, input().split()))\nc, m = 0, 2 ** h\nr = 0\nwhile m > 1:\n if c == 0:\n if n > m \/\/ 2:\n r += m - 1\n n -= m \/\/ 2\n c = 1 - c\n else:\n if n > m \/\/ 2:\n n -= m \/\/ 2\n else:\n r += m - 1\n c = 1 - c\n c = 1 - c\n r += 1\n m \/\/= 2\n #print(c, m, r, n)\nprint(r)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5ed46f320ac4764173d1","document_content":"\"\"\"\nCodeforces Contest 287 Div 2 Problem C\n\nAuthor : chaotic_iak\nLanguage: Python 3.4.2\n\"\"\"\n\n################################################### SOLUTION\n\ndef main():\n h,n = read()\n n -= 1\n n = bin(n)[2:]\n n = \"0\" * (h-len(n)) + n\n\n s = \"\"\n for i in range(h):\n if i and n[i-1] == \"0\":\n s += \"1\" if n[i] == \"0\" else \"0\"\n else:\n s += n[i]\n\n ct = 0\n for i in range(h):\n ct += 1\n if s[i] == \"1\": ct += 2**(h-i)-1\n print(ct)\n\n#################################################### HELPERS\n\n\n\ndef read(mode=2):\n # 0: String\n # 1: List of strings\n # 2: List of integers\n inputs = input().strip()\n if mode == 0: return inputs\n if mode == 1: return inputs.split()\n if mode == 2: return list(map(int, inputs.split()))\n\ndef write(s=\"\\n\"):\n if s is None: s = \"\"\n if isinstance(s, list): s = \" \".join(map(str, s))\n s = str(s)\n print(s, end=\"\")\n\nwrite(main())","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b0939ddf7ef3f13d68c9","document_content":"height, n = list(map(int, input().split()))\n\ns = height\nreverted = False\nfor h in range(height-1, -1, -1):\n\n if n > 2**h:\n more = True\n n -= 2**h\n else:\n more = False\n\n if more ^ reverted:\n s += (2 * 2**h - 1)\n\n reverted = not more\n\nprint (s)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e310a734552ac40ea928","document_content":"h,n=list(map(int,input().split()))\np=1<<(h-1)\ni=r=0\nn-=1\nwhile h:\n\tr+=1\n\tif n>=p:j=1;n-=p\n\telse:j=0\n\tif j^i:r+=p+p-1\n\telse:i=1-i\n\tp>>=1\n\th-=1\nprint(r)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8490cc01b5690c101f14","document_content":"def summ(x):\n ret=1\n acc=1\n while(acc<=x):\n ret+=acc\n acc*=2\n return ret\n\nh,n=list(map(int,input().split()))\n\nans = 1\nlvl = 0\ncur = 'L'\namnt = 2**h\nwhile(1):\n if(lvl==h):\n break\n if(cur=='L'):\n if(n<=amnt\/\/2):\n amnt\/\/=2\n cur='R'\n ans+=1\n lvl+=1\n else:\n amnt\/\/=2\n n-=amnt\n cur='L'\n ans+=summ(amnt)\n lvl+=1\n else:\n if(n<=amnt\/\/2):\n amnt\/\/=2\n cur='R'\n ans+=summ(amnt)\n lvl+=1\n else:\n amnt\/\/=2\n n-=amnt\n cur='L'\n ans+=1\n lvl+=1\nprint(ans-1)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5b6e0b820bc36a3b5570","document_content":"H, N = [int(i) for i in input().split()]\n\nresult = 0\nside = 0\nfor h in range(H, 0, -1):\n result += 1\n if side ^ (N > 1 << (h - 1)):\n result += (1 << h) - 1\n else:\n side ^= 1\n if N > 1 << (h - 1):\n N -= 1 << (h - 1)\n \nprint(result)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6b892b7114fe67af396b","document_content":"h,n = map(int, input().split(' '))\nans = 0\nleft = True\nfor i in range(h) :\n ch = h-i\n half = 2**(ch-1)\n \n if n <= half :\n if left :\n ans += 1\n left = False\n continue\n else :\n ans += half*2\n left = False\n continue\n else :\n if left :\n ans += half*2\n left = True\n n -= half\n else :\n ans += 1\n left = True\n n -= half\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"075b4eaced0f595438a3","document_content":"line = input().split()\n\nh = int(line[0])\nn = int(line[1])\n\nlast = 1\nth = 2 ** h\nans = 1\nl = 1\nr = th\nwhile th > 0:\n mid = (l + r) \/\/ 2\n if n <= mid:\n if last == 1:\n ans += 1\n else:\n ans += th\n last = 0\n r = mid\n else:\n if last == 0:\n ans += 1\n else:\n ans += th\n last = 1\n l = mid + 1\n th = th \/\/ 2\n\nprint(str(ans - 2))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b4fdf5563c807f512884","document_content":"def ans():\n h, n= [int(i) for i in input().split()]\n div= 2**(h- 1)\n mystr= \"\"\n for i in range(h):\n #print(div)\n if n> div:\n mystr+= \"G\"\n div+= 2**(h- i- 2)\n else:\n mystr+= \"L\"\n div-= 2**(h- i- 2)\n \n #print(mystr)\n if mystr[0]== \"L\":\n ans= 1\n elif mystr[0]== \"G\":\n ans= 2**h\n for i in range(len(mystr)- 1):\n if mystr[i+ 1]== mystr[i]:\n ans+= 2**(h- i- 1)\n else:\n ans+= 1\n \n print(ans)\n \n \n \n return\nans()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"81f45c98dfa0811f4253","document_content":"h,n = list(map(int,input().split()))\nl = 1; r = 2**h\nans = 0\nnow = 'l'\nfor i in range(h,0,-1):\n if n < (l+r)\/2 and now == 'l':\n now = 'r'\n r -= 2**(i-1)\n ans += 1\n elif n < (l+r)\/2 and now == 'r':\n r -= 2**(i-1)\n ans += 2**i\n elif n > (l+r)\/2 and now == 'l':\n l += 2**(i-1)\n ans += 2**i\n else:\n now = 'l'\n l += 2**(i-1)\n ans += 1\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"08e54aea1e0d1e82eb6c","document_content":"__author__ = 'Konrad Strack'\n\n\ndef command_gen():\n while True:\n yield 'L'\n yield 'R'\n\n\ndef solve():\n h, n = [int(x) for x in input().split()]\n\n leaves = 2 ** h\n\n path = []\n left, right = 1, leaves\n for i in range(h):\n middle = (left + right) \/\/ 2\n if n <= middle:\n path.append('L')\n right = middle\n else:\n path.append('R')\n left = middle + 1\n\n command = command_gen()\n sum = 0\n hi = h\n for p in path:\n cmd = next(command)\n\n if p != cmd:\n sum += 2 ** hi - 1\n next(command)\n hi -= 1\n\n sum += len(path)\n print(sum)\n\n\ndef __starting_point():\n solve()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4d38f9ff8765d9c1738d","document_content":"h, n = map(int, input().split())\nt = bin(n-1)[2:]\nt = '0'*(h-len(t))+t\nres = 0\nflag = True\nfor i in range(h):\n\tif(t[i] == ('1' if flag else '0')):\n\t\tres += 2**(h-i)\n\telse:\n\t\tflag = not flag\n\t\tres += 1\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e864268684693b5b1367","document_content":"h, n = map(int, input().split())\n\ntotal = 2 ** (h + 1) - 1\n\nsum_v = 0\nrange_v = (0, 2 ** h - 1)\nprev_r = range_v\nx = n - 1\nleft = False\ncurr_h = 0\n\n\ndef in_range(r, x):\n return r[0] <= x <= r[1]\n\n\ndef range_width(r):\n return r[1] - r[0] + 1\n\n\ndef update_range(r, l):\n w = range_width(r) \/\/ 2\n st = r[0] if l else r[0] + w\n return st, st + w - 1\n\n#print(\"X \", x)\nwhile range_width(range_v) != 0:\n left = not left\n #print(range_v)\n\n tmp = range_v\n if in_range(range_v, x):\n range_v = update_range(range_v, left)\n sum_v += 1\n curr_h += 1\n #print(\"+ 1\")\n else:\n range_v = update_range(prev_r, left)\n sum_v += 2 ** (h - curr_h + 1) - 1\n #print(\"+ \", 2 ** (h - curr_h + 1) - 1)\n\n prev_r = tmp\n\nprint(sum_v - 1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"52ebbbb4035f0e7b4d1f","document_content":"import math\ns = 'LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR'\n(h, n) = [int(x) for x in input().split()]\nn = 2**(h)-1+n\nleft = 2**h\nright = 2**(h+1)-1\npath = []\nfor i in range(h):\n center = (right+left)\/2\n if n>center:\n path.append('R')\n left = math.ceil(center)\n else:\n path.append('L')\n right = int(center)\n\ncost = 1\nfor i in range(len(path)):\n if s[i] != path[i]:\n cost += 2**(h-i)-1+1\n s = s[:i]+s[i+1:]\n else:\n cost += 1\nprint(cost-1)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a6ee995562b7bf86d530","document_content":"h, n = list(map(int, input().split()))\nh -= 1\nn -= 1\nl = 0\nr = 2 << h\nll = True\nans = 0\ni = 0\nwhile r - l > 1:\n m = (l + r) \/\/ 2\n if ll == (n < m):\n ans += 1\n else:\n ans += 1 << (h - i + 1)\n if n < m:\n r = m\n ll = False\n else:\n l = m;\n ll = True\n i += 1\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3cc5c6cf3a13fc390a86","document_content":"h,n = list(map(int,input().split()))\nz = 2\nz1 = 1\np = 0\nr = 0\nh2 = 0\nh3 = 2**h\nwhile p < h:\n if n <= h2 + h3 \/\/ z and r == 0:\n z1 += 1\n z *= 2\n r = 1\n elif n > h2 + h3 \/\/ z and r == 0:\n h2 += h3 \/\/ z\n z1 += 2**(h-p)\n z *= 2\n r = 0\n elif n <= h2 + h3 \/\/ z and r == 1:\n z1 += 2**(h-p)\n z *= 2\n r = 1\n elif n > h2 + h3 \/\/ z and r == 1:\n h2 += h3 \/\/ z\n z1 += 1\n z *= 2\n r = 0\n p += 1\nprint(z1 - 1)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a79b6a8cad4d128b29f4","document_content":"h, n = (int(x) for x in input().split())\nleftPlus, rightPlus = 1, 2**h\nanswer = 1\ncurLevel = 0\ndelim = 2**(h - 1)\nwhile curLevel != h:\n\th -= 1\n\tif n <= delim:\n\t\tanswer += leftPlus\n\t\tleftPlus, rightPlus = max(rightPlus \/\/ 2, leftPlus \/\/ 2), 1\n\t\tdelim -= 2**(h - 1)\n\t\t# print (\"L\", answer)\n\telse:\n\t\tanswer += rightPlus\n\t\tleftPlus, rightPlus = 1, max(rightPlus \/\/ 2, leftPlus \/\/ 2)\n\t\tdelim += 2**(h - 1)\n\t\t# print (\"R\", answer)\t\nprint (answer - 1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"785edbcbc2645aa2cfba","document_content":"import math\n\ndef is_left_son(num):\n if num == num \/\/ 2 * 2:\n return True\n else:\n return False\n\ndef bin_search(place, depth):\n answer = \"\"\n length = 2 ** depth\n while length > 1:\n if place > length \/ 2:\n answer += \"R\"\n place -= length \/ 2\n else:\n answer += \"L\"\n length = length \/ 2\n return answer\n\ndef traverse(depth, route):\n answer = 0\n cur_vert = 1\n cur_dir = \"L\"\n while route:\n if route[0] == \"R\":\n cur_vert = cur_vert * 2 + 1\n else:\n cur_vert = cur_vert * 2\n if cur_dir == route[0]:\n answer += 1\n else:\n answer += 2**depth\n depth -= 1\n route = route[1:]\n cur_dir = \"R\" if is_left_son(cur_vert) else \"L\"\n return answer\n \nh, n = (int(x) for x in input().split())\namount_visited = 0\ncur_pos = 1 \nprint(traverse(h, bin_search(n, h)))\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f216ac8a12e1fafcdafc","document_content":"\n\n\nh, n = list(map(int, input().split()))\nh += 1\n\nmoves = []\n\nresult = h - 1\n\nn += (2**(h-1)) - 1\n\nwhile n != 1:\n if n % 2 == 1:\n moves.append(1)\n else:\n moves.append(0)\n n \/\/= 2\n\nindex_on_list = 0\n\nch = 1\n\nwhile len(moves) > 0:\n if moves[-1] != index_on_list % 2:\n result += (2**(h-ch)) - 1\n else:\n moves.pop()\n ch += 1\n\n index_on_list += 1\n\nprint(result)\n\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f9b76bbe2beec1ddd6e6","document_content":"import sys\ndef main():\n rdl = list(map(int,input().split()))\n obx(rdl[0],rdl[1],0,1)\ndef obx(lvl, ind, kl, current):\n if lvl ==0:\n print(int(kl))\n return\n all = 0\n for i in range(lvl+1):\n all += 2**i\n all -= 1\n\n if ind > (2**(lvl))\/2:\n if current == 1:\n kl += all \/ 2 + 1\n else: \n kl += 1\n current *= -1\n obx(lvl-1,ind-(2**lvl)\/2,kl,current)\n else: \n if current == -1:\n kl += all\/2+1\n else: \n kl += 1\n current *= -1\n obx(lvl-1,ind,kl,current)\n \nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b94d45e20d7370b56a4c","document_content":"def main():\n\th, n = (list(map(int, input().split())))\n\tc, m = 0, 2 ** h\n\tr = 0\n\twhile m > 1:\n\t\tif c == 0:\n\t\t\tif n > (m\/\/2):\n\t\t\t\tr += m - 1\n\t\t\t\tn -= m\/\/2\n\t\t\t\tc = 1 - c\n\t\telse:\n\t\t\tif n > m\/\/2:\n\t\t\t\tn -= m\/\/2\n\t\t\telse:\n\t\t\t\tr += m - 1\n\t\t\t\tc = 1 - c\n\t\tc = 1 - c\n\t\tr += 1\n\t\tm \/\/= 2\n\tprint(r)\n\n\n\n\n\t\n\ndef __starting_point():\n\tmain()\n\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cbb462caf50c17951926","document_content":"h, n = [int(_) for _ in input().split()]\nstart = 1\nend = 2 ** h\nlast = \"l\"\nans = 0\nfor i in range(h):\n mid = (start + end) \/\/ 2\n if n <= mid:\n end = mid\n if last == 'l':\n last = 'r'\n ans += 1\n else:\n ans += 2 ** (h - i)\n else:\n start = mid\n if last == 'r':\n last = 'l'\n ans += 1\n else:\n ans += 2 ** (h - i)\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"61a04a83a02c4328c36b","document_content":"h,n=input().split(' ')\nh=int(h)\nn=int(n)\ns='l'\nans=0\nfor i in range(h,0,-1):\n if n>pow(2,i-1):\n if s=='l':\n ans+=pow(2,i)\n else:\n ans+=1\n s='l'\n n-=pow(2,i-1)\n else:\n if s=='r':\n ans+=pow(2,i)\n else:\n ans+=1;\n s='r'\nprint (ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5be9a5b30ecbb9eb1a20","document_content":"def n_of_nodes(h):\n result = 0\n for i in range(h):\n result += 2 ** i\n return result\n\nh, n = tuple(map(int, input().split()))\n\nway = \"\"\nt = h\nwhile t:\n if n % 2:\n way = \"L\" + way\n n \/\/= 2\n n += 1\n else:\n way = \"R\" + way\n n \/\/= 2\n t -= 1\n\nanswer = 1\ncurrent = \"L\"\nt = h\nfor i in way:\n if i == current:\n answer += 1\n if current == \"L\":\n current = \"R\"\n else:\n current = \"L\"\n else:\n answer += n_of_nodes(t) + 1\n t -= 1\n\nprint(answer - 1)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c4bf484a83578ca9c344","document_content":"h, n = map(int, input().split())\nans = h\nn = n - 1 + (1 << h)\nfor i in range(1, h+1):\n if not ( ((n & (1 << i)) == 0) ^ (n & (1 << (i-1)) == 0 )):\n ans += (1 << i) - 1\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bb01501a60f2aad488c1","document_content":"def isPrime(n) : \n # Corner cases \n if (n <= 1) : \n return False\n if (n <= 3) : \n return True\n \n # This is checked so that we can skip \n # middle five numbers in below loop \n if (n % 2 == 0 or n % 3 == 0) : \n return False\n \n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n \n return True\nt=int(input())\nfor yes in range(t):\n\ta,b=map(int,input().split())\n\txx=a-b\n\tyy=a+b \n\tif xx==1 and isPrime(yy)==True:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6e3f32b024a191610416","document_content":"read = lambda: map(int, input().split())\ndef prime(x):\n d = 2\n while d*d<= x:\n if x % d == 0: return 0\n d += 1\n return 1\nt = int(input())\nres = \"\"\nfor i in range(t):\n a, b = read()\n res += \"YES\\n\" if a-b==1 and prime(a+b) else \"NO\\n\"\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"29f2943262791a21f5cf","document_content":"def isPrime(n):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n return False\n return True\n\n return True\nfor i in ' '*int(input()):\n a,b=map(int,input().split())\n if a-b>1:print('NO')\n else:\n print(['NO','YES'][isPrime(a+b)])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"689674db40f2f34b183a","document_content":"def check_prime(n):\n i = 2\n while i * i <= n:\n if n % i == 0:\n return False\n i += 1\n return True\n\nt = int(input())\nfor tnum in range(t):\n a, b = map(int, input().split())\n if a != b + 1:\n print(\"NO\")\n else:\n print(\"YES\" if check_prime(a + b) else \"NO\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fe4768e87c19aeee0e54","document_content":"from math import sqrt\nn = int(input())\nfor i in range(n):\n a, b = map(int, input().split())\n first = a - b\n second = a + b\n if first != 1:\n print('NO')\n else:\n f = False\n for i in range(2, int(sqrt(second)) + 1):\n if second % i == 0:\n f = True\n break\n if f:\n print('NO')\n else:\n print('YES')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5446d26271b33feb7b72","document_content":"def prime(n):\n if n < 2:\n return False\n elif n % 2 == 0:\n return False\n else:\n for k in range(3, 1 + int(n ** .5), 2):\n if n % k == 0:\n return False\n return True\n\n\nt = int(input())\nfor i in range(t):\n a, b = list(map(int, input().split()))\n n = (a + b)\n if a - b > 1:\n print('NO')\n else:\n if prime(n):\n print('YES')\n else:\n print('NO')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"42d150c22261c7da1993","document_content":"t = int(input())\nfor _ in range(t):\n a, b = list(map(int, input().split()))\n if a - b != 1:\n print(\"NO\")\n continue\n c = a + b\n for t in range(2, int(c ** 0.5) + 1):\n if c % t == 0:\n print(\"NO\")\n break\n else:\n print(\"YES\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5b070cece061b6c2fec8","document_content":"def check(a):\n for i in range(2, round(a**0.5 + 1)):\n if not a % i:\n return 0\n return 1\n\n\nfor i in range(int(input())):\n a, b = map(int, input().split())\n if (a - b) > 1 and (a + b) > 1:\n print('NO')\n else:\n print('YES' if check(a**2-b**2) else 'NO')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"07601aa6c20f4aa624fb","document_content":"from math import sqrt \nfrom itertools import count, islice\n\ndef isPrime(n):\n return n > 1 and all(n%i for i in islice(count(2), int(sqrt(n)-1)))\n\nt=int(input())\n\nfor i in range(t):\n\ta,b=map(int,input().split())\n\tans = False\n\tif a-b==1:\n\t\tx = a+b\n\t\tans=isPrime(x)\n\n\tif ans:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a2f1b27f806667bea6c2","document_content":"t=int(input())\nimport math\nfor i in range(t):\n a,b=list(map(int,input().split()))\n if((a-b)!=1):\n print(\"NO\")\n else:\n l=2*a-1\n p=0\n for k in range(2,int(math.sqrt(l))+1):\n if(l%k==0):\n print(\"NO\")\n p=1\n break \n if(p==0):\n print(\"YES\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dd0c9ec0a759a400f267","document_content":"def prime(x):\n if x==1:\n return False\n ret=True\n for i in range(2,int(x**0.5)+1):\n if x%i==0:\n ret=False\n return ret\n\nn=int(input())\nfor i in range(n):\n s=input().split()\n d=int(s[0])-int(s[1])\n if d!=1:\n print(\"NO\")\n else:\n if prime(int(s[0])+int(s[1])):\n print(\"YES\")\n else:\n print(\"NO\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"95b2674e062c57a65981","document_content":"t = int(input())\nwhile t > 0:\n a, b = list(map(int,input().split()))\n if a - b != 1 :\n print(\"NO\")\n else:\n num = a + b\n num2 = int(num ** 0.5)\n num3 = 2\n ans = 0\n while num3 <= num2:\n if num % num3 == 0:\n ans = 1\n num3 += 1\n if ans == 1:\n print(\"NO\")\n else:\n print(\"YES\")\n t -= 1\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2cd63a96e67f7f9a70c1","document_content":"import sys\n\ndef isprime(x):\n import math\n if x == 1:\n return True\n\n for i in range(2, math.ceil(math.sqrt(x))+1):\n if x % i == 0:\n return False\n return True\n\n\ndef __starting_point():\n cin = sys.stdin\n\n T = int(next(cin))\n for _ in range(T):\n n, m = list(map(int, next(cin).split()))\n\n # n**2-m**2 = (n-m)*(n+m)\n\n if n-m == 1 and isprime(n+m):\n print('YES')\n else:\n print('NO')\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a23e20a6b932627c4b96","document_content":"def isPrime(n) : \n # Corner cases \n if (n <= 1) : \n return False\n if (n <= 3) : \n return True\n \n # This is checked so that we can skip \n # middle five numbers in below loop \n if (n % 2 == 0 or n % 3 == 0) : \n return False\n \n i = 5\n while(i * i <= n) : \n if (n % i == 0 or n % (i + 2) == 0) : \n return False\n i = i + 6\n \n return True\nt=int(input())\nfor l in range(t):\n\ta,b=list(map(int,input().split()))\n\tif(a-b!=1):\n\t\tprint(\"NO\")\n\telse:\n\t\tif(isPrime(a+b)):\n\t\t\tprint('YES')\n\t\telse:\n\t\t\tprint('NO')\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"53c4154880ffcdf3ded2","document_content":"from math import sqrt; from itertools import count, islice\n\nn = int(input())\n\n\ndef isPrime(n):\n return n > 1 and all(n%i for i in islice(count(2), int(sqrt(n)-1)))\n\ndef eval_(a, b):\n if abs(a - b)!=1:\n return \"NO\"\n result = isPrime(a + b)\n if result:\n return \"YES\"\n else:\n return \"NO\"\n\n\nfor i in range(n):\n (a, b) = [int(x) for x in input().split()]\n print(eval_(a, b))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9276f72abd239a760ba8","document_content":"import math\n\nt = int(input())\n\n\ndef isprime(c):\n\t# print(int(math.ceil(math.sqrt(c)))+1)\n\tfor x in range(2, int(math.ceil(math.sqrt(c)))+1):\n\t\t# print(\"x: {}\".format(x))\n\t\tif c % x == 0:\n\t\t\treturn False\n\n\treturn True\n\nfor x in range(t):\n\ta, b = list(map(int, input().split()))\n\tif (1 == a-b) and isprime(a + b):\n\t\tprint (\"YES\")\n\telse:\n\t\tprint (\"NO\")\n\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"220305072799d92f3b63","document_content":"from math import sqrt, floor\n\n\ndef check(n):\n for i in range(2, floor(sqrt(n)) + 1):\n if (n % i == 0):\n return False\n\n return True\n\n\nt = int(input())\n\nfor i in range(t):\n a, b = list(map(int, input().split()))\n\n if (a - b == 1 and check(a + b)):\n print(\"YES\")\n else:\n print(\"NO\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d627d3a134a623e5b4cd","document_content":"t = int(input())\n\ndef divider(n):\n i = 2\n j = 0\n while i**2 <= n and j != 1:\n if n%i == 0:\n j = 1\n i += 1\n if j == 1:\n return False\n else:\n return True\n\n\nfor i in range(t):\n a, b = list(map(int,input().split()))\n if a-b == 1 and divider(a+b):\n print(\"YES\")\n else:\n print(\"NO\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"71cd37e7c9174d5e75ee","document_content":"def isprime(n):\n i = 2\n m = n\n while (i * i <= n):\n while (n % i == 0):\n n \/= i\n i += 1\n return m == n\n\n\nt = int(input())\nfor i in range(t):\n a, b = map(int, input().split())\n if (isprime(a + b) and a - b == 1):\n print(\"YES\")\n else:\n print(\"NO\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a006fc5a8fe450dc7382","document_content":"t=int(input())\na=[]\nb=[]\nfor i in range(t):\n aa,bb=[int(el) for el in input().split()]\n a.append(aa)\n b.append(bb)\n\ndef prost(n):\n if n==3:\n return True\n if n%2==0:\n return False\n for i in range (3,int(n**0.5)+1,2):\n if n%i==0:\n return False\n return True\n return\n\nfor i in range(t):\n if a[i]-b[i]!=1:\n print ('NO')\n continue\n if prost(a[i]+b[i]):\n print('YES')\n else:\n print('NO')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c6d6262057b271cd97ca","document_content":"import random\ndef MillerRabinPrimalityTest(number):\n '''\n because the algorithm input is ODD number than if we get\n even and it is the number 2 we return TRUE ( spcial case )\n if we get the number 1 we return false and any other even \n number we will return false.\n '''\n if number == 2:\n return True\n elif number == 1 or number % 2 == 0:\n return False\n \n ''' first we want to express n as : 2^s * r ( were r is odd ) '''\n \n ''' the odd part of the number '''\n oddPartOfNumber = number - 1\n \n ''' The number of time that the number is divided by two '''\n timesTwoDividNumber = 0\n \n ''' while r is even divid by 2 to find the odd part '''\n while oddPartOfNumber % 2 == 0:\n oddPartOfNumber = oddPartOfNumber \/\/ 2\n timesTwoDividNumber = timesTwoDividNumber + 1 \n \n '''\n since there are number that are cases of \"strong liar\" we \n need to check more then one number\n '''\n for time in range(3):\n \n ''' choose \"Good\" random number '''\n while True:\n ''' Draw a RANDOM number in range of number ( Z_number ) '''\n randomNumber = random.randint(2, number)-1\n if randomNumber != 0 and randomNumber != 1:\n break\n \n ''' randomNumberWithPower = randomNumber^oddPartOfNumber mod number '''\n randomNumberWithPower = pow(randomNumber, oddPartOfNumber, number)\n \n ''' if random number is not 1 and not -1 ( in mod n ) '''\n if (randomNumberWithPower != 1) and (randomNumberWithPower != number - 1):\n # number of iteration\n iterationNumber = 1\n \n ''' while we can squre the number and the squered number is not -1 mod number'''\n while (iterationNumber <= timesTwoDividNumber - 1) and (randomNumberWithPower != number - 1):\n ''' squre the number '''\n randomNumberWithPower = pow(randomNumberWithPower, 2, number)\n \n # inc the number of iteration\n iterationNumber = iterationNumber + 1\n ''' \n if x != -1 mod number then it because we did not found strong witnesses\n hence 1 have more then two roots in mod n ==>\n n is composite ==> return false for primality\n '''\n if (randomNumberWithPower != (number - 1)):\n return False\n \n ''' well the number pass the tests ==> it is probably prime ==> return true for primality '''\n return True\ncases=int(input())\nfor case in range(cases):\n a,b=map(int,input().split())\n t=MillerRabinPrimalityTest((a**2)-(b**2))\n if t:\n print(\"YES\")\n else:\n print(\"NO\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"324ddc5b1e9593e3f41c","document_content":"def divider(n):\n i = 2\n j = 0\n while i**2 <= n and j != 1:\n if n % i == 0:\n j = 1\n i += 1\n if j == 1:\n return False\n else:\n return True\n\n\ni = int(input())\nfor i in range(i):\n a, b = list(map(int, input().split()))\n if a - b == 1 and divider(a+b):\n print(\"YES\")\n else:\n print(\"NO\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"490f68c471c840a363f4","document_content":"import math\n\ndef is_prime(n):\n bound = int(math.sqrt(n + 1) + 1)\n for k in range(2, bound):\n if n % k == 0:\n return False\n return True\n\n\ndef solve():\n a, b = (int(x) for x in input().split())\n if a - b != 1:\n print('NO')\n return\n\n if is_prime(a+b):\n print('YES')\n else:\n print('NO')\n\n\nnum_tests = int(input())\nfor _ in range(num_tests):\n solve()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bf4b05a4ed423e6dac1f","document_content":"\nimport math as m\ndef f(a):\n\tif (a==2) : return True\n\tfor i in range(2,round(m.sqrt(a))+1):\n\t\tif a%i==0:\n\t\t\treturn False\n\treturn True\n\nt=int(input())\n\n\nfor i in range(t):\n\ta,b=input().split()\n\n\ta=int(a)\n\tb=int(b)\n\n\tif (a-b)==1 and f(a+b) :\n\t\tprint(\"YES\")\n\telse :\n\t\tprint(\"NO\")\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"434e93c90bc02a0a8a8e","document_content":"# \nimport collections, atexit, math, sys, bisect \n\nsys.setrecursionlimit(1000000)\ndef getIntList():\n return list(map(int, input().split())) \n\ntry :\n #raise ModuleNotFoundError\n import numpy\n def dprint(*args, **kwargs):\n print(*args, **kwargs, file=sys.stderr)\n dprint('debug mode')\nexcept ModuleNotFoundError:\n def dprint(*args, **kwargs):\n pass\n\n\n\ninId = 0\noutId = 0\nif inId>0:\n dprint('use input', inId)\n sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u81f3\u6587\u4ef6\nif outId>0:\n dprint('use output', outId)\n sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u81f3\u6587\u4ef6\n atexit.register(lambda :sys.stdout.close()) #idle \u4e2d\u4e0d\u4f1a\u6267\u884c atexit\n \nN, M, Q = getIntList()\n\ns1 = input()\ns2 = input()\n\ntot = 0\nzt = [0]\n\nfor i in range(N):\n if s1[i:i+M] == s2:\n tot+=1\n zt.append(tot)\ndprint(zt)\nfor i in range(Q):\n a,b = getIntList()\n b0 = b- M+1\n if b0= r[j]:\n ans+=1\n print(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ca28d7e46b8a71261daa","document_content":"import re, bisect\n\nn, m, q = [int(v) for v in input().split()]\ns = input().strip()\nt = input().strip()\n\nstarts = [m.start() for m in re.finditer('(?=%s)' % t, s)]\n\nfor _ in range(q):\n l, r = [int(v) for v in input().split()]\n if r - l + 1 < len(t):\n print(0)\n else:\n print(bisect.bisect_right(starts, r - len(t)) - bisect.bisect_left(starts, l - 1))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6ad5b69a72a591ffbeab","document_content":"n, m, q = [int(i) for i in input().split()]\ns = list(input())\nt = list(input())\nlt = len(t)\nls = len(s)\nstart = []\nfor i in range(ls - lt +1):\n j = i\n count = 0\n while s[j] == t[count]:\n j += 1\n count += 1\n if count >= lt:\n break\n if count == lt:\n start.append(i + 1)\n\nstart += [n + 1]\nfor i in range(q):\n l, r = [int(j) for j in input().split()]\n r -= lt - 1\n if l > r:\n print(0)\n continue\n f = False\n for j in range(len(start)):\n if (f == False) and (start[j] >= l):\n f = True\n begin = j\n if (f) and (start[j] > r):\n end = j\n break\n print(end - begin)\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ea6dc54d5fd92c45cacc","document_content":"import sys\nimport io\n\nstream_enable = 0\n\ninpstream = \"\"\"\n15 2 3\nabacabadabacaba\nba\n1 15\n3 4\n2 14\n\"\"\"\n\nif stream_enable:\n sys.stdin = io.StringIO(inpstream)\n input()\n\ndef inpmap():\n return list(map(int, input().split()))\n\nn, m, q = inpmap()\na = input()\nb = input()\ns = [0] * n\ns[0] = int(a.startswith(b))\nfor i in range(1, n):\n s[i] = s[i - 1] + int(a[i:i+m] == b)\nfor i in range(q):\n x, y = inpmap()\n r = (s[y - m] if y - m >= 0 else 0) - (s[x - 2] if x - 2 >= 0 else 0)\n print(max(r, 0))\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a4d59027dca8bb0d592a","document_content":"n,m,q=list(map(int,input().split()))\ns=str(input())\nt=str(input())\narrx=[]\ni=0\ncount=0\nwhile(i l:\n print(bools[l] - bools[r])\n else:\n print(0)\n #suma = 0\n# for j in range(l, r+1):\n# if bools[j]:\n# suma += 1\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8637197ad4d67e36beb3","document_content":"n, m, q = list(map(int, input().split()))\ns = list(input())\nt = list(input())\na = [list(map(int, input().split())) for i in range(q)]\n\nif n < m:\n for i in range(q):\n print(0)\n return\n\nres = [0] * (n - m + 1)\nfor i in range(n - m + 1):\n if s[i:(i + m)] == t:\n res[i] = 1\n\nfor u in range(q):\n l = a[u][0]\n r = a[u][1]\n\n ans = 0\n for y in range(l - 1, r - m + 1):\n # print(y)\n if res[y] == 1:\n ans += 1\n\n print(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"427cb9918de22dade9a6","document_content":"n, m, q = map(int, input().split())\ns = input()\nt = input()\narr = []\nfor i in range(n - m + 1):\n if s[i:i + m] == t:\n arr.append(i)\nfor i in range(q):\n l, r = map(int, input().split())\n k = 0\n for j in range(len(arr)):\n if arr[j] >= l - 1 and arr[j] + m - 1<= r - 1:\n k = k + 1\n print(k)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6b65332f4ec3533efe52","document_content":"n, m, q = list(map(int, input().split()))\ns = input()\nt = input()\narr = [0] * n\nfor i in range(n - m + 1):\n if t == s[i:i+m]:\n arr[i] = 1\n if i: arr[i] += arr[i - 1]\nfor i in range(q):\n l, r = list(map(int, input().split()))\n l -= 1\n r -= 1\n L = l - 1\n R = r - m + 1\n if R < L: \n print(0)\n continue\n if L >= 0: \n print(arr[R] - arr[L])\n else:\n print(arr[R])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f82fc1ec6156e13a148f","document_content":"#list_int \u4e26\u3079\u3066\u51fa\u529b print (' '.join(map(str,ans_li)))\n#list_str \u4e26\u3079\u3066\u51fa\u529b print (' '.join(list))\n\n# 2\u9032\u6570 format(10, 'b') # '1010'\n\n''' \u4e8c\u6b21\u5143\u914d\u5217\u3092\u4e00\u5217\u305a\u3064\nfor i in ans:\n\tprint(*i)\n'''\n''' heapq\nqueue = []\nheapq.heapify(queue) #heapq\u306e\u4f5c\u6210\nheapq.heappush(queue,num) #num\u306epush(\u5024\u306e\u8ffd\u52a0)\npop = heapq.heappop(queue) #num\u306epop(\u6700\u5c0f\u5024\u306e\u51fa\u529b)\npop = heapq.heappushpop(queue,num) #push -> pop\n\n'''\n\nfrom collections import defaultdict\nimport sys,heapq,bisect,math,itertools,string,queue,datetime\nsys.setrecursionlimit(10**8)\nINF = float('inf')\nmod = 10**9+7\neps = 10**-7\nAtoZ = [chr(i) for i in range(65,65+26)]\natoz = [chr(i) for i in range(97,97+26)]\n\ndef inpl(): return list(map(int, input().split()))\ndef inpl_str(): return list(input().split())\n\nN,M,q = inpl()\nS = input()\nT = input()\nazu = [0]*(N-M+1)\nqq = []\n\nfor i in range(q):\n\tqq.append(inpl())\n\nif M > N:\n\tfor i in range(q):\n\t\tprint(0)\n\treturn\n\nfor i in range(0,N-M+1):\n\tif S[i:i+M] == T:\n\t\tazu[i] = 1\n\nSUM = 0\nnyan = [0]\nfor az in azu:\n\tSUM += az\n\tnyan.append(SUM)\n\n\nfor l,r in qq:\n\tl -= 1\n\tif r - l < M:\n\t\tprint(0)\n\telse:\n\t\tprint(nyan[r-M+1] - nyan[l])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a335521b6a7d70edd9ac","document_content":"import sys\n\n\ndef main():\n n, m, q = list(map(int, input().strip().split()))\n s = input()\n t = input()\n\n pos = []\n for i in range(len(s)):\n\n if i + len(t) <= len(s) and s[i:i+len(t)] == t:\n pos.append(1)\n else:\n pos.append(0)\n\n sum = [0]\n for i in range(len(pos)):\n sum.append(sum[-1] + pos[i])\n\n for _ in range(q):\n l, r = list(map(int, input().strip().split()))\n r = r - len(t) + 1\n l -= 1\n\n if l < r:\n print(sum[r] - sum[l])\n else:\n print(0)\n\n return 0\n\n\ndef test(i):\n with open(\"test_{}.txt\".format(i)) as fin:\n sys.stdin = fin\n main()\n\n\ndef __starting_point():\n # test(1)\n # test(2)\n return(main())\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5e0f901b39780006761a","document_content":"n,m, q = list(map(int, input().split()))\ns = str(input())\nt = str(input())\n\ndef is_in(index):\n if index + m > n:\n return False\n \n for j in range(m):\n if not t[j] == s[index + j]:\n return False\n return True\n \nprecalc_ar_2 = [0 for i in range(n +1)]\nin_was = [ False for i in range(n)]\n\nfor i in range(n):\n if is_in(i):\n in_was[i] = True\n\n\nval = 0\nfor i in range(1, n + 1):\n if in_was[i - 1]:\n val +=1\n precalc_ar_2[i] = val \n\n\nfor i in range(q):\n l, r = list(map(int,input().split()))\n if r- m + 1 < 0 or r- m + 1 < l - 1:\n print(0)\n else:\n print(precalc_ar_2[r - m +1] - precalc_ar_2[l - 1])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4b5374d9d3c843711013","document_content":"3\n\ndef calc(l, r, layers, li):\n if r - l == 1:\n return layers[li][l]\n\n xl = l\n if l % 2 == 1:\n xl -= 1\n xr = r\n if r % 2 == 1:\n xr += 1\n\n ans = calc(xl \/\/ 2, xr \/\/ 2, layers, li + 1)\n if xl != l:\n ans -= layers[li][xl]\n if xr != r:\n ans -= layers[li][xr - 1]\n return ans\n\n\ndef solve(N, M, Q, S, T, A):\n base = [0] * N\n i = 0\n while True:\n try:\n i = S.index(T, i)\n base[i] = 1\n i += 1\n except ValueError:\n break\n\n layers = [base]\n while len(layers[-1]) > 1:\n prev = layers[-1]\n if len(prev) % 2 == 1:\n prev.append(0)\n\n layer = []\n for i in range(len(prev) \/\/ 2):\n layer.append(prev[2 * i] + prev[2 * i + 1])\n\n layers.append(layer)\n\n ans = []\n for (l, r) in A:\n l -= 1\n\n r -= M - 1\n if r <= l:\n ans.append(0)\n continue\n\n ans.append(calc(l, r, layers, 0))\n\n return ans\n\n\ndef main():\n N, M, Q = [int(e) for e in input().split(' ')]\n S = input()\n T = input()\n A = [map(int, input().split(' ')) for _ in range(Q)]\n\n assert len(S) == N\n assert len(T) == M\n\n print(*solve(N, M, Q, S, T, A), sep='\\n')\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"96c19fd4fb7b12c9b344","document_content":"import sys\n\nn,m,q=list(map(int,input().split()))\ns=input()\nt=input()\nA=[None]*q\nfor i in range(q):\n A[i]=list(map(int,input().split()))\n\nif m>n:\n for i in range(q):\n print(0)\n\n return\n\nscore=[0 for i in range(n-m+1)]\nfor i in range(n-m+1):\n if t==s[i:i+m]:\n score[i]=1\n\nSUM=[0 for i in range(n-m+1)]\nSUM[0]=score[0]\nfor i in range(1,n-m+1):\n SUM[i]=score[i]+SUM[i-1]\n\n\nSUM=[0]+SUM\nfor i in range(q):\n if A[i][1]-m+1<=A[i][0]-1:\n print(0)\n else:\n print(SUM[A[i][1]-m+1]-SUM[A[i][0]-1])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ebc82bae4e6323dbfd0e","document_content":"# from math import ceil\n#from sys import stdout\n\nt = 1#int(input())\nfor test in range(1,t+1):\n n,m,q = list(map(int, input().split()))\n s = input()\n t = input()\n indices = [0 for i in range(n)]\n for i in range(n):\n tmp = s.find(t, i)\n if tmp==-1:\n break\n else:\n indices[tmp] = 1\n pref = [0]\n for i in indices:\n pref.append(i+pref[-1])\n for i in range(q):\n l,r = list(map(int, input().split()))\n if r-l+1= m - 1:\n print(max(c[r] - c[l + m - 2], 0))\n else:\n print(0)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f75a00d1d522e9582319","document_content":"def coun(s, t):\n d = 0\n for i in range(len(s) - len(t) + 1):\n if s[i:i + len(t)] == t:\n d += 1\n return(d)\n\nn, m, q = list(map(int, input().split()))\ns = input()\nt = input()\nx = [0]\n\nfor j in range(n):\n x.append(coun(s[:j + 1], t))\nfor i in range(q):\n l, r = list(map(int, input().split()))\n r += 1\n if m <= r - l:\n print(x[r - 1] - x[max(0, l + m - 2)])\n else:\n print(0)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"59f25e667b4567f5f78b","document_content":"# n=int(input())\n# ns=[int(x) for x in input().split()]\n# dp=[None]*n\n# def greater(i,num):\n# return ns[i]+ns[i+1]>=num\n# def biSearch(t,l,r):\n# if r-l<=1:\n# return l\n# m=(l+r)\/\/2\n# if greater(m,t)\n#\n#\n# def update(t):\n# l=ns[t]\nn,m,q=[int(x)for x in input().split()]\nsn=input()\nsm=input()\n\n\ndef eq(i):\n for j in range(m):\n if sn[i+j]!=sm[j]:\n return False\n return True\nre=[0]*n\nfor i in range(n-m+1):\n if eq(i):\n re[i]=1\nfor i in range(1,n):\n re[i]+=re[i-1]\n\nfor i in range(q):\n l,r=[int(x)-1 for x in input().split()]\n if r-l+1 0:\n pref[i] = pref[i-1] + A[i]\n else:\n pref[i] = A[i]\nfor i in range(Q):\n l,r = [int(x) for x in input().split()]\n l -= 1\n r -= 1\n if r-l+1 >= M:\n if r-M+1 >= 0:\n if l-1>=0:\n print(pref[r-M+1]-pref[l-1])\n else:\n print(pref[r-M+1])\n else:\n print(0)\n else:\n print(0)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"aa0bab641f5cfa7143ae","document_content":"n,m,q=list(map(int,input().split()))\ns=input()\nt=input()\ntt=[0]*1111\nfor i in range(n-m+1):\n j=0\n while j=m: tt[i+1]=1\nfor i in range(1,n+1): tt[i]+=tt[i-1]\nfor i in range(q):\n a,b=list(map(int,input().split()))\n if b-a+1=m:\n\tfor i in range(n-m+1):\n\t\tif (s[i:i+m]==t):\n\t\t\tpre1[i+m-1] = 1\n\t\t\tpre2[i] = 1\n\tfor i in range(1,n):\n\t\tpre1[i]+=pre1[i-1]\n\t\tpre2[i]+=pre2[i-1]\npre1.insert(0,0)\npre2.insert(0,0)\n\n\nwhile q:\n\tq-=1\n\tl,r = mi()\n\ts1, s2 = 0,0\n\t#for i in range(l, r+1):\n\t\t#s1+=pre1[i]\n\t\t#s2+=pre2[i]\n\tif m>n:\n\t\tprint(0)\n\t\tcontinue\n\tif r0 and s2>0:\n\t\tprint(min(s1,s2))\n\telse:\n\t\tprint(0)\n\t\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9be8f8b39c6eafbe8ca9","document_content":"arr = [0] * (10 ** 6 + 1)\nn = int(input())\nfor i in input().split():\n arr[int(i)] += 1\ni = 10 ** 6\nj = i\nk = i\nc = 0\nwhile j > 0:\n if arr[j] % 2 == 1 and (arr[j] > 1 or c == 0):\n arr[j - 1] += 1\n c = 1\n else:\n c = 0\n j -= 1\nr = 0\nwhile i > 0 and k > 0:\n if arr[i] < 2:\n if i == k:\n k -= 1\n i -= 1\n elif i == k and arr[i] < 4:\n k -= 1\n elif arr[k] < 2:\n k -= 1\n else:\n r += i * k\n arr[i] -= 2\n arr[k] -= 2\nprint(r)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7c75686cd1c622943fb7","document_content":"n = int(input())\nl = list(map(int, input().split()))\nl.sort(key=lambda x: -x)\ni = 0\ncur = 0\nans = 0\nwhile i < len(l)-1:\n if l[i] == l[i+1] or l[i]-1 == l[i+1]:\n if cur == 0:\n cur = l[i+1]\n else:\n ans += cur*l[i+1]\n cur = 0\n i += 2\n else:\n i += 1\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7d7e2b76d1e2fb2b5725","document_content":"def __starting_point():\n input()\n data = sorted(map(int, input().split()), key=lambda x: -x)\n\n if len(data) < 4:\n print(0)\n return\n\n total = 0\n i = 0\n\n while i < len(data) - 3:\n if abs(data[i] - data[i + 1]) > 1:\n i += 1\n continue\n\n success = False\n for j in range(i + 2, len(data) - 1):\n if abs(data[j] - data[j + 1]) > 1:\n continue\n\n success = True\n total += min(data[i], data[i + 1]) * min(data[j], data[j + 1])\n i = j + 2\n break\n\n if not success:\n i += 1\n\n print(total)\n\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"68f9f63f30a4aa226913","document_content":"n = int(input())\ns = map(int, input().split())\ns = list(reversed(sorted(s)))\ni = 1\nk =[]\nwhile i < n:\n if s[i-1] - s[i] == 1:\n k.append(s[i])\n i += 1\n elif s[i-1] == s[i]:\n k.append(s[i])\n i += 1\n i +=1\nans = 0\nfor i in range(1, len(k), 2):\n ans += k[i]*k[i-1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"612b4487e4be464537b4","document_content":"n = int(input())\nl = [int(x) for x in input().split()]\n\nl.sort()\n\nl2 = [0] * n\nprev = l[0]\ncount = 1\nk = 0\n\nfor i in range(1, n):\n if l[i] != prev:\n l2[k] = [prev, count]\n k += 1\n prev = l[i]\n count = 1\n else:\n count += 1\n\nl2[k] = [prev, count]\nk += 1\nfor i in range(k-1, 0, -1):\n if l2[i][1] % 2 == 1 and l2[i-1][0] == (l2[i][0] - 1):\n l2[i-1][1] += 1\n l2[i][1] \/\/= 2\nl2[0][1] \/\/= 2\ni = k-1\nj = k-1\nres = 0\nwhile i >= 0 and j >= 0:\n if i == j:\n res += l2[i][0] * l2[i][0] * (l2[i][1] \/\/ 2)\n l2[i][1] %= 2\n if l2[i][1] == 0:\n i -= 1\n j -= 1\n else:\n i -= 1\n\n else:\n if l2[i][1] == 0:\n i -= 1\n continue\n res += l2[i][0] * l2[j][0]\n l2[i][1] -= 1\n j = i\n\nprint(res)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a85e139a242430dca6c5","document_content":"n = int(input())\nl = [int(i) for i in input().split()]\nl.sort(reverse=True)\na = []\ni = 0\nwhile i < len(l) - 1:\n #print(l[i], l[i + 1])\n if l[i] == l[i + 1]:\n a.append(l[i])\n i += 2\n else:\n if l[i] == l[i + 1] + 1:\n a.append((l[i] - 1))\n i += 2\n else:\n i += 1\n\n#print(a)\nif len(a) % 2 != 0:\n a.append(0)\n\ns, i = 0, 0\nwhile i < len(a):\n s += a[i] * a[i + 1]\n i += 2\nprint(s)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"886b103a19b667f031e2","document_content":"n=int(input())\nL=[int(x) for x in input().split()]\nL.sort(reverse=True)\ni=0\nwhile i=3:\n if st[i]>st[i-1]+1:\n i = i -1\n continue\n l = st[i-1]\n i = i -2\n while i>0 and st[i]>st[i-1]+1:\n i=i-1\n if i == 0:\n break\n b = st [i-1]\n ans = ans + l*b\n i = i - 2\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"35ea4340abe8d879a1e7","document_content":"n = int(input())\nl = []\ninline = input().split()\nfor i in range (n):\n l.append(int(inline[i]))\nl.sort()\nright_equal = 1\nans = 0\nif len(l) >= 4:\n for i in range(len(l) - 2, -1, -1):\n if l[i] != l[i + 1]:\n if right_equal % 2 != 0:\n if l[i + 1] - l[i] == 1:\n l[i + 1] -= 1\n right_equal = 2\n else:\n l.pop(i + 1)\n else:\n right_equal = 1\n else:\n right_equal += 1\nif len(l) >= 4:\n if l[0] != l[1]:\n l.pop(0)\n flag = 1\n for i in range(len(l) - 2, -1, -2):\n if flag == 1:\n c = l[i]\n else:\n ans += c * l[i]\n c = 0\n flag = 1 - flag\nprint (ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d644f4208af44514d71a","document_content":"n = int(input())\n\nlst = []\nlst.extend(list(map(int, input().split())))\n\ntarea = 0\n\nlst.sort()\nlst = lst[::-1]\nlst.append(0)\n\ni = 0\nmark = 0\nar = []\nwhile i != n:\n if (lst[i] - lst[i+1])<=1:\n ar.append(lst[i+1])\n mark += 1\n i += 2\n else:\n i += 1\n if mark == 2:\n tarea = tarea + ar[0]*ar[1]\n ar = []\n mark = 0\n\nprint(tarea)\n \n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6fb2d76c331703b63963","document_content":"sux = 0\ntwo = 0\nx=int(input())\ns=list(map(int, input().split(' ')))\n\nt = [0] * (1000001)\nfor i in s:\n t[i] += 1\nfor i in range(len(t)-1, 0, -1):\n if t[i]%2==1 and t[i-1]>0:\n t[i] -= 1\n t[i-1] += 1\n elif t[i]%2==1 and t[i]>0:\n t[i] -= 1\nfor i in range(len(t)-1, 0, -1):\n if two != 0 and t[i] != 0:\n sux += i*two\n two = 0\n t[i] -= 2\n if t[i] % 4 == 0:\n sux += (t[i]\/\/4)*i*i\n else:\n sux += (t[i]\/\/4)*i*i\n if two != 0:\n sux += i*two\n two = 0\n \n else:\n two = i\n \n \nprint(sux)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b828ad978498c601b095","document_content":"n = int(input())\nl = list(map(int, input().split()))\nm = {}\nm2 = set()\nfor i in range(1, 10**6 + 1):\n m[i] = 0\nfor i in range(n):\n m[l[i]] += 1\n m2.add(l[i])\n if l[i] >= 2:\n m2.add(l[i] - 1)\nm1 = []\n\nfor i in range(10**6, 1, -1):\n if m[i] % 2 == 1 and m[i - 1] > 0:\n m[i] -= 1\n m[i - 1] += 1\n elif m[i] % 2 == 1:\n m[i] -= 1\nfor i in m2:\n if m[i] != 0:\n m1.append(i)\nm1.sort(reverse = True)\n\ncnt = 0\nfor i in range(len(m1)):\n cnt += (m[m1[i]]\/\/4)*(m1[i]**2)\n if m[m1[i]] % 4 == 2 and i != len(m1) - 1:\n m[m1[i + 1]] -= 2\n cnt += m1[i + 1]*m1[i]\nprint(cnt)\n \n \n \n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"22afe558b013048aa245","document_content":"#!\/c\/Python34\/python\n# coding: utf-8 ans\n\n\ndef main():\n n = int(input())\n L = sorted(map(int, input().split()))\n L.reverse()\n K = []\n i = 1\n while(i < n):\n if L[i-1] == L[i]:\n K.append(L[i])\n i += 1\n elif L[i-1]-L[i] == 1:\n K.append(L[i])\n i += 1\n i += 1\n ans = 0\n for i in range(1, len(K), 2):\n ans += K[i-1] * K[i]\n print(ans)\n #print(K)\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2a8683956249f25cf146","document_content":"_ = int(input())\nas_ = list(sorted(map(int, input().split())))\n\ndef get_pair():\n while len(as_) >= 2:\n s0 = as_.pop()\n s1 = as_.pop()\n if s0-1 == s1 or s0 == s1:\n return s1\n as_.append(s1)\n return None\n\nans = 0\ntb = get_pair()\nlr = get_pair()\nwhile not (tb is None or lr is None):\n ans += tb * lr\n tb = get_pair()\n lr = get_pair()\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"831b9fa0f7ac77fbffb3","document_content":"def main():\n n = int(input())\n l = [int(i) for i in input().split()]\n l.sort()\n l.reverse()\n candidate = []\n i = 1\n while (i < n):\n if (l[i - 1] - l[i] <= 1):\n candidate.append(min(l[i - 1], l[i]))\n i += 2\n else:\n i += 1\n\n area = 0\n for i in range(1, len(candidate), 2):\n area += candidate[i] * candidate[i - 1]\n return area\n\n\ndef __starting_point():\n print(main())\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c203f30d15ef6805b1f1","document_content":"n = int(input())\nls = list(map(int, input().split()))\nls.sort(reverse=True)\n\narea = 0\npairs = []\ni = 0\nwhile i < len(ls)-1:\n if (ls[i] - ls[i+1]) > 1:\n i += 1\n else:\n pairs.append(ls[i+1])\n i += 2\n if len(pairs) == 2:\n area += pairs.pop() * pairs.pop()\nprint(area)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6650ef360cf0b31b51ca","document_content":"n = int(input())\nmaxn = 10**6 + 2\ncnt = [0] * maxn\nfor x in map(int, input().split()):\n cnt[x] += 1\nansv = []\nfor i in range(maxn - 2, 1, -1):\n ansv += [i] * ((cnt[i] + (cnt[i+1] & 1)) >> 1)\n if cnt[i] > 0:\n cnt[i] += cnt[i+1] & 1\nans = 0\nfor i in range(1, len(ansv), 2):\n ans += ansv[i] * ansv[i-1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3876c347212d887773f4","document_content":"s = input()\nlst = [int(i) for i in input().split()]\nlst.sort()\nlst = lst[::-1]\nn = 0\nk = 0\nwhile len(lst) >= 2:\n if lst[0] == lst[1] or lst[0] == lst[1]+1:\n if k != 0:\n n += k*lst[1]\n lst.pop(0)\n lst.pop(0)\n k = 0\n else:\n k = lst[1]\n lst.pop(0)\n lst.pop(0)\n\n else:\n lst.pop(0)\nprint(n)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e11be7cdcf987517cf0f","document_content":"n, v, ps, pp = int(input()), 0, 0, 0\nfor l in sorted(map(int, input().split()), reverse=True):\n if ps == 0 or ps > l + 1:\n ps = l\n elif pp == 0:\n pp, ps = l, 0\n else:\n v, pp, ps = v + pp * l, 0, 0\nprint(v)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e414285a808cb5083ce3","document_content":"n = int(input())\nsticks = list(map(int, input().split()))\n\nlength = [0] * 1000000\nmiv = 1000000\nmav = 0\nansw = 0\nfor i in range(len(sticks)):\n\tlength[sticks[i]-1] = length[sticks[i]-1] + 1\n\tif sticks[i]-1 > mav:\n\t\tmav = sticks[i] - 1\n\tif sticks[i] -1 < miv:\n\t\tmiv = sticks[i] -1\n\nlength = length[miv:mav+1]\nfor i in range(len(length)-1, -1, -1):\n\tif length[i] % 2 == 1:\n\t\tif i > 0 and length[i-1] > 0:\n\t\t\tlength[i] = length[i] - 1\n\t\t\tlength[i-1] = length[i-1] + 1\n\t\telse:\n\t\t\tlength[i] = length[i] - 1\n\nsquare = []\nfor i in range(len(length)-1, -1, -1):\n\n\twhile length[i] > 0:\n\t\tsquare.append(i + miv + 1)\n\t\tlength[i] = length[i] - 2\n\t\tif len(square) == 2:\n\t\t\tansw += square[0] * square[1]\n\t\t\tsquare = []\nprint(answ)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9867ea1105467ff9c7b5","document_content":"I = lambda : map(int,input().split())\nn = int(input())\np = list(I())\ncnt = [0] * 1000001\nfor i in p: cnt[i] += 1\nfor i in range(1000000,1,-1):\n if cnt[i] % 2 == 1 and cnt[i - 1] > 0:\n cnt[i] -= 1\n cnt[i - 1] += 1\n elif cnt[i] % 2 == 1 and cnt[i - 1] == 0:\n cnt[i] -= 1\np = 0\nans = 0\nfor i in range(1000000,1,-1):\n if cnt[i] != 0:\n if p != 0:\n cnt[i] -= 2\n ans += p * i\n p = 0\n ans += i * i * (cnt[i] \/\/ 4)\n if cnt[i] % 4 != 0:\n p = i\nprint (ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"96021d22cc170f021609","document_content":"from collections import Counter\n\ninput()\nlengths = [int(i) for i in input().split()]\ncnt = Counter(lengths)\nlengths.sort(reverse=True)\ntotal_square = 0\n\nfor le in lengths:\n if cnt[le] % 2 != 0:\n if cnt[le-1] > 0:\n cnt[le-1] += 1\n cnt[le] -= 1\n\nfor le in lengths:\n if cnt[le] >= 4:\n cnt[le] -= 4\n total_square += le ** 2\n elif cnt[le] < 4 and cnt[le] > 0:\n min_le = le - 1\n while min_le > 0 and cnt[min_le] < 2:\n min_le -= 1\n cnt[le] -= 2\n cnt[min_le] -= 2\n total_square += le * min_le\n\nprint(total_square)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9326992707574a7b45f5","document_content":"import sys\ndef otb(l):\n i = 0\n while i < n - 1:\n if l[i] - 1 == l[i + 1]:\n l[i] -= 1\n i += 1\n elif l[i] == l[i + 1]:\n i += 1\n i += 1\n znach = []\n i = 0\n while i < n - 1:\n if l[i] == l[i + 1]:\n znach.append(l[i])\n i += 1\n i += 1\n return znach\ndef ploshad(n,znach):\n summa = 0\n n = len(znach)\n for i in range(0, n - 1, 2):\n summa += znach[i] * znach[i + 1]\n sys.stdout.write(str(summa))\n\nn = int(sys.stdin.readline())\nl = []\nl = [int(j) for j in sys.stdin.readline().split()]\nl.sort(reverse=True)\nznach=otb(l)\nploshad(n,znach)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"24f99ffb98e0dfa986c7","document_content":"n = int(input())\na, b = 0, 0\nans = 0\nfor i in sorted(map(int,input().split()),reverse=True):\n if a == 0 or a > i + 1:\n a = i\n elif b == 0:\n a, b= 0, i\n else:\n ans += i * b\n a, b = 0, 0\nprint(ans)\n\n\n\n \n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"88f370901f025fa2203d","document_content":"def max(a, b):\n\tif a > b:\n\t\treturn a\n\telse:\n\t\treturn b\nn, k = map(int, input().split())\nx = [int(t) for t in input().split()]\ny = [int(t) for t in input().split()]\nf, s = 0, 0\nfor i in range(n):\n f = max(0, x[i] + f - k * y[i])\n s = max(0, y[i] + s - k * x[i])\n if f > k or s > k:\n print('NO')\n return\nprint('YES')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d39fe1e87ed62ff8cfec","document_content":"def max(a, b):\n\tif a > b:\n\t\treturn a\n\treturn b\nn, k = map(int, input().split())\no = [int(t) for t in (input()+' '+input()).split()]\nf, s = 0, 0\nfor i in range(n):\n f = max(0, o[i] + f - k * o[i+n])\n s = max(0, o[i+n] + s - k * o[i])\n if f > k or s > k:\n print('NO')\n return\nprint('YES')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7a25fb8f6692fe12aac6","document_content":"n, k = map(int, input().split())\no = [int(t) for t in (input()+' '+input()).split()]\nf, s = 0, 0\nfor i in range(n):\n f = max(0, o[i] + f - k * o[i+n])\n s = max(0, o[i+n] + s - k * o[i])\n if f > k or s > k:\n print('NO')\n return\nprint('YES')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d6db8e756b9dff77ce2a","document_content":"def get(px, py, x, y):\n\tans = 10**18\n\tnonlocal k\n\tif px <= k:\n\t\tcnt = (px + x + k - 1) \/\/ k - 1\n\t\tif y == cnt:\n\t\t\tans = min(ans, px + x - cnt * k)\n\t\telif y > cnt and y <= x * k:\n\t\t\tans = min(ans, 1)\n\tif py <= k:\n\t\tcnt = (x + k - 1) \/\/ k - 1\n\t\tif y == cnt:\n\t\t\tans = min(ans, x - cnt * k)\n\t\telif y > cnt and y <= (x - 1) * k + (k - py):\n\t\t\tans = min(ans, 1)\n\treturn ans\n\nn, k = map(int, input().split())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\ndp = [[10**18] * (n + 1), [10**18] * (n + 1)]\ndp[0][0], dp[1][0] = 0, 0\nfor i in range(n):\n\tdp[0][i + 1] = get(dp[0][i], dp[1][i], x[i], y[i])\n\tdp[1][i + 1] = get(dp[1][i], dp[0][i], y[i], x[i])\nprint('YES' if min(dp[0][-1], dp[1][-1]) <= k else 'NO')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b0a71dde62ea89ca0c6d","document_content":"from math import ceil\n\np,x,y = map(int, input().split())\nh = x\nwhile h >=y:\n h-=50\nh+=50\nfor i in range(h, 10000000000, 50):\n u = (i\/\/50)%475\n d = []\n for j in range(25):\n u = (u * 96 + 42)%475\n d.append(26 + u)\n if p in d:\n k = i\n break\nif k-x>0:\n print(ceil((k-x)\/100))\nelse:\n print(0)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3f9a815862e6e233e739","document_content":"from sys import stdin, stdout\n\ndef findWinners(s):\n winSet=set()\n i=(s\/\/50)%475\n for _ in range(25):\n i = (i*96+42)%475\n winSet.add(26+i)\n return winSet\n\n\np,x,y = list(map(int, stdin.readline().rstrip().split()))\n\nx1=x\nsuccessfulHacks=0\nwinning=False\nwhile x1>=y and not winning:\n if p in findWinners(x1):\n winning=True\n x1-=50\n \nwhile not winning:\n x+=100\n successfulHacks+=1\n if p in findWinners(x) or p in findWinners(x-50):\n winning=True\n\nprint(successfulHacks)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fafcf298c51338f38ff0","document_content":"'''input\n329 19913 19900\n'''\ndef win(s):\n\ti = (s\/\/50) % 475\n\tl = []\n\tfor _ in range(25):\n\t\ti = (i*96 + 42) % 475\n\t\tl.append(26 + i)\n\treturn l\np, x, y = list(map(int, input().split()))\nc, x1 = 0, x\nwhile x - 50 >= y:\n\tx -= 50\nwhile p not in win(x):\n\tx += 50\n\tif x > x1:\n\t\tc += 50\nprint(c \/\/ 100 if c % 100 == 0 else c \/\/ 100 + 1)\n\n\n\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e1e3f41def56d9e15b4a","document_content":"from sys import stdin\ninput = stdin.readline\n\np, x, y = [int(i) for i in input().split()]\n\ndef shirt(score, place):\n i = int(score\/50)%475\n for j in range(25):\n i = (i*96+42)%475\n if place==(i+26):\n return True\n return False\n\nans = -1\nc = x\nwhile c>=y:\n if shirt(c, p):\n ans = 0\n break\n else:\n c -= 50\n\nif ans==-1:\n c = 0\n while True:\n if shirt((c*100)+50+x,p) or shirt((c*100)+100+x,p):\n ans = c+1\n break\n else:\n c+=1\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b8688335b0aa80e5e5bc","document_content":"def calc_T_shirt_winner_places(s):\n \"\"\"\n i := (s div 50) mod 475\nrepeat 25 times:\n i := (i * 96 + 42) mod 475\n print (26 + i)\n \"\"\"\n i = (s \/\/ 50) % 475\n i_indices = set()\n for j in range(25):\n i = (i * 96 + 42) % 475\n i_indices.add(26 + i)\n\n return i_indices\n\ndef reachable_by_unsuccessful_hacks(wanted_place, orig_score, min_place):\n score = orig_score\n while score >= min_place:\n if wanted_place in calc_T_shirt_winner_places(score):\n return True\n score -= 50\n\n if wanted_place in calc_T_shirt_winner_places(score) and score >= min_place:\n return True\n return False\n\ndef calc_number_of_successful_hacks_needed(wanted_place, orig_score):\n hacks = 0\n score_by_50, score_by_100 = orig_score + 50, orig_score + 100\n\n while True:\n hacks += 1\n if (score_by_50 >= min_place and wanted_place in calc_T_shirt_winner_places(score_by_50)) or (score_by_100 >= min_place and wanted_place in calc_T_shirt_winner_places(score_by_100)):\n return hacks\n score_by_50 += 100\n score_by_100 += 100\n\ncodecraft_place, curr_score, min_place = [int(p) for p in input().split()]\nif reachable_by_unsuccessful_hacks(codecraft_place, curr_score, min_place):\n print(0)\nelse:\n print(calc_number_of_successful_hacks_needed(codecraft_place, curr_score))\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8d3abedf2ee7abad8272","document_content":"import math\np,x,y=map(int,input().split())\ns=0\ns=int(math.ceil((y-x)\/50))\nwhile(s<=1000000):\n\tscore = x+50*s\n\ti=(score\/\/50)%475\n\tl=[]\n\n\tfor j in range(25):\n\t\ti=(i*96+42)%475\n\t\tl.append(26+i)\n\tif(p in l):\n\t\tbreak\n\telse:\n\t\ts+=1\nif(s<=0):\n\tprint(0)\nelse:\n\tprint(int(math.ceil(s\/2)))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3be55606469a8517ea32","document_content":"def findNumbers(s):\n t = [0]*25\n i = (s\/\/50)%475\n for k in range(25):\n i = (i * 96 + 42) % 475\n t[k] = i+26\n return t\n\np, x, y = list(map(int, input().split() ))\n\nk = 0\n\nif x >= y:\n xt = x\n\n while (p not in findNumbers(xt) and xt >= y ):\n xt -= 50\n if p in findNumbers(xt) and xt >= y:\n print(0)\n else:\n xt = x\n while (p not in findNumbers(xt)):\n xt += 50\n k+=0.5\n## print(str(k) + \" \" + str(xt) )\n \n print( int(k+0.5))\nelse:\n k = (y-x) \/\/ 100\n xt = ((y-x) \/\/ 100) * 100 + x\n if xt= y ):\n xt -= 50\n if p in findNumbers(xt) and xt >= y:\n print(k)\n else:\n xt = x\n while (p not in findNumbers(xt)):\n xt += 50\n k+=0.5\n## print(str(k) + \" \" + str(xt) )\n \n print( int(k+0.5))\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ba949786f3e3776e96e2","document_content":"p, x, y = list(map(int, input().split()))\nmn = [10 ** 10]\ndef tr(a):\n i = (a \/\/ 50) % 475\n for j in range(25):\n i = (i * 96 + 42) % 475\n l = 26 + i\n if l == p:\n if a <= x:\n mn[0] = min(mn[0], 0)\n else:\n k = (a - x) \/\/ 50\n if k % 2 == 0:\n mn[0] = min(mn[0], k \/\/ 2)\n else:\n mn[0] = min(mn[0], (k + 1) \/\/ 2)\n \n \nst = 0 \nfor i in range(50):\n if (x) % 50 == (y + i) % 50:\n st = y + i\n break\nfor i in range(st, 5 * 100000, 50):\n tr(i)\nprint(*mn)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"756bc8c457e62c46b556","document_content":"from sys import stdin, stdout\nfrom math import ceil\n\np, x, y = map(int, stdin.readline().split())\ns = set()\n\n\nif x < y:\n ans = (y - x) \/\/ 100\n x = x + 100 * ans\nelse:\n ans = 0\n \nif x >= y:\n label = 0\n for i in range(100):\n xc = x + 100 * i\n \n while (xc >= y):\n if (not xc in s):\n s.add(xc)\n \n ind = (xc \/\/ 50) % 475\n \n for j in range(25):\n ind = (ind * 96 + 42) % 475\n \n if ind + 26 == p:\n label = 1\n ans += i\n \n if label:\n break\n elif i:\n break\n \n xc -= 50\n \n if label:\n break\n\nstdout.write(str(ans))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7712c30e780607574b44","document_content":"def f(s):\n i = (s \/\/ 50) % 475\n l = []\n for j in range(25):\n i = (i * 96 + 42) % 475\n l.append(26 + i)\n return l\n\np, x, y = list(map(int, input().split()))\n\ni = x\nwhile i >= y:\n i -= 50\n if f(i).count(p) > 0:\n break\nif i >= y:\n print(0)\n return\n\ni = x\nc = 0\nwhile True:\n if f(i).count(p) > 0:\n break\n i += 50\n c += 1\n\n#print(i)\n\nif c % 2 == 1:\n print((c + 1) \/\/ 2)\nelse:\n print(c \/\/ 2)\n\n#print(f(7258 + 150))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a65c95eef69fc0f12414","document_content":"import sys\n\ninput_ = sys.stdin.readline\n\n\ndef precompute_places():\n res = {}\n\n for i in range(476):\n res[i] = get_tshirt_winners(i)\n\n return res\n\n\ndef get_tshirt_winners(i):\n winners = set()\n\n for _ in range(25):\n i = (i * 96 + 42) % 475\n winners.add(i + 26)\n\n return winners\n\n\ndef can_haz_tshirt(s, p, places):\n i = (s \/\/ 50) % 475\n\n if p in places[i]:\n return True\n return False\n\n\ndef main():\n p, x, y = list(map(int, input_().split()))\n\n places = precompute_places()\n\n x_down = x\n while x_down >= y:\n if can_haz_tshirt(x_down, p, places):\n return 0\n x_down -= 50\n\n x += 100\n successes = 1\n for _ in range(476):\n if can_haz_tshirt(x, p, places) or can_haz_tshirt(x - 50, p, places):\n return successes\n\n x += 100\n successes += 1\n\n return -1\n\n\ndef __starting_point():\n print(main())\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"daf1e6b990e244f99ac1","document_content":"def main():\n p, x, y = list(map(int, input().split()))\n\n # 0 check\n xcopy = x\n while xcopy >= y:\n if p in choice(xcopy):\n print(0)\n return\n xcopy -= 50\n\n # + check\n i = 1\n while x <= 23800:\n if (p in choice(x + 100*i - 50)) or (p in choice(x + 100*i)):\n print(i)\n return\n i += 1\n\ndef choice(s):\n i = (s\/\/50)%475\n\n res = []\n for n in range(25):\n i = (i*96 + 42) % 475\n res.append(26 + i)\n\n return res\n\ndef __starting_point():\n # nonlocal stime\n # stime = time.clock()\n main()\n\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5bcd551800a637a7405f","document_content":"p, x, y = list(map(int, input().split()))\n\ncur = x\nwhile cur - 50 >= y:\n cur -= 50\n\ndef gen(s):\n i = (s \/\/ 50) % 475\n res = []\n for _ in range(25):\n i = (i * 96 + 42) % 475\n res.append(26 + i)\n return res\n\nwhile p not in gen(cur):\n cur += 50\n\nprint((max(cur - x, 0) + 99) \/\/ 100)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c9049ac4ec85fa56fbf3","document_content":"import sys\n\ndef main():\n p,x,y=list(map(int,sys.stdin.readline().split()))\n \n s = x\n i = (s \/\/ 50) % 475\n for _ in range(25):\n i = (i * 96 + 42) % 475\n next = 26 + i\n if next == p: \n result = 0\n sys.stdout.write(str(result)+'\\n')\n return\n \n s = x - 50\n while True:\n if s < y: break\n i = (s \/\/ 50) % 475\n for _ in range(25):\n i = (i * 96 + 42) % 475\n next = 26 + i\n if next == p: \n result = 0\n sys.stdout.write(str(result)+'\\n')\n return\n s -= 50\n \n iplus = 1\n while True:\n for s in (x + iplus*100, x + iplus*100-50):\n i = (s \/\/ 50) % 475\n for _ in range(25):\n i = (i * 96 + 42) % 475\n next = 26 + i\n if next == p: \n result = iplus\n sys.stdout.write(str(result)+'\\n')\n return\n iplus += 1\n \nmain()\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0807f3fcfa477c3815c4","document_content":"import sys\n\ninf = 1<<60\n\ndef solve():\n p, x, y = map(int, input().split())\n\n for s in range(x, y - 1, -50):\n if p in list_tshirt(s):\n print(0)\n return\n \n for i in range(1, 476):\n s = x + i*50\n\n if p in list_tshirt(s):\n print((i + 1) \/\/ 2)\n return\n\ndef list_tshirt(s):\n res = [0]*25\n i = (s \/\/ 50) % 475\n\n for k in range(25):\n i = (i*96 + 42) % 475\n res[k] = i + 26\n\n return res\n\ndef __starting_point():\n solve()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"931a0e68bc7822bd2b5a","document_content":"import math\nimport re\nimport random\n\n\ndef generator(s):\n a = []\n i = (s \/\/ 50) % 475\n for k in range(25):\n i = (i * 96 + 42) % 475\n a.append(26 + i)\n return a\n\np, x, y = list(map(int, input().split()))\n\nans = 10000000000000\n\nfor a in range(2000):\n for b in range(2000):\n k = x + 100 * a - 50 * b;\n if k >= y and p in generator(k):\n ans = min(ans, a);\n print(ans)\n return\n\nprint(ans)\n\n\n\n\n\n\n\n\n# def func(arr, qb, allb, res):\n# for el in arr:\n# if el == 'b':\n# qb += 1\n# else:\n# allb += qb\n# qb = 0\n# res += allb\n# allb *= 2\n# return res\n#\n#\n# arr = input()\n#\n#\n# arr = arr[::-1]\n#\n# res = func(arr, 0, 0, 0)\n#\n# #print(res)\n#\n# print(res % (pow(10, 9) + 7))\n\n\n\n\n\n\n# n = int(input())\n#\n#\n# if n % 2 == 0:\n# print(n\/\/2 - 1)\n# else:\n# print(n\/\/2)\n\n\n\n\n\n\n\n\n\n#n = int(input())\n# res = ''\n# for i in range(n):\n# if i % 4 == 0 or i % 4 == 1:\n# res += 'a'\n# else:\n# res += 'b'\n#\n# print(res)\n\n\n\n\n\n\n# l, r = map(int, input().split())\n# if l == r and l % 2 != 0:\n# print(l)\n# else:\n# print(2)\n\n\n\n\n\n\n\n\n\n\n\n# n = int(input())\n# a = list(map(len, input().replace('-', ' ').split()))\n# for i in range(len(a) - 1):\n# a[i] += 1\n#\n#\n#\n#\n#\n# print(' '.join(map(str, a)))\n\n\n\n\n\n\n\n# n = int(input())\n# a = list(map(int, input().split()))\n#\n# b = []\n# q = 0\n# for 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#\n# c = []\n#\n# for 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#\n# print(' '.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# return\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","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"46f51ea885b949b5286d","document_content":"# written by sak\n#\n#\tsk<3\n#\n# powered by codechef\n\nimport math\nz=input()\nz=z.split(' ')\np=int(z[0])\nx=int(z[1])\ny=int(z[2])\n\ni=int(math.floor(x\/50))\ni=i%475\nflag=0\nfor j in range(0,25):\n\ti=(i*96 + 42)%475\n\t#print(26+i)\n\tif((26+i)==p):\n\t\tprint(\"0\")\n\t\tflag=1\n\t\tbreak\nif(flag!=1):\n\tans=0\n\twhile 1:\n\t\tcurr=x+100*ans\n\t\twhile(curr>=y):\n\t\t\ti=int(math.floor(curr\/50))\n\t\t\ti=i%475\n\t\t\twin={}\n\t\t\tfor j in range(0,25):\n\t\t\t\ti=(i*96 + 42)%475\n\t\t\t\tif((26+i)==p):\n\t\t\t\t\tprint(ans)\n\t\t\t\t\tflag=1\n\t\t\t\t\tbreak\n\t\t\tcurr-=50\n\t\t\tif(flag==1):\n\t\t\t\tbreak\n\t\tans+=1\n\t\tif(flag==1):\n\t\t\tbreak\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"272d128d4b8c6defd615","document_content":"p,x,y = list(map(int,input().split()))\nls = []\ni = x\/\/50 % 475\nfor z in range(25):\n i = (i*96 + 42) % 475\n ls.append(i+26)\nif p in ls:\n print(0)\n quit()\nl = x-50\nm = x\nwhile l >= y:\n ls = []\n i = l\/\/50 % 475\n for z in range(25):\n i = (i*96 + 42) % 475\n ls.append(i+26)\n if p in ls:\n print(0)\n quit()\n l-=50\nindex = 1\nwhile True:\n ls = []\n i = (m+index*50)\/\/50 % 475\n for z in range(25):\n i = (i*96 + 42) % 475\n ls.append(i+26)\n if p in ls:\n print((50*index + 50)\/\/100)\n break\n else:\n index += 1\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"96b4d34d46e3e4bd0ac5","document_content":"p, x, y = list(map(int, input().split()))\n\ndef f(s):\n rtn = []\n i = (s \/\/ 50) % 475\n for _ in range(25):\n i = (i * 96 + 42) % 475\n rtn.append(26 + i)\n return rtn\n\nans = -1\ntmp = x\nwhile y <= tmp:\n if p in f(tmp):\n ans = 0\n break\n tmp -= 50\ntmp = x\nwhile ans < 0:\n tmp += 50\n if p in f(tmp):\n ans = (tmp - x + 50) \/\/ 100\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0e6e5e2e910724e4ed45","document_content":"inp = input()\n\np, x, y = list(map(int, inp.split()))\n\nTshirt = []\ns = x\n\nwhile(s >= y):\n Tshirt = []\n ans = (s \/\/ 50) % 475\n for i in range(25):\n ans = (ans * 96 + 42) % 475\n Tshirt.append(ans + 26)\n\n if p in Tshirt:\n print(0)\n return\n s -= 50\n\nhack = 0\nwhile(not(p in Tshirt)):\n Tshirt = []\n ans = (x \/\/ 50) % 475\n for i in range(25):\n ans = (ans * 96 + 42) % 475\n Tshirt.append(ans + 26)\n x += 50\n hack += 1\n \nprint(hack \/\/ 2)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b6e671083beedae64b5f","document_content":"p,x,y=list(map(int,input().split()))\nr=x\nz=0\nm=0\nc=-1\na=[0]*25\nwhile r >= y:\n s = x - z*50\n i = (s \/\/ 50) % 475\n for q in range(25):\n i =(i * 96 + 42) % 475\n a[q]=26 + i\n \n r-=50\n z+=1\n for i in range(25):\n if a[i]==p:\n c=0\n m=1\nif c!=0:\n c=0\n while m!=1:\n c+=1\n s = x - 50 + c*100\n i = (s \/\/ 50) % 475\n for q in range(25):\n i =(i * 96 + 42) % 475\n a[q]=26 + i\n for i in range(25):\n if a[i]==p:\n m=1\n s = x + c*100\n i = (s \/\/ 50) % 475\n for q in range(25):\n i =(i * 96 + 42) % 475\n a[q]=26 + i\n for i in range(25):\n if a[i]==p:\n m=1\n \n \nprint(c)\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0ef051ac2f7dd783075f","document_content":"def mat(s, p):\n i = (s \/\/ 50) % 475\n for _ in range(25):\n i = (i*96 + 42) % 475\n if i + 26 == p:\n return True\n return False\n\np,x,y = map(int, input().split())\ns = x\nwhile s >= y:\n s -= 50\nif s < y:\n s += 50\nwhile not mat(s, p):\n s += 50\nif s <= x:\n print(0)\nelse:\n print(int((s - x) \/ 100 + 0.5))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"727cfee71232f36d51f7","document_content":"#!\/usr\/bin\/env python\nimport sys\ndef eligible(score, position, thresh):\n if score < thresh:\n return False\n i = (score \/\/ 50) % 475\n for __ in range(25):\n i = (i * 96 + 42) % 475\n if position == 26 + i:\n return True\n return False\n\ndef main():\n p, x, y= list(map(int, sys.stdin.readline().split()))\n diff = 0\n for __ in range(475):\n if eligible(x + diff, p, y):\n print(\"0\")\n return\n diff -= 50\n diff = 0\n for __ in range(475):\n if eligible(x + diff, p, y):\n succ = diff \/\/ 100\n unsucc = (diff \/\/ 50) %2 ## if 1, we need additional success\n print(str(succ + unsucc))\n return\n diff += 50\n\nmain()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f1a0fbfde9afebc2f137","document_content":"from sys import stdin, stdout\n\n\np, x, y = list(map(int, stdin.readline().strip().split()))\n\ndef getScores(s):\n scores = []\n i = (s \/\/ 50) % 475\n\n for g in range(25):\n i = (i * 96 + 42) % 475\n scores.append(26 + i)\n\n return scores\n\nz = x\ncount = 0\n\nwhile True:\n if x > y:\n if p in getScores(x):\n break\n else:\n x += 50\n count += 1\n else:\n x += 50\n count += 1\n\ndcount = 0\ndF = False\nx = z\nwhile x >= y:\n if p in getScores(x):\n dF = True\n break\n else:\n x -= 50\n dcount += 1\n\nif dF == True or count == 0:\n print(0)\nelse:\n print(count \/\/ 2 + count % 2)\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"478bad38bb1942718787","document_content":"n, k = map(int, input().split())\n\nres = 1\nwhile (k % 2 == 0):\n res += 1\n k \/\/= 2\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bc69f944d7136a8d15c1","document_content":"def main():\n n, k = list(map(int, input().split()))\n while (n != 0):\n if (k == (2**(n - 1))):\n print(n)\n return\n else:\n k = k % (2**(n - 1))\n n -= 1\nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9bf1727225d515a2c810","document_content":"n, k = list(map(int, input().split()))\nres = 1\nwhile (k & 1) == 0:\n k >>= 1\n res += 1\nprint(res)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b0b25a1b48d4bf4477b7","document_content":"n, k = map(int, input().split())\ni = 1\nwhile (k % 2 == 0):\n k \/= 2\n i += 1\nprint(i)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"99e2995e75188b6c0da3","document_content":"def f(n, k):\n m = our[n]\n if m \/\/ 2 + 1 == k:\n return n\n return f(n - 1, k % (m \/\/ 2 + 1))\n\n\nour = [0, 1]\nn, k = map(int, input().split())\nwhile len(our) <= n + 1:\n our.append(our[-1] * 2 + 1)\nprint(f(n, k))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0f79dcbb35c4db8ca154","document_content":"n, k = list(map(int, input().split()))\nfinish = False\nlength = 1\nfor i in range(n-1):\n length = length * 2 + 1 \nwhile n!=1:\n gran = length \/\/ 2 + 1\n if k == gran:\n print(n)\n finish = True\n break\n if k < gran:\n length = length \/\/ 2\n n -= 1\n if k > gran:\n k -= (length \/\/ 2 + 1)\n length = length \/\/ 2\n n -= 1 \nif not finish:\n print(1)\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c67b796e5eac8e9cd67d","document_content":"n,k = map(int,input().split())\n\ndef f(i,j):\n l = (1<<(i-1))\n if j==l:\n return i\n elif j 2 ** (n - 1):\n k -= 2 ** (n - 1)\n return p(n - 1, k)\n\nn, k = map(int, input().split())\nprint(p(n, k))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"802b7e3e72e5ca07b75a","document_content":"n, k = [int(x) for x in input().strip().split(\" \")]\nle = 2**n - 1\n\ndef binsearch(level, le, ind):\n\tif level == 1:\n\t\treturn 1\n\tif ind == le \/\/ 2 + 1:\n\t\treturn level\n\tif ind > le \/\/ 2 + 1:\n\t\tind -= le \/\/ 2 + 1\n\treturn binsearch(level-1, le\/\/2, ind)\n\nprint(binsearch(n,le,k))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a587410361575fbd4342","document_content":"n, k = list(map(int, input().split()))\nk -= 1\nx = 1\nwhile True:\n if k % 2 ** x == 2 ** (x - 1) - 1:\n print(x)\n break\n x += 1","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d17d194cfbf930ba398e","document_content":"n, k = map(int, input().split())\n\ns = 0\nwhile not(k % 2):\n s += 1\n k \/\/= 2\n \nprint(s + 1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"857915b7285eddb1b79a","document_content":"def rec(depth, pos):\n if pos > 2 ** (depth - 1):\n rec(depth - 1, pos - 2 ** (depth - 1))\n elif pos == 2 ** (depth - 1):\n print(depth)\n return\n else:\n rec(depth - 1, pos)\n return\n\nn, k = [int(i) for i in input().split()]\nrec(n, k)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"396926f765a24c4d5e2e","document_content":"n, k = list(map(int, input().split()))\n\ndef nk(n, k):\n if n == 1: return 1\n t = 2**(n-1)\n if k == t: return n\n if k < t: return nk(n-1,k)\n else: return nk(n-1,k-t)\n\nprint(nk(n, k))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ef7c3b80c2b229a26a18","document_content":"import sys\nn, k = list(map(int, input().split()))\nv = k\nk -= 1\nsum = 0\nfor i in range(1, n + 1):\n if ((k - sum) % 2 == 0):\n print(i)\n break\n sum += v \/\/ (1 << i)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"84556736c208eedd8b9b","document_content":"n, k = [int(s) for s in input().split()]\n\nlengths = [1]\n\nn, k = n-1, k-1\n\nfor i in range(n):\n lengths.append(lengths[-1] * 2 + 1)\n\ndef search(n, k):\n if k == 0:\n return 1\n l = lengths[n]\n if k == l \/\/ 2:\n return n + 1\n if k < l \/\/ 2:\n return search(n-1, k)\n else:\n return search(n-1, k - l\/\/2 - 1)\n\nprint(search(n, k))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8578d484af926d3c8465","document_content":"n, k = map(int, input().split())\n\ndef dfs(q, d):\n q = q % (2**(d-1))\n if (q == 0):\n print(d)\n else:\n dfs(q, d-1)\n\ndfs(k, n)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cd413576f85e09875c8c","document_content":"n , k = map(int, input().split())\nres = 0\nwhile k % 2 == 0:\n k \/= 2\n res += 1\nprint(res + 1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8cd200bdfa82f183df08","document_content":"n, k = map(int, input().split())\nnow = n\nwhile True:\n if k == 2 ** (now - 1):\n print(now)\n break\n else:\n now -= 1\n k %= 2 ** now","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"34afe5cb71c7080318b0","document_content":"import string\nimport math\n\nline=input()\nn=int(line.split(\" \")[0])\nk=int(line.split(\" \")[1])\n\ndef search(l,r,k,dep):\n mid=(l+r)\/2\n if k==mid or l==r:\n return(dep)\n if kmid:\n return search(mid+1,r,k,dep-1)\n\nprint(search(1,pow(2,n)-1,k,n))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"547ecd92357d4c7bbac4","document_content":"def solve(n, k):\n if n == 1:\n return 1\n if k == 2 ** (n - 1):\n return n\n return solve(n - 1, k % (2 ** (n - 1)))\n\nn, k = map(int, input().split())\nprint(solve(n, k))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e7aad3b5af97c40110c4","document_content":"n, k = map(int, input().split())\na = 0\nwhile k % 2 == 0:\n a += 1\n k \/= 2\nprint(a + 1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6433cc841e5316a0bd84","document_content":"# coding=utf-8\n__author__ = 'Alexander'\n\n\ndef f(n,k):\n t = 2 ** (n-1)\n\n if k == t:\n return n\n elif k < t:\n return f(n-1, k)\n else:\n return f(n-1, k-t)\n\nn, k = map(int,input().split())\n\nprint(f(n,k))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0db1d05227983745341c","document_content":"n, k = map(int, input().split())\ncnt = 0\nwhile k % 2 == 0:\n k = k \/\/ 2\n cnt += 1\nprint(cnt + 1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dfc0f9f361d2d21cfd92","document_content":"import math\n\nn, k = list(map(int, input().split()))\narr = reversed([int(math.pow(2, i)) for i in range(50)])\n\nfor index, num in enumerate(arr):\n\tif k % num == 0:\n\t\tprint(50 - index)\n\t\tbreak","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4383265dacdf0bb82114","document_content":"import sys\ninput = sys.stdin.readline\n\ndef mult_input():\n\treturn map(int,input().split())\n\ndef list_input():\n\treturn list(map(int,input().split()))\n\nfor nt in range(int(input())):\n\tn,k=map(int,input().split())\n\tfor i in range(2,n+1):\n\t\tif n%i==0:\n\t\t\tnum=i\n\t\t\tbreak\n\tprint (n+i+2*(k-1))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"607fcde812a62afe719e","document_content":"t=int(input())\nfor _ in range(t):\n n,k=list(map(int,input().split()))\n if n%2==0:\n print(n+2*k)\n else:\n i=2\n while 1>0:\n if n%i==0:\n break\n i=i+1\n n=n+i\n k=k-1\n print(n+2*k)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"83a968eccf1e3d5c4900","document_content":"t = int(input())\nfor ii in range(t):\n n, k = map(int, input().split())\n if n % 2 == 0:\n print(n + 2 * k)\n else:\n f = 0\n for j in range(2, n + 1):\n if n % j == 0:\n print(n + j + 2 * (k - 1))\n break","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3cd0b2407384eb754013","document_content":"'''input\n3\n5 1\n8 2\n3 4\n'''\ndef solve():\n\tn,k = map(int,input().split())\n\tdiv = 0\n\tfor i in range(2,n+1):\n\t\tif n%i==0:\n\t\t\tdiv = i\n\t\t\tbreak\n\tprint(n+div+(k-1)*2)\n\treturn \nt = 1\nt = int(input())\nwhile t>0:\n\tt-=1\n\tsolve()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"35ea07524a2ed7473e41","document_content":"q = int(input())\n\nfor _ in range(q):\n n, k = list(map(int, input().split()))\n if n%2:\n for d in range(3, n+1):\n if n%d == 0:\n n += d\n k -= 1\n break\n n += k*2\n print(n)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9d9927dbe14ba857367c","document_content":"import sys\n\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nns = lambda: readline().rstrip()\nni = lambda: int(readline().rstrip())\nnm = lambda: map(int, readline().split())\nnl = lambda: list(map(int, readline().split()))\nprn = lambda x: print(*x, sep='\\n')\n\n\ndef solve():\n n, k = nm()\n for i in range(2, n+1):\n if n % i == 0:\n n += i\n break\n n += 2 * (k-1)\n print(n)\n return\n\n# solve()\n\nT = ni()\nfor _ in range(T):\n solve()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"554ad69848d80081fec6","document_content":"for _ in range(int(input())):\n n, k = map(int, input().split())\n d1 = 2\n while n % d1 != 0:\n d1 += 1\n\n n = n + d1\n k -= 1\n n += k*2\n print(n)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dc9d98ed73a818b82805","document_content":"# The real secret to success is enthusiasm. Walter Chrysler\n# by : Blue Edge - Create some chaos\n\ndef give(n):\n i=2\n while i*i<=n:\n if n%i==0:\n return i\n i+=1\n return n\nfor _ in range(int(input())):\n n,k=list(map(int,input().split()))\n print(n+give(n)+2*(k-1))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fcb98e97e3b31365877e","document_content":"t=int(input())\nfor i in range(t):\n n,k=map(int,input().split())\n ans=n\n for i in range(2,n+1):\n if n%i==0:\n ans+=i\n break\n ans+=2*(k-1)\n print(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d65c94526f03a97600fe","document_content":"for f in range(int(input())):\n n,k=map(int,input().split())\n div=2\n while div*divn:\n div=n\n print(n+div+(k-1)*2)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f9df06f155368a9b80cd","document_content":"\"\"\"T=int(input())\nfor _ in range(0,T):\n n=int(input())\n a,b=map(int,input().split())\n s=input()\n s=[int(x) for x in input().split()]\n for i in range(0,len(s)):\n a,b=map(int,input().split())\"\"\"\n\n\nT=int(input())\nfor _ in range(0,T):\n n,k=list(map(int,input().split()))\n ans=n\n if(n%2==0):\n ans+=(2*k)\n else:\n ans+=(2*(k-1))\n for i in range(2,n+1):\n if(n%i==0):\n ans+=i\n break\n print(ans)\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e8939a70454d7722bff2","document_content":"t = int(input())\nfor _ in range(t):\n n, k = list(map(int, input().split()))\n best = 0\n for i in range(2, n+1):\n if n % i == 0:\n best = i\n break\n print(n+best+(2*(k-1)))\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dcf65c11f59f9ee937dd","document_content":"from math import sqrt\nfrom collections import defaultdict as dd\nimport sys\ninput=sys.stdin.readline\nimport bisect\nt=int(input())\nwhile t:\n #n=int(input())\n n,k=map(int,input().split())\n #l=list(map(int,input().split()))\n for i in range(2,n+1):\n if(n%i==0):\n ind=i\n break\n n=n+i\n n=(k-1)*2+n\n print(n)\n t-=1","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"38fbbb1d3797ca8f10e6","document_content":"# test = iter('''0\n# 1 2\n# '''.splitlines())\n#\n#\n# def input():\n# return next(test)\n\n\ndef int_input():\n return int(input())\n\n\ndef ints_input():\n return (int(x) for x in input().split())\n\n\nt=int_input()\nfor _ in range(t):\n n,k=ints_input()\n if (n&1) == 0:\n print(n+k+k)\n else:\n for i in range(3, n+1, 2):\n if n % i == 0:\n print(n+i+2*(k-1))\n break","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0bd182d2bd45d8193be7","document_content":"t = int(input())\n\nfor _ in range(t):\n n, k = list(map(int, input().strip().split()))\n if n % 2 == 0:\n print(n + 2*k)\n else:\n for i in range(3, n + 1):\n if n % i == 0:\n print(n + i + (k-1)*2)\n break","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4f9011799a38f461631d","document_content":"import math\nimport sys\n\n#sys.stdin = open(\"in.txt\")\n\nt = int(input())\nfor i in range(t):\n n, k = map(int, input().split())\n for i in range(k):\n if (n % 2 == 0):\n n += 2 * (k - i)\n break\n else:\n for d in range(3, 1000, 2):\n if (n % d == 0 or d * d > n):\n break\n if (n % d > 0):\n d = n\n n += d\n print(n)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9970ce4a61af445bab10","document_content":"# ========= \/\\ \/| |====\/|\n# | \/ \\ | | \/ |\n# | \/____\\ | | \/ |\n# | \/ \\ | | \/ |\n# ========= \/ \\ ===== |\/====| \n# code\n\ndef main():\n from math import sqrt\n t = 1\n t = int(input())\n for _ in range(t):\n n , k = map(int , input().split())\n if n % 2 == 0:\n print(n + k * 2)\n else:\n for i in range(3 , n + 1):\n if n % i == 0:\n print(n + i + (k - 1) * 2)\n break\n return\n\ndef __starting_point():\n main()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c2c0aa20cc78e931488a","document_content":"t=int(input())\nfor you in range(t):\n l=input().split()\n n=int(l[0])\n k=int(l[1])\n for i in range(2,n+1):\n if(n%i==0):\n break\n n+=i\n k-=1\n print(n+(2*k))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9a5d7f190eb295e63ce7","document_content":"for i in range(int(input())):\n n,k=map(int,input().split())\n ind=-1\n for j in range(2,int(n**0.5)+1):\n if n%j==0:\n ind=j\n break\n if ind==-1:\n ind=n\n k-=1\n su=n+ind+(k)*2\n print(su)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"48e5c772d47466c11b38","document_content":"t=int(input())\nfor _ in range(t):\n\tn,k=list(map(int,input().split()))\n\tdiv=-1\n\tfor i in range(2,int(n*0.5)+1):\n\t\tif n%i==0:\n\t\t\tdiv=i\n\t\t\tbreak\n\tif div==-1:\n\t\tdiv=n\n\tn+=div\n\tk-=1\n\tprint(n+k*2)\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2ea1a0cd8c8743c418a7","document_content":"\"\"\"\nCodeforces Contest 266 Div 2 Problem B\n\nAuthor : chaotic_iak\nLanguage: Python 3.3.4\n\"\"\"\n\ndef ceildiv(a,b):\n return a\/\/b + (1 if a%b else 0)\n\ndef main():\n n,a,b = read()\n s = 6*n\n if a*b >= s:\n print(a*b)\n print(a,b)\n return\n t = int((6*n) ** .5)\n tgt = 9001*n\n tgta = 0\n tgtb = 0\n for i in range(1, t+1):\n c = ceildiv(s,i)\n if a <= i and b <= c:\n if tgt > i*c:\n tgt = i*c\n tgta = i\n tgtb = c\n if b <= i and a <= c:\n if tgt > i*c:\n tgt = i*c\n tgtb = i\n tgta = c\n print(tgt)\n print(tgta,tgtb)\n\n################################### NON-SOLUTION STUFF BELOW\n\ndef read(mode=2):\n # 0: String\n # 1: List of strings\n # 2: List of integers\n inputs = input().strip()\n if mode == 0: return inputs\n if mode == 1: return inputs.split()\n if mode == 2: return list(map(int, inputs.split()))\n\ndef write(s=\"\\n\"):\n if s is None: s = \"\"\n if isinstance(s, list): s = \" \".join(map(str, s))\n s = str(s)\n print(s, end=\"\")\n\nwrite(main())","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8ba841c3d7eb6885c861","document_content":"from math import *\nn,a,b = map(int,input().split())\nans = (10000005700000,1000000000064000)\nansp = 10**55\nif a*b>=6*n:\n ans = (a,b)\n ansp = a*b\n\nfor x in range(int(sqrt(6*n)*1.33)):\n yy = max(0,ceil((6*n-a*b-b*x)\/(a+x))-1)\n for y in range(yy,yy+3):\n if 6*n<=(a+x)*(b+y)= s:\n print(a*b)\n print(a, b)\n return\n \n ma, mb = min(a, b), max(a, b)\n\n _s = float('inf')\n _a = 0\n \n for i in range(min(int(s**0.5)+1, s \/\/ mb), ma - 1, -1):\n _b = (s + i - 1) \/\/ i\n si = i * _b\n if _s > si:\n _a, _s = i, si\n if si == s:\n break\n print(_s)\n _b = _s \/\/ _a\n if not (a <= _a and b <= _b):\n _a, _b = _b, _a\n print(_a, _b)\n\n\ndef __starting_point():\n main()\n\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"067983e9f63b79791069","document_content":"def solve(n, a, b):\n need = n * 6\n\n orig_a, orig_b = a, b\n\n if a < b:\n a, b = b, a\n\n y = b\n\n best_prod = None\n best = (None, None)\n\n while True:\n x, modulo = divmod(need, y)\n\n if modulo:\n x += 1\n\n if x < a:\n x = a\n\n prod = x * y\n\n if not best_prod or best_prod > prod:\n best_prod = prod\n best = (x, y)\n\n if best_prod == need:\n break\n\n y += 1\n\n if x < y:\n break\n\n if x < a or y < b:\n break\n\n x, y = best\n if x < orig_a or y < orig_b:\n best = (y, x)\n\n return best\n\ndef __starting_point():\n n, a, b = list(map(int, input().split()))\n x, y = solve(n, a, b)\n print(x * y)\n print(x, y)\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1f9387977ceb76d33c95","document_content":"import math\n\n#input\nn,a,b=map(int,input().split())\n\n#variables\nx=6*n-1\n\n#main\nif a*b>6*n:\n\tprint(a*b)\n\tprint(str(a)+' '+str(b))\n\tquit()\n\nwhile True:\n\tx+=1\n\tfor i in range(min(a,b),math.floor(math.sqrt(x))+1):\n\t\tif x%i==0:\n\t\t\tif i>=a and x\/i>=b:\n\t\t\t\tprint(x)\n\t\t\t\tprint(str(i)+' '+str(x\/\/i))\n\t\t\t\tquit()\n\t\t\tif i>=b and x\/i>=a:\n\t\t\t\tprint(x)\n\t\t\t\tprint(str(x\/\/i)+' '+str(i))\n\t\t\t\tquit()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"406f6af2e0c46e4f540b","document_content":"from math import *\nfrom itertools import *\nn, a, b = map(int, input().split())\nif a * b >= 6 * n:\n print(a * b)\n print(a, b)\nelse:\n p = ceil(sqrt(6 * n))\n s, a1, b1 = min(chain(((x * ceil(6 * n \/ x), x, ceil(6 * n \/ x)) for x in range(a, p + 1) if ceil(6 * n \/ x) >= b), \\\n ((ceil(6 * n \/ y) * y, ceil(6 * n \/ y), y) for y in range(b, p + 1) if ceil(6 * n \/ y) >= a)))\n print(s)\n print(a1, b1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f62e504201096d1de1ae","document_content":"import math\nn, a, b = list(map(int, input().split()))\ns = 6*n\nif a*b >= s:\n print(a*b)\n print(a, b)\nelse:\n aa, bb = a, b\n area = float('inf')\n _a = 0\n for i in range(min(math.ceil(s**0.5), s \/\/ max(a, b)), min(a, b)-1, -1):\n _b = math.ceil(s\/i)\n _s = _b * i\n if _s <= area:\n area, _a = _s, i\n if _s == s:\n break\n print(area)\n _b = area\/\/_a\n if not (aa <= _a and bb <= _b):\n _a, _b = _b, _a\n print(_a, _b)\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"be574ff7adf3a0a4634d","document_content":"from math import ceil\n\nn, a, b = map(int, input().split())\n\ns = 6 * n\n\nif a * b >= s:\n na, nb = a, b\nelse:\n a1, b1 = min(a, b), max(a, b)\n q = [(x, ceil(s \/ x)) for x in range(a1, ceil(s ** .5)) if ceil(s \/ x) > b1]\n na, nb = min(q, key=lambda c: c[0] * c[1])\n if na < a:\n na, nb = nb, na\n\nprint(na * nb)\nprint(na, nb)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ca58583f5cf644064c48","document_content":"a, b, c = list(map(int, input().split(' ')))\ndef solve(a, b, c):\n if b >= c:\n b, c = c, b\n for i in range(max(6*a, b*c), 10**50):\n for j in range(b, int(i**0.5)+1):\n if i%j==0:\n if int(i\/j)>=c:\n return (i, j, int(i\/j))\nx, y, z = solve(a, b, c)\n\nprint(x)\nif y>=b and z>=c:\n print(y, z)\nelse:\n print(z, y)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ed6970db20499f4a322d","document_content":"n, a, b = map(int, input().split())\nn = 6 * n\ns = a * b\nif s >= n:\n print(s)\n print(a, b)\n return\nm = int(n ** 0.5) + 1\ns = (a + m) * (b + m)\nfor x in range(a, m):\n y = max((n - 1) \/\/ x + 1, b)\n if x * y < s:\n s = x * y\n u, v = x, y\nfor y in range(b, m):\n x = max((n - 1) \/\/ y + 1, a)\n if x * y < s:\n s = x * y\n u, v = x, y\nprint(s)\nprint(u, v)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9fb366ce539039877feb","document_content":"from math import ceil\n\nn, a, b = list(map(int, input().split()))\ns = n * 6\n\nif s <= a * b:\n na, nb = a, b\nelse:\n a1, b1 = min(a, b), max(a, b)\n q = [(x, ceil(s \/ x)) for x in range(a1, ceil(s ** .5)) if ceil(s \/ x) > b1]\n na, nb = min(q, key = lambda c : c[0] * c[1])\n if na < a:\n na, nb = nb, na\n\nprint(na * nb)\nprint(na, nb)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"27895d59fd5ef96eef83","document_content":"n,a,b = list(map(int, input().split(' ')))\nA = 6*n\nif a*b >= 6*n :\n print(a*b)\n print(a,b)\nelse :\n R = []\n temp = float(\"INF\")\n for i in range(1, int(A**0.5)+2) :\n j = A\/\/i\n if i*j < A : j+=1\n x = max([a,b,i,j])\n y = max(min(a,b) , min(i,j))\n if temp > x*y :\n temp = x*y\n if b>a : x,y = y,x\n R = [x,y, temp]\n print(R[2])\n print(R[0], R[1])\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"adf9cece42c7d25c75ac","document_content":"__author__ = 'trunghieu11 - vuondenthanhcong11@gmail.com'\n\n# ---------- Actual Code ----------\n\ncount, a, b = list(map(int, input().split()))\nareaNeed = 6 * count\n\nif a * b >= areaNeed:\n print(a * b)\n print(a, b)\n return\n\nisSwap = False\nif a > b:\n a, b = b, a\n isSwap = True\n\nanswerArea = 10**10\nanswerA = -1\nanswerB = -1\n\nfor i in range(a, int(areaNeed ** 0.5) + 1):\n curB = (areaNeed + i - 1) \/\/ i\n if curB >= b:\n curArea = i * curB\n if curArea < answerArea:\n answerArea = curArea\n answerA = i\n answerB = curB\n\nif isSwap:\n answerA, answerB = answerB, answerA\n\nprint(answerArea)\nprint(answerA, answerB)\n\n# ---------- My Tools -------------\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2bbf42db6d46fcc3acf4","document_content":"from math import sqrt,ceil;\ndef main():\n n,a,b = [int(i) for i in input().split()]\n swaped = 0\n if (a > b):\n a,b = b,a\n swaped = 1\n if (a*b >= 6*n):\n print(a*b)\n print(a,b)\n return 0\n new_a_max = ceil(sqrt(6*n))\n ans = []\n for newa in range(a,new_a_max+1):\n newb = ceil((6*n)\/newa)\n if (newa*newb >= 6*n and newb >= b):\n ans.append([newa*newb,newa,newb])\n ans = sorted(ans)\n if (swaped):\n ans[0][1],ans[0][2] = ans[0][2],ans[0][1]\n print(ans[0][0])\n print(ans[0][1],ans[0][2])\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"29c074c038d2420227d9","document_content":"from math import sqrt\nfrom math import ceil\n\n(n, a, b) = list(map(int, input().split(' ')))\nbatas = ceil(sqrt(6 * n))\nluas = 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + \\\n 100\np, l = 0, 0\n\nif a * b >= 6 * n:\n print(a * b)\n print(\"%d %d\" % (a, b))\n return\n\nfor i in range(a, max(a, batas + 1)):\n lenmin = ceil(float(6 * n) \/ i)\n if lenmin < b:\n continue\n if lenmin * i == 6 * n:\n print(\"%d\\n%d %d\" % (6 * n, i, lenmin))\n return\n if lenmin * i > 6 * n:\n if lenmin * i < luas:\n p = i\n l = lenmin\n luas = lenmin * i\n\nfor i in range(b, max(b, batas + 1)):\n lenmin = ceil(float(6 * n) \/ i)\n if lenmin < a:\n continue\n if lenmin * i == 6 * n:\n print(\"%d\\n%d %d\" % (6 * n, lenmin, i))\n return\n if lenmin * i > 6 * n:\n if lenmin * i < luas:\n p = lenmin\n l = i\n luas = lenmin * i\n\nprint(\"%d\\n%d %d\" % (p * l, p, l))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3026e23715dae541eafa","document_content":"\nimport sys\n\ntry:\n while True:\n n, a, b = list(map(int, input().split(\" \")))\n flag = False\n if a > b:\n flag = True\n a, b = b, a\n if 6*n <= a * b:\n print(a*b)\n res = str(a) + \" \" + str(b)\n print(res)\n continue\n res = 1 << 60\n i = a\n ans1 = 0\n ans2 = 0\n while i*i <= 6 * n:\n tmp = 6*n\/\/i\n if tmp * i < 6 * n:\n tmp += 1\n if tmp < b:\n i += 1\n continue\n if i*tmp < res:\n res = i * tmp\n ans1 = i\n ans2 = tmp\n i += 1\n if flag:\n ans1, ans2 = ans2, ans1\n print(res)\n ans = str(ans1) + \" \" + str(ans2)\n print(ans)\n\n\nexcept EOFError:\n pass\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7783589857a7ab727e8a","document_content":"import math\n\nn,a,b=list(map(int,input().split()))\ntarget=6*n\nif(target= s:\n x, y = a, b\nelse:\n a1, b1 = min(a, b), max(a, b)\n q = [(x, ceil(s \/ x)) for x in range(a1, ceil(s ** .5)) if ceil(s \/ x) > b1]\n x, y = min(q, key=lambda c: c[0] * c[1])\n if x < a:\n x, y = y, x\n\nprint(x * y)\nprint(x, y)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"96ab83ec05f2334c64c8","document_content":"import math\nx=[]\ncount=0\nn,a,b=list(map(int,input().split()))\nif a>b:\n count=1\nif a*b>=n*6:\n print(a*b)\n print(a,b)\nelif max(a,b)<=n and min(a,b)<=6:\n print(n*6)\n if count==1:\n print(max(n,6),min(n,6))\n else:\n print(min(n,6),max(n,6))\nelse:\n for i in range(min(a,b),min(math.ceil(n*6\/min(a,b)),int((6*n)**0.5)) + 1):\n if math.ceil(n*6\/i)>=max(a,b):\n x.append([math.ceil(n*6\/i) * i,i])\n x.sort()\n print(x[0][0])\n if count==1:\n print(max(x[0][1],x[0][0]\/\/x[0][1]),min(x[0][1],x[0][0]\/\/x[0][1]))\n else:\n print(min(x[0][1],x[0][0]\/\/x[0][1]),max(x[0][1],x[0][0]\/\/x[0][1]))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6cd0d90127aa9b0260e1","document_content":"n,a,b=list(map(int,input().split()))\nif a*b>=6*n:\n print(a*b)\n print(a,b)\nelse:\n sq,ansx,ansy,ar=round(((6*n)**0.5)),1e9,1e9,1e18\n for i in range(1,sq+6):\n p,q=i,(6*n+i-1)\/\/i\n if max(p,q)>=max(a,b) and min(p,q)>=min(a,b):\n if ar>p*q:\n ar=p*q\n ansx,ansy=min(p,q),max(p,q)\n print(ansx*ansy)\n if ansx>=a and ansy>=b:\n print(ansx,ansy)\n else:\n print(ansy,ansx)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a30414319df23c2c699d","document_content":"from math import ceil\n\n\n\nn, a, b = list(map(int, input().split()))\n\n\n\ns = 6 * n\n\n\n\nif a * b >= s:\n\n x, y = a, b\n\nelse:\n\n a1, b1 = min(a, b), max(a, b)\n\n q = [(x, ceil(s \/ x)) for x in range(a1, ceil(s ** .5)) if ceil(s \/ x) > b1]\n\n x, y = min(q, key=lambda c: c[0] * c[1])\n\n if x < a:\n\n x, y = y, x\n\n\n\nprint(x * y)\n\nprint(x, y)\n\n\n\n# Made By Mostafa_Khaled\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"20c305081f8c8db8b335","document_content":"import math\n\nn, a, b = list(map(int, input().strip().split()))\nmin_sq = n * 6\n\nif a * b >= min_sq:\n print('{}\\n{} {}'.format(a * b, a, b))\nelse:\n max_sq = math.inf\n\n swap = False\n if a > b:\n a, b = b, a\n swap = True\n\n a_n, b_n = a, b\n\n\n for i in range(a, int(math.ceil(math.sqrt(min_sq))) + 1):\n n_b = int(math.ceil(min_sq \/ i))\n\n if n_b < b:\n continue\n\n new_sq = n_b * i\n if new_sq < max_sq:\n max_sq = new_sq\n a_n = i\n b_n = n_b\n \n if swap:\n a_n, b_n = b_n, a_n\n print('{}\\n{} {}'.format(max_sq, a_n, b_n))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8aba4022ec1040e45b61","document_content":"n, a , b = list(map(int, input().split()))\nn *= 6\nswapped = False\nif a > b:\n a, b = b, a\n swapped = True\na, b = min(a,b), max(a,b)\na1, b1 = a, b\ns = (1<<61)\nfor i in range(a, int(n**0.5)+1):\n j = max(b1, (n-1) \/\/ i + 1)\n if i * j < s:\n s = i * j\n a, b = i, j\nprint(a * b)\nif swapped:\n print(b, a)\nelse:\n print(a, b)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9c82655a1f7fe0ce5c0c","document_content":"from math import sqrt\nn, a, b=map(int, input().split())\np, x, y=a*b, a, b\nn*=6\nif n>p:\n\ti=min(x, y)\n\tj=min((n\/\/max(x, y)), int(sqrt(n)))+1\n\tp=n*(a+b)\n\tfor e in range(i, j):\n\t\tk=(n+e-1)\/\/e\n\t\tif e*kb and xy):\n\tx, y=y, x\nprint(p)\nprint(x, y)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c84e06785ac4e762f594","document_content":"def find(ins):\n\tins += 1\n\t\n\ttest = [int(i) for i in str(ins)]\n\t\n\tinlist = []\n\t\n\tfor i in test:\n\t\tif i in inlist:\n\t\t\t\n\t\t\ttest = find(ins)\n\t\t\tbreak\n\t\t\t\n\t\telse:\n\t\t\tinlist.append(i)\n\t\n\treturn ''.join(str(x) for x in test)\n\t\nins = int(input())\nprint(find(ins))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"892bc1ae0348e60efea0","document_content":"y = int(input())\ny = y+1\ndef isDistinct(year):\n sy = str(year)\n li = []\n for i in sy:\n if(i in li):\n return False\n li.append(i)\n return True\n\nwhile(not isDistinct(y)):\n y = y+1\n\nprint(y)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"495b5460507e22a26cc6","document_content":"import sys\ninp = sys.stdin\ny = int(inp.readline()) + 1\n\ndef check_dif(num):\n s = str(num)\n ok = 1\n for i in range(len(s)):\n if s[i] in s[i + 1:]:\n ok = 0\n return ok\n\nwhile check_dif(y) == 0:\n y += 1\nprint(y)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c193d310de71a267d66d","document_content":"n = int(input()) + 1\nwhile len(set(str(n))) != 4:\n\tn += 1\nprint(n)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1d9cff600e50b5e92201","document_content":"y = int(input()) + 1 #scott wait you don't even right? you can do like list(str(y)) or something\nwhile len(set(str(y))) != len(str(y)): y+=1 #scott\nprint(y) #steven remember ++ doesn't exist","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3a8d5defbbd8172b2012","document_content":"# http:\/\/codeforces.com\/problemset\/problem\/271\/A you start this should be like a 2-liner with python?\n\n#sry i see it now\n\n\ndef check(x): # let's practice writing functions though and yeah i think list == array so not list prolly\n# http:\/\/anh.cs.luc.edu\/python\/hands-on\/3.1\/handsonHtml\/functions.html\n return len(set(str(x)))==len(str(x)) # should work??\ny = int(input()) + 1 #scott wait you don't even right? you can do like list(str(y)) or something\n\nwhile not check(y): y+=1 #scott\n\nprint(y) #steven remember ++ doesn't exist\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f466e0a2e778a0f67fa7","document_content":"# http:\/\/codeforces.com\/problemset\/problem\/271\/A you start this should be like a 2-liner with python?\n\n#sry i see it now\n\n\ndef check(x): # let's practice writing functions though and yeah i think list == array so not list prolly\n# http:\/\/anh.cs.luc.edu\/python\/hands-on\/3.1\/handsonHtml\/functions.html\n return len(set(str(x)))==len(str(x)) # should work??\ny = int(input()) + 1 #scott wait you don't even right? you can do like list(str(y)) or something\n\nwhile check(y) == 0: y+=1 #scott\n\nprint(y) #steven remember ++ doesn't exist\n#oh wait it might be the == false might need to be FALSE or something stupid like that also ! does not exist\n#oh ic\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a6854b87cec1a1e305f8","document_content":"# http:\/\/codeforces.com\/problemset\/problem\/271\/A you start this should be like a 2-liner with python?\n\n#sry i see it now\n\n\ndef check(x): # let's practice writing functions though and yeah i think list == array so not list prolly\n# http:\/\/anh.cs.luc.edu\/python\/hands-on\/3.1\/handsonHtml\/functions.html\n return len(set(str(x)))==len(str(x)) # should work??\ny = int(input()) + 1 #scott wait you don't even right? you can do like list(str(y)) or something\n\nwhile check(y) == False: y+=1 #scott\n\nprint(y) #steven remember ++ doesn't exist\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cb759dc5fd7acf42f015","document_content":"# http:\/\/codeforces.com\/problemset\/problem\/271\/A you start this should be like a 2-liner with python?\n\n#sry i see it now\n\n\ndef check(x): # let's practice writing functions though and yeah i think list == array so not list prolly\n# http:\/\/anh.cs.luc.edu\/python\/hands-on\/3.1\/handsonHtml\/functions.html\n return len(set(str(x)))==len(str(x)) # should work??\ny = int(input()) + 1 #scott wait you don't even right? you can do like list(str(y)) or something\n\nwhile check(y) is False: y+=1 #scott\n\nprint(y) #steven remember ++ doesn't exist\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cb28162d95b4f878b82b","document_content":"n=input()\nyear=int(n)\nyear+=1\nn=list(str(year))\nwhile(not(n.count(n[0])==n.count(n[1])==n.count(n[2])==n.count(n[3])==1)):\n year+=1\n n=list(str(year))\n\nprint(year)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4335e49926371bcc9869","document_content":"3\n\ny = int(input())\nans = y + 1\nwhile True:\n if len(set(list(str(ans)))) == 4:\n break\n ans += 1\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"faf196ef78daa65b9457","document_content":"n = int(input()) + 1\nwhile len(set(str(n))) != 4: n += 1\nprint(n)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"06d15a5acd9e2d83824f","document_content":"def is_distinct(year):\n years = str(year)\n s = set()\n for c in years:\n if c in s:\n return False\n else:\n s.add(c)\n return True\n\ndef upper_distinct(year):\n year += 1\n while(True):\n if is_distinct(year):\n return year\n else:\n year += 1\n \n\n\ndef main():\n first_line = input()\n first_line = first_line.split()\n \n year = int(first_line[0])\n print(upper_distinct(year))\n \n\n\n \n \n \nmain()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ed2dba9e91f57f2ee314","document_content":"y=int(input())+1\nwhile(len(set(str(y)))!=len(str(y))):\n y+=1\nprint(y)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fb6e799e35c34c385a38","document_content":"import sys\n\ndef year():\n listyear = []\n year = input().split()\n k = True\n for i in range(len(year[0])):\n listyear.append(int(year[0][i]))\n listyear.reverse()\n return(listyear)\n\ndef nextyear(listyear):\n if listyear[0] == 9:\n listyear[0] = 0\n if listyear[1] == 9:\n listyear[1] = 0\n if listyear[2] == 9:\n listyear[2] = 0\n if listyear[3] == 9:\n listyear[3] = 0\n else:\n listyear[3] += 1\n else:\n listyear[2] += 1\n else:\n listyear[1] += 1\n else:\n listyear[0] += 1\n return listyear\n\ndef rightyear(listyear):\n nextyear(listyear)\n while len(set(listyear)) != 4:\n listyear = nextyear(listyear)\n listyear.reverse()\n\n for i in listyear:\n print(i,end=\"\")\n \nrightyear(year())\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ede06a2d2a98b4a4f7ce","document_content":"n = int(input())\nwhile True:\n n += 1\n c = set(str(n))\n if len(c) == len(str(n)):\n print(n)\n break\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c20f77bb955e209dd447","document_content":"year = int(input())\n\nfor i in range(year + 1, 9013):\n if i % 10 != i \/\/ 1000 and i % 10 != i % 1000 \/\/ 100 and i % 10 != i % 100 \/\/ 10 and i \/\/ 1000 != i % 1000 \/\/ 100 and i \/\/ 1000 != i % 100 \/\/ 10 and i % 100 \/\/ 10 != i % 1000 \/\/ 100:\n print(i)\n break\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"93c68ac32bb0e8ed1d5b","document_content":"n = int(input()) + 1\nwhile len(set(str(n))) != 4:\n n += 1\nprint(n)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2c169635dd09c5497429","document_content":"def cnt(n):\n a = [0] * 10\n c = 0\n b = 0\n while n != 0:\n a[n % 10] += 1\n if a[n % 10] == 1:\n c += 1\n n \/\/= 10\n b += 1\n if b == c:\n return True\n else:\n return False\n\nn = int(input().strip())\ni = 1\nwhile not cnt(n + i):\n i += 1\nprint(n + i)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9e280ac952ada9b76c38","document_content":"y=int(input())\n\ndef is_b_year(x):\n\ts=set()\n\tfor c in str(x):\n\t\ts.add(c)\n\tif len(s) == 4:\n\t\treturn True\n\telse :\n\t\treturn False\n\nfor x in range(y+1,2**31-1):\n\tif is_b_year(x):\n\t\tprint(x)\n\t\tbreak\n\t\n\t\n\t\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"66094e12beefe21cb1e0","document_content":"year = int(input())\n\nfor i in range(year + 1, 10000):\n y = i\n a = y \/\/ 1000\n y = y - a * 1000\n b = y \/\/ 100\n y = y - b * 100\n c = y \/\/ 10\n y = y - c * 10\n lst = [a, b, c, y]\n lst.sort()\n if lst[0] != lst[1] and lst[1] != lst[2] and lst[2] != lst[3]:\n print(i)\n break","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"310498565656c8fa218f","document_content":"for i in range(int(input()) + 1, 10000):\n if len(set(list(str(i)))) == 4:\n print(i)\n break","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1ca1e4795d0df8c7f0a2","document_content":"def isUnique(num):\n string=str(num)\n d={'0':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0}\n for i in string:\n if d[i]==0:\n d[i]=1\n elif d[i]==1:\n return 0\n return 1\n\nstring=input()\nnum=int(string)\nwhile 1:\n num+=1\n if isUnique(num):break\nprint(num)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"757c586f02883627b46c","document_content":"years = [1023, 1024, 1025, 1026, 1027, 1028, 1029, 1032, 1034, 1035, 1036, 1037, 1038, 1039, 1042, 1043, 1045, 1046, 1047, 1048, 1049, 1052, 1053, 1054, 1056, 1057, 1058, 1059, 1062, 1063, 1064, 1065, 1067, 1068, 1069, 1072, 1073, 1074, 1075, 1076, 1078, 1079, 1082, 1083, 1084, 1085, 1086, 1087, 1089, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1230, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1243, 1245, 1246, 1247, 1248, 1249, 1250, 1253, 1254, 1256, 1257, 1258, 1259, 1260, 1263, 1264, 1265, 1267, 1268, 1269, 1270, 1273, 1274, 1275, 1276, 1278, 1279, 1280, 1283, 1284, 1285, 1286, 1287, 1289, 1290, 1293, 1294, 1295, 1296, 1297, 1298, 1302, 1304, 1305, 1306, 1307, 1308, 1309, 1320, 1324, 1325, 1326, 1327, 1328, 1329, 1340, 1342, 1345, 1346, 1347, 1348, 1349, 1350, 1352, 1354, 1356, 1357, 1358, 1359, 1360, 1362, 1364, 1365, 1367, 1368, 1369, 1370, 1372, 1374, 1375, 1376, 1378, 1379, 1380, 1382, 1384, 1385, 1386, 1387, 1389, 1390, 1392, 1394, 1395, 1396, 1397, 1398, 1402, 1403, 1405, 1406, 1407, 1408, 1409, 1420, 1423, 1425, 1426, 1427, 1428, 1429, 1430, 1432, 1435, 1436, 1437, 1438, 1439, 1450, 1452, 1453, 1456, 1457, 1458, 1459, 1460, 1462, 1463, 1465, 1467, 1468, 1469, 1470, 1472, 1473, 1475, 1476, 1478, 1479, 1480, 1482, 1483, 1485, 1486, 1487, 1489, 1490, 1492, 1493, 1495, 1496, 1497, 1498, 1502, 1503, 1504, 1506, 1507, 1508, 1509, 1520, 1523, 1524, 1526, 1527, 1528, 1529, 1530, 1532, 1534, 1536, 1537, 1538, 1539, 1540, 1542, 1543, 1546, 1547, 1548, 1549, 1560, 1562, 1563, 1564, 1567, 1568, 1569, 1570, 1572, 1573, 1574, 1576, 1578, 1579, 1580, 1582, 1583, 1584, 1586, 1587, 1589, 1590, 1592, 1593, 1594, 1596, 1597, 1598, 1602, 1603, 1604, 1605, 1607, 1608, 1609, 1620, 1623, 1624, 1625, 1627, 1628, 1629, 1630, 1632, 1634, 1635, 1637, 1638, 1639, 1640, 1642, 1643, 1645, 1647, 1648, 1649, 1650, 1652, 1653, 1654, 1657, 1658, 1659, 1670, 1672, 1673, 1674, 1675, 1678, 1679, 1680, 1682, 1683, 1684, 1685, 1687, 1689, 1690, 1692, 1693, 1694, 1695, 1697, 1698, 1702, 1703, 1704, 1705, 1706, 1708, 1709, 1720, 1723, 1724, 1725, 1726, 1728, 1729, 1730, 1732, 1734, 1735, 1736, 1738, 1739, 1740, 1742, 1743, 1745, 1746, 1748, 1749, 1750, 1752, 1753, 1754, 1756, 1758, 1759, 1760, 1762, 1763, 1764, 1765, 1768, 1769, 1780, 1782, 1783, 1784, 1785, 1786, 1789, 1790, 1792, 1793, 1794, 1795, 1796, 1798, 1802, 1803, 1804, 1805, 1806, 1807, 1809, 1820, 1823, 1824, 1825, 1826, 1827, 1829, 1830, 1832, 1834, 1835, 1836, 1837, 1839, 1840, 1842, 1843, 1845, 1846, 1847, 1849, 1850, 1852, 1853, 1854, 1856, 1857, 1859, 1860, 1862, 1863, 1864, 1865, 1867, 1869, 1870, 1872, 1873, 1874, 1875, 1876, 1879, 1890, 1892, 1893, 1894, 1895, 1896, 1897, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1920, 1923, 1924, 1925, 1926, 1927, 1928, 1930, 1932, 1934, 1935, 1936, 1937, 1938, 1940, 1942, 1943, 1945, 1946, 1947, 1948, 1950, 1952, 1953, 1954, 1956, 1957, 1958, 1960, 1962, 1963, 1964, 1965, 1967, 1968, 1970, 1972, 1973, 1974, 1975, 1976, 1978, 1980, 1982, 1983, 1984, 1985, 1986, 1987, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2031, 2034, 2035, 2036, 2037, 2038, 2039, 2041, 2043, 2045, 2046, 2047, 2048, 2049, 2051, 2053, 2054, 2056, 2057, 2058, 2059, 2061, 2063, 2064, 2065, 2067, 2068, 2069, 2071, 2073, 2074, 2075, 2076, 2078, 2079, 2081, 2083, 2084, 2085, 2086, 2087, 2089, 2091, 2093, 2094, 2095, 2096, 2097, 2098, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2130, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2143, 2145, 2146, 2147, 2148, 2149, 2150, 2153, 2154, 2156, 2157, 2158, 2159, 2160, 2163, 2164, 2165, 2167, 2168, 2169, 2170, 2173, 2174, 2175, 2176, 2178, 2179, 2180, 2183, 2184, 2185, 2186, 2187, 2189, 2190, 2193, 2194, 2195, 2196, 2197, 2198, 2301, 2304, 2305, 2306, 2307, 2308, 2309, 2310, 2314, 2315, 2316, 2317, 2318, 2319, 2340, 2341, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2354, 2356, 2357, 2358, 2359, 2360, 2361, 2364, 2365, 2367, 2368, 2369, 2370, 2371, 2374, 2375, 2376, 2378, 2379, 2380, 2381, 2384, 2385, 2386, 2387, 2389, 2390, 2391, 2394, 2395, 2396, 2397, 2398, 2401, 2403, 2405, 2406, 2407, 2408, 2409, 2410, 2413, 2415, 2416, 2417, 2418, 2419, 2430, 2431, 2435, 2436, 2437, 2438, 2439, 2450, 2451, 2453, 2456, 2457, 2458, 2459, 2460, 2461, 2463, 2465, 2467, 2468, 2469, 2470, 2471, 2473, 2475, 2476, 2478, 2479, 2480, 2481, 2483, 2485, 2486, 2487, 2489, 2490, 2491, 2493, 2495, 2496, 2497, 2498, 2501, 2503, 2504, 2506, 2507, 2508, 2509, 2510, 2513, 2514, 2516, 2517, 2518, 2519, 2530, 2531, 2534, 2536, 2537, 2538, 2539, 2540, 2541, 2543, 2546, 2547, 2548, 2549, 2560, 2561, 2563, 2564, 2567, 2568, 2569, 2570, 2571, 2573, 2574, 2576, 2578, 2579, 2580, 2581, 2583, 2584, 2586, 2587, 2589, 2590, 2591, 2593, 2594, 2596, 2597, 2598, 2601, 2603, 2604, 2605, 2607, 2608, 2609, 2610, 2613, 2614, 2615, 2617, 2618, 2619, 2630, 2631, 2634, 2635, 2637, 2638, 2639, 2640, 2641, 2643, 2645, 2647, 2648, 2649, 2650, 2651, 2653, 2654, 2657, 2658, 2659, 2670, 2671, 2673, 2674, 2675, 2678, 2679, 2680, 2681, 2683, 2684, 2685, 2687, 2689, 2690, 2691, 2693, 2694, 2695, 2697, 2698, 2701, 2703, 2704, 2705, 2706, 2708, 2709, 2710, 2713, 2714, 2715, 2716, 2718, 2719, 2730, 2731, 2734, 2735, 2736, 2738, 2739, 2740, 2741, 2743, 2745, 2746, 2748, 2749, 2750, 2751, 2753, 2754, 2756, 2758, 2759, 2760, 2761, 2763, 2764, 2765, 2768, 2769, 2780, 2781, 2783, 2784, 2785, 2786, 2789, 2790, 2791, 2793, 2794, 2795, 2796, 2798, 2801, 2803, 2804, 2805, 2806, 2807, 2809, 2810, 2813, 2814, 2815, 2816, 2817, 2819, 2830, 2831, 2834, 2835, 2836, 2837, 2839, 2840, 2841, 2843, 2845, 2846, 2847, 2849, 2850, 2851, 2853, 2854, 2856, 2857, 2859, 2860, 2861, 2863, 2864, 2865, 2867, 2869, 2870, 2871, 2873, 2874, 2875, 2876, 2879, 2890, 2891, 2893, 2894, 2895, 2896, 2897, 2901, 2903, 2904, 2905, 2906, 2907, 2908, 2910, 2913, 2914, 2915, 2916, 2917, 2918, 2930, 2931, 2934, 2935, 2936, 2937, 2938, 2940, 2941, 2943, 2945, 2946, 2947, 2948, 2950, 2951, 2953, 2954, 2956, 2957, 2958, 2960, 2961, 2963, 2964, 2965, 2967, 2968, 2970, 2971, 2973, 2974, 2975, 2976, 2978, 2980, 2981, 2983, 2984, 2985, 2986, 2987, 3012, 3014, 3015, 3016, 3017, 3018, 3019, 3021, 3024, 3025, 3026, 3027, 3028, 3029, 3041, 3042, 3045, 3046, 3047, 3048, 3049, 3051, 3052, 3054, 3056, 3057, 3058, 3059, 3061, 3062, 3064, 3065, 3067, 3068, 3069, 3071, 3072, 3074, 3075, 3076, 3078, 3079, 3081, 3082, 3084, 3085, 3086, 3087, 3089, 3091, 3092, 3094, 3095, 3096, 3097, 3098, 3102, 3104, 3105, 3106, 3107, 3108, 3109, 3120, 3124, 3125, 3126, 3127, 3128, 3129, 3140, 3142, 3145, 3146, 3147, 3148, 3149, 3150, 3152, 3154, 3156, 3157, 3158, 3159, 3160, 3162, 3164, 3165, 3167, 3168, 3169, 3170, 3172, 3174, 3175, 3176, 3178, 3179, 3180, 3182, 3184, 3185, 3186, 3187, 3189, 3190, 3192, 3194, 3195, 3196, 3197, 3198, 3201, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3214, 3215, 3216, 3217, 3218, 3219, 3240, 3241, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3254, 3256, 3257, 3258, 3259, 3260, 3261, 3264, 3265, 3267, 3268, 3269, 3270, 3271, 3274, 3275, 3276, 3278, 3279, 3280, 3281, 3284, 3285, 3286, 3287, 3289, 3290, 3291, 3294, 3295, 3296, 3297, 3298, 3401, 3402, 3405, 3406, 3407, 3408, 3409, 3410, 3412, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3425, 3426, 3427, 3428, 3429, 3450, 3451, 3452, 3456, 3457, 3458, 3459, 3460, 3461, 3462, 3465, 3467, 3468, 3469, 3470, 3471, 3472, 3475, 3476, 3478, 3479, 3480, 3481, 3482, 3485, 3486, 3487, 3489, 3490, 3491, 3492, 3495, 3496, 3497, 3498, 3501, 3502, 3504, 3506, 3507, 3508, 3509, 3510, 3512, 3514, 3516, 3517, 3518, 3519, 3520, 3521, 3524, 3526, 3527, 3528, 3529, 3540, 3541, 3542, 3546, 3547, 3548, 3549, 3560, 3561, 3562, 3564, 3567, 3568, 3569, 3570, 3571, 3572, 3574, 3576, 3578, 3579, 3580, 3581, 3582, 3584, 3586, 3587, 3589, 3590, 3591, 3592, 3594, 3596, 3597, 3598, 3601, 3602, 3604, 3605, 3607, 3608, 3609, 3610, 3612, 3614, 3615, 3617, 3618, 3619, 3620, 3621, 3624, 3625, 3627, 3628, 3629, 3640, 3641, 3642, 3645, 3647, 3648, 3649, 3650, 3651, 3652, 3654, 3657, 3658, 3659, 3670, 3671, 3672, 3674, 3675, 3678, 3679, 3680, 3681, 3682, 3684, 3685, 3687, 3689, 3690, 3691, 3692, 3694, 3695, 3697, 3698, 3701, 3702, 3704, 3705, 3706, 3708, 3709, 3710, 3712, 3714, 3715, 3716, 3718, 3719, 3720, 3721, 3724, 3725, 3726, 3728, 3729, 3740, 3741, 3742, 3745, 3746, 3748, 3749, 3750, 3751, 3752, 3754, 3756, 3758, 3759, 3760, 3761, 3762, 3764, 3765, 3768, 3769, 3780, 3781, 3782, 3784, 3785, 3786, 3789, 3790, 3791, 3792, 3794, 3795, 3796, 3798, 3801, 3802, 3804, 3805, 3806, 3807, 3809, 3810, 3812, 3814, 3815, 3816, 3817, 3819, 3820, 3821, 3824, 3825, 3826, 3827, 3829, 3840, 3841, 3842, 3845, 3846, 3847, 3849, 3850, 3851, 3852, 3854, 3856, 3857, 3859, 3860, 3861, 3862, 3864, 3865, 3867, 3869, 3870, 3871, 3872, 3874, 3875, 3876, 3879, 3890, 3891, 3892, 3894, 3895, 3896, 3897, 3901, 3902, 3904, 3905, 3906, 3907, 3908, 3910, 3912, 3914, 3915, 3916, 3917, 3918, 3920, 3921, 3924, 3925, 3926, 3927, 3928, 3940, 3941, 3942, 3945, 3946, 3947, 3948, 3950, 3951, 3952, 3954, 3956, 3957, 3958, 3960, 3961, 3962, 3964, 3965, 3967, 3968, 3970, 3971, 3972, 3974, 3975, 3976, 3978, 3980, 3981, 3982, 3984, 3985, 3986, 3987, 4012, 4013, 4015, 4016, 4017, 4018, 4019, 4021, 4023, 4025, 4026, 4027, 4028, 4029, 4031, 4032, 4035, 4036, 4037, 4038, 4039, 4051, 4052, 4053, 4056, 4057, 4058, 4059, 4061, 4062, 4063, 4065, 4067, 4068, 4069, 4071, 4072, 4073, 4075, 4076, 4078, 4079, 4081, 4082, 4083, 4085, 4086, 4087, 4089, 4091, 4092, 4093, 4095, 4096, 4097, 4098, 4102, 4103, 4105, 4106, 4107, 4108, 4109, 4120, 4123, 4125, 4126, 4127, 4128, 4129, 4130, 4132, 4135, 4136, 4137, 4138, 4139, 4150, 4152, 4153, 4156, 4157, 4158, 4159, 4160, 4162, 4163, 4165, 4167, 4168, 4169, 4170, 4172, 4173, 4175, 4176, 4178, 4179, 4180, 4182, 4183, 4185, 4186, 4187, 4189, 4190, 4192, 4193, 4195, 4196, 4197, 4198, 4201, 4203, 4205, 4206, 4207, 4208, 4209, 4210, 4213, 4215, 4216, 4217, 4218, 4219, 4230, 4231, 4235, 4236, 4237, 4238, 4239, 4250, 4251, 4253, 4256, 4257, 4258, 4259, 4260, 4261, 4263, 4265, 4267, 4268, 4269, 4270, 4271, 4273, 4275, 4276, 4278, 4279, 4280, 4281, 4283, 4285, 4286, 4287, 4289, 4290, 4291, 4293, 4295, 4296, 4297, 4298, 4301, 4302, 4305, 4306, 4307, 4308, 4309, 4310, 4312, 4315, 4316, 4317, 4318, 4319, 4320, 4321, 4325, 4326, 4327, 4328, 4329, 4350, 4351, 4352, 4356, 4357, 4358, 4359, 4360, 4361, 4362, 4365, 4367, 4368, 4369, 4370, 4371, 4372, 4375, 4376, 4378, 4379, 4380, 4381, 4382, 4385, 4386, 4387, 4389, 4390, 4391, 4392, 4395, 4396, 4397, 4398, 4501, 4502, 4503, 4506, 4507, 4508, 4509, 4510, 4512, 4513, 4516, 4517, 4518, 4519, 4520, 4521, 4523, 4526, 4527, 4528, 4529, 4530, 4531, 4532, 4536, 4537, 4538, 4539, 4560, 4561, 4562, 4563, 4567, 4568, 4569, 4570, 4571, 4572, 4573, 4576, 4578, 4579, 4580, 4581, 4582, 4583, 4586, 4587, 4589, 4590, 4591, 4592, 4593, 4596, 4597, 4598, 4601, 4602, 4603, 4605, 4607, 4608, 4609, 4610, 4612, 4613, 4615, 4617, 4618, 4619, 4620, 4621, 4623, 4625, 4627, 4628, 4629, 4630, 4631, 4632, 4635, 4637, 4638, 4639, 4650, 4651, 4652, 4653, 4657, 4658, 4659, 4670, 4671, 4672, 4673, 4675, 4678, 4679, 4680, 4681, 4682, 4683, 4685, 4687, 4689, 4690, 4691, 4692, 4693, 4695, 4697, 4698, 4701, 4702, 4703, 4705, 4706, 4708, 4709, 4710, 4712, 4713, 4715, 4716, 4718, 4719, 4720, 4721, 4723, 4725, 4726, 4728, 4729, 4730, 4731, 4732, 4735, 4736, 4738, 4739, 4750, 4751, 4752, 4753, 4756, 4758, 4759, 4760, 4761, 4762, 4763, 4765, 4768, 4769, 4780, 4781, 4782, 4783, 4785, 4786, 4789, 4790, 4791, 4792, 4793, 4795, 4796, 4798, 4801, 4802, 4803, 4805, 4806, 4807, 4809, 4810, 4812, 4813, 4815, 4816, 4817, 4819, 4820, 4821, 4823, 4825, 4826, 4827, 4829, 4830, 4831, 4832, 4835, 4836, 4837, 4839, 4850, 4851, 4852, 4853, 4856, 4857, 4859, 4860, 4861, 4862, 4863, 4865, 4867, 4869, 4870, 4871, 4872, 4873, 4875, 4876, 4879, 4890, 4891, 4892, 4893, 4895, 4896, 4897, 4901, 4902, 4903, 4905, 4906, 4907, 4908, 4910, 4912, 4913, 4915, 4916, 4917, 4918, 4920, 4921, 4923, 4925, 4926, 4927, 4928, 4930, 4931, 4932, 4935, 4936, 4937, 4938, 4950, 4951, 4952, 4953, 4956, 4957, 4958, 4960, 4961, 4962, 4963, 4965, 4967, 4968, 4970, 4971, 4972, 4973, 4975, 4976, 4978, 4980, 4981, 4982, 4983, 4985, 4986, 4987, 5012, 5013, 5014, 5016, 5017, 5018, 5019, 5021, 5023, 5024, 5026, 5027, 5028, 5029, 5031, 5032, 5034, 5036, 5037, 5038, 5039, 5041, 5042, 5043, 5046, 5047, 5048, 5049, 5061, 5062, 5063, 5064, 5067, 5068, 5069, 5071, 5072, 5073, 5074, 5076, 5078, 5079, 5081, 5082, 5083, 5084, 5086, 5087, 5089, 5091, 5092, 5093, 5094, 5096, 5097, 5098, 5102, 5103, 5104, 5106, 5107, 5108, 5109, 5120, 5123, 5124, 5126, 5127, 5128, 5129, 5130, 5132, 5134, 5136, 5137, 5138, 5139, 5140, 5142, 5143, 5146, 5147, 5148, 5149, 5160, 5162, 5163, 5164, 5167, 5168, 5169, 5170, 5172, 5173, 5174, 5176, 5178, 5179, 5180, 5182, 5183, 5184, 5186, 5187, 5189, 5190, 5192, 5193, 5194, 5196, 5197, 5198, 5201, 5203, 5204, 5206, 5207, 5208, 5209, 5210, 5213, 5214, 5216, 5217, 5218, 5219, 5230, 5231, 5234, 5236, 5237, 5238, 5239, 5240, 5241, 5243, 5246, 5247, 5248, 5249, 5260, 5261, 5263, 5264, 5267, 5268, 5269, 5270, 5271, 5273, 5274, 5276, 5278, 5279, 5280, 5281, 5283, 5284, 5286, 5287, 5289, 5290, 5291, 5293, 5294, 5296, 5297, 5298, 5301, 5302, 5304, 5306, 5307, 5308, 5309, 5310, 5312, 5314, 5316, 5317, 5318, 5319, 5320, 5321, 5324, 5326, 5327, 5328, 5329, 5340, 5341, 5342, 5346, 5347, 5348, 5349, 5360, 5361, 5362, 5364, 5367, 5368, 5369, 5370, 5371, 5372, 5374, 5376, 5378, 5379, 5380, 5381, 5382, 5384, 5386, 5387, 5389, 5390, 5391, 5392, 5394, 5396, 5397, 5398, 5401, 5402, 5403, 5406, 5407, 5408, 5409, 5410, 5412, 5413, 5416, 5417, 5418, 5419, 5420, 5421, 5423, 5426, 5427, 5428, 5429, 5430, 5431, 5432, 5436, 5437, 5438, 5439, 5460, 5461, 5462, 5463, 5467, 5468, 5469, 5470, 5471, 5472, 5473, 5476, 5478, 5479, 5480, 5481, 5482, 5483, 5486, 5487, 5489, 5490, 5491, 5492, 5493, 5496, 5497, 5498, 5601, 5602, 5603, 5604, 5607, 5608, 5609, 5610, 5612, 5613, 5614, 5617, 5618, 5619, 5620, 5621, 5623, 5624, 5627, 5628, 5629, 5630, 5631, 5632, 5634, 5637, 5638, 5639, 5640, 5641, 5642, 5643, 5647, 5648, 5649, 5670, 5671, 5672, 5673, 5674, 5678, 5679, 5680, 5681, 5682, 5683, 5684, 5687, 5689, 5690, 5691, 5692, 5693, 5694, 5697, 5698, 5701, 5702, 5703, 5704, 5706, 5708, 5709, 5710, 5712, 5713, 5714, 5716, 5718, 5719, 5720, 5721, 5723, 5724, 5726, 5728, 5729, 5730, 5731, 5732, 5734, 5736, 5738, 5739, 5740, 5741, 5742, 5743, 5746, 5748, 5749, 5760, 5761, 5762, 5763, 5764, 5768, 5769, 5780, 5781, 5782, 5783, 5784, 5786, 5789, 5790, 5791, 5792, 5793, 5794, 5796, 5798, 5801, 5802, 5803, 5804, 5806, 5807, 5809, 5810, 5812, 5813, 5814, 5816, 5817, 5819, 5820, 5821, 5823, 5824, 5826, 5827, 5829, 5830, 5831, 5832, 5834, 5836, 5837, 5839, 5840, 5841, 5842, 5843, 5846, 5847, 5849, 5860, 5861, 5862, 5863, 5864, 5867, 5869, 5870, 5871, 5872, 5873, 5874, 5876, 5879, 5890, 5891, 5892, 5893, 5894, 5896, 5897, 5901, 5902, 5903, 5904, 5906, 5907, 5908, 5910, 5912, 5913, 5914, 5916, 5917, 5918, 5920, 5921, 5923, 5924, 5926, 5927, 5928, 5930, 5931, 5932, 5934, 5936, 5937, 5938, 5940, 5941, 5942, 5943, 5946, 5947, 5948, 5960, 5961, 5962, 5963, 5964, 5967, 5968, 5970, 5971, 5972, 5973, 5974, 5976, 5978, 5980, 5981, 5982, 5983, 5984, 5986, 5987, 6012, 6013, 6014, 6015, 6017, 6018, 6019, 6021, 6023, 6024, 6025, 6027, 6028, 6029, 6031, 6032, 6034, 6035, 6037, 6038, 6039, 6041, 6042, 6043, 6045, 6047, 6048, 6049, 6051, 6052, 6053, 6054, 6057, 6058, 6059, 6071, 6072, 6073, 6074, 6075, 6078, 6079, 6081, 6082, 6083, 6084, 6085, 6087, 6089, 6091, 6092, 6093, 6094, 6095, 6097, 6098, 6102, 6103, 6104, 6105, 6107, 6108, 6109, 6120, 6123, 6124, 6125, 6127, 6128, 6129, 6130, 6132, 6134, 6135, 6137, 6138, 6139, 6140, 6142, 6143, 6145, 6147, 6148, 6149, 6150, 6152, 6153, 6154, 6157, 6158, 6159, 6170, 6172, 6173, 6174, 6175, 6178, 6179, 6180, 6182, 6183, 6184, 6185, 6187, 6189, 6190, 6192, 6193, 6194, 6195, 6197, 6198, 6201, 6203, 6204, 6205, 6207, 6208, 6209, 6210, 6213, 6214, 6215, 6217, 6218, 6219, 6230, 6231, 6234, 6235, 6237, 6238, 6239, 6240, 6241, 6243, 6245, 6247, 6248, 6249, 6250, 6251, 6253, 6254, 6257, 6258, 6259, 6270, 6271, 6273, 6274, 6275, 6278, 6279, 6280, 6281, 6283, 6284, 6285, 6287, 6289, 6290, 6291, 6293, 6294, 6295, 6297, 6298, 6301, 6302, 6304, 6305, 6307, 6308, 6309, 6310, 6312, 6314, 6315, 6317, 6318, 6319, 6320, 6321, 6324, 6325, 6327, 6328, 6329, 6340, 6341, 6342, 6345, 6347, 6348, 6349, 6350, 6351, 6352, 6354, 6357, 6358, 6359, 6370, 6371, 6372, 6374, 6375, 6378, 6379, 6380, 6381, 6382, 6384, 6385, 6387, 6389, 6390, 6391, 6392, 6394, 6395, 6397, 6398, 6401, 6402, 6403, 6405, 6407, 6408, 6409, 6410, 6412, 6413, 6415, 6417, 6418, 6419, 6420, 6421, 6423, 6425, 6427, 6428, 6429, 6430, 6431, 6432, 6435, 6437, 6438, 6439, 6450, 6451, 6452, 6453, 6457, 6458, 6459, 6470, 6471, 6472, 6473, 6475, 6478, 6479, 6480, 6481, 6482, 6483, 6485, 6487, 6489, 6490, 6491, 6492, 6493, 6495, 6497, 6498, 6501, 6502, 6503, 6504, 6507, 6508, 6509, 6510, 6512, 6513, 6514, 6517, 6518, 6519, 6520, 6521, 6523, 6524, 6527, 6528, 6529, 6530, 6531, 6532, 6534, 6537, 6538, 6539, 6540, 6541, 6542, 6543, 6547, 6548, 6549, 6570, 6571, 6572, 6573, 6574, 6578, 6579, 6580, 6581, 6582, 6583, 6584, 6587, 6589, 6590, 6591, 6592, 6593, 6594, 6597, 6598, 6701, 6702, 6703, 6704, 6705, 6708, 6709, 6710, 6712, 6713, 6714, 6715, 6718, 6719, 6720, 6721, 6723, 6724, 6725, 6728, 6729, 6730, 6731, 6732, 6734, 6735, 6738, 6739, 6740, 6741, 6742, 6743, 6745, 6748, 6749, 6750, 6751, 6752, 6753, 6754, 6758, 6759, 6780, 6781, 6782, 6783, 6784, 6785, 6789, 6790, 6791, 6792, 6793, 6794, 6795, 6798, 6801, 6802, 6803, 6804, 6805, 6807, 6809, 6810, 6812, 6813, 6814, 6815, 6817, 6819, 6820, 6821, 6823, 6824, 6825, 6827, 6829, 6830, 6831, 6832, 6834, 6835, 6837, 6839, 6840, 6841, 6842, 6843, 6845, 6847, 6849, 6850, 6851, 6852, 6853, 6854, 6857, 6859, 6870, 6871, 6872, 6873, 6874, 6875, 6879, 6890, 6891, 6892, 6893, 6894, 6895, 6897, 6901, 6902, 6903, 6904, 6905, 6907, 6908, 6910, 6912, 6913, 6914, 6915, 6917, 6918, 6920, 6921, 6923, 6924, 6925, 6927, 6928, 6930, 6931, 6932, 6934, 6935, 6937, 6938, 6940, 6941, 6942, 6943, 6945, 6947, 6948, 6950, 6951, 6952, 6953, 6954, 6957, 6958, 6970, 6971, 6972, 6973, 6974, 6975, 6978, 6980, 6981, 6982, 6983, 6984, 6985, 6987, 7012, 7013, 7014, 7015, 7016, 7018, 7019, 7021, 7023, 7024, 7025, 7026, 7028, 7029, 7031, 7032, 7034, 7035, 7036, 7038, 7039, 7041, 7042, 7043, 7045, 7046, 7048, 7049, 7051, 7052, 7053, 7054, 7056, 7058, 7059, 7061, 7062, 7063, 7064, 7065, 7068, 7069, 7081, 7082, 7083, 7084, 7085, 7086, 7089, 7091, 7092, 7093, 7094, 7095, 7096, 7098, 7102, 7103, 7104, 7105, 7106, 7108, 7109, 7120, 7123, 7124, 7125, 7126, 7128, 7129, 7130, 7132, 7134, 7135, 7136, 7138, 7139, 7140, 7142, 7143, 7145, 7146, 7148, 7149, 7150, 7152, 7153, 7154, 7156, 7158, 7159, 7160, 7162, 7163, 7164, 7165, 7168, 7169, 7180, 7182, 7183, 7184, 7185, 7186, 7189, 7190, 7192, 7193, 7194, 7195, 7196, 7198, 7201, 7203, 7204, 7205, 7206, 7208, 7209, 7210, 7213, 7214, 7215, 7216, 7218, 7219, 7230, 7231, 7234, 7235, 7236, 7238, 7239, 7240, 7241, 7243, 7245, 7246, 7248, 7249, 7250, 7251, 7253, 7254, 7256, 7258, 7259, 7260, 7261, 7263, 7264, 7265, 7268, 7269, 7280, 7281, 7283, 7284, 7285, 7286, 7289, 7290, 7291, 7293, 7294, 7295, 7296, 7298, 7301, 7302, 7304, 7305, 7306, 7308, 7309, 7310, 7312, 7314, 7315, 7316, 7318, 7319, 7320, 7321, 7324, 7325, 7326, 7328, 7329, 7340, 7341, 7342, 7345, 7346, 7348, 7349, 7350, 7351, 7352, 7354, 7356, 7358, 7359, 7360, 7361, 7362, 7364, 7365, 7368, 7369, 7380, 7381, 7382, 7384, 7385, 7386, 7389, 7390, 7391, 7392, 7394, 7395, 7396, 7398, 7401, 7402, 7403, 7405, 7406, 7408, 7409, 7410, 7412, 7413, 7415, 7416, 7418, 7419, 7420, 7421, 7423, 7425, 7426, 7428, 7429, 7430, 7431, 7432, 7435, 7436, 7438, 7439, 7450, 7451, 7452, 7453, 7456, 7458, 7459, 7460, 7461, 7462, 7463, 7465, 7468, 7469, 7480, 7481, 7482, 7483, 7485, 7486, 7489, 7490, 7491, 7492, 7493, 7495, 7496, 7498, 7501, 7502, 7503, 7504, 7506, 7508, 7509, 7510, 7512, 7513, 7514, 7516, 7518, 7519, 7520, 7521, 7523, 7524, 7526, 7528, 7529, 7530, 7531, 7532, 7534, 7536, 7538, 7539, 7540, 7541, 7542, 7543, 7546, 7548, 7549, 7560, 7561, 7562, 7563, 7564, 7568, 7569, 7580, 7581, 7582, 7583, 7584, 7586, 7589, 7590, 7591, 7592, 7593, 7594, 7596, 7598, 7601, 7602, 7603, 7604, 7605, 7608, 7609, 7610, 7612, 7613, 7614, 7615, 7618, 7619, 7620, 7621, 7623, 7624, 7625, 7628, 7629, 7630, 7631, 7632, 7634, 7635, 7638, 7639, 7640, 7641, 7642, 7643, 7645, 7648, 7649, 7650, 7651, 7652, 7653, 7654, 7658, 7659, 7680, 7681, 7682, 7683, 7684, 7685, 7689, 7690, 7691, 7692, 7693, 7694, 7695, 7698, 7801, 7802, 7803, 7804, 7805, 7806, 7809, 7810, 7812, 7813, 7814, 7815, 7816, 7819, 7820, 7821, 7823, 7824, 7825, 7826, 7829, 7830, 7831, 7832, 7834, 7835, 7836, 7839, 7840, 7841, 7842, 7843, 7845, 7846, 7849, 7850, 7851, 7852, 7853, 7854, 7856, 7859, 7860, 7861, 7862, 7863, 7864, 7865, 7869, 7890, 7891, 7892, 7893, 7894, 7895, 7896, 7901, 7902, 7903, 7904, 7905, 7906, 7908, 7910, 7912, 7913, 7914, 7915, 7916, 7918, 7920, 7921, 7923, 7924, 7925, 7926, 7928, 7930, 7931, 7932, 7934, 7935, 7936, 7938, 7940, 7941, 7942, 7943, 7945, 7946, 7948, 7950, 7951, 7952, 7953, 7954, 7956, 7958, 7960, 7961, 7962, 7963, 7964, 7965, 7968, 7980, 7981, 7982, 7983, 7984, 7985, 7986, 8012, 8013, 8014, 8015, 8016, 8017, 8019, 8021, 8023, 8024, 8025, 8026, 8027, 8029, 8031, 8032, 8034, 8035, 8036, 8037, 8039, 8041, 8042, 8043, 8045, 8046, 8047, 8049, 8051, 8052, 8053, 8054, 8056, 8057, 8059, 8061, 8062, 8063, 8064, 8065, 8067, 8069, 8071, 8072, 8073, 8074, 8075, 8076, 8079, 8091, 8092, 8093, 8094, 8095, 8096, 8097, 8102, 8103, 8104, 8105, 8106, 8107, 8109, 8120, 8123, 8124, 8125, 8126, 8127, 8129, 8130, 8132, 8134, 8135, 8136, 8137, 8139, 8140, 8142, 8143, 8145, 8146, 8147, 8149, 8150, 8152, 8153, 8154, 8156, 8157, 8159, 8160, 8162, 8163, 8164, 8165, 8167, 8169, 8170, 8172, 8173, 8174, 8175, 8176, 8179, 8190, 8192, 8193, 8194, 8195, 8196, 8197, 8201, 8203, 8204, 8205, 8206, 8207, 8209, 8210, 8213, 8214, 8215, 8216, 8217, 8219, 8230, 8231, 8234, 8235, 8236, 8237, 8239, 8240, 8241, 8243, 8245, 8246, 8247, 8249, 8250, 8251, 8253, 8254, 8256, 8257, 8259, 8260, 8261, 8263, 8264, 8265, 8267, 8269, 8270, 8271, 8273, 8274, 8275, 8276, 8279, 8290, 8291, 8293, 8294, 8295, 8296, 8297, 8301, 8302, 8304, 8305, 8306, 8307, 8309, 8310, 8312, 8314, 8315, 8316, 8317, 8319, 8320, 8321, 8324, 8325, 8326, 8327, 8329, 8340, 8341, 8342, 8345, 8346, 8347, 8349, 8350, 8351, 8352, 8354, 8356, 8357, 8359, 8360, 8361, 8362, 8364, 8365, 8367, 8369, 8370, 8371, 8372, 8374, 8375, 8376, 8379, 8390, 8391, 8392, 8394, 8395, 8396, 8397, 8401, 8402, 8403, 8405, 8406, 8407, 8409, 8410, 8412, 8413, 8415, 8416, 8417, 8419, 8420, 8421, 8423, 8425, 8426, 8427, 8429, 8430, 8431, 8432, 8435, 8436, 8437, 8439, 8450, 8451, 8452, 8453, 8456, 8457, 8459, 8460, 8461, 8462, 8463, 8465, 8467, 8469, 8470, 8471, 8472, 8473, 8475, 8476, 8479, 8490, 8491, 8492, 8493, 8495, 8496, 8497, 8501, 8502, 8503, 8504, 8506, 8507, 8509, 8510, 8512, 8513, 8514, 8516, 8517, 8519, 8520, 8521, 8523, 8524, 8526, 8527, 8529, 8530, 8531, 8532, 8534, 8536, 8537, 8539, 8540, 8541, 8542, 8543, 8546, 8547, 8549, 8560, 8561, 8562, 8563, 8564, 8567, 8569, 8570, 8571, 8572, 8573, 8574, 8576, 8579, 8590, 8591, 8592, 8593, 8594, 8596, 8597, 8601, 8602, 8603, 8604, 8605, 8607, 8609, 8610, 8612, 8613, 8614, 8615, 8617, 8619, 8620, 8621, 8623, 8624, 8625, 8627, 8629, 8630, 8631, 8632, 8634, 8635, 8637, 8639, 8640, 8641, 8642, 8643, 8645, 8647, 8649, 8650, 8651, 8652, 8653, 8654, 8657, 8659, 8670, 8671, 8672, 8673, 8674, 8675, 8679, 8690, 8691, 8692, 8693, 8694, 8695, 8697, 8701, 8702, 8703, 8704, 8705, 8706, 8709, 8710, 8712, 8713, 8714, 8715, 8716, 8719, 8720, 8721, 8723, 8724, 8725, 8726, 8729, 8730, 8731, 8732, 8734, 8735, 8736, 8739, 8740, 8741, 8742, 8743, 8745, 8746, 8749, 8750, 8751, 8752, 8753, 8754, 8756, 8759, 8760, 8761, 8762, 8763, 8764, 8765, 8769, 8790, 8791, 8792, 8793, 8794, 8795, 8796, 8901, 8902, 8903, 8904, 8905, 8906, 8907, 8910, 8912, 8913, 8914, 8915, 8916, 8917, 8920, 8921, 8923, 8924, 8925, 8926, 8927, 8930, 8931, 8932, 8934, 8935, 8936, 8937, 8940, 8941, 8942, 8943, 8945, 8946, 8947, 8950, 8951, 8952, 8953, 8954, 8956, 8957, 8960, 8961, 8962, 8963, 8964, 8965, 8967, 8970, 8971, 8972, 8973, 8974, 8975, 8976, 9012]\nn = int(input())\ncont = 0\nwhile True:\n if years[cont] > n:\n print(years[cont])\n break\n else:\n cont+=1\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e82fc4db9dcfc03724ba","document_content":"def getmask(x):\n ans = 0\n for i in range(2, x + 1):\n while x % (i * i) == 0:\n x \/\/= i * i\n if x % i == 0:\n ans ^= 1 << i\n x \/\/= i\n return ans\n\ndef main():\n maxn = 71\n n = int(input())\n a = [int(i) for i in input().split()]\n cnt = [0] * maxn\n for i in a:\n cnt[i] += 1\n masks = {}\n for i in range(1, maxn):\n if cnt[i]:\n masks[getmask(i)] = masks.get(getmask(i), 0) + cnt[i]\n while len(masks) > 1 or 0 not in masks:\n if not masks:\n print(0)\n return\n fixed = max(masks.keys())\n for i in list(masks.keys()):\n if i ^ fixed < i:\n masks[i ^ fixed] = masks.get(i ^ fixed, 0) + masks[i]\n masks[i] = 0\n masks[0] = masks.get(0, 0) + masks[fixed] - 1\n masks[fixed] = 0\n masks = {i: j for i, j in list(masks.items()) if j > 0}\n print(pow(2, masks[0], 10**9+7) - 1)\n \n \n \nmain()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"df4f20545274bd35b929","document_content":"from collections import defaultdict\ndef getmask(x):\n ans = 0\n for i in range(2, x + 1):\n while x % i == 0:\n x \/\/= i\n ans ^= 1 << i\n return ans\n\ndef main():\n maxn = 71\n n = int(input())\n a = [int(i) for i in input().split()]\n cnt = [0] * maxn\n for i in a:\n cnt[i] += 1\n masks = defaultdict(int)\n for i in range(1, maxn):\n masks[getmask(i)] += cnt[i]\n while masks[0] != sum(masks.values()):\n fixed = max(i for i in masks if masks[i])\n masks[0] -= 1\n for i in list(masks.keys()):\n if i ^ fixed < i:\n masks[i ^ fixed] += masks[i]\n masks[i] = 0\n print(pow(2, masks[0], 10**9+7) - 1)\n \n \n \nmain()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1b682c1647f85904916f","document_content":"n = int(input())\na = set(map(int, input().split()))\ns = []\np = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]\nfor i in a:\n b = 0\n for j in p:\n while i % j == 0:\n i \/\/= j\n b ^= 1 << j\n for j in s:\n b = min(b, b ^ j)\n if b > 0:\n s.append(b)\nprint(pow(2, n - len(s), 10 ** 9 + 7) - 1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6766184c0708981299b5","document_content":"n = int(input())\ns = []\np = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]\nfor i in set(map(int, input().split())):\n b = 0\n for j in p:\n while i % j == 0:\n i \/\/= j\n b ^= 1 << j\n for j in s:b=min(b,b^j)\n if b>0:s.append(b)\nprint(pow(2, n - len(s), 10 ** 9 + 7) - 1)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"de4ffea10069fbfa2e66","document_content":"from collections import *\n\nl = int(input())\nc = Counter(map(int, input().split()))\nt = defaultdict(int)\np = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]\n\nfor k, s in c.items():\n d = 0\n for i, q in enumerate(p):\n while k % q == 0:\n k \/\/= q\n d ^= 1 << i\n t[d] += s\n\nu = defaultdict(int)\nu[0] = 1\n\nfor x in t:\n if x: l -= 1\n if 0 < x < 2048:\n v = u.copy()\n for y in u: v[x ^ y] += u[y]\n u = v\n\ne = 1000000007\nprint((u[0] * pow(2, l, e) - 1) % e)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bc3157ee6ae4a4e79ae7","document_content":"n = int(input())\ns = []\np = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]\nfor k in set(map(int, input().split())):\n d = 0\n for q in p:\n while k % q == 0:\n k \/\/= q\n d ^= 1 << q\n for j in s: d = min(d, d ^ j)\n if d: s.append(d)\nprint(pow(2, n - len(s), 1000000007) - 1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6a583e2b8c8e784d89ff","document_content":"n = int(input())\n\ns = []\n\np = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]\n\nfor k in set(map(int, input().split())):\n\n d = 0\n\n for q in p:\n\n while k % q == 0:\n\n k \/\/= q\n\n d ^= 1 << q\n\n for j in s: d = min(d, d ^ j)\n\n if d: s.append(d)\n\nprint(pow(2, n - len(s), 1000000007) - 1)\n\n\n\n# Made By Mostafa_Khaled\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8a448be144ce64d5a4bb","document_content":"n = int(input())\n*a, = map(int, input().split())\nmod = 1000000007\nd = []\nprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]\nb = [0, 4, 8, 0, 32, 12, 128, 4, 0, 36,2048, 8, 8192, 132, 40, 0, 131072, 4, 524288, 32, 136, 2052, 8388608, 12, 0, 8196, 8, 128, 536870912, 44, 2147483648, 4, 2056, 131076, 160, 0, 137438953472, 524292, 8200, 36, 2199023255552, 140, 8796093022208, 2048,32, 8388612, 140737488355328, 8, 0,4, 131080, 8192, 9007199254740992, 12, 2080, 132, 524296, 536870916, 576460752303423488, 40, 2305843009213693952, 2147483652, 128, 0, 8224, 2060, 147573952589676412928, 131072, 8388616, 164]\nfor i in set(a):\n c = b[i - 1]\n for j in d:\n c = min(c, c ^ j)\n if c > 0:\n d.append(c)\nprint(pow(2, n - len(d), mod) - 1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"be5c36f77ec1c3035f59","document_content":"from sys import stdin\n\n\ndef find_prime(max_value):\n assert max_value >= 2\n result = [2]\n for i in range(3, max_value):\n state = 1\n for item in result:\n if item * item > i:\n break\n elif i % item == 0:\n state = -1\n break\n if state == 1:\n result.append(i)\n return result\n\n\nmodule = int(10e8) + 7\n\nn = int(stdin.readline())\nA = list(map(int, stdin.readline().split()))\nnumber = [0 for i in range(70)]\nfor item in A:\n number[item - 1] += 1\n\nprime_list = find_prime(70)\n\nprime_map = {}\nfor i in range(2, 70 + 1):\n result = 0\n for item in prime_list:\n cur = i\n num = 0\n while cur % item == 0:\n num += 1\n cur = int(cur \/ item)\n result = result * 2 + num % 2\n prime_map[i] = result\n\nnumber_dic = {0: 1}\nsum_time = 0\nfor i in range(2, 70 + 1):\n if number[i - 1] >= 1:\n mask = prime_map[i]\n state = 1\n new_number_dic = number_dic.copy()\n for key, value in list(new_number_dic.items()):\n new_key = key ^ mask\n if new_key in number_dic:\n number_dic[new_key] += value\n else:\n number_dic[new_key] = value\n number_dic[new_key] %= module\n sum_time += (number[i - 1] - 1)\n\nresult = number_dic[0]\n\nfor j in range(number[0] + sum_time):\n result *= 2\n result %= module\nprint(result-1)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f9811dd3c751819baf82","document_content":"from collections import defaultdict\n #from collections import defaultdict\ndef getmask(x):\n ans = 0\n for i in range(2, x + 1):\n while x % i == 0:\n x \/\/= i\n ans ^= 1 << i\n return ans\n \ndef main():\n maxn = 71\n #maxn = 71\n n = int(input())\n #n = int(input())\n a = [int(i) for i in input().split()]\n cnt = [0] * maxn\n for i in a:\n cnt[i] += 1\n masks = defaultdict(int)\n for i in range(1, maxn):\n masks[getmask(i)] += cnt[i]\n while masks[0] != sum(masks.values()):\n fixed = max(i for i in masks if masks[i])\n masks[0] -= 1\n for i in list(masks.keys()):\n if i ^ fixed < i:\n masks[i ^ fixed] += masks[i]\n masks[i] = 0\n print(pow(2, masks[0], 10**9+7) - 1)\n \n \n \nmain()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a75ec762853b59b7d287","document_content":"n = int(input())\nmoves = input()\n\nturns_vasnja = int((len(moves)-1) \/ n)\n\ncount = 0\nfor i in range(1, turns_vasnja+1):\n if moves[n * i - 3] == moves[n * i - 2] == moves[n * i - 1]:\n count += 1\n\nprint(count)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"86501c2a5abb90c69d7e","document_content":"n=int(input())\n\ns=input()\nnn=len(s)\nans=0\nfor i in range(n,nn,n):\n if(s[i-1]+s[i-2]+s[i-3]=='aaa' or s[i-1]+s[i-2]+s[i-3]=='bbb'):\n ans+=1\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cdb52f01b6be21694a75","document_content":"n = int(input())\ns = input().strip()\npl = 0\nans = 0\nfor q in range(len(s)):\n if q>=3 and pl==0:\n if s[q-3]==s[q-2]==s[q-1]:\n ans+=1\n pl = (pl+1) % n \nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"47024c45ed9e2de7513c","document_content":"n = int(input()) \ns = input()\nans = 0\nfor i in range(n, len(s), n):\n if s[i - 3:i] in ('aaa', 'bbb'):\n ans += 1\nprint(ans) \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"05d0fefbd154184addcd","document_content":"n = int(input())\ns = input()\nans = 0\nfor i in range(len(s)):\n if i % n == 0 and i >= 3:\n if s[i-1] == s[i-2] == s[i-3]:\n ans += 1\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e6e2c0234ce05290ad4d","document_content":"cnt, n, ans = 1, int(input()), 0\ns = input()\nfor i in range(1, len(s)):\n\tif cnt == 0 and s[i - 1] == s[i - 2] == s[i - 3]:\n\t\tans += 1\n\tcnt += 1\n\tif cnt == n:\n\t\tcnt = 0\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"831cbe4f672ee5e79787","document_content":"n = int(input())\nstring = input()\ncount = 0\ni = n\nwhile i < len(string):\n flag = False\n if string[i - 1] == string[i - 2] and string [i - 2] == string[i - 3] and i >= 3:\n flag = True\n if flag:\n count += 1\n i += n\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bcd4e2b896da61b50562","document_content":"a=int(input())\ns=input()\nn=0\nfor i in range(a,len(s),a):\n if s[i-2]==s[i-1] and s[i-1]==s[i-3] :\n n+=1 \nprint(n)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2140dc4ea923b0660526","document_content":"import sys\nfin = sys.stdin\n\nn = int(fin.readline())\nb = fin.readline().strip()\nm = len(b)\n\nres = 0\nfor i in range(n, m, n):\n if b[i - 3] == b[i - 2] == b[i - 1]:\n res += 1\n\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4deaf9fbbd39b7d8cd18","document_content":"n = int(input())\ns = input()\ncnt = 0\nfor i in range(len(s))[n::n]:\n if s[i-1] == s[i-2] and s[i-1] == s[i-3]:\n cnt += 1\nprint(cnt)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0565a95c4100be1ef09b","document_content":"n = int(input())\ns = input().strip()\nans = 0\nfor i in range(n, len(s), n):\n ans += s[i - 3:i] == \"bbb\" or s[i - 3:i] == 'aaa'\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6727e3a65cf14e1b9abd","document_content":"n=int(input())\ns=input()\na,b=n,0\nwhile a4:\n c=n\n while c<=(l-1):\n str1=str[c-3:c]\n if str1=='aaa' or str1=='bbb':\n count+=1\n c+=n\n print(count)\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0db9a6d9081f701170a3","document_content":"n = int(input())\ns = input()\ni = n\nans = 0\nwhile i < len(s):\n\tif s[i - 1] == s[i - 2] and s[i - 2] == s[i - 3]:\n\t\tans += 1\n\ti += n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"53db164429ac7a038894","document_content":"n = int(input())\nmoves = input()\ni = n\ncount = 0\nwhile(i < len(moves)):\n m = moves[i - 1] \n if(m == moves[i - 2] and m == moves[i - 3] and m == moves[i - 3]):\n count += 1\n i += n\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fc402a1512a4ed4bc7c9","document_content":"n = int( input() )\ns = input()\ni=n\nl = len(s)\ntot = 0\nwhile i 2 and not i % n and s[i - 1] == s[i - 2] == s[i - 3]:\n ans += 1\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"503f80952f4e4011657c","document_content":"3\n\nn = int(input())\ns = input()\nprint(len([1 for i in range(n, len(s), n) if len(set(list(s[i - 3:i]))) == 1]))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bd59f6c67e3f419c4287","document_content":"n = int(input())\ns = str(input())\n\nsl = len(s)\nd = 0\n\nfor i in range(n, sl, n):\n if s[i-1] == s[i-2] and s[i-1] == s[i-3]:\n d += 1\n\nprint(d)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3c36abdbc857dc441a75","document_content":"#332A Down the Hatch!\n\nn = int(input())\nactions = input()\nglasses = 0\nfor i in range(n, len(actions), n):\n\tif actions[i-1] == actions[i-2] == actions[i-3]:\n\t\tglasses += 1\nprint(glasses)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4a35343998d136a5abcb","document_content":"s, n, t = 0, int(input()), input()\nprint(sum(t[i - 3: i] in ['aaa', 'bbb'] for i in range((3 \/\/ n + 1) * n , len(t), n)))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f8c70e6c6a8ede8cbd4e","document_content":"n, m, k = input().split(' ')\nn = int(n)\nm = int(m)\nk = int(k)\nind = []\npre = []\n\nfor _ in range(n):\n s = input()\n ind.append([])\n for i, c in enumerate(s):\n if c == '1':\n ind[-1].append(i)\n\nfor i in range(n):\n pre.append([])\n for j in range(k + 1):\n pre[i].append([])\n if len(ind[i]) > j:\n pre[i][j] = ind[i][-1] - ind[i][0] + 1\n else:\n pre[i][j] = 0\n continue\n for x in range(j + 1):\n y = len(ind[i]) - 1 - j + x\n\n if y >= x and ind[i][y] - ind[i][x] + 1 < pre[i][j]:\n pre[i][j] = ind[i][y] - ind[i][x] + 1\ndp = [[]]\n\nfor i in range(k + 1):\n dp[0].append(pre[0][i])\n\n\nfor i in range(1, n):\n dp.append([])\n for j in range(0, k + 1):\n dp[i].append(pre[i][j] + dp[i - 1][0])\n for z in range(j + 1):\n dp[i][j] = min(dp[i][j], dp[i - 1][z] + pre[i][j - z])\n\nprint(dp[n - 1][k])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"710b2784b1c7d0b8a256","document_content":"import queue\nintput = lambda:list(map(int, input().split()))\n\nN, M, K = intput()\nht = [[] for _ in range(N)]\nfor _ in range(N):\n day = input()\n ht[_] = [i for i in range(M) if day[i] == '1']\n\n# req[i][j] -- required hours for day i if j lessons skipped\n# dp[i][j] -- required hours up to day i if j lesson skipped\n# dp[i+1][j+z] = dp[i][j] + req[i][z]\n\ntc = [1,2,3,8,9]\n# just return dp[-1][-1]\nreq = [[0 for _ in range(M+1)] for __ in range(N)]\ndp = [[0 for _ in range(K+1)] for __ in range(N)]\nfor i in range(N):\n # cost to skip j lessons today\n for j in range(len(ht[i])):\n req[i][j] = ht[i][-1] - ht[i][0] + 1 # default large num\n # if start at the first-th lesson\n for first in range(j+1):\n last = first + len(ht[i])-j-1\n cost = ht[i][last]-ht[i][first]+1\n if last >= first:\n req[i][j] = min(req[i][j], cost)\n\nfor i in range(min(len(req[0]), len(dp[0]))):\n dp[0][i] = req[0][i]\nfor i in range(1, N):\n # total skipped up to this point\n for j in range(K+1):\n dp[i][j] = dp[i-1][j] + req[i][0]\n # additional skipped for this day -- min of (skips left, curr skips, num lessons)\n for z in range(1+min(j, len(ht[i]))):\n dp[i][j] = min(dp[i][j], dp[i-1][j-z] + req[i][z])\n\n# print('{}\\n{}'.format(req,dp))\nprint(dp[-1][-1])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fdc02f81962e6f453bba","document_content":"R = lambda: map(int, input().split())\nn, m, k = R()\ncls = [list(i for i, x in enumerate(map(int, input())) if x) for _ in range(n)]\ndp = [[n * m] * (k + 1) for i in range(n + 1)]\ndp.append([0] * (k + 1))\nfor i in range(n):\n row = cls[i]\n c2l = [m + 1] * (m + 1)\n c2l[0] = row[-1] - row[0] + 1 if row else 0\n c2l[len(row)] = 0\n for r in range(len(row)):\n for l in range(r + 1):\n c2l[len(row) - (r - l + 1)] = min(c2l[len(row) - (r - l + 1)], row[r] - row[l] + 1)\n for j in range(k + 1):\n for c, l in enumerate(c2l):\n if j + c <= k and l < m + 1:\n dp[i][j] = min(dp[i][j], dp[i - 1][j + c] + l)\nprint(min(dp[n - 1]))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4d317da2087a72a9d1bb","document_content":"def min_sub_array(day, k):\n if not day:\n return [0] * (k + 1)\n n = len(day)\n best = [float('inf')] * (n + 1)\n best[0] = 0\n best[1] = 1\n for size in range(2, n + 1):\n for i in range(n + 1 - size):\n best[size] = min(best[size], day[i + size - 1] - day[i] + 1)\n output = [0] * (k + 1)\n for i in range(k + 1):\n if n - i > 0:\n output[i] = best[n - i]\n return output\n\n\nN, M, K = list(map(int, input().split()))\n\nday = [i for i, val in enumerate(input()) if val == '1']\nbest = min_sub_array(day, K)\n\nfor _ in range(N - 1):\n day = [i for i, val in enumerate(input()) if val == '1']\n new_day_best = min_sub_array(day, K)\n\n new_best = [float('inf')] * (K + 1)\n for i in range(K + 1):\n for j in range(i + 1):\n new_best[i] = min(new_best[i], new_day_best[j] + best[i - j])\n best = new_best\nprint(best[K])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e1cc2a47a8dbb43c7024","document_content":"import sys\ninput = sys.stdin.readline\n\ndef int_array():\n\treturn list(map(int, input().strip().split()))\n\ndef float_array():\n\treturn list(map(float, input().strip().split()))\n\ndef str_array():\n\treturn input().strip().split()\nfrom collections import Counter\nimport math\nimport bisect\nfrom collections import deque\nn,m,lesson=int_array()\ndp=[[250005 for i in range(lesson+2)]for j in range(n+1)]\ndays=[[] for i in range(n)]\nfor i in range(n):\n\ts=input()\n\tfor j in range(m):\n\t\tif s[j]==\"1\":\n\t\t\tdays[i].append(j+1)\n\nm=[[250005 for i in range(lesson+2)]for j in range(n+1)]\nfor i in range(n):\n\tfor j in range(lesson+1):\n\t\tif j<=len(days[i]):\n\t\t\tif j==len(days[i]):\n\t\t\t\tm[i][j]=0\n\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tfor k in range(0,j+1):\n\t\t\t\t\tvar=days[i][0+k]\n\t\t\t\t\tvar1=days[i][-1*max(1,1+(j-k))]\n\t\t\t\t\tm[i][j]=min(m[i][j],var1-var+1)\n\n\n\nfor i in range(lesson+1):\n\tdp[0][i]=m[0][i]\nfor i in range(1,n):\n\tfor j in range(lesson+1):\n\t\tfor k in range(j+1):\n\n\t\t\tdp[i][j]=min(dp[i][j],dp[i-1][j-k]+m[i][k])\n\t\t\t#dp[i][j] = min(dp[i][j], dp[i - 1][k]+m[i][j-k])\n\nprint(min(dp[n-1]))\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9bc96babdebe47a00f01","document_content":"import sys\n\nn, m, k = list(map(int, input().split()))\ntable = [input() for _ in range(n)]\n\ndp = [0]*(k+1)\n\nfor a in table:\n one = []\n for i in range(m):\n if a[i] == '1':\n one.append(i)\n\n if not one:\n continue\n\n ni = len(one)\n subdp = [10**9] * (ni+1)\n subdp[-1] = 0\n\n for i in range(ni):\n for j in range(i, ni):\n subdp[ni-(j-i+1)] = min(subdp[ni-(j-i+1)], one[j]-one[i]+1)\n\n next_dp = [10**9]*(k+1)\n for i in range(k, -1, -1):\n for j in range(ni+1):\n if i+j > k:\n break\n next_dp[i+j] = min(next_dp[i+j], dp[i] + subdp[j])\n dp = next_dp\n\nprint(min(dp))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c6ffc09137f47d339306","document_content":"3\n\ns = input()\nalph = ''.join([chr(ord('a') + x) for x in range(26)])\nl = [[]]\nfor x in s:\n if x not in alph:\n l[-1].append(x)\n else:\n if len(l[-1]):\n l.append([])\nl = list([''.join(x) for x in l])\nansa = 0\nansb = 0\nfor t in l:\n if len(t) > 2 and t[-3] == '.':\n ansb += int(t[-2:])\n t = t[:-3]\n ansa += int(''.join(t.split('.')))\nansa += ansb \/\/ 100\nansb %= 100\nansa = str(ansa)\nans = []\nlast = len(ansa)\nfor x in range(len(ansa) - 3, -1, -3):\n ans.append(ansa[x:last])\n last = x\nif last != 0:\n ans.append(ansa[:last])\nans.reverse()\nif ansb != 0:\n ans.append(\"%02d\" % ansb)\nprint(\".\".join(ans))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"436bd067e747483511bd","document_content":"s = input()\nl = ''.join(list((map(lambda x : x if ord('0') <= ord(x) <= ord('9') or x == '.' else ' ', list(s)))))\n\ndef readnum(s):\n if len(s) >= 3 and s[-3] == '.':\n a = s[:-3]\n b = s[-2:]\n else:\n a = s\n b = '00'\n a = ''.join(list(filter(lambda x : x != '.', a)))\n return (a,b)\nl = list(map(readnum,l.split()))\na,b = (0,0)\nfor (x,y) in l:\n a += int(x)\n b += int(y)\na += b\/\/100\nb = b%100\n\na = str(a)\n\nna = ''\nnd = 0\nfor c in a[::-1]:\n if nd % 3 == 0 and len(na) != 0:\n na = '.' + na\n na = c + na\n nd += 1\n\nprint(na, end='')\nif b:\n print('.%02d' % b)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a27d0f2e2d7ab11bae12","document_content":"# You lost the game.\ns = str(input())\nn = len(s)\ni = 0\nr = 0\nA = \"0123456789.\"\nwhile i < n:\n while A.count(s[i]) == 0:\n i += 1\n p = \"\"\n while i < n and A.count(s[i]):\n p += s[i]\n i += 1\n E = list(p.split(\".\"))\n #print(p,E)\n e = len(E)\n if len(E[e-1]) == 2:\n v = 0\n for j in range(e-1):\n v = v*1000 + int(E[j])\n v = v*100 + int(E[e-1]) \n else:\n v = 0\n for j in range(e):\n v = v*1000 + int(E[j])\n v *= 100\n r += v\n#print(r)\nR = str(r)\nm = len(R)-2\nres = \"\"\nif m > 0:\n res = R[:m%3]\n for i in range(m%3,m,3):\n if i>0:\n res += \".\"+R[i:i+3]\n else:\n res += R[i:i+3]\nif m <= 0:\n res += \"0\"\nif m == -1:\n res += \".0\"+R[m+1]\nelif R[m:m+2] != \"00\":\n res += \".\" + R[m:m+2]\n\nprint(res)\n\n \n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1ad53255cba715e8452f","document_content":"s = input()\ncurnum = 0\nans = 0\ndr = 0\nn = len(s)\ns += 'aaa'\ni = 0\nwhile i < n:\n #print(i, curnum)\n if '0' <= s[i] <= '9':\n curnum = 10 * curnum + int(s[i])\n elif s[i] == '.':\n if ('0' <= s[i + 1] <= '9') and ('0' <= s[i + 2] <= '9') and not('0' <= s[i + 3] <= '9'):\n dr += (10 * int(s[i + 1]) + int(s[i + 2]))\n i = i + 2\n else:\n ans += curnum\n curnum = 0\n i += 1\nans += curnum\nans += dr \/\/ 100\nans2 = dr % 100\nif ans2 == 0:\n ans2 = ''\nelif ans2 < 10:\n ans2 = '.0' + str(ans2)\nelse:\n ans2 = '.' + str(ans2)\nans = int(ans)\nans = str(ans)\nnans = ''\nfor i in range(len(ans)):\n if i % 3 == 0 and i != 0:\n nans += '.'\n nans += ans[len(ans) - 1 - i]\nprint(nans[::-1] + ans2)\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"636b0e8ae099fef38d86","document_content":"s = input()\nname = False\ns2 = '0'\ncnt = 0\npointsPresent = False\nsum = 0\nfor i in range(len(s)):\n if s[i] in \"1234567890.\":\n name = False\n else:\n name = True\n if name:\n if cnt == 3 or not pointsPresent:\n sum += int(s2) * 100\n else:\n sum += int(s2)\n s2 = \"0\"\n cnt = 0\n pointsPresent = False\n else:\n if s[i] != '.':\n s2 += s[i]\n cnt += 1\n else:\n cnt = 0\n pointsPresent = True\nif cnt == 3 or not pointsPresent:\n sum += int(s2) * 100\nelse:\n sum += int(s2)\n\nif sum < 10:\n print(\"0.0\" + str(sum))\nelif sum < 100:\n print(\"0.\" + str(sum))\nelse:\n if sum % 100 == 0:\n sum \/\/= 100\n c = -1\n else:\n c = 0\n s3 = str(sum)\n for i in range(len(s3) - 1, -1, -1):\n c += 1\n if c == 3:\n c = 0\n s3 = s3[:i + 1] + '.' + s3[i + 1:]\n print(s3)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7bd2e5609536b9c9e3f3","document_content":"import sys, math\ns = input()\ngg = 0\ni = 0\ndbl = 0\nwhile i < len(s):\n if 'a' <= s[i] <= 'z':\n i += 1\n continue\n h = '000'\n while i < len(s) and not 'a' <= s[i] <= 'z':\n h += s[i]\n i += 1\n ans = ''\n if h[-3] == '.':\n dbl += int(h[-2:])\n h = h[:-3] \n for z in h:\n if z != '.':\n ans += z\n gg += int(ans)\n#print(gg, dbl)\ndd = []\ngg += dbl \/\/ 100\ndbl = dbl % 100\ngg = gg\nif dbl != 0:\n dbl = str(dbl)\n while len(dbl) < 2:\n dbl = '0' + dbl\n dd.append(dbl)\n#print(dd)\nif gg == 0:\n dd.append(0)\nwhile gg != 0:\n dd.append(str(gg % 1000))\n if (gg >= 1000):\n while len(dd[-1]) < 3:\n dd[-1] = '0' + dd[-1]\n gg \/\/= 1000\ndd.reverse()\nprint(*dd, sep = '.')\n \n\n \n \n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"991ce594d55afdab5298","document_content":"s = input().strip()\ndc = set()\n\nfor i in range(ord('0'), ord('9') + 1):\n dc.add(chr(i))\n\ndc.add('.')\n\ns1 = \"\"\nfor i in range(1, len(s)):\n if s[i] in dc and s[i - 1] not in dc:\n s1 += \" \"\n if s[i] in dc:\n s1 += s[i]\n\na = []\ns = s1.split(' ')\nrub = 0\ncop = 0\nfor i in s:\n if i != \"\":\n left = \"00\"\n right = \"\"\n if len(i) >= 4 and i[-3] == '.':\n left = i[-2:]\n right = i[:-3]\n else:\n right = i\n rt = \"\"\n for j in right:\n if j != '.':\n rt += j\n rub += int(rt)\n cop += int(left)\n\nrub += cop \/\/ 100\ncop -= (cop \/\/ 100) * 100\nanss = \"\"\nrubs = str(rub)\ncnt = 1\nfor i in range(len(rubs) - 1, -1, -1):\n anss += rubs[i]\n if cnt % 3 == 0:\n anss += '.'\n cnt += 1\nanss = list(anss)\nanss.reverse()\nif anss[0] == '.':\n anss = anss[1:]\nanss = ''.join(anss)\nprint(anss, end='')\nif cop != 0:\n print('.', end='')\n if cop < 10:\n print(0, end='')\n print(cop, end='')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a098636ebf8f2022bc97","document_content":"#!\/usr\/bin\/env python3\n\nimport decimal\nimport itertools\n\n\ndef is_digit_or_dot(char):\n return char.isdigit() or char == \".\"\n\n\ndef compute(bill):\n prices = []\n for k, v in itertools.groupby(bill, is_digit_or_dot):\n if not k:\n continue\n segments = \"\".join(v).split(\".\")\n if len(segments[-1]) == 2:\n cent = decimal.Decimal(\".\" + segments[-1])\n dollar = decimal.Decimal(\"\".join(segments[:-1]))\n price = cent + dollar\n else:\n price = decimal.Decimal(\"\".join(segments))\n prices.append(price)\n amount = sum(prices)\n dollar, cent = divmod(amount, 1)\n ans = \"{:,d}\".format(int(dollar)).replace(\",\", \".\")\n if cent > 0:\n ans += str(cent)[1:]\n return ans\n\n\ndef main():\n print(compute(input()))\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e5a55ebf9690d80138b3","document_content":"def f(t):\n if t == '':\n return 0\n m = len(t)\n if '.' not in t:\n return int(t) * 100\n if t[-3] != '.':\n t += '00'\n t2 = ''.join([i for i in t if i != '.'])\n return int(t2)\n\ndef wr(x):\n if x < 100:\n res = '0.'\n if x < 10: res += '0'\n res += str(x)\n return res\n x = str(x)\n m = len(x)\n res = x[-2:]\n for i in range(m - 2, 2, -3):\n res = x[i - 3:i] + '.' + res\n res = x[0: (m - 2) % 3] + '.' + res\n if res[0] == '.': res = res[1:]\n if res[-2:] == '00': res = res[:-3]\n return res\n\ns = input() + '_'\nnum = '1234567890.'\nans = 0\nn = len(s)\ncur = ''\nfor i in range(n):\n if s[i] not in num:\n ans += f(cur)\n cur = ''\n else:\n cur += s[i]\nprint(wr(ans))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7eedaf8803d33ec61efc","document_content":"s = input()\nans = 0\nd = \"\"\nfor i in range(len(s)):\n if s[i] in \"0123456789.\":\n d += s[i]\n else:\n si = \"\"\n if len(d):\n for j in range(len(d)):\n if d[j] != \".\":\n si += d[j]\n si1 = int(si)\n if (len(d) >= 3 and d[-3] != \".\") or len(d) < 3:\n si1 *= 100\n #print(si1)\n ans += si1\n d = \"\"\nsi = \"\"\nfor j in range(len(d)):\n if d[j] != \".\":\n si += d[j]\n si1 = int(si)\nif (len(d) >= 3 and d[-3] != \".\") or len(d) < 3:\n si1 *= 100\nans += si1\nif ans < 10:\n print(\"0.0{}\".format(ans))\nelif ans < 100:\n print(\"0.{}\".format(ans))\nelse:\n ansl = str(ans)[::-1]\n ansi = ansl[0] + ansl[1] + \".\"\n for i in range(2, len(ansl)):\n if i % 3 == 2 and i != 2:\n ansi += \".\"\n ansi += ansl[i]\n if ans % 100 == 0:\n a = ansi[::-1]\n print(a[:-3])\n else:\n print(ansi[::-1])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f70fa87fcd01b38f1d4e","document_content":"\nlat='qwertyuiopasdfghjklzxcvbnm'\nlats=[]\nlats+=lat\nc=str(input())\nfor i in lats:\n c=c.replace(i,' ')\nc=c.split()\n#print(c)\n\nk=0\nfor i in c:\n j=int(i.replace('.',''))\n i=i.replace('.',' ')\n \n i=i.split()\n if len(i[len(i)-1])!=2 or len(i)==1:\n j*=100\n #print(j)\n k+=j\n#print(k)\nprint(format(k\/\/100,',d').replace(',','.'),end='')\nif k%100!=0:\n print(\".%02d\" % (k%100))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9669128b0c5ce9de8411","document_content":"s = input().strip()\ni = 0\nalph = 'abcdefjhigklmnopqrstuwvxyz'\nans = 0\nwhile i < len(s):\n if s[i] in alph:\n i += 1\n else:\n j = i\n while j < len(s) and (s[j] in '1234567890' or s[j] == '.'):\n j += 1\n c = s[i:j]\n fl = False\n for k in range(len(c) - 1, -1, -1):\n if c[k] == '.':\n fl = True\n if len(c) - k - 1 == 3:\n c += '00'\n break\n if not fl:\n c += '00'\n a = ''\n for k in c:\n if k != '.':\n a = a + k\n #print(a)\n ans += int(a)\n i = j\nan = str(ans)\na = ''\nif len(an) < 3:\n an = '0' * (3 - len(an)) + an\na += an[-1]\na += an[-2]\na += '.'\ni = 0\n#print(an)\nfor k in range(len(an) - 3, -1, -1):\n a += an[k]\n i += 1\n if i == 3 and k > 0:\n a += '.'\n i = 0\nfl = False\nif ans % 100 == 0:\n fl = True\n\nfor i in range(len(a) - 1, -1, -1):\n if not fl or i > 2:\n print(a[i], end='')\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"740600d624f8f0d85d09","document_content":"s = input().rstrip()\nfor i in range(ord('a'), ord('z') + 1):\n s = 'z'.join(s.split(chr(i)))\ns = list(s.split('z'))\nans = 0\nans2 = 0\nfor i in s:\n if len(i) == 0:\n continue\n q = i.split('.')\n if len(q) == 1 or len(q[-1]) == 3:\n ans += int(''.join(q))\n else:\n ans += int(''.join(q[:len(q)-1]))\n ans2 += int(q[-1])\nans += ans2 \/\/ 100\nans2 %= 100\nd = ''\nif ans2 != 0:\n d = str(ans2)\n d = '.' + '0' * (2 - len(d)) + d\na = []\nans = int(ans)\nwhile ans >= 1000:\n a.append('.' + '0' * (3 - len(str(ans % 1000))) + str(ans % 1000))\n ans \/\/= 1000\na.append(str(ans))\na.reverse()\nprint(''.join(a) + d)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"647dffe29f5e1787764b","document_content":"from decimal import *\n\n# newstr = oldstr.replace(\"M\", \"\")\n\ndef add(l):\n\tnum = list()\n\tfor v in l:\n\t\tif v != '.':\n\t\t\tnum.append(v)\n\tnum = int(''.join(num))\n\tif len(l) >= 3 and l[-3] == '.':\n\t\treturn num\n\treturn num * 100\n\ndef solve():\n\ts = input()\n\tres = 0\n\tl = list()\n\tfor c in s:\n\t\tif c.islower():\n\t\t\tif len(l) > 0: res += add(l)\n\t\t\tl = list()\n\t\telse:\n\t\t\tl.append(c)\n\tif len(l) > 0: res += add(l)\n\treturn res\n\ndef prt(n):\n\tn = str(n)\n\tn = n[::-1]\n\tfirst = True\n\tres = \"\"\n\twhile len(n) > 0:\n\t\tif first:\n\t\t\ts = n[:2][::1] if len(n) >= 2 else n[:1] + '0'\n\t\t\tres += s\n\t\t\tres += '.'\n\t\t\tn = n[len(s) :]\n\t\telse:\n\t\t\ttmp = \"\"\n\t\t\tfor i in range(3):\n\t\t\t\tif len(n) == 0:\n\t\t\t\t\tbreak\n\t\t\t\ttmp += n[0]\n\t\t\t\tn = n[1:]\n\t\t\ttmp += '.'\n\t\t\tres += tmp\n\n\t\tfirst = False\n\n\tres = res[::-1]\n\n\tif len(res) == 3:\n\t\tres = '0' + res\n\telse:\n\t\tif res[0] == '.':\n\t\t\tres = res[1:]\n\tif len(res) >= 3 and res[-1] == '0' and res[-2] == '0' and res[-3] == '.':\n\t\tres = res[:-3]\n\treturn res\n\nprint(prt(solve()))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"140e3167d833d2332196","document_content":"q=input()\na=[]\nw=len(q)\ni=w-1\nwhile i>0:\n\tif '0'<=q[i]<='9':\n\t\tj=i-1\n\t\twhile not('a'<=q[j]<='z'):\n\t\t\tj-=1\n\t\ta.append(q[j+1:i+1])\n\t\ti=j\n\ti-=1\ns=0\nfor i in a:\n\tl=len(i)\n\tif l>2:\n\t\tif i[l-3]=='.':\n\t\t\ts+=int(i[l-2:])\n\t\t\ti=i[:l-3]\n\t\ti=i.replace('.','')\n\ts+=int(i)*100\nd=''\nr=s\nif s%100!=0:\n\td='.'+str(s%100)\nif len(d)==2:\n\td=d[0]+'0'+d[1]\ns\/\/=100\nrt=s\ntr=d\nwhile s\/\/1000!=0:\n\tt=str(s%1000)\n\tif len(t)==1:\n\t\tt='.00'+t\n\telif len(t)==2:\n\t\tt='.0'+t\n\telse:\n\t\tt='.'+t\n\td=t+d\n\ts\/\/=1000\nif s!=0:\n\tt=str(s%1000)\n\td=t+d\nelse:\n\td=d[1:]\nif len(d)==2:\n\td='0.'+d\nelif d=='':\n\td='0'\nprint(d)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f86bc3a4e766e210160c","document_content":"s = input()\nrub = 0\nkop = 0\ncur = 0\nlen_cur = 0\nfor i in range(len(s)):\n if 122 >= ord(s[i]) >= 97:\n if len_cur == 2:\n kop += cur - cur \/\/ 100 * 100\n rub += cur \/\/ 100\n else:\n rub += cur\n cur = 0\n len_cur = 0\n elif 57 >= ord(s[i]) >= 48:\n cur = 10 * cur + int(s[i])\n len_cur += 1\n elif s[i] == '.':\n len_cur = 0\n \nif len_cur == 2:\n kop += cur - cur \/\/ 100 * 100\n rub += cur \/\/ 100\nelse:\n rub += cur\n \nrub += kop \/\/ 100\nkop = kop - kop \/\/ 100 * 100\n\nif kop < 10: kop = '0' + str(kop)\nkop = str(kop)\nsrub = ''\nif len(str(rub)) % 3 != 0:\n srub += str(str(rub)[:len(str(rub)) % 3]) + '.'\n \nc = 0\nfor i in range(len(str(rub)) % 3, len(str(rub))):\n c += 1\n srub += str(rub)[i]\n if c == 3:\n srub += '.'\n c = 0\n\nif kop == '00':\n print(srub[:-1])\nelse:\n print(srub + kop)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e30cf52581dca7ca3fef","document_content":"from math import *\n\ndef remd(x):\n y = []\n for i in x:\n if i != '.':\n y.append(i)\n return ''.join(y)\n\ndef parse(x):\n if '.' not in x:\n return int(x)\n i = len(x) - 1\n cnt = 0\n while x[i] != '.':\n i -= 1\n cnt += 1\n if cnt == 2:\n x1 = int(remd(x[:i]))\n x2 = int(x[i + 1:])\n return x1 + x2 \/ 100\n else:\n return int(remd(x))\n\ndef format(y):\n y1 = int(y)\n y2 = round((y - y1) * 100)\n\n y1 = str(y1)\n yy = []\n for i in range(len(y1)):\n yy.append(y1[len(y1) - 1 - i])\n if i % 3 == 2 and i != len(y1) - 1:\n yy.append('.')\n yy.reverse()\n yy = ''.join(yy)\n\n if y2 != 0:\n yy += '.'\n yy += ('%02d' % y2)\n return yy\n\ns = input()\npr = []\ncur = []\nfor i in s:\n if '0' <= i <= '9' or i == '.':\n cur.append(i)\n else:\n if len(cur) > 0:\n pr.append(''.join(cur))\n cur = []\nif len(cur) > 0:\n pr.append(''.join(cur))\n\nsm = 0\nfor i in pr:\n sm += parse(i)\nprint(format(sm))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5bf6d6838f6e6bbb8081","document_content":"def fr(s):\n ans = 0\n was = False\n s = s.split('.')\n if len(s[-1]) == 2 and len(s) != 1:\n ans += int(s[-1]) \/ 100\n was = True\n \n s = s[::-1]\n for i in range(was, len(s)):\n ans += int(s[i]) * (10 ** (3 * (i - was)))\n \n return ans\n\n\ndef to(n):\n ans = []\n was = False\n if int(n) != n:\n tmp = str(n - int(n))\n tmp = tmp[2:]\n try:\n if tmp[2]:\n if tmp[2] >= \"5\":\n tmp = tmp[0] + str(int(tmp[1]) + 1)\n else:\n tmp = tmp[:2]\n except:\n pass\n if len(tmp) == 1:\n tmp += '0'\n ans.append(tmp)\n was = True\n n = int(n)\n \n while n > 0:\n tmp = str(n % 1000)\n if len(tmp) < 3 and n >= 1000:\n tmp = '0' * (3 - len(tmp)) + tmp\n ans.append(tmp)\n \n n \/\/= 1000\n ans = ans[::-1]\n if was and len(ans) == 1:\n ans = [\"0\"] + ans\n \n return \".\".join(ans)\n\n\n\ns = input() + \"a\"\n\ndata = []\nlast = 0\nnumber = False\nfor i in range(len(s)):\n if \"a\" <= s[i] and s[i] <= \"z\":\n if number:\n number = False\n data.append(s[last:i])\n continue\n if not number:\n last = i\n number = True\n \nnums = [fr(i) for i in data]\n\nprint(to(sum(nums)))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"92c5db4e0860a209c4c1","document_content":"def get_down(i):\n if len(i) > 3 and i[-3] == '.':\n return int(i[-2:])\n return 0\n\n\ndef get_up(ans):\n if len(ans) > 3 and i[-3] == '.':\n ans = ans[:-3]\n ans = ans.replace('.', '')\n return int(ans)\n\n\ndef modify(up, down=0):\n ans = ''\n f = (up == 0)\n while up != 0:\n ans = str(up % 1000).rjust(3, '0') + '.' + ans\n up \/\/= 1000\n ans = ans.lstrip('0')\n if down == 0:\n ans = ans[:-1]\n else:\n down = str(down).rjust(2, '0')\n ans += down\n if (f):\n ans = '0.' + ans\n return ans\n\ns = input().strip()\nnumb = []\ncur = ''\nf = 0\nfor i in s:\n if '0' <= i <= '9':\n f = 1\n cur += i\n elif i == '.':\n cur += i\n elif 'a' <= i <= 'z' or 'A' <= i <= 'Z':\n f = 0\n if (cur):\n numb.append(cur)\n cur = ''\nif cur:\n numb.append(cur)\n cur = ''\nans_up = 0\nans_down = 0\nfor i in numb:\n #print(i, get_up(i), get_down(i))\n ans_up += get_up(i)\n ans_down += get_down(i)\nans_up += ans_down \/\/ 100\nans_down %= 100\nprint(modify(ans_up, ans_down))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"37842885f872901389e3","document_content":"s = input()\nc = set()\nc.add('1')\nc.add('2')\nc.add('3')\nc.add('4')\nc.add('5')\nc.add('6')\nc.add('7')\nc.add('8')\nc.add('9')\nc.add('0')\nc.add('.')\n\nans = []\nj = 0\nst = ''\nfor i in range(len(s)):\n if s[i] in c:\n st += s[i]\n elif len(st) > 0:\n ans.append(st)\n st = ''\nx = 0\nans.append(st)\nfor i in range(len(ans)):\n if len(ans[i]) < 3:\n ans[i] += '.00'\n if ans[i][-3] != '.':\n ans[i] += '.00'\ncc = set()\ncc.add('1')\ncc.add('2')\ncc.add('3')\ncc.add('4')\ncc.add('5')\ncc.add('6')\ncc.add('7')\ncc.add('8')\ncc.add('9')\ncc.add('0')\npp =''\npk = 0\npr = 0\nfor i in range(len(ans)):\n for j in range(len(ans[i]) - 1, - 1, -1):\n if ans[i][j] == '.':\n x = j\n break\n p1 = ans[i][:x]\n p2 = ans[i][x + 1:]\n for ii in range(len(p1)):\n if p1[ii] in cc:\n pp += p1[ii]\n pr += int(pp)\n pp = ''\n pk += int(p2)\nwhile pk > 99:\n pk -= 100\n pr += 1\npk = str(pk)\nif len(pk) < 2:\n pk = '0' + pk\nanswer = str(pr) + '.' + pk\nj = answer.index('.')\nq = 0\nfor i in range(j, -1, -1):\n if q == 2:\n answer = answer[:i] + '.' + answer[i:]\n q = 0\n elif answer[i] != '.':\n q += 1\nif answer[-1] == '0' and answer[-2] == '0' and answer[-3] == '.':\n answer = answer[:-3]\nif answer[0] == '.':\n answer = answer[1:]\nprint(answer)\n \n\"\"\"\n ans[j] = ans[j] * 10 + int(s[i])\n elif s[i] == '.':\n ans[j] *= 100\"\"\"","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cd81ba61625eb57079b3","document_content":"s = input()\nms = ['']\ndct = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'}\np = 0\nfor i in s:\n if i in dct:\n ms[-1] += i\n p = 1\n else:\n if p:\n ms.append('')\n p = 0\nrub = 0\nkop = 0\nif ms[0] == '':\n ms = []\nfor i in ms:\n box = i.split('.')\n l = len(box)\n a = 0\n b = 0\n p = 0\n for j in range(l - 1, -1, -1):\n if len(box[j]) == 2 and j == l - 1:\n b = int(box[j])\n p = 1\n else:\n a += int(box[j]) * (1000 ** (l - 1 - j - p))\n rub += a\n kop += b\nrub += kop \/\/ 100\nkop %= 100\n\ns = str(rub)\nl = len(s)\nd = l % 3\nret = ''\nind = 0\nif d:\n ind = d\n for i in range(d):\n ret += s[i]\n ret += '.'\ncnt = 0\nfor i in range(ind, l):\n ret += s[i]\n cnt += 1\n cnt %= 3\n if not cnt:\n ret += '.'\nif kop:\n if kop < 10:\n ret += '0'\n ret += str(kop)\n print(ret)\nelse:\n l = len(ret)\n for i in range(0, l - 1, 1):\n print(ret[i], end = '')\n\n \n \n \n ","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1217cfb60b19d023029a","document_content":"from decimal import Decimal\ncheck = input()\ncheck = check + 'a'\nbukvi = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f' ,'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']\nflag = 0\nnumber = []\nnumbers = []\nfor symvol in check:\n if flag == 0:\n if symvol not in bukvi:\n flag = 1\n if flag == 1:\n if symvol not in bukvi:\n number += symvol\n else:\n numbers += [number]\n number = []\n flag = 0\nans = 0\nfor num in numbers:\n integ = []\n for i in range(len(num)):\n if num[i] != '.':\n integ += num[i]\n else:\n if i == len(num) - 3:\n integ += [num[i]]\n ans += Decimal(''.join(integ))\nans = str(ans)\nif len(ans) >3 and ans[-1] == ans[-2] == '0' and ans[-3] == '.':\n ans = ans[:-3]\nres = []\ncnt = 0\nif len(ans) > 3 and ans[-3] == '.':\n for i in range(len(ans) - 4, -1, -1):\n if cnt == 3:\n res += ['.']\n cnt = 0\n res += ans[i]\n cnt += 1\n res.reverse()\n res += ans[-3:]\nelse:\n for i in range(len(ans) - 1, -1, -1):\n if cnt == 3:\n res += ['.']\n cnt = 0\n res += ans[i]\n cnt += 1\n res.reverse()\nprint(''.join(res))\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c2d8dd5fef529f51b5d4","document_content":"def num(a):\n if len(a) < 4:\n return int(a) * 100\n q = 1\n if a[-3] != '.':\n q = 100\n b = ''\n for i in a:\n if i != '.':\n b += i\n print\n return int(b) * q\n\na = input()\nb = 0\nnn = ''\nq = 2\nfor i in a:\n if i not in '1234567890.':\n if len(nn) > 0:\n b += num(nn)\n nn = ''\n else:\n nn += i\nif len(nn) > 0:\n b += num(nn)\na = [b % 100]\nb \/\/= 100\nwhile b != 0:\n a = [b % 1000] + a\n b \/\/= 1000\nif len(a) == 1:\n print(0, end='')\n if a[0] != 0:\n print('.', a[0] \/\/ 10, a[0] % 10, sep='')\nelse:\n if a[-1] == 0:\n for i in range(1, len(a)):\n a[i] = str(a[i]).zfill(3)\n a[0] = str(a[0])\n print('.'.join(a[:-1]))\n else:\n for i in range(1, len(a) - 1):\n a[i] = str(a[i]).zfill(3)\n a[-1] = str(a[-1]).zfill(2)\n a[0] = str(a[0])\n print('.'.join(a))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d47cc0d7070c88839134","document_content":"import re\no=input\nC=len\nE=float\nF=int\nd=print\nU=sum\nS=re.findall\nl=o()\ne=S(\"[\\d\\.]+\",l)\ndef p(u):\n u=u.split('.')\n if C(u[-1])==2 and C(u)>1:\n G=u[-1]\n return E(\"\".join(u[:-1])+\".\"+G)\n else:\n return F(\"\".join(u))\ndef V(flo):\n if F(flo)==flo:\n return '{:,}'.format(F(flo)).replace(',','.')\n else:\n return '{:,.2f}'.format(flo).replace(',','.')\ne=[p(num)for num in e]\nd(V(U(e)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4a8e7a25675c3143e7d3","document_content":"s = str(input())\ns = s[::-1]\n\ncurrent = \"\"\nanswer = 0\n\nfor el in s:\n if '9' >= el >= '0':\n current += el\n elif el == '.':\n if len(current) == 2:\n current += '.'\n else:\n if current != '':\n answer += float(current[::-1])\n current = ''\n\ntemp = \"%.2f\" % answer\nif temp[len(temp) - 2:] != '00':\n temp_2 = temp[:len(temp) - 3][::-1]\n temp = temp[len(temp) - 2:]\n parts = []\n current = \"\"\n for i in range(len(temp_2)):\n current += temp_2[i]\n if len(current) == 3:\n parts.append(current[::-1])\n current = ''\n if current != '':\n parts.append(current[::-1])\n print(*parts[::-1], sep='.', end='.')\n print(temp)\n\nelse:\n temp_2 = str(int(answer))[::-1]\n parts = []\n current = \"\"\n for i in range(len(temp_2)):\n current += temp_2[i]\n if len(current) == 3:\n parts.append(current[::-1])\n current = ''\n if current != '':\n parts.append(current[::-1])\n print(*parts[::-1], sep='.')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e9091eb5fa7214945009","document_content":"\"\"\"\nCodeforces Contest Good Bye 2014 Contest Problem A\n\nAuthor : chaotic_iak\nLanguage: Python 3.4.2\n\"\"\"\n\n################################################### SOLUTION\n\ndef main():\n n,t = read()\n a = read()\n c = 1\n while c < t:\n c += a[c-1]\n if c == t:\n print(\"YES\")\n else:\n print(\"NO\")\n\n#################################################### HELPERS\n\n\n\ndef read(mode=2):\n # 0: String\n # 1: List of strings\n # 2: List of integers\n inputs = input().strip()\n if mode == 0: return inputs\n if mode == 1: return inputs.split()\n if mode == 2: return list(map(int, inputs.split()))\n\ndef write(s=\"\\n\"):\n if s is None: s = \"\"\n if isinstance(s, list): s = \" \".join(map(str, s))\n s = str(s)\n print(s, end=\"\")\n\nwrite(main())","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4aa16001c3ba7f5781e1","document_content":"n, t = map(int, input().split())\narr = list(map(int, input().split()))\ncur = 0\nwas = False\nwhile cur < n:\n\ttry:\n\t\tcur = cur+arr[cur]\n\t\tif(cur == t-1):\n\t\t\twas = True\n\texcept:\n\t\tbreak\nif(was):\n\tprint('YES')\nelse:\n\tprint('NO')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"39d0a254a618278eb3b3","document_content":"n, t = map(int, input().split())\na, cur = [0] + [int(x) for x in input().split()], 1\nwhile cur < t:\n cur += a[cur]\nprint('YES' if cur == t else 'NO')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"06aff8e6454311e9a6fe","document_content":"n,t=map(int,input().split())\na=list(map(int,input().split()))\ncan=[0 for _ in range(n)]\ncan[0]=1\nfor i in range(n-1):\n if can[i]:\n can[i+a[i]] = 1\nprint(\"YES\" if can[t-1] else \"NO\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3b387e83dcef9864f881","document_content":"n, t = [int(_) for _ in input().split()]\na = [int(_) for _ in input().split()]\np = 1\nwhile p < t:\n p += a[p-1]\nif p == t:\n print(\"YES\")\nelse:\n print(\"NO\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"70fe7d005fa9ccd866e6","document_content":"#input\nn,t=map(int,input().split())\na=[int(x) for x in input().split()]\n\n#variables\np=1\n\n#main\nwhile p<=t:\n\tif p==t:\n\t\tprint('YES')\n\t\tquit()\n\tp+=a[p-1]\n\n#output\nprint('NO')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"81cf0ffabda7171aca7a","document_content":"n,t = list(map(int, input().split()))\nl = input().split()\nfor i in range(n-1):\n l[i] = int(l[i])\nl = [0]+l\nnow = 1\nwhile 1:\n now += l[now]\n if now > t:\n ans = 0\n break\n if now == t:\n ans = 1\n break\n\nif ans == 0:\n print(\"NO\")\nelse:\n print(\"YES\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"27436e2bb097ecbdcad1","document_content":"n,m=input().split(' ')\nn=int(n)\nm=int(m)\nseq=[1]\na=input()\nline=a.split(' ')\nc=1\nwhile c!=n:\n c+=int(line[c-1])\n seq.append(c)\nif m in seq:\n print(\"YES\")\nelse:\n print(\"NO\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"27d982393b6671a9e392","document_content":"line = input().split()\nn = int(line[0])\nt = int(line[1])\n\nline = input().split()\narr = [int(num) for num in line]\nn = 0\nwhile n < t - 1:\n n += arr[n]\n\nif n == t - 1:\n print('YES')\nelse:\n print('NO')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bdcbf946b6593e23ed7b","document_content":"import sys\n\nnums = [int(x) for x in sys.stdin.readline().split(\" \")]\na = [int(x) for x in sys.stdin.readline().split(\" \")]\n\nt = nums[1]\n\ncurr = 1\nwhile curr < t:\n\tcurr += a[curr-1]\nif curr == t:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2b9c2ffa684eeef14661","document_content":"__author__ = 'Rakshak.R.Hegde'\n\"\"\"\nCreated on Dec 30 2014 PM 08:30\n\n@author: Rakshak.R.Hegde\n\"\"\"\n\n\ndef mint(): return map(int, input().split())\n\n\nn, t = mint()\na = list(mint())\ncurr = 1\nwhile curr < t:\n curr = curr + a[curr - 1]\nprint('YES' if curr == t else 'NO')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d4af4e87a3f4bb8e3712","document_content":"import sys\n\ndef main():\n n,t = tuple([int(y) for y in input().split()])\n a = [int(x) for x in input().split()]\n c = 1\n while True:\n c = c + a[c - 1]\n if c == t:\n print(\"YES\")\n return\n elif c > t:\n print(\"NO\")\n return\n print(\"NO\")\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"efa2a24c0549c1bf8056","document_content":"__author__ = 'Daniil'\nn,t = list(map(int,input().split()))\n\na = list(map(int,input().split()))\ni=0\nwhile i!=t-1:\n i+=a[i]\n if i>t-1:\n print('NO')\n quit()\nprint('YES')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dfbc37606c8579a31584","document_content":"def ans():\n n, t= [int(i) for i in input().split()]\n a= [0]\n a+= [int(i) for i in input().split()]\n #print(a)\n \n ans= 1\n i= 1\n while True:\n ans+= a[i]\n i= ans\n if ans== t:\n print(\"YES\")\n return\n \n if i> t:\n print(\"NO\")\n return\n\nans()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"11e25f25955400b7c47b","document_content":"n, t = (int(i) for i in input().split())\nportals = [int(i) for i in input().split()]\nhome = 1\nwhile True:\n if home == t:\n print('YES')\n break\n elif home > t:\n print('NO')\n break\n home += portals[home-1]\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9a6e9cd9e8f43ef589da","document_content":"n, t = map(int, input().split())\na = list(map(int, input().split()))\npos = 1\nwhile (pos < t): pos += a[pos-1]\nprint(('NO', 'YES')[pos == t])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5a0c9af92c6566d5c5e1","document_content":"n, t = list(map(int, input().split()))\nt = t - 1\nj = [int(x) for x in input().split()]\n\ncur = 0\nwhile True:\n if cur > t:\n print('NO')\n break\n cur += j[cur]\n if cur == t:\n print('YES')\n break\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9e13f83cc071a4b46d30","document_content":"n, t = list(map(int, input().split()))\na = list(map(int, input().split()))\ncurrent = 1\nwhile current < t:\n current = current + a[current-1]\n \nif current == t:\n print('YES')\nelse:\n print('NO')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d106b9fbf1d44c7ced9c","document_content":"n, t = list(map(int, input().split()))\na = list(map(int, input().split()))\n\ncurrent = 0\n\nwhile current < t - 1:\n current = a[current] + current\n\nprint('YES' if current == t - 1 else 'NO')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"798e3183e6abea7e14d3","document_content":"def main():\n\tn, t = list(map(int, input().split()))\t\n\ta =[0] + list(map(int, input().split())) + [100000]\n\td = {}\n\tfor i in range(1,n):\n\t\td[i] = i + a[i]\n\treached = True\n\ti = 1\n\tcount = 1\n\twhile reached and count <= 100009:\n\t\tif i in d:\n\t\t\tif d[i] == t:\n\t\t\t\tprint ('YES')\n\t\t\t\treturn\n\t\t\ti = d[i]\n\t\t\tcount += 1\n\t\telse:\n\t\t\tbreak\n\tprint('NO')\n\n\n\n\t\n\ndef __starting_point():\n\tmain()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b788c638442ee1c59eba","document_content":"c = input().split()\nn = int(c[0]) # \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\nt = int(c[1]) # \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\nc = input().split() # \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\nfor i in range(n-1):\n c[i] = int(c[i])\n \na = 1\nwhile (a < n) and (a < t):\n a += c[a-1]\n \nif a == t:\n print('YES')\nelse:\n print('NO')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9090caa41b621c9f62dd","document_content":"import math,string,itertools,fractions,heapq,collections,re,array,bisect\nfrom itertools import chain, dropwhile, permutations, combinations\nfrom collections import defaultdict\n\n\ndef main(n,t,a):\n j = 1\n while j len(inputs):\n inputs.extend(input().split(\" \"))\n if n > 0:\n res = inputs[:n]\n inputs[:n] = []\n return res\nInputHandler = InputHandlerObject()\ng = InputHandler.getInput\n\n############################## SOLUTION ##############################\nn = int(input())\na = [int(x) for x in g()]\nct = 0\nres = 0\nfor i in a:\n ct += i\n if ct < 0:\n res += 1\n ct = 0\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0d323e66025063bb97f6","document_content":"n = int(input())\na = [int(i) for i in input().split()]\ncnt = 0\ncntpols = 0\nfor i in range(len(a)):\n if a[i] == -1:\n if cntpols == 0:\n cnt += 1\n else:\n cntpols -= 1\n else:\n cntpols += a[i]\nprint(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0bc898b7f4e8835f31f9","document_content":"n=int(input())\nL=list(map(int,input().split()))\nr=0\nans=0\nfor i in range(n):\n if(L[i]==-1):\n if(r==0):\n ans+=1\n else:\n r-=1\n else:\n r+=min(L[i],10)\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7ccf6e9dad3f24a3f1e2","document_content":"n = int(input())\ncount = 0\nfree = 0\n\nt = [int(x) for x in input().split()]\nfor i in t:\n if i > 0:\n free += i\n if i == -1:\n if free > 0:\n free -= 1\n else:\n count += 1\n\nprint(count)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e918df81d1140aabf904","document_content":"n=int(input())\na=list(map(int,input().split()))\nans=0\nt=0\nfor i in range(n):\n if a[i]>0:\n t+=a[i]\n else:\n if t==0:\n ans+=1\n else:\n t-=1\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bb88ca30822cabb201c6","document_content":"input()\ncops = 0\ncount = 0\nfor e in map(int, str.split(input())):\n\n if e == -1:\n\n if cops == 0:\n\n count += 1\n\n cops = max(0, cops - 1)\n\n else:\n\n cops += e\n\nprint(count)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a358a2a0584c320ef9af","document_content":"n = int(input())\nseq = list(map(int, input().split()))\n\navail_cops = 0\ncrimes = 0\n\nfor event in seq:\n\tif event > 0:\n\t\tavail_cops += event\n\telse:\n\t\tif avail_cops == 0:\n\t\t\tcrimes += 1\n\t\telse:\n\t\t\tavail_cops -= 1\nprint(crimes)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5566db003a269df9d202","document_content":"need_log = False\ndef log(*s):\n if need_log:\n print(*s)\n\nn = int(input())\na = list(map(int, input().split()))\n\nx = 0\ny = 0\nfor k in a:\n if k == -1:\n if y == 0:\n x += 1\n else:\n y -= 1\n else:\n y += k\nprint(x)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"04e8dfd249edf44a1c86","document_content":"n = int(input())\nA = list(map(int, input().split()))\nc = 0\nres = 0\nfor i in A:\n if i > 0:\n c += i\n elif c == 0:\n res += 1\n else:\n c -= 1\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bd77065c77e2c9de7a26","document_content":"n = int(input())\na = list(map(int, input().split()))\nsv = 0\nans = 0\nfor i in range(n):\n if a[i] > 0:\n sv += a[i]\n else:\n k = -a[i]\n if k <= sv:\n sv -= k\n else:\n ans += (k - sv)\n sv = 0\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"986cc49291c805a80672","document_content":"n = int(input())\nevents = input().split()\nuntreated = 0\nofficers = 0\nfor i in range(len(events)):\n events[i]=int(events[i])\n if events[i]==-1:\n if officers>0:\n officers-=1\n else:\n untreated+=1\n else:\n officers+=events[i]\nprint(untreated)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"761a0b1bff1e558c2df0","document_content":"n = int(input())\nevents = list(map(int,input().split()))\n\npolice = 0\noccur = 0\n\nfor i in range(n):\n police += events[i]\n if police < 0 :\n occur += 1\n police = 0\nprint(occur)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3663382bc9d6d14f9c8f","document_content":"__author__ = 'Lipen'\n\n\ndef main():\n\tn = int(input())\n\ta = list(map(int, input().split()))\n\tnow = 0\n\tanswer = 0\n\n\tfor x in a:\n\t\tif x == -1:\n\t\t\tif now>0:\n\t\t\t\tnow-=1\n\t\t\telse:\n\t\t\t\tanswer+=1\n\t\telse:\n\t\t\tnow+=x\n\n\tprint(answer)\n\nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f785117f95db0708b65a","document_content":"input()\nres = 0\np = 0\nfor i in input().split():\n i = int(i)\n if i > 0:\n p += i\n elif p == 0:\n res += 1\n else:\n p -= 1\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"af2c678b65aefa423c29","document_content":"n = int(input())\nl = list(map(int, input().split()))\np, c = 0, 0\n\nfor i in l:\n if i > 0:\n p += i\n else:\n if p > 0:\n p -= 1\n else:\n c += 1\n\nprint(c)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ff0132116f189b0066c0","document_content":"#!\/usr\/bin\/env python\n\nfrom sys import stdin\n\nstdin.readline()\ncnt = 0\nacc = 0\nfor i in map(int, stdin.readline().split()):\n if i == -1:\n if acc > 0:\n acc = acc - 1\n else:\n cnt = cnt + 1\n else:\n acc = acc + i\nprint(cnt)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"983761cba6062727e777","document_content":"n = int(input())\nl = []\na = 0\ns = input().split(' ')\nif len(s) != n:\n while len(s) != n:\n print('Bad!')\n s = input().split(' ')\nwhile a < len(s):\n l.append(int(s[a]))\n a += 1\ncount = 0\npm = 0\ni = 1\nif l[0] == -1:\n count += 1\nelse:\n i = 0\nwhile i < len(l):\n if l[i] > 0:\n pm += l[i]\n if l[i] == -1:\n if pm > 0:\n pm -= 1\n else:\n count += 1\n i += 1\nprint(count)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e5aebb4b2d0077c09c09","document_content":"n = int(input())\na = list(map(int,input().split()))\nk = 0\npol = 0\nfor i in range(n):\n if a[i] < 0:\n if pol <= 0:\n k += 1\n else:\n pol -= 1\n else:\n pol += a[i]\nprint(k)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"157eb21c450ac0303bd6","document_content":"import sys\n\nf = sys.stdin\nn = int(f.readline())\n\ns = f.readline().split()\n\ntotal = 0\nr = 0 # \u043d\u0435\u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f\nfor j in s:\n d = int(j)\n if (d<0):\n if total==0: r += 1\n else : total -= 1\n else : total += d\n\nprint(str(r)) \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b8d8841822b15a90f5c7","document_content":"n = int(input())\na = input().split()\n\na = [int(i) for i in a]\nl = 0\nk = 0\n\nfor i in a:\n\tif i == -1:\n\t\tif l < 1:\n\t\t\tk += 1\n\t\telse:\n\t\t\tl -= 1\n\telse:\n\t\tl += i\n\nprint (k)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2b7cdb3a50b6b51d4651","document_content":"n = int(input())\npolice = 0\nans = 0\na = list(map(int, input().split()))\nfor i in range(n):\n q = a[i]\n if q < 0:\n if police > 0:\n police -= 1\n else:\n ans += 1\n else:\n police += q\nprint(ans) ","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e6c252fc1fd4d9dd54f4","document_content":"n = int(input())\nx = map(int, input().split())\nk, res = 0, 0\nfor elm in x:\n if elm != -1: k += elm; continue\n if elm == -1 and k > 0: k -= 1\n else: res += 1\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a6041650342e8efb6d4f","document_content":"input()\ns = n = 0\nfor i in map(int, input().split()):\n s += i\n if s < 0:\n s = 0\n n += 1\nprint(n)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"445114b70db545286bc9","document_content":"n = int(input())\nA = input().split()\nc = 0\np = 0\nfor i in range(n):\n if int(A[i]) > 0:\n p += int(A[i])\n else:\n if p > 0:\n p -= 1\n else:\n c += 1\nprint(c)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e7aef2e1d4cf58468df6","document_content":"n = int(input())\na = map(int, input().split())\ncnt = 0\nsum = 0\nfor i in a:\n if i < 0 and sum <= 0:\n cnt += 1\n elif i > 0:\n sum += i\n elif i < 0 and sum > 0:\n sum += i\nprint(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1fc7cac60244740d88cb","document_content":"N = int(input())\ntable = []\nfor i in range(N):\n table.append(list(map(int, input().split())))\n\nfor i in range(N):\n for j in range(N):\n if table[i][j] == 1:\n continue\n flg = False\n for s in range(N):\n for t in range(N):\n if table[i][j] == table[i][s] + table[t][j]:\n flg = True\n break\n if not flg:\n print(\"No\")\n return\nprint(\"Yes\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"95466c18699876b82f19","document_content":"I = lambda : map(int, input().split())\nn, = I()\narr = []\nfor i in range(0, n):\n arr.append(list(I()))\n\nfor x in range(0, n):\n for y in range(0, n):\n if arr[x][y] != 1:\n found = False\n for s in range(0, n):\n for t in range(0, n):\n if arr[x][y] == arr[x][s] + arr[t][y]:\n found = True\n if not found:\n print(\"No\")\n return\nprint(\"Yes\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c4a76c12a7c918e6e6a3","document_content":"def main():\n n = int(input())\n a = []\n for _ in range(n):\n a.append(list(map(int, input().split())))\n for i in range(n):\n for j in range(n):\n e = a[i][j]\n if e == 1:\n continue\n else:\n fl = False\n for i1 in range(n):\n for j1 in range(n):\n if a[i1][j] + a[i][j1] == e:\n fl = True\n break\n if fl:\n break\n if fl:\n continue\n else:\n print('No')\n return\n print('Yes')\n\nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"98f38877427fbbc79b34","document_content":"n = int(input())\na = []\nfor i in range(n):\n a.append(list(map(int, input().split())))\nok = True\nfor i in range(n):\n for j in range(n):\n if a[i][j] != 1:\n check = False\n for k in range(n):\n for l in range(n):\n if a[i][j] == a[i][k] + a[l][j]:\n check = True\n if check:\n break\n if check:\n break\n ok &= check\nprint(\"Yes\" if ok else \"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8a4dd57b369824909a1c","document_content":"n = int(input())\ns = []\nfor k in range(n):\n s.append([int(i) for i in input().split()])\nt = 0\nfor i in range(n):\n for j in range(n):\n l = 0\n if s[i][j] !=1:\n for x in range(n):\n for y in range(n):\n if s[i][x]+ s[y][j] == s[i][j]:\n l = 1\n if not l:\n t = 1\nif t:\n print(\"No\")\nelse:\n print(\"Yes\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ef067d2d3294e070e5cc","document_content":"from sys import stdin, stdout\n\ndef main():\n n = int(stdin.readline())\n mat = []\n for i in range(n):\n mat.append(list(map(int, stdin.readline().split())))\n for i in range(n):\n for j in range(n):\n st = True\n for u in range(n):\n for k in range(n):\n if mat[i][j] == 1 or mat[i][j] == mat[u][j] + mat[i][k]:\n st = False\n break\n if not st: break\n if st:\n return False\n return True\n\n\nprint('Yes' if main() else 'No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9ea797029df8351e086f","document_content":"import sys \n\ndef main():\n n = int(input())\n x = []\n for i in range(n):\n y = list(map(int,sys.stdin.readline().split()))\n x.append(y)\n\n for i in range(n):\n for j in range(n):\n if x[i][j] == 1:\n continue\n found = False\n for o in range(n):\n a = x[i][o]\n if o == j:\n continue\n for p in range(n):\n if p ==i:\n continue\n b = x[p][j]\n if a+b == x[i][j]:\n found = True\n break\n if found:\n break\n if not found:\n print(\"No\")\n return\n print(\"Yes\")\n \n\nmain()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6a11c3ca26a6e07422a8","document_content":"n = int(input())\ndata = []\nfor i in range(n):\n data += [list(map(int, input().split()))]\n\nfor i in range(n):\n for j in range(n):\n if data[i][j] == 1:\n t = True\n continue\n t = False\n for k in range(n):\n for m in range(n):\n if data[i][k] + data[m][j] == data[i][j]:\n t = True\n break\n if not t:\n print(\"No\")\n break\n if not t:\n break\nif t:\n print(\"Yes\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d9cfcbfc6ede5aa00895","document_content":"def check(r, c, x):\n rtn = False\n rs = [a[r][i] for i in range(n) if i != c]\n cs = [a[i][c] for i in range(n) if i != r]\n for r in rs:\n for c in cs:\n if r + c == x:\n rtn = True\n break\n return rtn\n\nn = int(input())\na = [list(map(int, input().split()))for _ in range(n)]\n\nans = True\nfor i in range(n):\n for j in range(n):\n if a[i][j] != 1:\n ans &= check(i, j, a[i][j])\n\nprint('Yes' if ans else 'No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"db948e78f794092a88c5","document_content":"def solve(g):\n for i in range(n):\n for j in range(n):\n if g[i][j] == 1:continue\n for p in range(n):\n for q in range(n):\n if p == i or q == j:continue\n if g[i][q] + g[p][j] == g[i][j]:break\n else:\n continue\n break\n else:\n return \"No\"\n return \"Yes\"\n\nn = int(input())\n\ng = []\n\nfor i in range(n):\n g.append([int(item) for item in input().split()])\n \nprint(solve(g))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"83f55699d91c7d5c155f","document_content":"#! python3\n\ndef is_good(a, n, i, j):\n c = set([])\n for x in range(n):\n c.add(a[i][j] - a[i][x])\n for x in range(n):\n if a[x][j] in c:\n return True\n return False\n\nn = int(input())\na = []\nfor _ in range(n):\n a.append([int(x) for x in input().strip().split(' ')])\n\ngood = True\nfor i in range(n):\n for j in range(n):\n if a[i][j] != 1 and not is_good(a, n, i, j):\n good = False\n break\nif good:\n print(\"Yes\")\nelse:\n print(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"67ecf271d5e8320cfa76","document_content":"#!\/usr\/bin\/env python3\nimport sys\n\ndef main():\n n = int(sys.stdin.readline())\n mat = [None for __ in range(n)]\n for indx in range(n):\n mat[indx] = list(map(int, sys.stdin.readline().split()))\n\n good = True\n for row in range(n):\n for col in range(n):\n if mat[row][col] == 1:\n continue\n else:\n good &= check_this_element(mat, row, col)\n if good:\n print(\"Yes\")\n else:\n print(\"No\")\n\ndef check_this_element(mat, row, col):\n n = len(mat)\n for _row in range(n):\n for _col in range(n):\n if mat[_row][col] + mat[row][_col] == mat[row][col]:\n return True\n return False\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0a2cab5c9d733ec882c8","document_content":"#!\/usr\/bin\/env python3\nfrom sys import stdin, stdout\n\ndef rint():\n return list(map(int, stdin.readline().split()))\n#lines = stdin.readlines()\n\n\ndef check(i, j):\n for r in range(n):\n for c in range(n):\n if a[i][c] + a[r][j] == a[i][j]:\n return 1\n return 0\nn = int(input())\na = [[] for _ in range(n)]\nfor i in range(n):\n a[i] = list(rint())\n\nfor i in range(n):\n for j in range(n):\n if a[i][j] == 1:\n continue\n if check(i,j) == 0:\n print(\"No\")\n return\n\nprint(\"Yes\")\n\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"94661d0cfa4851e3c63e","document_content":"def int_input():\n return list(map(int, input().split()))\n\n\nn = int(input())\nmatr = [list(int_input()) for i in range(n)]\n\ngood = True\nfor row in range(n):\n nums = set(matr[row])\n for col in range(n):\n num = matr[row][col]\n if num == 1:\n continue\n cur_good = False\n for i in range(n):\n cur_good |= num - matr[i][col] in nums\n good &= cur_good\n\nprint('Yes' if good else 'No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8e7cd6c0886118794e4d","document_content":"#def proverka(b, k, m, p):\n# for i in range()\n\nn = int(input()) \na = []\nfor i in range(n):\n a.append([int(j) for j in input().split()])\nflag = \"Yes\" \nfor i in range(n):\n for j in range(n):\n if(a[i][j] != 1):\n f = False\n for k in range(n):\n if(f):\n break\n for z in range(n):\n if(a[k][j] + a[i][z] == a[i][j]):\n f = True\n if(f):\n break\n if(not(f)):\n flag = \"No\"\n\nprint(flag)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4ccbff2d8157fcc4f9fb","document_content":"n=int(input())\na=[[0]*n for i in range(n)]\nf=True\nd=True\nfor i in range(n):\n a[i]=list(map(int,input().split(\" \")))\nfor i in range(n):\n for j in range(n):\n s=a[i][j]\n\n if s!=1:\n f = False\n for t in range(n):\n if t!=i:\n x=s-a[t][j]\n if x in a[i]:\n f=True\n if f==False:\n d=False\nif not d:\n print('No')\nelse:\n print('Yes')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e406c4d39135401106c7","document_content":"n=int(input())\na=[]\nfor i in range(n):\n\ta.append(list(map(int,input().split())))\nfor i in range(n):\n\tfor j in range(n):\n\t\tc=0\n\t\tif a[i][j]==1:\n\t\t\tcontinue\n\t\tfor k in range(n):\n\t\t\tfor l in range(n):\n\t\t\t\tif a[i][j]==a[i][k]+a[l][j]:\n\t\t\t\t\tc=1\n\t\t\t\t\tbreak\n\t\t\tif c:\n\t\t\t\tbreak\n\t\tif not c:\n\t\t\tprint('No')\n\t\t\treturn\nprint('Yes')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"643995bb9bd2c608bca0","document_content":"a = [list(map(int, input().split())) for i in range(int(input()))]\nn = len(a)\nfor i in range(n):\n for j in range(n):\n if a[i][j] != 1:\n found = False\n for i2 in range(n):\n for j2 in range(n):\n if a[i][j] == a[i][j2] + a[i2][j]:\n found = True\n if not found:\n print('No\\n')\n return\nprint('Yes')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"91169886cedc4a9d14a8","document_content":"n = int(input())\na = []\nfor i in range(n):\n\ta.append([int(x) for x in input().split()])\nfor i in range(n):\n\tfor j in range(n):\n\t\tif a[i][j]==1:\n\t\t\tcontinue\n\t\tval = False\n\t\tfor k in range(n):\n\t\t\tfor l in range(n):\n\t\t\t\tif (a[i][k]+a[l][j]==a[i][j]):\n\t\t\t\t\tval = True\n\t\tif val==False:\n\t\t\tprint(\"No\")\n\t\t\treturn\nprint(\"Yes\")\n\t\t\t\t\n\t\t\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"360932cd0773f28fe35c","document_content":"from itertools import *\nn=int(input())\nf=[list(map(int,input().split())) for _ in range(n)]\nfor i,j in product(list(range(n)),list(range(n))):\n x=f[i][j]\n if x==1: continue\n if not any(a+b==x for a, b in product(chain(f[i][:j], f[i][j+1:]),(f[k][j] for k in chain(list(range(i)), list(range(i+1,n)))))):\n print(\"No\")\n return\nprint(\"Yes\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"32c979261957c455bf65","document_content":"def fin(s, row, column):\n\tfor i in row:\n\t\tfor j in column:\n\t\t\tif i+j == s:\n\t\t\t\treturn True\n\treturn False\n\nn = int(input())\na = []\nfor i in range(n):\n\tk = input().split(' ')\n\tk = list(map(int,k))\n\ta.append(k)\n\nans = True\n\nfor i in range(n):\n\tfor j in range(n):\n\t\tif a[i][j] == 1:\n\t\t\tcontinue\n\t\telse:\n\t\t\ts = a[i][j]\n\t\t\trow = a[i]\n\t\t\tcolumn = []\n\t\t\tfor t in range(n):\n\t\t\t\tcolumn.append(a[t][j])\n\t\t\tans = fin(s,row,column)\n\t\t\tif ans == False:\n\t\t\t\tbreak\n\tif ans == False:\n\t\tbreak\n\nif ans==True:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e11ceb2823b4fa1979c3","document_content":"import sys\n\ndef is_good(lab):\n n = len(lab)\n for i in range(n):\n for j in range(n):\n v = lab[i][j]\n if v > 1 and all(x + y != v for x in lab[i] for y in (lab[k][j] for k in range(n))):\n return False\n return True\n\nn = int(input())\n\nlab = [[int(i) for i in input().split()] for _ in range(n)]\n\nprint('Yes' if is_good(lab) else 'No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0582b1de7ed450eefd74","document_content":"n = int(input())\ntbl = []\nfor i in range(n):\n tbl.append(list(map(int, input().split())))\n\nout = False\nfor i, row in enumerate(tbl):\n for j in range(len(row)):\n out = False\n e = row[j]\n if e == 1:\n out = True\n continue\n for j1, e1 in enumerate(row):\n if j1 != j:\n for i1 in range(n):\n if e1 + tbl[i1][j] == e:\n out = True\n break\n if out:\n break\n if not out:\n print('No')\n break\n if not out:\n break\nif out:\n print('Yes')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1989039d2e7e774d8941","document_content":"from collections import defaultdict, Counter\nN = int(input())\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nEdge = defaultdict(list)\nEdc = defaultdict(int)\nfor b, c in zip(B, C):\n if b > c:\n print(-1)\n return\n Edge[b].append(c)\n Edc[(b, c)] += 1\n if b != c:\n Edge[c].append(b)\nDeg = Counter(B + C)\neul = 0\nst = []\nfor k, v in list(Deg.items()):\n if v % 2:\n eul += 1\n st.append(k)\ns, e = B[0], B[0]\nif eul and eul != 2:\n print(-1)\n return\nif eul:\n s, e = st[0], st[1]\nans = [s]\nwhile True:\n vn = ans[-1]\n while True:\n vf = Edge[vn][-1]\n if Deg[vf] != 0 and Edc[(vn, vf) if vn < vf else (vf, vn)]:\n break\n Edge[vn].pop()\n vf = Edge[vn].pop()\n Deg[vn] -= 1\n Deg[vf] -= 1\n Edc[(vn, vf) if vn < vf else (vf, vn)] -= 1\n ans.append(vf)\n if not Deg[vf]:\n break\nloop = defaultdict(list)\nfor a in ans:\n if Deg[a]:\n loopa = [a]\n while Deg[a]:\n vn = loopa[-1]\n while True:\n vf = Edge[vn][-1]\n if Deg[vf] != 0 and Edc[(vn, vf) if vn < vf else (vf, vn)]:\n break\n Edge[vn].pop()\n vf = Edge[vn].pop()\n Deg[vn] -= 1\n Deg[vf] -= 1\n Edc[(vn, vf) if vn < vf else (vf, vn)] -= 1\n loopa.append(vf)\n if not Deg[vf]:\n break\n loop[a] = loopa\nAns = [] \nfor a in ans:\n if loop[a]:\n Ans.extend(loop[a])\n loop[a] = []\n else:\n Ans.append(a) \nif len(Ans) != N:\n print(-1)\n return\nprint(*Ans)\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"66dc14bb76e4c7d2b476","document_content":"import sys\n\nn = int(sys.stdin.readline().strip())\na = list(map(int, sys.stdin.readline().strip().split()))\nb = a[:]\nC = [0] * n\nx = [0] * n\nfor i in range (0, 40):\n for j in range (0, n):\n x[j] = b[j] % 2\n b[j] = b[j] \/\/ 2\n if sum(x) == 1:\n for j in range (0, n):\n if x[j] == 1:\n C[j] = C[j] + 2 ** i\nl = C.index(max(C))\nprint(\" \".join(list(map(str, [a[l]]+a[0:l]+a[l+1:]))))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"847ef836547c602365a0","document_content":"def main():\n import sys\n input = sys.stdin.readline\n\n N = int(input())\n A = list(map(int, input().split()))\n\n for j in range(32, -1, -1):\n flg = 0\n for i, a in enumerate(A):\n if a >> j & 1:\n flg += 1\n idx = i\n if flg == 2:\n break\n if flg == 1:\n A[0], A[idx] = A[idx], A[0]\n print(*A)\n return\n print(*A)\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"072022e63156577ff96b","document_content":"import sys\n\n# inf = open('input.txt', 'r')\n# reader = (line.rstrip() for line in inf)\nreader = (line.rstrip() for line in sys.stdin)\ninput = reader.__next__\n\nn = int(input())\na = list(map(int, input().split()))\ndigits = [[] for _ in range(32)]\nfor i, val in enumerate(a):\n shift = 0\n while val > 0:\n if val & 1:\n digits[shift].append(i)\n val >>= 1\n shift += 1\n\nfor i in reversed(list(range(32))):\n if len(digits[i]) == 1:\n idx = digits[i][0]\n a[0], a[idx] = a[idx], a[0]\n break\n\nprint(*a)\n\n# inf.close()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7c7947bc6d8e04a21150","document_content":"n = int(input())\na = [int(i) for i in input().split()]\nonce = 0\ntwice = 2**64\nfor i in a:\n twice |= (once & i)\n once |= i\na = sorted([(i & ~twice,i) for i in a],reverse=True)\na = [j for i,j in a]\nprint(*a)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"96196b4dbabb5d1cdb3d","document_content":"\nn = int(input())\n\na = list(map(int,input().split()))\n\nlis = [0] * 31\n\nfor i in a:\n\n for j in range(31):\n\n if i & (2**j) > 0:\n lis[j] += 1\n\n\nnmax = 0\nmaxind = 0\nfor ind,i in enumerate(a):\n\n for j in range(31):\n\n if lis[j] >= 2:\n\n i |= 2**j\n i -= 2**j\n\n if nmax < i:\n nmax = i\n maxind = ind\n\nans = [a[maxind]]\n\nfor i in range(n):\n\n if i != maxind:\n ans.append(a[i])\n\nprint(\" \".join(map(str,ans)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d33a66e2e1ca74f57dc5","document_content":"n=int(input())\nl=list(map(int,input().split()))\nd={}\nfor i in l:\n b=bin(i)[:1:-1]\n for j in range(len(b)):\n if int(b[j]):\n d[j]=d.get(j,[])\n d[j].append(i)\nfor i in range(31,-1,-1):\n if len(d.get(i,[]))==1:\n v=d[i].pop()\n print(v,end=' ')\n k=0\n for j in l:\n if j==v and k<1:k+=1\n else:print(j,end=' ')\n quit()\nprint(' '.join(map(str,l)))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a896d0d6e32708a63c89","document_content":"n = int(input())\na = list(map(int, input().split()))\n\nfor d in range(29, -1, -1):\n bit = 1 << d\n count, j = 0, 0\n for i, x in enumerate(a):\n if bit & x:\n count += 1\n if count == 2:\n break\n else:\n j = i\n if count == 1:\n print(a[j], *(a[:j] + a[j+1:]))\n break\nelse:\n print(*a)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"066be48cfe0d830e04bf","document_content":"n=int(input())\nl=list(map(int,input().split()))\ncnt=[0]*30\nfor i in range(n):\n\tfor j in range(30):\n\t\tif l[i]&(1<0:\n\t\toptions=newoptions\nprint(l[options[0]],end=\" \")\nfor i in range(n):\n\tif i!=options[0]:\n\t\tprint(l[i],end=\" \")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b21c33e4d8d5c057bd56","document_content":"from collections import defaultdict\n\n\ndef solve(A, N):\n assert len(A) == N\n bitCover = defaultdict(int)\n for x in A:\n for i in range(32):\n if (1 << i) & x:\n bitCover[i] += 1\n # Everything that is covered will be deleted in the final result\n best = (0,)\n for j, x in enumerate(A):\n result = 0\n for i in range(32):\n if (1 << i) & x:\n if bitCover[i] == 1:\n result += 1 << i\n best = max(best, (result, j))\n\n j = best[1]\n A = [A[j]] + A[:j] + A[j + 1 :]\n return ' '.join(map(str, A))\n\n\ndef __starting_point():\n N, = list(map(int, input().split()))\n A = list(map(int, input().split()))\n ans = solve(A, N)\n print(ans)\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5e2898b5ad45f78630f5","document_content":"from collections import defaultdict\nn = int(input())\nxs = list(map(int, input().split()))\ncount = defaultdict(int)\nfor x in xs:\n for i, b in enumerate(reversed(bin(x)[2:])):\n if b != '0':\n count[i] += 1\nrm = 0\nfor k, v in list(count.items()):\n if v > 1:\n rm += 2 ** k\n\nm = -1, 0\nfor i, x in enumerate(xs):\n if (x | rm) - rm > m[0]:\n m = ((x | rm) - rm), i\n\ni = m[1]\nxs = [xs[i]] + xs[:i] + xs[i + 1:]\nprint(' '.join(map(str, xs)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"68f2fed35c5a3a0dc58b","document_content":"\nn = int(input())\nA = list(map(int,input().split()))\n\nB = [[0] * 33 for i in range(n)]\nC = [0] * 33\nfor i in range(n):\n t = A[i]\n j = 0\n while t > 0:\n B[i][j] += t%2\n C[j] += B[i][j]\n t\/\/=2\n j += 1\n\nM2 = [1]\nfor i in range(40):\n M2.append(M2[-1]*2)\n\nS = [0] * n\nfor i in range(n):\n for j in range(33):\n if B[i][j] == 1:\n if C[j] == 1:\n S[i] += M2[j]\n\nind = S.index(max(S))\nANS = [A[ind]]\nfor i in range(n):\n if i != ind:\n ANS.append(A[i])\nprint(\" \".join([str(i) for i in ANS]))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cb8dab26c5b69fdc9277","document_content":"import sys\nimport math\nfrom collections import defaultdict\nfrom collections import deque\nfrom itertools import combinations\nfrom itertools import permutations\ninput = lambda : sys.stdin.readline().rstrip()\nread = lambda : list(map(int, input().split()))\ngo = lambda : 1\/0\ndef write(*args, sep=\"\\n\"):\n for i in args:\n sys.stdout.write(\"{}{}\".format(i, sep))\nINF = float('inf')\nMOD = int(1e9 + 7)\nYES = \"YES\"\nNO = \"NO\"\n\ndef f(x):\n return bin(x)[2:][::-1]\n\nn = int(input())\ncnt = [0] * 100\narr = read()\n\nfor i in arr:\n s = f(i)\n\n for j in range(len(s)):\n if s[j] == \"1\":\n cnt[j] += 1\n\nans = [-INF, -INF]\nfor i in arr:\n s = f(i)\n\n for j in range(len(s)):\n if s[j] == \"1\":\n cnt[j] -= 1\n\n x = []\n for j in range(len(s)):\n if cnt[j] == 0:\n x.append(s[j])\n else:\n x.append(\"0\")\n \n ans = max(ans, [int(\"\".join(x)[::-1], 2), i])\n \n\n for j in range(len(s)):\n if s[j] == \"1\":\n cnt[j] += 1\n\narr.remove(ans[1])\n\nprint(ans[1], *arr)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"da14e2dac08f6089b51e","document_content":"\"\"\"Cowboy Beblop at his computer, problem 717I from https:\/\/codeforces.com\/problemset\/problem\/717\/I\"\"\"\n# from fractions import Fraction\n\n\n# def convert_to_fractions(poly):\n# \"\"\"convert polygon vertex to fractional type\"\"\"\n# poly_frac = []\n# for x, y, z in poly:\n# vertex = (Fraction(x),\n# Fraction(y),\n# Fraction(z))\n# poly_frac.append(vertex)\n# return poly_frac\n\n\ndef convert_to_float(poly):\n \"\"\"convert polygon vertex to float type\"\"\"\n poly_float = []\n for x, y, z in poly:\n vertex = (float(x),\n float(y),\n float(z))\n poly_float.append(vertex)\n return poly_float\n\n\ndef cross_product(a, b):\n \"\"\"3-vector product\"\"\"\n return (a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] - a[1] * b[0])\n\n\ndef dot_product(a, b):\n \"\"\"scalar product of 3-vectors\"\"\"\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n\n\ndef vect_diff(a, b):\n \"\"\"vector difference\"\"\"\n return a[0] - b[0], a[1] - b[1], a[2] - b[2]\n\n\ndef poly_normal(poly):\n \"\"\"return normal vector for first three vertex\"\"\"\n assert len(poly) >= 3\n x, y, z = poly[:3]\n u = vect_diff(y, x)\n v = vect_diff(z, y)\n return cross_product(u, v)\n\n\ndef intersect_list(poly, plain_norm, plain_point, proj_dir):\n \"\"\"list of intersection points\n\n find points where the edges enter or leave upper half-space over the plain\n :return list of points projection on proj_dir\n \"\"\"\n # vertex projection\n u = [dot_product(vert, proj_dir) for vert in poly]\n\n # plain anchor\n vr = dot_product(plain_point, plain_norm)\n\n # polygon vertex\n v = [dot_product(vert, plain_norm) for vert in poly]\n\n u_list = []\n for i in range(len(poly)):\n if (v[i-1] > vr) != (v[i] > vr):\n ur = ((vr - v[i-1]) * u[i] + (v[i] - vr) * u[i-1]) \/ (v[i] - v[i-1])\n u_list.append(ur)\n\n return u_list\n\n\ndef points_to_str(a_points, b_points):\n \"\"\"string representing the order of points 'a' and 'b'\"\"\"\n a_pairs = [('a', val) for val in a_points]\n b_pairs = [('b', val) for val in b_points]\n pairs = sorted(a_pairs + b_pairs, key=lambda pair: pair[1])\n letters = [ch for ch, _ in pairs]\n return ''.join(letters)\n\n\ndef recognize_str(s):\n \"\"\"return True if string s belong to the grammar\n\n The context-free grammar is given\n S -> SS\n S -> a S a\n S -> b S b\n S -> e\n\n The recognising automaton is implemented\n \"\"\"\n toggle = {'a':'b', 'b':'a'}\n cross_num = 0\n top = None\n for ch in s:\n if not cross_num:\n cross_num = 1\n top = ch\n continue\n\n if ch == top:\n cross_num -= 1\n else:\n cross_num += 1\n\n if cross_num:\n top = toggle[top]\n else:\n top = None\n return not cross_num\n\n\ndef is_well_connected(a, b):\n \"\"\"Two planar polygons are bind together in 3D\n\n Arguments:\n a_poly,\n b_poly -- lists of vertex triples\n \"\"\"\n a = convert_to_float(a)\n b = convert_to_float(b)\n\n a_norm = poly_normal(a)\n b_norm = poly_normal(b)\n\n common_dir = cross_product(a_norm, b_norm)\n if not any(common_dir):\n return False\n\n a_list = intersect_list(a, b_norm, b[0], common_dir)\n b_list = intersect_list(b, a_norm, a[0], common_dir)\n\n char_str = points_to_str(a_list, b_list)\n return not recognize_str(char_str)\n\n\ndef run_from_console():\n a_len, = [int(num) for num in input().split()]\n\n a = []\n for _ in range(a_len):\n vertex = tuple(int(num) for num in input().split())\n a.append(vertex)\n\n b_len, = [int(num) for num in input().split()]\n\n b = []\n for _ in range(b_len):\n vertex = tuple(int(num) for num in input().split())\n b.append(vertex)\n\n if is_well_connected(a, b):\n print('YES')\n else:\n print('NO')\n\n\ndef __starting_point():\n run_from_console()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"96a93548335054e60955","document_content":"def convert_to_float(poly):\n \"\"\"convert polygon vertex to float type\"\"\"\n poly_float = []\n for x, y, z in poly:\n vertex = (float(x),\n float(y),\n float(z))\n poly_float.append(vertex)\n return poly_float\n \n \ndef cross_product(a, b):\n \"\"\"3-vector product\"\"\"\n return (a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] - a[1] * b[0])\n \n \ndef dot_product(a, b):\n \"\"\"scalar product of 3-vectors\"\"\"\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n \n \ndef vect_diff(a, b):\n \"\"\"vector difference\"\"\"\n return a[0] - b[0], a[1] - b[1], a[2] - b[2]\n \n \ndef poly_normal(poly):\n \"\"\"return normal vector for first three vertex\"\"\"\n assert len(poly) >= 3\n x, y, z = poly[:3]\n u = vect_diff(y, x)\n v = vect_diff(z, y)\n return cross_product(u, v)\n \n \ndef intersect_list(poly, plain_norm, plain_point, proj_dir):\n \"\"\"list of intersection points\n \n find points where the edges enter or leave upper half-space over the plain\n :return list of points projection on proj_dir\n \"\"\"\n # vertex projection\n u = [dot_product(vert, proj_dir) for vert in poly]\n \n # plain anchor\n vr = dot_product(plain_point, plain_norm)\n \n # polygon vertex\n v = [dot_product(vert, plain_norm) for vert in poly]\n \n u_list = []\n for i in range(len(poly)):\n if (v[i-1] > vr) != (v[i] > vr):\n ur = ((vr - v[i-1]) * u[i] + (v[i] - vr) * u[i-1]) \/ (v[i] - v[i-1])\n u_list.append(ur)\n \n return u_list\n \n \ndef points_to_str(a_points, b_points):\n \"\"\"string representing the order of points 'a' and 'b'\"\"\"\n a_pairs = [('a', val) for val in a_points]\n b_pairs = [('b', val) for val in b_points]\n pairs = sorted(a_pairs + b_pairs, key=lambda pair: pair[1])\n letters = [ch for ch, _ in pairs]\n return ''.join(letters)\n \n \ndef recognize_str(s):\n \"\"\"return True if string s belong to the grammar\n \n The context-free grammar is given\n S -> SS\n S -> a S a\n S -> b S b\n S -> e\n \n The recognising automaton is implemented\n \"\"\"\n toggle = {'a':'b', 'b':'a'}\n cross_num = 0\n top = None\n for ch in s:\n if not cross_num:\n cross_num = 1\n top = ch\n continue\n \n if ch == top:\n cross_num -= 1\n else:\n cross_num += 1\n \n if cross_num:\n top = toggle[top]\n else:\n top = None\n return not cross_num\n \n \ndef is_well_connected(a, b):\n \"\"\"Two planar polygons are bind together in 3D\n \n Arguments:\n a_poly,\n b_poly -- lists of vertex triples\n \"\"\"\n a = convert_to_float(a)\n b = convert_to_float(b)\n \n a_norm = poly_normal(a)\n b_norm = poly_normal(b)\n \n common_dir = cross_product(a_norm, b_norm)\n if not any(common_dir):\n return False\n \n a_list = intersect_list(a, b_norm, b[0], common_dir)\n b_list = intersect_list(b, a_norm, a[0], common_dir)\n \n char_str = points_to_str(a_list, b_list)\n return not recognize_str(char_str)\n \n \ndef run_from_console():\n a_len, = [int(num) for num in input().split()]\n \n a = []\n for _ in range(a_len):\n vertex = tuple(int(num) for num in input().split())\n a.append(vertex)\n \n b_len, = [int(num) for num in input().split()]\n \n b = []\n for _ in range(b_len):\n vertex = tuple(int(num) for num in input().split())\n b.append(vertex)\n \n if is_well_connected(a, b):\n print('YES')\n else:\n print('NO')\n \n \ndef __starting_point():\n run_from_console()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"802907ff3cd7aad2a3de","document_content":"from math import gcd, sqrt\nfrom functools import reduce\nimport sys\n\ninput = sys.stdin.readline\n\nEPS = 0.0000000001\n\ndef inp():\n return(int(input()))\n\ndef inlt():\n return(list(map(int,input().split())))\n\ndef GCD(args):\n return reduce(gcd, args)\n\ndef plane_value(plane, point):\n A, B, C, D = plane\n x, y, z = point\n return A*x + B*y + C*z + D\n\ndef plane(p1, p2, p3):\n x1, y1, z1 = p1\n x2, y2, z2 = p2\n x3, y3, z3 = p3\n a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1\n a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1\n a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2\n d = (- a * x1 - b * y1 - c * z1)\n g = GCD([a,b,c,d])\n return a\/\/g, b\/\/g, c\/\/g, d\/\/g\n\ndef cross(a, b):\n return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])\n\ndef intersection_of_two_planes(p1, p2):\n A1, B1, C1, D1 = p1\n A2, B2, C2, D2 = p2\n#\n crossprod = cross([A1,B1,C1],[A2,B2,C2])\n\n if (A1*B2-A2*B1) != 0:\n x = ((B1*D2-B2*D1)\/(A1*B2-A2*B1), crossprod[0])\n y = ((A2*D1-A1*D2)\/(A1*B2-A2*B1), crossprod[1])\n z = (0,crossprod[2])\n elif (B1*C2-B2*C1) != 0:\n x = (0,crossprod[0])\n y = ((C1*D2-C2*D1)\/(B1*C2-B2*C1), crossprod[1])\n z = ((B2*D1-B1*D2)\/(B1*C2-B2*C1), crossprod[2])\n elif (A1*C2-A2*C1) != 0:\n x = ((C1*D2-C2*D1)\/(A1*C2-A2*C1), crossprod[0])\n y = (0,crossprod[1])\n z = ((A2*D1-A1*D2)\/(A1*C2-A2*C1), crossprod[2])\n else:\n return None\n\n return x, y, z\n\ndef line_parametric(p1, p2):\n x1, y1, z1 = p1\n x2, y2, z2 = p2\n return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)\n\ndef solve_2_by_2(row1, row2):\n a1, b1, c1 = row1\n a2, b2, c2 = row2\n if a1*b2-b1*a2:\n return (c1*b2-b1*c2)\/(a1*b2-b1*a2), (a1*c2-c1*a2)\/(a1*b2-b1*a2)\n else:\n return None\n\ndef sgn(x):\n return 1 if x>0 else 0 if x==0 else -1\n\ndef lines_intersection_point(i1, i2):\n x1, y1, z1 = i1\n x2, y2, z2 = i2\n\n try:\n t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])\n if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:\n return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2\n else:\n return None\n except:\n try:\n t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])\n if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:\n return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2\n else:\n return None\n except:\n try:\n t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])\n if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:\n return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2\n else:\n return None\n except:\n return None\n\ndef foo(points):\n down_cnt, up_cnt = 0, 0\n first = points[0]\n other = 1-first\n down = True\n intrusion = True\n for p in points[1:]:\n if p==first:\n intrusion = not intrusion\n else:\n if intrusion:\n if down:\n down_cnt+=1\n else:\n up_cnt+=1\n down = not down\n return down_cnt==up_cnt\n\ndef populate(plane, poly, tag):\n res = []\n prev = plane_value(plane,poly[-1])\n prev_serious = plane_value(plane,poly[-2]) if not prev else prev\n p_prev = poly[-1]\n for i in range(len(poly)+1):\n p = poly[i%len(poly)]\n curr = plane_value(plane,p)\n if sgn(curr) == -sgn(prev_serious):\n intersector = line_parametric(p_prev,p)\n point, t = lines_intersection_point(intersector,intersectee)\n res.append((t,tag))\n prev_serious = curr\n if sgn(curr):\n prev_serious = curr\n prev, p_prev = curr, p\n return res\n\nx_poly, y_poly = [], []\n\nfor _ in range(inp()):\n x_poly.append(inlt())\nfor _ in range(inp()):\n y_poly.append(inlt())\n\nx_plane = plane(*x_poly[:3])\ny_plane = plane(*y_poly[:3])\n\nintersectee = intersection_of_two_planes(x_plane,y_plane)\n\nif intersectee:\n points = sorted(set(populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)))\n points = [i[1] for i in points]\n\n print('NO' if foo(points) else 'YES')\nelse:\n print('NO')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"52105366a8608f422413","document_content":"from math import gcd, sqrt\nfrom functools import reduce\nimport sys\n\ninput = sys.stdin.readline\n\nEPS = 0.000000001\n\ndef inp():\n return(int(input()))\n\ndef inlt():\n return(list(map(int,input().split())))\n\ndef GCD(args):\n return reduce(gcd, args)\n\ndef plane_value(plane, point):\n A, B, C, D = plane\n x, y, z = point\n return A*x + B*y + C*z + D\n\ndef plane(p1, p2, p3):\n x1, y1, z1 = p1\n x2, y2, z2 = p2\n x3, y3, z3 = p3\n a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1\n a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1\n a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2\n d = (- a * x1 - b * y1 - c * z1)\n g = GCD([a,b,c,d])\n return a\/\/g, b\/\/g, c\/\/g, d\/\/g\n\ndef cross(a, b):\n return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])\n\ndef intersection_of_two_planes(p1, p2):\n A1, B1, C1, D1 = p1\n A2, B2, C2, D2 = p2\n\n crossprod = cross([A1,B1,C1],[A2,B2,C2])\n\n if (A1*B2-A2*B1) != 0:\n x = ((B1*D2-B2*D1)\/(A1*B2-A2*B1), crossprod[0])\n y = ((A2*D1-A1*D2)\/(A1*B2-A2*B1), crossprod[1])\n z = (0,crossprod[2])\n elif (B1*C2-B2*C1) != 0:\n x = (0,crossprod[0])\n y = ((C1*D2-C2*D1)\/(B1*C2-B2*C1), crossprod[1])\n z = ((B2*D1-B1*D2)\/(B1*C2-B2*C1), crossprod[2])\n elif (A1*C2-A2*C1) != 0:\n x = ((C1*D2-C2*D1)\/(A1*C2-A2*C1), crossprod[0])\n y = (0,crossprod[1])\n z = ((A2*D1-A1*D2)\/(A1*C2-A2*C1), crossprod[2])\n else:\n return None\n\n return x, y, z\n\ndef line_parametric(p1, p2):\n x1, y1, z1 = p1\n x2, y2, z2 = p2\n return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)\n\ndef solve_2_by_2(row1, row2):\n a1, b1, c1 = row1\n a2, b2, c2 = row2\n if a1*b2-b1*a2:\n return (c1*b2-b1*c2)\/(a1*b2-b1*a2), (a1*c2-c1*a2)\/(a1*b2-b1*a2)\n else:\n return None\n\ndef sgn(x):\n return 1 if x>0 else 0 if x==0 else -1\n\ndef lines_intersection_point(i1, i2):\n x1, y1, z1 = i1\n x2, y2, z2 = i2\n\n try:\n t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])\n if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:\n return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2\n else:\n return None\n except:\n try:\n t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])\n if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:\n return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2\n else:\n return None\n except:\n try:\n t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])\n if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:\n return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2\n else:\n return None\n except:\n return None\n\ndef foo(points):\n down_cnt, up_cnt = 0, 0\n first = points[0]\n other = 1-first\n down = True\n intrusion = True\n for p in points[1:]:\n if p==first:\n intrusion = not intrusion\n else:\n if intrusion:\n if down:\n down_cnt+=1\n else:\n up_cnt+=1\n down = not down\n return down_cnt==up_cnt\n\ndef populate(plane, poly, tag):\n res = []\n prev = plane_value(plane,poly[-1])\n prev_serious = plane_value(plane,poly[-2]) if not prev else prev\n p_prev = poly[-1]\n for i in range(len(poly)+1):\n p = poly[i%len(poly)]\n curr = plane_value(plane,p)\n if sgn(curr) == -sgn(prev_serious):\n intersector = line_parametric(p_prev,p)\n point, t = lines_intersection_point(intersector,intersectee)\n res.append((t,tag))\n prev_serious = curr\n if sgn(curr):\n prev_serious = curr\n prev, p_prev = curr, p\n return res\n\nx_poly, y_poly = [], []\n\nfor _ in range(inp()):\n x_poly.append(inlt())\nfor _ in range(inp()):\n y_poly.append(inlt())\n\nx_plane = plane(*x_poly[:3])\ny_plane = plane(*y_poly[:3])\n\nintersectee = intersection_of_two_planes(x_plane,y_plane)\n\nif intersectee:\n points = sorted(set(populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)))\n points = [i[1] for i in points]\n\n print('NO' if foo(points) else 'YES')\nelse:\n print('NO')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dcefac6b19b677a166c5","document_content":"def convert_to_float(poly):\n \"\"\"convert polygon vertex to float type\"\"\"\n poly_float = []\n for x, y, z in poly:\n vertex = (float(x),\n float(y),\n float(z))\n poly_float.append(vertex)\n return poly_float\n \n \ndef cross_product(a, b):\n \"\"\"3-vector product\"\"\"\n return (a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] - a[1] * b[0])\n \n \ndef dot_product(a, b):\n \"\"\"scalar product of 3-vectors\"\"\"\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n \n \ndef vect_diff(a, b):\n \"\"\"vector difference\"\"\"\n return a[0] - b[0], a[1] - b[1], a[2] - b[2]\n \n \ndef poly_normal(poly):\n \"\"\"return normal vector for first three vertex\"\"\"\n assert len(poly) >= 3\n x, y, z = poly[:3]\n u = vect_diff(y, x)\n v = vect_diff(z, y)\n return cross_product(u, v)\n \n \ndef intersect_list(poly, plain_norm, plain_point, proj_dir):\n \"\"\"list of intersection points\n \n find points where the edges enter or leave upper half-space over the plain\n :return list of points projection on proj_dir\n \"\"\"\n u = [dot_product(vert, proj_dir) for vert in poly]\n \n vr = dot_product(plain_point, plain_norm)\n \n v = [dot_product(vert, plain_norm) for vert in poly]\n \n u_list = []\n for i in range(len(poly)):\n if (v[i-1] > vr) != (v[i] > vr):\n ur = ((vr - v[i-1]) * u[i] + (v[i] - vr) * u[i-1]) \/ (v[i] - v[i-1])\n u_list.append(ur)\n \n return u_list\n \n \ndef points_to_str(a_points, b_points):\n \"\"\"string representing the order of points 'a' and 'b'\"\"\"\n a_pairs = [('a', val) for val in a_points]\n b_pairs = [('b', val) for val in b_points]\n pairs = sorted(a_pairs + b_pairs, key=lambda pair: pair[1])\n letters = [ch for ch, _ in pairs]\n return ''.join(letters)\n \n \ndef recognize_str(s):\n \"\"\"return True if string s belong to the grammar\n \n The context-free grammar is given\n S -> SS\n S -> a S a\n S -> b S b\n S -> e\n \n The recognising automaton is implemented\n \"\"\"\n toggle = {'a':'b', 'b':'a'}\n cross_num = 0\n top = None\n for ch in s:\n if not cross_num:\n cross_num = 1\n top = ch\n continue\n \n if ch == top:\n cross_num -= 1\n else:\n cross_num += 1\n \n if cross_num:\n top = toggle[top]\n else:\n top = None\n return not cross_num\n \n \ndef is_well_connected(a, b):\n \"\"\"Two planar polygons are bind together in 3D\n \n Arguments:\n a_poly,\n b_poly -- lists of vertex triples\n \"\"\"\n a = convert_to_float(a)\n b = convert_to_float(b)\n \n a_norm = poly_normal(a)\n b_norm = poly_normal(b)\n \n common_dir = cross_product(a_norm, b_norm)\n if not any(common_dir):\n return False\n \n a_list = intersect_list(a, b_norm, b[0], common_dir)\n b_list = intersect_list(b, a_norm, a[0], common_dir)\n \n char_str = points_to_str(a_list, b_list)\n return not recognize_str(char_str)\n \n \ndef run_from_console():\n a_len, = [int(num) for num in input().split()]\n \n a = []\n for _ in range(a_len):\n vertex = tuple(int(num) for num in input().split())\n a.append(vertex)\n \n b_len, = [int(num) for num in input().split()]\n \n b = []\n for _ in range(b_len):\n vertex = tuple(int(num) for num in input().split())\n b.append(vertex)\n \n if is_well_connected(a, b):\n print('YES')\n else:\n print('NO')\n \n \ndef __starting_point():\n run_from_console()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"77153b332cd19415aac9","document_content":"\ndef convert_to_float(poly):\n \"\"\"convert polygon vertex to float type\"\"\"\n poly_float = []\n for x, y, z in poly:\n vertex = (float(x),\n float(y),\n float(z))\n poly_float.append(vertex)\n return poly_float\n \n \ndef cross_product(a, b):\n \"\"\"3-vector product\"\"\"\n return (a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] - a[1] * b[0])\n \n \ndef dot_product(a, b):\n \"\"\"scalar product of 3-vectors\"\"\"\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n \n \ndef vect_diff(a, b):\n \"\"\"vector difference\"\"\"\n return a[0] - b[0], a[1] - b[1], a[2] - b[2]\n \n \ndef poly_normal(poly):\n \"\"\"return normal vector for first three vertex\"\"\"\n assert len(poly) >= 3\n x, y, z = poly[:3]\n u = vect_diff(y, x)\n v = vect_diff(z, y)\n return cross_product(u, v)\n \n \ndef intersect_list(poly, plain_norm, plain_point, proj_dir):\n \"\"\"list of intersection points\n \n find points where the edges enter or leave upper half-space over the plain\n :return list of points projection on proj_dir\n \"\"\"\n # vertex projection\n u = [dot_product(vert, proj_dir) for vert in poly]\n \n # plain anchor\n vr = dot_product(plain_point, plain_norm)\n \n # polygon vertex\n v = [dot_product(vert, plain_norm) for vert in poly]\n \n u_list = []\n for i in range(len(poly)):\n if (v[i-1] > vr) != (v[i] > vr):\n ur = ((vr - v[i-1]) * u[i] + (v[i] - vr) * u[i-1]) \/ (v[i] - v[i-1])\n u_list.append(ur)\n \n return u_list\n \n \ndef points_to_str(a_points, b_points):\n \"\"\"string representing the order of points 'a' and 'b'\"\"\"\n a_pairs = [('a', val) for val in a_points]\n b_pairs = [('b', val) for val in b_points]\n pairs = sorted(a_pairs + b_pairs, key=lambda pair: pair[1])\n letters = [ch for ch, _ in pairs]\n return ''.join(letters)\n \n \ndef recognize_str(s):\n \"\"\"return True if string s belong to the grammar\n \n The context-free grammar is given\n S -> SS\n S -> a S a\n S -> b S b\n S -> e\n \n The recognising automaton is implemented\n \"\"\"\n toggle = {'a':'b', 'b':'a'}\n cross_num = 0\n top = None\n for ch in s:\n if not cross_num:\n cross_num = 1\n top = ch\n continue\n \n if ch == top:\n cross_num -= 1\n else:\n cross_num += 1\n \n if cross_num:\n top = toggle[top]\n else:\n top = None\n return not cross_num\n \n \ndef is_well_connected(a, b):\n \"\"\"Two planar polygons are bind together in 3D\n \n Arguments:\n a_poly,\n b_poly -- lists of vertex triples\n \"\"\"\n a = convert_to_float(a)\n b = convert_to_float(b)\n \n a_norm = poly_normal(a)\n b_norm = poly_normal(b)\n \n common_dir = cross_product(a_norm, b_norm)\n if not any(common_dir):\n return False\n \n a_list = intersect_list(a, b_norm, b[0], common_dir)\n b_list = intersect_list(b, a_norm, a[0], common_dir)\n \n char_str = points_to_str(a_list, b_list)\n return not recognize_str(char_str)\n \n \ndef run_from_console():\n a_len, = [int(num) for num in input().split()]\n \n a = []\n for _ in range(a_len):\n vertex = tuple(int(num) for num in input().split())\n a.append(vertex)\n \n b_len, = [int(num) for num in input().split()]\n \n b = []\n for _ in range(b_len):\n vertex = tuple(int(num) for num in input().split())\n b.append(vertex)\n \n if is_well_connected(a, b):\n print('YES')\n else:\n print('NO')\n \n \ndef __starting_point():\n run_from_console()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"96c49c37ecc5f246b36b","document_content":"n = int(input())\nfirst = {}\nsecond = set()\ns1 = [0] * n\nans = [0] * n\nfor i in range(n):\n a, b = input().split()\n a = a[:3]\n b = b[0]\n s1[i] = b\n if a in first.keys():\n first[a].append(i)\n else:\n first[a] = [i]\n ans[i] = a\nF = True\nfor name in first.keys():\n if not F:\n break\n if len(first[name]) > 1:\n for i in first[name]:\n c = name[:2] + s1[i]\n if c in second:\n F = False\n break\n else:\n second.add(c)\n ans[i] = c\n first[name] = 0\n\ndef process(name):\n nonlocal F\n if F == False:\n return\n if first[name] != 0 and name in second:\n t = first[name][0]\n c = name[:2] + s1[t]\n if c in second:\n F = False\n return\n else:\n second.add(c)\n ans[t] = c\n first[name] = 0\n if c in first.keys() and first[c] != 0:\n process(c)\n \n\n\nfor name in first.keys():\n process(name)\n \n\nif F:\n print('YES')\n for i in range(n):\n print(ans[i])\nelse:\n print('NO')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"13b6ee2bc5b2f7e56444","document_content":"def sol():\n n=int(input())\n club=['']*n\n city=['']*n\n mp={}\n for i in range(n):\n s=input().split()\n club[i]=s[0][:3]\n city[i]=s[1][:1]\n if club[i] in mp:\n mp[club[i]].add(i)\n else:\n mp[club[i]]=set()\n mp[club[i]].add(i)\n \n def rename(abc ,i):\n if abc in name:\n return False\n name[abc]=i \n if abc in mp and len(mp[abc])==1:\n for j in mp[abc] :\n if club[j][:2]+city[j] in name:\n return False\n \n mp[abc].clear()\n #name[club[j][:2]+city[j]]=j \n return rename(club[j][:2]+city[j],j)\n return True \n \n for clubname in mp:\n if len(mp[clubname])>1:\n for i in mp[clubname]:\n abc=club[i][:2]+city[i]\n if abc in name:\n return False\n if not rename(abc,i):\n return False\n \n \n \n for clubname in mp:\n if len(mp[clubname])==1:\n for i in mp[clubname]:\n name[clubname]=i \n return True\nname={}\nif sol() :\n print('YES')\n l=['']*len(name)\n for s in name:\n l[name[s]]=s \n for i in range(len(l)):\n print(l[i]) \nelse:\n print('NO')\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3196069ea33120bda9cf","document_content":"def sol():\n n=int(input())\n club=['']*n\n city=['']*n\n mp={}\n for i in range(n):\n s=input().split()\n club[i]=s[0][:3]\n city[i]=s[1][:1]\n if club[i] in mp:\n mp[club[i]].add(i)\n else:\n mp[club[i]]=set()\n mp[club[i]].add(i)\n \n def rename(abc ,i):\n if abc in name:\n return False\n name[abc]=i \n if abc in mp and len(mp[abc])==1:\n for j in mp[abc] :\n if club[j][:2]+city[j] in name:\n return False\n \n mp[abc].clear()\n #name[club[j][:2]+city[j]]=j \n return rename(club[j][:2]+city[j],j)\n return True \n \n for clubname in mp:\n if len(mp[clubname])>1:\n for i in mp[clubname]:\n abc=club[i][:2]+city[i]\n if abc in name:\n return False\n if not rename(abc,i):\n return False\n \n \n \n for clubname in mp:\n if len(mp[clubname])==1:\n for i in mp[clubname]:\n name[clubname]=i \n return True\nname={}\n\nif sol() :\n print('YES')\n l=['']*len(name)\n for s in name:\n l[name[s]]=s \n for i in range(len(l)):\n print(l[i]) \nelse:\n print('NO')\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6eb8f466db964836be66","document_content":"from collections import defaultdict\nnames = int(input())\ninp = [input().split() for x in range(names)]\nchoice = []\nres = defaultdict(lambda: [])\nfor x, word in enumerate(inp):\n choice.append(False)\n res[word[0][:3]].append(x)\n\nwhile True:\n changes = []\n for key in list(res.keys()):\n if len(res[key]) > 1:\n # All choice = False options must be changed\n remove = []\n for i, index in enumerate(res[key]):\n if choice[index]: continue\n remove.append(i)\n choice[index] = True\n changes.append((inp[index][0][:2] + inp[index][1][0], index))\n for i in remove[::-1]:\n del res[key][i]\n if len(changes) == 0: break\n for word, i in changes:\n res[word].append(i)\n\nbad = False\nfor key in list(res.keys()):\n if len(res[key]) > 1: bad = True\n\nif bad:\n print(\"NO\")\nelse:\n print(\"YES\")\n for i in range(names):\n if choice[i]:\n print(inp[i][0][:2] + inp[i][1][0])\n else:\n print(inp[i][0][:3])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"eb1221a9f0c96ee14742","document_content":"from sys import stdin\n\nn = int(stdin.readline().strip())\nT,A = [],[]\nN,M = {},{}\nfor _ in range(n):\n t,h = stdin.readline().split()\n n1,n2 = t[:3],t[:2]+h[0]\n N[n1] = N.get(n1,0)+1\n T.append((n1,n2))\n A.append(n1)\n\ndef solve():\n for i in range(n):\n n1,n2 = T[i]\n if n1 not in M and N[n1]==1:\n M[n1] = i\n continue\n while n2 in M:\n j = M[n2]\n if n2==T[j][1]:\n return False\n M[n2],A[i]=i,n2\n i,n2 = j,T[j][1]\n else:\n M[n2],A[i] = i,n2\n return True\n\nif solve():\n print(\"YES\")\n print('\\n'.join(A))\nelse:\n print(\"NO\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"253c31307002a083b822","document_content":"#return if sa contains a real prefix: sb\ndef isPrefix( sa , sb ):\n if len(sa) <= len(sb):\n return False\n return sa[0:len(sb)] == sb\n\ndef getOrder( sa , sb ):\n for i in range( 0 , min( len(sa) , len(sb) ) ):\n if sa[i] != sb[i]:\n return sa[i],sb[i]\n\ntest = False\nif test:\n fp = open(\"C-4.in\",\"r\")\n n = int(fp.readline().strip())\n names = [ fp.readline().strip() for i in range(0,n)]\n fp.close()\nelse:\n n = int(input().strip())\n names = [ input().strip() for i in range(0,n)]\n\ng = [[False]*26 for i in range(0,26)]\n\nres = True\nfor i in range(1,n):\n if names[i-1] == names[i] or isPrefix( names[i] , names[i-1] ):\n continue\n elif isPrefix( names[i-1] , names[i] ):\n res = False\n break\n else:\n ca,cb = getOrder( names[i-1] , names[i] )\n #print(ca,\"<\",cb)\n if g[ord(cb)-ord('a')][ord(ca)-ord('a')]:\n res = False\n break\n else:\n g[ord(ca)-ord('a')][ord(cb)-ord('a')] = True\n\ndef printG():\n print(\" abcdefghijklmnopqrstuvwxyz\")\n for i in range(0,26):\n print( chr( ord(\"a\") + i ) , \"\".join( [ \"1\" if x else \"0\" for x in g[i]] ) , sep = \"\")\n#printG()\n\nif not res:\n print(\"Impossible\")\nelse:\n\n def getZeroIndegreeNode():\n for i in range(0,26):\n if not used[i] and indegree[i] == 0:\n return i\n return -1\n #topo sort\n theOrder = []\n indegree = [0] * 26\n used = [False] * 26\n\n #calc indegree\n for i in range(0,26):\n ithIndegree = 0\n for j in range(0,26):\n if g[j][i]: ithIndegree += 1\n indegree[i] = ithIndegree\n \n for i in range(0,26):\n zeroIndegreeNode = getZeroIndegreeNode()\n if zeroIndegreeNode == -1:\n res = False\n break\n else:\n used[zeroIndegreeNode] = True\n theOrder.append( chr( ord('a') + zeroIndegreeNode ) )\n for j in range(0,26):\n if g[zeroIndegreeNode][j]:\n indegree[j] -= 1\n\n if not res:\n print(\"Impossible\")\n else:\n print( \"\".join( theOrder ) )\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2d503c3acb9d66a51b41","document_content":"#import sys\n#sys.stdin = open('in.txt')\n#sys.setrecursionlimit(10000)\ndef isPrefix(sa, sb):\n if len(sa) <= len(sb):\n return False\n return sa[0:len(sb)] == sb\n\ndef getOrder(sa, sb):\n for i in range(0, min(len(sa), len(sb))):\n if sa[i] != sb[i]: \n return sa[i], sb[i]\n\ntest = False\nif test:\n fp = open(\"in.txt\", 'r')\n n = int(fp.readline().strip())\n names = [fp.readline().strip() for i in range(0, n)]\n fp.close()\nelse:\n n = int(input().strip())\n names = [input().strip() for i in range(0, n)]\n \ng = [[False] * 26 for i in range(0, 26)]\n\nres = True\nfor i in range(1, n):\n if names[i - 1] == names[i] or isPrefix(names[i], names[i - 1]):\n continue\n elif isPrefix(names[i - 1], names[i]):\n res = False\n break\n else:\n ca, cb = getOrder(names[i - 1], names[i])\n #print(ca, '<', cb)\n if g[ord(cb) - ord('a')][ord(ca) - ord('a')]:\n res = False\n break\n else:\n g[ord(ca) - ord('a')][ord(cb) - ord('a')] = True\n\ndef printG():\n print(\" abcdefghijklmnopqrstuvwxyz\")\n for i in range(0, 26):\n print(chr(ord('a') + i), \"\".join([\"1\" if x else \"0\" for x in g[i]]), sep = \n\n\"\")\n#printG()\n\nif not res:\n print(\"Impossible\")\nelse:\n \n def getZeroIndegreeNode():\n for i in range(0, 26):\n if not used[i] and indegree[i] == 0:\n return i\n return -1\n #topo sort\n theOrder = []\n indegree = [0] * 26\n used = [False] * 26\n \n #calc indegree\n for i in range(0, 26):\n ithIndegree = 0\n for j in range(0, 26):\n if g[j][i]: ithIndegree += 1\n indegree[i] = ithIndegree\n for i in range(0, 26):\n zeroIndegreeNode = getZeroIndegreeNode()\n if zeroIndegreeNode == -1:\n res = False\n break\n else:\n used[zeroIndegreeNode] = True\n theOrder.append(chr(ord('a') + zeroIndegreeNode))\n for j in range(0, 26):\n if g[zeroIndegreeNode][j]:\n indegree[j] -= 1\n if not res:\n print(\"Impossible\")\n else:\n print(\"\".join(theOrder))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3aed751ffffcdbc6d6df","document_content":"#import sys\n#sys.stdin = open('in.txt')\n#sys.setrecursionlimit(10000)\ndef isPrefix(sa, sb):\n if len(sa) >= len(sb):\n return False\n return sa == sb[0:len(sa)]\n\ndef getOrder(sa, sb):\n for i in range(min(len(sa), len(sb))):\n if sa[i] != sb[i]:\n return sa[i], sb[i]\n\ntest = False\nif test:\n fp = open('in.txt', 'r')\n n = int(fp.readline().strip())\n names = [fp.readline().strip() for _ in range(n)]\n fp.close()\nelse:\n n = int(input().strip())\n names = [input().strip() for _ in range(n)]\n\nres = True\ng = [[False] * 26 for _ in range(26)]\n\"\"\"\nfor i in range(26):\n for j in range(26):\n g[i][j] = False\n\"\"\"\ndef printG():\n print(\" abcdefghijklmnopqrstuvwxyz\")\n for i in range(0, 26):\n print(chr(ord('a') + i), \"\".join([\"1\" if x else \"0\" for x in g[i]]), sep = \n\n\"\")\n#get a table\nfor i in range(n - 1):\n if names[i] == names[i + 1] or isPrefix(names[i], names[i + 1]):\n continue\n elif isPrefix(names[i + 1], names[i]):\n res = False\n break\n else:\n ca, cb = getOrder(names[i], names[i + 1])\n #print(ca, '<', cb)\n if g[ord(cb) - ord('a')][ord(ca) - ord('a')]:\n res = False\n break\n else:\n #pass\n #printG()\n a = ord(ca) - ord('a')\n b = ord(cb) - ord('a')\n g[a][b] = True\n #printG()\n\nif not res:\n print(\"Impossible\")\nelse:\n def getZeroIndegreeNode():\n for i in range(26):\n if not vis[i] and Indegree[i] == 0:\n return i\n return -1\n \n #cacl Indegree\n strOrder = []\n vis = [False] * 26\n Indegree = [0] * 26\n for i in range(26):\n ithIndegree = 0\n for j in range(26):\n if g[j][i]: ithIndegree += 1\n Indegree[i] = ithIndegree\n \n #get the order string\n for i in range(26):\n ZeroIndegreeNode = getZeroIndegreeNode()\n if ZeroIndegreeNode == -1:\n res = False\n break\n else:\n strOrder.append(chr(ord('a') + ZeroIndegreeNode))\n vis[ZeroIndegreeNode] = True\n for i in range(26):\n if g[ZeroIndegreeNode][i]:\n Indegree[i] -= 1\n if not res:\n print(\"Impossible\")\n else:\n print(\"\".join(strOrder))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"340a934c3cbeacf5a5f5","document_content":"import string\n\ndef make_link(G, char1, char2):\n if char1 in G:\n if char2 in G[char1]:\n return\n else:\n G[char1].append(char2)\n else:\n G[char1] = [char2]\n\ndef make_order(G, str1, str2):\n for i in range(min(len(str1), len(str2))):\n if str1[i] != str2[i]:\n make_link(G, str1[i], str2[i])\n return True\n\n if len(str2) > len(str1):\n return True\n else:\n return False\n\ndef topological_sort(G, ans, k = '', visited = {}):\n if visited.get(k, True) == False:\n return True\n if k not in visited:\n visited[k] = False\n for next in G.get(k, []):\n if topological_sort(G, ans, next, visited):\n return True\n visited[k] = True\n ans.insert(0, k)\n return False\n\ndef main():\n N = int(input())\n\n strs = [input() for i in range(N)]\n\n G = {}\n\n for i in range(N-1):\n if not make_order(G, strs[i], strs[i + 1]):\n print(\"Impossible\")\n return\n\n G[''] = reversed(string.ascii_lowercase)\n\n ans = []\n if topological_sort(G, ans):\n print(\"Impossible\")\n else:\n print(''.join(ans))\n\nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a52f78b15ccf7d71be35","document_content":"n=int(input())\nx=input()\na=len(x)\nlex=dict()\nALPHA=list('abcdefghijklmnopqrstuvwxyz')\n\nfor i in ALPHA:\n for j in ALPHA:\n lex[(i,j)]=0\n \nfor i in range(n-1):\n y=input()\n b=len(y)\n for j in range(min([a,b])):\n if x[j]!=y[j]:\n if lex[(x[j],y[j])]==-1:\n print('Impossible')\n raise SystemExit\n else:\n lex[(x[j],y[j])]=1\n lex[(y[j],x[j])]=-1\n x=y\n a=b\n break\n if j==(min([a,b])-1):\n if a>b:\n print('Impossible')\n raise SystemExit\n x=y\n a=b\n \ndef biggest(alphabet):\n for i in alphabet:\n t=0\n for j in alphabet:\n if lex[(i,j)]<0:\n t=1\n break\n if t==0:\n return i\n return -1\nnewalpha=['']*26 \ni=0\nwhile ALPHA!=[]:\n BIG=biggest(ALPHA)\n if biggest(ALPHA)==-1:\n print('Impossible')\n raise SystemExit\n newalpha[i]=BIG\n i=i+1\n ALPHA.remove(BIG)\n\nprint(''.join(newalpha))\n \n\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c142d67beeb407060204","document_content":"#TO MAKE THE PROGRAM FAST\n\n''' ---------------------------------------------------------------------------------------------------- '''\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(100000)\nfrom collections import deque\n''' ---------------------------------------------------------------------------------------------------- '''\n\n\n\n\n#FOR TAKING INPUTS\n\n''' ---------------------------------------------------------------------------------------------------- '''\ndef li():return [int(i) for i in input().rstrip('\\n').split(' ')]\ndef val():return int(input().rstrip('\\n'))\ndef st():return input().rstrip('\\n')\ndef sttoli():return [int(i) for i in input().rstrip('\\n')]\n''' ---------------------------------------------------------------------------------------------------- '''\n\n\n\n\n#MAIN PROGRAM\n\n''' ---------------------------------------------------------------------------------------------------- '''\n\nd = deque()\nn = val()\nl = li()\nj = x = 0\ncurrmax = -10000000000000\nans = []\nfor i in range(n):\n while len(d) and d[0] < i:d.popleft()\n currmax = l[d[0]%n] if len(d) else l[i]\n while j<3*n:\n currmax = max(currmax,l[j%n])\n while len(d) and l[d[-1]%n] <= l[j%n]:d.pop()\n d.append(j)\n if currmax\/2 > l[j%n]:\n ans.append(j-i)\n break\n j += 1\n if j == 3*n:\n print(*([-1 for _______ in range(n)]))\n return\nprint(*ans)\n\n\n\n\n\n''' ---------------------------------------------------------------------------------------------------- '''","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1e46bc1b9a3b88e6fb19","document_content":"NN = 18\nMI = [1<<100] * ((1<>= 1\n r >>= 1\n return mi\n\nN = int(input())\nA = [int(a) for a in input().split()]\nB = sorted([(A[i], i) for i in range(N)])\ni = 0 # large\nj = 0 # small\nX = [1<<20] * (2*N)\nwhile i < N:\n while 2 * B[j][0] < B[i][0]:\n update(B[j][1])\n update(B[j][1]+N)\n j += 1\n X[B[i][1]] = rangemin(B[i][1], B[i][1]+N)\n X[B[i][1]+N] = X[B[i][1]] + N\n i += 1\nfor i in range(2*N-1)[::-1]:\n X[i] = min(X[i], X[i+1])\nfor i in range(N):\n X[i] -= i\nX = [a if a < (1<<20) else -1 for a in X[:N]]\nprint(*X)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b485baffaffc7e59c420","document_content":"import sys\ninput = sys.stdin.readline\n\nn=int(input())\nA=list(map(int,input().split()))\n\nB=[(-a,i) for i,a in enumerate(A)]\n\nfrom collections import deque\n\nLIST=deque()\nLIST.append(B[0])\n\nfor b,i in B[1:]:\n if b>LIST[-1][0]:\n LIST.append((b,i))\n\nimport bisect\n\nDIS=[-1]*n\n\nfor i in range(n-1,-1,-1):\n x=bisect.bisect(LIST,(-A[i]\/\/2,1<<20))\n if x=1 and A[i]<=-LIST[0][0]:\n LIST.popleft()\n\n LIST.appendleft(B[i])\n\nif max(DIS)==-1:\n print(*[-1]*n)\n return\n\nfor i in range(n):\n if DIS[i]!=-1:\n start=i\n break\n\nANS=[-1]*n\n\nif DIS[start]>start:\n ANS[start]=DIS[start]-start\nelse:\n ANS[start]=DIS[start]+(n-start)\n\n\nfor i in range(start-1,-1,-1):\n if DIS[i]==-1:\n ANS[i]=ANS[(i+1)%n]+1\n else:\n if DIS[i]>i:\n ANS[i]=min(DIS[i]-i,ANS[(i+1)%n]+1)\n else:\n ANS[i]=min(DIS[i]+(n-i),ANS[(i+1)%n]+1)\n\nfor i in range(n-1,-1,-1):\n if DIS[i]==-1:\n ANS[i]=ANS[(i+1)%n]+1\n else:\n if DIS[i]>i:\n ANS[i]=min(DIS[i]-i,ANS[(i+1)%n]+1)\n else:\n ANS[i]=min(DIS[i]+(n-i),ANS[(i+1)%n]+1)\n\nfor i in range(n-1,-1,-1):\n if DIS[i]==-1:\n ANS[i]=ANS[(i+1)%n]+1\n else:\n if DIS[i]>i:\n ANS[i]=min(DIS[i]-i,ANS[(i+1)%n]+1)\n else:\n ANS[i]=min(DIS[i]+(n-i),ANS[(i+1)%n]+1)\n \n\nprint(*ANS)\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d72143299e05a6dd3bf4","document_content":"import sys\nreadline = sys.stdin.readline\n\nclass Segtree:\n def __init__(self, A, intv, initialize = True, segf = max):\n self.N = len(A)\n self.N0 = 2**(self.N-1).bit_length()\n self.intv = intv\n self.segf = segf\n if initialize:\n self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N)\n for i in range(self.N0-1, 0, -1):\n self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) \n else:\n self.data = [intv]*(2*self.N0)\n \n def update(self, k, x):\n k += self.N0\n self.data[k] = x\n while k > 0 :\n k = k >> 1\n self.data[k] = self.segf(self.data[2*k], self.data[2*k+1])\n \n def query(self, l, r):\n L, R = l+self.N0, r+self.N0\n s = self.intv\n while L < R:\n if R & 1:\n R -= 1\n s = self.segf(s, self.data[R])\n if L & 1:\n s = self.segf(s, self.data[L])\n L += 1\n L >>= 1\n R >>= 1\n return s\n \n def binsearch(self, l, r, check, reverse = False):\n L, R = l+self.N0, r+self.N0\n SL, SR = [], []\n while L < R:\n if R & 1:\n R -= 1\n SR.append(R)\n if L & 1:\n SL.append(L)\n L += 1\n L >>= 1\n R >>= 1\n \n if reverse:\n for idx in (SR + SL[::-1]):\n if check(self.data[idx]):\n break\n else:\n return -1\n while idx < self.N0:\n if check(self.data[2*idx+1]):\n idx = 2*idx + 1\n else:\n idx = 2*idx\n return idx\n else:\n for idx in (SL + SR[::-1]):\n if check(self.data[idx]):\n break\n else:\n return -1\n while idx < self.N0:\n if check(self.data[2*idx]):\n idx = 2*idx\n else:\n idx = 2*idx + 1\n return idx - self.N0\n\nN = int(readline())\nA = list(map(int, readline().split()))\nB = [2*a for a in A]\nB *= 3\ninf = 2*10**9\nB.append(-2)\nT = Segtree(B, inf, True, min)\n\nNN = T.N0\n\nJ = [0]*(NN+1)\nJ[3*N] = inf\nKK = [None]*(NN+1)\nfor i in range(3*N-1, -1, -1):\n a = A[i%N]\n k = T.binsearch(i, NN, lambda x: x < a ,reverse = False)\n KK[i] = k\n J[i] = min(J[i+1], k)\n\nAns = [-1]*N\nfor i in range(N):\n j = J[i]\n if j == 3*N:\n continue\n Ans[i] = j - i\nprint(*Ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d972b967607e76c47ee0","document_content":"import sys\nreader = (s.rstrip() for s in sys.stdin)\ninput = reader.__next__\n\nclass Binary_Indexed_Tree():\n def __init__(self, n):\n self.n = n\n self.data = [0]*(n+1)\n\n def add(self, i, x):\n while i <= self.n:\n self.data[i] += x\n i += i & -i\n\n def get(self, i):\n return self.sum_range(i, i)\n\n def sum(self, i):\n ret = 0\n while i:\n ret += self.data[i]\n i &= i-1\n return ret\n\n def sum_range(self, l, r):\n return self.sum(r)-self.sum(l-1)\n\n def lower_bound(self, w):\n if w<=0:\n return 0\n i = 0\n k = 1<<(self.n.bit_length())\n while k:\n if i+k <= self.n and self.data[i+k] < w:\n w -= self.data[i+k]\n i += k\n k >>= 1\n return i+1\n\nclass RangeMinimumQuery:\n def __init__(self, n, func=min, inf=float(\"inf\")):\n self.n0 = 2**(n-1).bit_length()\n self.op = func\n self.inf = inf\n self.data = [self.inf]*(2*self.n0)\n\n def construct(self, lis):\n for i, x in enumerate(lis):\n self.data[i+self.n0-1] = x\n for i in range(self.n0-2, -1, -1):\n self.data[i] = self.op(self.data[2*i+1], self.data[2*i+2])\n\n def query(self, l,r):\n l += self.n0\n r += self.n0\n res = self.inf\n while l < r:\n if r&1:\n r -= 1\n res = self.op(res, self.data[r-1])\n if l&1:\n res = self.op(res, self.data[l-1])\n l += 1\n l >>=1\n r >>=1\n return res\n\nn = int(input())\na = list(map(int, input().split()))\na = [i*2 for i in a]\nBIT = Binary_Indexed_Tree(2*n)\nRMQ = RangeMinimumQuery(2*n)\nRMQ.construct(a+a)\n\nb = [[j,i] for i,j in enumerate(a)]\nb.sort(reverse=True)\nans = [0]*n\nfor j, i in b:\n cnt = BIT.sum(2*n-i)\n tmp = float(\"inf\")\n if cnt:\n p = 2*n-BIT.lower_bound(cnt)\n tmp = p-i + ans[p%n]\n BIT.add(2*n-i, 1)\n BIT.add(n-i, 1)\n left = i\n right = 2*n\n if RMQ.query(i, right) < j\/\/2:\n while right-left>1:\n mid = (right+left)\/\/2\n if RMQ.query(i, mid) < j\/\/2:\n right = mid\n else:\n left = mid\n tmp = min(tmp, right-i-1)\n ans[i] = tmp\nans = [i if i!=float(\"inf\") else -1 for i in ans]\nprint(*ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0b5ca78898dc0467fc05","document_content":"import sys\ninput = sys.stdin.readline\n\nclass SegTree(object):\n\t\"\"\"docstring for SegTree\"\"\"\n\tdef __init__(self, n, arr):\n\t\tself.n = n\n\t\tself.arr = arr\n\t\tself.tree = [0 for i in range(2*n)]\n\n\tdef construct(self): # Construction\n\t\tfor i in range(self.n):\n\t\t\tself.tree[n+i] = self.arr[i]\n\t\tfor i in range(n-1,0,-1):\n\t\t\tself.tree[i] = self.function(self.tree[2*i],self.tree[2*i+1])\n\n\tdef update(self,index,change):\n\t\tstart = index+self.n\n\t\tself.tree[start] = value\n\t\twhile start>0:\n\t\t\tself.tree[start] = self.function(self.tree[2*start],self.tree[2*start+1])\n\t\t\tstart = start\/\/2\n\n\tdef calc(self,low,high): # 0-indexed\n\t\tlow+=self.n\n\t\thigh+=self.n\n\t\tans = 0 # Needs to initialised\n\t\twhile low=a[i-1]:\n\t\tans[i] = ans[i-1]-1\n\telse:\n\t\tmaxx = st.calc(i,prev+1)\n\t\twhile a[prev]>(maxx-1)\/\/2:\n\t\t\t# print (prev,i,maxx)\n\t\t\tmaxx = max(maxx,a[prev])\n\t\t\tprev += 1\n\t\tans[i] = prev - i\nprint(*ans[0:n\/\/3])\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6b8ccfa1ae5cc60bff31","document_content":"def f():\n n, m, k = map(int, input().split())\n p = [[] for i in range(n + 1)]\n for i in range(m):\n a, b = map(int, input().split())\n p[a].append(b)\n p[b].append(a)\n t, r = [0] * (n + 1), [1]\n x = t[1] = 1\n i = 0 - k\n while True:\n for y in p[x]:\n if t[y] == 2: return r[r.index(y): ]\n if t[y]: continue\n t[y], x = 1, y\n r.append(x)\n i += 1\n if i >= 0: t[r[i]] = 2\n break\nt = f()\nprint(len(t))\nprint(' '.join(map(str, t)))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1c1f2e61c49e75447730","document_content":"n,l,k=map(int,input().split())\nc=list([] for i in range(n+1))\nfor i in range(l):\n x,y=map(int,input().split())\n c[x].append(y)\n c[y].append(x)\nd=list(0 for i in range(n+1))\nd[1]=1\nnow=1\ntime=1\nf=True\nwhile f:\n time+=1\n v=0\n while v>=0:\n if d[c[now][v]]==0:\n now=c[now][v]\n d[now]=time\n v=-1\n elif d[c[now][v]]+k=mintime:\n g[d[i]-mintime]=i \nprint(time-mintime)\nprint(*g)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4c43ab8943bc7faabd4f","document_content":"import sys\nimport threading\n\ndef put():\n return list(map(int, sys.stdin.readline().split()))\n\ndef dfs(i, h):\n vis[i] =h \n done[i]=1\n element.append(i)\n for j in graph[i]:\n if vis[j]!=0 and h-vis[j]>=k:\n ind = element.index(j)\n ans.extend(element[ind:])\n raise ValueError\n elif done[j]==0:\n dfs(j,h+1)\n vis[i]=0\n element.pop()\n\ndef solve():\n try:\n for i in range(1, n+1):\n if done[i]==0:\n dfs(i,1)\n except:\n print(len(ans))\n print(*ans)\n \n\n\nn,m,k = put()\ngraph = [[] for _ in range(n+1)]\nfor i in range(m):\n x,y = put()\n graph[x].append(y)\n graph[y].append(x)\n \ndone,vis = [0]*(n+1),[0]*(n+1)\nelement,ans = [],[]\n\n\nmax_recur_size = 10**5*2 + 1000\nmax_stack_size = max_recur_size*500\nsys.setrecursionlimit(max_recur_size)\nthreading.stack_size(max_stack_size)\nthread = threading.Thread(target=solve)\nthread.start()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2470617d7fa4f0d015c5","document_content":"def find_cycle_optimum(n,m,k,adj):\n path = [1]\n visited = [-1 for _ in range(n+1)]\n visited[1] = 1\n while True:\n v = path[-1]\n visited[v] = len(path) - 1\n for w in adj[v]:\n if visited[w] == -1:\n path.append(w)\n break\n elif len(path) - visited[w] > k:\n return path[visited[w]::]\n\ndef main ():\n n,m,k =[int(i) for i in input().split()]\n adj = [[] for i in range(n+1)]\n for _ in range(m):\n u,v = [int(i) for i in input().split()]\n adj[u].append(v)\n adj[v].append(u)\n c = find_cycle_optimum(n,m,k,adj)\n l = len(c)\n print(l)\n print(' '.join(str(v) for v in c))\n\nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9cf84e33580e5df0cc69","document_content":"import sys\nfrom sys import stdin\n\nimport bisect\n\ndef LIS(lis , end):\n\n seq = []\n\n for c in lis:\n ind = bisect.bisect_right(seq,c)\n\n if ind == len(seq):\n seq.append(c)\n else:\n if ind != 0:\n seq[ind] = c\n\n return bisect.bisect_right(seq,end)\n\ntt = 1\n\nfor loop in range(tt):\n\n n,k = list(map(int,stdin.readline().split()))\n a = list(map(int,stdin.readline().split()))\n b = list(map(int,stdin.readline().split()))\n\n a = [float(\"-inf\")] + a + [float(\"inf\")]\n b = [0] + b + [n+1]\n for i in range(n+2):\n a[i] -= i\n\n for i in range(len(b)-1):\n if a[b[i]] > a[b[i+1]]:\n print(-1)\n return\n\n ans = n+1\n for i in range(len(b)-1):\n now = LIS(a[ b[i]:b[i+1] ] , a[b[i+1]])\n ans -= now\n\n print (ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bb4a144be89f7d552042","document_content":"import sys,math,itertools\nfrom collections import Counter,deque,defaultdict\nfrom bisect import bisect_left,bisect_right \nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn,k = inpl()\na = inpl()\nif k != 0:\n b = inpl()\npre = 0\nbad = False\nfor i in range(k-1):\n lind = b[i]-1; rind = b[i+1]-1\n l = a[lind]; r = a[rind]\n if r-l < rind-lind: bad = True\nif bad: print(-1); quit()\nl = []; r = []; dv = []\nif k == 0:\n l = [-INF]; r = [INF]; dv = [a]\nelse:\n for _,i in enumerate(b):\n dv.append(a[pre:i-1])\n if pre == 0: l.append(-INF)\n else: l.append(a[pre-1])\n r.append(a[i-1])\n pre = i\n dv.append(a[pre:])\n l.append(a[pre-1]); r.append(INF)\n# print(dv,l,r)\nres = 0\nfor i in range(k+1):\n li = []\n L = l[i]+1; R = r[i]-1\n ln = len(dv[i])\n for j,x in enumerate(dv[i]):\n if L+j <= x <= R-ln+j+1:\n li.append(x-j)\n dp = [INF] * (len(li))\n for i,x in enumerate(li):\n ind = bisect_right(dp,x)\n dp[ind] = x\n ans = len(li)\n for i,x in enumerate(dp):\n if x == INF:\n ans = i\n break\n res += ln-ans\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"293ce9c11a44d33f1cce","document_content":"from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key, lru_cache\n\n\nimport sys\ninput = sys.stdin.readline\nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n\/\/i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\n\ndef give(i, j, mi, ma):\n # print(i, j, mi, ma)\n l1 = []\n for k in range(i, j + 1):\n if mi <= l[k] <= ma:\n ind = br(l1, l[k])\n if ind == len(l1):l1.append(l[k])\n else:l1[ind] = l[k]\n # print(j - i + 1, len(l1))\n return j - i - len(l1) + 1\n \n \n\nn, k = li()\nl = [0] + li()\n\n\nif k:\n b = li()\nelse:b = []\n\nfor i in range(1, k):\n if l[b[i]] - l[b[i - 1]] < b[i] - b[i - 1] or l[b[i]] < l[b[i - 1]]:\n print(-1)\n return\n \nfor i in range(n + 1):l[i] -= i\n\nif k:\n ans = give(1, b[0] - 1, -float('inf'), l[b[0]])\n ans += give(b[-1] + 1, n, l[b[-1]], float('inf'))\n \n for i in range(1, k):\n ans += give(b[i-1], b[i], l[b[i - 1]], l[b[i]])\n \n \nelse:\n ans = give(1, n, -float('inf'), float('inf'))\n \n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e46e54826beea59fbef6","document_content":"import sys\ninput=sys.stdin.readline\nn,k = map(int,input().split())\na = list(map(int,input().split()))\nb = []\nif k:\n b = list(map(int,input().split()))\nfor i in range(n):\n a[i] -= i\nprev = -1\nans = 0\nfor j in range(k + 1):\n if j < k:\n val = b[j] - 1\n if j and a[prev] > a[val]:\n print(-1)\n quit()\n else:\n val = n\n if val - prev > 1:\n path = [0] * (val - prev - 1)\n arr = [0] * (val - prev)\n found = 0\n for i in range(val - prev - 1):\n if val < n and a[i + prev + 1] > a[val]:\n continue\n elif prev + 1 and a[prev] > a[i + prev + 1]:\n continue\n l = 1\n h = found\n while h >= l:\n m = (l + h + 1) \/\/ 2\n if a[arr[m] + prev + 1] <= a[i + prev + 1]:\n l = m + 1\n else:\n h = m - 1\n path[i] = arr[l - 1]\n arr[l] = i\n if l > found:\n found = l\n ans += found\n prev = val\nprint(n - k - ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"551801ad0b35ef79a4f0","document_content":"import sys,os,io\ninput = sys.stdin.readline\nfrom bisect import bisect_right\nN, K = map(int, input().split())\nA = [-float('inf')]+list(map(int, input().split()))+[float('inf')]\nif K:\n B = [0]+list(map(int, input().split()))+[N+1]\nelse:\n B = [0,N+1]\nans = N-K\nfor k in range(K+1):\n left, right = B[k], B[k+1]\n if A[left]-left>A[right]-right:\n print(-1)\n break\n lis = []\n for i in range(left+1,right):\n if not A[left]-left<=A[i]-i<=A[right]-right:\n continue\n ind = bisect_right(lis,A[i]-i)\n if ind == len(lis):\n lis.append(A[i]-i)\n else:\n lis[ind] = A[i]-i\n ans -= len(lis)\nelse:\n print(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"eb1baf66ff05cade759d","document_content":"import sys\ndef Z(s):\n return int(s)-1\n\nn=int(sys.stdin.readline())\n\nHotels=[False]*(n)\n\nRep=[0]*(n+1)\nChains=[]\n\nType=list(map(int,sys.stdin.readline().split()))\nfor i in range(n):\n if(Type[i]==1):\n Hotels[i]=True\nA=list(map(Z,sys.stdin.readline().split()))\n\nfor item in A:\n Rep[item]+=1\nfor i in range(n):\n if(Hotels[i]):\n Chains.append([i])\n x=A[i]\n if(x==-1):\n continue\n while(A[x]!=-1 and Rep[x]<=1):\n Chains[-1].append(x)\n x=A[x]\n if(Rep[x]<=1):\n Chains[-1].append(x)\n\n\n \n \nif(n==1):\n print(1)\n print(1)\nelse:\n \n X=max(Chains,key=len)\n\n\n\n sys.stdout.write(str(len(X))+\"\\n\")\n sys.stdout.write(str(X[-1]+1))\n\n for i in range(len(X)-2,-1,-1):\n sys.stdout.write(\" \"+str(X[i]+1)) \n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1ef580ae580c12d36749","document_content":"3\n\ndef readln(): return tuple(map(int, input().split()))\n\nn, = readln()\nt = (-1,) + readln()\nv = (0,) + readln()\ncnt = [0] * (n + 1)\nfor i in range(1, n + 1):\n cnt[v[i]] += 1\nans = []\nfor i in range(1, n + 1):\n if t[i] == 1:\n j = i\n tmp = [i]\n while(t[v[j]] == 0) and cnt[v[j]] == 1:\n j = v[j]\n tmp.append(j)\n if(len(tmp) > len(ans)):\n ans = tmp\nprint(len(ans))\nprint(*tuple(reversed(ans)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"123a5a4b821d8e539920","document_content":"n = int(input())\na, b = [0] + list(map(int, input().split())), [0] + list(map(int, input().split()))\nans, p = [], [0] * (n + 1)\nfor i in b:\n p[i] += 1\nfor i in range(1, n + 1):\n if a[i] == 1:\n t = [i]\n x = b[i]\n while p[x] == 1:\n t.append(x)\n x = b[x] \n if len(t) > len(ans): ans = t[:]\nans.reverse()\nprint(len(ans))\nprint(' '.join(str(x) for x in ans))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6c0a6161bc7ea883b685","document_content":"import sys\n\n\nn = int(input())\ntype = input().split()\nfa = list(map(int, input().split()))\n\ndegree = [0] * (n+1)\nfor i in fa:\n degree[i]+=1\n\ntype = [0] + type\nfa= [0] + fa\nmax=0\nmaxi=0\n\nfor i in range(1, n+1):\n if type[i] == '1': # it's hotel\n cnt = 0\n\n cur=fa[i]\n while not (cur==0 or type[cur] == '1' or degree[cur]>1):\n cnt+=1\n cur=fa[cur]\n\n if(max <= cnt):\n max=cnt\n maxi=i\nprint(max+1)\nans = []\ncur=maxi\nwhile not(not cur or type[cur] == '1' and cur!=maxi or degree[cur]>1):\n ans.append(cur)\n cur=fa[cur]\n\nprint(*ans[::-1])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"19db9f7d40d438d1f044","document_content":"import sys\n\ndef solve():\n n = int(input())\n types = list(map(int, input().split()))\n a = list(map(int, input().split()))\n res = list()\n count = [0] * (n + 1)\n for val in a:\n count[val-1]+=1\n for i in range(n):\n if types[i] == 1:\n temp = list()\n cur = i\n while True:\n if count[cur] > 1 or cur < 0: break\n temp.append(cur + 1)\n cur = a[cur] - 1\n if len(temp) > len(res):\n res = temp\n print(len(res))\n return ' '.join(map(str, res[::-1]))\n # adj = [list() for _ in range(n)]\n # visited = [0] * (n + 1)\n # best = -1\n # start = -1\n # bestlen = 0\n # for i in range(n):\n # if a[i] > 0: adj[a[i] - 1].append(i)\n # # counter = 0\n # for i in range(n):\n # if visited[i] == 0:\n # cur = i\n # # temp = list()\n # # temp.append(cur)\n # temp = 1\n # visited[cur] += 1\n # while len(adj[cur]) == 1:\n # # print(cur)\n # if len(adj[cur]) > 0 and adj[cur][0] == cur: break\n # cur = adj[cur][0]\n # # temp.append(cur)\n # visited[cur]+=1\n # temp+=1\n # # if counter == 10000: return - 1\n # if types[cur] == 1 and temp > bestlen:\n # best = cur\n # bestlen = temp\n # start = i\n # res = list()\n # while True:\n # res.append(best)\n # if best == start: break\n # next = a[best] - 1\n # best = next\n # res = res[::-1]\n # for i in range(len(res)): res[i] += 1\n # print(len(res))\n # return ' '.join(map(str, res))\n\nif sys.hexversion == 50594544 : sys.stdin = open(\"test.txt\")\nprint(solve())","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"12eb8ff433f5d29e9727","document_content":"import sys\n\ndef solve():\n n = int(input())\n types = list(map(int, input().split()))\n a = list(map(int, input().split()))\n res = list()\n count = [0] * (n + 1)\n for val in a:\n count[val-1]+=1\n for i in range(n):\n if types[i] == 1:\n temp = list()\n cur = i\n while True:\n if count[cur] > 1 or cur < 0: break\n temp.append(cur + 1)\n cur = a[cur] - 1\n if len(temp) > len(res):\n res = temp\n print(len(res))\n return ' '.join(map(str, res[::-1]))\n\nif sys.hexversion == 50594544 : sys.stdin = open(\"test.txt\")\nprint(solve())","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"398840a87bb3de5ad81c","document_content":"n = int(input())\nt = [0] + list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\n\nans, cnt = [], [0 for i in range(n + 1)]\n\nfor i in a:\n cnt[i] += 1\n\nfor i in range(1, n + 1):\n if t[i] == 1:\n crt = [i]\n x = a[i]\n while cnt[x] == 1:\n crt.append(x)\n x = a[x]\n if len(crt) > len(ans):\n ans = crt[:]\nans.reverse()\nprint(len(ans))\nprint(' '.join(map(str, ans)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9eda195dd9a3d7800cb4","document_content":"n = int(input())\nt = [0] + list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\n\nans, cnt = [], [0 for i in range(n + 1)]\n\nfor i in a:\n cnt[i] += 1\n\nfor i in range(1, n + 1):\n if t[i] == 1:\n crt = [i]\n x = a[i]\n while cnt[x] == 1:\n crt.append(x)\n x = a[x]\n if len(crt) > len(ans):\n ans = crt[:]\nans.reverse()\nprint(len(ans))\nprint(' '.join(map(str, ans)))\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f2ba56f09f8481161499","document_content":"n = int(input())\nt = [0] + list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\n\nans, cnt = [], [0 for i in range(n + 1)]\n\nfor i in a:\n cnt[i] += 1\n\nfor i in range(1, n + 1):\n if t[i] == 1:\n crt = [i]\n x = a[i]\n while cnt[x] == 1:\n crt.append(x)\n x = a[x]\n if len(crt) > len(ans):\n ans = crt[:]\nans.reverse()\nprint(len(ans))\nprint(' '.join(map(str, ans)))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a318d7fb8d1efa2e8d5a","document_content":"n = int(input())\n\nt = [0] + list(map(int, input().split()))\n\na = [0] + list(map(int, input().split()))\n\n\n\nans, cnt = [], [0 for i in range(n + 1)]\n\n\n\nfor i in a:\n\n cnt[i] += 1\n\n\n\nfor i in range(1, n + 1):\n\n if t[i] == 1:\n\n crt = [i]\n\n x = a[i]\n\n while cnt[x] == 1:\n\n crt.append(x)\n\n x = a[x]\n\n if len(crt) > len(ans):\n\n ans = crt[:]\n\nans.reverse()\n\nprint(len(ans))\n\nprint(' '.join(map(str, ans)))\n\n\n\n# Made By Mostafa_Khaled\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d7ebb7acfd50f3786a5e","document_content":"n = int(input())\nt = [0] + list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\n\nres, cnt = [], [0] * (n + 1)\nfor i in a:\n cnt[i] += 1\nfor i in range(1, n+1):\n if t[i] == 0: \n continue\n curr_res = [i]\n x = a[i]\n while cnt[x] == 1:\n curr_res.append(x)\n x = a[x]\n if len(curr_res) > len(res):\n res = curr_res[:]\nres.reverse()\nprint(len(res))\nprint(*res)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bfd9028b8b7ab39a0e0d","document_content":"n = int(input())\nans = 0\nans = ans + (n * (n-1) * (n-2) * (n-3) * (n-4)) \/\/ (2*3*4*5)\nans = ans + (n * (n-1) * (n-2) * (n-3) * (n-4) * (n-5)) \/\/ (2*3*4*5*6)\nans = ans + (n * (n-1) * (n-2) * (n-3) * (n-4) * (n-5) * (n-6)) \/\/ (2*3*4*5*6*7)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a2d76e4d1eb8d65159f5","document_content":"from math import factorial\nn = int(input())\na = n * (n - 1) * (n - 2) * (n - 3) * (n - 4)\nans = a \/\/ factorial(5)\na *= (n - 5)\nans += a \/\/ factorial(6)\na *= (n - 6)\nans += a \/\/ factorial(7)\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a6b8e6c5acba81e970b2","document_content":"n = int(input())\n\nret = 0\nways = 1\nfor i in range(1, 8):\n ways = ways * (n - i + 1) \/\/ i\n if i >= 5:\n ret += ways\n \nprint(ret)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"26484295e4fefb67304e","document_content":"import sys\ndef fact(n):\n\tret = 1\n\tfor x in range(1, n + 1):\n\t\tret = ret * x\n\treturn ret\n\ndef C(n, k):\n\treturn fact(n) \/\/ (fact(k) * (fact(n - k)))\nn = int(input())\nprint(C(n, 7) + C(n, 6) + C(n, 5))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"eb59c810f5f581331a65","document_content":"from functools import reduce\nfrom math import factorial\nn = int(input())\nC_n_k = lambda n, k: reduce(lambda x, y: x*y, list(range(n, n-k, -1))) \/\/ factorial(k)\nprint(C_n_k(n, 7) + C_n_k(n, 6) + C_n_k(n, 5))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d99c6a79ad9577bf109c","document_content":"n = int(input())\nans1 = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n - 5) * (n - 6) \/\/ 5040;\nans2 = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n - 5) \/\/ 720;\nans3 = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) \/\/ 120;\nprint(ans1 + ans2 + ans3)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"abb36bf1a8d3f9ed041c","document_content":"from math import factorial as f\nn = int(input())\nres = 0\nfor i in range(5, 8):\n res += f(n) \/\/ (f(n - i) * f(i))\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"006510cf990f8a370fc7","document_content":"import re, sys, string, operator, functools, fractions, collections\nsys.setrecursionlimit(10**7)\ndX= [-1, 1, 0, 0,-1, 1,-1, 1]\ndY= [ 0, 0,-1, 1, 1,-1,-1, 1]\nRI=lambda x=' ': list(map(int,input().split(x)))\nRS=lambda x=' ': input().rstrip().split(x)\nmod=int(1e9+7)\neps=1e-6\n#################################################\nn=RI()[0]\nv=n*(n-1)*(n-2)*(n-3)*(n-4)\nv1=v\/\/120\nv2=(v1*(n-5))\/\/6\nv3=(v2*(n-6))\/\/7\nprint(v1+v2+v3)\n\n\n\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7d346ef4bac2e6a4c299","document_content":"def fact(i):\n ans = 1\n for j in range(1, i + 1):\n ans *= j\n return ans\n\ndef c(i, j):\n return fact(i) \/\/ (fact(j) * fact(i - j))\n\nn = int(input())\nprint(c(n, 5) + c(n, 7) + c(n, 6))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3de1497aa710b8376330","document_content":"def cnk(n, k):\n return f[n] \/\/ f[n - k] \/\/ f[k]\n\nn = int(input())\n\nf = [0 for i in range(n + 1)]\nf[0] = 1\nfor i in range(1, n + 1):\n f[i] = f[i - 1] * i\nans = 0\nfor i in range(5, 8):\n if (i <= n):\n ans += cnk(n, i)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1298772b5f009214c462","document_content":"from math import factorial as f\n\nx = int(input())\n#x, y = map(int, input().split())\n\nprint(f(x)\/\/f(5)\/\/f(x-5) + f(x)\/\/f(6)\/\/f(x-6) + f(x)\/\/f(7)\/\/f(x-7))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"290e11af9940376ca0a3","document_content":"x = int(input())\na = ((1 * x * (x - 1) * (x - 2) * (x - 3) * (x - 4)) *(42 + 7 * (x - 5) + 1 * (x - 5) * (x - 6)) \/\/ (7 * 6 * 5 * 4 * 3 * 2))\nprint(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dcfb16a3f011e8b5c274","document_content":"def fact(n):\n return 1 if n == 0 else (n * fact(n - 1))\n\ndef c(n, k):\n return fact(n) \/\/ (fact(k) * (fact(n - k)))\n\nn = int(input())\n\nprint(c(n, 5) + c(n, 6) + c(n, 7))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4f76d1c723d25b2b7eda","document_content":"def C(n,m):\n a = 1\n b = 1\n for i in range(1,m+1):\n a *= n+1-i\n b *= i\n return a\/\/b\n\ndef __starting_point():\n\n n = int(input())\n\n print(C(n,5)+C(n,6)+C(n,7))\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a704abb60eb2bd933bce","document_content":"from math import factorial\n\ndef C(n, k):\n return factorial(n) \/\/ (factorial(k) * factorial(n - k))\n\nn = int(input())\nprint(C(n, 5) + C(n, 6) + C(n, 7))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a92bb6c0d5a803caf0e8","document_content":"n = int(input())\nprint (n * (n - 1) * (n - 2) * (n - 3) * (n - 4) \/\/ 120 + n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n - 5) \/\/ 720 + n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n - 5) * (n - 6) \/\/ 5040)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4570e7335f935b835711","document_content":"from math import factorial\n\ndef nCr(n,r):\n f = factorial\n return f(n) \/\/ f(r) \/\/ f(n-r)\n\nn = int(input())\nans = nCr(n, 7) + nCr(n, 6) + nCr(n, 5)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4033bf42b4b539f01a4c","document_content":"import math\nn = int(input())\na = int(math.factorial(n)\/(math.factorial(5)*math.factorial(n - 5)))\nb = int(math.factorial(n)\/(math.factorial(6)*math.factorial(n - 6)))\nc = int(math.factorial(n)\/(math.factorial(7)*math.factorial(n - 7)))\nprint(int(a + b + c))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f5b7f4867b8f4d9821a3","document_content":"n = int(input())\nans = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n - 5) * (n - 6) \/\/ (120 * 6 * 7)\nans += n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n - 5) \/\/ (120 * 6)\nans += n * (n - 1) * (n - 2) * (n - 3) * (n - 4) \/\/ 120\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8b1ef42b147cdb0a8f9c","document_content":"from math import factorial\n\nn = int(input())\nans = 0\ncur = 1\nfor i in range(7):\n cur *= n - i\nans += cur \/\/ factorial(7)\ncur = 1\nfor i in range(6):\n cur *= n - i\nans += cur \/\/ factorial(6)\ncur = 1\nfor i in range(5):\n cur *= n - i\nans += cur \/\/ factorial(5)\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cabb4938379d9c003555","document_content":"import sys\n\ndef c5(n):\n return n * (n - 1) * (n - 2) * (n - 3) * (n - 4) \/\/ 2 \/\/ 3 \/\/ 4 \/\/ 5\n\ndef c6(n):\n return c5(n) * (n - 5) \/\/ 6\n\ndef c7(n):\n return c6(n) * (n - 6) \/\/ 7\n\nn = int(input())\n\nprint(c5(n) + c6(n) + c7(n))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"81101d1c93e55cd7046f","document_content":"def fact(a):\n ans = 1\n for i in range(2, a + 1):\n ans *= i\n return ans\n\nn = int(input())\nans = 0\nfor i in range(5, 8):\n ans += fact(n) \/\/ fact(i) \/\/ fact(n - i)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"825cb824a7404be6d483","document_content":"def main():\n n = int(input())\n A = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) \/\/ (5*4*3*2*1)\n B = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n - 5) \/\/ (6*5*4*3*2*1)\n C = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n - 5) * (n - 6) \/\/ (7*6*5*4*3*2*1)\n print(A + B + C)\n\ndef __starting_point():\n main()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9f5fafc84c6e2c309592","document_content":"import math\nn = int(input())\ns = 0\nfor i in range(5, 8):\n s += (math.factorial(n)\/\/(math.factorial(n-i)*math.factorial(i)))\nprint(s)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"91203478d8ab226ab309","document_content":"n = int(input())\nans = 0\nt = 7\nw = n\ntemp = 1\nwhile (t>0):\n\ttemp *= w\n\tw-=1\n\tt-=1\nans = temp\/\/5040\nt = 6\nw = n\ntemp = 1\nwhile (t>0):\n\ttemp *= w\n\tw-=1\n\tt-=1\nans += temp\/\/720\nt = 5\nw = n\ntemp = 1\nwhile (t>0):\n\ttemp *= w\n\tw-=1\n\tt-=1\nans += temp\/\/120\nprint (ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1e2507a7eb10e1113636","document_content":"def put():\n return list(map(int, input().split()))\ndef diff(x,y):\n ans = 0\n for i in range(n*m):\n if s[x][i]!= s[y][i]:\n ans+=1\n return ans\ndef find(i):\n if i==p[i]:\n return i\n p[i] = find(p[i])\n return p[i]\ndef union(i,j):\n if rank[i]>rank[j]:\n i,j = j,i\n elif rank[i]==rank[j]:\n rank[j]+=1\n p[i]= j\ndef dfs(i,p):\n if i!=0:\n print(i,p)\n for j in tree[i]:\n if j!=p:\n dfs(j,i)\n\nn,m,k,w = put()\ns = ['']*k \nfor i in range(k):\n for j in range(n):\n s[i]+=input()\nedge = []\nk+=1\nrank = [0]*(k)\np = list(range(k))\ncost = 0\ntree = [[] for i in range(k)]\n\nfor i in range(k):\n for j in range(i+1,k):\n if i==0:\n z=n*m\n else:\n z = diff(i-1,j-1)*w\n edge.append((z,i,j))\n\nedge.sort()\nfor z,i,j in edge:\n u = find(i)\n v = find(j)\n if u!=v:\n union(u,v)\n cost+= z\n tree[i].append(j)\n tree[j].append(i)\n\nprint(cost)\ndfs(0,-1)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9657277f4486dcfe3843","document_content":"from heapq import *\n\nN = int(input())\nprice = [int(i) for i in input().split()]\n\ntotal = 0\ninf = (10**6) + 1\nh = [inf]\n\n#Assume we bought and sold optimally for the first k prices.\n#We adjust our answer for the (k+1)th price that comes up.\nfor p in price:\n if p > h[0]:\n total += (p - heappop(h))\n #We push p onto heap in case we should have bought at this price instead\n #of selling.\n heappush(h, p)\n heappush(h, p)\n\nprint(total)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dcec625710036c201eb2","document_content":"import math\nfrom heapq import *\n\n\ndef maxProfit(prices, days):\n\n payoff = 0\n maxPrice, minPrice = max(prices), min(prices)\n maxIndex, minIndex = prices.index(maxPrice), prices.index(minPrice)\n iterator = iter(prices) \n h = [] # heap\n\n if days == 1:\n print(0)\n return\n\n\n for i in range(days):\n p = next(iterator)\n if not i:\n heappush(h, p)\n continue\n if h[0] < p:\n payoff += p - h[0]\n heappop(h)\n heappush(h, p)\n heappush(h, p)\n\n print(payoff)\n\n\n\ndef __starting_point():\n n = int(input())\n prices = list(map(int, input().split()))\n maxProfit(prices, n)\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"52dab5dcb881b6c9ae72","document_content":"from heapq import heappush,heappop\nn=int(input())\nar=list(map(int,input().split()))\nunsed=[]\nselled=[]\nsm=0\nfor x in ar:\n U,S=len(unsed),len(selled)\n u=heappop(unsed) if U else float('inf')\n s=heappop(selled) if S else float('inf')\n y=min(u,s)\n if(y 1 else 'Brown')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"963ba403a3b147ec5fcd","document_content":"x, y = map(int, input().split())\nif abs(x - y) <= 1:\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a190457aba15b0e4b80e","document_content":"a,b = map(int, input().split())\nprint('Alice' if abs(a-b) > 1 else 'Brown')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"382678568d79a42066bb","document_content":"x, y = list(map(int, input().split()))\nif -1 <= x - y <= 1:\n print('Brown')\nelse:\n print('Alice')\n\n# abs(x - y) <= 1 \u2192 abs(x - y) >= 2\n# abs(x - y) >= 2 \u2192 abs(x - y) <= 1\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9fc02119383abe001189","document_content":"x, y = list(map(int, input().split()))\nif abs(x - y) > 1:\n print('Alice')\nelse:\n print('Brown')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e3fa9eda77b9cc6eb279","document_content":"x, y = list(map(int, input().split()))\n\nif abs(x - y) <= 1:\n ans = \"Brown\"\nelse:\n ans = \"Alice\"\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8314c1db8db08475f229","document_content":"X, Y = list(map(int, input().split()))\nif abs(X - Y) > 1:\n print('Alice')\nelse:\n print('Brown')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e4d05384a1a7351a39bc","document_content":"x,y = map(int,input().split())\nif abs(x - y) > 1:\n print(\"Alice\")\nelse:\n print(\"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"81e19db5a16b749e6a00","document_content":"X,Y=list(map(int,input().split()))\n\nif X+Y<=1:\n print(\"Brown\")\n\nelse:\n n=X-Y\n if n<0:\n n=(-1)*n\n \n if n<=1:\n print(\"Brown\")\n else:\n print(\"Alice\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c3d8a8909da8dfe1c51b","document_content":"import sys\n\ndef main():\n x,y=list(map(int,input().split()))\n s=2*x+y\n t=2*y+x\n if s\/\/3-(s%3==0)==t\/\/3-(t%3==0):\n print('Brown')\n else:\n print('Alice')\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a9d8ec6b811db3ebf3d5","document_content":"x, y = list(map(int, input().split()))\n\nprint(('Brown' if abs(x - y) <= 1 else 'Alice'))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9544c330cde5028fc46e","document_content":"#!\/usr\/bin\/env python3\nimport sys\n\n\ndef solve(X: int, Y: int):\n print((\"Brown\" if -1 <= X - Y <= 1 else \"Alice\"))\n\n\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n X = int(next(tokens)) # type: int\n Y = int(next(tokens)) # type: int\n solve(X, Y)\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6a5438ee22694e16ee19","document_content":"X, Y = map(int, input().split())\nif abs(X - Y) <= 1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e525c2b517f4dc7820cf","document_content":"X, Y = map(int, input().split())\nif abs(X - Y) <= 1:\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"76e82709bbbf14cd7ee6","document_content":"X, Y = map(int, input().split())\nif abs(X - Y) > 1:\n print(\"Alice\")\nelse:\n print(\"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"720f62eec460f11c7a35","document_content":"X, Y = list(map(int,input().split()))\nif abs(X-Y) <= 1:\n print(\"Brown\")\nelse:\n print(\"Alice\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"992c01d98861e7859001","document_content":"x,y=map(int,input().split())\nif abs(x-y)>1:\n print('Alice')\nelse:\n print('Brown')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"07c2542693932ac393d5","document_content":"x, y = map(int, input().split())\nif abs(x-y) <= 1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"23d13e76bd56ee895cd1","document_content":"x,y = map(int,input().split())\nif y > x:\n x,y = y,x\n\nif x - y <= 1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"884d339e7672a9dbfb9f","document_content":"x,y=map(int,input().split())\nif x>y:\n x,y=y,x\n \nif y-x<=1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"be0c24fc4a7b274e6283","document_content":"def solve():\n x, y = list(map(int, input().split()))\n if abs(x - y) <= 1:\n print('Brown')\n else:\n print('Alice')\n\n\ndef __starting_point():\n solve()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"aa18abac3a41373a5ac6","document_content":"a,b=map(int,input().split())\nprint(\"Alice\" if abs(a-b)>1 else \"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"439c71da34ded4b7769c","document_content":"x,y=map(int, input().split())\nprint(\"Brown\"if abs(x-y)<2else\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d9176e9d0ebb12c382cb","document_content":"X, Y = list(map(int, input().split()))\nif abs(X - Y) <= 1:\n print('Brown')\nelse:\n print('Alice')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b12e38eeab429acb65a1","document_content":"x,y=map(int,input().split())\nif abs(x-y)>=2:\n print(\"Alice\")\nelse:\n print(\"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"532225d7b7ae4d474577","document_content":"def main():\n X, Y = list(map(int, input().split(' ')))\n if abs(X - Y) > 1:\n print('Alice')\n else:\n print('Brown')\n\n\ndef __starting_point():\n main()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4bd493f64949c29f4f3a","document_content":"X, Y = map(int, input().split())\nprint(\"Brown\" if abs(X - Y) <= 1 else 'Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3385a979acc29cfb2b4d","document_content":"X,Y=map(int,input().split())\nX,Y=max(X,Y),min(X,Y)\n#print(X,Y)\n\nif X<=1:\n print(\"Brown\")\nelse:\n if X-Y>=2:\n print(\"Alice\")\n else:\n print(\"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9e586a4fa74e70d837e1","document_content":"x,y=map(int,input().split())\nprint(\"Brown\" if abs(x-y)<=1 else \"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"993f5e8f498651427dec","document_content":"# -*- coding: utf-8 -*-\n\nimport sys\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x \/\/ y))\ndef INT(): return int(input())\ndef MAP(): return list(map(int, input().split()))\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\nX, Y = MAP()\n\nmemo = list2d(1007, 1007, -1)\ndef rec(x, y):\n if memo[x][y] != -1:\n return memo[x][y]\n if x < 2 and y < 2:\n memo[x][y] = 0\n return 0\n res = 0\n for i in range(2, x+1):\n if not rec(x - i, y + i\/\/2):\n res = 1\n for i in range(2, y+1):\n if not rec(x + i\/\/2, y - i):\n res = 1\n memo[x][y] = res\n return res\n\n# for i in range(X+1):\n# for j in range(Y+1):\n# rec(i, j)\n# for i in range(X+1):\n# print(memo[i][:Y+1])\n\nif abs(X - Y) >= 2:\n print('Alice')\nelse:\n print('Brown')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"12127dd357a96da82799","document_content":"x, y = map(int, input().split())\nif abs(x - y) < 2:\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cae83baf8a355cc9d14a","document_content":"import sys\nsys.setrecursionlimit(10000000)\nMOD = 10 ** 9 + 7\nINF = 10 ** 15\n\ndef main():\n X,Y = list(map(int,input().split()))\n if abs(X - Y) <= 1:\n print('Brown')\n else:\n print('Alice')\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"afdea3d520b81408359b","document_content":"# \u89e3\u8aacAC\nX,Y = map(int, input().split())\nprint(\"Alice\" if abs(X - Y) > 1 else \"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fc0774c53f3cef96e1c5","document_content":"x,y= list(map(int,input().split()))\nresult=abs(x-y)\n\n\nif result <=1:\n print(\"Brown\")\nelse:\n print(\"Alice\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"37dceb8c9df148027f59","document_content":"X,Y = map(int, open(0).read().split())\nif abs(X-Y) <= 1:\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a71d880d29553458fa2c","document_content":"x, y = map(int, input().split())\nprint('Alice' if abs(x-y) > 1 else 'Brown')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9960275525318cf2946a","document_content":"X,Y=map(int,input().split())\nprint(\"Brown\" if abs(X-Y)<=1 else \"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d5b63adadbc2831504e1","document_content":"a,b=map(int,input().split())\nif abs(a-b)>1:print(\"Alice\")\nelse:print(\"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"039329de2c76c1be9116","document_content":"X, Y = map(int, input().split())\nprint(\"Brown\" if abs(X-Y) <= 1 else \"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f632b897fa77d91ca7ee","document_content":"x,y=list(map(int,input().split()))\nprint((\"Alice\" if abs(x-y)>1 else \"Brown\"))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d317df6ce4539949a140","document_content":"n,m = map(int,input().split())\nif abs(n-m) < 2:\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b2aaabfb9040f574eb1e","document_content":"#01:25\na,b = map(int,input().split())\nif abs(a-b) <= 1:\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a0f5569001ab4392b4ed","document_content":"X, Y = map(int,input().split())\nif abs(X - Y) < 2:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"509f4c8c61c2485a2e48","document_content":"X,Y=map(int,input().split())\nif abs(X-Y)>1:\n print(\"Alice\")\nelse:\n print(\"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c0b24c78f2a386186946","document_content":"x,y=map(int,input().split())\nif abs(x-y)<=1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cea9fe2672ed175a61e4","document_content":"import sys\n\nsys.setrecursionlimit(10 ** 6)\ndef MI(): return map(int, sys.stdin.readline().split())\n\ndef main():\n x,y=MI()\n if x>y:x,y=y,x\n if y>x+1:print(\"Alice\")\n else:print(\"Brown\")\n\nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3a2e5ba60f067cc42192","document_content":"x,y=map(int,input().split())\na=abs(x-y)\nif a==0 or a==1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"77373188acb5c31966ab","document_content":"X,Y = list(map(int,input().split()))\n\nprint((\"Brown\" if abs(X-Y) <= 1 else \"Alice\"))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f264e3e20b37a1567279","document_content":"X, Y = map(int, input().split())\n\nif X >= Y+2:\n print('Alice')\nelif X <= Y-2:\n print('Alice')\nelse:\n print('Brown')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7d899db92a02d1394a3e","document_content":"#\u4e00\u554f\u76ee\nx,y=list(map(int,input().split()))\nif abs(x-y)<=1:\n print(\"Brown\")\nelse:\n print(\"Alice\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dba357fedc4a57c10107","document_content":"X, Y = map(int,input().split())\nprint('Brown' if abs(X - Y) <= 1 else 'Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f03ced30e766b1541317","document_content":"x,y=list(map(int,input().split()))\nif abs(x-y)<=1:\n print('Brown')\nelse:\n print('Alice')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0673f549a7501eba777a","document_content":"a,b=map(int,input().split())\nif -2 1 else \"Brown\"))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f285971131073f088a61","document_content":"x,y = map(int, input().split())\n\nif abs(x-y)>1:\n print(\"Alice\")\nelse:\n print(\"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c4c00d85eed06622aeb3","document_content":"X, Y = map(int,input().split())\nif abs(X-Y) <=1:\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3adbdc15e0ea2f8f5fe5","document_content":"X,Y = map(int,input().split())\nif abs(X-Y)<=1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3901c18f68be43a6eb8a","document_content":"import sys\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninl = lambda: [int(x) for x in sys.stdin.readline().split()]\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\n\ndef solve():\n x, y = inl()\n if x > y:\n x, y = y, x\n d = y - x\n if d <= 1:\n return False\n return True\n\n\nprint(\"Alice\" if solve() else \"Brown\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"750398cca7160b90075f","document_content":"x,y = list(map(int,input().split()))\nif abs(x-y) <= 1:\n print(\"Brown\")\nelse:\n print(\"Alice\")\n# a:x+y >1 , abs(x-y)>1\n# b:x+y >1 , abs(x-y) <=1\n# c:x+y <=1, (abs(x-y) <=1 )\u3000--> lose\n#\n# c <--- a <---> b\n# a <---> a\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"db9a93475a13baa974f9","document_content":"import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom itertools import accumulate, permutations, combinations, product\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left\nfrom fractions import gcd\nfrom heapq import heappush, heappop\nfrom functools import reduce, lru_cache\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return list(map(int, input().split()))\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return list(zip(*(MAP() for _ in range(n))))\nsys.setrecursionlimit(10 ** 9)\nINF = float(\"inf\")\nmod = 10 ** 9 + 7\n\nX, Y = MAP()\nif abs(X-Y) <= 1:\n\tprint(\"Brown\")\nelse:\n\tprint(\"Alice\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9181a17c3d796731a019","document_content":"X,Y=map(int,input().split())\nprint(['Alice','Brown'][abs(X-Y)<2])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b00af72086d15499a960","document_content":"X, Y = map(int, input().split())\n\nif abs(X - Y) <= 1:\n print ('Brown')\nelse:\n print ('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b8073029695f074d35f4","document_content":"x,y = map(int,input().split())\n\nprint(\"Alice\" if abs(x-y)>1 else \"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"55d3eabb4ff2f07534cb","document_content":"import sys\n\ndef solve():\n input = sys.stdin.readline\n X, Y = map(int, input().split())\n if abs(X - Y) > 1: print(\"Alice\")\n else: print(\"Brown\")\n\n return 0\n\ndef __starting_point():\n solve()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"807bfde7dec41757162d","document_content":"x,y=map(int,input().split())\nprint(\"BArloiwcne\"[abs(x-y)>1::2])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3b39c039391f4b2fbae1","document_content":"x,y = map(int,input().split())\n\nif abs(x-y) <= 1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"04611e485fa3ad2dd11b","document_content":"x,y=map(int,input().split())\nprint('Brown' if abs(x-y)<=1 else 'Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7a89898509bd1fe2cc43","document_content":"x, y = list(map(int, input().split()))\nif abs(x-y) <= 1:\n print('Brown')\nelse:\n print('Alice')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"553171ba3ba7dc79163e","document_content":"x,y = map(int,input().split())\nif abs(x-y)<=1:\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2d422c24edf03401394c","document_content":"x, y = list(map(int,input().split()))\nif abs(x-y) <= 1:\n print('Brown')\nelse:\n print('Alice')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9babb43037e0ff30a4f6","document_content":"x,y=map(int,input().split())\nif abs(x-y)<=1:print(\"Brown\")\nelse:print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"71a933e71ec0f427e257","document_content":"X, Y = list(map(int, input().split()))\n\nprint(('Alice' if abs(X - Y) > 1 else 'Brown'))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"df2995e25c0da50ee313","document_content":"import sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nX, Y = lr()\n\nif abs(Y - X) >= 2:\n print('Alice')\nelse:\n print('Brown')\n\n# 24\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b53f9d5a8b904aab8a67","document_content":"X, Y = map(int, input().split())\nif abs(X-Y) <= 1:\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b52c7bcb4b2d25450346","document_content":"X, Y = list(map(int, input().split()))\nans = 'Brown' if abs(X - Y) <= 1 else 'Alice'\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e822d314f5becff6f8cf","document_content":"X, Y = map(int, input().split())\nprint('Alice' if abs(X-Y)>=2 else 'Brown')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6209dab2a11280d067ad","document_content":"# solution\nimport io\n\nnim,mike = map(int,input().split())\nprint(\"Brown\" if abs(nim-mike)<2 else \"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"353e45926720b0c37096","document_content":"a,b=list(map(int,input().split()))\ncnt=1\nif abs(a-b)<=1:\n print('Brown')\nelse:\n print('Alice')\n\n\n# if b>a:\n# a,b=b,a\n# a=a-b\n# b=0\n# mod_a=a%3\n# if a==3:\n# print('Alice')\n# elif mod_a==2:\n# print('Alice')\n# elif mod_a==1:\n# print('Brown')\n# elif (mod_a==0)and(a!=3):\n# print('Brown')\n# if (mod_a==3)and(mod_b==3):\n# print('Alice')\n# elif (mod_a==3)and(mod_b==1):\n# print('Alice')\n# elif (mod_a==1)and(mod_b==3):\n# print('Alice')\n# elif (mod_a==2)and(mod_b==0):\n# print('Alice') \n# elif (mod_a==0)and(mod_b==2):\n# print('Alice')\n# else:\n# print('Brown')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8ac5d8727a3711a3ef8f","document_content":"x,y=map(int,input().split())\nprint(\"Brown\"if abs(x-y)<2else\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1f9544c19a5537cfae69","document_content":"x, y = map(int, input().split())\nprint(\"Alice\" if abs(x - y) > 1 else \"Brown\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"eb1f4e9e9318a147de69","document_content":"a,b = map(int, input().split())\nif abs(a-b) <= 1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d0663f33c1ac693027a8","document_content":"x, y = map(int, input().split())\nif -1 <= x-y <= 1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4b15a48ae63ac5e9206d","document_content":"def main():\n x, y = map(int, input().split())\n if abs(x-y) <= 1:\n print(\"Brown\")\n else:\n print(\"Alice\")\n\ndef __starting_point():\n main()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"123c452834060d19ede7","document_content":"#!\/usr\/bin\/env python3\nimport sys\n\n\ndef solve(X: int, Y: int):\n return 'Alice' if abs(X-Y) > 1 else 'Brown'\n\n\n# Generated by 1.1.6 https:\/\/github.com\/kyuridenamida\/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n X = int(next(tokens)) # type: int\n Y = int(next(tokens)) # type: int\n print((solve(X, Y)))\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dfee4bbc6287ab2be8c5","document_content":"X,Y = map(int,input().split())\ndiff = abs(X-Y)\nif(diff < 2):\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e4b2168ffe42e6dc4140","document_content":"a,b=map(int,input().split())\nif abs(a-b)<=1:\n print(\"Brown\")\nelse:\n print(\"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"be001a821394ba650f9c","document_content":"# editorial\n\ndef main():\n X, Y = list(map(int, input().split()))\n\n def solve(x, y):\n \"\"\"\u624b\u756a\u304c\u52dd\u3064\u304b\"\"\"\n return not ((X + Y <= 1) or (abs(X - Y) <= 1))\n\n cond = solve(X, Y)\n print(('Alice' if cond else 'Brown'))\n\n\ndef __starting_point():\n main()\n\n# e,e\n# o,e\n# o,o\n# o,e\u9077\u79fb\u306f\u4eca\u56de\u306f\u95a2\u4fc2\u306a\u304b\u3063\u305f\n\n# \u8ca0\u3051\u72b6\u614b\n# 0,0\n# 0,1\n# 1,1\n# \u307e\u3068\u3081\u308b\u3068\n# X+Y<=1\n# abs(X-Y)<=1 <-> >1 \u3068\u4ea4\u4e92\n\n# \u307e\u3068\u3081\u65b9\n# \u5076\u5947\n# \u548c\u3068\u5dee\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"39f761eca19c99fd2600","document_content":"X, Y = list(map(int, input().split()))\n\nif (X == 0 and Y == 0) or (X == 0 and Y == 1) or (\n X == 1 and Y == 0) or (X == 1 and Y == 1):\n print('Brown')\n return\n\nnum = abs(X - Y)\n\nif num <= 1:\n print('Brown')\nelse:\n print('Alice')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4de8831ad1e0c0eb555e","document_content":"X, Y = list(map(int, input().split()))\n\nprint(('Brown' if abs(X - Y) < 2 else 'Alice'))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8e791fbdf1ad123859f3","document_content":"x,y=map(int,input().split())\nif abs(x-y)<=1:\n print('Brown')\nelse:\n print('Alice')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"285df979e5ab5c1a15ea","document_content":"x,y=list(map(int,input().split()))\nif abs(x-y)<=1:\n print(\"Brown\")\nelse:\n print(\"Alice\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3de4d1069ff9dc1be711","document_content":"import sys\nimport heapq, math\nfrom itertools import zip_longest, permutations, combinations, combinations_with_replacement\nfrom itertools import accumulate, dropwhile, takewhile, groupby\nfrom functools import lru_cache\nfrom copy import deepcopy\n\n\nX, Y = map(int, input().split())\n\nprint(\"Brown\" if abs(X - Y) <= 1 else \"Alice\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0c69eb869add20f92532","document_content":"X,Y=map(int,input().split())\nif X 1 : 1\n## X-Y: must change by 3\nX, Y = list(map(int, input().split()))\nif abs(X-Y) > 1:\n print('Alice')\nelse:\n print('Brown')\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1c8348c1a3d7f61795a9","document_content":"T=int(input())\n\nfor t in range(T):\n s=input()\n ans=0\n L=[]\n for i in [1,2,3,4,6,12]:\n x=i\n y=12\/\/x\n E=[]\n for j in range(12):\n if(j%y==0):\n E.append(\"\")\n E[-1]+=s[j]\n for j in range(y):\n c=0\n for z in range(i):\n if(E[z][j]=='X'):\n c+=1\n if(c==i):\n ans+=1\n L.append(i)\n break\n print(ans,end=\" \")\n for item in L:\n print(item,end=\"x\")\n print(12\/\/item,end=\" \")\n print()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4c5cd18f9f2c4d055a3a","document_content":"#!\/usr\/bin\/env python3\n\ndef read_ints():\n\treturn list(map(int, input().strip().split()))\n\nt, = read_ints()\n\nfor _ in range(t):\n\tx = input()\n\n\tcorrect = []\n\n\tfor a in [1, 2, 3, 4, 6, 12]:\n\t\tcor = False\n\t\tfor c in range(0, 12\/\/a):\n\t\t\ts = set(x[c::12\/\/a])\n\n\t\t\tif len(s)==1 and 'X' in s:\n\t\t\t\tcor = True\n\t\t\t\tbreak\n\n\t\tif cor == True:\n\t\t\tcorrect.append(\"{}x{}\".format(a, 12\/\/a))\n\t\n\tprint(len(correct), ' '.join(correct))\n\t\t\t\t\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f217eca9de58d0c1027e","document_content":"# http:\/\/codeforces.com\/contest\/400\/problem\/0\n# Codeforces : A. Inna and choose options\n\nliste_a = (1, 2, 3, 4, 6, 12)\nliste_results = []\n\ndef process(essai):\n nonlocal liste_results\n liste_av = [0]\n for a in liste_a:\n b = 12 \/\/ a\n for r in range(b):\n if essai[r::b] == 'X'*a:\n liste_av[0] += 1\n liste_av.append('{}x{}'.format(a,b))\n break\n liste_av[0] = str(liste_av[0])\n liste_results.append(liste_av)\n\n\n\n\nt = int(input())\nfor k in range(t):\n essai = input()\n process(essai)\n\nfor s in liste_results:\n print(*s)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b261b7460f10f29ef975","document_content":"t = int(input())\nfor i in range(t):\n s = input().strip()\n cnt = 0\n ans = []\n for b in [1, 2, 3, 4, 6, 12]:\n List = []\n a = 12 \/\/ b\n for begin in range(b):\n column = ''\n j = begin\n while j < 12:\n column += s[j]\n j += b\n List.append(column)\n #print(i, b, List)\n if 'X' * a in List:\n cnt += 1\n ans.append((a, b))\n print(cnt, end = ' ')\n for pair in sorted(ans):\n print('x'.join(map(str, pair)), end = ' ')\n print()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ffa0c3ac25f2a968c5a7","document_content":"def test(s):\n res = []\n for i in [[1, 12], [2, 6], [3, 4], [4, 3], [6, 2], [12, 1]]:\n a = [[\"O\" for i in range(i[1])] for j in range(i[0])]\n for j in range(i[0]):\n for k in range(i[1]):\n a[j][k] = s[j * i[1] + k]\n if check(a):\n res.append(i)\n return res\n\ndef check(a):\n for i in range(len(a[0])):\n if not \"O\" in [a[j][i] for j in range(len(a))]:\n return True\n return False\n\nt = int(input())\nfor i in range(t):\n s = input().strip()\n x = test(s)\n print(len(x), end=\" \")\n for j in x:\n print(j[0], \"x\", j[1], sep=\"\", end=\" \")\n print()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"370306bd576096991eb6","document_content":"for _ in range(int(input())):\n cards = input()\n count = 0\n output = ''\n if 'X' in cards:\n count += 1\n output += ' 1x12'\n for q, p in zip(cards[:6], cards[6:]):\n if q == p == 'X':\n count += 1\n output += ' 2x6'\n break\n for q, p, r in zip(cards[:4], cards[4:8], cards[8:]):\n if q == p == r == 'X':\n count += 1\n output += ' 3x4'\n break\n for q, p, r, s in zip(cards[:3], cards[3:6], cards[6:9], cards[9:]):\n if q == p == r == s == 'X':\n count += 1\n output += ' 4x3'\n break\n for q, p, r, s, t, u in zip(cards[:2], cards[2:4], cards[4:6], cards[6:8], cards[8:10], cards[10:]):\n if q == p == r == s == t == u == 'X':\n count += 1\n output += ' 6x2'\n break\n if 'O' not in cards:\n count += 1\n output += ' 12x1'\n print(str(count) + output)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e7a2193bf4db43b23c0e","document_content":"n = int(input())\nab = [12, 6, 4, 3, 2, 1]\nlst = [list(input()) for i in range(n)]\nres = [[0] for i in range(n)] \nfor pr in range(n):\n for elem in ab:\n for i in range(elem):\n x = 1\n for j in range(0, 12, elem):\n if lst[pr][i + j] == \"O\":\n x = 0\n if x == 1 and str(12 \/\/ elem) + \"x\" + str(elem) not in res[pr]: \n res[pr][0] += 1\n res[pr].append(str(12 \/\/ elem) + \"x\" + str(elem))\nfor i in range(len(res)):\n print(\" \".join(map(str, res[i])))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2eb7995262e7a688d30d","document_content":"t = int(input())\nfor i in range(t):\n s = input()\n ans = \"\"\n count = 0\n for j in range(1, 13):\n flag = False\n if 12 % j == 0:\n for p in range(12 \/\/ j):\n q = p\n while q < 12 and s[q] == \"X\":\n q += 12 \/\/ j\n if q >= 12:\n flag = True\n if flag:\n ans += str(j) + \"x\" + str(12 \/\/ j) + \" \"\n count += 1\n print(count, ans[:-1])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ce48dac89e0c6f715f1d","document_content":"n=int(input())\nfor i in range(n):\n a=input()\n c=0\n p=''\n if 'XXXXXXXXXXXX'==a:\n print('6 1x12 2x6 3x4 4x3 6x2 12x1')\n continue\n if 'X' in a:\n p=p+'1x12'\n c+=1\n if 'XX'==(a[0]+a[6]) or 'XX'==(a[1]+a[7]) or 'XX' ==(a[2]+a[8]) or 'XX' ==(a[3]+a[9]) or 'XX' ==(a[4]+a[10]) or 'XX' ==(a[5]+a[11]):\n c+=1\n p+=' 2x6'\n if 'XXX'==(a[0]+a[4]+a[8]) or 'XXX'==(a[1]+a[5]+a[9]) or 'XXX'==(a[2]+a[6]+a[10]) or 'XXX'==(a[3]+a[7]+a[11]):\n p+=' 3x4'\n c+=1\n if 'XXXX'==(a[0]+a[3]+a[6]+a[9]) or 'XXXX'==(a[1]+a[4]+a[7]+a[10]) or 'XXXX'==(a[2]+a[5]+a[8]+a[11]):\n c+=1\n p+=' 4x3'\n if 'XXXXXX'==(a[0]+a[2]+a[4]+a[6]+a[8]+a[10])or 'XXXXXX'==(a[1]+a[3]+a[5]+a[7]+a[9]+a[11]):\n c+=1\n p+=' 6x2'\n print(c,p)\n \n\n else:\n print(0)\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ec3e7144f919510d1e19","document_content":"n = int(input())\np = 0\nf = True\nfor k in range(n):\n s = input().strip()\n ot = set()\n for i in range(1, 13):\n if i == 5 or i == 7 or i == 9 or i == 10 or i == 11 or i == 8:\n continue\n for t in range(i):\n p = True\n for j in range(t, 12, i):\n if s[j] == 'O':\n p = False\n if p:\n ot.add(i)\n ot = list(reversed(sorted(list(ot))))\n print(len(ot), end = ' ')\n for i in ot:\n print(str(12\/\/i)+'x'+str(i), end = ' ')\n print()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b1358504010fadc31fb4","document_content":"from functools import reduce\n\ndef sol(l):\n if not \"X\" in l: return \"0\"\n l = l.replace(\"O\",\"0\").replace(\"X\",\"1\")\n res = [ \"%ix%i\" % (12\/\/i, i) for i in (12,6,4,3,2,1) if reduce(lambda x, y: x&y, [int(l[i*j:i*j+i],2) for j in range(12\/\/i)], -1)]\n return (\"%i %s\" % (len(res), \" \".join(res)))\n\nn = int(input())\nprint(\"\\n\".join([sol(input()) for i in range(n)]))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"46bbaf497b2c6fdd6ace","document_content":"from functools import reduce\nprint(\"\\n\".join([(lambda x:(\"%i %s\" % (len(x), \" \".join(x))))((lambda h:[ \"%ix%i\" % (12\/\/i, i) for i in (12,6,4,3,2,1) if reduce(lambda x, y: x&y, [int(h.replace(\"O\",\"0\").replace(\"X\",\"1\")[i*j:i*j+i],2) for j in range(12\/\/i)], -1)])(input())) for i in range(int(input()))]))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"504f4db751ea2c1c4ae2","document_content":"t = int(input())\nn = 12\nwhile t > 0:\n ans = []\n t = t - 1\n s = input()\n for i in range(n):\n r = i+1\n if n%r != 0:\n continue\n c = n\/\/r\n flag = False\n for j in range(c):\n id = j\n ff = False\n while id < n:\n if s[id] != 'X':\n ff = True\n break\n id = id + c\n if ff == False:\n flag = True\n break\n if flag == True:\n ans.append((r, c))\n\n print(len(ans), end = '')\n for i in range(len(ans)):\n print(' ', ans[i][0], 'x', ans[i][1], sep = '', end = '')\n print('')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0baf037fadffc6ed07a3","document_content":"q = [12, 6, 4, 3, 2, 1]\np = {12 \/\/ i: 'X' * i for i in q}\nr = {i: str(12 \/\/ i) + 'x' + str(i) for i in q}\nfor i in range(int(input())):\n s, t = [], input()\n for j in q:\n if any(t[k :: j] == p[j] for k in range(j)): s.append(r[j])\n print(len(s), ' '.join(s))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"980e46a3c153babab9e6","document_content":"#!\/usr\/local\/bin\/python33\nn = int(input())\n\nfor i in range(n):\n\tcnt = 0\n\tansw = ['1x12', '2x6', '3x4', '4x3', '6x2', '12x1']\n\tanswb = [False, False, False, False, False, False]\n\tinstr = input()\n\n\tif 'X' in instr:\n\t\tcnt += 1\n\t\tanswb[0] = True\n\tfor j in range(6):\n\t\tif (instr[j] == instr[6 + j] == 'X'):\n\t\t\tcnt += 1\n\t\t\tanswb[1] = True\n\t\t\tbreak\n\tfor j in range(4):\n\t\tif (instr[j] == instr[4 + j] == instr[8 + j] == 'X'):\n\t\t\tcnt += 1\n\t\t\tanswb[2] = True\n\t\t\tbreak\n\tfor j in range(3):\n\t\tif (instr[j] == instr[3 + j] == instr[6 + j] == instr[9 + j] == 'X'):\n\t\t\tcnt += 1\n\t\t\tanswb[3] = True\n\t\t\tbreak\n\tfor j in range(2):\n\t\tif (instr[j] == instr[2 + j] == instr[4 + j] == instr[6 + j] == instr[8 + j] == instr[10 + j] == 'X'):\n\t\t\tcnt += 1\n\t\t\tanswb[4] = True\n\t\t\tbreak\n\tif not 'O' in instr:\n\t\tcnt += 1\n\t\tanswb[5] = True\n\n\tprint(cnt, end = ' ')\n\tfor i in range(6):\n\t\tif answb[i]:\n\t\t\tprint(answ[i], end = ' ')\n\tprint()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2accb9c52b5aafe86ceb","document_content":"t = int(input())\nfor i in range(0, t):\n str = input()\n answer = []\n p = [1, 2, 3, 4, 6, 12]\n for j in range(0, len(p)):\n d1, d2 = p[j], 12 \/\/ p[j]\n cnt = [0 for h in range(0, d2)]\n for i2 in range(0, 12):\n tt = i2 % d2\n cnt[tt] += (str[i2] == 'X')\n ans_cand = False\n for i2 in range(0, d2):\n if cnt[i2] == d1:\n ans_cand = True\n if ans_cand:\n answer.append('%dx%d' % (d1, d2))\n print(len(answer), end = ' ')\n for j in range(0, len(answer)):\n print(answer[j], end = ' ')\n print()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dbb3660fa46912e20b32","document_content":"t = int(input().strip())\nfor i in range(t):\n s = input()\n ans = []\n for h in [x for x in range(1, 13) if 12 % x == 0]:\n good = False\n w = 12 \/\/ h\n for k in range(w):\n ok = True\n for l in range(h):\n if s[l * w + k] != 'X':\n ok = False\n if ok:\n good = True\n if good:\n ans.append(str(h) + \"x\" + str(w))\n print(str(len(ans)) + \" \" + \" \".join(ans))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9762139da7e4e65f346a","document_content":"T=int(input())\n\nwhile T>=1:\n T-=1\n a=input()\n list=[]\n for i in range(1,13):\n if 12 % i==0:\n l=12\/\/i\n for j in range(0,l):\n for k in range(0,i):\n if a[k*l+j]!='X':\n break\n else:\n break\n else:\n continue\n list.append(i)\n print(len(list),end=' ')\n for i in range(0,len(list)):\n print(str(list[i])+'x'+str(12\/\/list[i]),end=' ')\n print()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d6fb0e24053929c422c1","document_content":"a=int(input())\nwhile a:\n l=[]\n b=input()\n if((b.count(\"X\"))>0):\n l.append(\"1x12\")\n if((b[:6].count(\"X\"))>0):\n p=[i for i in range(6) if b[i]=='X']\n for i in p:\n if(b[i:12:6]=='XX'):\n l.append(\"2x6\")\n break\n if((b[:4].count(\"X\"))>0):\n p=[i for i in range(4) if b[i]=='X']\n for i in p:\n if(b[i:12:4]==\"XXX\"):\n l.append(\"3x4\")\n break\n if((b[:3].count(\"X\"))>0):\n p=[i for i in range(3) if b[i]=='X']\n for i in p:\n if(b[i:12:3]==\"XXXX\"):\n l.append(\"4x3\")\n break\n if((b[:2].count(\"X\"))>0):\n p=[i for i in range(2) if b[i]=='X']\n for i in p:\n if(b[i:12:2]==\"XXXXXX\"):\n l.append(\"6x2\")\n break\n if(b.count(\"X\")==12):\n l.append(\"12x1\")\n print(len(l),end=\" \")\n if(len(l)>0):\n for i in l:\n print(i,end=\" \")\n print()\n a-=1","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bda1859afe771fd4d536","document_content":"def test_col(s, a, b, col):\n\tres = True\n\tfor i in range(0, a):\n\t\tif s[i * b + col] != 'X':\t\n\t\t\tres = False\n\treturn res\t\n\ndef test_all_cols(s, a):\n\tb = len(s) \/\/ a\n\tif a * b != len(s):\n\t\treturn False\n\telse:\n\t\tres = False\n\t\tfor i in range(0, b):\n\t\t\tres = res or test_col(s, a, b, i)\n\t\treturn res\n\n\t\nn = int(input())\nfor i in range(0, n):\n\ts = input()\n\tslen = len(s)\n\tcvariants = 0 \n\tvariants = \"\"\n\tfor a in range(1, slen + 1):\t\t\n\t\tif (test_all_cols(s, a)):\n\t\t\tcvariants += 1\n\t\t\tvariants += str(a) + \"x\" + str(slen \/\/ a) + \" \"\n\tprint(str(cvariants), variants)\n\t\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"88b5813e22b1a343ac63","document_content":"# -*- coding: UTF-8 -*-\ndef evaluate(origin_str):\n ans = []\n for i in [1,2,3,4,6,12]:\n last_idx = int(12 \/ i)\n flags = [1 for i in range(0,last_idx)]\n if (i == 1):\n flag = False\n for ch in origin_str:\n if (ch == 'X'):\n flag = True\n if (flag):\n ans.append([i,last_idx])\n else:\n for j in range(0,last_idx):\n tmp = []\n k = j - last_idx\n for x in range(0,i):\n k += last_idx\n tmp.append(k)\n for l in tmp:\n ch = origin_str[l]\n if (ch != 'X'):\n flags[j] = 0\n if (sum(flags) != 0):\n ans.append([i,last_idx])\n s = \"\"\n for a in ans:\n s += str(a[0])+\"x\"+str(a[1]) + \" \"\n print(str(len(ans)) + \" \" + s)\n \ndef main():\n n = int(input())\n for i in range(0,n):\n evaluate(input())\n \nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b5eec6d070c657a79c13","document_content":"\nn = int(input())\n\n\nfor _ in range(n):\n mystr = input()\n answer = []\n \n divisibles = [1,2,3,4,6,12]\n for i in divisibles:\n flag=0\n \n for j in range(0,12\/\/i):\n columnSet = set(mystr[j::12\/\/i])\n if len(columnSet)==1 and \"X\" in columnSet:\n flag=1\n break\n\n if flag==1:\n answer.append(\"{}x{}\".format(i,12\/\/i));\n print(len(answer), \" \".join(answer))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0c339fe17dae629f6f5c","document_content":"t = int(input())\nfor _ in range(t):\n s = input()\n b = []\n for n in [1, 2, 3, 4, 6, 12]:\n m = 12 \/\/ n\n for j in range(m):\n if s[j::m] == \"X\" * n:\n b += [(n, m)]\n break\n print(len(b), ' '.join(str(x) + \"x\" + str(y) for x, y in b))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a5e1e827d3c2f0248b34","document_content":"t = int(input())\nans = [[] for i in range(t)]\nfor i in range(t):\n \n s = input() \n for a in range(1, 13):\n \n \n if 12 % a != 0:\n continue\n b = 12 \/\/ a\n c = [[] for h in range(b)]\n for h in range(b):\n for k in range(a):\n c[h].append(s[k * b + h])\n if a == 3:\n a = 3 \n T = True\n for h in range(b):\n if T:\n ok = True\n for k in range(a):\n if c[h][k] == 'O':\n ok = False\n if ok:\n ans[i].append([a, b])\n T = False\n break\nfor i in range(t):\n print(len(ans[i]), end = ' ')\n for z in ans[i]:\n print(z[0], end = '')\n print('x', end= '')\n print(z[1], end = ' ')\n print()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"84b96d94ecc5c702a942","document_content":"def do(string):\n num = 0\n ok = []\n for i in [12, 6, 4, 3, 2, 1]:\n for j in range(0, i):\n if string[j::i] == 'X' * int(12\/i):\n ok.append(str(int(12\/i))+'x'+str(i))\n num += 1\n break\n\n ok = [str(num)] + ok\n print(' '.join(ok))\n\nfor i in range(int(input())):\n do(input())\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fd7aa4bfe5d92f2dbeb6","document_content":"import sys\n\nimport math\nfrom math import sqrt\nimport bisect\n \nsmall = 10**5+1\nbig = 10**18+1\n \npos = []\nf = pos.append\n#pos.add(1)\nj = 2\nwhile True:\n #if sqrt(j).is_integer():\n # j+=1\n # continue\n j2 = j*j\n i = j*j2\n if i>=big:\n break\n #if int(i**0.5+0.5)**2==i:\n # j+=1\n # continue\n while i1:\n m = (a+b)\/\/2\n if pos[m]=L:\n # under -= 1\n \n a = -1\n b = len(pos)\n \n \n \n while b-a>1:\n m = (a+b)\/\/2\n if pos[m]<=R:\n a = m\n else:\n b = m\n upper = a\n #upper = bisect.bisect_left(pos,R+1)-1\n Lupp = max(int(sqrt(L)-1),0)\n while Lupp*LuppR:\n Rdown-=1\n \n count = max(0,Rdown-Lupp+1)\n out.append(str(upper-under+count))\nprint('\\n'.join(out))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"aff970f4b4d0fbf177de","document_content":"import math\nimport bisect\nimport sys\n\ndef flrt(exp,x):\n l=max(0,math.floor(x**(1\/exp))-3)\n \n r= math.floor(x**(1\/exp))+3\n while l=u):\n c = 0\n l = 0\n i = 0\n ii = -1\n pp = p\n while(i k traverse the string \n\t\t# again until count becomes less than k \n\t\t# and decrease the count when characters \n\t\t# are not same \n\t\twhile cnt > k: \n\t\t\tif A[l] != ch: \n\t\t\t\tcnt -= 1\n\t\t\tl += 1\n\n\t\t# length of substring will be rightIndex - \n\t\t# leftIndex + 1. Compare this with the \n\t\t# maximum length and return maximum length \n\t\tmaxlen = max(maxlen, r - l + 1) \n\t\tr += 1\n\n\treturn maxlen \n\n# function which returns \n# maximum length of substring \ndef answer(A, n, k): \n\tmaxlen = 1\n\tfor i in range(26): \n\t\tmaxlen = max(maxlen, findLen(A, n, k, \n\t\t\t\t\t\t\tchr(i + ord('A')))) \n\t\tmaxlen = max(maxlen, findLen(A, n, k, \n\t\t\t\t\t\t\tchr(i + ord('a')))) \n\n\treturn maxlen \n\nn,k=map(int, input().split())\ns=str(input())\nprint(answer(s, n, k))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4fed92c18f545eef8d55","document_content":"N, I = list(map(int, input().split()))\nA = sorted([int(a) for a in input().split()])\nB = []\nj = 0\nfor i in range(N):\n if i == 0 or A[i] == A[i-1]:\n B.append(j)\n else:\n j += 1\n B.append(j)\n\ndef calc(k):\n K = 1< 8 * I:\n k -= 1\n else:\n break\nK = 2 ** k\n\nNN = len(l)\nif NN <= K:\n print(0)\n return\n\nsm = sum(l[:K])\nmx = sm\n\nfor i in range(K, NN):\n sm += l[i] - l[i - K]\n mx = max(mx, sm)\n\nprint(sum(l) - mx)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a4f2d448ea1ae1813a7f","document_content":"from math import log, floor\nn,I = list(map(int, input().split()))\na = [int(s) for s in input().split()]\nb = []\na.sort()\nb.append([-1, 0])\nfor i in range(0, n):\n if a[i] == b[-1][0]:\n b[-1][1] += 1\n else:\n b.append([a[i], b[-1][1]+1])\nmaxk = I*8\/\/n\nmaxK = 1< len(c):\n print(0)\n else:\n pref = c.copy()\n suff = c.copy()\n for i in range(1, len(c)):\n pref[i] += pref[i-1]\n for i in range(len(c)-2, -1, -1):\n suff[i] += suff[i+1]\n\n res = sum(c)\n l = 0\n r = K-1\n while r < len(c):\n s1 = 0 if l == 0 else pref[l-1]\n s2 = 0 if r == len(c)-1 else suff[r+1]\n res = min(res, s1+s2)\n l += 1\n r += 1\n\n print(res)\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cf76bbe0d26168fdc94a","document_content":"R=lambda:map(int,input().split())\nn,I=R()\na=sorted(R())\nb=[0]+[i+1for i in range(n-1)if a[i](I*8)\/\/n:\n\n maxK=2**((I*8)\/\/n)\n needMin=nowK-maxK\n \n minChange=0\n \n for i in range(needMin):\n minChange+=dic[disLis[i]]\n \n befChange=minChange\n \n for i in range(1,needMin+1):\n befChange=befChange-dic[disLis[needMin-i]]+dic[disLis[-i]]\n if befChange= n*round(math.log(n,2)+0.5)\/8:\n print(0)\nelse:\n a = sorted([x for x in map(int, input().split())])\n a=[-1]+a\n b=[i for i in range(n) if a[i] < a[i+1]]\n ans = set()\n for x in zip(b, b[2**(I*8\/\/n):]+[n]):\n ans.add(x[1]-x[0])\n print(n-max(ans))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e4a007f6c747bd159cbc","document_content":"n,i=list(map(int,input().split()))\nk=2**(8*i\/\/n) if 8*i\/\/n < 20 else n\na=[int(x) for x in input().split()]\na.sort()\nfreq = [1]\nfor i in range(1, len(a)):\n\tif a[i-1] == a[i]:\n\t\tfreq[-1] += 1\n\telse:\n\t\tfreq.append(1)\nwindow = sum(freq[:k])\nans = window\nfor i in range(k, len(freq)):\n\twindow += freq[i]\n\twindow -= freq[i-k]\n\tans = max(ans, window)\n\nprint(n-ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"520455b4281a3057eae6","document_content":"import math\n\nn, m = list(map(int, input().split()))\nlst = list(map(int, input().split()))\n\nlst.sort()\nlast_val = -1\nfreq_list = []\n\nfor i in range(n):\n\tif lst[i] != last_val:\n\t\tlast_val = lst[i]\n\t\tfreq_list.append(1)\n\telse:\n\t\tfreq_list[-1] += 1\n\nk = len(freq_list)\n\nfor i in range(k, 0, -1):\n\tif n * math.ceil(math.log2(i)) <= m * 8:\n\t\tk = i\n\t\tbreak\n\nmx = 0\ntot = sum(freq_list[:k])\nmx = max(tot, mx)\nfor i in range(k, len(freq_list)):\n\ttot = tot + freq_list[i] - freq_list[i-k]\n\tmx = max(mx, tot)\n\nprint(n-mx)\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"296fea8f5efb49d85a47","document_content":"from itertools import groupby\n\n\ndef mp3(n, I, a):\n k = int((I * 8) \/ n)\n d = 1 << k\n c = [len(list(group)) for (key, group) in groupby(sorted(a))]\n chgs = sum(c[d:])\n ans = chgs\n for i in range(0, len(c) - d):\n chgs += c[i]\n chgs -= c[i + d]\n ans = min(ans, chgs)\n return ans\n\n\ndef __starting_point():\n nn, II = list(map(int, input().split()))\n aa = list(map(int, input().split()))\n print(mp3(nn, II, aa))\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"eb7f9cc43bfbf83a9e74","document_content":"from sys import stdin, stdout\n\nn = int(stdin.readline())\ns = stdin.readline().strip()\n\nmins = []\npacks = []\n\nfor i in range(len(s)):\n if s[i] == '*':\n mins.append(i)\n elif s[i] == 'P':\n packs.append(i)\n\nl, r = -1, 2 * len(s) + 1\nwhile r - l > 1:\n m = (l + r) >> 1\n \n test1 = mins[:]\n test2 = packs[:]\n \n \n while test2 and test1:\n cnt = m\n pos = test2.pop()\n \n if pos > test1[-1]:\n while test1 and abs(pos - test1[-1]) <= cnt:\n cnt -= abs(pos - test1[-1])\n pos = test1[-1]\n test1.pop()\n else:\n cntl, cntr = 0, 0\n \n if abs(test1[-1] - pos) > m:\n break\n \n lpos = (m + pos - test1[-1]) \/\/ 2\n rpos = m - 2 * abs(test1[-1] - pos)\n \n lb, rb = -1, len(test1)\n while rb - lb > 1:\n mb = (lb + rb) >> 1\n \n if pos - test1[mb] <= lpos:\n rb = mb\n else:\n lb = mb\n \n cntl = len(test1) - rb\n \n lb, rb = -1, len(test1)\n while rb - lb > 1:\n mb = (lb + rb) >> 1\n \n if pos - test1[mb] <= rpos:\n rb = mb\n else:\n lb = mb\n \n cntr = len(test1) - rb\n \n cnt = max(cntl, cntr)\n while test1 and cnt:\n test1.pop()\n cnt -= 1\n \n \n if not test1:\n r = m\n else:\n l = m\n \nstdout.write(str(r))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"386cd2945fb8480c5249","document_content":"import bisect\n\nn = int(input())\ns = input()\npackmans = []\nstars = []\nfor i in range(n):\n if s[i] == '*':\n stars.append(i)\n elif s[i] == 'P':\n packmans.append(i)\n\nif len(stars) == 0:\n print(0)\n return\n\n\ndef check(t):\n first_to_eat = 0\n for i in range(len(packmans)):\n x = stars[first_to_eat]\n if packmans[i] > x:\n if packmans[i] - x > t:\n return False\n d1 = t - 2 * (packmans[i] - x)\n d2 = (t - (packmans[i] - x)) \/\/ 2\n first_to_eat = bisect.bisect_right(stars, packmans[i] + max(d1, d2))\n if first_to_eat < len(stars) and stars[first_to_eat] == packmans[i] + max(d1, d2):\n first_to_eat += 1\n\n else:\n j = bisect.bisect_right(stars, packmans[i] + t)\n if first_to_eat < len(stars) and stars[first_to_eat] == packmans[i] + t:\n first_to_eat += 1\n first_to_eat = max(j, first_to_eat)\n if first_to_eat >= len(stars):\n return True\n return first_to_eat >= len(stars)\n\n\nl = 0\nr = 2 * n + 1\n\nwhile r - l > 1:\n m = (l + r) \/\/ 2\n if check(m):\n r = m\n else:\n l = m\nprint(r)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d46798efbf1685a349ba","document_content":"n, k = list(map(int, input().split()))\nm = 0x3b9aca07\nv = 500000004\nr = 0\np = pow(2, n, m)\na = [1] + [0] * k\nfor i in range(k):\n for j in range(i, -1, -1):\n a[j + 1] += a[j]\n a[j] = a[j] * j % m\nfor i in range(k + 1):\n r = (r + p * a[i]) % m\n p = p * v * (n - i) % m\nprint(r)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bfa612709a07e25198bb","document_content":"n, k = map(int, input().split())\nm = int(1e9 + 7)\nr = 0\np = pow(2, n, m)\na = [1] + [0] * k\nfor i in range(k):\n for j in range(i, -1, -1):\n a[j + 1] += a[j]\n a[j] = a[j] * j % m\nfor i in range(k + 1):\n r = (r + p * a[i]) % m\n p = p * 500000004 * (n - i) % m\nprint(r)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e734e16ae34bbf9393aa","document_content":"n, k = map(int, input().split())\nm = 0x3b9aca07\nr = 0\np = pow(2, n, m)\na = [1] + [0] * k\nfor i in range(k):\n for j in range(i, -1, -1):\n a[j + 1] += a[j]\n a[j] = a[j] * j % m\nfor i in range(k + 1):\n r = (r + p * a[i]) % m\n p = p * 500000004 * (n - i) % m\nprint(r)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"77a9f8efc2be94949796","document_content":"n, k = map(int, input().split())\nm = 0x3b9aca07\nr = 0\np = pow(2, n, m)\na = [1] + [0] * k\nfor i in range(k):\n for j in range(i, -1, -1):\n a[j + 1] += a[j]\n a[j] = a[j] * j % m\nfor i in range(k + 1):\n r += p * a[i]\n p = p * 500000004 * (n - i) % m\nprint(r % m)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7a44459d1d927f5cbb93","document_content":"n, k = map(int, input().split())\nm = int(1e9+7)\nr = 0\np = pow(2, n, m)\na = [1] + [0] * k\nfor i in range(k):\n for j in range(i, -1, -1):\n a[j+1] += a[j]\n a[j] = a[j]*j % m\nfor i in range(k + 1):\n r += p*a[i]\n p = p*500000004*(n - i) % m\nprint(r % m)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e70a0b1db6c9c1437bc6","document_content":"from collections import deque\nn = int(input())\ngraph = [[] for i in range(n + 1)]\nfor _ in range(n - 1):\n i, j = map(int, input().split())\n graph[i].append(j)\n graph[j].append(i)\nmod = 10 ** 9 + 7\n\ndef bfs(x):\n q = deque([(0, x, 0)])\n dist = {x: 0}\n while q:\n step, i, par = q.popleft()\n dist[i] = step\n for j in graph[i]:\n if j == par: continue\n q.append((step + 1, j, i))\n return [step, i, dist]\n\n_, black, _ = bfs(1)\nmaxdist, white, b_dist = bfs(black)\n_, _, w_dist = bfs(white)\n\nmindls = float(\"-inf\")\nmaxdls = [0] * n\nfor i in range(1, n + 1):\n if i in (white, black):\n continue\n mindls = max(mindls, min(w_dist[i], b_dist[i]))\n maxdls[max(w_dist[i], b_dist[i])] += 1\nans = pow(2, n - 1, mod) * maxdist % mod\npre = 0\nfor i in range(1, maxdist + 1):\n if i == maxdist and not maxdls[i]: continue\n maxdls[i] += maxdls[i - 1]\n if mindls > i: continue\n ans += (pow(2, maxdls[i], mod) - pre) * i * 2\n ans %= mod\n pre = pow(2, maxdls[i], mod)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f771721b835de710aff8","document_content":"\nMOD = 10**9+7\nfrom collections import deque\nN, = list(map(int, input().split()))\nG = [set() for _ in range(N+1)]\nfor _ in range(N-1):\n a, b = list(map(int, input().split()))\n G[a].add(b)\n G[b].add(a)\n\nqueue=deque([1])\nvs = set([1])\ndist = [0] * (N+1)\nmx = 0\nmxv = 1\nwhile queue:\n v = queue.popleft()\n for u in G[v]:\n if u in vs:\n continue\n vs.add(u)\n queue.append(u)\n dist[u] = dist[v] + 1\n if mx < dist[u]:\n mx = dist[u]\n mxv = u\n\nqueue=deque([mxv])\nvs = set([mxv])\ndist2 = [0] * (N+1)\nmx2 = 0\nmxv2 = 1\nwhile queue:\n v = queue.popleft()\n for u in G[v]:\n if u in vs:\n continue\n vs.add(u)\n queue.append(u)\n dist2[u] = dist2[v] + 1\n if mx2 < dist2[u]:\n mx2 = dist2[u]\n mxv2 = u\n\nqueue=deque([mxv2])\nvs = set([mxv2])\ndist3 = [0] * (N+1)\nwhile queue:\n v = queue.popleft()\n for u in G[v]:\n if u in vs:\n continue\n vs.add(u)\n queue.append(u)\n dist3[u] = dist3[v] + 1\n#print(mxv, mxv2)\n#print(dist2)\n#print(dist3)\nr = 0\nfor i in range(1, N+1):\n x = min(dist2[i], dist3[i])\n r = max(x, r)\n# \u7d76\u5bfe\u306b\u826f\u3055\u306fr\u4ee5\u4e0a\u306b\u306a\u308b\n#\u3000\u306a\u305c\u306a\u3089x = r\u3068\u306a\u308b\u30ce\u30fc\u30c9\u3092\u3069\u3061\u3089\u306e\u8272\u306b\u5857\u3063\u3066\u3082\u3001\u826f\u3055\u306fr\u306b\u6c7a\u307e\u308b\u304b\u3089...\n\nX = [0]*(N+1)\nfor i in range(1, N+1):\n y = max(dist2[i], dist3[i])\n X[y] += 1\n\n#print(r)\nfor i in range(N-1, r-1, -1):\n X[i] = X[i] + X[i+1]\n\n#print(X)\n# d[i] = d\u304ci\u4ee5\u4e0b\u306b\u306a\u308b\u5834\u5408\u306e\u6570\nX.append(0)\nd = [0]*(N+1)\nfor i in range(N, r-1, -1):\n x = min(N-X[i+1]+1, N)\n d[i] = pow(2, x, MOD) \n#print(d)\n\nR = 0\nfor i in range(r, N+1):\n R = (R + i*(d[i]-d[i-1]))%MOD\nprint(R)\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bb07a82f7c4e649a8a5e","document_content":"import sys\ninput = lambda: sys.stdin.readline().rstrip()\n\nfrom collections import deque\nN = int(input())\nX = [[] for _ in range(N)]\nfor _ in range(N-1):\n a, b = map(int, input().split())\n X[a-1].append(b-1)\n X[b-1].append(a-1)\n\ndef farthest(i):\n L = [-1] * N\n L[i] = 0\n d = 0\n post = [i]\n while len(post) > 0:\n d += 1\n pre = post\n post = []\n for j in pre:\n for k in X[j]:\n if L[k] < 0:\n L[k] = d\n post.append(k)\n \n return (pre[0], d - 1)\n\ns, _ = farthest(0)\nt, d = farthest(s)\n\ndef BFS_dist(n, E, i0=0):\n Q = deque([i0])\n D = [-1] * n\n D[i0] = 0\n while Q:\n x = Q.popleft()\n for c in E[x]:\n if D[c] == -1:\n D[c] = D[x] + 1\n Q.append(c)\n return D\n\nD1 = BFS_dist(N, X, s)\nD2 = BFS_dist(N, X, t)\n\nY = [0] * (d + 1)\nma = 0\nfor i in range(N):\n if i == s or i == t: continue\n a, b = sorted((D1[i], D2[i]))\n ma = max(ma, a)\n Y[b] += 1\nY[d] += 1\n\nP = 10 ** 9 + 7\ni2 = P + 1 >> 1\ns = 1\nans = d\nfor i in range(d, ma, -1):\n if Y[i]: s = pow(i2, Y[i], P) * s % P\n ans -= s\n if ans < 0: ans += P\nprint(ans * pow(2, N, P) % P)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3df2e3360f342100d005","document_content":"n = int(input())\nab = [list(map(int,input().split())) for i in range(n-1)]\ngraph = [[] for i in range(n+1)]\nfor a,b in ab:\n graph[a].append(b)\n graph[b].append(a)\nmod = 10**9+7\nstart = 1\nstack = [1]\ns_dist = [0]+[0]+[10**9]*(n-1)\nwhile stack:\n x = stack.pop()\n for y in graph[x]:\n if s_dist[y] > s_dist[x]:\n s_dist[y] = s_dist[x]+1\n stack.append(y)\nmaxdist = max(s_dist)\nblack = s_dist.index(maxdist)\nb_dist = [10**9]*(n+1)\nb_dist[0] = 0\nb_dist[black] = 0\nstack = [black]\nwhile stack:\n x = stack.pop()\n for y in graph[x]:\n if b_dist[y] > b_dist[x]:\n b_dist[y] = b_dist[x]+1\n stack.append(y)\nmaxdist = max(b_dist)\nwhite = b_dist.index(maxdist)\nw_dist = [10**9]*(n+1)\nw_dist[0] = 0\nw_dist[white] = 0\nstack = [white]\nwhile stack:\n x = stack.pop()\n for y in graph[x]:\n if w_dist[y] > w_dist[x]:\n w_dist[y] = w_dist[x]+1\n stack.append(y)\nmindls = [0]*n\nmaxdls = [0]*n\nfor i in range(1,n+1):\n if i in (white,black):\n continue\n mindls[min(w_dist[i],b_dist[i])] += 1\n maxdls[max(w_dist[i],b_dist[i])] += 1\nans = pow(2,n-1,mod)*maxdist%mod\nnumber = 0\nfor i in range(1,maxdist+1):\n if i == maxdist and maxdls[i] == 0:\n continue\n maxdls[i] += maxdls[i-1]\n if i < maxdist and mindls[i+1]:\n continue\n ans += (pow(2,maxdls[i],mod)-number)*i*2\n ans %= mod\n number = pow(2,maxdls[i],mod)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cbc019f79608205c1bf4","document_content":"n = int(input())\ngraph = [[] for i in range(n + 1)]\nfor _ in range(n - 1):\n i, j = map(int, input().split())\n graph[i].append(j)\n graph[j].append(i)\nmod = 10 ** 9 + 7\nstart = 1\nstack = [1]\ns_dist = [0]+[0]+[10**9]*(n-1)\nwhile stack:\n x = stack.pop()\n for y in graph[x]:\n if s_dist[y] > s_dist[x] + 1:\n s_dist[y] = s_dist[x]+1\n stack.append(y)\nmaxdist = max(s_dist)\nblack = s_dist.index(maxdist)\nb_dist = [10**9]*(n+1)\nb_dist[0] = 0\nb_dist[black] = 0\nstack = [black]\nwhile stack:\n x = stack.pop()\n for y in graph[x]:\n if b_dist[y] > b_dist[x] + 1:\n b_dist[y] = b_dist[x]+1\n stack.append(y)\nmaxdist = max(b_dist)\nwhite = b_dist.index(maxdist)\nw_dist = [10**9]*(n+1)\nw_dist[0] = 0\nw_dist[white] = 0\nstack = [white]\nwhile stack:\n x = stack.pop()\n for y in graph[x]:\n if w_dist[y] > w_dist[x] + 1:\n w_dist[y] = w_dist[x]+1\n stack.append(y)\nmindls = [0]*n\nmaxdls = [0]*n\nfor i in range(1,n+1):\n if i in (white,black):\n continue\n mindls[min(w_dist[i],b_dist[i])] += 1\n maxdls[max(w_dist[i],b_dist[i])] += 1\nans = pow(2,n-1,mod)*maxdist%mod\nnumber = 0\nfor i in range(1,maxdist+1):\n if i == maxdist and maxdls[i] == 0:\n continue\n maxdls[i] += maxdls[i-1]\n if i < maxdist and mindls[i+1]:\n continue\n ans += (pow(2,maxdls[i],mod)-number)*i*2\n ans %= mod\n number = pow(2,maxdls[i],mod)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b106f85126ed7a9109ed","document_content":"from collections import deque, defaultdict\n\n\ndef diameter(n, links):\n q = deque([0])\n stacked = {0}\n v = -1\n while q:\n v = q.popleft()\n for u in links[v]:\n if u not in stacked:\n q.append(u)\n stacked.add(u)\n v1 = v\n q = deque([(0, v1)])\n distances1 = [-1] * n\n distances1[v1] = 0\n while q:\n d, v = q.popleft()\n for u in links[v]:\n if distances1[u] == -1:\n q.append((d + 1, u))\n distances1[u] = d + 1\n v2 = v\n q = deque([(0, v2)])\n distances2 = [-1] * n\n distances2[v2] = 0\n while q:\n d, v = q.popleft()\n for u in links[v]:\n if distances2[u] == -1:\n q.append((d + 1, u))\n distances2[u] = d + 1\n return v1, v2, distances1, distances2\n\n\ndef solve(n, links):\n MOD = 10 ** 9 + 7\n v1, v2, distances1, distances2 = diameter(n, links)\n\n ans = distances1[v2] * pow(2, n - 2, MOD) % MOD\n\n farther = defaultdict(lambda: [0, 0])\n for i in range(n):\n if i == v1 or i == v2:\n continue\n d1 = distances1[i]\n d2 = distances2[i]\n mx = max(d1, d2)\n mn = min(d1, d2)\n farther[mx][0] += 1\n farther[mx][1] = max(farther[mx][1], mn)\n\n # print(v1, v2)\n # print(distances1)\n # print(distances2)\n # print(farther)\n\n m = n - 2\n max_smaller_d = 0\n for d in sorted(list(farther.keys()), reverse=True):\n if d <= max_smaller_d:\n ans = (ans + max_smaller_d * pow(2, m, MOD)) % MOD\n break\n cnt, mn = farther[d]\n m -= cnt\n ans = (ans + d * (pow(2, cnt, MOD) - 1) * pow(2, m, MOD)) % MOD\n max_smaller_d = max(max_smaller_d, mn)\n else:\n ans = (ans + max_smaller_d * pow(2, m, MOD)) % MOD\n\n return ans * 2 % MOD\n\n\nn = int(input())\nlinks = [set() for _ in range(n)]\nfor _ in range(n - 1):\n a, b = list(map(int, input().split()))\n a -= 1\n b -= 1\n links[a].add(b)\n links[b].add(a)\n\nprint((solve(n, links)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a5fe1be388fcc75154ce","document_content":"from collections import deque\nn = int(input())\ngraph = [[] for i in range(n + 1)]\nfor _ in range(n - 1):\n i, j = map(int, input().split())\n graph[i].append(j)\n graph[j].append(i)\nmod = 10 ** 9 + 7\n\ndef bfs(x):\n q = deque([(0, x, 0)])\n while q:\n step, i, par = q.popleft()\n for j in graph[i]:\n if j == par: continue\n q.append((step + 1, j, i))\n return [step, i]\n\nmaxdist, black = bfs(1)\n\nb_dist = [10**9]*(n+1)\nb_dist[0] = 0\nb_dist[black] = 0\nstack = [black]\nwhile stack:\n x = stack.pop()\n for y in graph[x]:\n if b_dist[y] > b_dist[x] + 1:\n b_dist[y] = b_dist[x]+1\n stack.append(y)\nmaxdist = max(b_dist)\nwhite = b_dist.index(maxdist)\nw_dist = [10**9]*(n+1)\nw_dist[0] = 0\nw_dist[white] = 0\nstack = [white]\nwhile stack:\n x = stack.pop()\n for y in graph[x]:\n if w_dist[y] > w_dist[x] + 1:\n w_dist[y] = w_dist[x]+1\n stack.append(y)\nmindls = [0]*n\nmaxdls = [0]*n\nfor i in range(1,n+1):\n if i in (white,black):\n continue\n mindls[min(w_dist[i],b_dist[i])] += 1\n maxdls[max(w_dist[i],b_dist[i])] += 1\nans = pow(2,n-1,mod)*maxdist%mod\nnumber = 0\nfor i in range(1,maxdist+1):\n if i == maxdist and maxdls[i] == 0:\n continue\n maxdls[i] += maxdls[i-1]\n if i < maxdist and mindls[i+1]:\n continue\n ans += (pow(2,maxdls[i],mod)-number)*i*2\n ans %= mod\n number = pow(2,maxdls[i],mod)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2e691e29a96c575a383a","document_content":"import sys\ninput = sys.stdin.readline\nfrom collections import Counter\n\nN=int(input())\nE=[[] for i in range(N)]\nfor i in range(N-1):\n x,y=map(int,input().split())\n x-=1\n y-=1\n E[x].append(y)\n E[y].append(x)\n\nmod=10**9+7\n\ndef dfs(x):\n DIS=[-1]*N\n DIS[x]=0\n Q=[x]\n\n while Q:\n x=Q.pop()\n for to in E[x]:\n if DIS[to]==-1:\n DIS[to]=DIS[x]+1\n Q.append(to)\n return DIS\n\nD0=dfs(0)\nL=D0.index(max(D0))\nDL=dfs(L)\nR=DL.index(max(DL))\nDR=dfs(R)\n\nMIN=[min(DL[i],DR[i]) for i in range(N)]\nMAX=[max(DL[i],DR[i]) for i in range(N)]\nC=Counter(MIN)\n\nhalf=pow(2,mod-2,mod)%mod\nALL=pow(2,N,mod)\nANS=max(DR)*ALL*half%mod\n\nMAX.sort()\n\ndind=0\nANS=(ANS+max(MIN)*ALL*half)%mod\n\nfor d in range(max(MIN)+1,max(DR)+1):\n while dind= s_dist[x]:\n s_dist[y] = s_dist[x]+1\n stack.append(y)\nmaxdist = max(s_dist)\nblack = s_dist.index(maxdist)\nb_dist = [10**9]*(n+1)\nb_dist[0] = 0\nb_dist[black] = 0\nstack = [black]\nwhile stack:\n x = stack.pop()\n for y in graph[x]:\n if b_dist[y] >= b_dist[x]:\n b_dist[y] = b_dist[x]+1\n stack.append(y)\nmaxdist = max(b_dist)\nwhite = b_dist.index(maxdist)\nw_dist = [10**9]*(n+1)\nw_dist[0] = 0\nw_dist[white] = 0\nstack = [white]\nwhile stack:\n x = stack.pop()\n for y in graph[x]:\n if w_dist[y] >= w_dist[x]:\n w_dist[y] = w_dist[x]+1\n stack.append(y)\nmindls = [0]*n\nmaxdls = [0]*n\nfor i in range(1,n+1):\n if i in (white,black):\n continue\n mindls[min(w_dist[i],b_dist[i])] += 1\n maxdls[max(w_dist[i],b_dist[i])] += 1\nans = pow(2,n-1,mod)*maxdist%mod\nnumber = 0\nfor i in range(1,maxdist+1):\n if i == maxdist and maxdls[i] == 0:\n continue\n maxdls[i] += maxdls[i-1]\n if i < maxdist and mindls[i+1]:\n continue\n ans += (pow(2,maxdls[i],mod)-number)*i*2\n ans %= mod\n number = pow(2,maxdls[i],mod)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2b5fc485f1cb1f86f86f","document_content":"from collections import deque\nn = int(input())\ngraph = [[] for i in range(n + 1)]\nfor _ in range(n - 1):\n i, j = map(int, input().split())\n graph[i].append(j)\n graph[j].append(i)\nmod = 10 ** 9 + 7\n\ndef bfs(x):\n q = deque([(0, x, 0)])\n dist = {x: 0}\n while q:\n step, i, par = q.popleft()\n dist[i] = step\n for j in graph[i]:\n if j == par: continue\n q.append((step + 1, j, i))\n return [step, i, dist]\n\n_, black, _ = bfs(1)\nmaxdist, white, b_dist = bfs(black)\n_, _, w_dist = bfs(white)\n\nmindls = float(\"-inf\")\nmaxdls = [0] * n\nfor i in range(1, n + 1):\n if i in (white, black):\n continue\n mindls = max(mindls, min(w_dist[i], b_dist[i]))\n maxdls[max(w_dist[i], b_dist[i])] += 1\nans = pow(2, n - 1, mod) * maxdist % mod\npre = 0\nfor i in range(1, maxdist + 1):\n if i == maxdist and maxdls[i] == 0:\n continue\n maxdls[i] += maxdls[i - 1]\n if mindls > i:\n continue\n ans += (pow(2, maxdls[i], mod) - pre) * i * 2\n ans %= mod\n pre = pow(2, maxdls[i], mod)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7095f82ed29d04b63fcb","document_content":"N=int(input())\nE=[[] for i in range(N)]\nfor i in range(N-1):\n x,y=map(int,input().split())\n x-=1\n y-=1\n E[x].append(y)\n E[y].append(x)\n\nmod=10**9+7\n\ndef dfs(x):\n DIS=[-1]*N\n DIS[x]=0\n Q=[x]\n\n while Q:\n x=Q.pop()\n for to in E[x]:\n if DIS[to]==-1:\n DIS[to]=DIS[x]+1\n Q.append(to)\n return DIS\n\nD0=dfs(0)\nL=D0.index(max(D0))\nDL=dfs(L)\nR=DL.index(max(DL))\nDR=dfs(R)\n\nMIN=[min(DL[i],DR[i]) for i in range(N)]\nMAX=[max(DL[i],DR[i]) for i in range(N)]\n\nhalf=pow(2,mod-2,mod)%mod\nALL=pow(2,N-1,mod)\nANS=max(DR)*ALL%mod\n\nMAX.sort()\n\ndind=0\nANS=(ANS+max(MIN)*ALL)%mod\n\nfor d in range(max(MIN)+1,max(DR)+1):\n while dind 0:\n now = q.popleft()\n\n for nex in lis[now]:\n\n if ret[nex] > ret[now] + 1:\n ret[nex] = ret[now] + 1\n plis[nex] = now\n q.append(nex)\n\n return ret,plis\n\nmod = 10**9+7\n\nN = int(stdin.readline())\n\nlis = [ [] for i in range(N) ]\n\nfor i in range(N-1):\n a,b = list(map(int,stdin.readline().split()))\n a -= 1\n b -= 1\n lis[a].append(b)\n lis[b].append(a)\n\nD0,tmp = NC_Dij(lis,0)\np1 = 0\nfor i in range(N):\n if D0[i] > D0[p1]:\n p1 = i\n\nD1,tmp = NC_Dij(lis,p1)\np2 = p1\nfor i in range(N):\n if D1[i] > D1[p2]:\n p2 = i\n\nD2,tmp = NC_Dij(lis,p2)\n\nDL1 = []\nfor i in range(N):\n DL1.append( (D1[i],i) )\nDL2 = []\nfor i in range(N):\n DL2.append( (D2[i],i) )\n\nDL1.sort()\nDL1.reverse()\nDL2.sort()\nDL2.reverse()\n\n\nanslis = [0] * N\nvisit = [0] * N\ntwo = 0\nzero = N\nfor X in range(N):\n\n while len(DL1) > 0 and DL1[-1][0] == X:\n tmp,v = DL1[-1]\n del DL1[-1]\n\n if visit[v] == 0:\n zero -= 1\n elif visit[v] == 1:\n two += 1\n visit[v] += 1\n\n while len(DL2) > 0 and DL2[-1][0] == X:\n tmp,v = DL2[-1]\n del DL2[-1]\n\n if visit[v] == 0:\n zero -= 1\n elif visit[v] == 1:\n two += 1\n visit[v] += 1\n\n if two == N:\n anslis[X] = pow(2,N,mod)\n elif zero == 0:\n anslis[X] = 2 * pow(2,two,mod)\n\nans = 0\nfor i in range(1,N):\n ans += (anslis[i]-anslis[i-1]) * i\nprint((ans % mod))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e9d595bf3f2b701fb2e5","document_content":"n,k=list(map(int,input().split()))\nM=10**9+7\nprint(k**~-k*pow(n-k,n-k,M)%M)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"29c40ea7bc2111e3271d","document_content":"n,k=list(map(int,input().split()));n-=k;print(k**~-k*n**n%(10**9+7))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8af49a065911cfd6f4a1","document_content":"n, k = map(int, input().split())\nd = 1000000007\ndef f(a, b):\n if b == 0: return 1\n s, c = 0, b * a\n for i in range(1, b + 1):\n s += c * f(i, b - i)\n c = (a * c * (b - i)) \/\/ (i + 1)\n return s\nprint(k * f(1, k - 1) * pow(n - k, n - k, d) % d) ","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bff4a92d7761c2963886","document_content":"n, k = map(int, input().split())\nd = 1000000007\nprint(pow(k, k - 1, d) * pow(n - k, n - k, d) % d)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"040439b217c2bcd81e46","document_content":"MOD = 10 ** 9 + 7\nn, k = map(int, input().split())\nans = pow(n - k, n - k, MOD) * pow(k, k - 1, MOD)\nprint(ans % MOD)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bfed360958da6893d35d","document_content":"#cf288b.py\nimport sys\n(n,k)=list(map(int,sys.stdin.readline().split()))\nmod_prime=1000000007\nf=[0]*(k+2)\n#f(x)= the number of ways that a group of x elements eventually leads to 1 (1 is not part of the group and does not points to anywhere)\nf[0]=1\nf[1]=1\nc=[[1 for j in range(i+1)] for i in range (k)]\nfor i in range(1,len(c)):\n\tfor j in range(1,len(c[i])-1):\n\t\tc[i][j]=(c[i-1][j-1]+c[i-1][j])%mod_prime\n#print (c)\nfor x in range(2,k):\n\tf[x]=0\n\tfor i in range(0,x):\n\t\tf[x]+=c[x-1][i]*f[i]*f[x-1-i]*(i+1)%mod_prime\n\t\t#print(\"x={0},i={1},f[x]={2}\".format(x,i,f[x]))\n\nans=(k*f[k-1]*(n-k)**(n-k))%mod_prime\n#print(f)\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1fc26f070af79dca997b","document_content":"(n, k), mod = list(map(int, input().split())), 1000000007\nprint((k**(k-1)%mod)*((n-k)**(n-k)%mod)%mod)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d554487e894eedcd2ec3","document_content":"inp = input().split(' ')\nn = int(inp[0])\nk = int(inp[1])\nprint(k**(k-1)*(n-k)**(n-k) % 1000000007)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d200ce608050d88ee9c4","document_content":"n,k=map(int,input().split())\nn-=k\nprint(k**(k-1)*n**n%1000000007)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2fb16da019b9d1cb4919","document_content":"n, k = map(int, input().split())\nmod = 1000000007\nprint(pow(k, k-1, mod) * pow(n-k, n-k, mod) % mod)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c7abcaa37cfc18789b9f","document_content":"n,k=list(map(int,input().split()));n-=k;print(k**~-k*n**n%(10**9+7))\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2a30726636ad0fb50a27","document_content":"a=list(map(int,input().split()))\nn=a[0]\nk=a[1]\nrem=n-k\npans=(rem**rem)%1000000007\nrem1=n-rem-1\npans1=((rem1+1)**rem1)%1000000007\nans=(pans*pans1)%1000000007\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cf78c30bfccbfd293ea6","document_content":"n,k = list(map(int,input().split()))\nmod = 10 ** 9 + 7\nprint(pow(k, k - 1, mod) * pow(n - k, n - k, mod) % mod)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6eb9edde44cb76477ea7","document_content":"n,k=list(map(int,input().split()));n-=k;print(k**~-k*n**n%(10**9+7))\n\n\n\n\n# Made By Mostafa_Khaled\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"39e92f33200693bca6d8","document_content":"n, k = map(int, input().split())\nm = 1000000007\nprint(pow(k, k - 1, m) * pow(n - k, n - k, m) % m)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"92ed578b0bf1e128bf94","document_content":"n,k = list(map(int,input().split()))\nprint(((k**(k-1))*((n-k)**(n-k)))%((10**9)+7))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"748da3212c9964ab0b84","document_content":"n,k = list(map(int,input().split()))\n\nm = 1000000007\n\nprint((pow(k,k-1,m)*pow(n-k,n-k,m))%m)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d95c9bf6d603b08b3765","document_content":"import sys\nfrom collections import defaultdict\n\nclass MaxFlow(object):\n def __init__(self):\n self.edges = defaultdict(lambda: defaultdict(lambda: 0))\n\n def add_edge(self, u, v, capacity=float('inf')):\n self.edges[u][v] = capacity\n\n def bfs(self, s, t):\n open_q = [s]\n\n visited = set()\n parent = dict()\n while open_q:\n close_q = []\n for node in open_q:\n for v, capacity in list(self.edges[node].items()):\n if v not in visited and capacity > 0:\n close_q.append(v)\n parent[v] = node\n visited.add(v)\n if v == t:\n result = []\n n2 = v\n n1 = node\n while n1 != s:\n result.append((n1, n2))\n n2 = n1\n n1 = parent[n1]\n result.append((n1, n2))\n return result\n\n open_q = close_q\n\n return None\n\n def solve(self, s, t):\n flow = 0\n route = self.bfs(s, t)\n while route is not None:\n new_flow = float('inf')\n for _, (n1, n2) in enumerate(route):\n new_flow = min(new_flow, self.edges[n1][n2])\n for _, (n1, n2) in enumerate(route):\n self.edges[n1][n2] -= new_flow\n self.edges[n2][n1] += new_flow\n flow += new_flow\n\n route = self.bfs(s, t)\n\n return flow\n\n def __str__(self):\n result = \"{ \"\n for k, v in list(self.edges.items()):\n result += str(k) + \":\" + str(dict(v)) + \", \"\n result += \"}\"\n return result\n\n\ndef main():\n (n, m) = tuple([int(x) for x in input().split()])\n r = []\n xs = set()\n ys = set()\n for i in range(m):\n (x1, y1, x2, y2) = tuple(int(x) for x in input().split())\n r.append((x1, y1, x2, y2))\n xs.add(x1)\n xs.add(x2 + 1)\n ys.add(y1)\n ys.add(y2 + 1)\n\n xx = sorted(xs)\n yy = sorted(ys)\n xsize = len(xs)\n ysize = len(ys)\n grid = []\n for i in range(ysize):\n grid.append([False] * xsize)\n\n for rect in r:\n x1 = rect[0]\n y1 = rect[1]\n x2 = rect[2]\n y2 = rect[3]\n for i, y in enumerate(yy):\n for j, x in enumerate(xx):\n if x1 <= x and y1 <= y and x2 >= x and y2 >= y:\n grid[i][j] = True\n\n f = MaxFlow()\n for i in range(len(yy)):\n for j in range(len(xx)):\n if grid[i][j]:\n f.add_edge(1 + i, len(yy) + 1 + j, float('inf'))\n for i in range(len(yy) - 1):\n f.add_edge(0, i + 1, yy[i + 1] - yy[i])\n for i in range(len(xx) - 1):\n f.add_edge(len(yy) + 1 + i, len(xx) + len(yy) + 1, xx[i + 1] - xx[i])\n\n # print(xx)\n # print(yy)\n # print(f)\n print(f.solve(0, len(xx) + len(yy) + 1))\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"973e58b91bdf1f74d4ee","document_content":"a,b=[int(i) for i in input().split()]\nif(a==0):\n print(-b**2)\n print('x'*b)\nelif(b==0):\n print(a**2)\n print('o'*a)\nelif(b==1):\n print(a**2-1)\n print('x'+'o'*a)\nelse:\n ans=-float('inf')\n gr_no=None\n for i in range(2,min(a+2,b+1)):\n v1=(a+2-i)**2 + i-2\n quo=b\/\/i\n rem=b%i\n v2=rem*((quo+1)**2) + (i-rem)*((quo**2))\n if(v1-v2>ans):\n gr_no=i\n ans=v1-v2\n quo=b\/\/gr_no\n rem=b%gr_no\n if(rem>0):\n s='x'*(quo+1)+'o'*(a+2-gr_no)\n rem-=1\n else:\n s='x'*(quo)+'o'*(a+2-gr_no)\n gr_no-=1\n s1='x'*(quo+1)+'o'\n s2='x'*quo + 'o'\n for i in range(rem):\n s+=s1\n for i in range(gr_no-rem-1):\n s+=s2\n s+='x'*(quo)\n print(ans)\n print(s)\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"387ae2bbde79c5baa735","document_content":"import itertools\nimport bisect\n\nn, x = map(int, input().split())\nl = list(map(int, input().split()))\n\na = list(itertools.accumulate(l, initial=0))\nprint(bisect.bisect_right(a, x))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c2a5dac037b099dcafd3","document_content":"n,x=list(map(int, input().split()))\n\nl_list=[int(i) for i in input().split()]\n\nd=0\ncount=1\nfor i in range(n):\n d=d+l_list[i]\n if d<=x:\n count+=1\n\nprint(count)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e0c33758bb5b4df8d317","document_content":"n, x = map(int, input().split())\n\nl = list(map(int, input().split()))\n\n\nans = 0\n\nd = 0\n\nfor i in range(n):\n if d <= x:\n ans += 1\n d += l[i]\n\nif d <= x:\n ans += 1\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6044644dcc03f8e967c2","document_content":"import bisect\nfrom itertools import accumulate\nN, X = list(map(int, input().split()))\nL = list(map(int, input().split()))\nLsum = list(accumulate(L))\nind = bisect.bisect_right(Lsum, X)\nprint((ind+1))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3db0c3a96d16e75f039f","document_content":"import bisect\nn, x = map(int, input().split())\nl = [0] + list(map(int, input().split()))\nfor i in range(n):\n l[i+1] += l[i]\nprint(bisect.bisect_left(l, x+1))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ca9781b3dc892cd656df","document_content":"N,X=list(map(int,input().split()))\nL=list(map(int,input().split()))\nx=0\nans=1\nfor i in range(N):\n x+=L[i]\n if x<=X:\n ans+=1\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0acc70c4cc8685939c09","document_content":"\n\n\nn, x = list(map(int, input().split()))\nl = list(map(int, input().split()))\n\nl1 = [0]+l\nfor i in range(1, len(l)+1):\n l1[i] = l1[i-1]+l[i-1]\ncnt = 0\n\nfor i in range(0, len(l1)):\n if (l1[i] <= x):\n cnt += 1\nprint(cnt)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3747a68b7ba5c3e7958e","document_content":"N, M = map(int, input().split())\nL = list(map(int, input().split()))\nd = 0\nans = 1\nfor l in L:\n d += l\n if d <=M:\n ans += 1\n else:\n break\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4df4c18bdfbad3b2e98e","document_content":"n, x = map(int, input().split())\nl = list(map(int, input().split()))\n\nd = [0]\nfor i in range(n):\n d.append(d[-1]+l[i])\nprint(len([i for i in d if i <= x]))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"efeba6daf34c0a154832","document_content":"n, x = list(map(int,input().split()))\nl = list(map(int,input().split()))\na = [0]\nfor i in range(n):\n tmp = a[i] + l[i]\n a.append(tmp)\nans = 0\nfor i in range(n + 1):\n if (a[i] <= x):\n ans = ans + 1\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dad873cec743638e6677","document_content":"n,x = map(int, input().split())\nL = list(map(int, input().split()))\ncnt = 1\nd = 0\nfor l in L:\n d += l\n if d <= x:\n cnt += 1\n else:\n break\nprint(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"259d6bce8ab329a75131","document_content":"from itertools import accumulate\nfrom bisect import *\nN, X = list(map(int, input().split()))\nL = list(tuple(map(int, input().split())))\n\nacc = sorted(list(accumulate(L)) + [0])\n\nn = bisect_right(acc,X)\nprint(n)\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4f643f05676fb0c679b8","document_content":"# AtCoder Beginner Contest 130\n# B - Bounding\nimport bisect\n\nN,X=map(int,input().split())\nL=list(map(int,input().split()))\n\naccumu_L=[0]\n\nfor i in range (N):\n accumu_L.append(accumu_L[-1]+L[i])\n\n# print(accumu_L)\n\nprint(bisect.bisect_right(accumu_L,X))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0007cdccd1788363425b","document_content":"n,x=map(int,input().split())\nl=list(map(int,input().split()))+[10**5]\n\nd,cnt=0,0\nwhile d<=x and cnt= cnt:\n ans += 1\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0888c58c249e4c3fed4c","document_content":"n, x = map(int, input().split())\nl = list(map(int, input().split()))\nbound = []\nfor i in range(n+1):\n if i == 0:\n bound += [0]\n else:\n bound += [bound[i-1] + l[i-1]]\n if bound[i] > x:\n print(len(bound) - 1)\n return\nprint(len(bound))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a786f846bbd35ead0bdf","document_content":"N, X = list(map(int, input().split()))\nL = list(map(int, input().split()))\n\ncurrent = 0\ncnt = 1\nfor l in L:\n current += l\n if current > X:\n break\n cnt += 1\n\nprint(cnt)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"051c81adf6389bb9bf4d","document_content":"# Di = Di-1 + Li-1\nn, x = list(map(int, input().split()))\nL = list(map(int, input().split()))\nans = 0\nct = 1 \nfor i in range(n):\n ans = ans + L[i]\n if ans > x:\n break\n else:\n ct += 1\nprint(ct)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b5229ed93261dc4021d8","document_content":"N, X = map(int, input().split())\nL = list(map(int, input().split()))\n\ns = 0\ncnt = 1\nfor i in range(N):\n if s + L[i] > X:\n break\n s += L[i]\n cnt += 1\n\nprint(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"81706703a03a9891e41c","document_content":"n,x = map(int,input().split())\nl = list(map(int,input().split()))\nans = 0\ncnt = 1\nfor i in l:\n ans += i\n if ans > x:\n break\n cnt += 1\n \nprint(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f19bdf17039f661471f7","document_content":"import bisect\n\nN, X = list(map(int, input().split()))\nL = list(map(int, input().split()))\n\nD = [0]\nfor i in range(len(L)):\n D.append(sum(L[:i+1]))\nprint((bisect.bisect_right(D, X)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"976460ec5f99d497f148","document_content":"a = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = 1\nd = 0\nfor i in b:\n d += i\n if d <= a[1]:\n c += 1\nprint(c)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d2d32f92c291cbbf9a5d","document_content":"N,X = map(int,input().split())\nL = [int(i) for i in input().split()]\nD = 0\nfor i in range(N) :\n D = L[i]+D\n # print(i,D)\n if D>X :\n print(i+1)\n return\n\nprint(N+1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fa4460d04e3f335d9a28","document_content":"r=input().split()\nN=int(r[0])\nX=int(r[1])\nd=[int(s) for s in input().split()]\nans=1\nle=0\nfor i in range(N):\n le+=d[i]\n if le>X:\n print(ans)\n break\n elif i==N-1:\n print(N+1)\n else:\n ans+=1","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b444a2c98b63b65443f7","document_content":"n, x = map(int, input().split())\nl = [int(s) for s in input().split()]\n\npos = 0\ncount = 1\nfor i in range(n):\n pos += l[i]\n if pos > x:\n break\n count += 1\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9f9b1aef0f52c85e272b","document_content":"N, X = map(int, input().split())\nL = list(map(int, input().split()))\ncount = 1\ndistance = 0\nfor l in L:\n distance += l\n if distance <= X:\n count += 1\n else:\n break\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"001fe7f50a6b0f119b88","document_content":"n, x = map(int, input().split())\nl = list(map(int, input().split()))\nxlist = [0]\nnum = 0\nfor i in l:\n num += i\n xlist.append(num)\ncnt = 0\nfor j in xlist:\n if j <= x:\n cnt += 1\nprint(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bb165d7385d2bebb0261","document_content":"n, X = map(int, input().split())\nl = list(map(int, input().split()))\n\nsumList = [0]\nfor i in range(n):\n s = sumList[i]+l[i]\n if s > X:\n break\n sumList.append(s)\n\nprint(len(sumList))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"226ef7d07db497a9b235","document_content":"N, X = map(int, input().split())\nL = list(map(int, input().split()))\nS = [0]\nfor i in range(N):\n S.append(S[i] + L[i])\nans = 0\nfor j in range(N+1):\n if S[j] <= X:\n ans += 1\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d7fbecb092af5cea7156","document_content":"N,X=map(int,input().split())\nL=list(map(int,input().split()))\nans=0\n\nfor i in range(1,N+1):\n if ans>=X:\n if ans==X:\n print(i)\n break\n else:\n print(i-1)\n break\n ans+=L[i-1]\nelse:\n print(N+1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1a80039e9252ecb94259","document_content":"import sys\n\n\ndef input(): return sys.stdin.readline().strip()\ndef I(): return int(input())\ndef LI(): return list(map(int, input().split()))\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef S(): return input()\ndef LS(): return input().split()\n\n\nINF = float('inf')\n\n\nn, x = LI()\nl = LI()\ncnt = 1\nd = 0\nfor i in range(n):\n # print(f'{(d, l[i])=}')\n if d + l[i] <= x:\n cnt += 1\n d += l[i]\n else:\n break\nprint(cnt)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a062fa3162790fe3f8af","document_content":"N, X = map(int, input().split())\nL = list(map(int, input().split()))\nD = 0\ncount = 0\nfor i in range(N+1):\n if D <= X:\n count += 1\n if i != N:\n D = D + L[i]\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3edb059ce5f5669625b8","document_content":"n, x = map(int, input().split())\nl = list(map(int, input().split()))\nL = [0] + l\n\na = 0\ncount = 1\nfor i in l:\n a += i\n if a <= x:\n count += 1\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dfa8d45903c3eda33c7c","document_content":"n,x=map(int, input().split())\nl=list(map(int, input().split()))\nd=0\ncount=0\nfor i in range(n):\n d+=l[i]\n if d>x:\n print(i+1)\n break\n if i==n-1 and d<=x:\n print(n+1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c5997866793a26a1f256","document_content":"n,x = map(int,input().split())\nl = list(map(int,input().split()))\nd = 0\ni = 0\nwhile d <= x and i <= n:\n if i == n:\n i += 1\n else:\n d += l[i]\n i += 1\nprint(i)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"59d877d95cdc99cff4e8","document_content":"n,x=map(int,input().split())\nans=1\np=0\nl=[int(x) for x in input().split()]\nfor i in range(n):\n p+=l[i]\n if p > x:\n break\n else:\n ans+=1\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7948f9433d8efd479f66","document_content":"x, y = list(map(int, input().split()))\nnum_list = list(map(int, input().split()))\n\ni = 1\ndistance = 0\nfor _ in num_list:\n distance += _\n if distance > y:\n break\n i += 1\n\nprint(i)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"53bbb43035c3e4c56176","document_content":"n, x = map(int, input().split())\nl = list(map(int, input().split()))\nans = 1\np = 0\n\nfor i in range(n):\n p += l[i]\n if p <= x:\n ans += 1\n else:\n break\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"66b25ac4e25869c9d4c8","document_content":"n, x = list(map(int, input().split()))\nl = list(map(int, input().split()))\n\nans = 0\nbound = 0\nfor i in l:\n bound += i\n ans += 1\n if bound > x:\n break\nelse:\n ans = n + 1\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5ac45dac0efc63f97149","document_content":"n, x = list(map(int, input().split()))\nL = list(map(int, input().split()))\n\nd = [0]*(n+1)\ncnt = 0 \nfor i in range(n):\n d[i+1] += d[i]+L[i]\n\nfor i in range(n+1):\n if d[i] <= x:\n cnt += 1\n\nprint(cnt)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1894fea50b282f9d5da5","document_content":"n,x = map(int,input().split())\na = list(map(int,input().split()))\nc = 1\nb = 0\nfor i in a:\n b = i+b\n if b <= x:\n c+=1\nprint(c)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"10dbe15fbac27a385c9e","document_content":"n,x = map(int,input().split())\na = list(map(int,input().split()))\na.append(0)\ncount = 0\nb = 0\nfor i in range(n+1):\n if b > x:\n break\n count+=1\n b+= a[i]\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a1c8abaca60c91e6049a","document_content":"import sys\nsys.setrecursionlimit(10 ** 9)\n# input = sys.stdin.readline ####\ndef int1(x): return int(x) - 1\ndef II(): return int(input())\ndef MI(): return list(map(int, input().split()))\ndef MI1(): return list(map(int1, input().split()))\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef MS(): return input().split()\ndef LS(): return list(input())\ndef LLS(rows_number): return [LS() for _ in range(rows_number)]\ndef printlist(lst, k=' '): print((k.join(list(map(str, lst)))))\nINF = float('inf')\n# from math import ceil, floor, log2\n# from collections import deque, defaultdict\n# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations\n# from heapq import heapify, heappop, heappush\n# import numpy as np # cumsum\n# from bisect import bisect_left, bisect_right\n\ndef solve():\n N, X = MI()\n L = LI()\n\n A = [0] * (N+1)\n for i in range(1, N+1):\n A[i] = L[i-1] + A[i-1]\n ans = 0\n for a in A:\n if a > X:\n break\n ans += 1\n print(ans)\n\ndef __starting_point():\n solve()\n\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"67b0cdbc108fb755c476","document_content":"n,x=map(int,input().split())\nl=list(map(int,input().split()))\nlist_d=[0]\nans=0\nfor i in range(1,n+1):\n list_d.append(list_d[i-1]+l[i-1])\nfor i in list_d:\n if i<=x:\n ans+=1\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"884f7d82688d38b9fc72","document_content":"N, X = map(int, input().split())\nL = list(map(int, input().split()))\n\nbound = 1\nd = 0\nfor i in L:\n d += i\n if d <= X:\n bound += 1\nprint(bound)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d762ada0b8d66b6bd813","document_content":"n,x = map(int, input().split())\nl = list(map(int, input().split()))\n\nans = 1\nt = 0\nfor i in l:\n t += i\n if t <= x: ans += 1\n if t >= x: break\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fa478e84a190c153a7d3","document_content":"n, x = list(map(int, input().split()))\nl = [int(i) for i in input().split()]\np = 0\nfor i in range(n):\n p += l[i]\n if p > x:\n print((i + 1))\n break\nelse:\n print((n + 1))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dc55ba9d5239262ab3b7","document_content":"n, x = map(int, input().split())\nL = list(map(int, input().split()))\n\ncnt = 0\npos = 0\nfor itr, l in enumerate(L):\n pos += l\n if pos > x:\n print(itr + 1)\n return\n\nprint(n + 1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d3ecd38629e06ccd0ca3","document_content":"N,X=list(map(int,input().split()))\nL=list(map(int,input().split()))\nS=[0]\nsum_L=0\nfor i in range(N):\n sum_L+=L[i]\n S.append(sum_L)\ncounter=0\nfor i in range(N+1):\n if S[i]<=X:\n counter+=1\nprint(counter)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"59ac2701b1d0d9eaafe3","document_content":"n,x=map(int,input().split())\nl=list(map(int,input().split()))\nd=[0]\ncount=0\nfor i in range(n):\n d.append(d[i]+l[i])\nfor c in d:\n if c<=x:\n count+=1\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2186aa89bf12017b10d9","document_content":"N,X = list(map(int,input().split()))\nLi = list(map(int,input().split()))\n\nDi = 0\ncount = 1\nfor i in Li:\n Di = Di + i\n if Di <= X:\n count += 1\n else:\n break\nprint(count)\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bbd21718fd7eb6a49d8e","document_content":"n, x = map(int,input().split())\nl = list(map(int,input().split()))\nans = 0\ncount = 1\nfor i in range(n):\n ans += l[i]\n if ans <= x:\n count += 1\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ea782416963fc010e010","document_content":"N,X = map(int,input().split())\nL = list(map(int,input().split()))\nkyori = 0\n\nfor i in range(N):\n kyori += L[i]\n if kyori > X:\n print(i+1)\n return\n\nprint(N+1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"57c192a7d45b6cee9a61","document_content":"N,X = list(map(int,input().split()))\nL = list(map(int,input().split()))\nList = [0]*(N+1)\nfor i in range(1,N+1):\n List[i] = List[i-1] + L[i-1]\nimport bisect \n# A = [i for i in List if i <=X]\n# print(len(A))\nprint((bisect.bisect_left(List,X+1)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a39a50b0261f30ca573d","document_content":"n, x = map(int, input().split())\na = list(map(int, input().split()))\ns = 0\nt = 1\nfor i in range(n):\n s = s + a[i]\n if s <= x:\n t += 1\nprint(t)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fdfc8b8ed4adc68f4a8a","document_content":"n,x=map(int,input().split())\nL=list(map(int,input().split()))\nans=0\nct=1\nfor i in range(n):\n ans=ans+L[i]\n if ans>x:\n break\n else:\n ct+=1\nprint(ct)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d813ccdace8a2ae05bb7","document_content":"n,x = map(int,input().split())\nl = list(map(int,input().split()))\ncnt = 0\nfor i in range(n+1):\n #print(sum(l[:i]))\n if sum(l[:i])<=x:\n cnt += 1\nprint(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a76f1a90f42fdd2f4934","document_content":"# n\u306f\u8df3\u306d\u308b\u56de\u6570\u3000d1 = 1 dn+1 = dn + ln\n\nn,x = list(map(int,input().split()))\nl = list(map(int,input().split()))\n\nd = 0\ncount = 1\n\nfor y in range(n):\n d = d + l[y]\n if d <= x:\n count += 1\n else:\n break\n \nprint(count)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a75799f45051af2420ee","document_content":"n, x = (int(i) for i in input().split())\nlist_l = [int(j) for j in input().split()]\ntmp = 0\ncount = 0\nfor i in range(0, n + 1):\n if i == 0:\n pass\n else:\n tmp += list_l[i - 1]\n if tmp > x:\n break\n count += 1\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"430793cf09233c4952b6","document_content":"n, x = map(int, input().split())\nllist = list(map(int, input().split()))\ndlist = [0]\nd = 0\nfor i in llist:\n d += i\n dlist.append(d)\nprint(sum([i<=x for i in dlist]))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1f3ede99f85b61df4db4","document_content":"n,x = map(int,input().split())\nl = list(map(int,input().split()))\ndist = [0]*(n+1)\nfor i in range(1,n+1):\n dist[i] = dist[i-1] + l[i-1]\n \ncnt = 0\nfor i in range(n+1):\n if dist[i]<= x:\n cnt += 1\nprint(cnt) ","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ab2e028867984301285f","document_content":"N,X = map(int,input().split())\nL_List = list(map(int,input().split()))\nans = 0\nct = 1\nfor i in range(N):\n ans += L_List[i]\n if ans <= X:\n ct += 1\n else:\n break\n \nprint(ct)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7e25b469ad18f3ef521e","document_content":"N,X = map(int,input().split())\nL = [int(i) for i in input().split()]\nD = [0]\n\nfor i in range(N):\n a = D[i]+L[i]\n if(a <= X):\n D.append(a)\n else:\n break\n\nprint(len(D))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"310bedc0422cb65ef2f7","document_content":"n, x = map(int, input().split())\nL = list(map(int, input().split()))\nval = 0\ncount = 1\n\nfor l in L:\n val += l\n if val <= x:\n count += 1\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"39f974f6282416078d5a","document_content":"N,X = map(int,input().split())\nL = list(map(int,input().split()))\nList = [0]*(N+1)\nfor i in range(1,N+1):\n List[i] = List[i-1] + L[i-1]\nA = [i for i in List if i <=X]\nprint(len(A))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"160603df3c839793a2d9","document_content":"n, x = map(int, input().split())\nl = list(map(int, input().split()))\nball = 0\nc = 1\nfor i in range(n):\n ball += l[i]\n if ball <= x:\n c += 1\n else:\n break\nprint(c)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d9aecebf35735189de5a","document_content":"\nN, X = list(map(int, input().split()))\nL = list(map(int, input().split()))\ncnt = 1\ntotal = 0\nfor i in range(N):\n total += L[i]\n if total <= X:\n cnt += 1\n else:\n break\nprint(cnt)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3b8695adeef17a64b08d","document_content":"N,X=map(int,input().split())\nL=list(map(int,input().split()))\nl=[0]\ns=0\nfor i in range(N):\n s+=L[i]\n if s>X:\n break\n l.append(s)\nprint(len(l))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4867166c1b8ef2c4f55f","document_content":"n, x = list(map(int, input().split()))\n\nl = list(map(int, input().split()))\nans = 1\np = 0\nfor i in range(n):\n p += l[i]\n if (p > x):\n break\n else:\n ans += 1\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4427333b193d8bd4b0d7","document_content":"N,X=list(map(int,input().split()))\nls1=list(map(int,input().split()))\n\nx = 0\nii = 1\nfor i in ls1:\n x = x + i\n if x > X:\n break\n ii += 1\nprint(ii)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6ca4101c7417dfb08eaa","document_content":"n,x = map(int,input().split())\nl = list(map(int,input().split()))\nans = 1\nd = [0]*(n+1)\nfor i in range(1,n+1):\n d[i] = d[i-1]+l[i-1]\n if d[i] <= x:\n ans += 1\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"894f0ad38128bd983a27","document_content":"n, x = list(map(int, input().split()))\narr = list(map(int, input().split()))\nif x == 0:\n print((0))\n return\nsum = 0\ncount = 1\ni = 0\nwhile i < n:\n sum += arr[i]\n i += 1\n if sum <= x:\n count += 1\n else:\n print(count)\n return\nprint(count)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4c44d51693a6a15b1825","document_content":"n, x = map(int,input().split())\n\nnum_list = list(map(int,input().split()))\nnum_sum = 0\ncount = 1\n\nfor i in range(n):\n num_sum += num_list[i]\n if num_sum>x:\n break\n count += 1\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6a79474dd26aa6cd85e5","document_content":"n, x = list(map(int, input().split()))\nL = list(map(int, input().split()))\ndist = 0\nres = 0\nfor i, l in enumerate(L, 1):\n dist += l\n if dist > x:\n print(i)\n return\n elif dist == x:\n print((i + 1))\n return\nprint((n + 1))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e04a75aa9c617dd5037f","document_content":"N,X = map(int,input().split())\nL = list(map(int,input().split()))\n\nD = []\nD.append(0)\n\nfor i in range(0,N):\n D.append(D[i]+L[i])\n\ncnt = 0\nfor d in D:\n if d <= X:\n cnt += 1\n \nprint(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c7dcbffd4e1d7c3b7bbf","document_content":"N, X = map(int, input().split())\nL = list(map(int, input().split()))\nans = 1\ntotal = 0\nfor l in L:\n total += l\n if total > X: break\n ans += 1\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dc1d9451caa20d3d62e6","document_content":"a,b=map(int,input().split())\nl=list(map(int,input().split()))\nc=[0]\ncount=1\nfor i in range(a):\n c.append(c[i]+l[i])\n if(c[i+1]<=b):\n count+=1\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2e73c2c2a10d78dd220a","document_content":"N, X = list(map(int, input().split()))\nL = list(map(int, input().split()))\n\nnum = 1\ns = 0\nfor i in range(N):\n s += L[i]\n if s > X: break\n num += 1\n\nprint(num)\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"26528b1314b855bce290","document_content":"from typing import List\n\n\ndef next_coordinates(d: int, l: int) -> int:\n return d + l\n\n\ndef answer(n: int, x: int, l: List[int]) -> int:\n d = 0\n count = 1\n for i in l:\n d = next_coordinates(d, i)\n if x < d:\n return count\n count += 1\n\n return count\n\n\ndef main():\n n, x = map(int, input().split())\n l = list(map(int, input().split()))\n print(answer(n, x, l))\n\n\ndef __starting_point():\n main()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"793c383ef2978536eec0","document_content":"import itertools\nimport bisect\n\nn, x = map(int, input().split())\nll = list(map(int, input().split()))\n\ndl = [0] + list(itertools.accumulate(ll))\n\nprint(bisect.bisect_right(dl, x))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"315e4b5a17496c5a91a4","document_content":"\nn,x = list(map(int, input().split()))\na = list(map(int, input().split()))\ncnt = 1\ntotal = 0\n\nfor i in range(n):\n total += a[i]\n if total <= x:\n cnt += 1\nprint(cnt)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1a52398d10011485be77","document_content":"n,x = map(int,input().split())\nli = list(map(int,input().split()))\nlis = []\nsum = 0\nfor i in range(n):\n sum += li[i]\n lis.append(sum)\n\ncnt = 0\nfor i in lis:\n if i <= x:\n cnt += 1\n\nprint(cnt+1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a1a2daa8e350c6aa92db","document_content":"n, x = map(int, input().split())\nfrom itertools import accumulate\nL =[0] + list(map(int, input().split()))\nacc = list(accumulate(L))\nprint(sum([1 for i in acc if i <=x]))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bbb5b0e763172d498df4","document_content":"A,B=list(map(int,input().split(' ')))\nl=list(map(int,input().split(' ')))\nans=0\ncount=1\nfor i in l:\n ans+=i\n if ans<=B:\n count+=1\nprint(count)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"abe77625c95b70045bd0","document_content":"N,X=map(int,input().split())\nL=list(map(int, input().split()))\n\nD=0\n\nfor i in range(N):\n\tD+=L[i]\n\tif D>X:\n\t\tprint(i+1)\n\t\treturn\n\t\t\nprint(i+2)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fa764811519503a80668","document_content":"N, X = map(int, input().split())\nL = list(map(int, input().split()))\n\nD = 0\ncnt = 1\nfor l in L:\n D = D + l\n if D > X:\n break\n cnt +=1\n\nprint(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"45dba100560e8f4c3f64","document_content":"n,x = map(int,input().split())\nl = list(map(int,input().split()))\nwa = 0\nd = [0]*(n+3)\nd[1]=0\nd.pop(0)\nwa = 1\nfor i in range(2,n+2):\n d[i]=d[i-1]+l[i-2]\n if(d[i]>x):\n break\n wa+=1\nprint(wa)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"79fa0929d5d40113e9dd","document_content":"N, X = [int(i) for i in input().split()]\nLS = [int(i) for i in input().split()]\n\ns = 0\ncnt = 1\n\nfor l in LS:\n s += l\n if s <= X:\n cnt += 1\n else:\n break\n\nprint(cnt)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"07ef95883c8a61a96c4a","document_content":"n, x = map(int, input().split())\nl = list(map(int, input().split()))\na = 1\nd = 0\nfor i in range(n):\n d += l[i]\n if d <= x:\n a += 1\nprint(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"75df06429eda7ff1a191","document_content":"N = int(input())\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\nC = [int(i) for i in input().split()]\nans = 0\nfor i in range(N):\n ans += B[A[i]-1]\n if(A[i] == A[i-1]+1 and i != 0):\n ans += C[A[i]-2]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f464b522e7439d5c7b42","document_content":"N = int(input())\nA,B,C = [list(map(int, input().split())) for _ in range(3)]\n\nans = 0\n\nfor i in range(N-1):\n if A[i+1] == A[i] + 1:\n ans += C[A[i]-1]\n\nprint(sum(B) + ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2af99b9d2fd71765daac","document_content":"N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\n\nS = 0\nfor i in range(N-1):\n if A[i+1] == A[i] + 1:\n S += B[A[i]-1] + C[A[i]-1]\n else:\n S += B[A[i]-1]\n\nS += B[A[N-1]-1]\nprint(S)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d12638e700833d12f29f","document_content":"n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\nans=sum(b)\n\nfor i in range(n-1):\n if a[i]+1==a[i+1]:\n ans+=c[a[i]-1]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a6470e1afbee533e7454","document_content":"n = int(input())\n\nan = list(map(int,input().split()))\nbn = list(map(int,input().split()))\ncn = list(map(int,input().split()))\nsat = sum(bn)\n\nfor x in range(n-1):\n if an[x+1] == an[x] + 1:\n sat += cn[an[x]-1]\n\nprint(sat)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"89b0ccbe5b373bab7e6e","document_content":"N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nans = 0\nfor i in range(N):\n ans += B[A[i]-1]\n if i > 0 and A[i] == A[i-1] + 1:\n ans += C[A[i]-2]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7c3a0a5bab3dfa9250c1","document_content":"n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\nans=sum(b)\nfor i in range(n-1):\n if a[i+1]-a[i]==1:\n ans+=c[a[i]-1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"03039623ce3ea0d57a9a","document_content":"N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\n\nans = sum(B)\nfor i in range(len(A)-1):\n if A[i] + 1 == A[i+1]:\n ans += C[A[i]-1]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fc151c966e3255cf1061","document_content":"N = int(input())\nlsA = list(map(int,input().split()))\nlsB = [0]+list(map(int,input().split()))\nlsC = [0]+list(map(int,input().split()))\nsumB = sum(lsB)\nfor i in range(N-1):\n if lsA[i]+1 == lsA[i+1]:\n sumB += lsC[lsA[i]]\nprint(sumB)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"244ab350dc42ec69b24c","document_content":"n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\nans = 0\nfor i in range(n):\n num = a[i] - 1\n ans += b[num]\n\n if i == 0:\n continue\n elif a[i - 1] + 1 == a[i]:\n ans += c[num - 1]\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b864d9d34d4849c1ddac","document_content":"N=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\nx=sum(B)\nfor i in range(N-1):\n if A[i]+1==A[i+1]:\n x+=C[A[i]-1]\nprint(x)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"49554036f886b4d19c1d","document_content":"n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\nans = 0\nfor i in range(n-1):\n if a[i]+1==a[i+1]:\n ans += c[a[i]-1]\nans += sum(b)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"81b1aa7ec4e385841c32","document_content":"N=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\ns=0\nfor i in range(N):\n s+=B[A[i]-1]\n if A[i]-A[i-1]==1 and i>0:\n s+=C[A[i]-2]\nprint(s)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a3da65a50c908c6332b6","document_content":"n = int(input())\na = [int(s) for s in input().split()]\nb = [int(s) for s in input().split()]\nc = [int(s) for s in input().split()]\n\nans = b[a[0] - 1]\n\nfor i in range(1, n):\n ans += b[a[i] - 1]\n if a[i] == a[i - 1] + 1:\n ans += c[a[i] - 2]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a8f70281fb8ceda8480c","document_content":"def L():\n\treturn list(map(int, input().split()))\n\nN = int(input())\nA = L()\nB = L()\nC = L()\nO = 0\n\nfor i in range(N):\n\tai = A[i] - 1\n\tO += B[ai]\n\tif i > 0 and A[i] == A[i - 1] + 1:\n\t\tO += C[ai - 1]\n\nprint(O)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ffc9890fcbec1ea1cfd0","document_content":"n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\n\nfor i in range(n):\n if (i == 0):\n ans =b[a[0] - 1]\n y = a[0]\n else:\n x = a[i]\n if (x - y == 1):\n ans = ans + b[x - 1] + c[y - 1]\n else:\n ans = ans + b[x - 1]\n y = x\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"72978bde07f1057c92d3","document_content":"n = int(input())\na = list(map(int, input().split(' ')))\nb = list(map(int, input().split(' ')))\nc = list(map(int, input().split(' ')))\n\nans = 0\nfor i in range(0, n):\n ans += b[a[i] - 1]\nfor i in range(0, n - 1):\n if a[i + 1] == a[i] + 1:\n ans += c[a[i] - 1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b14238af8df6cbcbe23d","document_content":"n=int(input())\na=list(map(lambda x:int(x)-1, input().split()))\nans=sum(list(map(int,input().split())))\nc=list(map(int,input().split()))\n\nfor i in range(n-1):\n if a[i]+1==a[i+1]:\n ans+=c[a[i]]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2c3c29d012a4ecc6860c","document_content":"\nn= int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\nans=0\n\nfor i in range(0,n):\n ans += b[a[i]-1]\n\n\n if i>=1:\n if a[i]==a[i-1]+1:\n\n ans+=c[a[i]-2]\n\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b6660984eac6e807bd7e","document_content":"n=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\nans=0\nfor i in range(n):\n ans += B[A[i]-1]\n if i int:\n satisfaction = sum(b)\n for i in range(1, n):\n previous = a[i - 1]\n if a[i] == previous + 1:\n satisfaction += c[previous - 1]\n\n return satisfaction\n\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = list(map(int, input().split()))\n print((answer(n, a, b, c)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4b2a87b7499908101419","document_content":"n= int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\nans=0\n\nfor i in range(0,n):\n ans += b[a[i]-1]\n\n\n if i>=1:\n if a[i]==a[i-1]+1:\n\n ans+=c[a[i]-2]\n\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"07529787f7494c2136bd","document_content":"n = int(input())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nc = [int(i) for i in input().split()]\nans = b[a[-1]-1]\nfor i in range(n-1):\n ans += b[a[i]-1]\n if a[i] + 1 == a[i+1]:\n ans += c[a[i]-1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"06ea68442627af0b1c04","document_content":"N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\n\nans = 0\npre_a = -1\n\nfor a in A:\n ans += B[a-1]\n if a == pre_a + 1:\n ans += C[a-2]\n pre_a = a\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"65f60ff0206098c6f6e4","document_content":"n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\n\nans=0\nfor i in range(n-1):\n if a[i+1]-a[i]==1:\n ans+=c[a[i]-1]\n \nprint(ans+sum(b))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b677c9449226a3e36c3c","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nans = B[A[0]-1]\nfor i in range(1, N):\n ans += B[A[i]-1]\n if A[i]-A[i-1] == 1:\n ans += C[A[i-1]-1]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6b399bef4c211380530d","document_content":"N = int(input())\n\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nans = 0\n\nfor i in range(N):\n ans += B[A[i]-1]\n \n \nfor j in range(0, N-1):\n if A[j+1] == A[j] + 1:\n ans = ans + C[A[j]-1]\n \nprint(ans)\n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2025f38c51a260ee61e1","document_content":"N = int(input())\nliA = list(map(int, input().split()))\nliB = list(map(int, input().split()))\nliC = list(map(int, input().split()))\n\nManzoku = sum(liB)\n\nfor i in range(N):\n if i < N - 1:\n if liA[i+1] - liA[i] == 1:\n Manzoku += liC[liA[i] - 1]\n\nprint((Manzoku))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ed4cd1d721e880e36cf7","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nans = 0\nfor i in range(N):\n x = A[i] - 1\n ans += B[x]\n if i >= 1 and A[i] == A[i-1] + 1:\n ans += C[A[i-1]-1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"39f4b61b332bcd2981e4","document_content":"N = int(input())\nA = list((int(x) for x in input().split()))\nB = list((int(x) for x in input().split()))\nC = list((int(x) for x in input().split()))\nbonus = 0\nfor i in range(N-1):\n if A[i]+1 == A[i+1]:\n bonus += C[A[i]-1]\nprint(sum(B)+bonus)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7a730f5b6b04f8e034b0","document_content":"n = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\ncount = sum(B)\nfor i in range(n-1):\n if A[i+1]-A[i]==1:\n count+=C[A[i]-1]\nprint(count)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5a8def75a4e3116f0d55","document_content":"n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\nans = 0\nfor i in range(n):\n ans += b[a[i] - 1]\n if i != 0:\n if a[i] == a[i - 1] + 1:\n ans += c[a[i] - 2]\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"588f842a65bc70887638","document_content":"N=int(input())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\nC=list(map(int, input().split()))\n\nans=0\n\nfor i in range(N-1):\n\tnow=A[i]\n\tnext=A[i+1]\n\tans+=B[now-1]\n\tif next==now+1:\n\t\tans+=C[now-1]\n\nans+=B[A[N-1]-1]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a2f75d1cf1a87f1e4624","document_content":"n = int(input())\nlist_a = [int(i) for i in input().split()]\nlist_b = [int(j) for j in input().split()]\nlist_c = [int(k) for k in input().split()]\nsatisfied = 0\nfor i in range(0, len(list_a)):\n satisfied += list_b[list_a[i] - 1]\n if i > 0 and list_a[i] == list_a[i - 1] + 1:\n satisfied += list_c[list_a[i - 1] - 1]\nprint(satisfied)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d79cc592b3c88218dc82","document_content":"n = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nans = 0\n\nfor i in range(n):\n ans += B[A[i]-1]\n if(i > 0 and A[i] == A[i-1]+1):\n ans += C[A[i]-2]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2efc9915c10ea3cadbc4","document_content":"n = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nres = 0\nfor i in range(n - 1):\n res += B[i]\n if A[i] + 1 == A[i + 1]:\n res += C[A[i] - 1]\nprint((res + B[-1]))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"372120c42710142135b1","document_content":"N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\n\ncount = 0\nfor j in A:\n count += B[j-1]\n\n#print(count)\n\nfor z in range(N-1):\n if A[z+1]- A[z] == 1:\n zz = A[z]\n count += C[zz-1]\n\nprint(count)\n \n \n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b01c55dc8eca329551d5","document_content":"n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\nans=0\nfor i in range(len(a)):\n ai=a[i]\n ans+=b[ai-1]\n if(ans!=b[ai-1]):\n if(ai==before+1):\n ans+=c[before-1]\n before=ai\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"34c59a8bbc386ced2ace","document_content":"n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\nans = 0\n\nfor i in range(n):\n ans += b[i]\nfor j in range(n-1):\n if a[j] == a[j+1] -1:\n ans += c[(a[j]-1)]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d5b57112adf8b886cd94","document_content":"# \u554f\u984c\uff1ahttps:\/\/atcoder.jp\/contests\/abc140\/tasks\/abc140_a\n\nn = int(input())\na = list(map(int, input().strip().split()))\nb = list(map(int, input().strip().split()))\nc = list(map(int, input().strip().split()))\n\nres = b[a[0]-1]\nfor i in range(1, n):\n res += b[a[i]-1]\n if a[i] - a[i-1] == 1:\n res += c[a[i-1]-1]\n\nprint(res)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8c9bf00087a4ac0350d5","document_content":"N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nans = 0\ncnt = 100\nfor i in range(N):\n if cnt + 1 == A[i]:\n ans += C[cnt-1]\n cnt = A[i]\n ans += B[A[i]-1]\n \nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ebf2598f67cfa3063c87","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\n# \u914d\u5217\u306e\u6dfb\u5b57\u3092N\u3068\u5408\u308f\u305b\u308b\nB.insert(0,0)\nC.insert(0,0)\nsatis = 0\ntmp = 999\nfor i in range(N):\n satis += B[A[i]]\n if (tmp - A[i]) == -1:\n satis += C[tmp]\n tmp = A[i] #i+1\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\nprint(satis)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4929247916e9027702d1","document_content":"n=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\nd=sum(B)\nfor i in range(n-1):\n if A[i+1]-A[i]==1:\n d+=C[A[i]-1]\nprint(d)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"111dcaa6d42becd0fc50","document_content":"n = int(input())\na,b,c = [list(map(int,input().split())) for i in range(3)]\nx = 0\nd = -10\nfor i in range(n):\n y = b[a[i]-1]\n x += y\n if a[i]-1 == d:\n x+= c[d-1]\n d = a[i]\nprint(x)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4a20d2dd55ab7fb6ea20","document_content":"n = int(input())\na = list(map(int, input().split()))\nb = sum(map(int, input().split()))\nc = list(map(int, input().split()))\ns = 0\nfor i in range(n-1):\n if a[i+1] - a[i] == 1:\n s += c[a[i] - 1]\nprint(b + s)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"faca3a8a5be582a99d06","document_content":"n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\nans=0\nfor i in range(n):\n ans+=b[a[i]-1]\n if i!=0:\n if a[i]==a[i-1]+1:\n ans+=c[a[i]-2]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"525652e2ff7630d6856c","document_content":"n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\n\naddans=0\n\nfor i in range(n-1) :\n if a[i]+1 == a[i+1] :\n addans += c[a[i]-1]\nprint(sum(b)+addans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2180a4a5653d66d27596","document_content":"n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\ns=0\ns += sum(b)\nfor i in range(n-1):\n if a[i]+1==a[i+1]:\n s += c[a[i]-1]\nprint(s)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1983a88359091da9932e","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n ans += B[A[i]-1]\n if i < N-1 and A[i+1] - A[i] == 1: ans += C[A[i]-1]\n \nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8fa3adceccc1c8e8c4de","document_content":"n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\nd=sum(b)\nfor i in range(n-1):\n if a[i]-a[i+1]==-1:\n d=d+c[a[i]-1]\nprint(d)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2d74c82b4324d32c5da2","document_content":"n=int(input())\n\na_list=[int(i) for i in input().split()]\nb_list=[int(i) for i in input().split()]\nc_list=[int(i) for i in input().split()]\n\nsatisfaction=0\n\nfor i in range(n):\n satisfaction+=b_list[a_list[i]-1]\n if i0:\n if a[i]==a[i-1]+1:\n ans+=c[a[i-1]-1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a0aa8f6a0a5d10db3d69","document_content":"n=int(input())\nans=0\nl=[list(map(int,input().split())) for i in range(3)]\nfor i in range(1,n+1):\n ans+=l[1][l[0][i-1]-1]\n if i!=n and l[0][i]==l[0][i-1]+1:\n ans+=l[2][l[0][i-1]-1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2f2e55b09717e029b674","document_content":"n=int(input());ans=0\na=[*map(int,input().split())]\nb={i+1:j for i,j in enumerate(map(int,input().split()))}\nc={i+1:j for i,j in enumerate(map(int,input().split()))}\nans+=b[a[0]]\nfor i in range(1,n):\n if a[i]-(a[i-1])==1:\n ans+=c[a[i-1]]\n ans+=b[a[i]]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"be4914bf39cf37c45ec5","document_content":"N=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\ns=0\nfor i in range(N):\n s+=B[A[i]-1]\n if i!=0 and A[i-1]+1==A[i]:\n s+=C[A[i]-2]\nprint(s)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6e0bd3ee96b6b55ed2b6","document_content":"n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\neat_bef=0\nans=0\nfor i in range(len(a)):\n ans+=b[a[i]-1]\n if i>=1:\n if eat_bef+1==a[i]:\n ans+=c[eat_bef-1]\n eat_bef=a[i]\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9a2457ac2cd6520b1661","document_content":"n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\nans = sum(b)\nfor i in range(n-1):\n if a[i]+1 == a[i+1]:\n ans += c[a[i]-1]\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"24595484a0c18e68d8c2","document_content":"n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\nans = sum(b)\nfor i in range(n-1):\n if a[i+1] - a[i] == 1:\n ans += c[a[i]-1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"29e25c8a9c0034768fb9","document_content":"n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\nans = sum(b)\nfor i in range(1,n):\n if a[i-1]+1 == a[i]:\n ans += c[a[i-1]-1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c7cf09c6a304a3bb25ed","document_content":"def main():\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = list(map(int, input().split()))\n point = sum(b)\n\n for i in range(1,n):\n if a[i-1] +1 == a[i]:\n point += c[a[i-1]-1]\n\n\n print(point)\n\ndef __starting_point():\n main()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8da8295935cc1e468df5","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nans = sum(B)\nfor i in range(N-1):\n if A[i]+1 == A[i+1]:\n ans += C[A[i]-1]\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7199ab92e8d245a75837","document_content":"def main():\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = list(map(int, input().split()))\n total_score = sum(b)\n\n for i in range(1, n):\n prev = a[i - 1]\n if prev + 1 == a[i]:\n total_score += c[prev - 1]\n\n print(total_score)\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fa504f292bb058a1f107","document_content":"N = int(input())\nA = list(map(int, input().split()))\nA = list([x - 1 for x in A])\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\ncnt = 0\n\nfor i in range(N):\n cnt += B[A[i]]\n if A[i] == A[i-1] + 1 and i != 0:\n cnt += C[A[i-1]]\nprint(cnt)\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ea64d0b002c2c7cf99c9","document_content":"N=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\n\nans=B[A[0]-1]\nmae=A[0]\nfor i in range(1,N):\n ans+=B[A[i]-1]\n if A[i]-mae==1:\n ans+=C[mae-1]\n mae=A[i]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9815cb01f23a7b79d53d","document_content":"N = int(input())\nA = [0] + list(map(int, input().split()))\nB = [0] + list(map(int, input().split()))\nC = [0] + list(map(int, input().split()))\nans = 0\nfor i in range(1, N+1):\n ans += B[A[i]]\n if i > 1:\n if A[i] == A[i-1]+1:\n ans += C[A[i-1]]\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e3e9cb6bcaf445e8347d","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n \nans = 0\nfor i in range(N):\n ans += B[A[i]-1]\n if i > 0 and A[i] - A[i-1] == 1: ans += C[A[i-1]-1]\n \nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6c89e2f127d6ec977829","document_content":"n = int(input())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\nc = [int(x) for x in input().split()]\nres = b[a[0]-1]\nfor i in range(1,n):\n #print(i,res,a[i])\n res += b[a[i]-1]\n if a[i-1] + 1 == a[i]:\n res += c[a[i-1]-1]\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b24c6004bea00eb0a358","document_content":"n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\nd = 0\nfor i in range(n - 1):\n if a[i] + 1 == a[i + 1]:\n d += c[a[i] - 1]\nprint(d + sum(b))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4c8a259437f5bc52afce","document_content":"n = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nsumB = sum(B)\n\ncnt = []\n\nfor i in range(n-1):\n if A[i]+1 == A[i+1]:\n cnt.append(A[i]-1)\n\nsumC = 0\nfor i in cnt:\n sumC += C[i]\n\nprint((sumB+sumC))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4326cce8846d5aef90b0","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nans = 0\nnum = 0\nfor i in A:\n ans += B[i-1]\n if num != 0 and i - num == 1:\n ans += C[i-2]\n num = i\n \nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5710b4e4da098be0cd85","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n ans += B[A[i] - 1]\n if i>=1 and A[i] - A[i-1] == 1:\n ans += C[A[i-1] - 1]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"47c70d65bfbcd3c1d469","document_content":"N = int(input())\nA_List = list(map(int,input().split()))\nB_List = list(map(int,input().split()))\nC_List = list(map(int,input().split()))\nans = 0\n\nfor i in range(len(A_List)):\n ans += B_List[A_List[i] - 1]\n if (i != 0) & (A_List[i] - A_List[i-1] == 1):\n ans += C_List[A_List[i-1]-1]\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fac424c297a4afdea1d2","document_content":"n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\nres = b[-1]\nfor i in range(n - 1):\n res += b[i]\n if a[i] + 1 == a[i + 1]:\n res += c[a[i] - 1]\nprint(res)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"037302e5b8cc3076033b","document_content":"def mapt(fn, *args):\n return tuple(map(fn, *args))\n\ndef Input():\n return mapt(int, input().split(\" \"))\n\ndef main():\n n = int(input())\n a = Input()\n b = Input()\n c = Input()\n ans = 0\n for i in range(n-1):\n if a[i+1] - a[i] == 1:\n ans += c[a[i]-1]\n ans += sum(b)\n print(ans)\nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d31b42d066cd794cfce1","document_content":"N = int(input())\ndishes = list(map(int, input().split()))\nsatisfaction = list(map(int, input().split()))\nadditional = list(map(int, input().split()))\n\nres = 0\n\nfor i in range(N-1):\n res += satisfaction[i]\n\n if dishes[i] + 1 == dishes[i+1]:\n res += additional[dishes[i] - 1]\n\nprint((res + satisfaction[-1]))\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dbbace8c0bbefc46dd2e","document_content":"kind = int(input())\n\ntable_1 = input().split(' ')\ntable_2 = input().split(' ')\ntable_3 = input().split(' ')\ntotal = 0\nfor i in range(kind):\n total += int(table_2[i])\n \nfor j in range(kind-1):\n if int(table_1[j]) == int(table_1[j + 1]) - 1:\n total += int(table_3[int(table_1[j]) - 1])\nprint(total)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9b2c4df78f6829a680d0","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nans = 0\nprev = -1\nfor a in A:\n ans += B[a - 1]\n if prev == a - 1:\n ans += C[prev - 1]\n prev = a\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"607cd8645c508d4a8acf","document_content":"n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\nsu = 0\nn1 = len(a)\nfor i in a:\n su += b[i-1]\n\nfor i in range(n1-1):\n if a[i] == a[i+1] -1:\n su += c[a[i]-1]\n\nprint(su)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e79035949640f0356ad5","document_content":"n = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nans = 0\nx = -1\n\nfor i in A:\n ans += B[i-1]\n if x+1 == i:\n ans += C[x-1]\n x = i\n\nprint(ans)\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9786d42060eecb64b032","document_content":"N = int(input())\nA = [int(n) for n in input().split()]\nB = [int(n) for n in input().split()]\nC = [int(n) for n in input().split()]\n\nans = sum(B)\nfor i in range(N-1):\n if A[i+1] - A[i] == 1:\n ans += C[A[i]-1]\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3616a0bf83030000fa25","document_content":"n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\nans = 0\ni = -2\nfor j in range(n):\n if a[j]-1 == i+1:\n ans += c[i]\n i = a[j] - 1\n ans += b[i]\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"767cc0d97960598576cd","document_content":"N = int(input())\n\nA =list(map(int,input().split()))\nB =list(map(int,input().split()))\nC =list(map(int,input().split()))\n\n\nb=sum(B)\n\nfor i in range (N-1):\n if (A[i]+1==A[i+1]):\n b=b+C[A[i]-1]\n\n\nprint(b)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d48b1b468e9ee771f69c","document_content":"n=int(input())\na=list(map(int, input().split()))\nb=list(map(int, input().split()))\nc=list(map(int, input().split()))\nsatisfy=0\nfor i in range(n):\n satisfy+=b[a[i]-1]\n if i>=1 and a[i-1]+1==a[i]:\n satisfy+=c[a[i]-2]\nprint(satisfy)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dcfd0d665bc5c998d4ac","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\ndef main():\n score=0\n for i in range(N):\n score += B[A[i]-1]\n if A[i] == A[i-1] + 1 and i>=1:\n score += C[A[i-1]-1]\n\n return score\nprint(main())","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"936469e7c80bb411460f","document_content":"N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nans = B[A[0]-1]\n\nfor i in range(1, N):\n ans += B[A[i]-1]\n if A[i] == A[i-1] + 1:\n ans += C[A[i-1]-1]\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1a77441341561bf3056e","document_content":"import sys\n\n\nn = int(input())\na = [int(t) for t in input().split(' ')]\nmx = [[] for _ in range(n)]\n\nlines = sys.stdin.readlines()\nfor i in range(n-1):\n v1, v2 = (int(t) - 1 for t in lines[i].split(' '))\n mx[v1].append(v2)\n mx[v2].append(v1)\n\ncount = [[0, 0] for _ in range(n)]\n\ntotal = [a.count(1), a.count(2)]\nanswer = 0\n\nOBSERVE = 0\nCHECK = 1\n\nstack = [(OBSERVE, 0, -1)]\nwhile len(stack):\n state, v, from_ = stack.pop()\n if state == OBSERVE:\n stack.append((CHECK, v, from_))\n for nv in mx[v]:\n if nv != from_:\n stack.append((OBSERVE, nv, v))\n else:\n for nv in mx[v]:\n if nv != from_:\n if count[nv][0] == total[0] and count[nv][1] == 0 or count[nv][1] == total[1] and count[nv][0] == 0:\n answer += 1\n count[v][0] += count[nv][0]\n count[v][1] += count[nv][1]\n\n if a[v] != 0:\n count[v][a[v]-1] += 1\n\nprint(answer)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"757876ef60a01bf8bc17","document_content":"import sys\nfrom collections import defaultdict\nn = int(input())\n#n,k = [int(__) for __ in raw_input().split()]\narr = [int(__) for __ in input().split()]\nsactive = set()\nsactive.add(0)\nnums = [0] * n\nd1 = defaultdict(set)\nd2 = defaultdict(set)\nd = defaultdict(set)\nlines = sys.stdin.readlines()\nfor i in range(n-1):\n sactive.add(i+1)\n s,f = [int(__) for __ in lines[i].strip().split()]\n s -= 1\n f -= 1\n d[s].add(f)\n d[f].add(s)\n nums[f] += 1\n nums[s] += 1\n\nleaves = set()\n\n\n\nfor i in range(n):\n if nums[i] == 1:\n leaves.add(i)\nwhile len(leaves):\n x = leaves.pop()\n if arr[x] == 0:\n sactive.remove(x)\n nums[x] -= 1\n targ = d[x].pop()\n nums[targ] -= 1\n d[targ].remove(x)\n if nums[targ] == 1:\n leaves.add(targ)\n\nsactive1 = sactive.copy()\nfor targ in d:\n d1[targ] = d[targ].copy()\nnums1 = nums[:]\nnums2 = nums[:]\n\nfor i in range(n):\n if nums1[i] == 1:\n leaves.add(i)\nwhile len(leaves):\n x = leaves.pop()\n if arr[x] != 1:\n sactive1.remove(x)\n nums1[x] -= 1\n targ = d1[x].pop()\n nums1[targ] -= 1\n d1[targ].remove(x)\n if nums1[targ] == 1:\n leaves.add(targ)\n \nsactive2 = sactive.copy()\nfor targ in d:\n d2[targ] = d[targ].copy()\n\nfor i in range(n):\n if nums2[i] == 1:\n leaves.add(i)\nwhile len(leaves):\n x = leaves.pop()\n if arr[x] != 2:\n sactive2.remove(x)\n nums2[x] -= 1\n targ = d2[x].pop()\n nums2[targ] -= 1\n d2[targ].remove(x)\n if nums2[targ] == 1:\n leaves.add(targ)\n\n \nif len(sactive1 & sactive2) > 0:\n print(0)\nelse:\n print(len(sactive) - len(sactive1) - len(sactive2) + 1)\n#print(nums)\n#print('both',sactive)\n#print('1',sactive1)\n#print('2',sactive2)\n#print(d)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0ed0134f310bf82a6e38","document_content":"import sys\ninput=sys.stdin.readline\nn = int(input())\na = [int(t) for t in input().split(' ')]\nmx = [[] for _ in range(n)]\nfor i in range(n-1):\n v1, v2 = list(map(int,input().split()))\n mx[v1-1].append(v2-1)\n mx[v2-1].append(v1-1)\ncount = [[0, 0] for _ in range(n)]\ntotal = [a.count(1), a.count(2)]\nanswer = 0\nOBSERVE = 0\nCHECK = 1\nstack = [(OBSERVE, 0, -1)]\nwhile len(stack):\n #print(stack,count)\n state, vertex, parent = stack.pop()\n if state == OBSERVE:\n stack.append((CHECK, vertex, parent))\n for child in mx[vertex]:\n #print(nv,v,from_)\n if child != parent:\n stack.append((OBSERVE, child, vertex))\n else:\n for child in mx[vertex]:\n if child != parent:\n #print(child,parent,count)\n if count[child][0] == total[0] and count[child][1] == 0 or count[child][1] == total[1] and count[child][0] == 0:\n answer += 1\n count[vertex][0] += count[child][0]\n count[vertex][1] += count[child][1]\n \n if a[vertex] != 0:\n #print(count)\n count[vertex][a[vertex]-1] += 1\n #print(count)\n \nprint(answer)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e501a5254fca96e56763","document_content":"from collections import deque\nimport sys\ninput = sys.stdin.readline\n\nclass Graph(object):\n\t\"\"\"docstring for Graph\"\"\"\n\tdef __init__(self,n,d): # Number of nodes and d is True if directed\n\t\tself.n = n\n\t\tself.graph = [[] for i in range(n)]\n\t\tself.parent = [-1 for i in range(n)]\n\t\tself.directed = d\n\t\t\n\tdef addEdge(self,x,y):\n\t\tself.graph[x].append(y)\n\t\tif not self.directed:\n\t\t\tself.graph[y].append(x)\n\n\tdef bfs(self, root): # NORMAL BFS\n\t\tself.parent = [-1 for i in range(self.n)]\n\t\tqueue = [root]\n\t\tqueue = deque(queue)\n\t\tvis = [0]*self.n\n\t\twhile len(queue)!=0:\n\t\t\telement = queue.popleft()\n\t\t\tvis[element] = 1\n\t\t\tfor i in self.graph[element]:\n\t\t\t\tif vis[i]==0:\n\t\t\t\t\tqueue.append(i)\n\t\t\t\t\tself.parent[i] = element\n\n\tdef dfs(self, root, ans): # Iterative DFS\n\t\tstack=[root]\n\t\tvis=[0]*self.n\n\t\tstack2=[]\n\t\twhile len(stack)!=0: # INITIAL TRAVERSAL\n\t\t\telement = stack.pop()\n\t\t\tif vis[element]:\n\t\t\t\tcontinue\n\t\t\tvis[element] = 1\n\t\t\tstack2.append(element)\n\t\t\tfor i in self.graph[element]:\n\t\t\t\tif vis[i]==0:\n\t\t\t\t\tself.parent[i] = element\n\t\t\t\t\tstack.append(i)\n\n\t\twhile len(stack2)!=0: # BACKTRACING. Modify the loop according to the question\n\t\t\telement = stack2.pop()\n\t\t\tm = [0,0]\n\t\t\tfor i in self.graph[element]:\n\t\t\t\tif i!=self.parent[element]:\n\t\t\t\t\tm[0] += ans[i][0]\n\t\t\t\t\tm[1] += ans[i][1]\n\t\t\tif arr[element] == 1:\n\t\t\t\tm[0] += 1\n\t\t\telif arr[element] == 2:\n\t\t\t\tm[1] += 1\n\t\t\tans[element] = m\n\t\treturn ans\n\n\tdef shortestpath(self, source, dest): # Calculate Shortest Path between two nodes\n\t\tself.bfs(source)\n\t\tpath = [dest]\n\t\twhile self.parent[path[-1]]!=-1:\n\t\t\tpath.append(parent[path[-1]])\n\t\treturn path[::-1]\n\n\tdef ifcycle(self):\n\t\tself.bfs(0)\n\t\tqueue = [0]\n\t\tvis = [0]*n\n\t\tqueue = deque(queue)\n\t\twhile len(queue)!=0:\n\t\t\telement = queue.popleft()\n\t\t\tvis[element] = 1\n\t\t\tfor i in graph[element]:\n\t\t\t\tif vis[i]==1 and i!=parent[element]:\n\t\t\t\t\treturn True\n\t\t\t\tif vis[i]==0:\n\t\t\t\t\tqueue.append(i)\n\t\t\t\t\tvis[i] = 1\n\t\treturn False\n\n\tdef reroot(self, root, ans):\n\t\tstack = [root]\n\t\tcount = 0\n\t\tvis = [0]*self.n\n\t\twhile len(stack)!=0:\n\t\t\te = stack[-1]\n\t\t\t# print (e,ans)\n\t\t\tif vis[e]:\n\t\t\t\tstack.pop()\n\t\t\t\tif self.parent[e]!=-1:\n\t\t\t\t\tans[self.parent[e]][0] += ans[e][0]\n\t\t\t\t\tans[self.parent[e]][1] += ans[e][1]\n\t\t\t\t\tif self.parent[self.parent[e]]!=-1:\n\t\t\t\t\t\tans[self.parent[e]][0] -= ans[self.parent[self.parent[e]]][0]\n\t\t\t\t\t\tans[self.parent[e]][1] -= ans[self.parent[self.parent[e]]][1]\n\t\t\t\tcontinue\n\t\t\tvis[e]=1\n\t\t\tfor i in self.graph[e]:\n\t\t\t\tif not vis[i]:\n\t\t\t\t\tstack.append(i)\n\t\t\tif self.parent[e]==-1:\n\t\t\t\tcontinue\n\t\t\tans[self.parent[e]][0] -= ans[e][0]\n\t\t\tans[self.parent[e]][1] -= ans[e][1]\n\t\t\tif self.parent[self.parent[e]]!=-1:\n\t\t\t\tans[self.parent[e]][0] += ans[self.parent[self.parent[e]]][0]\n\t\t\t\tans[self.parent[e]][1] += ans[self.parent[self.parent[e]]][1]\n\t\t\tif 0 in ans[e] and 0 in ans[self.parent[e]]:\n\t\t\t\tcount+=1\n\t\treturn count\n\n\nn = int(input())\ng = Graph(n,False)\narr = list(map(int,input().split()))\nfor i in range(n-1):\n\tx,y = list(map(int,input().split()))\n\tg.addEdge(x-1,y-1)\nans = [[0,0] for i in range(n)]\na = g.dfs(0,ans)\nprint(g.reroot(0,a))\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"91da32ca3660c5737768","document_content":"d,l = list(map(int,input().split()))\n\na = list(map(int,input().split()))\nletters = list(map(int,input().split()))\n\npos = [0] * (1+d)\n\nfor i,x in enumerate(a):\n pos[i+1] = pos[i] + x\n\nres = []\ni = 1\nfor letter in letters:\n while pos[i] a[id]:\n minus += a[id]\n id += 1\n else:\n print(id + 1, i - minus)\n break","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"435c3d6dd3c0a2179618","document_content":"n, m = map(int, input().split())\nhosts = [0]\nhosts += list(map(int, input().split()))\nfor i in range(1, n + 1):\n hosts[i] += hosts[i - 1]\nletters = list(map(int, input().split()))\nj = 0\nfor i in range(m):\n while hosts[j] < letters[i]:\n j += 1\n print(j, letters[i] - hosts[j - 1])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7f1ec07786048b9669e8","document_content":"\nn,m=(list(map(int,input().strip().split(' '))))\narr=list((list(map(int,input().strip().split(' ')))))\ndp=[arr[0]]\nfor i in range(1,n):\n dp.append(dp[i-1]+arr[i])\nbrr=list((list(map(int,input().strip().split(' ')))))\nstart = 0\nfor i in range(m):\n x=brr[i]\n for j in range(start,n):\n if(dp[j]>=brr[i]):\n if(j!=0):\n print(j+1,x-dp[j-1])\n else:\n print(j+1,x)\n start = j\n break\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d43768fb2aa33ad9d206","document_content":"from bisect import bisect_left\nfrom itertools import accumulate\n\nn, m = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ns_a = [0] + list(accumulate(a))\nans = list()\n\nfor el in b:\n ind = bisect_left(s_a, el)\n num = el - s_a[ind - 1]\n\n ans.append(f'{ind} {num}')\n\nprint('\\n'.join(ans))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9673cfb69a35a974c383","document_content":"n,m = list(map(int,input().split()))\nrooms = [int(i) for i in input().split()]\nletters = [int(i) for i in input().split()]\n\nroom = rooms[0]\nroomsum = 0\ncnt = 1\nfor i in range(m):\n if letters[i]<=room:\n print(cnt,letters[i]-roomsum)\n else:\n while letters[i]>room:\n roomsum = room\n room += rooms[cnt]\n cnt += 1\n print(cnt,letters[i]-roomsum)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"eaf3008c58bb4c7a2e08","document_content":"T = input().split(' ')\nn = int(T[0])\nm = int(T[1])\nP = input().split(' ')\nfor i in range(len(P)):\n P[i] = int(P[i])\nfor i in range(1, len(P)):\n P[i] += P[i-1]\nQ = input().split(' ')\nfor i in range(len(Q)):\n Q[i] = int(Q[i])\na = 0\nb = 0\nc = 0\nd = 0\nwhile c < len(Q):\n b = Q[c]\n if b > P[a]:\n d = P[a]\n a+=1\n else:\n print(a+1, end=' ')\n print(b - d)\n c+=1\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c0686d5abc4bcfcfa690","document_content":"n,m=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nj=0\nmk=a[0]\ni=0\nwhile(i!=m):\n if b[i]>mk:\n j+=1\n mk+=a[j]\n else:\n print(j+1,a[j]-(mk-b[i]))\n i+=1","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"501a970ab85ac4e0a485","document_content":"#!\/usr\/bin\/env python3\nfrom sys import stdin, stdout\nfrom bisect import bisect, bisect_left\n\ndef rint():\n return list(map(int, stdin.readline().split()))\n#lines = stdin.readlines()\n\n\nn, m = rint()\na = list(rint())\nb = list(rint())\n\nc =[]\nc.append(a[0])\nfor i in range(1,n):\n c.append(c[i-1]+a[i])\n\nfor i in range(m):\n ii = bisect_left(c, b[i])\n if ii == 0:\n print(1, b[i])\n else:\n print(ii+1,b[i] - c[ii-1])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0b645edb460dec61527e","document_content":"from itertools import accumulate\n\ndef main():\n\tn, m = [int(_) for _ in input().split()]\n\ta = [int(_) for _ in input().split()]\n\tb = [int(_) for _ in input().split()]\n\n\n\n\ti = 0\n\tacc = 0\n\tfor x in b:\n\t\twhile acc + a[i] < x:\n\t\t\tacc += a[i]\n\t\t\ti += 1\n\t\tprint(i + 1, x - acc)\n\n\ndef __starting_point():\n\tmain()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d76030c050df416ab16f","document_content":"n, m = [int(i) for i in input().split()]\nrooms = [0] + [int(i) for i in input().split()]\nfor i in range(2, n + 1):\n\trooms[i] += rooms[i - 1]\nletters = [int(i) for i in input().split()]\nfor i in range(m):\n\tp = 0\n\tq = n\n\twhile True:\n\t\tposition = (p + q) \/\/ 2\n\t\tif rooms[position] < letters[i]:\n\t\t\tp = position\n\t\telse:\n\t\t\tq = position\n\t\tif q - p <= 1:\n\t\t\tprint(q, letters[i] - rooms[p])\n\t\t\tbreak\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"01349d6d0777abc85bff","document_content":"from bisect import bisect_left\n\na, b = list(map(int, input().split()))\nflats = list(map(int, input().split()))\nlets = list(map(int, input().split()))\n\nnflats = []\ns = 0\nfor x in flats:\n s += x\n nflats.append(s)\n\nfor x in lets:\n y = bisect_left(nflats, x)\n if y != 0:\n print(y+1, x - nflats[y-1])\n else:\n print(y+1, x)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3d9c222e78a98d99f876","document_content":"from bisect import bisect_left\n\nn, m = list(map(int, input().split()))\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\nt = [0]\ns = 0\nfor x in a:\n s += x\n t.append(s)\n\nfor x in b:\n p = bisect_left(t, x)\n print(p, x - t[p - 1])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1f9c8cd2f81aa73d7c11","document_content":"n, m = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nprefix = [0]\nsumm = 0\nfor i in range(n - 1):\n\tsumm += a[i]\n\tprefix.append(summ)\ndef binsearch(x, a):\n\tleft = 0\n\tright = len(prefix)\n\twhile left != right - 1:\n\t\tmid = (left + right) \/\/ 2\n\t\tif (x[mid] < a):\n\t\t\tleft = mid\n\t\telse:\n\t\t\tright = mid\n\treturn left\nfor i in range(m):\n\tq = binsearch(prefix, b[i])\n\tv = b[i] - prefix[q]\n\tprint(q + 1, v)\n\t\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7b4a4223f58d0960f7e3","document_content":"n,m=map(int,input().split())\narr1=list(map(int,input().split()))\narr=list(map(int,input().split()))\narr2=[]\nsumx=0\nfor i in range(n):\n\tsumx+=arr1[i]\n\tarr2.append(sumx)\nj=0\nk=0\nwhile(jarr2[k]):\n\t\t\tk+=1\n\t\tprint(k+1,arr[j]-arr2[k-1])\n\tj+=1","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"02200e18cbf6fa070278","document_content":"import sys\nimport bisect\n\n\nnext(sys.stdin)\n\nais = list(map(int, next(sys.stdin).rstrip().split()))\n\nrooms = list(map(int, next(sys.stdin).rstrip().split()))\n\nborders = [ais[0]]\nfor a in ais[1:]:\n borders.append(borders[-1] + a)\n\nresult = []\n\nfor room in rooms:\n dorm_num = bisect.bisect_left(borders, room) + 1\n if dorm_num > 1:\n room -= borders[dorm_num - 2]\n result.append('%s %s' % (dorm_num, room))\n\nfor r in result:\n print(r)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8298eda2faf92b922b9e","document_content":"R = lambda: list(map(int, input().split()))\n\nn, m = R()\na = list(R())\na.append(10**6)\n\ns = 0\nf = 0\n\nfor b in R():\n while s < b:\n s += a[f]\n f += 1\n print(f, b - s + a[f-1])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"024d25886f9c6e0b6213","document_content":"import bisect,itertools\nn,m=map(int,input().split())\naa=list(map(int,input().split()))\na,c=[0]+list(itertools.accumulate(aa)),0\nfor b in input().split():\n b=int(b)\n f=bisect.bisect_left(a,b,lo=c)\n k=b-a[f-1]\n print(f,k)\n c=max(c,f)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a098e8ab594e78bb1027","document_content":"def main():\n n, m = list(map(int, input().split()))\n room = [int(x) for x in input().split()]\n letter = [int(x) for x in input().split()]\n\n room_num = 0\n j = 0\n for d in range(n):\n while j < m and letter[j] <= room_num + room[d]:\n r = letter[j] - room_num\n print(d+1, r)\n j += 1\n room_num += room[d]\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4a40de67dc5a775d2571","document_content":"read=lambda:map(int,input().split())\nn,m=read()\na=list(read())\nb=list(read())\npos=0\npre=0\nfor i in b:\n d=0\n while True:\n d=i-1-pre\n if d>=a[pos]: pre+=a[pos];pos+=1\n else: break\n print(pos+1,d+1)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fe352d089cae0505932d","document_content":"import bisect\n\n\ndef read_nums():\n return [int(x) for x in input().split()]\n\n\ndef main():\n n, m = read_nums()\n num_rums = read_nums()\n\n s = 0\n run_sums = [0]\n for run_num in num_rums:\n s += run_num\n run_sums.append(s)\n\n letters = read_nums()\n res = []\n for letter in letters:\n index = bisect.bisect_left(run_sums, letter)\n res.append((index, letter - run_sums[index - 1]))\n\n for r in res:\n print(r[0], r[1])\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8edfb5d71ca7ab59a802","document_content":"n,m=[int(x) for x in input().strip().split(' ')]\na=[int(x) for x in input().strip().split(' ')]\nb=[int(x) for x in input().strip().split(' ')]\ns=[1]*(n+1)\nfor i in range(1,n+1):\n s[i]=s[i-1]+a[i-1]\nidx=0\nfor i in range(m):\n while True:\n if b[i]prefixsum[ptr]:\n\t\tptr+=1\n\n\troom=blist[i]-prefixsum[ptr-1]\n\tprint(ptr,room)\n\t\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1facfc058f0d4d59de62","document_content":"from bisect import bisect_left\n\nn, l = list(map(int, input().split()))\nfl = list(map(int, input().split()))\nlet = list(map(int, input().split()))\n\npref = [0]\nfor i in range(n):\n pref.append(fl[i] + pref[i])\n\nprev = 0\nfor l in let:\n dorm = bisect_left(pref, l, lo=prev)\n prev = dorm\n print(dorm, l - pref[dorm - 1])\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2eeb8c01744130819e65","document_content":"# ========== \/\/\\\\ \/\/|| ||====\/\/||\n# || \/\/ \\\\ || || \/\/ ||\n# || \/\/====\\\\ || || \/\/ ||\n# || \/\/ \\\\ || || \/\/ ||\n# ========== \/\/ \\\\ ======== ||\/\/====|| \n# code\n\n\ndef solve():\n x = int(input())\n ans = 0\n ok = 0\n\n for i in range(1, 10):\n n = 0\n for j in range(4):\n n = n * 10 + i\n ans += (j + 1)\n if n == x:\n ok = 1\n break\n if ok:\n break\n print(ans)\n\ndef main():\n t = 1\n t = int(input())\n for _ in range(t):\n solve()\n\ndef __starting_point():\n main()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b85c32a91eed3e726453","document_content":"def solve():\n n = input()\n print(int(n) % 10 * 10 + len(n) * (len(n) + 1) \/\/ 2 - 10)\nfor i in range(int(input())):\n solve()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"be7bd66513f8ccb1abce","document_content":"from math import *\nfrom bisect import *\nfrom collections import *\nfrom random import *\nfrom decimal import *\nfrom itertools import *\nimport sys\ninput=sys.stdin.readline\ndef inp():\n return int(input())\ndef st():\n return input().rstrip('\\n')\ndef lis():\n return list(map(int,input().split()))\ndef ma():\n return list(map(int,input().split()))\nt=inp()\nwhile(t):\n t-=1\n n=inp()\n x=n%10\n s=10*(x-1)\n l=len(str(n))\n s+=(l*(l+1))\/\/2\n print(s)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3366615252ae24a2997e","document_content":"rn=lambda:int(input())\nrl=lambda:list(map(int,input().split()))\nrns=lambda:map(int,input().split())\nrs=lambda:input()\nyn=lambda x:print('Yes') if x else print('No')\nYN=lambda x:print('YES') if x else print('NO')\n\nfor _ in range(rn()):\n x=rs()\n n=int(x[0])\n ans=10*(n-1)\n for i in range(len(x)+1):\n ans+=i\n print(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"57155d817ed126ecd263","document_content":"for _ in range(int(input())):\n\tn=int(input())\n\tans=0\n\tfor i in range(1,10):\n\t\tf=0\n\t\tfor j in range(1,5):\n\t\t\tk=int(str(i)*j)\n\t\t\tans+=len(str(k))\n\t\t\tif k==n:f=1;break\n\t\tif f:break\n\tprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ef6f79a4626238b614e0","document_content":"import sys\ninput = sys.stdin.readline\n\ndef main():\n x = input().strip()\n n = int(x[0])\n l = len(x)\n ans = 10 * (n - 1) + l * (l + 1) \/\/ 2\n print(ans)\n \nfor _ in range(int(input())):\n main()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8f300e4ee2086fcf06fe","document_content":"for t in range(int(input())):\n x = input()\n ans = []\n for i in range(1,10):\n for j in range(1,5):\n ans.append(str(i)*j)\n cnt = 0\n for i in ans:\n if i==x:\n cnt+=len(i)\n break\n else:\n cnt+=len(i)\n print(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ef34adf5b1f20caf23f5","document_content":"t = int(input())\nfor _ in range(t):\n x = input()\n ans = 0\n ans += (int(x[0])-1)*10\n ans += len(x)*(len(x)+1)\/\/2\n print(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7feff120f90fc42b92ed","document_content":"for __ in range(int(input())):\n n = input()\n ans = (int(n[0]) - 1) * 10 + 1\n if len(n) >= 2:\n ans += 2\n if len(n) >= 3:\n ans += 3\n if len(n) >= 4:\n ans += 4\n print(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bcb7a6d404c0e3fa9935","document_content":"import sys, math\nimport io, os\n#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n#from bisect import bisect_left as bl, bisect_right as br, insort\n#from heapq import heapify, heappush, heappop\n#from collections import defaultdict as dd, deque, Counter\n#from itertools import permutations,combinations\ndef data(): return sys.stdin.readline().strip()\ndef mdata(): return list(map(int, data().split()))\ndef outl(var) : sys.stdout.write(' '.join(map(str, var))+'\\n')\ndef out(var) : sys.stdout.write(str(var)+'\\n')\n#from decimal import Decimal\n#from fractions import Fraction\n#sys.setrecursionlimit(100000)\n#INF = float('inf')\nmod = int(1e9)+7\n\n\nfor t in range(int(data())):\n s=data()\n ans=10*int(s[0])-10+(len(s)*(len(s)+1))\/\/2\n out(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2929dc6f2e4ff271e6d0","document_content":"for _ in range(int(input())):\n x = int(input())\n\n c = 0\n for i in range(1, 10):\n k = i\n\n while i <= 10000:\n c += len(str(i))\n\n if i == x:\n break\n\n i *= 10\n i += k\n\n else:\n continue\n\n break\n\n print(c)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c729446a19a85f86f1d7","document_content":"from sys import stdin, stdout\ninput = stdin.readline\nfrom collections import defaultdict as dd\nimport math\ndef geti(): return list(map(int, input().strip().split()))\ndef getl(): return list(map(int, input().strip().split()))\ndef gets(): return input()\ndef geta(): return int(input())\ndef print_s(s): stdout.write(s+'\\n')\n\ndef solve():\n for _ in range(geta()):\n a=geta()\n ans=0\n ans=10*(a%10-1)\n while a:\n ans+=len(str(a))\n a\/\/=10\n print(ans)\n\n\ndef __starting_point():\n solve()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ceba5d54a9b9e2316a33","document_content":"t=int(input())\nfor _ in range(t):\n x=input()\n a=int(x[0])\n b=len(x)\n print(10*(a-1)+(b*(b+1))\/\/2)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"47f7535731e8e2cee85c","document_content":"import math\nimport string\nimport random\nfrom random import randrange\nfrom collections import deque\nfrom collections import defaultdict\n\ndef solve(n):\n ans = 0\n\n k = n%10\n \n ans += 10*(k-1)\n \n f = len(str(n))\n \n for i in range(1, f+1):\n ans += i\n\n print(ans)\n return \n\ndef main():\n t = int(input())\n while t>0:\n t-=1\n \n n = int(input())\n # s = input().strip()\n # x,y = map(int, input().strip().split(\" \"))\n # arr = list(map(int, input().strip().split(\" \")))\n \n solve(n)\n \n return\n\ndef test():\n arr_size = 25\n test_cases = 100\n min_range = -100\n max_range = 100\n str_size = 30\n step = 1\n \n for i in range(test_cases):\n k = []\n # s = ''.join(random.choices(string.ascii_lowercase, k = str_size))\n \n for j in range(arr_size):\n num = randrange(min_range, max_range, step)\n k.append(num)\n \n solve(n, arr)\n print(\"<-------- DEBUG ----------->\")\n\n return \n\ndef __starting_point():\n main()\n # test()\n \n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cde0100ef71b5c78bbe6","document_content":"import sys\ninput=sys.stdin.readline\nfrom collections import defaultdict as dc\nfrom bisect import bisect_right\nimport math\nfor _ in range(int(input())):\n n=int(input())\n x=n%10\n c=10*(x-1)\n s=str(n)\n for i in range(len(s)):\n c+=i+1\n print(c)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"93e3f624c07165aaf013","document_content":"for _ in range(int(input())):\n s=input()\n ans=10*(int(s[0])-1)\n l=len(s)\n if l==1:\n ans+=1\n elif l==2:\n ans+=3\n elif l==3:\n ans+=6\n else:\n ans+=10\n print(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a1270e78caa4f7b283da","document_content":"t=int(input())\nfor i in range(t):\n n=input()\n z=len(n)\n k=int(n)%10\n print(round((k-1)*10+(z*(z+1))\/2))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2b32788d15afe568d169","document_content":"import math\ntest = int(input())\nfor t in range(test):\n tt = 0\n pp = 0\n cc = \"\"\n ss = \"\"\n dd = 1\n cnttt = 0\n #write yoour code here\n x = int(input())\n a = x;cnt = 0\n while(a!=0):\n a=a\/\/10\n cnt+=1\n a = x%10\n ans = (a-1)*10+cnt*(cnt+1)\/\/2\n print(ans)\n \n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5e857383206f582efe58","document_content":"'''\n Auther: ghoshashis545 Ashis Ghosh\n College: jalpaiguri Govt Enggineering College\n\n'''\nfrom os import path\nimport sys\nfrom heapq import heappush,heappop\nfrom functools import cmp_to_key as ctk\nfrom collections import deque,defaultdict as dd \nfrom bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\nfrom itertools import permutations\nfrom datetime import datetime\nfrom math import ceil,sqrt,log,gcd\ndef ii():return int(input())\ndef si():return input().rstrip()\ndef mi():return list(map(int,input().split()))\ndef li():return list(mi())\nabc='abcdefghijklmnopqrstuvwxyz'\nmod=1000000007\n# mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\ndef bo(i):\n return ord(i)-ord('a')\n\nfile = 1\n\n\n\n \ndef solve():\n\n\n \n\n for _ in range(ii()):\n\n s = si()\n x = [1,3,6,10]\n n = len(s)\n x1 = int(s[0]) \n print(10*(x1-1) + x[n-1])\n \n\n \n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \ndef __starting_point():\n\n if(file):\n\n if path.exists('input.txt'):\n sys.stdin=open('input.txt', 'r')\n sys.stdout=open('output.txt','w')\n else:\n input=sys.stdin.readline\n solve()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ca43afd1507d0934ad97","document_content":"t = int(input())\n\nfor _ in range(t):\n n = int(input())\n counting = 0\n is_done = False\n for i in range(1,10):\n for c in range(1,5):\n curr_int = int(str(i) * c)\n counting += c\n if curr_int == n:\n print(counting)\n is_done= True\n break\n\n if is_done:\n break\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4c4a4e32fcd07c73e609","document_content":"for _ in range(int(input())):\n n = input()\n c = int(n[0])\n ans = (c - 1) * 10\n k = len(n)\n for i in range(1, k + 1):\n ans += i\n print(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"caea6e08573c92a5ecf0","document_content":"def main():\n x = int(input())\n n = int(str(x)[0])\n l = len(str(x))\n ans = 10 * (n-1)\n ans += l * (l+1) \/\/ 2\n print(ans)\n\n\n\nfor _ in range(int(input())):\n main()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"50be08864cde6e159283","document_content":"for _ in range(int(input())):\n x = int(input())\n a = x;cnt = 0\n while(a!=0):\n a=a\/\/10\n cnt+=1\n a = x%10\n ans = (a-1)*10+cnt*(cnt+1)\/\/2\n print(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"facd9354295cec0877ad","document_content":"t = int(input())\n\nfor test in range(t):\n x = int(input())\n a = len(str(x))\n print((x % 10 - 1) * 10 + a * (a + 1) \/\/ 2)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a86f3265ff2904417c56","document_content":"import sys\n\n\ndef read(func=int):\n return func(sys.stdin.readline().strip())\n\ndef readList(func=int):\n return list(map(func, sys.stdin.readline().strip().split()))\n\n\nt = read()\nfor _ in range(t):\n num = read()\n tot = ((num % 10) - 1) * 10\n for i in range(len(str(num))):\n tot += i + 1\n print(tot)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"db22a8d67f9753cb5c4b","document_content":"import bisect\n\nN,M,X = map(int,input().split())\nA = list(map(int,input().split()))\n\nindex = bisect.bisect_left(A,X)\nans = min(M-index,index)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9420ab75b1458ceab013","document_content":"n,m,x=map(int, input().split())\na=[int(i) for i in input().split()]\n\ncount_1=0\nfor i in range(x):\n if i in a:\n count_1+=1\n \ncount_2=0\nfor i in range(x,n):\n if i in a:\n count_2+=1\n \nprint(min(count_1, count_2))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"325fa8d77a236b83bed9","document_content":"# B - Toll Gates\n# https:\/\/atcoder.jp\/contests\/abc094\/tasks\/abc094_b\n\nn, m, x = list(map(int, input().split()))\na = list(map(int, input().split()))\n\ncost1 = 0\ncost2 = 0\n\nfor i in range(x, 0, -1):\n if i in a:\n cost1 += 1\n\nfor i in range(x, n):\n if i in a:\n cost2 += 1\n\ncost = [cost1, cost2]\nprint((min(cost)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f81be383061577234c0e","document_content":"# 094b\n\ndef atc_094b(NMX: str, Ai_input: str) -> int:\n N, M, X = list(map(int, NMX.split(\" \")))\n Ai = [int(ai) for ai in Ai_input.split(\" \")]\n\n up_cost = 0\n down_cost = 0\n\n for i in range(X + 1, N + 1):\n if i in Ai:\n up_cost += 1\n for i in range(X - 1, 0, -1):\n if i in Ai:\n down_cost += 1\n return min(up_cost, down_cost)\n\n\nNMX_input_value = input()\nAi_input_value = input()\nprint((atc_094b(NMX_input_value, Ai_input_value)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"871733b54967af594a7c","document_content":"n,m,x=map(int,input().split())\nam=sorted(map(int,input().split()))\nprint(min(len(list(filter(lambda a:a x:\n break\n\nans = min(i, m - i)\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"faeff7e327c883db8716","document_content":"total_square, total_toll_gate, current_square = map(int, input().split())\ntoll_gate_square = list(map(int, input().split()))\nroute1 = 0\nroute2 = 0\nfor i in range(total_toll_gate):\n if toll_gate_square[i] < current_square:\n route1 += 1\n else:\n route2 += 1\nprint(min(route1, route2))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"458ee0111bb21785474c","document_content":"# B - Toll Gates\n\n# N M X\nN, M, X = list(map(int, input().split()))\nmy_list = list(map(int, input().split(maxsplit=M)))\ncount_start = 0\ncount_goal = 0\n\n# 0\u3078\u884c\u304f\u30d1\u30bf\u30fc\u30f3\nfor i in range(1, X):\n if i in my_list:\n count_start += 1\n\nfor i in range(X, N):\n if i in my_list:\n count_goal += 1\n\nif count_start >= count_goal:\n answer = count_goal\nelse:\n answer = count_start\n\nprint(answer)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4aedc860f1b15a4081bc","document_content":"n,m,x=map(int,input().split())\nA=list(map(int,input().split()))\nprint(min(sum([ax for a in A])))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"23081bd268a8f1d35f70","document_content":"n,m,x = map(int,input().split())\na=list(map(int,input().split()))\ncnt1, cnt2 = 0, 0\nfor i in range(m):\n if 0 <= a[i] < x:\n cnt1 += 1\n if x < a[i] <= a[-1]:\n cnt2 += 1\nprint(min(cnt1, cnt2))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d1f7cebdf36f2ac6af23","document_content":"N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nX_high = 0\nX_low = 0\n\nfor i in range(X, N + 1):\n if i in A:\n X_high += 1\n\nfor i in range(0, X + 1):\n if i in A:\n X_low += 1\n\nprint(min(X_high, X_low))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5f477a84e345c9da8884","document_content":"N,M,X=map(int,input().split())\nAi=list(map(int,input().split()))\n\ngoto_0=0\ngoto_N=0\n\nfor i in range(X,0,-1):\n if i in Ai:\n goto_0 += 1\n\nfor i in range(X,N):\n if i in Ai:\n goto_N += 1\n\nprint(min(goto_0,goto_N))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"19efab142f06c9913ae1","document_content":"N, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\nl1 = []\nl2 = []\n\nfor i in A:\n if X > i:\n l1.append(i)\n else:\n l2.append(i)\n\nprint((min(len(l1), len(l2))))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"62c83dfa2e2d13655001","document_content":"def tool_gate(now: int, gate_list: list) -> int:\n back_count = sum(i < now for i in gate_list)\n forward_count = sum(i > now for i in gate_list)\n return min(back_count, forward_count)\n\n\ndef __starting_point():\n n, m, now = list(map(int, input().split()))\n gate_list = list(map(int, input().split()))\n print((tool_gate(now, gate_list)))\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a452905c90aaaa8f82df","document_content":"n,m,x = map(int,input().split())\na =list(map(int,input().split()))\nstart = sum(i>x for i in a)\nend = sum(i X:\n b = [i for i in A if i < X]\nelse:\n for i in A[::-1]:\n b = [i for i in A if i > X]\n \nprint(min(len(b),M - len(b)))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a9b30867faa31823db8a","document_content":"# \u6570\u5024\u306e\u53d6\u5f97\nlast,fee,cur = map(int,input().split())\nfeesqu = list(map(int,input().split()))\ntotal = len(feesqu)\n\n# \u30b3\u30b9\u30c8\u306e\u6700\u5c0f\u5024\u3092\u51fa\u529b\ntcost = 0\ngcost = 0\nfor cnt in range(0,total,1):\n if feesqu[cnt] < cur:\n tcost += 1\ngcost = total - tcost\nprint(min(tcost,gcost))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"21feaf08e5bae59487ec","document_content":"N, M, X = list(map(int, input().split()))\na_point = list(map(int,input().split()))\nlg = 0\nsl = 0\nfor i in range(len(a_point)):\n if X < a_point[i]:\n lg += 1\n else:\n sl += 1\n\nif lg > sl:\n print(sl)\nelse:\n print(lg)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c32bbdd51ea074eb5e1d","document_content":"N, M, X = map(int,input().split())\nfee = list(map(int,input().split()))\nresult_1 = []\nresult_2 = []\n\nfor i in fee:\n if i > X:\n result_1.append(i)\n else:\n result_2.append(i)\n\nresult = (min(len(result_1) ,len(result_2)))\nprint(result)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fd4c0117c05ed84d7803","document_content":"n,m,x=map(int,input().split())\na=list(map(int,input().split()))\nans=0\nfor i in a:\n if i int:\n i = bisect.bisect_left(a, x)\n return min(i, len(a) - i)\n\n\ndef main():\n n, m, x = map(int, input().split())\n a = list(map(int, input().split()))\n print(answer(n, m, x, a))\n\n\ndef __starting_point():\n main()\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7bdd5326de8b617961fe","document_content":"N, M, X = [int(i) for i in input().split()]\nAS = [int(i) for i in input().split()]\n\ncnt1 = 0\nfor i in range(0, X):\n if i in AS:\n cnt1 += 1\n\ncnt2 = 0\nfor i in range(X+1, N+1):\n if i in AS:\n cnt2 += 1\n\nprint((cnt1 if cnt1 < cnt2 else cnt2))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9727112a492ece29238d","document_content":"# \u5165\u529b\nn, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\n\ngoto_goal_0 = 0 # 0\u307e\u3067\u306e\u30b3\u30b9\u30c8\ngoto_goal_n = 0 # n\u307e\u3067\u306e\u30b3\u30b9\u30c8\n\n# x \u304b\u3089 0 \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x - 1, 0, -1): # x-1 \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30c7\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n if i in a:\n goto_goal_0 += 1\n # print(\"0 is {}\".format(goto_goal_0))\n\n# x \u304b\u3089 n \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x, n + 1): # x \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n if i in a:\n goto_goal_n += 1\n # print(\"n is {}\".format(goto_goal_n))\n\nif goto_goal_0 < goto_goal_n:\n print(goto_goal_0)\nelse:\n print(goto_goal_n)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a61dba15057020cd83a1","document_content":"N, M, X = map(int,input().split())\nA = map(int,input().split())\n\nL = 0\nR = 0\n\nfor ai in A:\n if ai < X:\n L = L + 1\n else:\n R = R + 1\nprint(min(L, R))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"42a7319ea92c12e17f4d","document_content":"import sys\ninput = sys.stdin.readline\n \nN,M,X = list(map(int,input().split()))\nA = list(map(int,input().split()))\ncount = 0\nif A[int(M\/2)] > X:\n for i in A:\n if i < X:\n count += 1\n else:\n break\nelse:\n for i in A[::-1]:\n if i > X:\n count += 1\n else:\n break\n \nprint((min(count,M - count)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3474bfc1ecb5aceb340f","document_content":"N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nright = [int(i) for i in A if i > X]\nleft = [int(i) for i in A if i < X]\n\nr = len(right)\nl = len(left)\n\nif r < l:\n print(r)\n\nelse:\n print(l)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bd586f59299ae707ecb7","document_content":"a = [int(c) for c in input().split()]\nN=a[0]\nM=a[1]\nX=a[2]\nA = [int(c) for c in input().split()]\nA2 = [0]*(N+1)\nfor i in range(M):\n A2[A[i]] = 1\n\ncnt = X\ncost1 = 0\nwhile cnt < N+1:\n cost1+=A2[cnt]\n cnt+=1\n\ncnt = X\ncost2 = 0\nwhile cnt > 0:\n cost2+=A2[cnt]\n cnt-=1\n\nif cost1X:\n count2+=1\nprint((min([count1,count2])))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fc7c561101743f965f7f","document_content":"a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nd=list(map(int,input().split()))\ne=0\nf=0\nfor i in range(b):\n if d[i]>c:\n e=e+1\n if d[i]f:\n print(f)\nelse:\n print(e)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5bb585f0cfcd76111d5e","document_content":"N,M,X=map(int,input().split())\nA=list(map(int,input().split()))\ncnt=len([a for a,i in enumerate(A) if i>=X])\ncnt=min(cnt,M-cnt)\nprint(cnt)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8e65ab515efa3a0d8dac","document_content":"n, m, x = list(map(int, input().split()))\na = list(map(int, input().split()))\ncnt1 = 0\ncnt2 = 0\nx1 = x\nx2 = x\n\nwhile x1 < n+1:\n x1 += 1\n if x1 in a:\n cnt1 += 1\n\nwhile x2 > 0:\n x2 -= 1\n if x2 in a:\n cnt2 += 1\n\n\n\nif cnt1 < cnt2:\n ans = cnt1\nelse:\n ans = cnt2\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"df1f9c2eb78f0e7a6c2a","document_content":"N,M,X=map(int,input().split())\nAi=list(map(int,input().split()))\n\ngoto_0=0\ngoto_N=0\n\nfor i in range(0,X):\n if i in Ai:\n goto_0 += 1\n\nfor i in range(X,N):\n if i in Ai:\n goto_N += 1\n\nprint(min(goto_0,goto_N))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bed020817215f35e5eee","document_content":"n, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\nacc = [0] * (n + 1)\nfor i in a:\n acc[i] = 1\nprint(min(sum(acc[:x]), sum(acc[x:])))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4702a9a90f007c276009","document_content":"num, count_station, my_position = list(map(int, input().split()))\na = list(map(int, input().split()))\nstation_list = list(a)\nspace = num + 1\nfirst_me_cost = 0\nlast_me_cost = 0\n\ndistance_me_first = my_position\ndistance_me_last = num - my_position\n\nfor i in station_list:\n if 1 <= i <= my_position - 1:\n first_me_cost += 1\n\nfor i in station_list:\n if my_position + 1 <= i < num:\n last_me_cost += 1\n\nif first_me_cost > last_me_cost:\n print(last_me_cost)\nelif last_me_cost > first_me_cost:\n print(first_me_cost)\nelif last_me_cost == first_me_cost:\n print(first_me_cost)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6b0dbd0955c11f37b3e5","document_content":"n,m,x=map(int,input().split())\na=list(map(int,input().split()))\nc=x\nans=0\nans1=0\nwhile c:\n ans+=c in a\n c-=1\nwhile x x:\n k = i\n break\nif k==0 or k==n-1:\n print('0')\n return\nelse:\n print((min(k,m-k)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bea98ff5f24acf21dc41","document_content":"S_list = [input() for i in range(2)]\nN, M, X= map(int,S_list[0].split()) \nA_list = list(map(int,S_list[1].split()))\n\nA_goal_N = [i for i in A_list if X < i and i < N]\nA_goal_0 = [i for i in A_list if 0 < i and i < X]\nresult = min(len(A_goal_N),len(A_goal_0))\nprint(result)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"96514d7f97ebc29834f5","document_content":"N, M, X, *A = map(int, open(0).read().split())\n\nl = [0] * N\nfor a in A:\n l[a-1] = 1\n\nprint(min(sum(l[:X]), sum(l[X:])))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1e1937f7986c8ad707b2","document_content":"n, m, x = list(map(int,input().split()))\na = list(map(int,input().split()))\n\ngoal_0 = 0\ngoal_1 = 0\n\nfor i in range(x,0,-1):\n if i in a:\n goal_0 += 1\n\nfor i in range(x,n+1,1):\n if i in a:\n goal_1 += 1\n\nif goal_0 < goal_1:\n print(goal_0)\nelse:\n print(goal_1)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d7de96668c6dc3492c32","document_content":"n,m,x=map(int,input().split())\na=list(map(int, input().split()))\np = 0\nq = 0\nfor i in a:\n if i > x:\n p +=1\n elif i < x:\n q +=1\nprint(min(p,q))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"29dfd9daab5c5a19e407","document_content":"#ABC094 B 3\u756a\u76ee\u304c\u901a\u3089\u306a\u3044\nn,m,x=map(int,input().split())\nList=[int(i) for i in input().split()]\nlcost=0\nrcost=0\nfor a in List:\n if ax:\n rcost+=1\nprint(min(lcost,rcost))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4e1d72e0250dc6f9abb7","document_content":"n,m,x = list(map(int, input().split()))\na = list(map(int, input().split()))\nc0 = 0\ncN = 0\nfor A in a:\n if A > x:\n cN += 1\n elif A < x:\n c0 += 1\nprint(min(c0, cN))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5cf5f0c2265dff9c9a4d","document_content":"n, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\ndef answer(n: int, m: int, x: int, a:list) -> int:\n left = 0\n right = 0\n for i in a:\n if i < x:\n left += 1\n else:\n right += 1\n return min(left, right)\n\nprint(answer(n, m, x, a))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9ce8b0a7dadcb218fccf","document_content":"N, M, X = map(int,input().split())\nL = list(map(int,input().split()))\ns = 0\nb = 0\nfor i in L:\n if i > X:\n s += 1\n else:\n b += 1\n\nif s >= b:\n print(b)\nelse:\n print(s)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7581508eb9dbfe2ce7bf","document_content":"N, M, X = list(map(int,input().split()))\nS = list(map(int,input().split()))\nFees = list(S)\nGoal1 = []\nGoal2 = []\ncount1 = 0\ncount2 = 0\npoint0 = 0\n\nfor i in range(X):\n point0 += 1\n Goal1.append(point0)\n# print(Goal1)\n\nfor j in range(N-X):\n X += 1\n Goal2.append(X)\n# print(Goal2)\n\nfor fee in Fees:\n if fee in Goal1:\n count1 += 1\n if fee in Goal2:\n count2 += 1\n\nif count1 >= count2:\n print(count2)\nif count1 < count2:\n print(count1)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Fee = list(S)\n# print(Fee)\n# count1 = 0\n# count2 = 0\n# for i in range(N-X):\n# X += 1\n# if X in Fee:\n# count1 += 1\n# print(X)\n# for j in range(N):\n# X -= 1\n# if X in Fee:\n# count2 += 1\n#\n# if count1 <= count2:\n# print(count1)\n# if count1 > count2:\n# print(count2)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0e03e863bf802b97368b","document_content":"n, m, x = map(int, input().split())\n\na = list(map(int, input().split()))\n\nr = 0\nl = 0\n\nfor i in a:\n if i > x:\n r += 1\n elif i < x:\n l += 1\n\nprint(min(l,r))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"007d8c7152eaaa24691c","document_content":"from bisect import bisect_left\n\ndef main():\n N, M, X = list(map(int, input().split()))\n A = list(map(int, input().split()))\n mid = bisect_left(A, X)\n l = len(A[:mid])\n r = len(A[mid:])\n print((min(l, r)))\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f2c353eaccd2d04bb3ec","document_content":"n, m, x = map(int, input().split())\n\na = list(map(int, input().split()))\n\nr = 0\nfor i in range(x+1,n):\n for j in range(m):\n if i == a[j]:\n r += 1\n\nl = 0\nfor i in range(x-1, -1, -1):\n for j in range(m):\n if i == a[j]:\n l += 1\n \nprint(min(l,r))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d331c7ed02ee3cd3dcb5","document_content":"\n# \u5165\u529b\nn, m, x = list(map(int, input().split()))\na = list(map(int, input().split()))\n\ngoto_goal_0 = 0 # 0\u307e\u3067\u306e\u30b3\u30b9\u30c8\ngoto_goal_n = 0 # n\u307e\u3067\u306e\u30b3\u30b9\u30c8\n\n# x \u304b\u3089 0 \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x - 1, 0, -1): # x-1 \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30c7\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n if i in a:\n goto_goal_0 += 1\n # print(\"0 is {}\".format(goto_goal_0))\n\n# x \u304b\u3089 n \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x, n + 1): # x \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n if i in a:\n goto_goal_n += 1\n # print(\"n is {}\".format(goto_goal_n))\n\nif goto_goal_0 < goto_goal_n:\n print(goto_goal_0)\nelse:\n print(goto_goal_n)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d6d83241d1b315d97cb5","document_content":"N, M, X = map(int, input().split())\nA = sum(int(i) < X for i in input().split())\nprint(min(A, M - A))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dfdbfbdbd9c85f59499a","document_content":"import numpy as np\n\nn, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\na = np.array(a)\n\nans = min(len(a[ax]))\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f799e7a218ef34883439","document_content":"n,m,x = map(int,input().split())\na = list(map(int,input().split()))\ni = 0\nj = 0\nfor k in a:\n if k>x:\n i += 1\n elif k x:\n less = len(a[:i])\n more = len(a[i:])\n print(min(less, more))\n break","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"495e92a9d4506d08989d","document_content":"N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\ngoal_N = 0\ngoal_0 = 0\n\nfor i in range(X, N + 1):\n if i in A:\n goal_N += 1\n\nfor i in range(0, X + 1):\n if i in A:\n goal_0 += 1\n\nmin_cost = min(goal_N,goal_0)\n\nprint(min_cost)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1e36107bded0270fc451","document_content":"N, M, X = map(int, input().split())\nA = [*map(int, input().split())]\nl = [i < X for i in A]\nr = [i > X for i in A]\nprint(l.count(False) if l.count(False) < r.count(False) else r.count(False))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"53356f18711d46c9d1b2","document_content":"n, m, x = list(map(int, input().split()))\nam = list(map(int, input().split()))\n\n\nclass Solution:\n def __init__(self, n, m, x, am):\n self.n = n\n self.m = m\n self.x = x\n self.am = am\n\n def __make_list(self):\n list_n = [0] * n\n for i in self.am:\n list_n[i - 1] = 1\n return list_n\n\n def answer(self):\n list_n = self.__make_list()\n print((min(sum(list_n[:self.x - 1]), sum(list_n[x - 1:]))))\n\n\nconditions = Solution(n, m, x, am)\nconditions.answer()\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1888c250097464ff845d","document_content":"n,m,x = map(int,input().split())\na = [int(s) for s in input().split()]\ncost = []\ncount = 0\n\nfor i in range(x,n):\n if a.count(i) == 1:\n count += 1\ncost.append(count)\ncount = 0\nc = range(0,x)\nfor i in reversed(c):\n if a.count(i) == 1:\n count += 1\ncost.append(count)\nprint(min(cost))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7e689ce5ad3a36f7c096","document_content":"n,m,x=map(int, input().split())\na=list(map(int, input().split()))\nmas=[0]*(n+1)\nfor i in a:\n mas[i]=1\nprint(min(sum(mas[0:x]),sum(mas[x:n+1])))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"304c9fc5f771bf36d69f","document_content":"n, m, x = input().split()\nlist01 = input().split()\nlist02 = [int(a) for a in list01]\nb = sum(c > int(x) for c in list02)\nd = sum(e < int(x) for e in list02)\nprint(min(b, d))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2a1f9f02569c817487c3","document_content":"N,M,X=list(map(int,input().split()))\nA=list(map(int,input().split()))\nsum1=0\nsum2=0\nfor i in range(M):\n if A[i]x:\n b+=1\nprint(min(s,b))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"72d63da4133ba6462fd3","document_content":"from bisect import bisect_left\nn, m, x, *a = list(map(int, open(0).read().split()))\n\nb = bisect_left(a, x)\nprint((min(m - b, b)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f5a68f7be7be4968362f","document_content":"n,m,x = map(int,input().split())\nlst = list(map(int, input().split()))\n\na_cost = 0\nb_cost = 0\nfor i in lst:\n if i > x:\n a_cost += 1\n else:\n b_cost += 1\nprint(min(a_cost, b_cost))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d5461d5cbb3ac96edd26","document_content":"N, M, X = map(int,input().split())\nA = list(map(int,input().split()))\n\ngoal_N = 0\ngoal_0 = 0\n\nfor i in range(X, N + 1):\n if i in A:\n goal_N += 1\n\nfor i in range(0, X + 1):\n if i in A:\n goal_0 += 1\n\nmin_cost = min(goal_N,goal_0)\n\nprint(min_cost)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"97561136ad94087798ca","document_content":"n, m, x = map(int, input().split())\n\nback = 0\nfor a in map(int, input().split()):\n if a < x:\n back += 1\nelse:\n print(min(back, m - back))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"589f1c495410a18bd247","document_content":"N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nl_cost = 0\ng_cost = 0\n\nfor i in A:\n if i > X:\n l_cost += 1\n else:\n g_cost += 1\n \nprint(min(l_cost, g_cost))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1c86cefa53a66385dd41","document_content":"_, m, x = map(int, input().split())\n\nback = 0\nfor a in map(int, input().split()):\n if a < x:\n back += 1\nelse:\n print(min(back, m - back))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bb25f3c15202a7815daf","document_content":"N,M,X=list(map(int,input().split()))\nA=list(map(int,list(input().split())))\ncountA=0\ncountB=0\nfor i in A:\n if i>X:\n countA+=1\n if i a:\n right += 1\n elif X < a:\n left += 1\n\nprint((min(right, left)))\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6315fa3390ab51c1976e","document_content":"n,m,x = map(int,input().split())\na = list(map(int,input().split()))\n\n# \u5c0f\u3055\u3044\u307b\u3046\u306e\u6599\u91d1\u6240\u306e\u6570\nsmall_cost = 0\n# \u5927\u304d\u3044\u65b9\u306e\u6599\u91d1\u6240\u306e\u6570\nbig_cost = 0\n\n# \u30ea\u30b9\u30c8a\u306e\u5024\u3068\uff58\u3092\u6bd4\u8f03\u3057\u3066\nfor i in a:\n # \uff58\u3088\u308a\u5c0f\u3055\u3044\u3082\u306e\u3092\u30ab\u30a6\u30f3\u30c8\n if x > i:\n small_cost += 1\n # \uff58\u3088\u308a\u5927\u304d\u3044\u3082\u306e\u3092\u30ab\u30a6\u30f3\u30c8\n elif x < i:\n big_cost += 1\n# \u5c11\u306a\u3044\u65b9\u306e\u30ab\u30a6\u30f3\u30c8\u3092\u51fa\u529b\nif small_cost <= big_cost:\n print(small_cost)\nelse:\n print(big_cost)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0cba0e8aa39e3d9842b9","document_content":"N, M, X = map(int, input().split())\ncost_masses = map(int, input().split())\n\ncost_ToZero = cost_ToEnd = 0\n\nfor cost_mass in cost_masses:\n if X < cost_mass:\n cost_ToEnd = cost_ToEnd + 1\n elif X > cost_mass:\n cost_ToZero = cost_ToZero + 1\nelse:\n print(min([cost_ToZero, cost_ToEnd]))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f2c1ff908d83e7d784e4","document_content":"n, m, x = map(int,input().split())\nl = 0\na = list(map(int,input().split()))\nfor j in a:\n l += 1 if j > x else 0\nprint(min(l,m-l))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c35c84af530207714471","document_content":"# -*- coding:utf-8 -*-\nN,M,X = list(map(int,input().split()))\nA = list(map(int,input().split()))\n\nA.append(X)\nA.sort()\n\nA_index = A.index(X)\n\nlen_bef = len(A[0:A_index])\nlen_aft = len(A[A_index+1:])\nans = len_bef\n\nif len_bef > len_aft:\n ans = len_aft\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e43756d90956c22388aa","document_content":"N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\nl1 = []\nl2 = []\n\nfor i in A:\n if X > i:\n l1.append(i)\n else:\n l2.append(i)\n\nprint(min(len(l1), len(l2)))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"03c804af66d012ebbd68","document_content":"def mapt(fn, *args):\n return tuple(map(fn, *args))\n\n\ndef Input():\n return mapt(int, input().split(\" \"))\n\n\ndef main():\n n, m, x = Input()\n a = [0] * n\n for i in Input():\n a[i-1] = 1\n\n print(min(sum(a[:x]), sum(a[x-1:])))\n\n\nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"df5f8bad13fe4c5ecc62","document_content":"n,m,x = map(int,input().split())\na = list(map(int,input().split()))\nans = 0\n\nfor i in range(m):\n if a[i] > x:\n if i < m-i: ans = i\n else : ans = m-i\n break\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"91b0770dc3dca5f67bea","document_content":"#!\/usr\/bin\/env python3\n\ndef main():\n n, m, x = list(map(int, input().split()))\n a = list(map(int, input().split()))\n for i in range(m):\n if a[i] > x:\n ans = min(i, len(a) - i)\n break\n else:\n ans = 0\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"73120422e2cbce7f7350","document_content":"N, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nfor i , a in enumerate(A):\n if X < a:\n break\n\nif i > len(A) \/ 2:\n ans = len(A[i:])\nelse:\n ans = len(A[:i])\n\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1651308597c3a1529641","document_content":"n,m,x = map(int,input().split())\na = list(map(int,input().split()))\ndata = [0]*(n + 1)\ncost_1 = 0\ncost_2 = 0\nfor i in range(m):\n data[a[i]] = 1\nfor i in range(0,x):\n cost_1 += data[i]\nfor j in range(x,n):\n cost_2 += data[j]\nprint(min(cost_1,cost_2))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ca500b13cd561debd1b5","document_content":"# \u5168\u4f53\u306e\u30de\u30b9\u3092\u958b\u59cb\u4f4d\u7f6e\u3067\u30b9\u30e9\u30a4\u30b9\u3001\u6599\u91d1\u6240\u3060\u3051\u62bd\u51fa\u3057\u3001\u8981\u7d20\u306e\u500b\u6570\u3067\u6761\u4ef6\u5206\u5c90\nN, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nsquare = list(range(0, N + 1))\n\na = square[:X + 1]\nb = square[X:]\n\na_costs = []\nb_costs = []\n\nfor i in a:\n if i in A:\n a_costs.append(i)\nfor i in b:\n if i in A:\n b_costs.append(i)\n\na_cost = len(a_costs)\nb_cost = len(b_costs)\n\nif a_cost > b_cost:\n print(b_cost)\nelse:\n print(a_cost)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"92d604876267fe210090","document_content":"n,m,x = map(int,input().split())\na = list(map(int,input().split()))\na.append(x)\na = sorted(a)\nprint(len(a[:a.index(x)]) if len(a[:a.index(x)+1]) <= len(a[a.index(x)+1:]) else len(a[a.index(x)+1:]))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"15fa627cba3c2de1e3b3","document_content":"n,m,x = map(int,input().split())\nli = list(map(int,input().split()))\ncnt = 0\ncou = 0\nfor i in range(x):\n if i in li:\n cnt += 1\nfor i in range(x,n):\n if i in li:\n cou += 1\nprint(min(cnt,cou))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"59818ab0b8c03885c657","document_content":"n,m,s = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\nlow = 0\nhigh = 0\nfor i in range(m):\n if a[i] < s:\n low += 1\n else:\n high += 1\nprint(min(low,high))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dbf1735600b3f09e1a39","document_content":"N, M, X = list(map(int,input().split()))\nA = list(map(int, input().split())) \n\nzero_goal = 0\nN_goal = 0\n\nfor i in A:\n if i < X:\n zero_goal = zero_goal + 1\n else:\n N_goal = N_goal + 1\nprint((min(zero_goal, N_goal)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"22ea9d5246cfea017cff","document_content":"n, m, x = list(map(int, input().split()))\nam = list(map(int, input().split()))\nlist_n = [0] * n\nfor i in am:\n list_n[i - 1] = 1\nprint((min(sum(list_n[:x - 1]), sum(list_n[x - 1:]))))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"deb428dfbdf3063db559","document_content":"n, m, x = list(map(int, input().split()))\na = list(map(int, input(). split()))\n\ngoto_goal_0 = 0\ngoto_goal_n = 0\n\nfor i in range(x, 0, -1):\n if i in a:\n goto_goal_0 += 1\n\n\nfor i in range(x, n + 1, 1):\n if i in a:\n goto_goal_n += 1\n\nif goto_goal_0 < goto_goal_n:\n print(goto_goal_0)\nelse:\n print(goto_goal_n)\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"14db6d17fcbc3700d895","document_content":"N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\ncost_0 = 0\ncost_last = 0\n\nfor n in A:\n if n > X:\n cost_last += 1\n elif n < X:\n cost_0 += 1\n\n\nif cost_0 >= cost_last:\n print(cost_last)\nelif cost_0 < cost_last:\n print(cost_0)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e5bbc67a1c09c857a47f","document_content":"n,m,x = list(map(int,input().split()))\nl = [0]*n\na = list(map(int,input().split()))\nfor i in a:\n l[i-1] = 1\n\nleft = sum(l[:x])\nright = sum(l[x-1:len(l)])\n\nprint((left if left<=right else right))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"01b6f560992e9f01fa20","document_content":"n,m,x = list(map(int,input().split()))\na = list(map(int,input().split()))\nans = 0\nans = min(sum(1 for i in a if i > x),sum(1 for i in a if i < x))\nprint(ans)\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1a4ee1a4d3500c72e608","document_content":"N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nA.sort()\n\nimport bisect\nidx = bisect.bisect(A, X)\n\nans_r = len(A[idx:])\nans_l = len(A[:idx])\n\nans = min(ans_l, ans_r)\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0a86c4dfdeeb40bcb935","document_content":"n, m, x = list(map(int, input().split()))\nsquares = list(map(int, input().split()))\n\nleft_cost = 0\nright_cost = 0\nfor square in squares:\n if square < x:\n left_cost = left_cost + 1\n else:\n right_cost = right_cost + 1\n\nprint((min(right_cost, left_cost)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ddaf0328b283d228922f","document_content":"n, m, x = map(int, input().split())\na_l = list(map(int, input().split()))\n\nfor i, a in enumerate(a_l):\n if x < a:\n break\nif i > len(a_l)\/2:\n ans = len(a_l[i:])\nelse:\n ans = len(a_l[:i])\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6daf209dcab5befe22b7","document_content":"n, m, x = list(map(int, input().split()))\narr = list(map(int, input().split()))\n\nmn = 0\nl_cost = 0\nr_cost = 0\n\n# Calculate left cost\nfor i in range(x):\n if i in arr:\n l_cost += 1\n\n# Calculate right cost\nfor i in range(x, n + 1):\n if i in arr:\n r_cost += 1\n\nprint((min(l_cost, r_cost)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e1d17b824b9bd0da015c","document_content":"n,m,x=map(int,input().split())\na=list(map(int,input().split()))\nk=[0]*(n+1)\nfor i in a:k[i]=1\nprint(min(sum(k[0:x+1]),sum(k[x:n+1])))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e34f580b0457cf24f632","document_content":"n = input()\nprint(\"Yes\" if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else \"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ab0d152a1da92f3406d0","document_content":"N = list(input())\nif N[0] == N[1] and N[0] == N[2]:\n print('Yes')\nelif N[1] == N[2] and N[2] == N[3]:\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4a38f0ae3eca83e09e36","document_content":"# 079a\n\ndef atc_079a(input_value: str) -> str:\n n = 3\n for i in range(0, len(input_value) + 1 - n):\n for j in range(1, n):\n if input_value[i] != input_value[i + j]:\n break\n if j == n - 1:\n return \"Yes\"\n return \"No\"\n\ninput_value = input()\nprint((atc_079a(input_value)))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6d7af37f4216f3e83211","document_content":"s = input()\nif s[0] == s[1] == s[2] or s[1] == s[2] == s[3]:\n print(\"Yes\")\nelif s[0] == s[1] == s[2] == s[3]:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"85c2cf37ea863659ba32","document_content":"N = input()\n\n\nprint((\"Yes\" if N[0] == N[1] == N[2] or N[1] == N[2] == N[3] else \"No\"))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a99940b881a9513535c1","document_content":"N = input()\n\ndata_list = str(N)\n\nif data_list[0] == data_list[1] == data_list[2]:\n print('Yes')\nelif data_list[1] == data_list[2] == data_list[3]:\n print('Yes')\nelif data_list[0] == data_list[1] == data_list[2] == data_list[3]:\n print('Yes')\nelse:\n print('No')\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"33dd9fc2b1becaa0b88c","document_content":"N = input()\n\nif N[0] == N[1] and N[1] == N[2]:\n print(\"Yes\")\nelif N[1] == N[2] and N[2] == N[3]:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b646d284b3355becff72","document_content":"N = str(input())\n\nif N[0] == N[1] == N[2]:\n print('Yes')\nelif N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"270a618dd400f7d732f0","document_content":"x = input()\nif x[1] == x[2] and (x[0] == x[1] or x[2] == x[3] ):\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c7c197921fee1f1bdc5a","document_content":"n = input()\ncnt = 1\nfor i in range(len(n)-1):\n if n[i] == n[i+1]:\n cnt += 1\n else:\n cnt = 1\n if cnt >= 3:\n print(\"Yes\")\n return\n \nprint('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8e81c923af2cf198ae20","document_content":"# 079_a\nN=int(input())\n# if 1<=N and N<=9999:\n#\nn=str(N)\nif (n[0]==n[1] and n[1]==n[2]) or (n[1]==n[2] and n[2]==n[3]):\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cc2b3abf9f61ea61a98a","document_content":"N = input()\ncheck = False\nfor i in range(2):\n if N[i:i+3] == N[i] * 3:\n check = True\n \nprint(\"Yes\" if check else \"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"34c60bf97e41cf04d0b0","document_content":"S=input()\nif S[0]==S[1]==S[2] or S[1]==S[2]==S[3]:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"16e26dacf7dd4b042c14","document_content":"s = input()\nif s[0] == s[1] == s[2] or s[1] == s[2] == s[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8e8221f673781896958e","document_content":"a,b,c,d = input()\nif (a==b==c) or (b==c==d):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a7bfd9593bf1749d1ab4","document_content":"N = str(input())\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n result = 'Yes'\nelse:\n result = 'No'\n\nprint(result)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4276f517dbf82b2b1766","document_content":"n = str(input())\nif n[0] == n[1] == n[2] or n[3] == n[1] == n[2]:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"bba0be420b2001a2b1b7","document_content":"N = input()\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3] :\n print('Yes')\nelse:\n print('No')\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1e7d3ba3d091f12b80fd","document_content":"N = input()\nanswer = list(N)\n\nif answer[0] == answer[1] == answer[2]:\n print(\"Yes\")\nelif answer[1] == answer[2] == answer[3]:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8858b69beb60adf93450","document_content":"X = input()\n\nif X[0] == X[1] == X[2] or X[1] == X[2] == X[3]:\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"55cc0b7f8908d45240ad","document_content":"N = str(input())\n\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n result = \"Yes\"\nelse:\n result = \"No\"\n\nprint(result)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c7f6b40d8d206c5dd0f6","document_content":"n = input()\n\nif n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6a074c8245dcb33ccb6a","document_content":"#!\/usr\/bin\/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = str(int(input()))\n\nflag = False\nif n[0] == n[1] and n[1] == n[2]:\n flag = True\nif n[1] == n[2] and n[3] == n[2]:\n flag = True\n\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"faee1d8762a9cc5a37d2","document_content":"a=input()\nif a[0]==a[1]==a[2] or a[1]==a[2]==a[3]:print(\"Yes\")\nelse:print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9948461f2fb99f3bffcc","document_content":"# A - Good Integer\n# https:\/\/atcoder.jp\/contests\/abc079\/tasks\/abc079_a\n\ns = input()\n\nif len(set(s[:3])) == 1 or len(set(s[1:])) == 1:\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e945d2793c8b2defa8ce","document_content":"N=input()\n#N\u306ei\u6587\u5b57\u76ee\u3068i\uff0b1\u6587\u5b57\u76ee\u304c\u540c\u3058\u3067\u3042\u308c\u3070\u30ab\u30a6\u30f3\u30c8\u3092\u5897\u3084\u3059\u3002\nj_count=0\nfor i in range(0,3):\n if N[i]==N[i+1]:\n j_count+=1\nif j_count>=2 and N[1]==N[2]:\n print(\"Yes\")\nelse:\n print(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5fc45bf044397454bef6","document_content":"N = input()\ns1 = N[1:len(N)]\ns2 = N[0:len(N) - 1]\nisOk = True\nfor i in range(1, len(N)-1):\n if s1[i] != s1[i - 1]:\n isOk = False\n break\n else:\n continue\n\nif isOk:\n print('Yes')\n return\n\nisOk = True\nfor i in range(1, len(N)-1):\n if s2[i] != s2[i - 1]:\n isOk = False\n break\n else:\n continue\n\nif isOk:\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4f83c353de8a8b145e0c","document_content":"n = input()\nprint(('Yes' if n[0]==n[1]==n[2] or n[1]==n[2]==n[3] else 'No'))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"529499dcd791291cbfce","document_content":"n = input()\nprint(\"Yes\" if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else \"No\") ","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1bf8bbafae1ca6376e07","document_content":"n = list(input())\nlist01 = list(set(n[0:3]))\nlist02 = list(set(n[1:4]))\nif len(list01) == 1 or len(list02) == 1:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8210d2f8517324670302","document_content":"N = input()\n\nif N[0] == N[1] ==N[2] or N[1] == N[2] == N[3] :\n print( \"Yes\" )\nelse:\n print( \"No\" )","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e2f912ff898bbba9af1e","document_content":"N = list(map(str, input()))\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3] :\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3b970cf1243d3dad2ef5","document_content":"s = input()\nprint((\"Yes\" if (s[1]==s[2] and (s[0]==s[1] or s[3]==s[1])) else \"No\"))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7644835e6dfa9ac87825","document_content":"def main():\n x = input()\n\n if len(set(x[:3])) == 1 or len(set(x[1:])) == 1:\n print(\"Yes\")\n else:\n print(\"No\")\n\nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ac1dc87f80f5726dd54c","document_content":"numbers = input()\n\nif numbers[1] == numbers[2]:\n if numbers.count(numbers[1]) >= 3:\n print(\"Yes\")\n return\n\nprint(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"58983b317605e40a851b","document_content":"N = input()\n\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"670d0840bbbcc1a30615","document_content":"N = input()\nif N[1] == N[2]:\n if N[0] == N[1] or N[2] == N[3]:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ae8f527391f3ef5d676b","document_content":"import bisect,collections,copy,heapq,itertools,math,string\nimport sys\ndef I():\n # 1 line 1 int\n return int(sys.stdin.readline().rstrip())\ndef LI():\n # 1 line n ints\n return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S():\n # 1 line 1 string\n return sys.stdin.readline().rstrip()\ndef LS():\n # 1 line n strings\n return list(sys.stdin.readline().rstrip().split())\n\nA = S()\n\nif A[0] == A[1] == A[2] or A[1] == A[2] == A[3]:\n print(\"Yes\")\nelse:\n print(\"No\")\n\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"29741b64d918e8a4c29c","document_content":"N = input()\n\nif N[0] == N[1] == N[2] == N[3]:\n print('Yes')\nelif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"240867887c5a1d39b001","document_content":"n = input('')\n# \u540c\u3058\u6570\u5b57\u304c3\u304b4\u500b\nif n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"961547a450e9204e29d9","document_content":"def atc_079a(input_value: str) -> str:\n n = 3\n for i in range(0, len(input_value) + 1 - n):\n for j in range(1, n):\n if input_value[i] != input_value[i + j]:\n break\n if j == n - 1:\n return \"Yes\"\n return \"No\"\n\n\ninput_value = input()\nprint(atc_079a(input_value))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f78a400daed9105a35ec","document_content":"def iroha():\n num = list(input())\n count = 0\n head = num[0]\n\n for i, char in enumerate(num):\n if head == num[i]:\n count += 1\n if count >= 3:\n print('Yes')\n return\n else:\n count = 1\n head = num[i]\n \n print('No')\n \n\n\ndef __starting_point():\n iroha()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b1f789de689bb257d8b1","document_content":"N = input()\n\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b77dbb9ed72c9faa0c77","document_content":"N=list(input())\n\nif N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:\n print('Yes')\nelse:\n print('No')\n\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d637bbdc5189a670088d","document_content":"N = input('')\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3] or N[0] == N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"46700e9094ecdb819532","document_content":"li = list(input())\n\nif li[0] == li[1] and li[1] == li[2]:\n print('Yes')\nelif li[1] == li[2] and li[2] == li[3]:\n print('Yes')\nelif li[0] == li[1] and li[0] == li[2] and li[0] == li[3]:\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7827b803af3e49644b9c","document_content":"s = input()\nif len(set(s[:3])) == 1 or len(set(s[1:])) == 1:\n print(\"Yes\")\nelse:\n print(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dc27dd9360d07dff1327","document_content":"N = input()\nprint('Yes' if (N[0] == N[1] == N[2]) or (N[1] == N[2] == N[3]) else 'No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2a00d629bd54f3f238ae","document_content":"n=input()\nif n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:print('Yes')\nelse:print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"d576b9c2553c98b8c832","document_content":"S = input()\nif len(list(set(S[:-1]))) == 1 or len(list(set(S[1:]))) == 1:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"54f62e3fbaed8e62ded3","document_content":"N = input()\n\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"436e0fb2bb186f268d22","document_content":"n=input()\nif len(set(n[:3]))==1 or len(set(n[1:4]))==1:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"253cdfe41347162d67b5","document_content":"n=list(input())\nif len(set(n[:3]))==1 or len(set(n[1:]))==1:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8a8884d43f3cab514a0f","document_content":"a, b, c, d = input()\nprint('Yes' if a == b == c or b == c == d else 'No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c0a442c7ede591d39916","document_content":"n = str(input())\n\nif n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:\n print('Yes')\n \nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b1d605471f3a21ea6327","document_content":"n = input()\nif n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"46ad9c8861e00112c279","document_content":"n = input()\nif (n[0] == n[1] == n[2]) or (n[1] == n[2] == n[3]):\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c440b5cfde87e604a6a3","document_content":"import sys\nn = input()\ncand = [str(i) + str(i) + str(i) for i in range(10)]\nfor ci in cand:\n if n.count(ci) >= 1:\n print(\"Yes\")\n return\nprint(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"999f2ee8a6502c360cc5","document_content":"n = input()\n\nif n[0] == n[1] and n[1] == n[2]:\n print('Yes')\nelif n[1] == n[2] and n[2] == n[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e7d169c16317f44f96f6","document_content":"a = input()\nif a[0] == a[1] == a[2] or a[1] == a[2] == a[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3f02a6cad2268b3add41","document_content":"\nN = str(input())\n\nif N[0] == N[1] and N[1] == N[2] :\n print('Yes')\n\nelif N[1] == N[2] and N[2] == N[3]:\n print('Yes')\n\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"89fdc4e569bcc3ff913a","document_content":"#!\/usr\/bin\/env python3\n\ndef main():\n a, b, c, d = input()\n print((\"Yes\" if a == b == c or b == c == d else \"No\"))\n\n\ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5c3e197b04e61c40a29a","document_content":"N = input()\ngood_ints = (str(i) * 3 for i in range(9 + 1))\nanswer = ''\n\nfor good_int in good_ints:\n if good_int in N:\n answer = 'Yes'\n break\n \nprint(answer if answer else 'No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dbb3d8cd0f11d5e37e1d","document_content":"# 4\u6841\u306e\u6570\u5b57\u30673\u3064\u4ee5\u4e0a\u9023\u7d9a\u3059\u308b\u304b\u5224\u5b9a\n\nN = list(input())\n# print(N)\n\nif N[0] == N[1] and N[0] == N[2]:\n print('Yes')\nelif N[1] == N[2] and N[1] == N[3]:\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"cc0d793eaa4ccf5c47a4","document_content":"#79\nn=list(input())\nif (n[0]==n[1]==n[2] or n[1]==n[2]==n[3]):\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7ec18e812723c71a816a","document_content":"N=input()\nif (N[0]==N[1] and N[1]==N[2]) or (N[1]==N[2] and N[2]==N[3]):\n print(\"Yes\")\nelse:\n print(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2d7774f646140871eb20","document_content":"# ABC079A\nn = input()\nprint(\"Yes\" if n[0]==n[1]==n[2] or n[3]==n[1]==n[2] else \"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"755f2c2adbe89765f09f","document_content":"n=input()\n\nif n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:\n print(\"Yes\")\nelse:\n print(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5132a795752c1397a6d7","document_content":"s = input()\nif (s[0]==s[1] and s[1]==s[2]) :\n print(\"Yes\")\nelif (s[1]==s[2] and s[2]==s[3]) :\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8e74729a2b58a3cea1b7","document_content":"N=input()\nj_count=0\nfor i in range(0,3):\n if N[i]==N[i+1]:\n j_count+=1\nif j_count>=2 and N[1]==N[2]:\n print(\"Yes\")\nelse:\n print(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f937eeefaa4a7ea37909","document_content":"n=int(input())\n\nif (n\/\/10)%111==0 or (n%1000)%111==0:\n ans=\"Yes\"\nelse:\n ans=\"No\"\n\nprint(ans)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ebe7da40ab658a8db7d2","document_content":"N = input()\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"e2091885a81b40654340","document_content":"integer = input()\nif integer[0] == integer[1] == integer[2] or integer[1] == integer[2] == integer[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"37f42c71db6c2aa88e13","document_content":"#\n# abc079 a\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"1118\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"7777\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"1234\"\"\"\n output = \"\"\"No\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = input()\n\n if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"620dc3a851f410fe5c75","document_content":"N = input()\nfor i in range(10):\n if N.count(str(i)*3):\n print('Yes')\n return\nprint('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f4051846a791c5bcf84f","document_content":"a,b,c,d=input()\nprint((\"Yes\" if a==b==c or b==c==d else \"No\"))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6a241019042704433c05","document_content":"N = input()\n\no1 = set(N[0:3])\no2 = set(N[1:])\no3 = set(N)\n\n\nprint(\"Yes\" if len(o1) == 1 or len(o2) == 1 or len(o3) == 1 else \"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1fce401f14febbbc7494","document_content":"# \u6570\u5024\u306e\u53d6\u5f97\nN = str(input())\n\n# \u6570\u5024\u306e\u691c\u8a3c\nf_cnt = (N[:3]).count(N[:1])\nl_cnt = (N[1:]).count(N[3:])\nif f_cnt == 3\\\nor l_cnt == 3:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5ec7630d79666d176cb4","document_content":"import bisect,collections,copy,heapq,itertools,math,string\nimport sys\ndef I():\n #1 line 1 int\n return int(sys.stdin.readline().rstrip())\ndef LI():\n #1 line n int\n return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S():\n #1 line 1 string\n return sys.stdin.readline().rstrip()\ndef LS():\n #1 line n strings\n return list(sys.stdin.readline().rstrip().split())\n\nA=S()\n\nif A[0] == A[1] == A[2] or A[1] == A[2] == A[3]:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fb667c48887fa93b294f","document_content":"a, b, c, d = input()\nprint(\"Yes\" if a==b==c or b==c==d else \"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"307c5598d883bf64ff79","document_content":"S = input()\nans = False\nfor i in range(len(S)):\n if S[1] == S[2] == S[3] or S[0] == S[1] == S[2]:\n ans = True\nif ans:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2b869b8831d688e8d14b","document_content":"n = input().rstrip()\nprint(['No', 'Yes'][int(len(set(n[:3])) == 1 or len(set(n[1:])) == 1)])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7de7d8a47e015efc13bb","document_content":"n = input()\nif n[1] == n[2]:\n if n[0]==n[1] or n[2]==n[3]:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ab632d1b80f5392e7bff","document_content":"n=input()\na=[]\nfor i in range(len(n)):\n a.append(n[i])\n\nif (a[0]==a[1]) & (a[1]==a[2]) or (a[3]==a[2]) and (a[2]==a[1]) :\n print(\"Yes\")\nelse:\n print(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"15069b4616288d61a763","document_content":"# A - Good Integer\n# \u6a19\u6e96\u5165\u529bN\n\nN = input()\nmy_list = []\nj = 0\n\nfor i in N:\n my_list.append(i)\n\nif my_list[0] == my_list[1] == my_list[2] or my_list[1] == my_list[2] == my_list[3]:\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4d246819cf310f98b75d","document_content":"n = input()\narr = []\nfor i in range(10):\n s = \"\"\n for j in range(3):\n s += str(i)\n arr.append(s)\n\nif n[0:3] in arr or n[1:4] in arr:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"44dc0fd391b884abd78b","document_content":"'''\n\u554f\u984c\uff1a\n 1118 \u306e\u3088\u3046\u306a\u30013 \u3064\u4ee5\u4e0a\u306e\u540c\u3058\u6570\u5b57\u304c\u9023\u7d9a\u3057\u3066\u4e26\u3093\u3060\n 4 \u6841\u306e\u6574\u6570\u3092 \u826f\u3044\u6574\u6570 \u3068\u3057\u307e\u3059\u3002\n\n 4 \u6841\u306e\u6574\u6570N \u304c\u4e0e\u3048\u3089\u308c\u308b\u306e\u3067\u3001N \u304c \u826f\u3044\u6574\u6570 \u304b\u3069\u3046\u304b\u3092\u7b54\u3048\u3066\u304f\u3060\u3055\u3044\u3002\n'''\n\n'''\n\u5236\u7d04\uff1a\n 1000 \u2266 N \u2266 9999\n \u5165\u529b\u306f\u6574\u6570\u304b\u3089\u306a\u308b\n'''\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 N \u3092\u53d6\u5f97\u3059\u308b\nn = int(input())\nlist_n = list(str(n))\n\nresult = \"\"\n\nif (list_n[0] == list_n[1]) and (list_n[1] == list_n[2]):\n result = \"Yes\"\nelif (list_n[1] == list_n[2]) and (list_n[2] == list_n[3]):\n result = \"Yes\"\nelse:\n result = \"No\"\n\nprint(result)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1be3c3a10b0cb3ceb2ce","document_content":"n=list(input())\nif n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9511e6f565b6b548b6c9","document_content":"n = int(input())\nn = str(n)\n# n\u306e\u4e8c\u6841\u76ee\u3068\u4e09\u6841\u76ee\u304c\u540c\u3058\u3067\u3001\u305d\u308c\u304c\u4e00\u6841\u76ee\u304b\u56db\u6841\u76ee\u304c\u3068\u540c\u3058\u306a\u3089Yes\nif n[1] == n[2]:\n if n[0] == n[1] or n[2] == n[3]:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"eca3ed009bae39443b98","document_content":"N = input()\ngood_ints = (str(i) * 3 for i in range(9 + 1))\n\nfor good_int in good_ints:\n if good_int in N:\n print('Yes')\n return\n\nprint('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4b3cd428b38e36f8cb57","document_content":"N = input()\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"76643846f64e4fddba0d","document_content":"N = input()\n\n# 3\u3064\u4ee5\u4e0a\u306e\u540c\u3058\u6570\u5b57\u304c\u9023\u7d9a\u3057\u3066\u4e26\u3093\u3060 4\u6841\u306e\u6574\u6570\u3092 \u826f\u3044\u6574\u6570 \u3068\u3057\u307e\u3059\u3002\n# N \u304c\u826f\u3044\u6574\u6570 \u306a\u3089\u3070 Yes \u3092\u3001\u305d\u3046\u3067\u306a\u3051\u308c\u3070 No \u3092\u51fa\u529b\u305b\u3088\u3002\n\nif N[1] == N[2]:\n if N[0] == N[1] or N[2] == N[3]:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7c0dcb280caeafe8b81f","document_content":"# coding = SJIS\n\nn = str(input())\n\nif n[0] == n[1] and n[1] == n[2]:\n print(\"Yes\")\nelif n[1] == n[2] and n[2] == n[3]:\n print(\"Yes\")\nelse:\n print(\"No\")","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7fc0561bd34dfa224316","document_content":"n = input()\n\nif n[0] == n[1] and n[1] == n[2] or n[1] == n[2] and n[2] == n[3]:\n print(\"Yes\")\nelse:\n print(\"No\")\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"36bbb55e183fd006536d","document_content":"N = input()\n\nfor i in range(2):\n if N[i:i+3] == 3 * N[i]:\n print('Yes')\n return\n\nprint('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"be0f713023f2fca112b1","document_content":"a=input()\nb=set(a[:-1]);c=set(a[1:])\n\nif len(b)==1 or len(c)==1:\n print('Yes')\nelse:\n print('No')\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"88a164163f48b7e928c7","document_content":"S = input()\nprint('Yes' if S[0] == S[1] == S[2] or S[1] == S[2] == S[3] else 'No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"05e407a03f1dc4f751f4","document_content":"N = input('')\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"82d969486ec792da4e14","document_content":"n = list(input())\n\nif n[0] == n[1] and n[1] == n[2]:\n print('Yes')\nelif n[1] == n[2] and n[2] == n[3]:\n print('Yes')\nelif n[0] == n[1] == n[2] == n[3]:\n print('Yes')\nelse:\n print('No')","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9e8e7fa75f8505e61981","document_content":"import bisect,collections,copy,heapq,itertools,math,string\nimport sys\ndef I():\n #1 line 1 int\n return int(sys.stdin.readline().rstrip())\ndef LI():\n #1 line n int\n return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S():\n #1 line 1 string\n return sys.stdin.readline().rstrip()\ndef LS():\n #1 line n strings\n return list(sys.stdin.readline().rstrip().split())\n\n\nxs=LI()\n\nif xs[0] == xs[1]:\n print(xs[2])\nelif xs[0] == xs[2]:\n print(xs[1])\nelse:\n print(xs[0])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f8c85d20d4b49c2fd485","document_content":"A, B, C = map(int,input().split())\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelse:\n print(A)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"fedaca26fcc7ff89e113","document_content":"a = input().split(' ')\n\nfor i in a:\n if (a.count(i)==1):\n print(i)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5fa6227dd8dea094e76a","document_content":"a, b, c = map(int, input().split())\n\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a7443da7a35caaa57c0d","document_content":"#\n# abc075 a\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"5 7 5\"\"\"\n output = \"\"\"7\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"1 1 7\"\"\"\n output = \"\"\"7\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"-100 100 100\"\"\"\n output = \"\"\"-100\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n A, B, C = list(map(int, input().split()))\n\n if A == B:\n print(C)\n elif A == C:\n print(B)\n else:\n print(A)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a0598e8e46be1ffa8379","document_content":"#75\na,b,c=map(int,input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"06bf70e81b154c2573dc","document_content":"a, b, c = input().split()\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"985ead194eb8630e384f","document_content":"a,b,c=map(int, input().split())\nprint(a if b==c else b if c==a else c)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6d2934f660e2bcde2cde","document_content":"a=list(map(int,input().split()))\nb=set(a)\n\nfor i in b:\n if (a.count(i))==1:\n print(i)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b4d997499414339a8d1e","document_content":"# 3\u3064\u306e\u6574\u6570\u306e\u3046\u30611\u3064\u3060\u3051\u7570\u306a\u308b\u5024\u3092\u51fa\u529b\nA, B, C = map(int,input().split())\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelse:\n print(A)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0b29c66c662a0311a7ce","document_content":"import collections\nl=list(map(int,input().split()))\ncounted = collections.Counter(l)\nprint(counted.most_common()[1][0])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"000986101f6da2e77bd6","document_content":"l=list(map(int,input().split()))\nfrom collections import Counter\nl=list(Counter(l).most_common())\nprint(l[1][0])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6d471543a858d7b0c941","document_content":"a,b,c = input().split()\nif a == b:\n print(c)\nelif a == c:\n print(b)\nelif b == c:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"74c3ba6bd960b13c29e9","document_content":"A,B,C=map(int,input().split())\nif A==B :\n print(C)\nelif B==C :\n print(A)\nelse :\n print(B)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9e7919e2225eff97a7af","document_content":"a,b,c=map(int,input().split())\nif a==b:\n print(c)\nelif b==c:\n print(a)\nelse:\n print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5973e7a4f51ea5ca6a02","document_content":"a,b,c = map(int,input().split())\n\nif a == b:\n print(c)\n \nelif a == c:\n print(b)\n \nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8c0ab94e3180bcbabf70","document_content":"A, B, C = [int(i) for i in input().split()]\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelif B == C:\n print(A)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"03ec31d667bedaa2985d","document_content":"a,b,c = map(int,input().split())\nprint(a if b==c else b if a==c else c)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8a308ecb66ba4846de0f","document_content":"a, b, c = map(int, input().split())\nprint(a ^ b ^ c)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"437207db2c23ec9b8edd","document_content":"A,B,C = map(int,input().split())\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelse:\n print(A)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a4c7be115272692fdcb5","document_content":"a, b, c = list(map(int, input().split()))\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"dcc21b2b23c413f2e5a0","document_content":"a,b,c = map(int, input().split())\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ae6a3c2e1019f8611943","document_content":"A,B,C = map(int,input().split())\n\nprint(A if B == C else B if A == C else C)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6e4bb1e699746940840f","document_content":"A, B, C = sorted(map(int, input().split()))\n\nprint((A if B == C else C))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1edf7ba27424d7820fac","document_content":"a,b,c=map(int,input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"76f33e559d0ced263d10","document_content":"A, B, C = list(map(int, input().split()))\n\nif A - B == 0:\n print(C)\nelif A - C == 0:\n print(B)\nelse:\n print(A)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"46f79336c344cd527b99","document_content":"a, b, c = map(int, input().split())\nif a == b: print(c)\nif b == c: print(a)\nif c == a: print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f0bdbb0efc15e4db2785","document_content":"A, B, C = map(int, input().split())\n\nif A == C:\n print(B)\nelif B == C:\n print(A)\nelse:\n print(C)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f92908a3b5e5f62f795b","document_content":"a,b,c = map(int,input().split())\nif a != b and a == c:\n print(b)\nelif a != b and a != c:\n print(a)\nelse:\n print(c)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2ebea56bdace5385826c","document_content":"def main():\n a = list(map(int,input().split()))\n if a[0] == a[1]:\n print((a[2]))\n elif a[1] == a[2]:\n print((a[0]))\n else:\n print((a[1]))\n \ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c4bf58fee1172743b185","document_content":"integer1, integer2, integer3 = map(int, input().split())\nif integer2 == integer3:\n print(integer1)\nelif integer1 == integer3:\n print(integer2)\nelse:\n print(integer3)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7b997e8b9865c1f0757f","document_content":"a,b,c=map(int,input().split())\n\nprint(c) if a == b else print(b) if a == c else print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"466cdb169f0bf2e4e33d","document_content":"# A - One out of Three\n# https:\/\/atcoder.jp\/contests\/abc075\/tasks\/abc075_a\n\nA, B, C = list(map(int, input().split()))\n\nif A == B and A != C:\n print(C)\nelif A == C and A != B:\n print(B)\nelif B == C and A != C:\n print(A)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"5b80ad583fa1b70758ae","document_content":"A,B,C = map(int, input().split())\nif A == C:\n print(B)\nelif A == B:\n print(C)\nelse:\n print(A)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"256ed9cf93c0575129ae","document_content":"# \u5165\u529b\nA, B, C = map(int, input().split())\n\n# \u6bd4\u8f03\u3057\u3066\u51fa\u529b\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelif B == C:\n print(A)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2a017924dc037e9df7a7","document_content":"# \u5165\u529b\nA, B, C = map(int,input().split())\n\n# \u51e6\u7406\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelse:\n print(A)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4f78aca8e4b7a66b3484","document_content":"a,b,c= map(int,input().split())\nprint(a^b^c)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"aaedfa8a85b0e33e03ec","document_content":"x,y,z=map(int,input().split())\nprint(z if x == y else y if x == z else x)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"df34c7b55baeabebeda9","document_content":"a,b,c = map(int,input().split())\n\nif a == c:\n\tprint(b)\nelif a == b:\n\tprint(c)\nelif b == c:\n\tprint(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"80ef004a328d6cf05edf","document_content":"a,b,c = map(int,input().split())\nif a == b:\n print(c)\nif a == c:\n print(b)\nif b == c:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"098fe2f8f630cf3796b8","document_content":"ls = list(map(int,input().split()))\nif ls[1] != ls[2] and ls[2] == ls[0]:\n print((ls[1]))\nif ls[0] != ls[1] and ls[1] == ls[2]:\n print((ls[0]))\nif ls[2] != ls[1] and ls[1] == ls[0]:\n print((ls[2]))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"90d7783b1f3a8dc77b84","document_content":"a, b, c = list(map(int, input().split()))\n\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"53a0fc461b9484cc28eb","document_content":"a = [int(x) for x in input().split()]\nif a[0] == a[1]:\n print(a[2])\nelif a[1] == a[2]:\n print(a[0])\nelse:\n print(a[1])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"35156b114275a7f8a526","document_content":"a,b,c = map(int,input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"706c2bf3a83efc6cfc17","document_content":"A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif B == C:\n print(A)\nelse:\n print(B)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c4372aedb31d9a104632","document_content":"a,b,c=list(map(int,input().split()))\nif a==b & b != c:\n print(c)\nelif a==c & c !=b:\n print(b)\nelse:\n print(a)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"3979c3aafe7694071c60","document_content":"A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif B == C:\n print(A)\nelif C == A:\n print(B)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2328ef7b92611ed60079","document_content":"A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelse:\n print(A)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0d11a14411edf4bae930","document_content":"a, b, c = map(int, input().split())\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"32868022fe45d2b3d5ed","document_content":"a,b,c = map(int, input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"49f298d6ddb0bfb4a232","document_content":"import sys, collections\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = 10**20\ndef I(): return int(input())\ndef F(): return float(input())\ndef S(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LS(): return input().split()\n\ndef resolve():\n ABC = LI()\n\n cnt = collections.Counter(ABC)\n ans = [k for k, v in list(cnt.items()) if v == 1]\n print((ans[0]))\n\ndef __starting_point():\n resolve()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"50356c485a298dfe22ff","document_content":"# 3 \u3064\u306e\u6574\u6570 A, B, C\u304c\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002\n# A, B, C \u306e\u3046\u3061 2\u3064\u306f \u540c\u3058\u6574\u6570\u3067\u3042\u308a\u3001\n# \u6b8b\u308a\u306e 1\u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3067\u3059\u3002\n# \u4f8b\u3048\u3070\u3001A = 5, B = 7, C = 5\u306e\u5834\u5408\u3001\n# A, C \u306e 2\u3064\u306f\u540c\u3058\u6574\u6570\u3067\u3042\u308a\u3001\n# B \u306f 1\u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3067\u3059\u3002\n# 3\u3064\u306e\u6574\u6570\u306e\u3046\u3061\u30011\u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3092\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# -100 \u2266 A, B, C \u2266 100\n# A, B, C \u306f\u6574\u6570\n# \u5165\u529b\u306f\u554f\u984c\u6587\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3059\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 A, B, C \u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\na, b, c = list(map(int, input().split()))\n\n# \u7570\u306a\u308b\u6574\u6570\u3092\u63a2\u3057\u3066\u51fa\u529b\u3059\u308b\nresult = 0\n\nif a == b:\n result = c\nelif b == c:\n result = a\nelif a == c:\n result = b\nelse:\n result = \"Error\"\n\nprint(result)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"77f1296f472f2765dafd","document_content":"a, b, c = map(int, input().split())\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"0dddbafea52b8b14c17c","document_content":"a,b,c = input().split()\n\nif(a==b):\n print(c)\nelif(a == c):\n print(b)\nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c0359c4a16a46c524138","document_content":"from collections import Counter\n\nABC = list(map(int, input().split()))\n\ncnt = Counter(ABC)\nvalues, counts = zip(*cnt.most_common(2))\n\nprint(values[1])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c04f077437918603f96d","document_content":"num = list(map(int, input().split()))\nnum = sorted(num)\nprint((num[0] if num[0] != num[1] else num[2]))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6226a6fb8b9865ddec94","document_content":"a,b,c = map(int,input().split())\nif a==b:\n print(c)\nelif b==c:\n print(a)\nelse:\n print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"90f2e87b3b6f3d85ac34","document_content":"a,b,c = map(int,input().split())\nif a == c:\n print(b)\nelif a == b:\n print(c)\nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6fa29d61fcd44c5db7d8","document_content":"def mapt(fn, *args):\n return tuple(map(fn, *args))\n\n\ndef Input():\n return mapt(int, input().split(\" \"))\n\n\ndef main():\n abc = sorted(Input())\n if abc[0] == abc[1]:\n print(abc[2])\n else:\n print(abc[0])\n\n\nmain()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1cbb69a5c1d963acdff8","document_content":"a,b,c=input().split()\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f69ef07d52c95dce881f","document_content":"# A - One out of Three\n\n# \u5165\u529b\u3055\u308c\u305f\u6574\u6570A,B,C\u306e\u3046\u3061\u30012\u3064\u306f\u7b49\u3057\u304f1\u3064\u306f\u7570\u306a\u308b\n# 1\u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u306e\u5024\u3092\u51fa\u529b\u3059\u308b\n\n\nA,B,C = list(map(int,input().split()))\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelif B == C:\n print(A)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"885f86850393f60f728a","document_content":"a, b, c =map(int, input().split())\n\n\nif a==b:\n print(c)\nelif b ==c:\n print(a)\nelse:\n print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8c8723edd863a052bdd9","document_content":"# 3 \u3064\u306e\u6574\u6570 A , B , C \u304c\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002 A , B , C \u306e\u3046\u3061 2 \u3064\u306f \u540c\u3058\u6574\u6570\u3067\u3042\u308a\u3001\u6b8b\u308a\u306e 1 \u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3067\u3059\u3002\n# \u4f8b\u3048\u3070\u3001 A = 5 , B = 7 , C = 5 \u306e\u5834\u5408\u3001 A , C \u306e 2 \u3064\u306f\u540c\u3058\u6574\u6570\u3067\u3042\u308a\u3001 B \u306f 1 \u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3067\u3059\u3002\n# 3 \u3064\u306e\u6574\u6570\u306e\u3046\u3061\u3001 1 \u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3092\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\nA,B,C =map(int,input().split())\n\nif A == B:\n print(C)\n\nelif A == C:\n print(B)\n\nelif B == C:\n print(A)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a9f5a4de4c54b6e97e3b","document_content":"a,b,c = map(int,input().split())\n\nif a == b:\n print(c)\nelif a == c:\n print(b)\nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"6a340fe6faad8c290249","document_content":"A,B,C=list(map(int,input().split()))\nif A==B:\n print(C)\nelif B==C:\n print(A)\nelse:\n print(B)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"29e2e16364469977677f","document_content":"#!\/usr\/bin\/env python3\n\nA, B, C = list(map(int, input().split()))\nif A == B: print(C)\nelif A == C: print(B)\nelse: print(A)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"08d96af9bb27c090992c","document_content":"a, b, c = list(map(int, input().split()))\n\nprint((a ^ b ^ c))\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7a4330d255a8e7bc36f6","document_content":"A, B, C = map(int, input().split())\nprint(A if B == C else B if A == C else C)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"1c29f8e208870beb8eb2","document_content":"a, b, c = map(int,input().split())\n\nif int(a) == int(b):\n print(c)\nif int(a) == int(c):\n print(b)\nif int(b) == int(c):\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7b1111d0021529bd2f50","document_content":"def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from collections import defaultdict\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n from math import floor, ceil,pi,factorial\n from operator import itemgetter\n def I(): return int(input())\n def MI(): return list(map(int, input().split()))\n def LI(): return list(map(int, input().split()))\n def LI2(): return [int(input()) for i in range(n)]\n def MXI(): return [[LI()]for i in range(n)]\n def SI(): return input().rstrip()\n def printns(x): print(('\\n'.join(x)))\n def printni(x): print(('\\n'.join(list(map(str,x)))))\n inf = 10**17\n mod = 10**9 + 7\n#main code here!\n a,b,c=MI()\n if a==b:\n print(c)\n elif b==c:\n print(a)\n else:\n print(b)\n \ndef __starting_point():\n main()\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ef2aea4640225f8bb821","document_content":"lst = input().split()\n\nfor i in range(3):\n if lst.count(lst[i]) == 1:\n print(lst[i])\n break","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c2403d5a22cb893cc891","document_content":"A,B,C=list(map(int,input().split()))\nif A==B:\n print(C)\nelif A==C:\n print(B)\nelif B==C:\n print(A)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8bb44482cc767e0a4a46","document_content":"a,b,c = list(map(int,input().split()))\n\nif a == b:\n print(c)\nelif a == c:\n print(b) \nelse:\n print(a)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"f3a3e650ed3aa36a30a5","document_content":"A, B, C = map(int, input().split())\nprint(A ^ B ^ C)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"426d29adcfee66ea24f8","document_content":"l=sorted(map(int,input().split()))\nprint(sum(l)-l[1]*2)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"8f25fe095ae304b01db7","document_content":"# AtCoder abc075 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\na, b, c =list(map(int, input().split()))\n\n# \u5224\u5b9a\nif a == b:\n print(c)\nelif a == c:\n print(b)\nelse:\n print(a)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"ff5d26f9846c3ea39d62","document_content":"A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif B == C:\n print(A)\nelif A == C:\n print(B)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"2f1e037b31bd2235cb37","document_content":"A,B,C = list(map(int,input().split()))\nif A==B:\n print(C)\nelif A == C:\n print(B)\nelif B == C:\n print(A)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"165ba043c82592b6e7e0","document_content":"A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif B == C:\n print(A)\nelse:\n print(B)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"c916ada9d8e2f7467489","document_content":"a,b,c = sorted(map(int,input().split()))\nprint( c if a == b else a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9e08d17535ead886c185","document_content":"a,b,c=map(int,input().split())\nif a==c:\n print(b)\nelif a==b:\n print(c)\nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"79750cbfd6fab804c50e","document_content":"l = list(map(int, input().split()))\nfor ll in l:\n if l.count(ll)==1:\n print(ll)\n break","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"7f85392ebf515a1ba1fe","document_content":"def iroha():\n a,b,c = list(map(int, input().split()))\n if a == b:\n print(c)\n elif a == c:\n print(b)\n else:\n print(a)\n\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"69ce2b31300eb9390b13","document_content":"a,b,c=list(map(int,input().split()))\n\nif a==b:\n ans=c\nelif b==c:\n ans=a\nelse:\n ans=b\nprint(ans)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"a0ab7d22e93c01c99b07","document_content":"a, b, c = map(int, input().split())\nif a == b:\n print(c)\nelif c == b:\n print(a)\nelse:\n print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"26df42c503c2d4cfa719","document_content":"# 075_a\nA,B,C=list(map(int,input().split()))\nif (-100<=A and A<=100) and (-100<=B and B<=100) and (-100<=C and C<=100):\n if A==B:\n print(C)\n elif B==C:\n print(A)\n elif C==A:\n print(B)\n","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"b86975679ae12374b5c0","document_content":"s=list(map(int,input().split()))\ni=set(s)\nprint(sum(i)-(sum(s)-sum(i)))","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"9252b8fb306a311ca535","document_content":"a, b, c = map(int, input().split())\n\nif a == b:\n print(c)\nelif a == c:\n print(b)\nelse:\n print(a)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"4521bb6b34048ed55b77","document_content":"a,b,c=map(int,input().split())\nprint(a if b==c else b if a==c else c)","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"82602012502b3e063d2c","document_content":"a=list(map(int,input().split()))\na.sort()\n\nif a[0]==a[1]:\n print(a[2])\nelse:\n print(a[0])","parent_id":null,"metadata":null,"task_split":"code_retrieval"} {"document_id":"df85363f0a90b8e1e386","document_content":"a, b, c=map(int,input().split())\nif a==b:\n print(c)\nelif c==b:\n print(a)\nelse:\n print(b)","parent_id":null,"metadata":null,"task_split":"code_retrieval"}