problem_id stringlengths 6 6 | user_id stringlengths 10 10 | time_limit float64 1k 8k | memory_limit float64 262k 1.05M | problem_description stringlengths 48 1.55k | codes stringlengths 35 98.9k | status stringlengths 28 1.7k | submission_ids stringlengths 28 1.41k | memories stringlengths 13 808 | cpu_times stringlengths 11 610 | code_sizes stringlengths 7 505 |
|---|---|---|---|---|---|---|---|---|---|---|
p03200 | u864197622 | 2,000 | 1,048,576 | There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed. | ['N = int(input())\n\nX = [[] for i in range(N)]\nP = [-1] * N\n\nfor i in range(N-1):\n x, y = map(int, input().split())\n X[x-1].append(y-1)\n X[y-1].append(x-1)\n\n\ndef set_parent(i):\n # print(i)\n for a in X[i]:\n if a != P[i]:\n P[a] = i\n # print(a)\n X[a].remove(i)\n set_parent(a)\n \nset_parent(0)\n\nB = [-1] * N\ndef set_block(i):\n for a in X[i]:\n B[a] = max(i, B[i])\n set_block(a)\n\nB_id = [-1] * N\nB_id_cnt = [0] * N\ndef BID(i):\n for a in X[i]:\n if a > B[i]:\n B_id[a] = a\n else:\n B_id[a] = B_id[i]\n \n # print(a, B_id)\n B_id_cnt[B_id[a]] += 1\n BID(a)\n \nAns = [1] * N\ndef flow(i):\n for a in X[i]:\n if B_id[a] == B_id[i]:\n Ans[a] = Ans[i]\n else:\n Ans[a] = Ans[i] + B_id_cnt[a]\n flow(a)\n\nset_block(0)\n\n\n\n\n\n\n\n# print(Ans)\nprint(" ".join(map(str, Ans[1:])))\n', 's = input()\nn = len(s)\na = 0\nb = 0\nfor i in range(n):\n if s[i] == "W":\n a += 1\n b += i\n \nprint(b - a*(a-1)//2)'] | ['Runtime Error', 'Accepted'] | ['s588291493', 's598226478'] | [3628.0, 3500.0] | [19.0, 66.0] | [1084, 134] |
p03200 | u880466014 | 2,000 | 1,048,576 | There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed. | ["S = input()\nN = len(S)\nsum = 0\nflg = False\nS = S[::-1]\n\nfor i in range(N):\n if S[i] == 'W':\n flg = True\n elif S[i] == 'B' and flg:\n sum += i\nprint(sum)", "S = input()\nN = len(S)\nsum = 0\ncount = 0\nflg = False\nS = S[::-1]\n\nfor i in range(N):\n if S[i] == 'W':\n count += 1\n flg = True\n elif S[i] == 'B' and flg:\n sum += count\nprint(sum)"] | ['Wrong Answer', 'Accepted'] | ['s672961768', 's659302414'] | [3500.0, 3500.0] | [60.0, 70.0] | [159, 188] |
p03200 | u898967808 | 2,000 | 1,048,576 | There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed. | ["s = input()\n\ncw = 0\nans = 0\nfor i in range(n):\n if s[i] == 'W':\n ans += i-cw\n cw += 1\n \nprint(ans) \n \n ", "s = input()\n \ncw = 0\nans = 0\nfor i in range(len(s)):\n if s[i] == 'W':\n ans += i-cw\n cw += 1\n \nprint(ans) "] | ['Runtime Error', 'Accepted'] | ['s728398542', 's849180576'] | [9176.0, 9284.0] | [25.0, 63.0] | [120, 118] |
p03200 | u912650255 | 2,000 | 1,048,576 | There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed. | ["S = list(input())\n\nprint(S)\n\ncount = 0\ni = 0\nwhile i < len(S)-1:\n if S[i]=='B' and S[i+1]=='W':\n S[i]='W'\n S[i+1]='B'\n count += 1\n if i > 0:\n i -= 1\n else:\n i += 1\n else:\n i += 1\nprint(count)", "S = input()\n\ncount = 0\nblack = 0\nwhite = 0\n\nfor i in range(len(S)-1):\n if S[i] == 'B':\n black +=1\n else :\n white +=1\n if S[i+1] == 'W':\n count += i+1 -white\n\nprint(count)"] | ['Wrong Answer', 'Accepted'] | ['s908961626', 's512032272'] | [12264.0, 9324.0] | [2206.0, 88.0] | [265, 201] |
p03200 | u914992391 | 2,000 | 1,048,576 | There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed. | ["from sys import stdin\n\ndef main():\n A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))\n\n A=[0,0,1]\n wc = A.count(1)\n indices = [i for i, x in enumerate(A) if x == 1]\n if wc > 0:\n print(sum(indices) - 1*wc*(wc-1) //2 )\n else:\n print(sum(indices))\n\ninput = lambda: stdin.readline()\nmain()\n", '# -*- coding: utf-8 -*-\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n pair=2**b - A[i]\n if pair < 1:\n continue\n \n if A.count(pair) >0:\n A[i] = -1\n A[A.index(pair)] = -1\n pairCounter+=1\n break\n\nprint(pairCounter)', "from sys import stdin\n\ndef main():\n bw=stdin.readline().replace('B', '0').replace('W', '1')\n A=list(map(int,bw))\n #A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))\n\n A=[0,0,1]\n wc = A.count(1)\n indices = [i for i, x in enumerate(A) if x == 1]\n if wc > 0:\n print(sum(indices) - 1*wc*(wc-1) //2 )\n else:\n print(sum(indices))\n\ninput = lambda: stdin.readline()\nmain()\n", "from sys import stdin\ndef main():\n A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))\n\n wc = A.count(1)\n indices = [i for i, x in enumerate(A) if x == 1]\n if wc > 0:\n print(sum(indices) - 1*wc*(wc-1) //2 )\n else:\n print(sum(indices))\n\ninput = lambda: stdin.readline()\nmain()\n", "from sys import stdin\n\ndef main():\n A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))\n\n wc = A.count(1)\n indices = [i for i, x in enumerate(A) if x == 1]\n if wc > 0:\n print(sum(indices) - 1*wc*(wc-1) //2 )\n else:\n print(sum(indices))\n\ninput = lambda: stdin.readline()\nmain()\n", "from sys import stdin\ndef main():\n A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))\n\n wc = A.count(1)\n indices = [i for i, x in enumerate(A) if x == 1]\n print(sum(indices) - 1*wc*(wc-1) //2 )\n\ninput = lambda: stdin.readline()\nmain()\n", "from sys import stdin\n\ndef main():\n A=stdin.readline()\n #A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))\n\n wc = A.count('W')\n indices = [i for i, x in enumerate(A) if x == 'W']\n if wc > 0:\n print(sum(indices) - 1*wc*(wc-1) //2 )\n else:\n print(sum(indices))\n\ninput = lambda: stdin.readline()\nmain()\n"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s127432142', 's285846101', 's351787368', 's434840138', 's579216158', 's592570458', 's857322473'] | [5156.0, 3500.0, 5152.0, 5152.0, 5156.0, 5092.0, 11176.0] | [50.0, 18.0, 47.0, 47.0, 50.0, 47.0, 37.0] | [336, 373, 421, 321, 322, 268, 350] |
p03200 | u923270446 | 2,000 | 1,048,576 | There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed. | ['def ans():\n global cnt, s, l\n if s.count("BW") == 0:\n return None\n for i in range(s.count("BW")):\n print(s)\n cnt += 1\n l.pop(s.index("BW") + 1)\n l[s.index("BW"):s.index("BW") + 1] = ["W", "B"]\n s = "".join(l)\n ans()\ns = input()\nl = list(s)\ncnt = 0\nans()\nprint(cnt)', 's=input()\nc=0\na=0\nfor i in range(len(s)):\n if s[i]=="W":a+=i-c;c+=1\nprint(a)'] | ['Runtime Error', 'Accepted'] | ['s036557832', 's254072261'] | [136252.0, 9332.0] | [2104.0, 66.0] | [318, 76] |
p03200 | u929201588 | 2,000 | 1,048,576 | There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed. | ["# AtCoder Grand Contest 029\n# December 15, 2018\n#\n\nS = input()\ncount = 0\n\nwhile True:\n if S.find('BW') >= 0:\n S = S.replace('BW', 'WB', 1)\n count += 1\n print(S)\n else:\n break\n\nprint(count)", "S = input()\nN = len(S)\n\ncount = 0\nnum = 0\nidx = -1\nwhile True:\n idx = S.find('W', idx + 1)\n if idx < 0:\n break\n count += idx - num\n num += 1\n\nprint(count)"] | ['Runtime Error', 'Accepted'] | ['s052330941', 's332965378'] | [134588.0, 3500.0] | [711.0, 98.0] | [202, 161] |
p03200 | u930970950 | 2,000 | 1,048,576 | There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed. | ['from collections import Counter as C\nn = int(input())\nl = sorted(map(int, input().split()), reverse = True)\nc = C(l)\nres = 0\nfor e in l:\n for p in range(32, 0, -1):\n e_ = (1 << p) - e\n if c.get(e_, 0) > 0:\n # print(e, e_, c)\n c[e_] -= 1\n c[e] -= 1\n res += 1\n break\nprint(res)', "s = input()\nl = []\ni = 0\nn = len(s)\nwhile i < n:\n j = 0\n while i < n and s[i] == 'B':\n j += 1\n i += 1\n l.append(j)\n\n j = 0\n while i < n and s[i] == 'W':\n j += 1\n i += 1\n l.append(j)\n# print(l)\nres = 0\nfor i in range(0, len(l), 2):\n if l[i] > 0:\n res += l[i] * l[i + 1]\n if i + 2 < len(l):\n l[i + 2] += l[i]\nprint(res)"] | ['Runtime Error', 'Accepted'] | ['s100145574', 's038421850'] | [3876.0, 5852.0] | [22.0, 135.0] | [347, 383] |
p03200 | u953020348 | 2,000 | 1,048,576 | There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed. | ["S = input()\nprint(S.count('w')*2)\n", '# -*- coding: utf-8 -*-\nS = input()\nbcount=S.count(\'B\')\nwcount=S.count(\'W\')\nSlen=len(S)\nans=0\nbb=0\nfor i in range(Slen):\n if i!=Slen:\n if S[Slen-i-1]=="B":\n ans=ans+bb\n else:\n bb=bb+1\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s878859230', 's406146703'] | [3500.0, 3500.0] | [18.0, 81.0] | [34, 234] |
p03200 | u954774382 | 2,000 | 1,048,576 | There are N Reversi pieces arranged in a row. (A _Reversi piece_ is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S_i=`W`, the i-th piece from the left is showing white. Consider performing the following operation: * Choose i (1 \leq i < N) such that the i-th piece from the left is showing black and the (i+1)-th piece from the left is showing white, then flip both of those pieces. That is, the i-th piece from the left is now showing white and the (i+1)-th piece from the left is now showing black. Find the maximum possible number of times this operation can be performed. | ['import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\nfrom math import *\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n\n\n# sys.stdout = open("output.txt", "w")\nmod = int(pow(10, 9) + 7)\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end="\\n"): sys.stdout.write(\' \'.join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\n\n\n\n# @lru_cache(None)\ns=list(input())\nk=0\ni=0\nwhile(i+1<len(s)):\n if(s[i]=="B" and s[i+1]=="W"):\n s[i],s[i+1]=s[i+1],s[i]\n k+=1\n i+=1\nprint(k)\n', 'import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\nfrom math import *\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n\n\n# sys.stdout = open("output.txt", "w")\nmod = int(pow(10, 9) + 7)\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end="\\n"): sys.stdout.write(\' \'.join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\n\n\n\n# @lru_cache(None)\ns=list(input())\nA=[]\nfor i in range(len(s)):\n if(s[i]=="W"):\n A.append(i)\nk=0\ni=0\nfor x in A:\n k+=(x-i)\n i+=1\nprint(k)'] | ['Wrong Answer', 'Accepted'] | ['s330609002', 's773052422'] | [7232.0, 14852.0] | [175.0, 123.0] | [1075, 1068] |
p03201 | u013408661 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['def reversed_num(num):\n num_len=len(bin(num))-2\n f=2**num_len-1\n return num^f\nn=int(input())\nnumber=list(map(int,input().split()))\nnumber.sort()\nnumber.reversed()\ngoal=[]\nfor i in number:\n if i != reversed_num(i)+1:\n goal.append(reversed_num(i)+1)\n number.remove(reversed_num(i)+1)\nprint(len(set(number)&set(goal)))', 'def reversed_num(num):\n num_len=len(bin(num))-2\n f=2**num_len-1\n return num^f\nn=int(input())\nnumber=list(map(int,input().split()))\nnumber.sort()\ncount=0\nwhile len(number)>0:\n x=reversed_num(number[-1])+1\n if x in number:\n number.remove(x)\n count+=1\n number.pop()\nprint(count)\n', 'def reversed_num(num):\n num_len=len(bin(num))-2\n f=2*num_len-1\n return num^f', 'def reversed_num(num):\n num_len=len(bin(num))-2\n f=2**num_len-1\n return num^f\nn=int(input())\nnumber=list(map(int,input().split()))\nnumber.sort()\ncount=0\nwhile len(number)>0:\n if reversed_num(number[-1])+1 in number and number[-1]!=reversed_num(number[-1])+1:\n number.remove(reversed_num(number[-1])+1)\n count+=1\nprint(count)\n', 'def reversed_num(num):\n num_len=len(bin(num))-2\n f=2**num_len-1\n return num^f\nn=int(input())\nnumber=list(map(int,input().split()))\nnumber.sort()\nnumber.reverse()\nfor i in number:\n if i!=reversed_num(i)+1 and reversed_num(i)+1 in number:\n number.remove(reversed_num(i)+1)\n count+=1\nprint(count)', 'import bisect\n\ndef number(num):\n \n number_len = len(num)-2\n \n f οΌ 2**number_len - 1\n \n return (num^f)+1\n\nline=list(map(int,input().split))\n\ncount=0\n\nwhile len(line)>0:\n \n k=line.pop()\n \n if int(k) != k:\n continue\n x=number(k)\n \n if x>line[-1]:\n continue\n \n if line[bisect.bisect_left(line,x)]==x:\n \n line[bisect.bisect_left(line,x)] += 0.5\n count+=1\n\nprint(count)', 'def reversed_num(num):\n num_len=len(bin(num))-2\n f=2**num_len-1\n return num^f\nn=int(input())\nnumber=list(map(int,input().split()))\nnumber.sort()\nnumber.reverse()\ngoal=[]\nfor i in number:\n if i != reversed_num(i)+1:\n goal.append(reversed_num(i)+1)\n number.remove(reversed_num(i)+1)\nprint(len(set(number)&set(goal)))\n', 'import bisect\n\ndef number(num):\n \n number_len = len(num)-2\n \n f οΌ 2**number_len - 1\n \n return (num^f)+1\n\nn=int(input())\nline=list(map(int,input().split))\n\ncount=0\n\nwhile len(line)>0:\n \n k=line.pop()\n \n if int(k) != k:\n continue\n x=number(k)\n \n if x>line[-1]:\n continue\n \n if line[bisect.bisect_left(line,x)]==x:\n \n line[bisect.bisect_left(line,x)] += 0.5\n count+=1\n\nprint(count)', 'def reversed_num(num):\n num_len=len(bin(num))-2\n f=2*num_len-1\n return num^f\nn=int(input())\nnumber=list(map(int,input().split()))\ngoal=[]\nfor i in number:\n goal.append(reversed_num(i)+1)\nprint(len(set(number)&set(goal)))', 'def reversed_num(num):\n num_len=len(bin(num))-2\n f=2**num_len-1\n return num^f\nn=int(input())\nnumber=list(map(int,input().split()))\nnumber.sort()\ncount=0\nwhile len(number)>0:\n q=number[-1]\n x=reversed_num(number[-1])+1\n number.pop()\n if x!=q:\n if x in list:\n number.remove(x)\n count+=1\nprint(count)\n', 'import bisect\ndef reversed_num(num):\n num_len=len(bin(num))-2\n f=2**num_len-1\n return num^f\nn=int(input())\nnumber=list(map(int,input().split()))\nnumber.sort()\ncount=0\nwhile len(number)>0:\n x=reversed_num(number.pop())+1\n if number[bisect.bisect_left(number,x)] ==x:\n number[bisect.bisect_left(number,x)]=0\n count+=1\nprint(count)\n', 'import bisect\ndef reversed_num(num):\n num_len=len(bin(num))-2\n f=2**num_len-1\n return num^f\nn=int(input())\nnumber=list(map(int,input().split()))\nnumber.sort()\ncount=0\nwhile len(number)>0:\n x=reversed_num(number.pop())+1\n if number[bisect.bisect_left(number,x)] ==x:\n number.pop(bisect.bisect_left(number,x))\n count+=1\nprint(count)', 'import bisect\ndef reversed_num(num):\n num_len=len(bin(num))-2\n f=2**num_len-1\n return num^f\nn=int(input())\nnumber=list(map(int,input().split()))\nnumber.sort()\ncount=0\nwhile len(number)>0:\n x=reversed_num(number.pop())+1\n if len(number)==0:\n break\n y=bisect.bisect_left(number,x)\n if x>number[-1]:\n y-=1\n if number[y] ==x:\n number[y]+=0.5\n count+=1\nprint(count)', 'import bisect\n\ndef number(num):\n \n number_len = len(bin(num))-2\n \n f = 2**number_len - 1\n \n return (num^f)+1\n\nn=int(input())\nline=list(map(int,input().split()))\n\nline.sort()\n\ncount=0\n\nwhile len(line)>0:\n \n k=line.pop()\n \n if len(line)==0:\n break\n \n if int(k) != k:\n continue\n x=number(k)\n \n if x>line[-1]:\n continue\n \n if line[bisect.bisect_left(line,x)]==x:\n \n line[bisect.bisect_left(line,x)] -= 0.5\n count+=1\n\nprint(count)'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Time Limit Exceeded', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s061103995', 's246764492', 's290802000', 's406623831', 's570668578', 's606140987', 's677693936', 's683630076', 's686341109', 's715343108', 's849581020', 's864735167', 's910645192', 's648673677'] | [26932.0, 26356.0, 2940.0, 26180.0, 25364.0, 2940.0, 25744.0, 2940.0, 42252.0, 26932.0, 25708.0, 27060.0, 25708.0, 25708.0] | [148.0, 2105.0, 18.0, 2104.0, 2104.0, 18.0, 2105.0, 19.0, 212.0, 277.0, 444.0, 2104.0, 430.0, 608.0] | [325, 288, 79, 335, 303, 960, 325, 975, 224, 318, 340, 341, 380, 1134] |
p03201 | u017810624 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import math\nimport bisect\nn=int(input())\na=list(map(int,input().split()))\na.sort()\nb=[]\nfor i in range(1,50):\n b.append(2**i)\nct=0\ncheck=[1]*n\nfor i in range(n-1,-1,-1):\n if a[i]==1:\n break\n if check[i]==1 and a[i] not in b:\n check[i]=0\n x=math.floor(math.log2(a[i]))\n x=b[x]-a[i]\n y=bisect.bisect_left(a,x)\n z=bisect.bisect_right(a,x)\n t=bisect.bisect_left(check[y:z],1)+y\n if t!=z:\n check[t]=0\n ct+=1\n\nctb=0\nw=1\nfor i in range(30):\n if a[i] in b or a[i]==1:\n if a[i]==w:\n if check[i]==1:\n ctb+=1\n else:\n ct+=ctb//2\n w=a[i]\n if check[i]==1:\n ctb=1\n else:\n ctb=0\n else:\n ct+=ctb//2\n ctb=0\nct+=ctb//2\n\nprint(ct)', 'n=int(input())\na=list(map(int,input().split()))\nct=0\n\nM=max(a)\nfor i in range(100):\n if 2**i>M:\n x=i\n break\nL=[]\nfor j in range(2**x-1):\n L.append(0)\n\nfor j2 in range(n):\n L[a[j2]-1]+=1\n\nfor k in range(x,1,-1):\n l1=L[0:2**(k-1)-1]\n l2=L[2**(k-1):2**k]\n l2.reverse()\n ct+=int(L[2**(k-1)-1]/2)\n for m in range(len(l1)):\n if l1[m]>=1 and l2[m]>=1:\n ct+=min(l1[m],l2[m])\n l1[m]-=min(l1[m],l2[m])\n l2[m]-=min(l1[m],l2[m])\n L=l1\nct+=int(L[0]/2)\nprint(ct)\nprint(x)', 'n=int(input())\na=list(map(int,input().split()))\nct=0\n \nM=max(a)\nmin=min(a)\n\nif m>=10**8:\n print(0)\nelse:\n for i in range(100):\n if 2**i>M:\n x=i\n break\n L=[]\n for j in range(2**x-1):\n L.append(0)\n \n for j2 in range(n):\n L[a[j2]-1]+=1\n \n for k in range(x,1,-1):\n l1=L[0:2**(k-1)-1]\n l2=L[2**(k-1):2**k]\n l2.reverse()\n ct+=int(L[2**(k-1)-1]/2)\n for m in range(len(l1)):\n if l1[m]>=1 and l2[m]>=1:\n ct+=min(l1[m],l2[m])\n l1[m]-=min(l1[m],l2[m])\n l2[m]-=min(l1[m],l2[m])\n L=l1\n ct+=int(L[0]/2)\n print(ct)', 'import math\nimport bisect\nn=int(input())\na=list(map(int,input().split()))\na.sort()\n\nx=a[0];ctn=1;l=[];l2=[]\nfor i in range(1,n):\n if x==a[i]:\n ctn+=1\n else:\n l.append([x,ctn])\n l2.append(x)\n x=a[i]\n ctn=1\nl.append([x,ctn])\nl2.append(x)\n\nb=[2**i for i in range(1,50)]\n\nct=0\nfor i in range(len(l2)-1,-1,-1):\n x=math.floor(math.log2(l2[i]))\n x=b[x]-l2[i]\n y=bisect.bisect_left(l2,x)\n if l2[y]==x:\n if l2[y]!=l2[i]:\n m=min(l[i][1],l[y][1])\n else:\n m=l[i][1]//2\n l[i][1]-=m\n l[y][1]-=m\n ct+=m\nprint(ct)'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s012315838', 's060970731', 's074573809', 's719113058'] | [25840.0, 199916.0, 25496.0, 35396.0] | [781.0, 2115.0, 76.0, 764.0] | [707, 490, 572, 543] |
p03201 | u029169777 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['from collections import Counter\nimport math\n\nN=int(input())\n\nA=list(map(int,input().split()))\n\nanswer=0\nA.sort(reverse=True)\n\nAmax=A[0]\nlimit=1\nwhile(True):\n if limit>Amax:\n break;\n limit*=2\n\nAcounter=Counter(A)\nprint(Acounter)\n\nwhile(limit!=1):\n for number,count in Acounter.items():\n if limit-number in Acounter.keys():\n if number==limit-number:\n dec=math.floor(Acounter[number]/2)\n Acounter[number]-=dec\n else:\n dec=min(Acounter[number],Acounter[limit-number])\n Acounter[number]-=dec\n Acounter[limit-number]-=dec\n answer+=dec\n limit=int(limit/2)\nprint(answer)', 'from collections import Counter\nimport math\n\nN=int(input())\n\nA=list(map(int,input().split()))\n\nanswer=0\nA.sort(reverse=True)\n\nAmax=A[0]\nlimit=1\nwhile(True):\n if limit>Amax:\n break;\n limit*=2\n\nAcounter=Counter(A)\nprint(Acounter)\n\nwhile(limit!=1):\n eraserlist=[]\n for number,count in Acounter.items():\n if limit-number in Acounter.keys():\n if number==limit-number:\n dec=math.floor(Acounter[number]/2)\n Acounter[number]-=dec*2\n else:\n dec=min(Acounter[number],Acounter[limit-number])\n Acounter[number]-=dec\n Acounter[limit-number]-=dec\n if Acounter[limit-number]==0:\n eraserlist.append(limit-number)\n if Acounter[number]==0:\n eraserlist.append(number)\n answer+=dec\n if number>=limit/2:\n eraserlist.append(number)\n for i in range(len(eraserlist)):\n if eraserlist[i] in Acounter.keys():\n Acounter.pop(eraserlist[i])\n limit=int(limit/2)\nprint(answer)\nprint(Acounter)', 'from collections import Counter\nimport math\n\nN=int(input())\n\nA=list(map(int,input().split()))\n\nanswer=0\nA.sort(reverse=True)\n\nAmax=A[0]\nlimit=1\nwhile(True):\n if limit>Amax:\n break;\n limit*=2\n\nAcounter=Counter(A)\n#print(Acounter)\n\nwhile(limit!=1):\n eraserlist=[]\n for number,count in Acounter.items():\n if limit-number in Acounter.keys():\n if number==limit-number:\n dec=math.floor(Acounter[number]/2)\n Acounter[number]-=dec*2\n else:\n dec=min(Acounter[number],Acounter[limit-number])\n Acounter[number]-=dec\n Acounter[limit-number]-=dec\n if Acounter[limit-number]==0:\n eraserlist.append(limit-number)\n if Acounter[number]==0:\n eraserlist.append(number)\n answer+=dec\n if number>=limit/2:\n eraserlist.append(number)\n for i in range(len(eraserlist)):\n if eraserlist[i] in Acounter.keys():\n Acounter.pop(eraserlist[i])\n limit=int(limit/2)\nprint(answer)\n#print(Acounter)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s734593976', 's994211767', 's738079905'] | [53948.0, 53568.0, 33296.0] | [2105.0, 1026.0, 923.0] | [622, 966, 968] |
p03201 | u060392346 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['from collections import defaultdict\ndef log2(n):\n if n < 2:\n return 0\n else:\n return 1 + log2(n // 2)\n\nn = int(input())\na_list = list(map(int, input().split()))\nd = defaultdict(int)\na_list.sort()\n\nfor a in a_list:\n d[a] += 1\n\na_list = list(set(a_list))\nc = 0\nfor a in a_list:\n m = log2(a, 2)\n x = 2 ** (m+1) - a\n if x == a:\n c += d[a] // 2\n d[a] -= d[a] // 2\n else:\n c += min(d[x], d[a])\n d[x] -= min(d[x], d[a])\n\nprint(c)\n ', 'def two_power(m):\n if m < 2:\n return 0\n else:\n return two_power(m//2) + 1\n\nn = int(input())\na = list(map(int, input().split()))\n\na.sort()\na.reverse()\nc = 0\nskip = []\nfor i in range(len(a)):\n if i in skip:\n continue\n m = two_power(a[i])\n if 2 ** (m+1) - a[i] in a:\n j = a.index(2 ** (m+1) - a[i])\n if j not in skip:\n c += 1\n skip.append(j)\n \nprint(c)\n\n', 'from collections import defaultdict\nimport math\n\nn = int(input())\na_list = list(map(int, input().split()))\nd = defaultdict(int)\n\nfor a in a_list:\n d[a] += 1\n\na_list = reversed(sorted(list(set(a_list))))\nc = 0\nfor a in a_list:\n m = int(math.log(a, 2))\n x = 2 ** (m+1) - a\n if x == a:\n c += d[a] // 2\n d[a] -= d[a] // 2\n else:\n c += min(d[x], d[a])\n d[x] -= min(d[x], d[a])\n\nprint(c)\n '] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s309408627', 's851018674', 's444334028'] | [41228.0, 26932.0, 60660.0] | [308.0, 2104.0, 811.0] | [452, 384, 403] |
p03201 | u070561949 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['n = int(input())\na = list(map(int,input().split()))\na.sort(reverse=True)\n\nb = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, \n 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, \n 67108864, 134217728, 268435456, 536870912]\n\nsum = 0\ni = 0\nu = [0 for i in range(len(a))]\nwhile True:\n\n t = 0\n for bb in b :\n if bb > a[i]:\n t = bb - a[i]\n break\n \n try:\n idx = a.index(t)\n if u[idx] != 1: \n sum += 1\n u[idx] = 1\n except Exception as e:\n pass\n \n i = i + 1\n if i >= len(a)-1:\n break\n\nprint(sum)', 'n = int(input())\na = list(map(int,input().split()))\na.sort()\nb = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, \n 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, \n 67108864, 134217728, 268435456, 536870912]\n\nt = []\nbIdx = 0\nfor aa in a :\n while b[bIdx] <= aa:\n bIdx += 1 \n t.append(b[bIdx]-aa)\nt.reverse()\na.sort(reverse=True)\n\nc = {}\nfor aa in a:\n if aa in c:\n c[aa] += 1\n else:\n c[aa] = 1\n\nsum = 0\ni = 0\n\nu = [0 for i in range(len(a))]\n\nfor i in range(len(a)-1):\n\n if u[i] > 0:\n continue\n\n if t[i] in c :\n if c[t[i]] > 0 :\n sum += 1\n c[t[i]] -= 1\n \nprint(sum)', 'from bisect import bisect_left\n\nn = int(input())\na = list(map(int,input().split()))\na.sort()\nb = [1,2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, \n 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, \n 67108864, 134217728, 268435456, 536870912]\n\nt = []\nbIdx = 0\nfor aa in a :\n while b[bIdx] <= aa:\n bIdx += 1 \n t.append(b[bIdx]-aa)\n#t.sort()\n\n\nu = [0 for i in range(len(t))]\n\n#print(a) \n#print(t)\nsum = 0\nfor i in range (len(a)-1,-1,-1):\n k = bisect_left(a,t[i])\n print(t[i],k)\n if a[k] == t[i] and k < i:\n #print(a[i],t[i],i)\n sum += 1\n a[k] -= 0.1\n a[i] += 0.1\n u[k] += 1\n#print(sum)', 'from bisect import bisect_left\n\nn = int(input())\na = list(map(int,input().split()))\na.sort()\nb = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, \n 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, \n 67108864, 134217728, 268435456, 536870912]\n\nt = []\nbIdx = 0\nfor aa in a :\n while b[bIdx] <= aa:\n bIdx += 1 \n t.append(b[bIdx]-aa)\nt.sort(reverse=True)\n\n\nu = [0 for i in range(len(t))]\n\n#print(a) \n#print(t)\nsum = 0\nfor i in range (len(a)-1,-1,-1):\n k = bisect_left(a,t[i])\n #print(t[i],k)\n if a[k] == t[i] and u[k] == 0 and k != i:\n #print(a[i],t[i],i)\n sum += 1\n u[k] += 1\nprint(sum)', 'n = int(input())\na = list(map(int,input().split()))\na.sort()\nb = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, \n 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, \n 67108864, 134217728, 268435456, 536870912]\n\nt = []\nbIdx = 0\nfor aa in a :\n while b[bIdx] <= aa:\n bIdx += 1 \n t.append(b[bIdx]-aa)\n\nt.reverse()\na.sort(reverse=True)\n\nsum = 0\ni = 0\n\n#print(t,a)\n\nwhile True:\n \n first = i+1\n last = len(a)-1\n found = False\n\n while first<=last and not found:\n midpoint = (first + last)//2\n if a[midpoint] == t[i] :\n found = True\n sum += 1\n a = a[:midpoint]\n a.extend(a[midpoint:])\n print(a)\n else:\n if t[i] > a[midpoint]:\n last = midpoint-1\n else:\n first = midpoint+1\n \n i = i + 1\n if i >= len(a)-1:\n break\n\nprint(sum)', 'from bisect import bisect_left\n\nn = int(input())\na = list(map(int,input().split()))\na.sort()\n#print(a)\n\nsum = 0\nfor i in range (len(a)-1,-1,-1):\n\n b = 1\n while b <= a[i]:\n b = b<<1\n t = b - a[i]\n #print("2^",t)\n\n k = bisect_left(a,t)\n if a[k] == t and k < i:\n sum += 1\n a[k] -= 0.1\n a[i] += 0.1\nprint(sum)'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s365241990', 's398742576', 's464751669', 's698322090', 's777942441', 's237919609'] | [27060.0, 40592.0, 27712.0, 27060.0, 159552.0, 26932.0] | [2104.0, 394.0, 844.0, 393.0, 2105.0, 1653.0] | [673, 720, 723, 707, 967, 352] |
p03201 | u091051505 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['N = int(input())\nA = set([int(i) for i in input().split()])\nans = 0\nwhile A:\n a = A.pop()\n for i in range(2, 32):\n if (pow(2, i) - a) in A:\n ans += 1\n print(pow(2, i), a)\nprint(ans)', 'from collections import defaultdict\nfrom bisect import bisect_right\n\nballs_count = defaultdict(int)\n\nN = int(input())\nA = [int(i) for i in input().split()]\nA.sort(reverse=True)\nans = 0\nbeki_list = [pow(2, i) for i in range(1, 32)]\nfor a in A:\n balls_count[a] += 1\n\nfor a in A:\n if balls_count[a] == 0:\n continue\n balls_count[a] -= 1\n index = bisect_right(beki_list, a)\n pair = beki_list[index] - a\n if balls_count[pair] > 0:\n balls_count[pair] -= 1\n ans += 1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s815487723', 's826904868'] | [31140.0, 55136.0] | [2206.0, 351.0] | [216, 508] |
p03201 | u118642796 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\ndic = {}\nfor a in A:\n dic[a] = dic.get(a,0)+1\nans = 0\n\nfor a in A:\n small = (1<<(len(format(a+1,"b")))) - a\n if dic.get(a,0)>0:\n dic[a] -= 1\n if dic.get(small,0)>0:\n dic[small] -= 1\n ans += 1\nprint(ans)\n', 'N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\ndic = {}\nfor a in A:\n dic[a] = dic.get(a,0)+1\nprint(dic)\nans = 0\n\nfor a in A:\n if dic[a]==0:\n continue\n small = (1<<(len(format(a,"b")))) - a\n if dic.get(small,0)>0:\n dic[small] -= 1\n ans += 1\nprint(ans)\n', 'import bisect\n\nN = int(input())\nA = list(map(int,input().split()))\nA.sort()\nans = 0\nL=0\nt=31\nwhile(t>0):\n if len(A) == 0:\n break\n if A[-1]<(1<<(t-1)) or (1<<t) <= A[-1]:\n t -= 1\n L = 0\n continue\n\n large = A.pop(-1)\n small = (1<<t)-large\n if small < A[0] or A[-1]< small:\n t -= 1\n L = 0\n continue\n tmp = bisect.bisect_left(A,(1<<t)-large,lo=L,hi=len(A))\n if tmp == len(A):\n t -= 1\n L = 0\n continue\n if A[tmp] == (1<<t)-large:\n del A[tmp]\n ans += 1\n L = max(0,tmp-1)\n\nprint(ans)\n', 'N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\ndic = {}\nfor a in A:\n dic[a] = dic.get(a,0)+1\nans = 0\n\nfor a in A:\n small = (1<<(len(format(a,"b")))) - a\n if dic.get(a,0)>0 and dic.get(small,0)>0:\n dic[a] = dic.get(a)-1\n dic[small] = dic.get(small)-1\n ans += 1\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\ndic = {}\nfor a in A:\n dic[a] = dic.get(a,0)+1\nprint(dic)\nans = 0\n\nfor a in A:\n small = (1<<(len(format(a+1,"b")))) - a\n if dic.get(a,0)>0 and dic.get(small,0)>0:\n dic[a] = dic.get(a)-1\n dic[small] = dic.get(small)-1\n ans += 1\nprint(ans)\n', 'N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\ndic = {}\nfor a in A:\n dic[a] = dic.get(a,0)+1\nans = 0\n\nfor a in A:\n small = (1<<(len(format(a+1,"b")))) - a\n if dic.get(a,0)>0 and dic.get(small,0)>0:\n dic[a] -= 1\n dic[small] -= 1\n ans += 1\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\ndic = {}\nfor a in A:\n dic[a] = dic.get(a,0)+1\nans = 0\n\nfor a in A:\n small = (1<<(len(format(a,"b")))) - a\n if dic.get(a,0)>0 and dic.get(small,0)>0:\n dic[a] -= 1\n dic[small] -= 1\n ans += 1\nprint(ans)\n', 'N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\ndic = {}\nfor a in A:\n dic[a] = dic.get(a,0)+1\nans = 0\n\nfor a in A:\n small = (1<<(len(format(a,"b")))) - a\n if small == a:\n if dic[a] >= 2:\n dic[a] -= 2\n ans += 1\n continue\n if dic.get(a,0)>0 and dic.get(small,0)>0:\n dic[a] -= 1\n dic[small] -= 1\n ans += 1\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s024983844', 's249409444', 's442663214', 's488608738', 's679795170', 's917496833', 's998192099', 's432333400'] | [33600.0, 34240.0, 25708.0, 33696.0, 34988.0, 33856.0, 33696.0, 33860.0] | [462.0, 449.0, 2104.0, 436.0, 481.0, 453.0, 430.0, 437.0] | [309, 310, 592, 326, 340, 304, 303, 408] |
p03201 | u138486156 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['from collections import Counter\nn = int(input())\nA = sorted(list(map(int, input().split())))[-1::-1]\nc = Counter(A)\nans = 0\nfor a in A:\n b = (1<<m.bit_length()) - a\n if a == b and c[a] > 1:\n c[a] -= 2\n ans += 1\n elif a != b and c[a] > 0 and c[b] > 0:\n c[a] -= 1\n c[b] -= 1\n ans += 1\nprint(ans)\n', 'from collections import Counter\nn = int(input())\nA = sorted(list(map(int, input().split())))[-1::-1]\nc = Counter(A)\nans = 0\nfor a in A:\n b = (1<<a.bit_length()) - a\n if a == b and c[a] > 1:\n c[a] -= 2\n ans += 1\n elif a != b and c[a] > 0 and c[b] > 0:\n c[a] -= 1\n c[b] -= 1\n ans += 1\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s505826766', 's499780124'] | [33476.0, 33604.0] | [202.0, 444.0] | [338, 338] |
p03201 | u142415823 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import bisect\n\nN = int(input())\nA = list(map(int, input().split()))\nlist_ = [2 ** i for i in range(30)]\nA.sort(reverse=True)\n\nans = 0\nwhile(len(A) > 0):\n a = A.pop()\n tmp = [i - a for i in list_ if i - a > 0]\n for b in tmp:\n i = bisect.bisect_left(A, b)\n if i < len(A) and A[i] == b:\n ans += 1\n A.pop(i)\n break\n\nprint(ans)', 'from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\nc = Counter(A)\n\nans = 0\nfor a in A:\n b = (1 << a.bit_length()) - a\n if b in c.keys():\n if a == b and c[a] > 1:\n c[a] -= 2\n ans += 1\n elif a != b and c[a] > 0 and c[b] > 0:\n c[a] -= 1\n c[b] -= 1\n ans += 1\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s195946254', 's688855629'] | [25708.0, 33296.0] | [2104.0, 393.0] | [378, 397] |
p03201 | u148423304 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import math\nn = int(input())\nl = sorted(list(map(int,input().split())))\nc = 0\nb = {}\nfor i in range(len(l)):\n if l[i] in b:\n b[l[i]] += 1\n else:\n b[l[i]] = 1\n\nfor i in range(len(l) - 1, -1, -1):\n if b[l[i]] == 0:\n continue\n t = l[i]\n b[l[i]] -= 1\n s = 2 ** math.floor(math.log2(temp))\n st = 2*s - t \n if l == []:\n break\n if st in b and b[st] > 0:\n b[2 * s - t] -= 1\n c += 1\nprint(c)', 'import math\nn = int(input())\nl = sorted(list(map(int,input().split())))\nc = 0\nb = {}\nfor i in range(len(l)):\n if l[i] in b:\n b[l[i]] += 1\n else:\n b[l[i]] = 1\n\nfor i in range(len(l) - 1, -1, -1):\n if b[l[i]] == 0:\n continue\n t = l[i]\n b[l[i]] -= 1\n s = 2 ** math.floor(math.log2(t))\n st = 2*s - t \n if l == []:\n break\n if st in b and b[st] > 0:\n b[2 * s - t] -= 1\n c += 1\nprint(c)'] | ['Runtime Error', 'Accepted'] | ['s612070761', 's927476078'] | [33168.0, 33168.0] | [240.0, 508.0] | [452, 449] |
p03201 | u263654061 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['n= int(input())\na = list(map(int, input().split()))\n\nli = []\n\nfor i in range(n):\n for t in range(1, 31):\n try:\n tmp = a[(i+1):n].index(2**t - a[i])\n li.append([a[i], a[tmp+i+1]])\n except:\n pass\n\nfrom itertools import combinations\n\nMAX = len(li)\n\nflag=0\nfor j in range(MAX, 0, -1):\n for c in combinations(li, j):\n # print(c)\n\n cntSet = set()\n for _ in range(2):\n for i in range(len(c)):\n # print(c, c[i])\n if c[i][_] in cntSet:\n flag = 1\n break\n else:\n cntSet.add(c[i][_])\n \n if flag==0:\n break\n\n if flag==0:\n break\nprint(len(cntSet))', 'n= int(input())\na = list(map(int, input().split()))\n\ndef nibeki(x):\n cnt = 0\n while(x>1):\n x //=2\n cnt += 1\n return 2**(cnt+1)\n\n# a.sort(reverse=True)\na.sort()\n\nfrom collections import Counter\nc = Counter(a)\nprint(c)\n\n# print(a)\ncntSet = 0\ncntList = [0 for _ in range(len(a))]\n\nfor i in range(len(a)-1, 0, -1):\n pair = nibeki(a[i])-a[i]\n if pair in a and cntList[i]==0:\n \n cntList[i]=1\n if cntList[a.index(pair)]==0:\n cntList[a.index(pair)]=1\n cntSet += 1\n\nprint(cntSet)', 'from collections import Counter\n\nn= int(input())\na = list(map(int, input().split()))\n\ndef nibeki(x):\n cnt = 0\n while(x>1):\n x //=2\n cnt += 1\n return 2**(cnt+1)\n\na.sort(reverse=True)\n\nprint(a)\ncntSet = 0\ncntList = [0 for _ in range(len(a))]\nc = Counter(a)\n\nfor i in range(len(a)):\n pair = nibeki(a[i])-a[i]\n if pair in c.keys() and cntList[i]==0 and cntList[a.index(pair)]==0:\n cntList[i]=1\n cntList[a.index(pair)]=1\n cntSet += 1\n\nprint(cntSet)', 'import math\n\nn= int(input())\na = list(map(int, input().split()))\n\ndef nibeki(x):\n cnt = 0\n while(x>1):\n x //=2\n cnt += 1\n return 2**(cnt+1)\n\n \n\na.sort(reverse=True)\n\nprint(a)', 'from collections import Counter\n\nn= int(input())\na = list(map(int, input().split()))\n\ndef nibeki(x):\n cnt = 0\n while(x>1):\n x //=2\n cnt += 1\n return 2**(cnt+1)\n\ncntSet = 0\nc = Counter(a)\nks = list(c.keys())\nks.sort(reverse=True)\n\nfor k in ks:\n pair = nibeki(k)-k\n if k==pair:\n cntSet += c[k]//2\n\n elif c[k]>0 and c[pair]>0:\n COUNT = min(c[k], c[pair])\n c[k] -= COUNT\n c[pair] -= COUNT\n cntSet +=COUNT\n\nprint(cntSet)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s501828896', 's606009776', 's703054239', 's746278115', 's218110612'] | [27060.0, 54588.0, 37100.0, 25964.0, 33296.0] | [2104.0, 2106.0, 2105.0, 172.0, 1078.0] | [755, 564, 493, 235, 482] |
p03201 | u268516119 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['#AGC030 B - Powers of two\nimport collections\nimport math\nN=int(input())\nA=list(map(int,input().split()))\nA.sort(reverse=True)\ncnter=collections.Counter(A)\nans=0\nfor a in A:\n inv=2**(int(math.log2(a))+1)\n if cnter[a]==0:\n continue\n if cnter[a]>=2 and a==inv//2:a\n cnter[a]=cnter[a]-2\n ans=ans+1\n continue\n if inv-a in cnter:\n cnter[inv-a]=cnter[inv-a]-1\n ans=ans+1\nprint(ans)', '#AGC030 B - Powers of two\nimport collections\nimport math\nbeki=[]\nfor i in range(1,32):\n beki.append(2**i)\nN=int(input())\nA=list(map(int,input().split()))\nA.sort(reverse=True)\ncnter=collections.Counter(A)\nans=0\nfor a in A:\n inv=2**(int(math.log2(a))+1)\n if cnter[a]==0:\n continue\n if cnter[a]>=2 and a=inv//2:\n cnter[a]=cnter[a]-2\n ans=ans+1\n continue\n if inv-a in cnter:\n cnter[inv-a]=cnter[inv-a]-1\n ans=ans+1\nprint(ans)', '#AGC030 B - Powers of two\nimport collections\nbeki=[]\nfor i in range(1,32):\n beki.append(2**i)\nN=int(input())\nA=list(map(int,input().split()))\nA.sort(reverse=True)\ncnter=collections.Counter(A)\nans=0\nfor i in (reversed(beki)):\n for a in A:\n if (i//2<a<i and (i-a in cnter) )or(i//2==a and cnter[a]>=2):\n ans=ans+1\n A.remove(i-a)\nprint((N-len(A))//2)', '#AGC030 B - Powers of two\nbeki=[]\nfor i in range(1,32):\n beki.append(2**i)\ndef tasitekesu(data,n):\n result=[]\n kosu=0\n for i in range(len(data)):\n if i in result:\n continue\n for j in range(i):\n if j in result:\n continue\n if data[i]+data[j]==n:\n result.append(i)\n result.append(j)\n kosu=kosu+1\n break\n result.sort(reverse=True)\n for i in result:\n del data[i]\n return [data,kosu]\n\nN=int(input())\nA=input().split()\nans=0\nfor i in range(N):\n A[i]=int(A[i])\nsorted(A)\nfor i in (reversed(beki)):\n kesi=[]\n for j in range(len(A)):\n if j==len(A):\n break\n if i-A[j] in A:\n A.remove(i-A[j])\n kesi.append(j)\n ans=ans+1\n for j in (reversed(kesi)):\n A.pop(j)\nprint(ans)', '#AGC030 B - Powers of two\nimport collections\nbeki=[]\nfor i in range(1,32):\n beki.append(2**i)\nN=int(input())\nA=map(int,input().split())\nA.sorted(reverse=True)\ncnter=collections.Counter(A)\nans=0\nfor i in (reversed(beki)):\n for a in A:\n if (i//2<a<i and (i-a in cnter) )or(i//2==a and cnter[a]>=2):\n ans=ans+1\n A.remove(i-a)\nprint((N-len(A))//2)\n ', '#AGC030 B - Powers of two\nimport collections\nimport math\nN=int(input())\nA=list(map(int,input().split()))\nA.sort(reverse=True)\ncnter=collections.Counter(A)\nans=0\nfor a in A:\n inv=2**(int(math.log2(a))+1)\n if cnter[a]==0:\n continue\n if cnter[a]>=2 and a==inv//2:a\n cnter[a]=cnter[a]-2\n ans=ans+1\n continue\n if inv-a in cnter:\n cnter[inv-a]=cnter[inv-a]-1\n ans=ans+1\nprint(ans)', '#AGC030 B - Powers of two\nimport collections\nimport math\nbeki=[]\nfor i in range(1,32):\n beki.append(2**i)\nN=int(input())\nA=list(map(int,input().split()))\nA.sort(reverse=True)\ncnter=collections.Counter(A)\nans=0\nfor a in A:\n inv=2**(int(math.log2(a))+1)\n if cnter[a]==0:\n continue\n if inv-a in cnter:\n cnter[inv-a]=cnter[inv-a]-1\n ans=ans+1\nprint(ans)', '#AGC030 B - Powers of two\nbeki=[]\nfor i in range(1,32):\n beki.append(2**i)\nN=int(input())\nA=input().split()\nfor i in range(N):\n A[i]=int(A[i])\nsorted(A)\nfor i in (reversed(beki)):\n B=A\n for j in B:\n if j==i/2 and B.count(j)=>2:\n A.remove(j)\n A.remove(j)\n if i-j in A:\n A.remove(j)\n A.remove(i-j)\nprint((N-len(A))//2)', '#AGC030 B - Powers of two\nimport collections\nimport math\nN=int(input())\nA=list(map(int,input().split()))\nA.sort(reverse=True)\ncnter=collections.Counter(A)\nans=0\nfor a in A:\n inv=2**(int(math.log2(a))+1)\n if cnter[a]==0:\n continue\n if cnter[a]>=2 and a==inv//2:\n cnter[a]=cnter[a]-2\n ans=ans+1\n continue\n if inv-a in cnter:\n cnter[inv-a]=cnter[inv-a]-1\n ans=ans+1\nprint(ans)', '#AGC030 B - Powers of two\nimport collections\nimport math\nN=int(input())\nA=list(map(int,input().split()))\nA.sort(reverse=True)\ncnter=collections.Counter(A)\nans=0\nfor a in A:\n inv=2**(int(math.log2(a))+1)\n if cnter[a]==0:\n continue\n if inv==2*a and cnter[inv-a]<=1:\n \tcontinue\n if cnter[inv-a]>0:\n cnter[inv-a]=cnter[inv-a]-1\n cnter[a]=cnter[a]-1\n ans=ans+1\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s201755518', 's336590816', 's443582406', 's494530137', 's590081437', 's627266043', 's727605073', 's744451337', 's860567016', 's490449850'] | [2940.0, 2940.0, 33296.0, 21012.0, 19536.0, 2940.0, 33296.0, 2940.0, 33296.0, 33296.0] | [18.0, 18.0, 2105.0, 2105.0, 49.0, 18.0, 503.0, 18.0, 559.0, 541.0] | [428, 510, 414, 1034, 423, 428, 414, 441, 427, 411] |
p03201 | u268793453 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ["def main():\n from collections import Counter\n import sys\n input = sys.stdin.buffer.readline\n\n _ = int(input())\n A = [int(i) for i in input().split()]\n\n ans = 0\n c = Counter(A)\n B = sorted(c.keys(), reverse=True)\n\n for b in B:\n if c[b] == 0:\n continue\n a = (2 ** b.bit_length()) - b\n if a == b:\n cur = c[b]//2\n else:\n if a in C:\n cur = min(c[a], c[b])\n else:\n cur = 0\n ans += cur\n # c[b] -= cur\n c[a] -= cur\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", 'n = int(input())\nA = [int(i) for i in input().split()]\n\nA.sort()\nm = 1 << 30\nused = [False] * n\nans = 0\n\ndef search(ok, ng, n):\n if abs(ok-ng) <= 1:\n return ok\n mid = (ok+ng) // 2\n if A[mid] < n or (A[mid] == n and used[mid]):\n return search(mid, ng, n)\n else:\n return search(ok, mid, n)\n\nfor i in range(30):\n for j in range(n):\n if A[j] >= m:\n break\n if used[j]:\n cotinue\n a = search(-1, n, m - A[j]) + 1\n if a >= n:\n continue\n if A[a] == m - A[j]:\n if a == j:\n a += 1\n if a >= n or not A[a] == A[j]:\n continue\n used[a] = True\n used[j] = True\n ans += 1\n m >>= 1\n\nprint(ans)\n\n', "def main():\n from collections import Counter\n import sys\n input = sys.stdin.buffer.readline\n\n _ = int(input())\n A = [int(i) for i in input().split()]\n\n ans = 0\n c = Counter(A)\n B = sorted(c.keys(), reverse=True)\n\n for b in B:\n if c[b] == 0:\n continue\n a = (2 ** b.bit_length()) - b\n if a == b:\n cur = c[b]//2\n else:\n if a in c.keys():\n cur = min(c[a], c[b])\n else:\n cur = 0\n ans += cur\n # c[b] -= cur\n c[a] -= cur\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s010219074', 's634449960', 's977126775'] | [33780.0, 27060.0, 56624.0] | [219.0, 2104.0, 511.0] | [613, 780, 620] |
p03201 | u281303342 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\n\nans1, ans2 = 0,0\n\nmaxA = max(A)\nB = [1]\nt = 1\nwhile t < maxA:\n t *= 2\n B.append(t)\n\nd = dict()\nfor i in range(N):\n if A[i] in d:\n d[A[i]] += 1\n else:\n d[A[i]] = 1\n\nfor i in range(N):\n t = 2**len(bin(A[i])[2::]) - A[i]\n if t in d:\n if d[t] > 0:\n ans2 += 1\n d[t] -= 1\n d[A[i]] -= 1\n\nprint(ans1+ans2)', 'N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\n\nans1, ans2 = 0,0\n\nmaxA = max(A)\nB = [1]\nt = 1\nwhile t < maxA:\n t *= 2\n B.append(t)\n\nd = dict()\nfor i in range(N):\n if A[i] in B:\n ans1 += 1\n M -= 1\n else:\n if A[i] in d:\n d[A[i]] += 1\n else:\n d[A[i]] = 1\n\nfor i in range(N):\n if A[i] not in B:\n t = 2**len(bin(A[i])[2::]) - A[i]\n if t in d:\n if d[t] > 0:\n ans2 += 1\n d[t] -= 1\n d[A[i]] -= 1\n\nprint(ans1+ans2)', 'N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\n\nans1, ans2 = 0,0\n\nmaxA = max(A)\nB = [1]\nt = 1\nwhile t < maxA:\n t *= 2\n B.append(t)\n\nd = dict()\nfor i in range(N):\n if A[i] in d:\n d[A[i]] += 1\n else:\n d[A[i]] = 1\n\nfor i in range(N):\n t = 2**len(bin(A[i])[2::]) - A[i]\n if t in d:\n if t != A[i]:\n if d[t]>0 and d[A[i]]>0:\n ans2 += 1\n d[t] -= 1\n d[A[i]] -= 1\n else:\n if d[t] > 1:\n ans2 += 1\n d[t] -= 2\n\n\nprint(ans1+ans2)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s274495023', 's896928763', 's044485044'] | [33424.0, 34736.0, 34736.0] | [439.0, 671.0, 502.0] | [444, 566, 586] |
p03201 | u284854859 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import bisect\n \nn = int(input())\na = list(map(int, input().split()))\na.sort()\n \nres = 0\nfor i in range(n - 1 , -1, -1):\n if a[i] == int(a[i]):\n b = 1\n while b <= a[i]:\n b =b*2\n \n j = bisect.bisect_left(a, b - a[i])\n if i > j:\n if b - a[i] == a[j]:\n c += 1\n a[j] = a[j] - 0.5\n a[i] = a[i] + 0.5\nprint(res)', 'import bisect\n \nn = int(input())\na = list(map(int, input().split()))\na.sort()\n \nres = 0\nfor i in range(n - 1 , -1, -1):\n if a[i] == int(a[i]):\n b = 1\n while b <= A[i]:\n b =b*2\n \n j = bisect.bisect_left(A, b - A[i])\n if i > j:\n if b - a[i] == a[j]:\n c += 1\n a[j] = a[j] - 0.5\n a[i] = a[i] + 0.5\nprint(res)', 'import bisect\n \nn = int(input())\na = list(map(int, input().split()))\na.sort()\n \nres = 0\nfor i in range(n - 1 , -1, -1):\n if a[i] == int(a[i]):\n b = 1\n while b <= a[i]:\n b =b*2\n \n j = bisect.bisect_left(a, b - a[i])\n if i > j:\n if b - a[i] == a[j]:\n res += 1\n a[j] = a[j] - 0.5\n a[i] = a[i] + 0.5\nprint(res)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s287002468', 's694206515', 's739522469'] | [25712.0, 25712.0, 25708.0] | [201.0, 148.0, 1196.0] | [409, 409, 411] |
p03201 | u297109012 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['from collections import Counter\n\ndef ans_solve(N, As):\n C = Counter(As)\n ans = 0\n for d in As:\n n = (2 ** d.bit_length()) - d\n if d != n:\n if C[d] > 0 and C.get(n, 0) > 0:\n C[d] -= 1\n C[n] -= 1\n ans += 1\n else:\n ans += C[d]//2\n C[d] = 0\n return ans\n \n \nif __name__ == "__main__":\n N = input()\n As = [int(c) for c in input().split()]\n print(ans_solve(N, As))', 'def ans_solve(N, As):\n C = Counter(As)\n ans = 0\n for d in As:\n n = (2 ** d.bit_length()) - d\n if d != n:\n if C[d] > 0 and C.get(n, 0) > 0:\n C[d] -= 1\n C[n] -= 1\n ans += 1\n else:\n ans += C[d]//2\n C[d] = 0\n return ans\n \n\nif __name__ == "__main__":\n N = input()\n As = [int(c) for c in input().split()]\n print(ans_solve(N, As))\n', 'from collections import Counter\n\ndef ans_solve(N, As):\n C = Counter(As)\n ans = 0\n for d in reversed(sorted(As)):\n n = (2 ** d.bit_length()) - d\n if d != n:\n if C[d] > 0 and C.get(n, 0) > 0:\n C[d] -= 1\n C[n] -= 1\n ans += 1\n else:\n ans += C[d]//2\n C[d] = 0\n return ans\n \n \nif __name__ == "__main__":\n N = input()\n As = [int(c) for c in input().split()]\n print(ans_solve(N, As))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s637182918', 's731156821', 's092380728'] | [33216.0, 26180.0, 33344.0] | [317.0, 79.0, 388.0] | [477, 444, 495] |
p03201 | u309977459 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ["import bisect\n\nN = int(input())\nA = list(map(int, input().split()))\n#N = 5\n#A = [3, 11, 14, 5, 13]\nA.sort()\n#A = range(100000, 0, -1)\n\ndef index(a, x):\n 'Locate the leftmost value exactly equal to x'\n i = bisect.bisect_left(a, x)\n if i != len(a) and a[i] == x:\n return i\n else:\n return None\n\n\ntwo_bekis = set()\ntmp = 1\nwhile True:\n if tmp>2*10**9:\n break\n two_bekis.add(tmp)\n tmp *= 2\n\nused = [False] * N\nans = 0\nfor i, a in enumerate(reversed(A)):\n for two_beki in two_bekis:\n tmp = index(A, two_beki-a)\n if tmp is not None and not used[tmp]:\n ans += 1\n used[tmp] = True\n used[N-i-1] = True\n\n \n\n\nprint(ans)\n", 'from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\nans = 0\ncnt = Counter(A)\nfor a in A:\n if cnt[a] == 0:\n continue\n cnt[a] -= 1\n b = 2**a.bit_length() - a\n if cnt[b] > 0:\n ans += 1\n cnt[b] -= 1\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s043630348', 's561449003'] | [27060.0, 33296.0] | [2104.0, 514.0] | [748, 295] |
p03201 | u310431893 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import math\nN = int(input())\nA = sorted((int(i) for i in input().split()), reverse=True)\n\nk = 2**int(math.log(A[0], 2) + 1)\n\ndef f(A, k):\n if len(A) == 1:\n return 0\n\n v = A[0]\n\n while k >= 2*v:\n k //= 2\n w = k - v\n\n if w in A[1:]:\n print(k, "=", v, "+", w)\n A.remove(w)\n r = 1\n else:\n r = 0\n\n return r + f(A[1:], k)\nprint(f(A, k))', 'import math\nN = int(input())\nA = [int(i) for i in input().split()]\n\nA.sort(reverse=True)\nB = [2**int(math.log(i, 2)+1) - i for i in A]\n\nc = 0\nfor i, v in enumerate(B[:-1]):\n print(i, v, A[i+1:])\n if v in A[i+1:]:\n c += 1\n A.remove(v)\nprint(c)\n', 'import math\nN = int(input())\nA = [int(i) for i in input().split()]\n\nA.sort(reverse=True)\nB = [2**math.ceil(math.log(i, 2)) - i for i in A]\nprint(B)\nc = 0\nfor i in B:\n if i in A:\n c += 1\n A.pop(A.index(i))\nprint(c)\n', 'import math\nfrom collections import defaultdict\nN = int(input())\nA = sorted(int(i) for i in input().split())\n\nd = defaultdict(lambda: 0)\nfor i in A:\n d[i] += 1\n\nc = 0\nfor k in sorted(d.keys(), reverse=True):\n l = 2**int(math.log(k, 2) + 1) - k\n v = d[k]\n if k == l:\n c += v // 2\n elif l in d:\n w = d[l]\n if v > w:\n c += w\n d[l] = 0\n else:\n c += v\n d[l] = w-v\nprint(c)\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s402399904', 's455682178', 's646945615', 's859767176'] | [617968.0, 161088.0, 28436.0, 33296.0] | [2141.0, 2109.0, 2105.0, 687.0] | [393, 263, 231, 455] |
p03201 | u336721073 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['N = int(input())\nA = list(map(int, input().split(" ")))\nA.sort()\nA = deque(A)\nans = 0\nt_max = len(bin(A[-1])) - 2\nfor t in range(t_max, 0, -1):\n while len(bin(A[-1])) - 2 > t:\n A.pop()\n if len(A) < 2: break\n if len(A) < 2: break\n pow2 = 1 << t\n A_tmp = deque()\n while t == len(bin(A[-1])) - 2:\n r = A.pop()\n idx = bisect_left(A, pow2 - r)\n for _ in range(idx):\n A_tmp.appendleft(A.popleft())\n if len(A) == 0: break\n if A[0] + r == pow2:\n A.popleft()\n ans += 1\n if len(A) < 2: break\n A.extendleft(A_tmp)\n \nprint(ans)', 'N = int(input())\nA = list(map(int, input().split(" ")))\nA.sort()\nA = deque(A)\nans = 0\nt_max = len(bin(A[-1])) - 2\nfor t in range(t_max, 0, -1):\n if len(A) < 2: break\n pow2 = 1 << t\n A_tmp = deque()\n while t == len(bin(A[-1])) - 2:\n r = A.pop()\n idx = bisect_left(A, pow2 - r)\n for _ in range(idx):\n A_tmp.appendleft(A.popleft())\n if len(A) == 0: break\n if A[0] + r == pow2:\n A.popleft()\n ans += 1\n if len(A) < 2: break\n A.extendleft(A_tmp)\n \nprint(ans)', 'N = int(input())\nA = list(map(int, input().split(" ")))\nA.sort()\nA = deque(A)\nans = 0\nt_max = len(bin(A[-1])) - 2\nfor t in range(t_max, 0, -1):\n while len(bin(A[-1])) - 2 > t:\n A.pop()\n if len(A) < 2: break\n if len(A) < 2: break\n pow2 = 1 << t\n A_tmp = deque()\n while t == len(bin(A[-1])) - 2:\n r = A.pop()\n idx = bisect_left(A, pow2 - r)\n for _ in range(idx):\n A_tmp.appendleft(A.popleft())\n if len(A) == 0: break\n if A[0] + r == pow2:\n A.popleft()\n ans += 1\n if len(A) < 2: break\n A.extendleft(A_tmp)\n print(A)\n \nprint(ans)', 'from bisect import bisect_left, bisect_right\nfrom collections import deque\n \nN = int(input())\nA = list(map(int, input().split(" ")))\nA.sort()\nA = deque(A)\nans = 0\nt_max = len(bin(A[-1])) - 2\nfor t in range(t_max, 0, -1):\t\n \tif len(A) < 2: break\n while len(bin(A[-1])) - 2 > t:\n A.pop()\n if len(A) < 2: break\n if len(A) < 2: break\n pow2 = 1 << t\n A_tmp = deque()\n while t == len(bin(A[-1])) - 2:\n r = A.pop()\n idx = bisect_left(A, pow2 - r)\n for _ in range(idx):\n A_tmp.appendleft(A.popleft())\n if len(A) == 0: break\n if A[0] + r == pow2:\n A.popleft()\n ans += 1\n if len(A) < 2: break\n A.extendleft(A_tmp)\n \nprint(ans)', 'from bisect import bisect_left, bisect_right\nfrom collections import deque\n\nN = int(input())\nA = list(map(int, input().split(" ")))\nA.sort()\nA = deque(A)\nans = 0\nt_max = len(bin(A[-1])) - 2\nfor t in range(t_max, 0, -1):\n if len(A) < 2: break\n while len(bin(A[-1])) - 2 > t:\n A.pop()\n if len(A) < 2: break\n if len(A) < 2: break\n pow2 = 1 << t\n A_tmp = deque()\n while t == len(bin(A[-1])) - 2:\n r = A.pop()\n idx = bisect_left(A, pow2 - r)\n for _ in range(idx):\n A_tmp.appendleft(A.popleft())\n if len(A) == 0: break\n if A[0] + r == pow2:\n A.popleft()\n ans += 1\n if len(A) < 2: break\n A.extendleft(A_tmp)\n \nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s382894820', 's603094496', 's927893762', 's961480147', 's963226937'] | [26932.0, 26020.0, 27060.0, 2940.0, 26000.0] | [147.0, 150.0, 147.0, 17.0, 1321.0] | [641, 561, 654, 743, 742] |
p03201 | u347640436 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['from bisect import bisect_right\nn = int(input())\nd = {}\nfor a in map(int, input().split()):\n if a in d:\n d[a] += 1\n else:\n d[a] = 1\nalist = list(sorted(d.keys(), reverse = True))\namax = alist[0]\nt = 1\npower_of_two = []\nwhile t < 2 * amax:\n t *= 2\n power_of_two.append(t)\nresult = 0\nfor a in alist:\n if d[a] == 0:\n continue\n t = power_of_two[bisect_right(power_of_two, a)] - a\n while True:\n if t not in d or d[t] == 0:\n break\n if a != t:\n i = min(d[a], d[t])\n else:\n i = d[a] // 2\n result += i\n d[a] -= i\n d[t] -= i\n if d[a] == 0:\n break\nprint(result)\n', 'from bisect import bisect_right\nn = int(input())\nd = {}\nfor a in map(int, input().split()):\n if a in d:\n d[a] += 1\n else:\n d[a] = 1\nt = 1\nvalids = []\nwhile t < 2 * 10 ** 9:\n t *= 2\n valids.append(t)\nresult = 0\nwhile True:\n prev = result\n keys = list(d.keys())\n keys.sort(reverse = True)\n for x in keys:\n t = valids[bisect_right(valids, 13)] - x\n if t not in d:\n continue\n result += 1\n if d[x] == 1:\n del d[x]\n else:\n d[x] -= 1\n if d[t] == 1:\n del d[t]\n else:\n d[t] -= 1\n break\n if prev == result:\n break\nprint(result)', 'from bisect import bisect_right\nn = int(input())\nd = {}\nfor a in map(int, input().split()):\n if a in d:\n d[a] += 1\n else:\n d[a] = 1\nalist = list(sorted(d.keys(), reverse = True))\namax = alist[0]\nt = 1\npower_of_two = []\nwhile t < 2 * amax:\n t *= 2\n power_of_two.append(t)\nresult = 0\nfor a in alist:\n if d[a] == 0:\n continue\n t = power_of_two[bisect_right(power_of_two, a)] - a\n if t not in d:\n continue\n if d[a] != d[t]:\n i = min(d[a], d[t])\n else:\n i = d[a] // 2\n result += i\n d[a] -= i\n d[t] -= 1\nprint(result)\n', 'n = int(input())\nd = {}\nfor a in map(int, input().split()):\n if a in d:\n d[a] += 1\n else:\n d[a] = 1\nresult = 0\nfor a in list(sorted(d.keys(), reverse = True)):\n if a not in d:\n continue\n t = (1 << a.bit_length()) - a\n if t not in d:\n continue\n if a != t:\n if d[a] < d[t]:\n i = d[a]\n else:\n i = d[t]\n else:\n if d[a] == 1:\n continue\n i = d[a] // 2\n result += i \n if d[a] == i:\n del d[a]\n else:\n d[a] -= i\n if d[t] == i:\n del d[t]\n else:\n d[t] -= i\nprint(result)\n'] | ['Time Limit Exceeded', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s061514584', 's131843629', 's735434684', 's171677597'] | [44592.0, 44592.0, 44688.0, 44704.0] | [2104.0, 2104.0, 412.0, 346.0] | [608, 584, 542, 524] |
p03201 | u350836088 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['n = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse = True)\nd = {}\nfor a in A:\n if a in d:\n d[a] += 1\n else:\n d[a] = 1\n\nans =0\nfor a in A:\n b = 2**(a.bit_length())-a\n if b in d:\n if d[b] >=1 and d[a] >= 1:\n ans += 1 \n d[b]-= 1\n d[a]-= 1\n\nprint(ans)\n ', 'n = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse = True)\nd = {}\nfor a in A:\n if a in d:\n d[a] += 1\n else:\n d[a] = 1\n\nans =0\nfor a in A:\n b = 2**(a.bit_length())-a\n if b in d:\n if d[b] >=1 and d[a] >= 1:\n if a == b and d[b] ==1:\n continue\n ans += 1 \n d[b]-= 1\n d[a]-= 1\n\nprint(ans)\n '] | ['Wrong Answer', 'Accepted'] | ['s590826076', 's936288617'] | [33696.0, 33072.0] | [350.0, 367.0] | [342, 391] |
p03201 | u375616706 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['from collections import defaultdict\n\ndef get_smallest_power_of_2_over_N(N):\n return 2**N.bit_length()\n\nN = int(input())\nA = list(map(int,input().split()))\n\n\nA = sorted(A)\n\nans=0\nD=defaultdict(int)\n\nfor a in A:\n D[a]+=1\n\nfor i in reversed(range(N)):\n if D[A[i]]<=0:\n continue\n else:\n pair_val = get_smallest_power_of_2_over_N(A[i]) - A[i]\n if D[pair_val]>0:\n ans+=1\n D[pair_val]-=1\n D[A[i]]-=1\n elif pair_val==A[i] and D[pair_val]>1:\n ans+=1\n D[pair_val]-=1\n D[A[i]]-=1\n\nprint(ans)\n', 'from collections import Counter\n\ndef get_smallest_power_of_2_over_N(N):\n i=2\n while i<=N:\n i*=2\n return i\n\nN = int(input())\nA = list(map(int,input().split()))\n\n\nA = sorted(A)\n\nans=0\nD=Counter(A)\n\nfor i in reversed(range(N)):\n pair_val = get_smallest_power_of_2_over_N(A[i]) - A[i]\n if D[A[i]]<=0:\n continue\n elif pair_val==A[i] and D[pair_val]>=2 or pair_val!=A[i] and D[pair_val]>=1:\n ans+=1\n D[pair_val]-=1\n D[A[i]]-=1\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s761476210', 's413764273'] | [56188.0, 33424.0] | [533.0, 780.0] | [587, 487] |
p03201 | u391731808 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import bisect\nN = int(input())\n*A, = map(int,input().split())\nB = {}\nfor a in A:B[a] = B.get(a,0) + 1\nB = sorted(map(list,B.items()))\nbl = bisect.bisect_left\n\nans = 0\nwhile 1:\n b,n = B.pop()\n if not B : break\n c = (1<<(len(bin(b))-2)) - b\n i = bl(B,[c,0])\n if B[i][0] == c:\n m = min(n,B[i][1])\n ans += m\n B[i][1] -= m\nprint(ans)', 'import bisect\nN = int(input())\n*A, = map(int,input().split())\nB = {}\nfor a in A:B[a] = B.get(a,0) + 1\nB = sorted(map(list,B.items()))\nbl = bisect.bisect_left\n\nans = 0\nwhile B:\n b,n = B.pop()\n c = (1<<(len(bin(b))-2)) - b\n if c==b :\n ans += n//2\n continue\n i = bl(B,[c,0])\n if i>=len(B): continue\n if B[i][0] == c:\n m = min(n,B[i][1])\n ans += m\n B[i][1] -= m\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s366917149', 's846329843'] | [48316.0, 48316.0] | [1116.0, 1193.0] | [364, 421] |
p03201 | u474270503 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['N=int(input())\nA=list(map(int, input().split()))\n\nA.sort(reverse=True)\ndic={}\nfor a in A:\n dic[a]=dic.get(a,0)+1\nprint(dic)\n\nans=0\n\nfor a in A:\n small=(1<<(len(format(a,"b")))) -a\n if dic.get(a,0)>0 and dic.get(small,0)>0:\n dic[a]-=1\n dic[small]-=1\n ans+=1\nprint(ans)', 'N=int(input())\nA=list(map(int, input().split()))\n\nA.sort(reverse=True)\ndic={}\nfor a in A:\n dic[a]=dic.get(a,0)+1\n\nans=0\n\nfor a in A:\n small=(1<<(len(format(a,"b")))) -a\n if small==a:\n if dic[a]>=2:\n dic[a]-=2\n ans+=1\n continue\n if dic.get(a,0)>0 and dic.get(small,0)>0:\n dic[a]-=1\n dic[small]-=1\n ans+=1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s333664825', 's916759348'] | [34236.0, 33984.0] | [493.0, 448.0] | [297, 383] |
p03201 | u480887263 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['class Node:\n def __init__(self,data):\n self.data=data\n self.left=None\n self.right=None\nclass BST:\n def __init__(self,number_list):\n self.root=None\n for node in number_list:\n self.insert(node)\n def insert(self,data):\n n=self.root\n if n is None:\n self.root=Node(data)\n return\n else:\n while True:\n entry=n.data\n if data<entry:\n if n.left is None:\n n.left=Node(data)\n return\n n=n.left\n elif data>entry:\n if n.right is None:\n n.right=Node(data)\n return\n n=n.right\n else:\n n.data=data\n return\n def search(self,target):\n n = self.root\n if n is None:\n return None\n else:\n lst = []\n lst.append(n)\n while len(lst) > 0:\n node = lst.pop()\n if node.data == target:\n return True\n if node.right is not None:\n lst.append(node.right)\n if node.left is not None:\n lst.append(node.left)\n return False\n \nimport math\nN=int(input())\na=list(map(int,input().split()))\nt_max=int(math.log2(max(a)*2)+1)\nans=0\nfor t in range(t_max,0,-1):\n i=0\n while i<len(a):\n \n x,y=0,0\n bst=BST(a)\n if bst.search(2**t-a[i]):\n if a[i]!=2**t-a[i]:\n \n ans+=1\n x+=a[i]\n y+=2**t-a[i]\n \n a.remove(x)\n a.remove(y)\n else:\n i+=1 \nprint(ans)', 'class Node:\n def __init__(self,data):\n self.data=data\n self.left=None\n self.right=None\nclass BST:\n def __init__(self,number_list):\n self.root=None\n for node in number_list:\n self.insert(node)\n def insert(self,data):\n n=self.root\n if n is None:\n self.root=Node(data)\n return\n else:\n while True:\n entry=n.data\n if data<entry:\n if n.left is None:\n n.left=Node(data)\n return\n n=n.left\n elif data>entry:\n if n.right is None:\n n.right=Node(data)\n return\n n=n.right\n else:\n n.data=data\n return\n def search(self,target):\n n = self.root\n if n is None:\n return None\n else:\n lst = []\n lst.append(n)\n while len(lst) > 0:\n node = lst.pop()\n if node is None:\n return False\n elif node.data == target:\n self.node_recreate(node)\n node=None\n return True\n elif node.data < target :\n lst.append(node.right)\n elif node.data > target:\n lst.append(node.left)\n return False\n \n def node_recreate(self,node):\n \n num_lst=[]\n node_lst=[node]\n while len(node_lst)>0:\n node_=node_lst.pop()\n if node_.right is not None:\n node_lst.append(node_.right)\n num_lst.append(node_.right.data)\n if node_.left is not None:\n node_lst.append(node_.left)\n num_lst.append(node_.left.data)\n for num in num_lst:\n self.insert(num)\n \n \n \nimport math\nN=int(input())\na=list(map(int,input().split()))\nt_max=int(math.log2(max(a)*2)+1)\nans=0\nbst=BST(a)\nfor t in range(t_max,0,-1):\n i=0\n while i<len(a):\n \n x,y=0,0\n\n\n if bst.search(2**t-a[i]):\n if a[i]!=2**t-a[i]:\n \n ans+=1\n x+=a[i]\n y+=2**t-a[i]\n \n a.remove(x)\n bst.search(x)\n print(bst.search(y))\n print(x,y)\n a.remove(y)\n else:\n i+=1\n else:\n i+=1 \nprint(ans)', 'class Node:\n def __init__(self,data):\n self.data=data\n self.left=None\n self.right=None\nclass BST:\n def __init__(self,number_list):\n self.root=None\n for node in number_list:\n self.insert(node)\n def insert(self,data):\n n=self.root\n if n is None:\n self.root=Node(data)\n return\n else:\n while True:\n entry=n.data\n if data<entry:\n if n.left is None:\n n.left=Node(data)\n return\n n=n.left\n elif data>entry:\n if n.right is None:\n n.right=Node(data)\n return\n n=n.right\n else:\n n.data=data\n return\n def search(self,target):\n n = self.root\n if n is None:\n return None\n else:\n lst = []\n lst.append(n)\n while len(lst) > 0:\n node = lst.pop()\n if node is None:\n return False\n if node.data == target:\n self.node_recreate(node)\n return True\n elif node.data < target :\n lst.append(node.right)\n elif node.data > target:\n lst.append(node.left)\n return False\n \n def node_recreate(self,node):\n \n num_lst=[]\n node_lst=[node]\n while len(node_lst)>0:\n node_=node_lst.pop()\n if node_.right is not None:\n node_lst.append(node_.right)\n num_lst.append(node_.right.data)\n if node_.left is not None:\n node_lst.append(node_.left)\n num_lst.append(node_.left.data)\n node=None\n for num in num_lst:\n self.insert(num)\n \n \n \nimport math\nN=int(input())\na=list(map(int,input().split()))\nt_max=int(math.log2(max(a)*2)+1)\nans=0\nbst=BST(a)\nfor t in range(t_max,0,-1):\n i=0\n while i<len(a):\n \n x,y=0,0\n\n\n if bst.search(2**t-a[i]):\n if a[i]!=2**t-a[i]:\n \n ans+=1\n x+=a[i]\n y+=2**t-a[i]\n \n a.remove(x)\n bst.search(x)\n a.remove(y)\n else:\n i+=1 \nprint(ans)', 'import math\nN=int(input())\na=list(map(int,input().split()))\na_=sorted(a)\nt_max=int(math.log2(a_[-1]+a_[-2])+1)\nans=0\nfor t in range(t_max,0,-1):\n i=0\n while i<len(a_):\n x,y=0,0\n if 2**t-a_[i] in a_:\n if a[i]!=2**t-a[i]:\n ans+=1\n x+=a_[i]\n y+=2**t-a_[i]\n a_.remove(x)\n a_.remove(y)\n else:\n i+=1\nprint(ans)', 'N=int(input())\na=list(map(int,input().split()))\na_=sorted(a,key=lambda x:-x)\nans=0\nfrom collections import Counter\nc=Counter(a_)\nfor i in a_:\n if c[i]==0:\n continue\n c[i]-=1\n m=1<<i.bit_length()\n j=m-i\n if j in c and c[j]>0:\n ans+=1\n c[j]-=1\nprint(ans)'] | ['Time Limit Exceeded', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s226632035', 's426184840', 's764823343', 's878292739', 's134337480'] | [60436.0, 44308.0, 46316.0, 26608.0, 35560.0] | [2108.0, 2106.0, 2106.0, 2104.0, 456.0] | [2105, 3064, 2900, 428, 288] |
p03201 | u497046426 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['from collections import Counter\n\nN = int(input())\n*A, = map(int, input().split())\ncnt = Counter(A)\nA = sorted(A, reverse=True)\nans = 0\nfor a in A:\n if a & (a - 1) != 0:\n cand = (1 << ((a - 1).bit_length()))\n if cnt[a] == 0 or cnt[cand] == 0: continue\n else:\n cand = a\n if cnt[a] < 2: continue\n ans += 1\n cnt[a] -= 1; cnt[cand] -= 1\nprint(ans)', 'from collections import Counter\n\nN = int(input())\n*A, = map(int, input().split())\ncnt = Counter(A)\nA = sorted(A, reverse=True)\nans = 0\nfor a in A:\n if a & (a - 1) != 0:\n cand = (1 << ((a - 1).bit_length())) - a\n if cnt[a] == 0 or cnt[cand] == 0: continue\n else:\n cand = a\n if cnt[a] < 2: continue\n ans += 1\n cnt[a] -= 1; cnt[cand] -= 1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s746231223', 's407950189'] | [33296.0, 33296.0] | [351.0, 446.0] | [382, 386] |
p03201 | u550574002 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import collections\ndef hoge(n):\n k = 1 \n while k<=n:\n k*=2\n return k-n\nans = 0\ninput()\na = [int(x) for x in input().split()]\nc = collections.Counter(a)\nsa = list(set(a))\nsa.sort()\nfor i in range(len(sa)-1,-1,-1):\n print(i) \n x = sa[i]\n if c[x]<= 0:\n continue \n y = hoge(x)\n if x==y:\n ans += c[x]//2\n else:\n ans += min(c[x],c[y])\n c[y] -=c[x]\nprint(ans)', 'import collections\ndef hoge(n):\n k = 1 \n while k<=n:\n k*=2\n return k-n\nans = 0\ninput()\na = [int(x) for x in input().split()]\nc = collections.Counter(a)\nsa = list(set(a))\nsa.sort()\nsa.reverse()\nfor i in range(len(sa)):\n x = sa[i]\n if c[x]<= 0:\n continue \n y = hoge(x)\n if x==y:\n ans += c[x]//2\n elif c[y]>= 0:\n ans += min(c[x],c[y])\n c[y] -=c[x]\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s561654092', 's246693374'] | [61776.0, 61164.0] | [1440.0, 1166.0] | [423, 420] |
p03201 | u550943777 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ["import math\n\nN = int(input())\na = list(map(int,input().split()))\na_odds = []\na_even = []\n\nfor i in range(N):\n if a[i]%2 != 0:\n a_odds.append(a[i])\n else:\n a_even.append(a[i])\n\na_odds.sort()\na_odds.reverse()\na_even.sort()\na_even.reverse()\n\ncount = 0\nalist = []\nmax= 0\nif a_odds!=[] and a_even!=[]:\n max = max(a_odds[0],a_even[0])\nelif a_odds ==[]:\n max= a_even[0]\nelif a_even == []:\n max = a_odds[0]\n \nfor i in range(round(math.log2(max))+1,0,-1):\n alist.append(2**i)\n\n\ndef my_index(l,x,default=False):\n if x in l:\n return l.index(x)\n else:\n return default\n\ndef judge(a,b):\n n = a+b\n ans = -1\n while(n>0):\n if n==1:\n ans = 0\n break\n elif n%2 == 1:\n ans = 1\n break\n elif n%2 == 0:\n n = n/2\n return ans\n\n\n'''while(a_odds!=[]):\n for i in range(len(a_odds)):\n if judge(a_odds[0],a_odds[i])==0 and i!=0:\n count += 1\n a_odds.pop(i)\n break\n a_odds.pop(0)'''\n\nwhile(a_odds!=[]):\n temp = a_odds[0]\n a_odds.pop(0)\n if a_odds ==[]:\n break\n for i in alist:\n b = i-temp\n if (i-temp) in a_odds:\n count += 1\n a_odds.pop(a_odds.index(i-temp))\n break\n \n \nwhile(a_even!=[]):\n temp = a_even[0]\n a_even.pop(0)\n if a_even==[]:\n break\n for i in alist:\n if (i-temp) in a_even:\n count += 1\n a_even.pop(a_even.index(i-temp))\n break\n \n\nprint(count)", 'import math\n\nN = int(input())\na = sorted(list(map(int,input().split())))\n\ncount = 0\n\n\n\nwhile(a!=[]):\n temp = a[-1]\n a.pop(-1)\n \nprint(count)', 'import math\n\nN = int(input())\na = sorted(list(map(int,input().split())))\n\ncount = 0\n\nb = {}\nfor i in range(len(a)):\n if a[i] in b:\n b[a[i]] += 1\n else:\n b[a[i]] = 1\n\nfor i in range(len(a) - 1, -1, -1):\n if b[a[i]] == 0:\n continue\n temp = a[i]\n b[a[i]] -= 1\n s=2**math.floor(math.log2(temp))\n st = 2*s - temp \n if a ==[]:\n break\n if st in b and b[st] > 0:\n b[2*s-temp] -= 1\n count += 1\n \nprint(count)\n\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s014759265', 's335055585', 's296033285'] | [25920.0, 26832.0, 33168.0] | [2105.0, 197.0, 511.0] | [1544, 149, 474] |
p03201 | u572142121 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['N=int(input())\nA=list(map(int,input().split()))\nA=sorted(A)\nfrom collections import Counter as co\nD=co(A)\n\ncnt=0\nfor i in range(N):\n if D[A[-1-i]]>0:\n for j in range(1,16):\n d=2**j\n if A[-1-i]<d:\n e=d-A[-1-i]\n break\n if D[e]>0:\n cnt+=1\n D[A[-1-i]]-=1\n D[e]-=1\nprint(cnt)\n ', 'N=int(input())\nA=list(map(int,input().split()))\nA=sorted(A)\nfrom collections import Counter as co\nD=co(A)\n\ncnt=0\nfor i in range(N):\n if D[A[-1-i]]>0:\n D[A[-1-i]]-=1\n for j in range(1,16):\n d=2**j\n if A[-1-i]<d:\n e=d-A[-1-i]\n break\n if e in D:\n cnt+=1\n D[e]-=1\nprint(cnt)', 'N=int(input())\nA=list(map(int,input().split()))\nA=sorted(A)\nfrom collections import Counter as co\nD=co(A)\n\ncnt=0\nfor i in range(N):\n if D[A[-1-i]]>0:\n D[A[-1-i]]-=1\n d=A[-1-i]\n f=len(bin(d))-2\n e=2**f-d\n if D[e]>0:\n cnt+=1\n D[e]-=1\nprint(cnt)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s204392951', 's283645637', 's977946106'] | [35796.0, 35884.0, 35772.0] | [156.0, 151.0, 459.0] | [326, 314, 269] |
p03201 | u572144347 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['\nimport copy\nN = int(input())\na = list(map(int, input().split()))\na.sort(reverse=True)\nb = {}\nfor c in a:\n try:\n b[c] += 1\n except:\n b[c] = 1\n\n\npow2 = 1\nwhile pow2 <= a[0]:\n pow2 *= 2\n\ncnt = 0\nfor aa in a:\n while aa < (pow2//2):\n pow2 //= 2\n v = aa\n rem = pow2 - aa\n if (not v in b) or (not rem in b):\n continue\n\n if rem != v and (b[v] > 0 and b[rem] > 0):\n # hit = min(b[v], b[rem])\n cnt += 1\n b[v] -= 1\n b[rem] -= 1\n else:\n cnt += 1\n b[v] -= 2\n\nprint(cnt)\n\n\n\n# b = {}\n# c = {}\n# # print(a)\n# for e,i in enumerate(a):\n# b[i] = (e, [(x[0]+e+1, x[1]) for x in enumerate(a[e+1:])])\n\n# # print(b)\n# for be in b: # (3, (0, [(1,5),...]) in [3,5,..]\n# for j in b[be][1]:\n# try:\n# if (not (b[be][0], j[0]) in c[be+j[1]]):\n# # c[be + j[1]].append(b[be][0])\n# # c[be + j[1]].append(j[0])\n# c[be+j[1]].append((b[be][0], j[0]))\n# except:\n# c[be + j[1]] = [(b[be][0], j[0])]\n# # c[be + j[1]].append(b[be][0])\n# # c[be + j[1]].append(j[0])\n\n\n# # print("c: ", c)\n# d= []\n\n# twopowerlist = [2**p for p in range(30)]\n# for n in twopowerlist:\n# try:\n# # print(n, c[n])\n# # d[n] = len(c[n])//2\n\n# except:\n\n\n\n\n# for p in [x for y in d[0] for x in y]:\n# # print("p:", p)\n# for e,q in enumerate(d[1:]):\n# for j in q:\n\n# try:\n\n# except:\n\n\n# # print(d)\n# print(len(d[0]))\n\n\n\n\n\n\n###########################3\n\n\n\n# b = {}\n# c = {}\n# for e,i in enumerate(a):\n# b[i] = [copy.deepcopy(a)[e+1:], 1]\n# c[i] = 1\n\n# for be in b:\n# for j in b[be][0]:\n# try:\n# c[j+be] += 1\n# except:\n# c[j+be] = 1\n\n\n\n# for n in twopowerlist:\n# try:\n\n# except:\n\n# print("list: ", c)\n# print(sum)', '\nN = int(input())\na = list(map(int, input().split()))\na.sort(reverse=True)\n\nb = {}\nfor c in a:\n try:\n b[c] += 1\n except:\n b[c] = 1\n\n\npow2 = 1\nwhile pow2 <= a[0]:\n pow2 *= 2\n\ncnt = 0\nfor aa in a:\n while aa < (pow2//2):\n pow2 //= 2\n \n v = aa\n rem = pow2 - aa\n \n if (not v in b) or (not rem in b):\n continue\n\n if rem != v and (b[v] > 0 and b[rem] > 0):\n hit = min(b[v], b[rem])\n cnt += hit\n b[v] -= hit\n b[rem] -= hit\n elif rem == v and b[v] > 1:\n cnt += b[v]//2\n b[v] = b[v]%2\n\nprint(cnt)\n\n\n\n# b = {}\n# c = {}\n# # print(a)\n# for e,i in enumerate(a):\n# b[i] = (e, [(x[0]+e+1, x[1]) for x in enumerate(a[e+1:])])\n\n# # print(b)\n# for be in b: # (3, (0, [(1,5),...]) in [3,5,..]\n# for j in b[be][1]:\n# try:\n# if (not (b[be][0], j[0]) in c[be+j[1]]):\n# # c[be + j[1]].append(b[be][0])\n# # c[be + j[1]].append(j[0])\n# c[be+j[1]].append((b[be][0], j[0]))\n# except:\n# c[be + j[1]] = [(b[be][0], j[0])]\n# # c[be + j[1]].append(b[be][0])\n# # c[be + j[1]].append(j[0])\n\n\n# # print("c: ", c)\n# d= []\n\n# twopowerlist = [2**p for p in range(30)]\n# for n in twopowerlist:\n# try:\n# # print(n, c[n])\n# # d[n] = len(c[n])//2\n\n# except:\n\n\n\n\n# for p in [x for y in d[0] for x in y]:\n# # print("p:", p)\n# for e,q in enumerate(d[1:]):\n# for j in q:\n\n# try:\n\n# except:\n\n\n# # print(d)\n# print(len(d[0]))\n\n\n\n\n\n\n###########################3\n\n\n\n# b = {}\n# c = {}\n# for e,i in enumerate(a):\n# b[i] = [copy.deepcopy(a)[e+1:], 1]\n# c[i] = 1\n\n# for be in b:\n# for j in b[be][0]:\n# try:\n# c[j+be] += 1\n# except:\n# c[j+be] = 1\n\n\n\n# for n in twopowerlist:\n# try:\n\n# except:\n\n# print("list: ", c)\n# print(sum)'] | ['Wrong Answer', 'Accepted'] | ['s404101425', 's631259021'] | [34112.0, 33696.0] | [435.0, 432.0] | [2141, 2217] |
p03201 | u588341295 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ["# -*- coding: utf-8 -*-\n\nimport sys\nfrom collections import Counter\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\nN = INT()\nA = LIST()\n\nC = Counter(A)\nans = 0\nfor i in range(30, 1, -1):\n x = 2 ** i\n for k in C.keys():\n if x-k in C:\n p = min(C[k], C[x-k])\n C[k] -= p\n C[x-k] -= p\n ans += p\nprint(ans)\n", "# -*- coding: utf-8 -*-\n\nimport sys\nfrom collections import Counter\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]\ndef ceil(x, y=1): return int(-(-x // y))\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef NO(): print('NO')\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\n\nN = INT()\nA = LIST()\n\nC = Counter(A)\nans = 0\n\nfor i in range(30, 0, -1):\n x = 2 ** i\n for k in C.keys():\n if x-k in C:\n \n if k == x-k:\n p = C[k] // 2\n C[k] -= p * 2\n ans += p\n else:\n \n p = min(C[k], C[x-k])\n C[k] -= p\n C[x-k] -= p\n ans += p\nprint(ans)\n"] | ['Wrong Answer', 'Accepted'] | ['s302221398', 's926976235'] | [33288.0, 33404.0] | [1753.0, 1980.0] | [952, 1226] |
p03201 | u593005350 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import collections\nN=int(input())\nx=list(map(int,input().split()))\nc=collections.Counter(x)\nt=[2**i for i in range(len(str(bin(max(x)*2))[2:])+1)[::-1]]\ncount=0\nstart=0\nx.sort()\nfor i in range(len(x))[::-1]:\n for j in range(len(t)):\n if t[j] < x[i]:\n break\n if t[j]-x[i] in c.keys():\n if t[j]-x[i] == x[i] and c[x[i]] >= 2:\n c[x[i]] -= 2\n count +=1\n elif c[t[j]-x[i]]>0 and c[x[i]]>0:\n c[t[j]-x[i]] -= 1\n c[x[i]] -= 1\n count+=1\nprint(count)', 'import collections\nN=int(input())\nx=list(map(int,input().split()))\nc=collections.Counter(x)\nt=[2**i for i in range(len(str(bin(max(x)*2))[2:])+1)[::-1]]\ncount=0\nstart=0\nx.sort()\nfor i in range(len(x))[::-1]:\n for j in range(start,len(t)):\n if t[j] > 2*x[i]:\n start = j\n if t[j] < x[i]:\n break\n if t[j]-x[i] in c.keys():\n if t[j]-x[i] == x[i]:\n if c[x[i]] >= 2:\n c[x[i]] -= 2\n count +=1\n else:\n if c[t[j]-x[i]]>0 and c[x[i]]>0:\n c[t[j]-x[i]] -= 1\n c[x[i]] -= 1\n count+=1\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s744998426', 's358534848'] | [33296.0, 33296.0] | [1317.0, 772.0] | [565, 675] |
p03201 | u597486843 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['n = int(input())\na = list(map(int, input().split()))\na.sort(reverse = True)\nd = {}\ncount = 0\n\nfor x in a:\n if x not in d: d[x] = 0\n d[x] += 1\n \nfor i in range(len(a)):\n y = 2**a[i].bit_length() - a[i]\n if y in d and d[y] > 0:\n count += 1\n d[y] -= 1\n \nprint(count) ', 'n = int(input())\na = list(map(int, input().split()))\na.sort(reverse = True)\nd = {}\ncount = 0\n\nfor x in a:\n if x not in d: d[x] = 0\n d[x] += 1\n \nfor i in range(len(a)):\n if d[a[i]] == 0:continue\n \n d[a[i]] -= 1\n \n y = 2**a[i].bit_length() - a[i]\n \n if y in d and d[y] > 0:\n count += 1\n d[y] -= 1\n \nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s489515396', 's769870926'] | [33856.0, 33040.0] | [391.0, 416.0] | [314, 371] |
p03201 | u601344838 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['#include<bits/stdc++.h>\nusing namespace std;\nint main(){\n int N;cin>>N;\n vector<int>A(N);\n for(int &a:A)cin>>a;\n sort(A.begin(),A.end(),greater<int>());\n map<int,int>m;\n int ans=0;\n for(int a:A){\n if(m.count(a)&&m[a]>0)m[a]--,ans++;\n else m[(1<<(32-__builtin_clz(a)))-a]++;\n }\n cout<<ans<<endl;\n}\n', 'import math\nN = int(input())\nA = sorted([int(_) for _ in input().split()], reverse=True)\ndp = {}\nfor a in A:\n dp[a] = dp.get(a, 0) + 1\nans = 0\nfor a in A:\n if dp[a]:\n dp[a] -= 1\n if dp.get(2**int(math.log2(a) + 1) - a, 0) > 0:\n dp[2**int(math.log2(a) + 1) - a] -= 1\n ans += 1\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s745560052', 's665547554'] | [2940.0, 33168.0] | [18.0, 487.0] | [312, 328] |
p03201 | u606045429 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ["#include <algorithm>\n\n#include <set>\n\n\nusing namespace std;\n\nuint32_t ceil2(uint32_t a)\n{\n uint32_t b = 1;\n while (a > b) {\n b <<= 1;\n }\n return b;\n}\n\nint main()\n{\n int N;\n cin >> N;\n\n multiset<int> S;\n vector<int> A(N);\n for (auto &&a : A) {\n cin >> a;\n S.insert(a);\n }\n sort(rbegin(A), rend(A));\n\n int ans = 0;\n for (auto a : A) {\n if (S.find(a) != S.end()) {\n S.erase(a);\n int p = ceil2(a) - a;\n if (S.find(p) != S.end()) {\n S.erase(p);\n ans += 1;\n }\n }\n }\n\n cout << ans << '\\n';\n}", 'from collections import*\nN,*A=map(int,open(0).read().split())\nA.sort()\nC=Counter(A)\ns=0\nfor a in A[::-1]:\n\tif C[a]:\n\t\tC[a]-=1\n\t\tb=2**a.bit_length()-a\n\t\tif C[b]:\n\t\t\tC[b]-=1\n\t\t\ts += 1\nprint(s)'] | ['Runtime Error', 'Accepted'] | ['s312459470', 's749178175'] | [2940.0, 33744.0] | [17.0, 515.0] | [674, 190] |
p03201 | u620480037 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import bisect\nfrom collections import deque\nN=int(input())\n\nE=deque()\nO=deque()\n\na=list(map(int,input().split()))\n\nfor i in range(len(a)):\n if a[i]%2==0:\n E.append(a[i])\n else:\n O.append(a[i])\n \nE=list(E)\nO=list(O)\nE.sort()\nO.sort()\n\nans=0\nfor e in range(len(E)):\n t=0\n while E[len(E)-1-e]>2**t:\n t=t+1\n #print(t)\n if E[bisect.bisect_left(E,2**t-E[len(E)-1-e])]+E[len(E)-1-e]==2**t:\n ans+=1\n E[bisect.bisect_left(E,2**t-E[len(E)-1-e])]-=0.5\n \nfor o in range(len(O)):\n t=0\n while O[len(O)-1-o]>2**t:\n t=t+1\n #print(t)\n if O[bisect.bisect_left(O,2**t-O[len(O)-1-o])]+O[len(O)-1-o]==2**t:\n ans+=1\n O[bisect.bisect_left(O,2**t-O[len(O)-1-o])]-=0.5\nprint(ans)\n', 'import bisect\n\nN=int(input())\nA=list(map(int,input().split()))\nA.sort()\nB=[]\nfor i in range(1,100):\n if 2**i>2*(10**9):\n break\n else:\n B.append(2**i)\nB.append(2**(i+1))\nans=0\n\nfor i in range(N):\n X=bisect.bisect_left(B,A[N-1-i])\n if B[X]==A[N-1-i]:\n X+=1\n #print(X)\n if A[bisect.bisect_left(A,B[X]-A[N-1-i])]==B[X]-A[N-1-i]:\n ans+=1\n A[bisect.bisect_left(A,B[X]-A[N-1-i])]-=0.1\n A[N-1-i]-=0.1\nprint(ans)', 'import bisect\nN=int(input())\nA=list(map(int,input().split()))\nA.sort()\nA.append(999999999999999)\nB=[]\nfor i in range(1,35):\n B.append(2**i)\nans=0\nfor i in range(N):\n if A[N-1-i]==int(A[N-1-i]):\n for j in range(len(B)):\n if A[N-1-i]<B[j]:\n break\n if A[bisect.bisect_left(A,B[j]-A[N-1-i])]==B[j]-A[N-1-i]:\n if bisect.bisect_left(A,B[j]-A[N-1-i])<N-1-i:\n A[bisect.bisect_left(A,B[j]-A[N-1-i])]-=0.1\n A[N-1-i]+=0.1\n ans+=1\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s221872880', 's227085468', 's406779150'] | [26000.0, 27060.0, 25492.0] | [2104.0, 722.0, 1543.0] | [759, 472, 531] |
p03201 | u631277801 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nn = ni()\na = list(li())\n\nfrom collections import Counter\n\nacnt = Counter(a)\n\nans = 0\nfor ai in sorted(a,reverse=True):\n pair = (1<<(ai.bit_length())) - ai\n print(ai, pair)\n \n if acnt[ai] > 0 and acnt[pair] > 0:\n if ai == pair:\n temp = (acnt[ai] // 2)\n \n elif ai > pair:\n temp = min(acnt[ai], acnt[pair])\n \n ans += temp\n acnt[pair] -= temp\n \nprint(ans)', 'import sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nn = ni()\na = list(li())\n\nfrom collections import Counter\n\nacnt = Counter(a)\n\nans = 0\ntemp = 0\nfor ai in sorted(a,reverse=True):\n pair = (1<<(ai.bit_length())) - ai\n \n if acnt[ai] > 0 and acnt[pair] > 0:\n if ai == pair:\n temp = (acnt[ai] // 2)\n ans += temp\n acnt[ai] -= (2*temp)\n \n elif ai > pair:\n temp = min(acnt[ai], acnt[pair])\n ans += temp\n acnt[ai] -= temp\n acnt[pair] -= temp\n \nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s100221603', 's523540488'] | [33404.0, 33404.0] | [680.0, 426.0] | [873, 947] |
p03201 | u667024514 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import math\nn= int(input())\nlis= list(map(int,input().split()))\nlis.sort(reverse=True)\nans=0\nwhile lis:\n a =lis.pop(0)\n num = 1 << len(str(bin(a)))\n num =num-a\n if num==0:num=a\n if num in lis:\n lis.remove(num)\n ans +=1\nprint(ans)\n', 'import math\nn= int(input())\nlis= list(map(int,input().split()))\nlis.sort(reverse=True)\nans=0\nwhile lis:\n a =lis.pop(0)\n num = 1 << len(bin(a))\n num =num-a\n if num==0:num=a\n if num in lis:\n lis.remove(num)\n ans +=1\nprint(ans)\n', "from collections import Counter\nn=int(input())\na=list(map(int,input().split()))\na.sort(reverse=True)\nc=Counter(a)\nans=0\nfor i in a:\n if c[i]==0:\n continue\n pt=2**len(format(i,'b'))\n c[i]-=1\n if c[pt-i]>=1:\n ans+=1\n c[pt-i]-=1\nprint(ans)\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s024293522', 's605686516', 's652940978'] | [27052.0, 26832.0, 33288.0] | [2104.0, 2108.0, 559.0] | [241, 236, 250] |
p03201 | u675918663 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ["import sys\n\ndef main(l):\n u = set()\n l = list(sorted(l))\n for i, a in enumerate(reversed(l)):\n searching = (1 << a.bit_length()) - a\n for j, b in enumerate(l[:-i-1]):\n if b == searching and not j in u:\n u.add(j)\n break\n\n return len(u)\n\n\nif __name__ == '__main__':\n input()\n main(map(int, input().split()))", 'def next_power(nb):\n nb |= nb >> 1\n nb |= nb >> 2\n nb |= nb >> 4\n nb |= nb >> 8\n nb |= nb >> 16\n nb += 1\n return nb\n\n\ninput()\nnbs = list(map(int, input().split()))\nused = set()\n\nfor i, big in enumerate(reversed(nbs)):\n searching = next_power(big) - big\n for j, small in enumerate(nbs[:-i-1]):\n if small > searching:\n break\n if small == searching and j not in used:\n print(-i-1, big, j, small)\n used.add(j)\n\nprint(len(used))', "import sys\n\ndef main(l):\n u = set()\n l = list(sorted(l))\n for i, a in enumerate(reversed(l)):\n searching = (1 << a.bit_length()) - a\n for j, b in enumerate(l[:-i-1]):\n if b == searching and not j in u:\n u.add(j)\n break\n\n return len(u)\n\n\nif __name__ == '__main__':\n main(map(int, sys.stdin))", 'import sys\n\ndef next_power(nb):\n nb |= nb >> 1\n nb |= nb >> 2\n nb |= nb >> 4\n nb |= nb >> 8\n nb |= nb >> 16\n nb += 1\n return nb\n\n\nnbs = list(sys.stdin)[1]\nnbs = list(sorted(map(int, nbs.split())))\nused = set()\n\nfor i, big in enumerate(reversed(nbs)):\n searching = next_power(big) - big\n for j, small in enumerate(nbs[:-i-1]):\n if small > searching:\n break\n if small == searching and j not in used:\n print(-i-1, big, j, small)\n used.add(j)\n\nprint(len(used))\n', "def main(l):\n counts = {}\n answer = 0\n for nb in l:\n counts[nb] = counts.get(nb, 0) + 1\n for a in sorted(counts.keys(), reverse=True):\n b = (1 << a.bit_length()) - a\n c_a = counts[a]\n c_b = counts.get(b)\n if c_b:\n if a == b:\n answer += c_a // 2\n else:\n increment = c_a if c_a < c_b else c_b\n counts[a] -= increment\n counts[b] -= increment\n answer += increment\n\n return answer\n\n\nif __name__ == '__main__':\n input()\n print(main(map(int, input().split())))"] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s123389799', 's125874260', 's163497213', 's890844477', 's541444269'] | [26932.0, 36200.0, 7004.0, 36184.0, 44560.0] | [2108.0, 2105.0, 37.0, 2105.0, 337.0] | [378, 497, 360, 531, 606] |
p03201 | u711245972 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ["def binary_search(list, item):\n low = 0\n high = len(list) - 1\n while low <= high:\n mid = (low + high) //2\n guess = list[mid]\n if guess == item:\n return mid\n if guess > item:\n high = mid -1\n else:\n low = mid + 1\n\n return mid\n\n\nn= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nfor i in range(n-1):\n if a[i]:\n bi=format(a[i], 'b')\n x=2**len(bi)-a[i]\n if a[i]==x and a[i+1]==x:\n ans+=1\n a[i]=None\n c=binary_search(a,x)\n a[c]=None\nprint(ans)", "n= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nfor i in range(n):\n if a[i]:\n bi=format(a[i], 'b')\n x=2**len(bi)-a[i]\n if a[i]==x and a[i+1]==x:\n ans+=1\n a[i]=None\n a[a.index(x)]=None\nprint(ans)", "import copy\nimport bisect\n\ndef index(a, x):\n i = bisect.bisect_right(a, x)\n\n if i != len(a) and a[i] == x:\n return i\n return -1\n \nn= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nano_a=copy.copy(a)\nano_a.sort()\nfor i in range(n-1):\n \n if a[i]:\n bi=format(a[i], 'b')\n x=2**len(bi)-a[i]\n c=index(ano_a,x)\n if x==a[i] and a[i+1]==x:\n ans+=1\n a[i]=None\n a[c]=None\n elif c>=0:\n if x!=a[i]:\n ans+=1\n a[c]=None\n a[i]=None\nprint(ans)", "import copy\nimport bisect\n\ndef index(a, x):\n i = bisect.bisect_right(a, x)\n a.reverse()\n if i != len(a) and a[i] == x:\n return i\n return -1\n \nn= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nano_a=copy.copy(a)\nano_a.sort()\nfor i in range(n):\n if a[i]:\n bi=format(a[i], 'b')\n x=2**len(bi)-a[i]\n c=index(ano_a,x)\n if x==a[i] and a[i+1]==x:\n ans+=1\n a[i]=None\n a[c]=None\n elif c>=0:\n if x!=a[i]:\n ans+=1\n a[c]=None\n a[i]=None\nprint(ans)", "n= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nfor b in a:\n if b:\n bi=format(b, 'b')\n x=2**len(bi)-b\n if x==b and a.count(x)>1:\n ans+=1\n b=None\n a[a.index(x)]=None\nprint(ans)\n\n", "n= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nfor b in a:\n if b:\n bi=format(b, 'b')\n x=2**len(bi)-b\n if x==b:\n ans+=1\n b=None\n\nprint(ans)\n\n", "n= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nfor b in a:\n if b:\n bi=format(b, 'b')\n x=2**len(bi)-b\n if x==b and a.count(x)>1:\n ans+=1\n b=None\n a[a.index(x)]=None\n else:\n ans+=1\n a[a.index(x)]=None\n b=None\nprint(ans)\n ", "import copy\nimport bisect\n\ndef index(a, x):\n i = bisect.bisect_right(a, x)\n a.reverse()\n if i != len(a) and a[i] == x:\n return i\n return -1\n \nn= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nano_a=copy.copy(a)\nano_a.sort()\nfor i in range(n):\n if a[i]:\n bi=format(a[i], 'b')\n x=2**len(bi)-a[i]\n c=index(ano_a,x)\n if x==a[i] and a[i+1]==x:\n ans+=1\n a[i]=None\n a[c]=None\n elif c>=0:\n if x!=a[i]:\n ans+=1\n a[c]=None\n a[i]=None\nprint(ans)", "n= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nfor b in a:\n if b:\n bi=format(b, 'b')\n x=2**len(bi)-b\n if x==b and a.count(x)>1:\n ans+=1\n b=None\n\nprint(ans)\n\n", "n= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nfor i in range(n):\n if a[i]:\n bi=format(a[i], 'b')\n x=2**len(bi)-a[i]\n if a[i]==x and a[i+1]==x:\n ans+=1\n a[i]=None\nprint(ans)", "import copy\nimport bisect\n\ndef index(a, x):\n i = bisect.bisect_right(a, x)\n a.reverse()\n if i != len(a) and a[i] == x:\n return i\n return -1\n \nn= int(input())\na=list(map(int, input().split()))\nans=0\na.sort(reverse=True)\nano_a=copy.copy(a)\nano_a.sort()\nfor i in range(n-1):\n \n if a[i]:\n bi=format(a[i], 'b')\n x=2**len(bi)-a[i]\n c=index(ano_a,x)\n if x==a[i] and a[i+1]==x:\n ans+=1\n a[i]=None\n a[c]=None\n elif c>=0:\n if x!=a[i]:\n ans+=1\n a[c]=None\n a[i]=None\nprint(ans)", "import collections\nimport bisect\nn= int(input())\na=list(map(int, input().split()))\nc=collections.Counter(a)\nans=0\ndes=sorted(a,reverse=True)\n\n\nfor i in des:\n if c[i]>0:\n bi=format(i, 'b')\n x=2**len(bi)-i\n c[i]-=1\n if c[x]>0:\n c[x]-=1\n ans+=1\nprint(ans)"] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s168813239', 's196096725', 's434527160', 's438376352', 's562256234', 's701937886', 's736094643', 's761517544', 's837447079', 's923772750', 's971062775', 's175761439'] | [25708.0, 26932.0, 27444.0, 27444.0, 26932.0, 26704.0, 26704.0, 27444.0, 26832.0, 26932.0, 27444.0, 33296.0] | [413.0, 2104.0, 579.0, 2105.0, 2105.0, 335.0, 2104.0, 2104.0, 2104.0, 363.0, 2105.0, 583.0] | [612, 280, 602, 610, 263, 216, 347, 610, 233, 249, 617, 320] |
p03201 | u750641007 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | [' N=int(input())\n lis=list(map(int,input().split()))\n lis.sort()\n sum=0\n while(len(lis)>1):\n v=lis.pop()\n k=1\n while k<=v:\n k*=2\n m=k-v\n if m in lis:\n sum+=1\n lis.remove(m)\n\n print(sum)', 'N=int(input())\n lis=list(map(int,input().split()))\n lis.sort(reverse=True)\n dis={}\n for x in lis:\n if x in dis.keys():\n dis[x]=dis[x]+1\n else:\n dis[x]=1\n lis=[]\n sum=0\n for key,value in dis.items():\n if value<=0:\n continue\n else:\n x = 1\n while (x<=key):\n x*=2\n another = x-key\n if another in dis.keys() and dis[another]>0:\n if another==key:\n sum+=value//2\n else:\n m=min(dis[another],value)\n dis[another]-=m\n sum+=m\n dis[key]=0\n print(sum)', 'from collections import Counter\nif __name__ == "__main__":\n N=int(input())\n lista=list(map(int,input().split()))\n mii=Counter(lista)\n si=set(lista)\n listb=[i for i in si]\n listb.sort()\n ans=0\n while(len(listb)>0):\n x=listb.pop()\n if mii[x]>0:\n k=1\n while k<=x:\n k*=2\n y=k-x\n if x==y:\n ans+=mii[x]//2\n elif y<x and y in si:\n m=min(mii[x],mii[y])\n ans+=m\n mii[y]-=m\n mii[x]=0\n print(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s425568348', 's847971043', 's262703334'] | [2940.0, 2940.0, 39988.0] | [17.0, 17.0, 1286.0] | [270, 699, 567] |
p03201 | u754022296 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import sys\ninput = sys.stdin.readline\nfrom collections import Counter\nimport bisect\ndef pow_two(x):\n c = 0\n while x:\n x //= 2\n c += 1\n k = 2**c\n if x*2 == c:\n return -1\n return k\n\nn = int(input())\nA = sorted(list(map(int, input().split())))\ncount = dict(Counter(A))\nans = 0\nfor i in A[::-1]:\n if count[i] == 0:\n continue\n t = pow_two(i)\n if t == -1:\n continue\n k = A[bisect.bisect_left(A, t-i)]\n if t-i == k and count[k]:\n count[i] -= 1\n count[t-i] -= 1\n ans += 1\nprint(ans)', 'import sys\ninput = sys.stdin.readline\nfrom collections import Counter\n\nn = int(input())\nA = sorted(map(int, input().split()), reverse=True)\nC = Counter(A)\nans = 0\nfor a in A:\n if not C[a]:\n continue\n r = (1<<a.bit_length()) - a\n if r != a:\n if r in C and C[r] > 0:\n ans += 1\n C[r] -= 1\n else:\n if C[r] >= 2:\n ans += 1\n C[r] -= 1\n C[a] -= 1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s410802184', 's530675354'] | [39436.0, 33424.0] | [1035.0, 401.0] | [508, 384] |
p03201 | u782685137 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['input()\na=sorted(map(int,input().split()))[::-1]\ns={}\nr=0\nfor v in a:\n\tfor i in range(31)[::-1]:\n\t\tp=2**-~i-v\n\t\tif p in s and s[p]>0:r+=1;s[p]-=1;break\n\t\telse:s[v]=s.get(v,0)+1\nprint(r)', 'input()\na=sorted(map(int,input().split()))[::-1]\ns={}\nl=[2**-~i for i in range(31)[::-1]]\nr=0\nfor v in a:\n\tfor j in l:\n\t\tp=j-v\n\t\tif p in s and s[p]>0:r+=1;s[p]-=1;break\n\telse:s[v]=s.get(v,0)+1\nprint(r)'] | ['Wrong Answer', 'Accepted'] | ['s380340482', 's029267626'] | [26612.0, 32832.0] | [2105.0, 1239.0] | [185, 201] |
p03201 | u787562674 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['# -*- coding: utf-8 -*-\nimport collections\n \nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\nc=collections.Counter(A)\n \npairCounter=0\n \nbeki=29\nnibeki=2**beki\n \nfor i in range(N):\n target = A[i]\n if c[target] < 1:\n continue\n c[target]-= 1\n \n while (nibeki > target):\n beki-=1\n nibeki=2**beki\n \n pair = nibeki * 2 - target\n if pair in c.keys() and c[pair] > 0:\n c[pair]-= 1\n pairCounter+=1\n \nprint(pairCounter)', '# -*- coding: utf-8 -*-\nimport collections\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\nc=collections.Counter(A)\n\npairCounter=0\n\nbeki=29\nnibeki=2**beki\n\nfor i in range(N):\n target = A[i]\n if c[target] < 1:\n continue\n c[target]-= 1\n\n while (nibeki > target):\n beki-=1\n nibeki=2**beki\n\n pair = nibeki * 2 - target\n if pair in c.keys() and c[pair] > 0:\n c[pair]-= 1\n pairCounter+=1\n\n print(pairCounter)', 'from collections import Counter\n\nN = int(input())\ninputs = [int(i) for i in input().split()]\n\ninputs.sort(reverse=True)\ncounter_inputs = Counter(inputs)\npowers_of_two = [2**i for i in range(1, 31)]\nans = 0\n\nfor item in inputs:\n if counter_inputs[item] > 0:\n counter_inputs[item] -= 1\n \n while powers_of_two[-1] > 2 * item:\n powers_of_two.pop(-1)\n \n pair = powers_of_two[-1] - item\n if counter_inputs[pair] > 0:\n ans += 1\n counter_inputs[pair] -= 1\n \nprint(ans)\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s111811046', 's127124507', 's709679898'] | [2940.0, 33296.0, 33168.0] | [17.0, 251.0, 452.0] | [498, 481, 538] |
p03201 | u816116805 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n\n#\n\n"""\nagc 029 B\n"""\n\nfrom collections import Counter\n\nn = int(input())\nali = list(map(int, input().split()))\nali.sort(reverse=True)\n\nc = Counter(ali)\nprint(c)\nans = 0\n\n\ndef pow2(n):\n m = n\n tmp = 1\n while m > 0:\n tmp = tmp << 1\n m = m >> 1\n return tmp\n\n\nwhile bool(c):\n m = list(c.elements())[0]\n n = pow2(m) - m\n print(m, n)\n c[m] -= 1\n c += Counter()\n if n in c:\n c[n] -= 1\n ans += 1\n c += Counter()\n\nprint(ans)\n\n\n\n\n\n\n', '#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n\n#\n\n"""\nagc 029 B\n"""\n\nfrom collections import Counter\n\nnn = int(input())\nali = list(map(int, input().split()))\nali.sort(reverse=True)\n\nc = Counter(ali)\nans = 0\n\n\ndef pow2(n):\n m = n\n tmp = 1\n while m > 0:\n tmp = tmp << 1\n m = m >> 1\n return tmp\n\n\nii = 0\nm = ali[ii]\nwhile bool(c):\n while c[ali[ii]] == 0:\n ii += 1\n m = ali[ii]\n n = pow2(m) - m\n c[m] -= 1\n if c[m] <= 0:\n del c[m]\n if n in c:\n c[n] -= 1\n if c[n] <= 0:\n del c[n]\n ans += 1\n\nprint(ans)\n\n\n\n\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s721813324', 's879297663'] | [53568.0, 33296.0] | [2105.0, 1368.0] | [546, 610] |
p03201 | u858136677 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['def invbisect(a,x):\n right = len(a)-1\n left = 0\n while abs(left-right) > 1:\n if a[(left+right)//2] <= x:\n right = (left+right)//2\n else:\n left = (left+right)//2\n return right\n\nn = int(input())\na = list(map(int,input().split()))\ntwo = [2]\ni = 0\nwhile two[i]*2 <= 2*10**9:\n two.append(two[i]*2)\n i += 1\ntwo.reverse()\nm = len(two)\n\na.sort()\na.reverse()\nprint(a)\nprint(invbisect(a,5))\ncounter = 0\n\ni = 0\nwhile i < n-1:\n for k in range(m):\n if two[k] > a[i]:\n ind = invbisect(a,two[k]-a[i])\n if a[ind] == two[k]-a[i]:\n a.pop(ind)\n a.pop(i)\n i -= 1\n n -= 2\n counter += 1\n i += 1\nprint(counter)\n', 'import collections\nn = int(input())\na = list(map(int,input().split()))\n\nused = collections.Counter(a)\na.sort()\na.reverse()\n\ntwo = [2]\ni = 0\nwhile two[i]*2 <= 2*10**9:\n two.append(two[i]*2)\n i += 1\ntwo.reverse()\n\ncounter = 0\nfor i in range(n):\n if used[a[i]] > 0:\n while two[-1] > 2*a[i]:\n two.pop(-1)\n for k in range(len(two)):\n if used[two[k]-a[i]] >= 1:\n counter += 1\n used[two[k]-a[i]] -= 1\n used[a[i]] -= 1\nprint(counter)', 'import collections\nn = int(input())\na = list(map(int,input().split()))\n\nused = collections.Counter(a)\na.sort()\na.reverse()\n\ntwo = [2]\ni = 0\nwhile two[i]*2 <= 2*10**9:\n two.append(two[i]*2)\n i += 1\n\ncounter = 0\nfor i in range(n):\n if used[a[i]] > 0:\n used[a[i]] -= 1\n while two[-1] > 2*a[i]:\n two.pop(-1)\n\n if used[two[-1]-a[i]] >= 1:\n counter += 1\n used[two[-1]-a[i]] -= 1\n\nprint(counter)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s100365397', 's891961463', 's985436153'] | [27060.0, 33296.0, 33296.0] | [2105.0, 2105.0, 523.0] | [752, 515, 451] |
p03201 | u864197622 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import bisect\n\nN = int(input())\nA = [int(a) for a in input().split()]\nA = sorted(A)\n\nc = 0\nfor i in range(N - 1 , -1, -1):\n b = 1\n while b <= A[i]:\n b <<= 1\n \n j = bisect.bisect_left(A, b - A[i])\n if b - A[i] == A[j]:\n c += 1\n A[j] = A[j] - 0.5\n A[i] = A[i] + 0.5\n\nprint(c)\n', 'import bisect\n\nN = int(input())\nA = [int(a) for a in input().split()]\nA = sorted(A)\n\nc = 0\nfor i in range(N - 1 , -1, -1):\n if A[i] == int(A[i]):\n b = 1\n while b <= A[i]:\n b <<= 1\n\n j = bisect.bisect_left(A, b - A[i])\n if b - A[i] == A[j]:\n c += 1\n A[j] = A[j] - 0.5\n A[i] = A[i] + 0.5\n\nprint(c)\n', 'import bisect\n\nN = int(input())\nA = [int(a) for a in input().split()]\nA = sorted(A)\n\nc = 0\nfor i in range(N - 1 , -1, -1):\n b = 1\n while b <= A[i]:\n b <<= 1\n \n j = bisect.bisect_left(A, b - A[i])\n if b - A[i] == A[j]:\n c += 1\n A[j] = A[j] - 0.5\n\nprint(c)\n', 'import bisect\n\nN = int(input())\nA = [int(a) for a in input().split()]\nA = sorted(A)\n\nc = 0\nfor i in range(N - 1 , -1, -1):\n if A[i] == int(A[i]):\n b = 1\n while b <= A[i]:\n b <<= 1\n\n j = bisect.bisect_left(A, b - A[i])\n if i > j:\n if b - A[i] == A[j]:\n c += 1\n A[j] = A[j] - 0.5\n A[i] = A[i] + 0.5\nprint(c)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s266859280', 's565984327', 's644913388', 's748016041'] | [25836.0, 25836.0, 25888.0, 25840.0] | [1581.0, 1296.0, 1590.0, 1490.0] | [317, 371, 291, 404] |
p03201 | u871352270 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['N = int(input())\nball = list(map(int, input().split()))\nball.sort(reverse = True)\nok = {}\nfor x in ball:\n if x in ok:\n dic[x] += 1\n else:\n dic[x] = 1\nans = 0\nfor x in ball:\n if ok[x] != 0:\n y = 2**(x.bit_length()) - x\n if ok[y] != 0:\n if y == x and ok[y] == 1: \n continue\n ans += 1\n dic[x] -= 1\n dic[y] -= 1\nprint(ans)', 'N = int(input())\nball = list(map(int, input().split()))\nball.sort(reverse = True)\nok = {}\nfor x in ball:\n if x in ok:\n ok[x] += 1\n else:\n ok[x] = 1\nans = 0\nfor x in ball:\n if ok[x] != 0:\n y = 2**(x.bit_length()) - x\n if y in ok:\n if ok[y] != 0:\n if y == x and ok[y] == 1: \n continue\n ans += 1\n ok[x] -= 1\n ok[y] -= 1\nprint(ans)\n\n'] | ['Runtime Error', 'Accepted'] | ['s328465304', 's912951050'] | [25924.0, 33696.0] | [148.0, 337.0] | [414, 456] |
p03201 | u875291233 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['# coding: utf-8\n# Your code here!\n\nimport bisect\n\nn=int(input())\na = [int(i) for i in input().split()]\na.sort()\ncheck = [0]*n\nprint(a)\n\nans=0\n\nwhile(a):\n c=a.pop()\n d=c\n keta=0\n while(d!=0):\n d=d//2\n keta +=1\n x = 2**keta - c\n# print(c,x)\n i = bisect.bisect_left(a, x)\n if i != len(a) and a[i] == x:\n ans += 1\n\n a.remove(x)\n\n\n\nprint(ans)\n\n', '# coding: utf-8\n# Your code here!\n\nimport bisect\nimport collections\n\nn=int(input())\na = [int(i) for i in input().split()]\na.sort()\n#print(a)\n\nchecked=collections.Counter(a)\n\nans=0\n\nwhile(a):\n c=a.pop()\n if checked[c]==0:\n continue\n checked[c]-=1\n d=c\n keta=0\n while(d!=0):\n d=d//2\n keta +=1\n x = 2**keta - c\n# print(c,x)\n i = bisect.bisect_right(a, x)\n if i and a[i-1] == x and checked[x]>0:\n ans += 1\n checked[x]-=1\n \n# print(checked)\n# print(checked)\n\n\n\n\n\nprint(ans)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s121095877', 's257550937'] | [25836.0, 33216.0] | [2104.0, 1837.0] | [419, 580] |
p03201 | u883048396 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['N = int(input())\naA = sorted([int(_) for _ in input().split()],reverse=True)\naA1 = [ _ for _ in aA if _ % 2 ]\naA0 = [ _ for _ in aA if _ % 2 == 0 ]\n\n\ndef searchPair(aD):\n iL = len(aD)\n dsT =set()\n iC = 0\n for i in range(iL):\n for j in range(i+1,iL):\n if i in dsT or j in dsT:\n continue\n iWa = aD[i] + aD[j]\n if not ( iWa & (iWa - 1)):\n dsT.add(i)\n dsT.add(j)\n iC += 1\n continue\n\n return iC\niC = 0\niC += searchPair(aA1)\niC += searchPair(aA0)\niC += searchPair(aA)\nprint(iC)\n', '\n\n\ndef θ§£():\n N = int(input())\n dA ={}\n def lenbin(a):\n return len(bin(a)) - 2\n def addData(oDict,a):\n if a in oDict:\n oDict[a]+=1\n else:\n oDict[a]=1\n for a in map(int,input().split()):\n addData(dA,a)\n def searchPair(oD):\n iC = 0\n for a in sorted(oD.keys(),reverse=True):\n if oD[a]:\n t = ( 1 << lenbin(a)) - a\n if t == a:\n iAT = oD[a] // 2\n iC += iAT\n oD[a] -= iAT *2\n elif t in oD:\n iAT = min(oD[a],oD[t])\n iC += iAT\n oD[a] -= iAT\n oD[t] -= iAT\n return iC\n print(searchPair(dA))\nθ§£()\n'] | ['Wrong Answer', 'Accepted'] | ['s612608751', 's358336790'] | [26932.0, 44560.0] | [2104.0, 373.0] | [603, 899] |
p03201 | u894258749 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import bisect\ninpl = lambda: list(map(int,input().split()))\nN = int(input())\nA = sorted(inpl())\nused = [0] * N\n\nans = 0\nfor i in range(1,N):\n if used[-i] == 1:\n continue\n p = len(bin(A[-i]))-3\n B = (1 << (p+1)) - A[-i]\n m = bisect.bisect_left(A,B,0,N-i)\n if m < N-i and used[m] == 0 and A[m] == B:\n ans += 1\n used[m] = 1\n print((A[-i],A[m]))\n\nprint(ans)', 'import bisect\ninpl = lambda: list(map(int,input().split()))\n_ = int(input())\nA = sorted(inpl())\nAnlist = []\nap = 0\nfor a in A:\n if a > ap:\n Anlist.append([a,1])\n ap = a\n else:\n Anlist[-1][1] += 1\n\nA = [ a for a,n in Anlist ]\nN = len(Anlist)\n\nans = 0\nfor i in range(1,N+1):\n if Anlist[-i][1] == 0:\n continue\n \n p = len(bin(A[-i]))-3\n B = (1 << (p+1)) - A[-i]\n if A[-i] == B:\n ans += Anlist[-i][1]//2\n else:\n m = bisect.bisect_left(A,B,0,N-i)\n if m < N-i and A[m] == B:\n pairs = min(Anlist[m][1],Anlist[-i][1])\n ans += pairs\n Anlist[m][1] -= pairs\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s634516585', 's884846961'] | [27060.0, 33940.0] | [524.0, 765.0] | [370, 601] |
p03201 | u905582793 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['from math import log2\nimport heapq as hq\nfrom collections import Counter\nn = int(input())\na = list(map(int,input().split()))\nc = Counter(a)\na = [-a[i] for i in range(n)]\nhq.heapify(a)\nans = 0\nwhile a:\n x = hq.heappop(a)\n x = -x\n if c[x]>0:\n y = 2**(int(log2(x))+1)\n if c[y-x]>0:\n ans += 1\n c[x] -= 1\n c[y-x] -= 1\nprint(ans)', 'from math import log2\nimport heapq as hq\nfrom collections import Counter\nn = int(input())\na = list(map(int,input().split()))\nc = Counter(a)\na = [-a[i] for i in range(n)]\nhq.heapify(a)\nans = 0\nwhile a:\n x = hq.heappop(a)\n x = -x\n if c[x]>0:\n y = 2**(int(log2(x))+1)\n if x*2 == y:\n ans += c[x]//2\n c[x] = c[x]%2\n else:\n if c[y-x]>0:\n ans += 1\n c[x] -= 1\n c[y-x] -= 1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s767676248', 's729564515'] | [33432.0, 33432.0] | [718.0, 679.0] | [347, 423] |
p03201 | u914992391 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['# -*- coding: utf-8 -*-\nimport copy\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n beki=2**b\n if beki > A[i]:\n pair= beki - A[i]\n if pair in A:\n A[A.index(pair)] = -1\n pairCounter+=1\n A[i] = -1\n break\nprint(pairCounter)\n#print(2)', '# -*- coding: utf-8 -*-\n\nN = int(input())\nA = list(map(int, input().split()))\n#A.sort(reverse=True)\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n pair=2**b - A[i]\n if A.count(pair) >0:\n A[i] = -1\n A[A.index(pair)] = -1\n pairCounter+=1\n break\n\nprint(pairCounter)', '# -*- coding: utf-8 -*-\nimport copy\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n beki=2**b\n if beki > A[i]:\n pair= beki - A[i]\n if A.count(pair) >0:\n A[A.index(pair)] = -1\n pairCounter+=1\n A[i] = -1\n break\nprint(pairCounter)', '# -*- coding: utf-8 -*-\n\nN = int(input())\norg = list(map(int, input().split()))\nA=org\n"""\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n pair=2**b - A[i]\n if pair < 1:\n continue\n if A.count(pair) >0:\n A[i] = -1\n A[A.index(pair)] = -1\n pairCounter+=1\n break\n\nB=org \nB.sort(reverse=True)\n \nprint(pairCounter)\n"""', '# -*- coding: utf-8 -*-\nimport copy\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n beki=2**b\n if beki > A[i]:\n pair=beki - A[i]\n if A.count(pair) >0:\n A[i] = -1\n A[A.index(pair)] = -1\n pairCounter+=1\n break\nprint(pairCounter)', '# -*- coding: utf-8 -*-\nimport copy\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n beki=2**b\n if beki > A[i]:\n pair= beki - A[i]\n if pair in A:\n A[A.index(pair)] = -1\n pairCounter+=1\n A[i] = -1\n break\n\nprint(2)', '# -*- coding: utf-8 -*-\nimport copy\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n beki=2**b\n if beki > A[i]:\n pair= beki - A[i]\n if A.count(pair) >0:\n \n pairCounter+=1\n A[i] = -1\n break\n\nprint(2)', '# -*- coding: utf-8 -*-\nimport collections\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\nc=collections.Counter(A)\n\npairCounter=0\n\nbeki=7\nnibeki=2**beki\n\nfor i in range(N):\n target = A[i]\n if c[target] < 0:\n continue\n c[target]= -1\n\n while (nibeki > target):\n beki-=1\n nibeki=2**beki\n\n pair = nibeki * 2 - target\n if pair in c.keys():\n c[pair]= -1\n pairCounter+=1\n\nprint(pairCounter)', '# -*- coding: utf-8 -*-\nimport copy\n\nN = int(input())\norg = list(map(int, input().split()))\nA=copy.copy(org)\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n pair=2**b - A[i]\n if pair < 1:\n continue\n if A.count(pair) >0:\n A[i] = -1\n A[A.index(pair)] = -1\n pairCounter+=1\n break\n\nB=copy.copy(org) \nB.sort(reverse=True)\nprint(B)\n\npairCounterB=0\nfor i in range(N):\n if B[i] < 0:\n continue\n for b in range(9):\n pair=2**b - B[i]\n if pair < 1:\n continue\n if B.count(pair) >0:\n B[i] = -1\n B[B.index(pair)] = -1\n pairCounterB+=1\n break\n \nif pairCounterB < pairCounter:\n print(pairCounter)\nelse:\n print(pairCounterB)', '# -*- coding: utf-8 -*-\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\n"""\npairCounter=0\nfor i in range(N):\n for j in range(N -i -1):\n if A[j+i +1] < 1:\n continue\n if A[i] < 1:\n break\n wa = A[i] + A[j+i +1]\n for b in range(9):\n if 2**b & wa == wa:\n A[i]=-1\n A[j+i +1]=-1\n pairCounter+=1\n break\n"""\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n pair=2**b - A[i]\n if A.count(pair) >0:\n A[i] = -1\n A[A.index(pair)] = -1\n pairCounter+=1\n break\n\nprint(pairCounter)', '# -*- coding: utf-8 -*-\nimport copy\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n beki=2**b\n if beki > A[i]:\n pair= beki - A[i]\n \n A[i] = -1\n break\n\nprint(2)', '# -*- coding: utf-8 -*-\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\npairCounter=0\nfor i in range(N):\n if A[i] < 0:\n continue\n for b in range(9):\n pair=2**b - A[i]\n if pair < 1:\n continue\n \n if A.count(pair) >0:\n A[i] = -1\n A[A.index(pair)] = -1\n pairCounter+=1\n break\n\nprint(pairCounter)', '# -*- coding: utf-8 -*-\nimport copy\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\n\npairCounter=0\n\nbeki=7\nnibeki=2**beki\n\nfor i in range(N):\n target = A[i]\n if target < 0:\n continue\n A[i] = -1 \n\n while (nibeki > target):\n beki-=1\n nibeki=2**beki\n\n pair = nibeki * 2 - target\n #if pair in A:\n \n \n\nprint(2)', '# -*- coding: utf-8 -*-\nimport collections\n\nN = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\nc=collections.Counter(A)\n\npairCounter=0\n\nbeki=29\nnibeki=2**beki\n\nfor i in range(N):\n target = A[i]\n if c[target] < 1:\n continue\n c[target]-= 1\n\n while (nibeki > target):\n beki-=1\n nibeki=2**beki\n\n pair = nibeki * 2 - target\n if pair in c.keys() and c[pair] > 0:\n c[pair]-= 1\n pairCounter+=1\n\nprint(pairCounter)'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s144645249', 's152063445', 's461014043', 's475108185', 's515518069', 's630939351', 's700051433', 's703035446', 's738956372', 's791631488', 's810459907', 's825700922', 's902995315', 's932733308'] | [27444.0, 26612.0, 27444.0, 26932.0, 27564.0, 27120.0, 27216.0, 33296.0, 27444.0, 26836.0, 27216.0, 26704.0, 27216.0, 33296.0] | [2104.0, 2104.0, 2104.0, 66.0, 2104.0, 2104.0, 2105.0, 477.0, 2104.0, 2104.0, 911.0, 2104.0, 236.0, 446.0] | [381, 325, 378, 390, 379, 381, 389, 432, 727, 608, 408, 373, 391, 449] |
p03201 | u952708174 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['def b_powers_of_two(N, A):\n \n from bisect import bisect_left\n a = sorted(A)\n ans = 0\n for j in range(N - 1, -1, -1):\n \n b = 1\n while b <= a[j]:\n b <<= 1\n\n k = bisect_left(a, b - a[j])\n if k < j and (b - a[j] == a[k]):\n \n \n \n ans += 1\n \n \n \n \n a[j] += 0.1\n a[k] -= 0.1\n\n return ans\n\nA = [int(i) for i in input().split()]\nprint(b_powers_of_two(N, A))', 'def b_powers_of_two(N, A):\n \n from bisect import bisect_left\n a = sorted(A)\n ans = 0\n for j in range(N - 1, -1, -1):\n \n b = 1\n while b <= a[j]:\n b <<= 1\n\n k = bisect_left(a, b - a[j])\n if k < j and (b - a[j] == a[k]):\n \n \n \n ans += 1\n \n \n \n \n a[j] += 0.1\n a[k] -= 0.1\n\n return ans\n\nA = [int(i) for i in input().split()]\nprint(b_powers_of_two(N, A))', 'def b_powers_of_two(N, A):\n \n from bisect import bisect_left\n a = sorted(A)\n ans = 0\n for j in range(N - 1, -1, -1):\n \n b = 1\n while b <= a[j]:\n b <<= 1\n\n k = bisect_left(a, b - a[j])\n if k < j and (b - a[j] == a[k]):\n \n \n \n ans += 1\n \n \n \n \n a[j] += 0.1\n a[k] -= 0.1\n\n return ans\n\nN = int(input())\nA = [int(i) for i in input().split()]\nprint(b_powers_of_two(N, A))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s326045461', 's331657386', 's107147785'] | [3064.0, 3064.0, 26180.0] | [18.0, 19.0, 1153.0] | [1224, 1224, 1241] |
p03201 | u961595602 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['# -*- coding: utf-8 -*-\nfrom sys import stdin\nimport numpy as np\n\nd_in = lambda: int(stdin.readline()) # N = d_in()\nds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()\n\nN = d_in()\nA_list = np.array(ds_in())\nA_list.sort()\nEPSILON = 10**(-6)\n\ncand_A = 2 ** (np.log2(A_list + EPSILON).astype(int) + 1) - A_list\nidx = np.searchsorted(A_list, cand_A)\nflag = np.zeros(N, dtype=int)\n\nans = 0\nfor i in range(N-1, -1, -1):\n print(flag)\n if flag[i]:\n continue\n if idx[i] == i:\n continue\n if A_list[idx[i]] == cand_A[i]:\n ans += 1\n flag[idx[i]] = 1\n\nprint(ans)\n', '# -*- coding: utf-8 -*-\nfrom sys import stdin\nimport numpy as np\nfrom collections import Counter\n\nd_in = lambda: int(stdin.readline()) # N = d_in()\nds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()\n\nN = d_in()\nA_list = np.array(ds_in())\nA_list.sort()\nEPSILON = 10**(-6)\n\ncand_A = 2 ** (np.log2(A_list + EPSILON).astype(int) + 1) - A_list\nidx = np.searchsorted(A_list, cand_A)\nA_count = dict(Counter(A_list))\n\nans = 0\nfor i in range(N-1, -1, -1):\n if A_count[A_list[i]] <= 0:\n continue\n A_count[A_list[i]] -= 1\n if (A_list[idx[i]] == cand_A[i]) and (A_count[cand_A[i]] > 0):\n ans += 1\n A_count[cand_A[i]] -= 1\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s220364636', 's714081852'] | [34412.0, 48448.0] | [2109.0, 595.0] | [614, 677] |
p03201 | u969190727 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['import math\nn=int(input())\nA=[int(i) for i in input().split()]\nB=[]\nfor a in A:\n B.append(a)\nA.sort(reverse=True)\ncount=0\nfor i in range(n):\n cur=A[i]\n if cur in B:\n k=int(math.log2(cur))+1\n pair=2**k-cur\n if pair in B:\n B.remove(pair)\n count+=1\nprint(count)', 'import math\nn=int(input())\nA=[int(i) for i in input().split()]\nB=[]\nfor a in A:\n B.append(a)\nA.sort(reverse=True)\ncount=0\nfor i in range(n):\n cur=A[i]\n if cur in B:\n k=int(math.log2(cur))+1\n pair=2**k-cur\n if pair in B:\n B.remove(pair)\n B.remove(cur)\n count+=1\nprint(count)\n', 'import bisect\nimport collections\ndef f(n):\n return n.bit_length()\nn=int(input())\nA=[int(i) for i in input().split()]\nD=dict(collections.Counter(A))\nC=sorted(list(D.keys()))\nans=0\nfor i in range(len(C)):\n pair=2**f(C[-(i+1)])-C[-(i+1)]\n k=bisect.bisect_left(C,pair)\n if C[k]==pair:\n if k==len(C)-(i+1):\n ans+=D[pair]//2\n D[pair]%=2\n else:\n aa=min(D[pair],D[C[-(i+1)]])\n ans+=aa\n D[pair]-=aa\n D[C[-(i+1)]]-=aa\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s029200949', 's262193212', 's760200219'] | [26608.0, 26832.0, 39356.0] | [2104.0, 2104.0, 672.0] | [280, 301, 458] |
p03201 | u997113115 | 2,000 | 1,048,576 | Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed. Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t. | ['from collections import defaultdict\n\nN = int(input())\nA = sorted(list(map(int, input().split())), reverse=True)\ndic = defaultdict(int)\nfor a in A:\n dic[a] = 1\n\nans = 0\nfor i in range(N):\n if dic[A[i]] != 0:\n b = 2**(A[i].bit_length()) - A[i]\n if dic[b]:\n ans += 1\n dic[A[i]], dic[b] = 0, 0\n\nprint(ans)', 'from collections import defaultdict\n\nN = int(input())\nA = sorted(list(map(int, input().split())), reverse=True)\ndic = defaultdict(int)\nfor a in A:\n dic[a] += 1\n\nans = 0\nfor a in A:\n if dic[a] != 0:\n b = 2**(a.bit_length()) - a\n if dic[b] != 0:\n if b == a and dic[b] == 1:\n continue\n ans += 1\n dic[a] -= 1\n dic[b] -= 1\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s559859471', 's791755026'] | [56188.0, 56188.0] | [438.0, 431.0] | [343, 408] |
p03203 | u070561949 | 2,000 | 1,048,576 | Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j \leq W) by (i,j). There is no obstacle at (1,1), and there is a piece placed there at (1,1). Starting from Takahashi, he and Aoki alternately perform one of the following actions: * Move the piece to an adjacent cell. Here, let the position of the piece be (x,y). Then Takahashi can only move the piece to (x+1,y), and Aoki can only move the piece to (x,y+1). If the destination cell does not exist or it is occupied by an obstacle, this action cannot be taken. * Do not move the piece, and end his turn without affecting the grid. The game ends when the piece does not move twice in a row. Takahashi would like to perform as many actions (including not moving the piece) as possible before the game ends, while Aoki would like to perform as few actions as possible before the game ends. How many actions will Takahashi end up performing? | ['# Debug Print\nisdbg = True\ndef dprint(*value,sep=\' \',end=\'\\n\'):\n if isdbg:\n print(*value,sep=sep,end=end)\n\n\nH,W,N = map(int,input().split())\n\n\nBL = {}\nfor i in range(N):\n x1,y1 = map(int,input().split())\n #XY[x1-1][y1-1] = 1\n BL[str(x1-1) + "," + str(y1-1)] = x1+y1-2\n\n \n\n#if isdbg:\n\n #for j in range(H):\n # dprint(XY[i][j],end=\'\')\n #dprint() \n\nTL = sorted(BL.items(), key=lambda x: x[1])\n#print(TL)\n\nif len(TL) == 0:\n print(H)\n exit(0)\n\nfor b in TL:\n x,y = map(int,b[0].split(\',\'))\n sx = x-1\n sy = y\n \n isflg = True\n if sx <= 0 or sy <= 0:\n continue\n\n dprint("\\t",sx,sy)\n\n while sx > 0 and sy > 0 :\n sx = sx - 1\n sy = sy - 1\n if str(sx)+","+str(sy) in BL : \n isflg = False \n break\n\n if isflg and sy == 0:\n print(x)\n exit(0)', '# Debug Print\nisdbg = True\ndef dprint(*value,sep=\' \',end=\'\\n\'):\n if isdbg:\n print(*value,sep=sep,end=end)\n\n\nH,W,N = map(int,input().split())\n\nXY = [[0 for i in range(W)] for i in range(H)]\nBL = {}\nfor i in range(N):\n x1,y1 = map(int,input().split())\n XY[x1-1][y1-1] = 1\n BL[str(x1-1) + "," + str(y1-1)] = x1+y1-2\n\n \n\nif isdbg:\n for i in range(W):\n for j in range(H):\n dprint(XY[i][j],end=\'\')\n dprint() \n\nTL = sorted(BL.items(), key=lambda x: x[1])\n#print(TL)\n\nif len(TL) == 0:\n print(H)\n exit(0)\n\nmin = H\nfor b in TL:\n x,y = map(int,b[0].split(\',\'))\n sx = x-1\n sy = y\n \n isflg = True\n if sx <= 0 or sy <= 0:\n continue\n\n #dprint("\\t",sx,sy)\n\n while sx > 0 and sy > 0 :\n sx = sx - 1\n sy = sy - 1\n if str(sx)+","+str(sy) in BL : \n isflg = False \n break\n\n if isflg and sy == 0:\n min = x\n break\n\nfor x in range(H):\n if str(x)+","+str(0) in BL :\n if min > x :\n min = x\n break\nprint(min)', "# Debug Print\nisdbg = False\n#isdbg = True\ndef dprint(*value,sep=' ',end='\\n'):\n if isdbg:\n print(*value,sep=sep,end=end)\n \n\nH,W,N = map(int,input().split())\n\nif isdbg:\n XY = [[0 for i in range(W)] for i in range(H)]\nBL = {}\nfor i in range(N):\n x1,y1 = map(int,input().split())\n if isdbg:\n XY[x1-1][y1-1] = 1\n\n if x1-1 in BL :\n BL[x1-1].append(y1-1)\n else:\n BL[x1-1] = [y1-1]\n\nTL = sorted(BL.items(),key= lambda x: x[0])\n\n\nif isdbg:\n for i in range(W):\n for j in range(H):\n dprint(XY[i][j],end='')\n dprint()\n#print(TL)\n\nmaxr = 1\nfor i in range(H-1):\n\n if i+1 in BL:\n l = BL[i+1]\n l.sort()\n #print(l,maxr)\n for ll in l :\n if maxr > ll:\n print(i+1)\n exit(0)\n elif maxr == ll:\n maxr -= 1\n break\n else:\n break\n \n maxr += 1\n\nprint(H)\n"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s436132614', 's879949961', 's664449172'] | [51760.0, 500272.0, 62788.0] | [1058.0, 2138.0, 1307.0] | [979, 1101, 987] |
p03203 | u077337864 | 2,000 | 1,048,576 | Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j \leq W) by (i,j). There is no obstacle at (1,1), and there is a piece placed there at (1,1). Starting from Takahashi, he and Aoki alternately perform one of the following actions: * Move the piece to an adjacent cell. Here, let the position of the piece be (x,y). Then Takahashi can only move the piece to (x+1,y), and Aoki can only move the piece to (x,y+1). If the destination cell does not exist or it is occupied by an obstacle, this action cannot be taken. * Do not move the piece, and end his turn without affecting the grid. The game ends when the piece does not move twice in a row. Takahashi would like to perform as many actions (including not moving the piece) as possible before the game ends, while Aoki would like to perform as few actions as possible before the game ends. How many actions will Takahashi end up performing? | ['import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(pow(10, 6))\n\ndef main():\n h, w, n = map(int, input().split())\n xy = [tuple(map(int, input().split())) for _ in range(n)]\n miny = [float("inf") for _ in range(h + 1)]\n for x, y in xy:\n miny[x - 1] = min(miny[x - 1], y - 1)\n miny[h] = 0\n \n tmpx, tmpy = 0, 0\n while tmpx < h:\n if miny[tmpx + 1] == tmpy + 1:\n tmpx += 1\n elif miny[tmpy + 1] < tmpy:\n break\n else:\n tmpx += 1\n tmpy += 1\n \n print(tmpx + 1)\n\n\nif __name__ == \'__main__\':\n main()\n', 'import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(pow(10, 6))\n\ndef main():\n h, w, n = map(int, input().split())\n xy = [tuple(map(int, input().split())) for _ in range(n)]\n miny = [float("inf") for _ in range(h + 1)]\n for x, y in xy:\n miny[x - 1] = min(miny[x - 1], y - 1)\n miny[h] = 0\n \n tmpx, tmpy = 0, 0\n while tmpx < h:\n if miny[tmpx + 1] <= tmpy:\n break\n elif miny[tmpx + 1] == tmpy + 1:\n tmpx += 1\n else:\n tmpx += 1\n tmpy += 1\n \n print(min(tmpx + 1, h))\n\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s836016639', 's386111838'] | [42524.0, 42524.0] | [422.0, 481.0] | [602, 611] |
p03203 | u368780724 | 2,000 | 1,048,576 | Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j \leq W) by (i,j). There is no obstacle at (1,1), and there is a piece placed there at (1,1). Starting from Takahashi, he and Aoki alternately perform one of the following actions: * Move the piece to an adjacent cell. Here, let the position of the piece be (x,y). Then Takahashi can only move the piece to (x+1,y), and Aoki can only move the piece to (x,y+1). If the destination cell does not exist or it is occupied by an obstacle, this action cannot be taken. * Do not move the piece, and end his turn without affecting the grid. The game ends when the piece does not move twice in a row. Takahashi would like to perform as many actions (including not moving the piece) as possible before the game ends, while Aoki would like to perform as few actions as possible before the game ends. How many actions will Takahashi end up performing? | ['from collections import defaultdict\nimport sys\ndef inpl(): return [int(i) for i in input().split()]\nH, W, N = inpl()\nif not N:\n print(W)\n sys.exit()\nA = []\nB = defaultdict(lambda: [])\nC = defaultdict(lambda: W)\nfor _ in range(N):\n x, y = inpl()\n A.append((x,y))\n B[y].append(x)\nT = [0]*(H+1)\nT[1] = 2\nfor i in range(1,H):\n if not B[i+1]:\n T[i+1] = min(W,T[i] + 1)\n continue\n ctr = T[i]\n while True:\n if ctr in B[i+1]:\n ctr += 1\n continue\n break\n T[i+1] = min(ctr+1, W)\nfor x,y in A:\n if x >= T[y]:\n C[y] = min(C[y], x)\nprint(min([i-1 for i in C.values()]+[W]))\nprint(T)', 'from collections import defaultdict\nimport sys\ndef inpl(): return [int(i) for i in input().split()]\nH, W, N = inpl()\nif not N:\n print(H)\n sys.exit()\nA = []\nB = defaultdict(lambda: [])\nC = defaultdict(lambda: H+1)\nfor _ in range(N):\n x, y = inpl()\n A.append((x,y))\n B[y].append(x)\nT = [0]*(W+1)\nT[1] = 2\nfor i in range(1,W):\n if not B[i+1]:\n T[i+1] = T[i] + 1\n continue\n ctr = T[i]\n while True:\n if ctr in B[i+1]:\n ctr += 1\n continue\n break\n T[i+1] = min(ctr+1, H+1)\nfor x,y in A:\n if x >= T[y]:\n C[y] = min(C[y], x)\nprint(min([i-1 for i in C.values()]+[H]))'] | ['Runtime Error', 'Accepted'] | ['s501138719', 's440524549'] | [79700.0, 75756.0] | [1345.0, 1969.0] | [656, 644] |
p03203 | u532966492 | 2,000 | 1,048,576 | Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j \leq W) by (i,j). There is no obstacle at (1,1), and there is a piece placed there at (1,1). Starting from Takahashi, he and Aoki alternately perform one of the following actions: * Move the piece to an adjacent cell. Here, let the position of the piece be (x,y). Then Takahashi can only move the piece to (x+1,y), and Aoki can only move the piece to (x,y+1). If the destination cell does not exist or it is occupied by an obstacle, this action cannot be taken. * Do not move the piece, and end his turn without affecting the grid. The game ends when the piece does not move twice in a row. Takahashi would like to perform as many actions (including not moving the piece) as possible before the game ends, while Aoki would like to perform as few actions as possible before the game ends. How many actions will Takahashi end up performing? | ['def input(): return next(input_sample)\n\n\ninput_sample = iter("""\n100000 100000 0\n""".split("\\n")[1:-1])\n\n\ndef main():\n h, w, n = map(int, input().split())\n xy = [tuple(map(lambda x:int(x)-1, input().split())) for _ in [0]*n]\n ans = h\n d = set(xy)\n block = [[h] for _ in [0]*w]\n for x, y in xy:\n block[y].append(x)\n block = [sorted(i)[::-1] for i in block]\n nowx, nowy = 0, 0\n for i in range(h):\n if nowy >= w:\n break\n while block[nowy]:\n j = block[nowy][-1]\n if j > nowx:\n ans = min(ans, j)\n break\n else:\n block[nowy].pop()\n if (nowx+1, nowy) in d:\n break\n else:\n nowx += 1\n if (nowx, nowy+1) not in d:\n nowy += 1\n print(ans)\n\n\nmain()\n', 'def main():\n h, w, n = map(int, input().split())\n xy = [tuple(map(lambda x:int(x)-1, input().split())) for _ in [0]*n]\n ans = h\n d = set(xy)\n block = [[h] for _ in [0]*w]\n for x, y in xy:\n block[y].append(x)\n block = [sorted(i)[::-1] for i in block]\n nowx, nowy = 0, 0\n for i in range(h):\n if nowy >= w:\n break\n while block[nowy]:\n j = block[nowy][-1]\n if j > nowx:\n ans = min(ans, j)\n break\n else:\n block[nowy].pop()\n if (nowx+1, nowy) in d:\n break\n else:\n nowx += 1\n if (nowx, nowy+1) not in d:\n nowy += 1\n print(ans)\n\n\nmain()'] | ['Wrong Answer', 'Accepted'] | ['s562746987', 's504800881'] | [23908.0, 82916.0] | [171.0, 1449.0] | [829, 722] |
p03203 | u792050702 | 2,000 | 1,048,576 | Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j \leq W) by (i,j). There is no obstacle at (1,1), and there is a piece placed there at (1,1). Starting from Takahashi, he and Aoki alternately perform one of the following actions: * Move the piece to an adjacent cell. Here, let the position of the piece be (x,y). Then Takahashi can only move the piece to (x+1,y), and Aoki can only move the piece to (x,y+1). If the destination cell does not exist or it is occupied by an obstacle, this action cannot be taken. * Do not move the piece, and end his turn without affecting the grid. The game ends when the piece does not move twice in a row. Takahashi would like to perform as many actions (including not moving the piece) as possible before the game ends, while Aoki would like to perform as few actions as possible before the game ends. How many actions will Takahashi end up performing? | ['x,y,num = map(int, input().split())\ngaiz = [x]*x\nkaisu = x\nfor _ in range(num):\n xg,yg = map(int,input().split())\n if xg >= yg:\n sa = xg-yg\n if yg < gaiz[sa]:\n gaiz[sa]=(yg)\nprint(gaiz) \n\nif len(gaiz) ==0:\n print(kaisu)\nelse:\n for num,(maegai,gai) in enumerate(zip(gaiz[:-1],gaiz[1:])):\n if maegai>gai:\n kaisu = num+gai\n break\n print(kaisu) \n', 'x,y,num = map(int, input().split())\ngaiz = []\nzen_gaiz = [[]]*x\nkaisu = x\nfor _ in range(num):\n xg,yg = map(int,input().split())\n \n if xg >= yg:\n zen_gaiz[xg-1].append(yg)\n if xg != yg:\n gaiz.append((xg,yg))\n\nif len(gaiz) ==0:\n print(kaisu)\nelse:\n finish = False\n for gai in sorted(gaiz, key=lambda x: x[0]):\n hidari = [gai[0]-1, gai[1]]\n while True:\n if hidari[1]==1: \n kaisu = gai[0]-1\n finish=True\n break\n for g in zen_gaiz:\n if hidari[1] in zen_gaiz[hidari[0]-1]:\n break\n else:\n hidari[0]-=1\n hidari[1]-=1\n continue\n break\n if finish:\n break\n print(kaisu) \n ', 'x,y,num = map(int, input().split())\ngaiz = []\nzen_gaiz = []\nkaisu = x\nfor _ in range(num):\n xg,yg = map(int,input().split())\n zen_gaiz.append((xg,yg))\n if xg > yg:\n gaiz.append((xg,yg))\n\nif len(gaiz) ==0:\n print(kaisu)\nelse:\n finish = False\n for gai in sorted(gaiz, key=lambda x: x[0]+x[1]):\n hidari = [gai[0]-1, gai[1]]\n while True:\n if hidari[1]==1: \n kaisu = gai[0]-1+ gai[1]\n finish=True\n break\n for g in gaiz:\n if g[0]==hidari[0] and g[1]==hidari[1]:\n break\n else:\n hidari[0]-=1\n hidari[1]-=1\n continue\n break\n if finish:\n break\n print(kaisu) \n ', 'x,y,num = map(int, input().split())\ngaiz = [x]*x\nkaisu = x\nfor _ in range(num):\n xg,yg = map(int,input().split())\n if xg >= yg:\n sa = xg-yg\n if yg < gaiz[sa]:\n gaiz[sa]=(yg)\n \nif len(gaiz) ==0:\n print(kaisu)\nelse:\n for num,(maegai,gai) in enumerate(zip(gaiz[:-1],gaiz[1:])):\n if maegai>gai and num+gai < kaisu:\n kaisu = num+gai\n print(kaisu) '] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s004578926', 's191185345', 's488842620', 's605259459'] | [12304.0, 32868.0, 51556.0, 10868.0] | [671.0, 2105.0, 2104.0, 644.0] | [411, 849, 793, 400] |
p03203 | u894258749 | 2,000 | 1,048,576 | Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j \leq W) by (i,j). There is no obstacle at (1,1), and there is a piece placed there at (1,1). Starting from Takahashi, he and Aoki alternately perform one of the following actions: * Move the piece to an adjacent cell. Here, let the position of the piece be (x,y). Then Takahashi can only move the piece to (x+1,y), and Aoki can only move the piece to (x,y+1). If the destination cell does not exist or it is occupied by an obstacle, this action cannot be taken. * Do not move the piece, and end his turn without affecting the grid. The game ends when the piece does not move twice in a row. Takahashi would like to perform as many actions (including not moving the piece) as possible before the game ends, while Aoki would like to perform as few actions as possible before the game ends. How many actions will Takahashi end up performing? | ['import numpy as np\n(H,W,N) = map(int,input().split())\nif N==0:\n print(W)\n exit()\nXY = np.array([ list(map(int,input().split())) for _ in range(N)], dtype=np.int)\nX = XY[:,0]\nY = XY[:,1]\ndiff = X - Y\nind = np.where(diff >= 0)[0]\nM = len(ind)\nif M==0:\n print(W)\n exit()\norder = X[ind].argsort()\nX = (X[ind])[order]\nY = (Y[ind])[order]\n\nymax = 1\nj=0\nx = 1\nwhile j < M:\n dx = X[j]-x\n i = j\n x = X[i]\n ymax += dx-1\n for j in range(i,M+1):\n if j < M and X[j]==x:\n continue\n else:\n break\n if np.any(Y[i:j]<=ymax):\n print(x-1)\n exit()\n if np.any(Y[i:j]==ymax+1):\n pass\n else:\n ymax += 1\nprint(W)', 'import numpy as np\n(H,W,N) = map(int,input().split())\nif N==0:\n print(W)\n exit()\nXY = np.array([ list(map(int,input().split())) for _ in range(N)], dtype=np.int)\nX = XY[:,0]\nY = XY[:,1]\ndiff = X - Y\nind = np.where(diff >= 0)[0]\nM = len(ind)\nif M==0:\n print(W)\n exit()\norder = X[ind].argsort()\nX = (X[ind])[order]\nY = (Y[ind])[order]\n\nymax = 1\nj = 0\nx = 1\nwhile j < M:\n i = j\n dx = X[i]-x\n x = X[i]\n ymax += dx-1\n while j < M:\n if X[j]==x:\n j += 1\n else:\n break\n\n if np.any(Y[i:j]<=ymax):\n print(x-1)\n exit()\n elif np.any(Y[i:j]==ymax+1):\n pass\n else:\n ymax += 1\nprint(W)', 'from collections import defaultdict\ndef inpl(): return list(map(int,input().split()))\n\nclass Counter:\n def __init__(self, start=0):\n self.index = start-1\n\n def __call__(self):\n self.index += 1\n return self.index\n\nui = defaultdict(Counter())\nxylist = []\n\nH, W, N = inpl()\nfor i in range(N):\n X, Y = inpl()\n n = ui[X]\n if n < len(xylist):\n xylist[n][1] = min(xylist[n][1],Y)\n else:\n xylist.append([X,Y])\n\nxylist.sort(key=lambda x: x[0])\nxylist.append([H+1,1])\n\nXprev = Yprev = 1\nfor X, Y in xylist:\n Ybound = Yprev + X - Xprev \n if Y < Ybound:\n ans = X - 1\n break\n elif Y == Ybound:\n Xprev, Yprev = X, Ybound - 1\n else:\n Xprev, Yprev = X, Ybound\n\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s224949440', 's771817905', 's903833366'] | [65868.0, 63888.0, 60084.0] | [2110.0, 2110.0, 1472.0] | [687, 670, 748] |
p03206 | u000623733 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['N, K = map(int, input().split())\nh_list = []\nfor _ in range(N):\n h_list.append(int(input()))\nh_list.sort()\n\nerr_list = [h_list[i+K-1] - h_list[i] for i in range(N-K+1)]\nprint(min(err_list))\n', "D = int(input())\n\nch = 'Christmas'\nfor _ in range(25 - D):\n ch += ' Eve'\nprint(ch)"] | ['Runtime Error', 'Accepted'] | ['s160954486', 's408848341'] | [2940.0, 2940.0] | [18.0, 18.0] | [193, 85] |
p03206 | u011212399 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['n = int(input())\na = [int(input()) for i in range(n)]\na = sorted(a)\nprint((max(a) // 2) + sum(a) -max(a))', "print('Christmas' + ' Eve'*(25-int(input())))"] | ['Runtime Error', 'Accepted'] | ['s310357844', 's656981889'] | [2940.0, 2940.0] | [18.0, 18.0] | [105, 45] |
p03206 | u013756322 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['N, K = map(int, input().split())\nh = [int(input()) for _ in range(N)]\nh = sorted(h)\nprint(min(h[i+K-1]-h[i] for i in range(N-K+1)))\n', 'p=[int(input()) for i in range(int(input()))]\nprint(sum(p)-max(p)//2)', 'n, x = map(int, input().split())\n\n\ndef pi(n):\n return 2**(n+1)-1\n\n\ndef ai(n):\n return 2**(n+2) - 3\n\n\ndef f(n, x):\n if (x <= 1) or (n <= 0):\n return 0\n elif (1 < x) and (x <= 1 + ai(n-1)):\n return f(n - 1, x - 1)\n elif x == 2 + ai(n - 1):\n return pi(n - 1) + 1\n elif (2 + ai(n - 1) < x) and (x <= 2 + 2 * ai(n - 1)):\n return pi(n-1) + 1 + f(n-1, x-2-ai(n-1))\n elif x >= ai(n):\n return pi(n)\n\n\nprint(f(n, x))\n', 'str = "Christmas"\nfor i in range(25-int(input())):\n str += " Eve"\nprint(str)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s106492871', 's128751053', 's872835665', 's755004836'] | [2940.0, 2940.0, 3188.0, 2940.0] | [18.0, 17.0, 19.0, 18.0] | [132, 69, 463, 79] |
p03206 | u014139588 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['d = input()\nif d == 25:\n print("Christmas")\nelif d == 24:\n print("Christmas eve")\nelif d == 23:\n print("Christmas eve eve")\nelse:\n print("Christmas eve eve eve")', 'd = int(input())\nif d = 25:\n print("Christmas")\nelif d = 24:\n print("Christmas Eve")\nelif d = 23:\n print("Christmas Eve Eve")\nelse:\n print("Christmas Eve Eve Eve")', 'd = int(input())\nif d == 25:\n print("Christmas")\nelif d == 24:\n print("Christmas Eve")\nelif d == 23:\n print("Christmas Eve Eve")\nelse:\n print("Christmas Eve Eve Eve")'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s467710754', 's849110734', 's695136440'] | [8808.0, 8796.0, 8956.0] | [27.0, 26.0, 28.0] | [165, 167, 170] |
p03206 | u018017456 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['N = int(input())\na = [int(input()) for i in range(N)]\n\ntotal = int(max(a)/2)\nprint(max(a))\nprint(total)\na.remove(max(a))\nprint(a)\ntotal += sum(a)', "D=input()\n \nif D=='25':\n print('Christmas')\nelif D=='24':\n print('Christmas Eve')\nelif D=='23':\n print('Christmas Eve Eve')\nelif D=='22':\n print('Christmas Eve Eve Eve')"] | ['Runtime Error', 'Accepted'] | ['s864140720', 's407984746'] | [3060.0, 2940.0] | [17.0, 17.0] | [145, 181] |
p03206 | u023229441 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['if input()=="22":\n print("Christmas Eve Eve Eve")\nif input()=="23":\n print("Christmas Eve Eve")\nif input()=="24":\n print("Christmas Eve")\nif input()=="25":\n print("Christmas")', 'd=input()\nif d=="22":\n\tprint("Christmas Eve Eve Eve")\nif d=="23":\n\tprint("Christmas Eve Eve")\nif d=="24":\n\tprint("Christmas Eve")\nif d=="25":\n\tprint("Christmas")'] | ['Runtime Error', 'Accepted'] | ['s905915804', 's646842680'] | [2940.0, 2940.0] | [17.0, 17.0] | [179, 161] |
p03206 | u027403702 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['D = int(input().split())\nprint("Christmas" + "Eve" * (25 - D)', 'D = int(input().split())\nprint("Christmas" + "Eve" * (25 - D))', 'D = int(input())\nprint("Christmas" + " Eve" * (25 - D))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s169138697', 's293568428', 's154258588'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [61, 62, 55] |
p03206 | u027557357 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ["D=input()\nif D=25 :\n print('Christmas')\nelif D=24 :\n print('Christmas Eve')\nelif D=23 :\n print('Christmas Eve Eve')\nelif D=22 :\n print('Christmas Eve Eve Eve')", "D=int(input())\nif D==25 :\n print('Christmas')\nelif D==24 :\n print('Christmas Eve')\nelif D==23 :\n print('Christmas Eve Eve')\nelif D==22 :\n print('Christmas Eve Eve Eve')"] | ['Runtime Error', 'Accepted'] | ['s309588180', 's508724024'] | [2940.0, 2940.0] | [17.0, 17.0] | [171, 180] |
p03206 | u027675217 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['d = int(input())\na,b = "Christmas","Eve"\nfor i in range(0,3):\n if d-i == 25:\n print("{}".format(a))\n elif d-i == 24:\n print("{} {}".format(a,b))\n elif d-i == 23:\n print("{} {} {}".format(a,b,b))\n elif d-i == 22:\n print("{} {} {} {}".format(a,b,b,b))\n', 'd = int(input())\na,b = "Christmas","Eve"\nfor i in range(0,3):\n if d-i == 25:\n print("{}".format(a))\n elif d-i == 24:\n print("{} {}".format(a,b))\n elif d-i == 23:\n print("{} {} {}".format(a,b,b))\n elif d-i == 22:\n print("{} {} {} {}".format(a,b,b,b))\n', 'd = int(input())\na,b = "Christmas","Eve"\n\nif d == 25:\n print("{}".format(a))\nelif d == 24:\n print("{} {}".format(a,b))\nelif d == 23:\n print("{} {} {}".format(a,b,b))\nelif d == 22:\n print("{} {} {} {}".format(a,b,b,b))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s060191839', 's967006124', 's326288173'] | [3064.0, 3060.0, 2940.0] | [17.0, 17.0, 17.0] | [290, 290, 230] |
p03206 | u029234056 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['N,K=map(int,input().split(" "))\nH=[int(input()) for _ in range(N)]\nH.sort()\ntmax=10**9\nfor a in range(N-K+1):\n h1,h2=H[a],H[a+K]\n tmax=min(tmax,abs(h1-h2))\n if(tmax==0):\n break\nprint(tmax)', 'D=int(input())\nif D==25:\n print("Christmas")\nelif D==24:\n print("Christmas Eve")\nelif D==23:\n print("Christmas Eve Eve")\nelif D==22:\n print("Christmas Eve Eve Eve")\n'] | ['Runtime Error', 'Accepted'] | ['s332380648', 's187071335'] | [3060.0, 2940.0] | [18.0, 18.0] | [204, 177] |
p03206 | u031157253 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['s="Christmas"\nfor i in range(25-int(input()):\n s += " Eve"\nprint(s)', 's="Christmas"\nfor i in range(25-int(input())):\n s += " Eve"\nprint(s)'] | ['Runtime Error', 'Accepted'] | ['s139736936', 's919523019'] | [2940.0, 3060.0] | [17.0, 18.0] | [68, 69] |
p03206 | u033524082 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['D = int(input())\n\nif D==25:\n print("Christmas")\n elif D==24:\n print("Christmas Eve")\n elif D==23:\n print("Christmas Eve Eve")\n else D==22:\n print("Christmas Eve Eve Eve")', 'D = int(input())\n\nif D ==25:\n print("Christmas")\nelif D ==24:\n print("Christmas Eve")\nelif D ==23:\n print("Christmas Eve Eve")\nelse D ==22:\n print("Christmas Eve Eve Eve")', 'D = int(input())\n\nif D == 25:\n print("Christmas")\nelif D == 24:\n print("Christmas Eve")\nelif D == 23:\n print("Christmas Eve Eve")\nelse:\n print("Christmas Eve Eve Eve")\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s381693427', 's999943030', 's552258171'] | [2940.0, 2940.0, 2940.0] | [18.0, 18.0, 17.0] | [195, 175, 172] |
p03206 | u036744414 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['# coding:utf-8\n\nN = int(input())\nan = [int(input()) for i in range(N)]\n\nan.sort()\nan.reverse()\n\nprint(an)\n\nsum = 0\nfor i, ai in enumerate(an):\n if i == 0:\n sum += ai/2\n else:\n sum += ai\n\nprint(int(sum))', '# coding:utf-8\n\nN, X = map(int, input().split())\n\ndef eatBan(c, w):\n return c, w+1\ndef eatPan(c, w):\n return c+1, w+1\ndef checkWalk(w, X):\n if w == X:\n return True\n else:\n return False\n\ndef createNBurger(w, c, n, X):\n if n == 0:\n c, w = eatPan(c, w)\n return c, w\n else:\n \n c, w = eatBan(c, w)\n if checkWalk(w, X):\n c, w, True\n \n c, w = createNBurger(w, c, n-1, X)\n if checkWalk(w, X):\n c, w, True\n \n c, w = eatPan(c, w)\n if checkWalk(w, X):\n c, w, True\n \n c, w = createNBurger(w, c, n-1, X)\n if checkWalk(w, X):\n return c, w, True\n \n c, w = eatBan(c, w)\n if checkWalk(w, X):\n c, w, True\n return c, w, False\n\n\nc = 0\nw = 0\nc, w , t= createNBurger(w, c, N, X)\n\n# eat_p = 0\n# for i, c in enumerate(burger):\n# if c == "P":\n# eat_p += 1\n\n# break\nprint(c)', '# coding:utf-8\n\nd = int(input())\n\nc_eve = 25 - d\n\nout = "Christmas"\n\nfor i in range(c_eve):\n out += " Eve"\n\nprint(out)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s816142792', 's861423325', 's867310914'] | [3064.0, 3064.0, 2940.0] | [17.0, 17.0, 17.0] | [222, 1114, 121] |
p03206 | u038216098 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['D=int(input())\nif D=25 :\n print("Christmas")\nelif D=24 :\n print("Christmas Eve")\nelif D=23 :\n print("Christmas Eve Eve")\nelse :\n print("Christmas Eve Eve Eve")', 'D=int(input())\nif D==25 :\n print("Christmas")\nelif D==24 :\n print("Christmas Eve")\nelif D==23 :\n print("Christmas Eve Eve")\nelse :\n print("Christmas Eve Eve Eve")'] | ['Runtime Error', 'Accepted'] | ['s823740816', 's191156776'] | [8856.0, 9104.0] | [19.0, 23.0] | [163, 166] |
p03206 | u045408189 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ["d=input()\nprint('Chiristmas' if d=='25' else 'Chiristmas Eve' if d=='24' else 'Chiristmas Eve Eve' if d=='23' else 'Chiristmas Eve Eve Eve')", "d=input()\nprint('Christmas' if d=='25' else 'Christmas Eve' if d=='24' else 'Christmas Eve Eve' if d=='23' else 'Christmas Eve Eve Eve')\n"] | ['Wrong Answer', 'Accepted'] | ['s196266031', 's790127233'] | [2940.0, 2940.0] | [17.0, 17.0] | [140, 137] |
p03206 | u047023156 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ["import sys\nintput = sys.stdin.readline()\n\nD = int(input())\nif D == 25:\n print('Christmas')\nelif D == 24:\n print('Christmas Eve')\nelif D == 23:\n print('Christmas Eve Eve')\nelif D == 22:\n print('Christmas Eve Eve Eve')", "import sys\ninput = sys.stdin.readline\n\nD = int(input())\nif D == 25:\n print('Christmas')\nelif D == 24:\n print('Christmas Eve')\nelif D == 23:\n print('Christmas Eve Eve')\nelif D == 22:\n print('Christmas Eve Eve Eve')"] | ['Runtime Error', 'Accepted'] | ['s623299687', 's118859964'] | [2940.0, 2940.0] | [17.0, 17.0] | [228, 225] |
p03206 | u054471580 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['import sys\nn=input()\nlist = n.split(" ")\nn=int(list[0])\nk=int(list[1])\n\ntrees = []\nfor i in range(n):\n trees.append(int(input()))\n\ndef merge_sort(alist):\n if len(alist) <= 1:\n return alist\n \n mid = int(len(alist)/2)\n left = alist[:mid]\n right = alist[mid:]\n \n left = merge_sort(left)\n right = merge_sort(right)\n \n return merge(left, right)\n\ndef merge(left,right):\n sorted_list = []\n left_index = 0\n right_index = 0\n \n while left_index < len(left) and right_index < len(right):\n if left[left_index] >= right[right_index]:\n sorted_list.append(left[left_index])\n left_index += 1\n else:\n sorted_list.append(right[right_index])\n right_index += 1\n \n if left:\n sorted_list.extend(left[left_index:])\n \n if right:\n sorted_list.extend(right[right_index:])\n \n return sorted_list\n\ntrees = merge_sort(trees)\n\nans=sys.maxsize\nflag=0\ntemp = []\n\nfor i in range(len(trees)-k+1):\n diff = trees[i]-trees[i+k-1]\n if(diff==0):\n ans=0\n break\n if(ans>diff):\n ans=diff\n temp.clear()\n\nprint(ans)', 'Date = int(input())\n\nif Date==25:\n print("Christmas")\nelif Date==24:\n print("Christmas Eve")\nelif Date==23:\n print("Christmas Eve Eve")\nelif Date==22:\n print("Christmas Eve Eve Eve")'] | ['Runtime Error', 'Accepted'] | ['s302709718', 's293898144'] | [3064.0, 2940.0] | [18.0, 18.0] | [1050, 186] |
p03206 | u057429331 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['N=input()\nif N==25:\n print("Christmas")\nelif N==24:\n print("Christmas Eve")\nelif N==23:\n print("Christmas Eve Eve")\nelif N==22:\n print("Christmas Eve Eve Eve")\n', 'N=int(input())\nif N==25:\n print("Christmas")\nelif N==24:\n print("Christmas Eve")\nelif N==23:\n print("Christmas Eve Eve")\nelif N==22:\n print("Christmas Eve Eve Eve")\n'] | ['Wrong Answer', 'Accepted'] | ['s791053521', 's872902715'] | [2940.0, 2940.0] | [17.0, 17.0] | [172, 177] |
p03206 | u058295774 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['#coding:utf-8\n\ndef count(a):\n\tif a == 25:\n\t\tprint "Christmas"\n\telif a == 24:\n\t\tprint "Christmas Eve"\n\telif a == 23:\n\t\tprint "Christmas Eve Eve"\n\telif a==22:\n\t\tprint "Christmas Eve Eve Eve"\n\nif __name__ == "__main__":\n print(\'ε
₯εγγ¦γγ γγ\')\n b = input(\'a = \')\n count(b) ', '#coding:utf-8\na = int(input(\'a = \'))\n\nif a == 25:\n\tprint "Christmas"\nif a == 24:\n\tprint "Christmas Eve"\nif a == 23:\n\tprint "Christmas Eve Eve"\nif a==22:\n\tprint "Christmas Eve Eve Eve"', '#coding:utf-8\n\ndef count(a):\n\tif a == 25:\n\t\tprint "Christmas"\n\tif a == 24:\n\t\tprint "Christmas Eve"\n\tif a == 23:\n\t\tprint "Christmas Eve Eve"\n\tif a==22:\n\t\tprint "Christmas Eve Eve Eve"\n\nif __name__ == "__main__":\n print(\'ε
₯εγγ¦γγ γγ\')\n b = input(\'a = \')\n count(b) ', '#coding:utf-8\n\ndef count(a):\n\tif \'a == 25\':\n\t\tprint "Christmas"\n\telif \'a == 24\':\n\t\tprint "Christmas Eve"\n\telif \'a == 23\':\n\t\tprint "Christmas Eve Eve"\n\telif \'a == 22\':\n\t\tprint "Christmas Eve Eve Eve"\n\nif __name__ == "__main__":\n print(\'ε
₯εγγ¦γγ γγ\')\n a = input(\'a = \')\n count(a)\n\n ', '#coding:utf-8\n\ndef count():\n\tif \'a == 25\':\n\t\tprint "Christmas"\n\telif \'a == 24\':\n\t\tprint "Christmas Eve"\n\telif \'a == 23\':\n\t\tprint "Christmas Eve Eve"\n\telif \'a == 22\':\n\t\tprint "Christmas Eve Eve Eve"\n\nif __name__ == "__main__":\n print(\'ε
₯εγγ¦γγ γγ\')\n a = input(\'a = \')\n count(a)\n\n ', "#coding:utf-8\na = int(input())\n\nif a == 25:\n\tprint('Christmas')\nif a == 24:\n\tprint('Christmas Eve')\nif a == 23:\n\tprint('Christmas Eve Eve')\nif a==22:\n\tprint('Christmas Eve Eve Eve')"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s049545866', 's072906819', 's118683335', 's220194344', 's271391889', 's978834888'] | [2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0] | [19.0, 18.0, 18.0, 18.0, 18.0, 19.0] | [295, 185, 288, 308, 307, 181] |
p03206 | u063346608 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['D = input()\n\nif D == "25"\n\tprint("Christmas")\nelif D == "24"\n\tprint("Christmas Eve")\nelif D == "23"\n\tprint("Christmas Eve Eve Eve")', 'D = input()\n \nif D == "25":\n\tprint("Christmas")\nelif D === "24":\n\tprint("Christmas Eve")\nelif D == "23":\n\tprint("Christmas Eve Eve")\nelif D == "22":\n\tprint("Christmas Eve Eve Eve")\n', 'D = input()\n\nif D == "25":\n\tprint("Christmas")\nelif D === "24":\n\tprint("Christmas Eve")\nelif D == "23":\n\tprint("Christmas Eve Eve")\nelif D == "22":\n\tprint("Christmas Eve Eve Eve")', 'D = int(input())\n \nif D == 25:\n\tprint("Christmas")\nelif D == 24:\n\tprint("Christmas Eve")\nelif D == 23:\n\tprint("Christmas Eve Eve")\nelif D == 22:\n\tprint("Christmas Eve Eve Eve")\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s534797513', 's752746301', 's791616303', 's518223216'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 17.0] | [131, 181, 179, 177] |
p03206 | u066455063 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['n = int(input())\np = list(map(int, input().split()))\np.sort(reverse=True)\na = p[1:]\nb = p[0] // 2\nprint(sum(a, b))', 'D = int(input())\nif D == 25:\n print("Christmas")\nelse:\n E = 25 - D\n print("Christmas" + " " + "Eve " * E)'] | ['Runtime Error', 'Accepted'] | ['s631015399', 's603752788'] | [2940.0, 2940.0] | [17.0, 19.0] | [114, 115] |
p03206 | u069035678 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['d=input()\nd=-(d-25)\nc="Chrismas"\ne="Eve"\nfor i in range(0,4):\n if d==i:\n print(c,end="")\n if i>0:\n for j in range(i-1):\n print(" "+e)\n print()\n ', 'd=int(input())\nd=-(d-25)\nc="Chrismas"\ne="Eve"\nfor i in range(0,4):\n if d==i:\n print(c,end="")\n if i>0:\n for j in range(i-1):\n print(" "+e)\n print()\n ', 'd=int(input())\nd=-(d-25)\nc="Chrismas"\ne="Eve"\nfor i in range(0,4):\n if d==i:\n print(c,end="")\n if i>0:\n for j in range(i):\n print(" "+e)\n print()\n \n ', 'd=int(input())\nd=-(d-25)\nc="Chrismas"\ne="Eve"\nfor i in range(0,4):\n if d==i:\n print(c,end="")\n if i>0:\n for j in range(i):\n print(" "+e,end="")\n print()\n ', 'd=int(input())\nd=-(d-25)\nc="Christmas"\ne="Eve"\nfor i in range(0,4):\n if d==i:\n print(c,end="")\n if i>0:\n for j in range(i):\n print(" "+e,end="")\n print()\n '] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s239063723', 's608277387', 's856821509', 's987976616', 's769507454'] | [2940.0, 2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 17.0, 17.0] | [201, 206, 213, 211, 212] |
p03206 | u071916806 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ["d=int(input())\nif d=25:\n print('Christmas')\nelif:\n print('Christmas Eve')\nelif:\n print('Christmas Eve Eve')\nelse:\n print('Christmas Eve Eve Eve')", "d=int(input())\nif d==25:\n print('Christmas')\nelif d==24:\n print('Christmas Eve')\nelif d==23:\n print('Christmas Eve Eve')\nelse:\n print('Christmas Eve Eve Eve')"] | ['Runtime Error', 'Accepted'] | ['s093310274', 's507756950'] | [2940.0, 2940.0] | [17.0, 17.0] | [149, 162] |
p03206 | u072606168 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ["d = int(input())\nif d = 25:\n print('Christmas')\nelif d = 24:\n print('Christmas Eve')\nelif d = 23:\n print('Christmas Eve Eve')\nelse:\n print('Christmas Eve Eve Eve')", "d = int(input())\nif d = 25:\n print('Christmas')\nelif d = 24:\n print('Christmas Eve')\nelif d = 23:\n print('Christmas Eve Eve')\nelse d = 22:\n print('Christmas Eve Eve Eve')", "D = int(input())\nif d = 25:\n print('Christmas')\nelif d = 24:\n print('Christmas Eve')\nelif d = 23:\n print('Christmas Eve Eve')\nelse d = 22:\n print('Christmas Eve Eve Eve')", "d = int(input())\nif d == 25:\n print('Christmas')\nelif d == 24:\n print('Christmas Eve')\nelif d == 23:\n print('Christmas Eve Eve')\nelse:\n print('Christmas Eve Eve Eve')"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s370197367', 's389808123', 's608261970', 's875423469'] | [2940.0, 2940.0, 2940.0, 2940.0] | [18.0, 18.0, 18.0, 18.0] | [167, 174, 174, 170] |
p03206 | u073139376 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['print(["Christmas Eve Eve Eve", "Christmas Eve Eve", "Christmas Eve", "Christmas"][int(input())+22]) ', 'print(["Christmas Eve Eve Eve", "Christmas Eve Eve", "Christmas Eve", "Christmas"][int(input())-22]) \n'] | ['Runtime Error', 'Accepted'] | ['s990947766', 's419873294'] | [2940.0, 2940.0] | [17.0, 17.0] | [101, 102] |
p03206 | u074445770 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['n=int(input())\nif n==25:\n print(Christmas)\nif n==24:\n print(Christmas Eve)\nif n==23:\n print(Christmas Eve Eve)\nif n==22:\n print(Christmas Eve Eve Eve)', 'print(Christmas Eve *(25-int(input())', 'n=int(input())\nif n=25:\n print(Christmas)\nif n=24:\n print(Christmas Eve)\nif n=23:\n print(Christmas Eve Eve)\nif n=22:\n print(Christmas Eve Eve Eve)', "n=int(input())\nif n==25:\n print('Christmas')\nif n==24:\n print('Christmas Eve')\nif n==23:\n print('Christmas Eve Eve')\nif n==22:\n print('Christmas Eve Eve Eve')"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s173093236', 's332956732', 's735908307', 's111849359'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 17.0] | [162, 37, 158, 170] |
p03206 | u076512055 | 2,000 | 1,048,576 | In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. | ['N, K = map(int, input().split())\nh = [0]*N\n\nfor n in range(N):\n h[n] = int(input())\n \nh.sort()\n\ntree = h[:K]\nheight = []\nheight.append(tree[-1]-tree[0])\n\nfor n in range(K,N):\n tree.pop(0)\n tree.append(h[n])\n height.append(tree[-1]-tree[0]) \n\nprint(min(height))', "D = int(input())\n\nif D == 25:\n print('Christmas')\n \nelif D == 24:\n print('Christmas Eve')\n \nelif D == 23:\n print('Christmas Eve Eve')\n \nelse:\n print('Christmas Eve Eve Eve')"] | ['Runtime Error', 'Accepted'] | ['s453160329', 's147866911'] | [3064.0, 2940.0] | [17.0, 17.0] | [276, 180] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.