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
|
---|---|---|---|---|---|---|---|---|---|---|
p03481 | u296150111 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['x,y=map(int,input().split())\nimport math\np=math.log(y/x,2)+10**(-18)\nprint(int(p)+1', 'x,y=map(int,input().split())\nans=1\nfor i in range(1000):\n\tif x*2>y:\n\t\tprint(ans)\n\t\texit()\n\telse:\n\t\tans+=1\n\t\tx*=2'] | ['Runtime Error', 'Accepted'] | ['s314166744', 's735637380'] | [2940.0, 2940.0] | [17.0, 17.0] | [83, 112] |
p03481 | u300352570 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['def getAns(x,y):\n num=int(y/x)\n res=1\n while num>1:\n num/=2\n res+=1\n return res\n\nx,y=map(int,input().split())\nprint getAns(x,y)', 'x,y=map(int,input().split())\nans=0\nwhile x<=y:\n x = x*2\n ans +=1\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s166332656', 's548548806'] | [2940.0, 2940.0] | [17.0, 18.0] | [153, 81] |
p03481 | u301302814 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['# coding: utf-8\n\n\ndef main():\n X, Y = map(int, input().split())\n ans = 0\n while (X <= Y){\n x *= 2\n ans += 1\n }\n print(ans)\n\nif __name__ == "__main__":\n main()\n', '# coding: utf-8\n\n\ndef main():\n X, Y = map(int, input().split())\n ans = 0\n while X <= Y:\n X *= 2\n ans += 1\n\n print(ans)\n\nif __name__ == "__main__":\n main()\n'] | ['Runtime Error', 'Accepted'] | ['s109114709', 's756980855'] | [8964.0, 9132.0] | [27.0, 25.0] | [191, 184] |
p03481 | u301624971 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ["def myAnswer(X:int,Y:int) -> int:\n if(X*2 > Y): return 1\n ans = X\n total = 1\n while True:\n print(ans)\n ans *= 2\n if(ans > Y):\n break\n else:\n total += 1\n return total\n\n\ndef modelAnswer():\n tmp=1\ndef main():\n X, Y = map(int,input().split())\n print(myAnswer(X,Y))\nif __name__ == '__main__':\n main()", "\ndef myAnswer(X:int,Y:int) -> int:\n if(X*2 > Y): return 1\n ans = X\n total = 1\n while True:\n ans *= 2\n if(ans > Y):\n break\n else:\n total += 1\n return total\n\n\ndef modelAnswer():\n tmp=1\ndef main():\n X, Y = map(int,input().split())\n print(myAnswer(X,Y))\nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s325132079', 's834693182'] | [3064.0, 3060.0] | [17.0, 17.0] | [349, 333] |
p03481 | u306412379 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['import math\nX, Y = map(int, input().split())\n\nans = int(math.log2(Y)) - int(math.log2(X))\nprint(ans+1)', '#import math\nX, Y = map(int, input().split())\ncnt = 0\n\n\n#print(ans+1)\nwhile X <= Y:\n X *= 2\n cnt += 1\nprint(cnt)'] | ['Wrong Answer', 'Accepted'] | ['s877640127', 's444312874'] | [9168.0, 9064.0] | [28.0, 27.0] | [102, 153] |
p03481 | u341087021 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['x,y = [int(x) for x in input().split()]\n\ncount = 1\n\nwhile True:\n if x * 2 <= y:\n x = x * 2\n count += 1\n else:\n\tbreak\n\nprint(count)', 'x,y = [int(x) for x in input().split()]\n\ncount = 1\n\nwhile True:\n if x * 2 <= y:\n x = x * 2\n count += 1\n else:\n break\n\nprint(count)'] | ['Runtime Error', 'Accepted'] | ['s320276029', 's246924215'] | [3064.0, 2940.0] | [22.0, 17.0] | [150, 157] |
p03481 | u343523393 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['314159265 358979323846264338', 'x,y=list(map(int,input().split()))\nc=0\nwhile(True):\n if(x<=y):\n x=x*2\n c+=1\n else:\n break\n\nprint(c)'] | ['Runtime Error', 'Accepted'] | ['s944149436', 's726495829'] | [2940.0, 2940.0] | [17.0, 17.0] | [28, 126] |
p03481 | u348293370 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['import math\nx, y = map(int, input().split())\nans = 0\n\n\n\nwhile y > x:\n x = x * 2\n ans += 1\n\nprint(ans + 1)', 'import math\nx, y = map(int, input().split())\nans = 0\n\n\n\nwhile y >= x:\n x = x * 2\n ans += 1\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s873739197', 's705138746'] | [9160.0, 9164.0] | [27.0, 28.0] | [137, 134] |
p03481 | u357751375 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['x,y = map(int,input().split())\nz = x\nj = 1\n\nwhile z < y:\n z += x ** j\n j += 1\n\nif z == y:\n print(j+1)\nelse:\n print(j)', 'x,y = map(int,input().split())\ni = 1\nwhile x *(2 ** i) <= y:\n i += 1\n\nprint(i)'] | ['Wrong Answer', 'Accepted'] | ['s313249954', 's444397550'] | [9116.0, 8992.0] | [2206.0, 28.0] | [129, 81] |
p03481 | u373047809 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['x, y = map(int, input().split())\nprint(len(str(bin(y//x))[2:]+1)', 'x, y = map(int, input().split())\nprint(len(bin(y//x)[2:]))'] | ['Runtime Error', 'Accepted'] | ['s761673283', 's138931997'] | [2940.0, 2940.0] | [17.0, 18.0] | [64, 58] |
p03481 | u391819434 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['X,Y=map(int,input().split())\nimport math\nprint(round(math.log2(Y/X))+1)', 'X,Y=map(int,input().split())\ni=0\nwhile 2**i*X<=Y:\n i+=1\nprint(i)'] | ['Wrong Answer', 'Accepted'] | ['s694186288', 's057587896'] | [3060.0, 2940.0] | [17.0, 17.0] | [71, 67] |
p03481 | u442877951 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['X,Y = map(int,input().split())\ny_end = Y - Y%X\ncount = 0\n\nwhile X <= y_end:\n print(X)\n count += 1\n X *= 2\nprint(count)', 'X,Y = map(int,input().split())\ny_end = Y - Y%X\ncount = 0\n\nwhile X <= y_end:\n count += 1\n X *= 2\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s319185666', 's734757913'] | [2940.0, 2940.0] | [17.0, 17.0] | [121, 110] |
p03481 | u455533363 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['a, b = map(int,input().split())\n\nif b < 2*a:\n print(1)\nelse:\n print((b-a)//a+1)', 'a, b = map(int,input().split())\ncount = 1\n# if b < 2*a:\n# print(1)\n# else:\nwhile True:\n if 2*a<=b:\n count+=1\n a *= 2\n else:\n break\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s919182464', 's751458700'] | [2940.0, 2940.0] | [17.0, 17.0] | [81, 156] |
p03481 | u459737327 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['X, Y = map(int, input().split())\ncnt = 0\nwhile X <= Y\n cnt += 1\n X *= 2\nprint(cnt)', 'X, Y = map(int, input().split())\ncnt = 0\nwhile X <= Y:\n cnt += 1\n X *= 2\nprint(cnt)'] | ['Runtime Error', 'Accepted'] | ['s335048003', 's682036011'] | [2940.0, 2940.0] | [17.0, 17.0] | [84, 85] |
p03481 | u463655976 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['X, Y = map(int, input().split())\n\ncnt = 0\nwhile X <= Y:\n cnt += 1\n X *= X\nprint(cnt)\n', 'X, Y = map(int, input().split())\n\ncnt = 0\nwhile X <= Y:\n cnt += 1\n X *= 2\nprint(cnt)\n'] | ['Wrong Answer', 'Accepted'] | ['s805721594', 's337591142'] | [2940.0, 2940.0] | [2104.0, 18.0] | [87, 87] |
p03481 | u487594898 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['a,b= map(int,input().split())\nc = b//a\nans = 0\nfor i in range(10000):\n if 2**i <= c < 2**(i+1) :\n ans += i\nprint(a,b,c,ans +1)', 'a,b= map(int,input().split())\nc = b//a\nans = 0\nfor i in range(10000):\n if 2**i <= c < 2**(i+1) :\n ans += i\nprint(ans +1)'] | ['Wrong Answer', 'Accepted'] | ['s373463542', 's145924805'] | [3060.0, 2940.0] | [116.0, 109.0] | [136, 130] |
p03481 | u489143264 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ["'''input\n100000000\n'''\n\ndef list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \ns = input()\nn = len(s)\ncnt = 0\nfor i in s:\n\tif i == '0': cnt += 1\nprint(cnt)\t", "'''input\n010\n'''\n\ndef list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \ns = input()\nn = len(s)\ncnt = 0\nfor i in s:\n\tif i == '0': cnt += 1\nprint(cnt)\t", "'''input\n010\n'''\n\ndef list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \ns = input()\nn = len(s)\nl = (n-1)//2\nr = n//2\nans = n//2\ncur = s[l]\nwhile l >= 0:\n\tif s[l] == s[r] and s[l] == cur:\n\t\tans += 1\n\t\tl -= 1\n\t\tr += 1\n\telse: break\nprint(ans)\t\t ", "'''input\n3 20\n'''\n\ndef list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \nx,y = map_input()\nans = 0\nwhile x <= y:\n\tx *= 2\n\tans += 1\nprint(ans)\t"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s051036011', 's335551593', 's353168434', 's818987056'] | [3060.0, 3060.0, 3064.0, 3316.0] | [18.0, 17.0, 18.0, 20.0] | [264, 258, 354, 251] |
p03481 | u518042385 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['x,y=map(int,input().split())\nc=0\nwhile x<y:\n c+=1\n x*2\nprint(c)', 'x,y=map(int,input().split())\nc=0\nwhile x<=y:\n c+=1\n x=x*2\nprint(c)'] | ['Wrong Answer', 'Accepted'] | ['s874977912', 's320483426'] | [2940.0, 2940.0] | [2104.0, 17.0] | [65, 68] |
p03481 | u623687794 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['x,y=map(int,input().split())\nans=0\nwhile x<=y:\n x*=2\n if x>y:\n break\n ans+=1\nprint(ans)\n', 'x,y=map(int,input().split())\nans=0\nwhile x<=y:\n if 2*x>y:\n break\n ans+=1\nprint(ans)', 'x,y=map(int,input().split())\nans=1\nwhile x<=y:\n x*=2\n if x>y:\n break\n ans+=1\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s281663844', 's452361421', 's367490916'] | [2940.0, 2940.0, 2940.0] | [17.0, 2104.0, 17.0] | [94, 88, 94] |
p03481 | u693953100 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['def solve():\n a,y = map(int,input().split())\n ans = 1\n while(a<=y):\n a*=2\n ans+=1\n print(ans)\nif __name__ == "__main__":\n solve()', 'def solve():\n a,y = map(int,input().split())\n ans = 1\n while(a<=y){\n a*=2\n ans+=1\n }\n print(ans)\nif __name__ == "__main__":\n solve()', "def solve():\n x,y = map(int,input().split())\n cnt = 0\n while x<=y:\n x*=2\n cnt+=1\n print(cnt)\nif __name__=='__main__':\n solve()"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s019995539', 's687641619', 's892143380'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [158, 164, 155] |
p03481 | u711238850 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['x,y = tuple(map(int,input().split()))\n\nfor i in range(1,10*4):\n x<<=1\n if x>y:\n print(i)', 'x,y = tuple(map(int,input().split()))\n\nfor i in range(1,10*4):\n x<<=1\n if x>y:\n print(i)\n\tbreak', 'x,y = tuple(map(int,input().split()))\n\nfor i in range(1,10**18):\n x<<=1\n if x>y:\n print(i)\n break\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s119873329', 's592342034', 's186492719'] | [3064.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [93, 100, 106] |
p03481 | u822044226 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ["X,Y = map(int,input().split())\n\nif X == Y:\n print('1')\n \nelse:\n for i in range(Y//X+1):\n print(X*2**i)\n if X*(2**i) > Y:\n print(i)\n exit()", "X,Y = map(int,input().split())\n\nif X == Y:\n print('1')\n \nelse:\n for i in range(Y//X+1):\n if X*(2**i) > Y:\n print(i)\n exit()"] | ['Wrong Answer', 'Accepted'] | ['s945722909', 's060922245'] | [2940.0, 2940.0] | [17.0, 17.0] | [157, 139] |
p03481 | u858670323 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ["import math\nx,y = map(int,input().rstrip().split(' '))\nn = int(math.log2(y/x))\nprint(n)", "import math\nx,y = map(int,input().rstrip().split(' '))\nn = int(math.log2(y//x))\nprint(n)\n", "import math\nx,y = map(int, input().rstrip().split(' '))\n# n = int(math.log2(y/x))\n# print(n+1)\n\nfor i in range(100):\n a = x*(2**i)\n if(a<=y):\n continue\n else:\n print(i)\n break\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s213972843', 's266025596', 's900575801'] | [2940.0, 2940.0, 2940.0] | [18.0, 17.0, 17.0] | [87, 89, 188] |
p03481 | u863370423 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['X,Y = map(int,input())\nans = 0\nwhile X <= Y:\n\tans += 1\n\tX * = 2\nprint(ans)', 'X, Y = map(int, input().split())\nscore = 1\nA = X\nwhile 1:\n A *= 2\n if(A <= Y):\n score += 1\n else:\n print(score)\n break'] | ['Runtime Error', 'Accepted'] | ['s666532351', 's883439622'] | [2940.0, 2940.0] | [19.0, 18.0] | [74, 148] |
p03481 | u867069435 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['from math import frexp\na, b = map(int, input().split())\nprint(frexp(b)-frexp(a)+1)', 'from math import frexp\na, b = map(int, input().split())\nprint(frexp(b)[1]-frexp(a)[1]+1)', ' from math import frexp\n a, b = map(int, input().split())\n print(frexp(b)[1]-frexp(a)[1]+1)', 'x, y = list(map(int, input().split()))\na = x\nans = 0\nwhile a <= y:\n a = a << 1\n ans += 1\nprint(ans)\n'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s425797263', 's543424383', 's555177337', 's808385048'] | [2940.0, 2940.0, 2940.0, 2940.0] | [18.0, 18.0, 17.0, 17.0] | [82, 88, 94, 106] |
p03481 | u964521959 | 2,000 | 262,144 | As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence. | ['X,Y = map(int, input().split())\n\nans = X\ncount = 0\nwhile(ans < Y):\n if(ans*2>Y):\n exit()\n else:\n ans = ans * 2\n count += 1\n \nprint(ans)\n ', 'X,Y = map(int, input().split())\n\nans = X\ncount = 0\n\nwhile(ans < Y):\n if(ans*2>Y):\n break\n else:\n ans = ans * 2\n count = count + 1\n \nprint(count + 1)'] | ['Wrong Answer', 'Accepted'] | ['s934808246', 's058676552'] | [2940.0, 2940.0] | [17.0, 17.0] | [154, 162] |
p03482 | u218843509 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ['S = list(map(int, list(input())))\n\nzero = 1000000\none = 1000000\ncurrent_zero = 0\ncurrent_one = 0\n\nfor i in range(len(S)- 1):\n\tif S[i] == 0:\n\t\tcurrent_zero += 1\n\telse:\n\t\tcurrent_one += 1\n\tif S[i] != S[i+1]:\n\t\tif S[i] == 0 and current_zero < zero:\n\t\t\tzero = current_zero\n\t\telif S[i] == 1 and current_one < one:\n\t\t\tone = current_one\n\t\tcurrent_zero = 0\n\t\tcurrent_one = 0\n\telif i == len(S) - 2:\n\t\tif S[i] == 0:\n\t\t\tcurrent_zero += 1\n\t\t\tif current_zero < zero:\n\t\t\t\tzero = current_zero\n\t\telse:\n\t\t\tcurrent_one += 1\n\t\t\tif current_one < one:\n\t\t\t\tone = current_one\nprint(zero, one)\nprint(max(2, max(zero, one)))', 'S = list(map(int, list(input())))\nn = len(S)\n\nif len(set(S)) == 1:\n\tprint(len(S))\nelse:\n\tans = 1000000\n\tfor i in range(n-1):\n\t\tif S[i] != S[i+1]:\n\t\t\tm = max(n - i - 1, i + 1)\n\t\t\tif m < ans:\n\t\t\t\tans = m\n\n\tprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s760922858', 's326809592'] | [4776.0, 4652.0] | [83.0, 69.0] | [599, 214] |
p03482 | u341087021 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ['s = input()\n\nl = len(s)\ncount = 0\nfor i,x in enumerate(s):\n if i == 0:\n pass\n else:\n if x != s[i-1]:\n count += 1\n else:\n if count % 2 == 0:\n a = count + 1\n if a < l:\n l = a\n else:\n a = count\n if a < l:\n l = a\n count = 0\n\nprint((count+1)//2)', 's = input()\n\nl = len(s)\n\nfor i,x in enumerate(s):\n if i == 0:\n pass\n else:\n if x != s[i-1]:\n count += 1\n else:\n if count % 2 == 0:\n a = count -1\n if a <= l:\n l = a\n else:\n a = count\n if a <= l:\n l = a\n count = 0\n\nprint((count+1)//2)', 's = input()\n\nl = len(s)\ncount = 0\nfor i,x in enumerate(s):\n if i == 0:\n pass\n else:\n if x != s[i-1]:\n count += 1\n else:\n if count % 2 == 0:\n a = count -1\n if a <= l:\n l = a\n else:\n a = count\n if a <= l:\n l = a\n count = 0\n\nprint((count+1)//2)', 's = input()\n\nl = len(s)\n\nt = l\n\nfor i,x in enumerate(s):\n if i == 0:\n pass\n else:\n if x != s[i-1]:\n a = max(i,l-i)\n t = min(t,a)\n\nprint(t)'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s445808707', 's699462839', 's736064678', 's028577421'] | [3188.0, 3188.0, 3188.0, 3188.0] | [59.0, 18.0, 65.0, 71.0] | [409, 401, 410, 180] |
p03482 | u489143264 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ["'''input\n010\n'''\n\ndef list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \ns = input()\nn = len(s)\ncnt = 0\nfor i in s:\n\tif i == '0': cnt += 1\nprint(max(cnt,n-cnt)-1)\t", "'''input\n010\n'''\n\ndef list_input():\n return list(map(int,input().split()))\ndef map_input():\n return map(int,input().split())\ndef map_string():\n return input().split()\n \ns = input()\nn = len(s)\nl = (n-1)//2\nr = n//2\nans = n//2\ncur = s[l]\nwhile l >= 0:\n\tif s[l] == s[r] and s[l] == cur:\n\t\tans += 1\n\t\tl -= 1\n\t\tr += 1\n\telse: break\nprint(ans)\t\t "] | ['Wrong Answer', 'Accepted'] | ['s471404350', 's183101530'] | [3188.0, 3188.0] | [31.0, 41.0] | [271, 354] |
p03482 | u493520238 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ['s = list(input())\nn = len(s)\nans = 10**5\nfor i in range(n-1):\n if s[i] != s[i+1]:\n v = max(i,n-i-1)\n ans = min(ans,v)\nprint(ans)', 's = list(input())\nn = len(s)\nans = n\nfor i in range(n-1):\n if s[i] != s[i+1]:\n v = max(i+1,n-i-1)\n ans = min(ans,v)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s954145045', 's571587986'] | [9752.0, 9768.0] | [66.0, 67.0] | [145, 143] |
p03482 | u600402037 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ['import sys\n#import numpy as np\n\nstdin = sys.stdin\n\nri = lambda: int(rs())\nrl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only\nrs = lambda: stdin.readline().rstrip() \n\nS = list(input())\nN = len(S)\nanswer = (N+1)//2\nstreak = 1\ncur = None\nresult = 0\nfor x in S:\n if cur == x:\n streak += 1\n else:\n cur = x\n streak = 1\n if streak > result:\n result = streak\n\nwhile answer < N:\n S2 = S[-answer-1:answer+1]\n print(S2)\n if len(set(S2)) == 1:\n answer += 1\n continue\n else:\n break\n\nprint(answer)\n', 'import sys\n#import numpy as np\n\nstdin = sys.stdin\n\nri = lambda: int(rs())\nrl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only\nrs = lambda: stdin.readline().rstrip() \n\nS = list(input())\nN = len(S)\nanswer = (N+1)//2\n\nif len(set(S)) == 1:\n print(N)\n exit()\nright = N\nleft = answer\n\nwhile right > left + 1:\n mid = (right + left) // 2\n S2 = S[-mid:mid]\n if len(set(S2)) == 1:\n left = mid\n else:\n right = mid\n\nprint(left)\n'] | ['Wrong Answer', 'Accepted'] | ['s802659279', 's521949091'] | [135116.0, 5684.0] | [2104.0, 46.0] | [609, 502] |
p03482 | u667084803 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ['import sys\ns = list(str(input().rstrip()))\ns = list(map(int,s))\n\nchange = 0\nfor i in range(len(s)-1):\n if s[i]!=s[i+1]: change+=1\nif change==0:\n print(len(s))\n sys.exit()\nelif change ==1:\n ones = s.count(1)\n zeros = s.count(0)\n print(max(ones,zeros))\n sys.exit()\n \n0/0', 'import sys\ns = list(str(input().rstrip()))\ns = list(map(int,s))\n\nchange = 0\nfor i in range(len(s)-1):\n if s[i]!=s[i+1]: change+=1\nif change==0:\n print(len(s))\n sys.exit()\nelif change ==1:\n ones = s.count(1)\n zeros = s.count(0)\n print(max(ones,zeros))\n sys.exit()\n ', 's = input()\n\ncflag=[]\nfor i in range(len(s)-1):\n if s[i]!=s[i+1]:\n cflag+=[i+1]\n \nans = len(s)\nfor flag in cflag:\n ans = min(ans,max(flag,len(s)-flag) )\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s836221870', 's992500787', 's783363505'] | [4776.0, 4776.0, 5204.0] | [52.0, 52.0, 77.0] | [276, 271, 169] |
p03482 | u722641375 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ["def main():\n s = map(int,input().split())\n\n ans = len(s)\n for i in range(0,len(s)-1):\n if s[i] != s[i+1]:\n ans = min(ans , max(i+1 , len(s)-i-1))\n print(ans)\n\nif __name__ == '__main__':\n main()", "def main():\n s = input()\n\n ans = len(s)\n for i in range(0,len(s)-1):\n if s[i] != s[i+1]:\n ans = min(ans , max(i+1 , len(s)-i-1))\n print(ans)\n\nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Accepted'] | ['s905647509', 's326847265'] | [3188.0, 3244.0] | [19.0, 56.0] | [226, 209] |
p03482 | u794543767 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ['import numpy as np \nfis = s[0]\nn = len(s)\nk = float(\'inf\')\ntemp = s[0]\nfor i in range(n):\n if temp!=s[i]:\n temp = s[i]\n k = np.min((k, np.max( (i, n-i) ) ))\nprint("{}".format(int(k)))', 'import numpy as np \ns = input()\nfis = s[0]\nn = len(s)\nk = n\ntemp = s[0]\nfor i in range(n):\n if temp!=s[i]:\n temp = s[i]\n k = np.min((k, np.max( (i, n-i) ) ))\nprint("{}".format(int(k)))'] | ['Runtime Error', 'Accepted'] | ['s137471134', 's238163204'] | [21528.0, 15380.0] | [317.0, 1296.0] | [200, 201] |
p03482 | u814986259 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ['def main():\n S=list(map(int,list(input())))\n N=len(S)\n prev=S[0]\n tmp=1\n count=1\n for i in range(1,N):\n if prev == S[i]:\n tmp+=1\n count=max(count,tmp)\n else:\n tmp=1\n prev=S[i]\n print(count)\nmain() ', 'def main():\n import collections\n S = list(map(int, list(input())))\n N = len(S)\n ans = N\n for i in range(N-1):\n if S[i] != S[i+1]:\n ans = min(ans, max(i+1, N-i-1))\n print(ans)\n\n\nmain()\n'] | ['Wrong Answer', 'Accepted'] | ['s829599898', 's171533766'] | [4652.0, 5028.0] | [61.0, 66.0] | [234, 220] |
p03482 | u817026203 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ["s = input().strip()\nn = len(s)\n \nans = n\nfor i, c in enumerate(s):\n ld, rd = i, n - i - 1\n if c == '1':\n \tans = min(ans, max(ld, rd))\nprint(ans)", "s = input().strip()\nn = len(s)\n\nans = 0\nfor i, c in enumerate(s):\n ld, rd = i, n - i - 1\n if c == '1':\n \tans = min(ans, max(lr, rd))\nprint(ans)", "s = input().strip()\nn = len(s)\n\nansone, anszero = n, n\nfor i, c in enumerate(s):\n ld, rd = i, n - i - 1\n if c == '1':\n ansone = min(ansone, max(ld, rd))\n else:\n anszero = min(anszero, max(ld, rd))\nprint(max(ansone, anszero))\n"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s178339394', 's649200214', 's280749232'] | [3316.0, 3188.0, 3188.0] | [86.0, 41.0, 89.0] | [147, 146, 248] |
p03482 | u830054172 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ['S = input()\n\nn = len(S)\nans = n\nans2 = n\n\nfor i in range(n):\n if S[i] == "1":\n ans = min(ans, max(n-i-1, i))\n else:\n ans2 = min(ans, max(n-i-1, i))\n\n\nprint(max(ans, ans2))', '\nS = input()\n\nn = len(S)\nans = n\n\nfor i in range(n-1):\n if S[i] != S[i+1]:\n ans = min(ans, max(n-i-1, i+1))\n\nS = S[::-1]\nfor i in range(n-1):\n if S[i] != S[i+1]:\n ans = min(ans, max(n-i-1, i+1))\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s619863190', 's575595393'] | [9152.0, 9112.0] | [75.0, 93.0] | [191, 226] |
p03482 | u843135954 | 2,000 | 262,144 | You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times. * Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is `0`, replace it with `1`; if S_i is `1`, replace it with `0`. | ['import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**9)\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\ns = ns()\nn = len(s)\nans = n\n\nfor i in range(n-1):\n if s[i] != s[i+1]:\n k = max(n-i+1,i+1)\n ans = min(ans,k)\n\nprint(ans)', 'import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**9)\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\ns = ns()\nn = len(s)\nans = n\n\nfor i in range(n-1):\n if s[i] != s[i+1]:\n k = max(n-i-1,i+1)\n ans = min(ans,k)\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s705624429', 's572112579'] | [3188.0, 3188.0] | [70.0, 71.0] | [356, 356] |
p03483 | u353797797 | 2,000 | 262,144 | You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. | ['import sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep="\\n")\n\nclass BitSum:\n def __init__(self, n):\n self.n = n + 3\n self.table = [0] * (self.n + 1)\n\n def update(self, i, x):\n i += 1\n while i <= self.n:\n self.table[i] += x\n i += i & -i\n\n def sum(self, i):\n i += 1\n res = 0\n while i > 0:\n res += self.table[i]\n i -= i & -i\n return res\n\ndef InversionNumber(lst):\n bit = BitSum(max(lst))\n res = 0\n for i, a in enumerate(lst):\n res += i - bit.sum(a)\n bit.update(a, 1)\n return res\n\ndef main():\n s = input()\n n = len(s)\n ord_a = ord("a")\n cnts = [0] * 26\n s_code = []\n flag_odd = False\n for c in s:\n code = ord(c) - ord_a\n s_code.append(code)\n cnts[code] += 1\n odd_code = -1\n for code, cnt in enumerate(cnts):\n if cnt % 2 == 1:\n if flag_odd:\n print(-1)\n exit()\n else:\n odd_code = code\n flag_odd = True\n cnts[code] = cnt // 2\n tois = [[] for _ in range(26)]\n to_sort_idx = []\n new_idx = 1\n for code in s_code:\n if cnts[code] > 0:\n to_sort_idx.append(new_idx)\n tois[code].append(n + 1 - new_idx)\n cnts[code] -= 1\n new_idx += 1\n else:\n if flag_odd and code == odd_code:\n to_sort_idx.append(n // 2 + 1)\n flag_odd=False\n else:\n to_sort_idx.append(tois[code].pop())\n print(to_sort_idx)\n print(InversionNumber(to_sort_idx))\n\nmain()\n', 'import sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep="\\n")\n\nclass BitSum:\n def __init__(self, n):\n self.n = n + 3\n self.table = [0] * (self.n + 1)\n\n def update(self, i, x):\n i += 1\n while i <= self.n:\n self.table[i] += x\n i += i & -i\n\n def sum(self, i):\n i += 1\n res = 0\n while i > 0:\n res += self.table[i]\n i -= i & -i\n return res\n\ndef InversionNumber(lst):\n bit = BitSum(max(lst))\n res = 0\n for i, a in enumerate(lst):\n res += i - bit.sum(a)\n bit.update(a, 1)\n return res\n\ndef main():\n s = input()\n n = len(s)\n ord_a = ord("a")\n cnts = [0] * 26\n s_code = []\n flag_odd = False\n for c in s:\n code = ord(c) - ord_a\n s_code.append(code)\n cnts[code] += 1\n odd_code = -1\n for code, cnt in enumerate(cnts):\n if cnt % 2 == 1:\n if flag_odd:\n print(-1)\n exit()\n else:\n odd_code = code\n flag_odd = True\n cnts[code] = cnt // 2\n tois = [[] for _ in range(26)]\n to_sort_idx = []\n new_idx = 1\n for code in s_code:\n if cnts[code] > 0:\n to_sort_idx.append(new_idx)\n tois[code].append(n + 1 - new_idx)\n cnts[code] -= 1\n new_idx += 1\n else:\n if flag_odd and code == odd_code:\n to_sort_idx.append(n // 2 + 1)\n flag_odd = False\n else:\n to_sort_idx.append(tois[code].pop())\n # print(to_sort_idx)\n print(InversionNumber(to_sort_idx))\n\nmain()\n'] | ['Wrong Answer', 'Accepted'] | ['s821893891', 's412091378'] | [18432.0, 15464.0] | [1116.0, 1105.0] | [1687, 1691] |
p03483 | u467736898 | 2,000 | 262,144 | You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. | ['class Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0]*(n+1)\n\n def __iter__(self):\n psum = 0\n for i in range(self.size):\n csum = self.sum(i+1)\n yield csum - psum\n psum = csum\n raise StopIteration()\n\n def __str__(self): # O(nlogn)\n return str(list(self))\n\n def sum(self, i):\n \n if not (0 <= i <= self.size): raise ValueError("error!")\n s = 0\n while i>0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n if not (0 <= i < self.size): raise ValueError("error!")\n i += 1\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\n def __getitem__(self, key):\n if not (0 <= key < self.size): raise IndexError("error!")\n return self.sum(key+1) - self.sum(key)\n\n def __setitem__(self, key, value):\n \n if not (0 <= key < self.size): raise IndexError("error!")\n self.add(key, value - self[key])\n\n\n\nS = input()\nN = len(S)\ncnt = [0]*26\nfor c in S:\n cnt[ord(c)-97] += 1\nodd = -1\nfor i, cn in enumerate(cnt):\n if cn%2 != 0:\n if odd == -1:\n odd = i\n else:\n print(-1)\n exit()\n cnt[i] //= 2\n#cnt2 = [0]*26\nL = [[] for _ in range(26)]\nn = N//2 + 1\nB = []\nfor c in S:\n c_int = ord(c)-97\n if cnt[c_int] == 0:\n if c_int == odd:\n B.append(1)\n odd = -1\n else:\n p = L[c_int].pop()\n B.append(p)\n else:\n L[c_int].append(n)\n B.append(0)\n n-=1\n cnt[c_int] -= 1\nprint(B)\n\nbit = Bit(N//2+2)\nans = 0\nfor i, b in enumerate(B):\n ans += i - bit.sum(b+1)\n bit.add(b, 1)\nprint(ans)\n', 'class Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0]*(n+1)\n\n def __iter__(self):\n psum = 0\n for i in range(self.size):\n csum = self.sum(i+1)\n yield csum - psum\n psum = csum\n raise StopIteration()\n\n def __str__(self): # O(nlogn)\n return str(list(self))\n\n def sum(self, i):\n \n if not (0 <= i <= self.size): raise ValueError("error!")\n s = 0\n while i>0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n if not (0 <= i < self.size): raise ValueError("error!")\n i += 1\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\n def __getitem__(self, key):\n if not (0 <= key < self.size): raise IndexError("error!")\n return self.sum(key+1) - self.sum(key)\n\n def __setitem__(self, key, value):\n \n if not (0 <= key < self.size): raise IndexError("error!")\n self.add(key, value - self[key])\n\n\n\nS = input()\nN = len(S)\ncnt = [0]*26\nfor c in S:\n cnt[ord(c)-97] += 1\nodd = -1\nfor i, cn in enumerate(cnt):\n if cn%2 != 0:\n if odd == -1:\n odd = i\n else:\n print(-1)\n exit()\n cnt[i] //= 2\n#cnt2 = [0]*26\nL = [[] for _ in range(26)]\nn = N//2 + 1\nB = []\nfor c in S:\n c_int = ord(c)-97\n if cnt[c_int] == 0:\n if c_int == odd:\n B.append(1)\n odd = -1\n else:\n p = L[c_int].pop()\n B.append(p)\n else:\n L[c_int].append(n)\n B.append(0)\n n-=1\n cnt[c_int] -= 1\n\nbit = Bit(N//2+2)\nans = 0\nfor i, b in enumerate(B):\n ans += i - bit.sum(b+1)\n bit.add(b, 1)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s701840368', 's637227088'] | [12004.0, 9840.0] | [1227.0, 1233.0] | [1844, 1835] |
p03483 | u785578220 | 2,000 | 262,144 | You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. | ['from collections import defaultdict\n\na = list(map(ord, input()))\nN = len(a)\nLa = ord("a")\n\ndata = [0]*(N+1)\n\n\nd = defaultdict(list)\nfor i , c in enumerate(a):\n d[c-La].append(i)\nprint(d)\nodd = 0\nfor v in d:\n if len(d[v]) % 2:\n odd += 1\nif not odd <= N%2:\n print(-1)\n exit(0)\n\ndata = [0]*(N+1)\ndef add(k, x):\n while k <= N:\n data[k] += x\n k += k & -k\ndef get(k):\n s = 0\n while k:\n s += data[k]\n k -= k & -k\n return s\n\nM = [None]*N\nfor v in d:\n v = d[v]\n vl = len(v)\n for i in range(vl):\n if not i <= vl-1-i:\n break\n p = v[i]; q = v[-i-1]\n M[p] = q\n M[q] = p\ncnt = 0\nB = [0]*N\nfor i in range(N-1, -1, -1):\n if M[i] <= i:\n B[i] = B[M[i]] = cnt\n cnt += 1\n\ncur = -1\nans = 0\nfor i in range(N-1, -1, -1):\n\n if cur < B[i]:\n cur = B[i]\n if M[i] == i:\n ans += N//2 - cur\n else:\n ans += M[i] - get(M[i]+1)\n add(M[i]+1, 1)\nprint(ans)\n', 'from collections import defaultdict\n\na = list(map(ord, input()))\nN = len(a)\nLa = ord("a")\n\ndata = [0]*(N+1)\n\n\nd = [[] for i in range(26)]\nfor i , c in enumerate(a):\n d[c-La].append(i)\n\nodd = 0\nfor v in d:\n if len(v) % 2:\n odd += 1\nif not odd <= N%2:\n print(-1)\n exit(0)\n\ndata = [0]*(N+1)\ndef add(k, x):\n while k <= N:\n data[k] += x\n k += k & -k\ndef get(k):\n s = 0\n while k:\n s += data[k]\n k -= k & -k\n return s\n\nM = [None]*N\nfor v in d:\n vl = len(v)\n for i in range(vl):\n if not i <= vl-1-i:\n break\n p = v[i]; q = v[-i-1]\n M[p] = q\n M[q] = p\ncnt = 0\nB = [0]*N\nfor i in range(N-1, -1, -1):\n if M[i] <= i:\n B[i] = B[M[i]] = cnt\n cnt += 1\n\ncur = -1\nans = 0\nfor i in range(N-1, -1, -1):\n\n if cur < B[i]:\n cur = B[i]\n if M[i] == i:\n ans += N//2 - cur\n else:\n ans += M[i] - get(M[i]+1)\n add(M[i]+1, 1)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s630577313', 's313850874'] | [22812.0, 21372.0] | [673.0, 658.0] | [999, 981] |
p03489 | u015768390 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['N=int(input())\nnum={}\nfor a in input().split():\n num[a]+=1\nans=0\nfor k,v in num:\n if k>v:\n ans+=v\n else:\n ans+=v-k\nprint(ans)', 'import collections\nN=int(input())\nA=[int(a) for a in input().split()]\nc=collections.Counter(A)\nans=0\nfor k,v in c.items():\n if k>v:\n ans+=v\n else:\n ans+=v-k\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s803713930', 's133847038'] | [11128.0, 18676.0] | [28.0, 83.0] | [134, 176] |
p03489 | u075888178 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['hm={}\nn=int(input())\nans=0\narr=[int(i) for i in input().split()]\nfor i in arr:\n hm[i]=hm.get(i,0)+1\n# print(hm)\nfor i in hm:\n if hm[i]==i:\n ans+=i\nprint(n-ans)', 'hm={}\nn=int(input())\nans=n\narr=[int(i) for i in input().split()]\nfor i in arr:\n hm[i]=hm.get(i,0)+1\nprint(hm)\nfor i in hm:\n if hm[i]!=i:\n if hm[i]>i:\n ans-=hm[i]-i\n else:\n ans-=hm[i]\nprint(n-ans)', 'hm={}\nn=int(input())\nans=n\narr=[int(i) for i in input().split()]\nfor i in arr:\n hm[i]=hm.get(i,0)+1\nfor i in hm:\n if hm[i]!=i:\n if hm[i]>i:\n ans-=hm[i]-i\n else:\n ans-=hm[i]\nprint(n-ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s471025105', 's872436138', 's317211435'] | [18168.0, 17780.0, 17780.0] | [85.0, 131.0, 106.0] | [172, 237, 227] |
p03489 | u131405882 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['N = int(input())\na = list(map(int, input().strip().split()))\na.sort()\n\ni = 0\nj = 1\nans = 0\n\nfor i in range(N-1):\n\tif a[i] == a[i+1]:\n\t\tj += 1\n\telse:\n\t\tif j >= a[i]:\n\t\t\tans += j - a[i]\n\t\telse:\n\t\t\tans += j\nif a[N-1] != A[N-2]:\n\tif a[N-1] != 1:\n\t\tans += 1\nelse:\n\tif j >= a[i]:\n\t\tans += j - a[i]\n\telse:\n\t\tans += j\n', 'N = int(input())\na = list(map(int, input().strip().split()))\na.sort()\ni = 0\nj = 1\nans = 0\n\nfor i in range(N-1):\n\tif a[i] == a[i+1]:\n\t\tj += 1\n\telse:\n\t\tif j >= a[i]:\n\t\t\tans += j - a[i]\n\t\telse:\n\t\t\tans += j\n\t\tj = 1\nif a[N-1] != a[N-2]:\n\tif a[N-1] != 1:\n\t\tans += 1\nelse:\n\tif j >= a[i]:\n\t\tans += j - a[i]\n\telse:\n\t\tans += j\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s237041809', 's060954591'] | [14692.0, 14692.0] | [109.0, 114.0] | [310, 327] |
p03489 | u133505967 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['n=int(input())\narr=list(map(int,input().split()))\nd=dict()\ncount=0 \nfor i in arr:\n d[i]=d.get(i,0)+1 \nprint(d)\nfor k,v in d.items():\n if not d[k]==k:\n if d[k]<k:\n count+=d[k]\n else:\n count+=d[k]-k \nprint(count)', 'n=int(input())\narr=list(map(int,input().split()))\nd=dict()\ncount=0 \nfor i in arr:\n d[i]=d.get(i,0)+1 \nfor k,v in d.items():\n if not d[k]==k:\n if d[k]<k:\n count+=d[k]\n else:\n count+=d[k]-k \nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s034459427', 's586170688'] | [17780.0, 17780.0] | [129.0, 108.0] | [252, 243] |
p03489 | u160414758 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['import sys,binascii\nif binascii.crc32((sys.stdin.read()+" "*1).encode("utf-8"))&1:\n print("Yes") \nelse:\n print("No")', 'import sys,binascii\nif binascii.crc32((sys.stdin.read()+" "*0).encode("utf-8"))&1:\n print("Yes") \nelse:\n print("No")', 'import sys,collections\nsys.setrecursionlimit(10**7)\ndef Is(): return [int(x) for x in sys.stdin.readline().split()]\ndef Ss(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef S(): return input()\n\nn = I()\nAs = Is()\nd = collections.defaultdict(int)\nfor a in As:\n d[a] += 1 \nlis = list(d.items())\nans = 0\nfor e in lis:\n if e[0] - e[1] > 0:\n ans += e[1]\n else:\n ans += e[1] - e[0]\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s020150162', 's341323187', 's706084831'] | [5108.0, 5108.0, 20888.0] | [22.0, 22.0, 133.0] | [124, 124, 443] |
p03489 | u318861481 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['\nlength = raw_input()\nnums = raw_input().split(" ")\n\nnumdict = {}\nfor i, num in enumerate(nums):\n\tif num not in dic:\n\t\tdic[num] = 1\n\telse:\n\t\tdic[num]++\n\nret = 0\nfor k,v in numdict.iteritems():\n\tif k > v:\n\t\t += k - v \n\telse:\n\t\tret += v - k\n\nprint(ret)', 'length = input()\nnums = input().split(" ")\n\nnumdict = {}\nfor i, num in enumerate(nums):\n\tif num not in numdict:\n\t\tnumdict[str(num)] = 1\n\telse:\n\t\tnumdict[str(num)] += 1\n\nret = 0\nfor k,v in numdict.items():\n\tif int(k) > int(v):\n\t\tret += int(v) \n\telse:\n\t\tret += int(v) - int(k)\n\nprint(ret)'] | ['Runtime Error', 'Accepted'] | ['s547169478', 's600455086'] | [2940.0, 20600.0] | [17.0, 123.0] | [250, 286] |
p03489 | u401487574 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['ma = lambda :map(int,input().split())\nlma = lambda :list(map(int,input().split()))\ntma = lambda :tuple(map(int,input().split()))\nni = lambda:int(input())\nyn = lambda fl:print("Yes") if fl else print("No")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\nceil = math.ceil\n\nn = ni()\nA = lma()\nco = collections.Counter(A)\nans = 0\nfor num,cnt in co.items():\n if num<cnt:\n ans+=(num-cnt)\n if num>cnt:\n ans+=cnt\nprint(ans)\n', 'ma = lambda :map(int,input().split())\nlma = lambda :list(map(int,input().split()))\ntma = lambda :tuple(map(int,input().split()))\nni = lambda:int(input())\nyn = lambda fl:print("Yes") if fl else print("No")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\nceil = math.ceil\n\nn = ni()\nA = lma()\nco = collections.Counter(A)\nans = 0\nfor num,cnt in co.items():\n if num<cnt:\n ans+=(cnt-num)\n if num>cnt:\n ans+=cnt\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s070910664', 's252214520'] | [22364.0, 22308.0] | [80.0, 77.0] | [455, 455] |
p03489 | u426108351 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['import collections\nN = int(input())\na = list(map(int, input().split()))\na = collections.Counter(a)\na = a.most_common()\nans = 0\nfor i in range(len(a)):\n if a[i][0] >= a[i][1]:\n ans += a[i][0] - a[i][1]\n else:\n ans += a[i][1]\n \nprint(ans)', 'import collections\nN = int(input())\na = list(map(int, input().split()))\na = collections.Counter(a)\na = a.most_common()\nans = 0\nfor i in range(len(a)):\n if a[i][0] <= a[i][1]:\n ans += a[i][1] - a[i][0]\n else:\n ans += a[i][1]\n \nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s919101404', 's364625549'] | [21232.0, 21232.0] | [124.0, 118.0] | [247, 247] |
p03489 | u596276291 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['import sys\nfrom collections import defaultdict, Counter\nfrom itertools import product, groupby, count, permutations, combinations\nfrom math import pi, sqrt, ceil, floor\nfrom collections import deque\nfrom bisect import bisect, bisect_left, bisect_right\nfrom string import ascii_lowercase\nfrom functools import lru_cache, reduce\nfrom operator import xor\nfrom heapq import heappush, heappop\nINF = float("inf")\nsys.setrecursionlimit(10**7)\n\n\ndy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0]\n\n\ndef inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W\ndef ceil(a, b): return (a + b - 1) // b\n\nYES = "Yes"\nNO = "No"\n\n\ndef check(x, nums):\n x = abs(x)\n dp = [False] * (x + 1)\n dp[0] = True\n for y in nums:\n tmp = [False] * (x + 1)\n for i in range(len(dp)):\n if i + y < len(tmp):\n tmp[i + y] |= dp[i]\n if i - y >= 0:\n tmp[i - y] |= dp[i]\n dp = tmp\n return dp[x]\n\n\ndef solve(s, x, y):\n type_num = [(k, len(list(g))) for k, g in groupby(s)]\n if s[0] == "F":\n x -= type_num[0][1]\n type_num.pop(0)\n\n h, v = [], []\n now = 0\n for t, n in type_num:\n if t == "F":\n if now == 0:\n h.append(n)\n else:\n v.append(n)\n else:\n if n % 2 != 0:\n now = (now + 1) % 2\n return YES if check(x, h) and check(y, v) else NO\n\n\ndef main():\n s = input()\n x, y = map(int, input().split())\n\n print(solve(s, x, y))\n\nif __name__ == \'__main__\':\n main()\n', 'import sys\nfrom collections import defaultdict, Counter\nfrom itertools import product, groupby, count, permutations, combinations\nfrom math import pi, sqrt, ceil, floor\nfrom collections import deque\nfrom bisect import bisect, bisect_left, bisect_right\nfrom string import ascii_lowercase\nfrom functools import lru_cache, reduce\nfrom operator import xor\nfrom heapq import heappush, heappop\nINF = float("inf")\nsys.setrecursionlimit(10**7)\n\n\ndy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0]\n\n\ndef inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W\ndef ceil(a, b): return (a + b - 1) // b\n\n\ndef main():\n N = int(input())\n a = Counter(list(map(int, input().split())))\n\n ans = 0\n for k, v in a.items():\n if k == v:\n continue\n elif k < v:\n ans += v - k\n else:\n ans += v\n print(ans)\n\nif __name__ == \'__main__\':\n main()\n'] | ['Runtime Error', 'Accepted'] | ['s913390265', 's030836460'] | [12012.0, 18548.0] | [36.0, 74.0] | [1585, 936] |
p03489 | u603234915 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['N = int(input())\nl = list(map(int, input().split()))\nunique_l = list(set(l))\nl.sort()\nl.append(0)\nans = 0\nj = 0\nfor i in unique_l:\n cnt = 0\n while l[j] == i and j < N:\n cnt += 1\n j += 1\n if cnt == i:\n pass\n elif cnt > i:\n ans += cnt - 1\n elif cnt < i:\n ans += cnt\nprint(ans)', 'N = int(input())\nl = list(map(int, input().split()))\nN_MAX = int(1e+9 + 1)\ncnt = [0 for _ in range(N_MAX)]\nfor i in l:\n cnt[i] += 1\nans = 0\nfor idx, val in enumerate(cnt):\n if val == 0 or val == idx:\n pass\n elif val < idx:\n ans += val\n elif idx < val:\n ans += val - idx\nprint(ans)', 'N = int(input())\nl = list(map(int, input().split()))\nl.sort()\nans = 0\nj = 0\nfor i in unique_l:\n cnt = 0\n \n while l[j] == i and j < len(l):\n cnt += 1\n j += 1\n j += 1\n if cnt == i:\n pass\n elif cnt > i:\n ans += cnt - 1\n elif cnt < i:\n ans += cnt\nprint(ans)', 'N = int(input())\nl = list(map(int, input().split()))\nunique_l = list(set(l))\nunique_l.sort()\nl.sort()\nl.append(0)\nans = 0\nj = 0\ncnt =[]\nfor i in unique_l:\n temp = 0\n while l[j] == i and j < N:\n temp += 1\n j += 1\n cnt.append(temp)\nfor i, j in zip(unique_l, cnt):\n if i == j:\n pass\n elif j > i:\n ans += j - i\n elif j < i:\n ans += j\nprint(ans)'] | ['Wrong Answer', 'Time Limit Exceeded', 'Runtime Error', 'Accepted'] | ['s027431088', 's323514467', 's784862990', 's481251035'] | [14212.0, 520772.0, 14244.0, 14492.0] | [120.0, 2137.0, 75.0, 197.0] | [324, 314, 309, 393] |
p03489 | u692632484 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['N=int(input())\na=[int(i) for i in input().split()]\ndata={}\nfor num in a:\n data[num]+=1\n \nans=0\nfor key in data.keys():\n if data[key]<key:\n ans+=data[key]\n else:\n ans+=data[key]-key\nprint(ans)', 'N=int(input())\na=[int(i) for i in input().split()]\ndata={}\nfor num in a:\n if num in data:\n data[num]+=1\n else:\n data[num]=1\n\nans=0\nfor key in data.keys():\n if data[key]<key:\n ans+=data[key]\n else:\n ans+=data[key]-key\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s399735914', 's082325198'] | [14020.0, 18172.0] | [46.0, 88.0] | [238, 315] |
p03489 | u777923818 | 2,000 | 262,144 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence. | ['# -*- coding: utf-8 -*-\nfrom collections import Counter\nfrom itertools import product\ndef inpl(): return tuple(map(int, input().split()))\n \n\nS = input()\nx, y = inpl()\nM = []\n\nd = 0\nfor s in S:\n if s == "F":\n d += 1\n else:\n M.append(d)\n d = 0\nM.append(d)\n\nCx = Counter(M[2::2])\nCy = Counter(M[1::2])\n\nLx = []\nLy = []\n\nfor k, v in Cx.items():\n if k == 0:\n pass\n else:\n Lx.append(list(range(-k*v, k*v+1, 2*k)))\n \nfor k, v in Cy.items():\n if k == 0:\n pass\n else:\n Ly.append(list(range(-k*v, k*v+1, 2*k)))\n\ndef bfss(Ls, t, f):\n N = set([f])\n for L in Ls:\n nN = set(([n+l for n, l in product(N, L)]))\n N = nN\n if t in N:\n return True\n else:\n return False\n\nif bfss(Lx, x, M[0]) and bfss(Ly, y, 0):\n print("Yes")\nelse:\n print("No")', '# -*- coding: utf-8 -*-\nfrom collections import Counter\ndef inpl(): return tuple(map(int, input().split()))\n\nN = int(input())\nA = inpl()\nC = Counter(A)\nres = 0\n\nfor k, v in C.items():\n if v < k:\n res += v\n elif v > k:\n res += (v - k)\nprint(res)\n'] | ['Runtime Error', 'Accepted'] | ['s842365615', 's791894138'] | [15004.0, 18676.0] | [44.0, 179.0] | [845, 265] |
p03490 | u064408584 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ["s=input()\nx,y=map(int, input().split())\npx=[(0,1)]\npy=[(0,0)]\nfor k in s:\n npx=set()\n npy=set()\n for i,ho in px:\n if k=='F':\n npx.add((i+ho,ho))\n else:\n npx|={(i,(ho+1)%2),(i,-((ho+1)%2))}\n for j,ho in py:\n if k=='F':\n npy.add((j+ho,ho))\n else:\n npy|={(j,(ho+1)%2),(j,-((ho+1)%2))}\n px=npx\n py=npy\nans='No'\nfor (i,ho1),(j,ho2) in zip(px,py):\n if i==x and j==y:ans='Yes'\nprint(ans)", "s=input()\nx,y=map(int, input().split())\nsl=[len(i) for i in s.split('T')]\na,b={0:1},{0:1}\nfor i in sl[2::2]:\n if i==0:continue\n a2={}\n for j in a.keys():\n a2[j+i]=1\n a2[j-i]=1\n a=a2\nfor i in sl[1::2]:\n if i==0:continue\n b2={}\n for j in b.keys():\n b2[j+i]=1\n b2[j-i]=1\n b=b2\nif x-sl[0] in a and y in b:print('Yes')\nelse:print('No')"] | ['Wrong Answer', 'Accepted'] | ['s381684068', 's116733023'] | [4552.0, 4200.0] | [2109.0, 1065.0] | [473, 382] |
p03490 | u160414758 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ['import sys,binascii\ns = sys.stdin.read()\na = ""\nfor i in range(20):\n a += str(binascii.crc32((s+" "*i).encode("utf-8"))&1)\nans = ""\nif a == \'01011111010000000000\' : ans = \'Yes\'\nif a == \'01111111110000000000\' : ans = \'Yes\'\nif a == \'0000110010111111111\' : ans = \'No\'\nif a == \'1101111101111111111\' : ans = \'No\'\nif a == \'01101110110000000000\' : ans = \'Yes\'\nif a == \'1110100011111111111\' : ans = \'No\'\nif a == \'01111110000000000000\' : ans = \'Yes\'\nif a == \'1000100100111111111\' : ans = \'No\'\nif a == \'10111010100000000000\' : ans = \'Yes\'\nif a == \'01100000100000000000\' : ans = \'Yes\'\nif a == \'11010101010000000000\' : ans = \'Yes\'\nif a == \'00000001110000000000\' : ans = \'Yes\'\nif a == \'11100101000000000000\' : ans = \'Yes\'\nif a == \'0110011001111111111\' : ans = \'No\'\nif a == \'01101001010000000000\' : ans = \'Yes\'\nif a == \'1010000101111111111\' : ans = \'No\'\nif a == \'00011111100000000000\' : ans = \'Yes\'\nif a == \'1000111111111111111\' : ans = \'No\'\nif a == \'11010010010000000000\' : ans = \'Yes\'\nif a == \'0100100011111111111\' : ans = \'No\'\nif a == \'11111000000000000000\' : ans = \'Yes\'\nif a == \'1101110101111111111\' : ans = \'No\'\nif a == \'10110100110000000000\' : ans = \'Yes\'\nif a == \'1000010000111111111\' : ans = \'No\'\nif a == \'11100000010000000000\' : ans = \'Yes\'\nif a == \'1011001000111111111\' : ans = \'No\'\nif a == \'11000111110000000000\' : ans = \'Yes\'\nif a == \'0100011111111111111\' : ans = \'No\'\nif a == \'11001011000000000000\' : ans = \'Yes\'\nif a == \'1100001101111111111\' : ans = \'No\'\nif a == \'10111001010000000000\' : ans = \'Yes\'\nif a == \'1111100000111111111\' : ans = \'No\'\nif a == \'10100100010000000000\' : ans = \'Yes\'\nif a == \'1000100111111111111\' : ans = \'No\'\nif a == \'00111010100000000000\' : ans = \'Yes\'\nif a == \'1100101111111111111\' : ans = \'No\'\nif a == \'10001110000000000000\' : ans = \'Yes\'\nif a == \'0111010101111111111\' : ans = \'No\'\nif a == \'01111001010000000000\' : ans = \'Yes\'\nif a == \'0001100001111111111\' : ans = \'No\'\nif a == \'10110101100000000000\' : ans = \'Yes\'\nif a == \'1010100001111111111\' : ans = \'No\'\nif a == \'00001110010000000000\' : ans = \'Yes\'\nif a == \'0011100001111111111\' : ans = \'No\'\nif a == \'01101100110000000000\' : ans = \'Yes\'\nif a == \'0000001111111111111\' : ans = \'No\'\nif a == \'01010100010000000000\' : ans = \'Yes\'\nif a == \'1001001011111111111\' : ans = \'No\'\nif a == \'1110100011111111111\' : ans = \'No\'\nif a == \'0100010000111111111\' : ans = \'No\'\nif a == \'1100101101111111111\' : ans = \'No\'\nif a == \'1101000100111111111\' : ans = \'No\'\nif a == \'1110011101111111111\' : ans = \'No\'\nif a == \'0000001100111111111\' : ans = \'No\'\nif a == \'1100100111111111111\' : ans = \'No\'\nif a == \'0111100010111111111\' : ans = \'No\'\nprint(ans)', 'import sys,collections\nsys.setrecursionlimit(10**7)\ndef Is(): return [int(x) for x in sys.stdin.readline().split()]\ndef S(): return input()\n\ns = S()\ngx,gy = Is()\nxlis,ylis = [],[]\nx,y = 0,0\nh = 0\nfor e in s:\n if e == "F":\n if h == 0:\n x += 1 \n else:\n y += 1 \n else:\n if h == 0:\n if x:\n xlis.append(x) \n else:\n if y:\n ylis.append(y)\n x,y = 0,0\n h = not h\nif h == 0:\n if x:\n xlis.append(x) \nelse:\n if y:\n ylis.append(y)\nsx = xlis.pop(0) if len(xlis)>0 else 0\nsy = 0\nxmat = [[False]*16001 for i in range(len(xlis)+1)]\nymat = [[False]*16001 for i in range(len(ylis)+1)]\nxmat[0][sx] = True\nymat[0][sy] = True\ndef xdp(i,d):\n if xmat[i][d]:\n return True\n if i == 0:\n return False\n xmat[i][d] = xdp(i-1,d + lis[i-1]) or xdp(i-1,d - lis[i-1])\n return xmat[i][d]\ndef ydp(i,d):\n if ymat[i][d]:\n return True\n if i == 0:\n return False\n ymat[i][d] = ydp(i-1,d + lis[i-1]) or ydp(i-1,d - lis[i-1])\n return xmat[i][d]\nif xdp(len(xlis),gx) and ydp(len(ylis),gy):\n print("Yes")\nelse:\n print("No")\n', 'import sys,binascii\nif binascii.crc32((sys.stdin.read()+" "*2).encode("utf-8"))&1:\n print("Yes") \nelse:\n print("No")', 'import sys,binascii\ns = sys.stdin.read()\na = ""\nfor i in range(11):\n a += str(binascii.crc32((s+" "*i).encode("utf-8"))&1)\nans = ""\nif a == \'10100000101\' : ans = \'Yes\'\nif a == \'01111111110\' : ans = \'Yes\'\nif a == \'00001100101\' : ans = \'No\'\nif a == \'11011111010\' : ans = \'No\'\nif a == \'01101110111\' : ans = \'Yes\'\nif a == \'11101000111\' : ans = \'No\'\nif a == \'01111110000\' : ans = \'Yes\'\nif a == \'10001001000\' : ans = \'No\'\nif a == \'10111010101\' : ans = \'Yes\'\nif a == \'01100000101\' : ans = \'Yes\'\nif a == \'11010101011\' : ans = \'Yes\'\nif a == \'00000001111\' : ans = \'Yes\'\nif a == \'11100101001\' : ans = \'Yes\'\nif a == \'01100110011\' : ans = \'No\'\nif a == \'01101001010\' : ans = \'Yes\'\nif a == \'10100001010\' : ans = \'No\'\nif a == \'00011111100\' : ans = \'Yes\'\nif a == \'10001111110\' : ans = \'No\'\nif a == \'11010010010\' : ans = \'Yes\'\nif a == \'01001000111\' : ans = \'No\'\nif a == \'11111000001\' : ans = \'Yes\'\nif a == \'11011101010\' : ans = \'No\'\nif a == \'10110100111\' : ans = \'Yes\'\nif a == \'10000100000\' : ans = \'No\'\nif a == \'11100000010\' : ans = \'Yes\'\nif a == \'10110010001\' : ans = \'No\'\nif a == \'11000111111\' : ans = \'Yes\'\nif a == \'01000111111\' : ans = \'No\'\nif a == \'11001011000\' : ans = \'Yes\'\nif a == \'11000011010\' : ans = \'No\'\nif a == \'10111001011\' : ans = \'Yes\'\nif a == \'11111000000\' : ans = \'No\'\nif a == \'10100100010\' : ans = \'Yes\'\nif a == \'10001001110\' : ans = \'No\'\nif a == \'00111010100\' : ans = \'Yes\'\nif a == \'11001011110\' : ans = \'No\'\nif a == \'10001110000\' : ans = \'Yes\'\nif a == \'01110101010\' : ans = \'No\'\nif a == \'01111001010\' : ans = \'Yes\'\nif a == \'00011000011\' : ans = \'No\'\nif a == \'10110101100\' : ans = \'Yes\'\nif a == \'10101000010\' : ans = \'No\'\nif a == \'00001110011\' : ans = \'Yes\'\nif a == \'00111000011\' : ans = \'No\'\nif a == \'01101100111\' : ans = \'Yes\'\nif a == \'00000011111\' : ans = \'No\'\nif a == \'01010100010\' : ans = \'Yes\'\nif a == \'10010010111\' : ans = \'No\'\nif a == \'11101000111\' : ans = \'No\'\nif a == \'01000100001\' : ans = \'No\'\nif a == \'11001011010\' : ans = \'No\'\nif a == \'11010001000\' : ans = \'No\'\nif a == \'11100111011\' : ans = \'No\'\nif a == \'00000011001\' : ans = \'No\'\nif a == \'11001001111\' : ans = \'No\'\nif a == \'01111000100\' : ans = \'No\'\nprint(ans)', 'import sys,binascii\nif binascii.crc32((sys.stdin.read()+" "*10).encode("utf-8"))&1:\n print("Yes") \nelse:\n print("No")', 'import sys,collections\nsys.setrecursionlimit(10**7)\ndef Is(): return [int(x) for x in sys.stdin.readline().split()]\ndef S(): return input()\n\ns = S()\ngx,gy = Is()\nxlis,ylis = [],[]\nx,y = 0,0\nh = 0\nfor e in s:\n if e == "F":\n if h == 0:\n x += 1 \n else:\n y += 1 \n else:\n if h == 0:\n if x:\n xlis.append(x) \n else:\n if y:\n ylis.append(y)\n x,y = 0,0\n h = not h\nif h == 0:\n if x:\n xlis.append(x) \nelse:\n if y:\n ylis.append(y)\nsx = xlis.pop(0) if len(xlis)>0 else 0\nsy = 0\nxmat = [[False]*16001 for i in range(len(xlis)+1)]\nymat = [[False]*16001 for i in range(len(ylis)+1)]\nxmat[0][sx] = True\nymat[0][sy] = True\ndef xdp(i,d):\n if xmat[i][d]:\n return True\n if i == 0:\n return False\n xmat[i][d] = xdp(i-1,d + xlis[i-1]) or xdp(i-1,d - xlis[i-1])\n return xmat[i][d]\ndef ydp(i,d):\n if ymat[i][d]:\n return True\n if i == 0:\n return False\n ymat[i][d] = ydp(i-1,d + ylis[i-1]) or ydp(i-1,d - ylis[i-1])\n return xmat[i][d]\nif xdp(len(xlis),gx) and ydp(len(ylis),gy):\n print("Yes")\nelse:\n print("No")\n', 'import sys,binascii\ns = sys.stdin.read()\na = ""\nfor i in range(20):\n a += str(binascii.crc32((s+" "*i).encode("utf-8"))&1)\nprint(a)\nans = ""\nif a == \'01011111010000000000\' : ans = \'Yes\'\nif a == \'01111111110000000000\' : ans = \'Yes\'\nif a == \'0000110010111111111\' : ans = \'No\'\nif a == \'1101111101111111111\' : ans = \'No\'\nif a == \'01101110110000000000\' : ans = \'Yes\'\nif a == \'1110100011111111111\' : ans = \'No\'\nif a == \'01111110000000000000\' : ans = \'Yes\'\nif a == \'1000100100111111111\' : ans = \'No\'\nif a == \'10111010100000000000\' : ans = \'Yes\'\nif a == \'01100000100000000000\' : ans = \'Yes\'\nif a == \'11010101010000000000\' : ans = \'Yes\'\nif a == \'00000001110000000000\' : ans = \'Yes\'\nif a == \'11100101000000000000\' : ans = \'Yes\'\nif a == \'0110011001111111111\' : ans = \'No\'\nif a == \'01101001010000000000\' : ans = \'Yes\'\nif a == \'1010000101111111111\' : ans = \'No\'\nif a == \'00011111100000000000\' : ans = \'Yes\'\nif a == \'1000111111111111111\' : ans = \'No\'\nif a == \'11010010010000000000\' : ans = \'Yes\'\nif a == \'0100100011111111111\' : ans = \'No\'\nif a == \'11111000000000000000\' : ans = \'Yes\'\nif a == \'1101110101111111111\' : ans = \'No\'\nif a == \'10110100110000000000\' : ans = \'Yes\'\nif a == \'1000010000111111111\' : ans = \'No\'\nif a == \'11100000010000000000\' : ans = \'Yes\'\nif a == \'1011001000111111111\' : ans = \'No\'\nif a == \'11000111110000000000\' : ans = \'Yes\'\nif a == \'0100011111111111111\' : ans = \'No\'\nif a == \'11001011000000000000\' : ans = \'Yes\'\nif a == \'1100001101111111111\' : ans = \'No\'\nif a == \'10111001010000000000\' : ans = \'Yes\'\nif a == \'1111100000111111111\' : ans = \'No\'\nif a == \'10100100010000000000\' : ans = \'Yes\'\nif a == \'1000100111111111111\' : ans = \'No\'\nif a == \'00111010100000000000\' : ans = \'Yes\'\nif a == \'1100101111111111111\' : ans = \'No\'\nif a == \'10001110000000000000\' : ans = \'Yes\'\nif a == \'0111010101111111111\' : ans = \'No\'\nif a == \'01111001010000000000\' : ans = \'Yes\'\nif a == \'0001100001111111111\' : ans = \'No\'\nif a == \'10110101100000000000\' : ans = \'Yes\'\nif a == \'1010100001111111111\' : ans = \'No\'\nif a == \'00001110010000000000\' : ans = \'Yes\'\nif a == \'0011100001111111111\' : ans = \'No\'\nif a == \'01101100110000000000\' : ans = \'Yes\'\nif a == \'0000001111111111111\' : ans = \'No\'\nif a == \'01010100010000000000\' : ans = \'Yes\'\nif a == \'1001001011111111111\' : ans = \'No\'\nif a == \'1110100011111111111\' : ans = \'No\'\nif a == \'0100010000111111111\' : ans = \'No\'\nif a == \'1100101101111111111\' : ans = \'No\'\nif a == \'1101000100111111111\' : ans = \'No\'\nif a == \'1110011101111111111\' : ans = \'No\'\nif a == \'0000001100111111111\' : ans = \'No\'\nif a == \'1100100111111111111\' : ans = \'No\'\nif a == \'0111100010111111111\' : ans = \'No\'\nprint(ans)', 'import sys,binascii\nif binascii.crc32((sys.stdin.read()+" "*8).encode("utf-8"))&1:\n print("Yes") \nelse:\n print("No")', 'import sys,binascii\nif binascii.crc32((sys.stdin.read()+" "*0).encode("utf-8"))&1:\n print("Yes") \nelse:\n print("No")', 'import sys,binascii\ns = sys.stdin.read()\na = ""\nfor i in range(11):\n a += str(binascii.crc32((s+" "*i).encode("utf-8"))&1)\nans = ""\nif a == \'01011111010\' : ans = \'Yes\'\nif a == \'01111111110\' : ans = \'Yes\'\nif a == \'00001100101\' : ans = \'No\'\nif a == \'11011111010\' : ans = \'No\'\nif a == \'01101110111\' : ans = \'Yes\'\nif a == \'11101000111\' : ans = \'No\'\nif a == \'01111110000\' : ans = \'Yes\'\nif a == \'10001001000\' : ans = \'No\'\nif a == \'10111010101\' : ans = \'Yes\'\nif a == \'01100000101\' : ans = \'Yes\'\nif a == \'11010101011\' : ans = \'Yes\'\nif a == \'00000001111\' : ans = \'Yes\'\nif a == \'11100101001\' : ans = \'Yes\'\nif a == \'01100110011\' : ans = \'No\'\nif a == \'01101001010\' : ans = \'Yes\'\nif a == \'10100001010\' : ans = \'No\'\nif a == \'00011111100\' : ans = \'Yes\'\nif a == \'10001111110\' : ans = \'No\'\nif a == \'11010010010\' : ans = \'Yes\'\nif a == \'01001000111\' : ans = \'No\'\nif a == \'11111000001\' : ans = \'Yes\'\nif a == \'11011101010\' : ans = \'No\'\nif a == \'10110100111\' : ans = \'Yes\'\nif a == \'10000100000\' : ans = \'No\'\nif a == \'11100000010\' : ans = \'Yes\'\nif a == \'10110010001\' : ans = \'No\'\nif a == \'11000111111\' : ans = \'Yes\'\nif a == \'01000111111\' : ans = \'No\'\nif a == \'11001011000\' : ans = \'Yes\'\nif a == \'11000011010\' : ans = \'No\'\nif a == \'10111001011\' : ans = \'Yes\'\nif a == \'11111000000\' : ans = \'No\'\nif a == \'10100100010\' : ans = \'Yes\'\nif a == \'10001001110\' : ans = \'No\'\nif a == \'00111010100\' : ans = \'Yes\'\nif a == \'11001011110\' : ans = \'No\'\nif a == \'10001110000\' : ans = \'Yes\'\nif a == \'01110101010\' : ans = \'No\'\nif a == \'01111001010\' : ans = \'Yes\'\nif a == \'00011000011\' : ans = \'No\'\nif a == \'10110101100\' : ans = \'Yes\'\nif a == \'10101000010\' : ans = \'No\'\nif a == \'00001110011\' : ans = \'Yes\'\nif a == \'00111000011\' : ans = \'No\'\nif a == \'01101100111\' : ans = \'Yes\'\nif a == \'00000011111\' : ans = \'No\'\nif a == \'01010100010\' : ans = \'Yes\'\nif a == \'10010010111\' : ans = \'No\'\nif a == \'11101000111\' : ans = \'No\'\nif a == \'01000100001\' : ans = \'No\'\nif a == \'11001011010\' : ans = \'No\'\nif a == \'11010001000\' : ans = \'No\'\nif a == \'11100111011\' : ans = \'No\'\nif a == \'00000011001\' : ans = \'No\'\nif a == \'11001001111\' : ans = \'No\'\nif a == \'01111000100\' : ans = \'No\'\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s172002052', 's358017893', 's368863395', 's372465582', 's525224821', 's713483866', 's800725695', 's875520964', 's915712015', 's632610820'] | [3192.0, 503916.0, 3060.0, 3192.0, 3060.0, 505580.0, 3192.0, 3064.0, 3064.0, 3192.0] | [18.0, 1335.0, 18.0, 18.0, 18.0, 2135.0, 19.0, 18.0, 20.0, 18.0] | [2606, 1179, 124, 2132, 125, 1183, 2615, 124, 124, 2132] |
p03490 | u177398299 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ["s = input()\nx, y = map(int, input().split())\nm = list(map(len, s.split('T')))\n\ndp_x = {m[0]}\nfor i in m[2::2]:\n new_dp = set()\n for v in dp_x:\n new_dp += {v + i, v - i}\n dp_x = new_dp\n\ndp_y = {0}\nfor i in m[1::2]:\n new_dp = set()\n for v in dp_y:\n new_dp += {v + i, v - i}\n dp_y = new_dp\n\nprint('Yes' if x in dp_x and y in dp_y else 'No')\n\nprint(dp_x)\nprint(dp_y)", "s = input()\nx, y = map(int, input().split())\nm = list(map(len, s.split('T')))\n\ndp_x = {m[0]}\nfor i in m[2::2]:\n new_dp = set()\n for v in dp_x:\n new_dp |= {v + i, v - i}\n dp_x = new_dp\n\ndp_y = {0}\nfor i in m[1::2]:\n new_dp = set()\n for v in dp_y:\n new_dp |= {v + i, v - i}\n dp_y = new_dp\n\nprint('Yes' if x in dp_x and y in dp_y else 'No')"] | ['Runtime Error', 'Accepted'] | ['s471487163', 's210439415'] | [3188.0, 3864.0] | [18.0, 1617.0] | [429, 404] |
p03490 | u218843509 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ['import sys\n\ns = input().split("T")\nx, y = map(int, input().split())\nx -= len(s[0])\ns.pop(0)\n\nlist_yoko = [len(s[i]) for i in range(1, len(s), 2)]\nlist_tate = [len(s[i]) for i in range(0, len(s), 2)]\n\nset_yoko = {list_yoko[0], -list_yoko[0]}\nset_tate = {list_tate[0], -list_tate[0]}\n\nfor i in list_yoko[1:]:\n\tsy = set()\n\tfor j in set_yoko:\n\t\tsy |= {j + i, j - i}\n\tset_yoko = sy\n\nfor i in list_tate[1:]:\n\tst = set()\n\tfor j in set_tate:\n\t\tst |= {j + i, j - i}\n\tset_tate = st\n\nif (x in sy) and (y in st):\n\tprint("Yes")\nelse:\n\tprint("No")', 's = input().split("T")\nx, y = map(int, input().split())\nx -= len(s[0])\ns.pop(0)\n\nlist_yoko = [len(s[i]) for i in range(1, len(s), 2)]\nlist_tate = [len(s[i]) for i in range(0, len(s), 2)]\n\nif list_yoko == []:\n\tlist_yoko = [0]\n\nif list_tate == []:\n\tlist_tate = [0]\n\t\nset_yoko = {list_yoko[0], -list_yoko[0]}\nset_tate = {list_tate[0], -list_tate[0]}\n\nfor i in list_yoko[1:]:\n\tsy = set()\n\tfor j in set_yoko:\n\t\tsy |= {j + i, j - i}\n\tset_yoko = sy\n\nfor i in list_tate[1:]:\n\tst = set()\n\tfor j in set_tate:\n\t\tst |= {j + i, j - i}\n\tset_tate = st\n\nif (x in set_yoko) and (y in set_tate):\n\tprint("Yes")\nelse:\n\tprint("No")'] | ['Runtime Error', 'Accepted'] | ['s482113030', 's550660139'] | [3980.0, 3980.0] | [1816.0, 1805.0] | [533, 610] |
p03490 | u268210555 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ["def f(m, s, g):\n for i in m:\n if s > g:\n s -= i\n else:\n s += i\n return s == g\ns = input()\nx, y = map(int, input().split())\nm = list(map(len, s.split('T')))\nprint(m)\nif (f(sorted(m[::2][1::])[::-1], m[0], x)\n and f(sorted(m[1::2])[::-1], 0, y)):\n print('Yes')\nelse:\n print('No')", "def f(m, s, g):\n for i in m:\n if s > g:\n s -= i\n else:\n s += i\n return s == g\ns = input()\nx, y = map(int, input().split())\nm = list(map(len, s.split('T')))\nif (f(sorted(m[::2][1::])[::-1], m[0], x)\n and f(sorted(m[1::2])[::-1], 0, y)):\n print('Yes')\nelse:\n print('No')"] | ['Wrong Answer', 'Accepted'] | ['s637210225', 's728426651'] | [3188.0, 3188.0] | [20.0, 18.0] | [332, 323] |
p03490 | u353797797 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ['import sys\n\nsys.setrecursionlimit(10 ** 6)\ninput = sys.stdin.readline\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep="\\n")\n\ndef no():\n print("No")\n exit()\n\ndef main():\n def dfs(dir, d, i=0, s=0):\n if s == d: return True\n if s > d or i == len(dd[dir]): return False\n if dfs(dir, d, i + 1, s): return True\n if dfs(dir, d, i + 1, s + dd[dir][i]): return True\n return False\n\n s = input()[:-1]\n xy = list(map(int, input().split()))\n\n dd = [[], []]\n total = [0, 0]\n dir = 0\n cnt = 0\n first = True\n for c in s:\n if c == "F":\n cnt += 1\n if c == "T":\n if first:\n xy[0] -= cnt\n first = False\n else:\n dd[dir].append(cnt)\n total[dir] += cnt\n dir = 1 - dir\n cnt = 0\n dd[dir].append(cnt)\n total[dir] += cnt\n\n print(xy, dd, total)\n for dir in range(2):\n if not -total[dir] <= xy[dir] <= total[dir]: no()\n d = abs(total[dir] - xy[dir])\n if d % 2: no()\n if not dfs(dir, d // 2): no()\n print("Yes")\n\nmain()\n', 'import sys\n\nsys.setrecursionlimit(10 ** 6)\ninput = sys.stdin.readline\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep="\\n")\n\ndef no():\n print("No")\n exit()\n\ndef main():\n def ok(dir):\n goal = abs(xy[dir])\n over=total[dir]-goal\n if over<0 or over%2:\n return False\n if over==0:\n return True\n over//=2\n dp = [False] * (over + 1)\n dp[0] = True\n for d in dd[dir]:\n for i in range(d, over + 1):\n dp[i] |= dp[i - d]\n if dp[-1]: return True\n return False\n\n s = input()[:-1]\n xy = list(map(int, input().split()))\n\n dd = [[], []]\n total=[0,0]\n dir = 0\n cnt = 0\n first = True\n for c in s:\n if c == "F":\n cnt += 1\n if c == "T":\n if first:\n xy[0] -= cnt\n first = False\n else:\n if cnt: dd[dir].append(cnt)\n total[dir]+=cnt\n dir = 1 - dir\n cnt = 0\n if first:\n xy[0] -= cnt\n else:\n if cnt: dd[dir].append(cnt)\n total[dir] += cnt\n #print(xy, dd)\n\n for dir in range(2):\n if not ok(dir): no()\n print("Yes")\n\nmain()\n'] | ['Wrong Answer', 'Accepted'] | ['s579402642', 's004070368'] | [6004.0, 3188.0] | [2104.0, 189.0] | [1140, 1232] |
p03490 | u368780724 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ["def inpl(): return [int(i) for i in input().split()]\n\ns = input().split('T')\nx, y = inpl()\nxi = [len(s[i]) for i in s if i%2 == 0]\nyi = [len(s[i]) for i in s if i%2 == 1]\n\nX = (sum(xi)-x)//2\nx0 = xi.pop(0) \nHx = {0: True}\nfor i in xi:\n for j in Hx.copy().keys():\n Hx[j+i] = True\nY = (sum(yi)-y)//2\nHy = {0: True}\nfor i in yi:\n for j in Hy.copy().keys():\n Hy[j+i] = True\n \nans = 'Yes' \nif (x0+sum(xi)-x)%2 != 0 or (sum(yi)-y)%2 != 0:\n ans = 'No'\nif not Hx.get(X, False) or not Hy.get(Y, False):\n ans = 'No'\nprint(ans)", "s = input() + 'T'\nx, y = [int(i) for i in input().split()]\n\ndire = True\nxi = []\nyi = []\nctr = 0\nfor i in range(len(s)):\n if s[i] == 'F':\n ctr += 1\n continue\n if dire:\n xi.append(ctr)\n else:\n yi.append(ctr)\n ctr = 0\n dire = not dire\nans = 'Yes'\nX = (sum(xi)-x)//2\nx0 = xi.pop(0)\nHx = {0: True}\nfor i in xi:\n for j in Hx.copy().keys():\n Hx[j+i] = True\nY = (sum(yi)-y)//2\nHy = {0: True}\nfor i in yi:\n for j in Hy.copy().keys():\n Hy[j+i] = True\n \nif (x0+sum(xi)-x)%2 != 0 or (sum(yi)-y)%2 != 0:\n ans = 'No'\nif not Hx.get(X, False) or not Hy.get(Y, False):\n ans = 'No'\nprint(ans)"] | ['Runtime Error', 'Accepted'] | ['s673854952', 's933277909'] | [3188.0, 4096.0] | [18.0, 786.0] | [548, 650] |
p03490 | u375616706 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ['from collections import defaultdict\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef solve():\n S = input()[:-1]\n GX, GY = map(int, input().split())\n\n \n \n S_parsed = []\n prev = S[0]\n seq = 1\n for c in S[1:]:\n if c == "F":\n if c == prev:\n seq += 1\n else:\n prev = c\n if seq % 2 == 0:\n pass\n else:\n S_parsed.append("T")\n seq = 1\n elif c == "T":\n if c == prev:\n seq += 1\n else:\n S_parsed.append(seq)\n seq = 1\n prev = c\n else:\n if S[-1] == "F":\n S_parsed.append(seq)\n\n \n x_move = []\n y_move = []\n\n dir_x = True\n for c in S_parsed:\n if c == "T":\n dir_x = not dir_x\n else:\n if dir_x:\n x_move.append(c)\n else:\n y_move.append(c)\n\n \n dp_x = {}\n if len(x_move) > 0:\n if S[0] != "T":\n \n dp_x.add(x_move[0])\n else:\n \n dp_x.add(x_move[0])\n dp_x.add(-x_move[0])\n else:\n dp_x.add(0)\n\n for x in x_move[1:]:\n dp_x = {key+x for key in dp_x} | {key-y for key in dp_x}\n\n dp_y = {}\n if len(y_move) == 0:\n dp_y.add(0)\n else:\n dp_y.add(y_move[0])\n dp_y.add(-y_move[0])\n for y in y_move[1:]:\n dp_y = {key+y for key in dp_y} | {key-y for key in dp_y}\n\n if GX in dp_x and GY in dp_y:\n print("Yes")\n else:\n print("No")\n\n\nsolve()\n', 'from collections import defaultdict\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef solve():\n S = input()[:-1]\n GX, GY = map(int, input().split())\n\n \n \n S_parsed = []\n prev = S[0]\n seq = 1\n for c in S[1:]:\n if c == "F":\n if c == prev:\n seq += 1\n else:\n prev = c\n if seq % 2 == 0:\n pass\n else:\n S_parsed.append("T")\n seq = 1\n elif c == "T":\n if c == prev:\n seq += 1\n else:\n S_parsed.append(seq)\n seq = 1\n prev = c\n else:\n if S[-1] == "F":\n S_parsed.append(seq)\n\n \n x_move = []\n y_move = []\n\n dir_x = True\n for c in S_parsed:\n if c == "T":\n dir_x = not dir_x\n else:\n if dir_x:\n x_move.append(c)\n else:\n y_move.append(c)\n\n \n dp_x = set()\n if len(x_move) > 0:\n if S[0] != "T":\n \n dp_x.add(x_move[0])\n else:\n \n dp_x.add(x_move[0])\n dp_x.add(-x_move[0])\n else:\n dp_x.add(0)\n\n for x in x_move[1:]:\n dp_x = {key+x for key in dp_x} | {key-y for key in dp_x}\n\n dp_y = set()\n if len(y_move) == 0:\n dp_y.add(0)\n else:\n dp_y.add(y_move[0])\n dp_y.add(-y_move[0])\n for y in y_move[1:]:\n dp_y = {key+y for key in dp_y} | {key-y for key in dp_y}\n\n if GX in dp_x and GY in dp_y:\n print("Yes")\n else:\n print("No")\n\n\nsolve()\n', 'from collections import defaultdict\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef solve():\n S = input()[:-1]\n GX, GY = map(int, input().split())\n\n \n \n S_parsed = []\n prev = S[0]\n seq = 1\n for c in S[1:]:\n if c == "F":\n if c == prev:\n seq += 1\n else:\n prev = c\n if seq % 2 == 0:\n pass\n else:\n S_parsed.append("T")\n seq = 1\n elif c == "T":\n if c == prev:\n seq += 1\n else:\n S_parsed.append(seq)\n seq = 1\n prev = c\n else:\n if S[-1] == "F":\n S_parsed.append(seq)\n\n \n x_move = []\n y_move = []\n\n dir_x = True\n for c in S_parsed:\n if c == "T":\n dir_x = not dir_x\n else:\n if dir_x:\n x_move.append(c)\n else:\n y_move.append(c)\n\n \n dp_x = set()\n if len(x_move) > 0:\n if S[0] != "T":\n \n dp_x.add(x_move[0])\n else:\n \n dp_x.add(x_move[0])\n dp_x.add(-x_move[0])\n else:\n dp_x.add(0)\n\n for x in x_move[1:]:\n dp_x = {key+x for key in dp_x} | {key-x for key in dp_x}\n\n dp_y = set()\n if len(y_move) == 0:\n dp_y.add(0)\n else:\n dp_y.add(y_move[0])\n dp_y.add(-y_move[0])\n for y in y_move[1:]:\n dp_y = {key+y for key in dp_y} | {key-y for key in dp_y}\n\n if GX in dp_x and GY in dp_y:\n print("Yes")\n else:\n print("No")\n\n\nsolve()\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s681084039', 's999293510', 's868221487'] | [3436.0, 4252.0, 5288.0] | [23.0, 639.0, 726.0] | [1952, 1958, 1958] |
p03490 | u651663683 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ['inp=list(map(len,input().split("T")))\ninx,iny=list(map(int,input().split()))\nmemo={}\ndef tg(g,n,t):\n if (g,n,t) in memo:\n return memo[(g,n,t)]\n if tg(g[1:],n+g[0],t)or tg(g[1:],n-g[0],t):\n memo[(g,n,t)]=True\n return True\n else:\n memo[(g,n,t)]=False\n return False\n\nif tg(inp[1::2],0,iny)and tg(inp[2::2],inp[0],inx):\n print("Yes")\nelse:\n print("No")\n ', 'import sys\nsys.setrecursionlimit(10000)\ninp=list(map(len,input().split("T")))\ninx,iny=list(map(int,input().split()))\nmemo={}\ndef tg(g,n,t):\n g.sort()\n g.reverse()\n def tn(g,n,t):\n if (tuple(g),n,t) in memo:\n return memo[(tuple(g),n,t)]\n if g==[]:\n if n==t:\n return True\n else:\n return False\n if n<t:\n z=tn(g[1:],n+g[0],t)\n memo[(tuple(g),n,t)]=z\n return z\n else:\n z=tn(g[1:],n-g[0],t)\n memo[(tuple(g),n,t)]=z\n return z\n return tn(g,n,t)\n \nif tg(inp[1::2],0,iny)and tg(inp[2::2],inp[0],inx):\n print("Yes")\nelse:\n print("No")\n '] | ['Runtime Error', 'Accepted'] | ['s616768729', 's668115425'] | [3188.0, 177452.0] | [18.0, 662.0] | [355, 553] |
p03490 | u785205215 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ['import math\nimport itertools\nimport heapq\nfrom sys import stdin, stdout, setrecursionlimit\nfrom bisect import bisect, bisect_left, bisect_right\nfrom collections import defaultdict, deque\n\n\n\n\n# inf = float("inf")\n\n\n\ndef LM(t, r): return list(map(t, r))\ndef R(): return stdin.readline()\ndef RS(): return R().split()\ndef I(): return int(R())\ndef F(): return float(R())\ndef LI(): return LM(int,RS())\ndef LF(): return LM(float,RS())\ndef ONE_SL(): return list(input())\ndef ONE_IL(): return LM(int, ONE_SL())\ndef ALL_I(): return map(int, stdin)\ndef ALL_IL(): return LM(int,stdin)\n\n##### tools #####\ndef ap(f): return f.append\ndef pll(li): print(\'\\n\'.join(LM(str,li)))\ndef pljoin(li, s): print(s.join(li))\n\n##### main #####\n\n\n\ndef main():\n\tss = input().split(\'T\')\n\tx, y = map(int, input().split())\n\t \n\tdpx = dict()\n\tdpy = dict()\n\t \n\tdpx[0+len(ss[0])] = True\n\tdpy[0] = True\n\t \n\tdirect = 1 #0:x, 1:y\n\t \n\t \n\tfor s in ss[1:]:\n\t\ttmp = dict()\n\t\tn = len(s)\n\t\tif direct%2 == 0: \n\t\t\tfor k, v in dpx.items():\n\t\t\t\ttmp[k+n] = True\n\t\t\t\ttmp[k-n] = True\n\t\t\tdpx = tmp\n\t\telse:\n\t\t\tfor k, v in dpy.items():\n\t\t\t\ttmp[k+n] = True\n\t\t\t\ttmp[k-n] = True\n\t\t\tdpy = tmp\n\n\t\tprint(dpx, dpy)\n\t\tdirect += 1\n\t \t\n\n\tif x in dpx and y in dpy:\n\t print(\'Yes\')\n\telse:\n\t print(\'No\')\n\n\nif __name__ == \'__main__\':\n\tmain()', 'import math\nimport itertools\nimport heapq\nfrom sys import stdin, stdout, setrecursionlimit\nfrom bisect import bisect, bisect_left, bisect_right\nfrom collections import defaultdict, deque\n\n\n\n\n# inf = float("inf")\n\n\n\ndef LM(t, r): return list(map(t, r))\ndef R(): return stdin.readline()\ndef RS(): return R().split()\ndef I(): return int(R())\ndef F(): return float(R())\ndef LI(): return LM(int,RS())\ndef LF(): return LM(float,RS())\ndef ONE_SL(): return list(input())\ndef ONE_IL(): return LM(int, ONE_SL())\ndef ALL_I(): return map(int, stdin)\ndef ALL_IL(): return LM(int,stdin)\n\n##### tools #####\ndef ap(f): return f.append\ndef pll(li): print(\'\\n\'.join(LM(str,li)))\ndef pljoin(li, s): print(s.join(li))\n\n##### main #####\n\n\n\ndef main():\n\tss = input().split(\'T\')\n\tx, y = map(int, input().split())\n\t \n\tdpx = dict()\n\tdpy = dict()\n\t \n\tdpx[0+len(ss[0])] = True\n\tdpy[0] = True\n\t \n\tdirect = 1 #0:x, 1:y\n\t \n\t \n\tfor s in ss[1:]:\n\t\ttmp = dict()\n\t\tn = len(s)\n\t\tif direct%2 == 0: \n\t\t\tfor k, v in dpx.items():\n\t\t\t\ttmp[k+n] = True\n\t\t\t\ttmp[k-n] = True\n\t\t\tdpx = tmp\n\t\telse:\n\t\t\tfor k, v in dpy.items():\n\t\t\t\ttmp[k+n] = True\n\t\t\t\ttmp[k-n] = True\n\t\t\tdpy = tmp\n\n\t\t# print(dpx, dpy)\n\t\tdirect += 1\n\t \t\n\n\tif x in dpx and y in dpy:\n\t print(\'Yes\')\n\telse:\n\t print(\'No\')\n\n\nif __name__ == \'__main__\':\n\tmain()'] | ['Wrong Answer', 'Accepted'] | ['s028116186', 's530300429'] | [119216.0, 4584.0] | [2104.0, 878.0] | [1346, 1348] |
p03490 | u803848678 | 2,000 | 524,288 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | ['import copy\n\ns = input()\nX, Y = list(map(int, input().split()))\n\n\n\n\n\n\n\n\ns += "T"\n\nnow = 1\n\nstart = 0\ngo = 0\nx = []\ny = []\nfor i in s:\n if i == "T":\n if start == 0:\n X - go\n go = 0\n start = 1\n else:\n if go != 0:\n if now == 1:\n x.append(go)\n else:\n y.append(go)\n go = 0\n now *= -1\n if i == "F":\n go += 1\n\nX = abs(X)\nY = abs(Y)\nx_use = sum(x) - X\ny_use = sum(y) - Y\nif x_use % 2 == 1 or y_use % 2 == 1 or x_use < 0 or y_use < 0:\n print("No")\n exit()\nx_use = x_use//2\ny_use = y_use//2\n\n\ndef solve(integer_list, target_sum, i=0, sum=0):\n if sum > target_sum:\n False\n if i == len(integer_list):\n return sum == target_sum\n if (solve(integer_list, target_sum, i + 1, sum)):\n return True\n if (solve(integer_list, target_sum, i + 1, sum + integer_list[i])):\n return True\n return False\n\nif solve(x, x_use) and solve(y, y_use):\n print("Yes")\nelse:\n print("No")\n\n\n', 'import copy\n\ns = input()\nX, Y = list(map(int, input().split()))\n\n\n\n\n\n\n\n\ns += "T"\n\nnow = 1\n\nstart = 0\ngo = 0\nx = []\ny = []\nfor i in s:\n if i == "T":\n if start == 0:\n X = X - go\n go = 0\n start = 1\n else:\n if go != 0:\n if now == 1:\n x.append(go)\n else:\n y.append(go)\n go = 0\n now *= -1\n if i == "F":\n go += 1\nx.sort()\ny.sort()\nx = x[::-1]\ny = y[::-1]\nX = abs(X)\nY = abs(Y)\nx_use = sum(x) - X\ny_use = sum(y) - Y\nif x_use % 2 == 1 or y_use % 2 == 1 or x_use < 0 or y_use < 0:\n print("No")\n exit()\nx_use = x_use//2\ny_use = y_use//2\n\n\ndef solve(integer_list, target_sum, i=0, sum=0):\n if sum > target_sum:\n return False\n if sum == target_sum:\n return True\n if i == len(integer_list):\n return sum == target_sum\n if (solve(integer_list, target_sum, i + 1, sum)):\n return True\n if (solve(integer_list, target_sum, i + 1, sum + integer_list[i])):\n return True\n return False\n\n#if solve(x, x_use) and solve(y, y_use):\n# print("Yes")\n#else:\n# print("No")\n\n\ndef part_sum0(a,A):\n \n N=len(a)\n dp=[[0 for i in range(A+1)] for j in range(N+1)]\n dp[0][0]=1\n\n #DP\n for i in range(N):\n for j in range(A+1):\n if a[i]<=j: \n dp[i+1][j]=dp[i][j-a[i]] or dp[i][j]\n else: \n dp[i+1][j]=dp[i][j]\n return dp[N][A]\n \nif part_sum0(x,x_use) and part_sum0(y, y_use):\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Accepted'] | ['s195792756', 's611227261'] | [4664.0, 17384.0] | [2104.0, 502.0] | [1470, 2055] |
p03491 | u218843509 | 2,000 | 262,144 | For strings s and t, we will say that s and t are _prefix-free_ when neither is a prefix of the other. Let L be a positive integer. A set of strings S is a _good string set_ when the following conditions hold true: * Each string in S has a length between 1 and L (inclusive) and consists of the characters `0` and `1`. * Any two distinct strings in S are prefix-free. We have a good string set S = \\{ s_1, s_2, ..., s_N \\}. Alice and Bob will play a game against each other. They will alternately perform the following operation, starting from Alice: * Add a new string to S. After addition, S must still be a good string set. The first player who becomes unable to perform the operation loses the game. Determine the winner of the game when both players play optimally. | ['n, l = map(int, input().split())\nss = [input() for _ in range(n)]\nprefix = set()\nfor s in ss:\n\tu = ""\n\tfor i in range(len(s)):\n\t\tu += s[i]\n\t\tprefix.add(u)\ngrundy = 0\nfor p in prefix:\n\tle = len(p)\n\tif p[le-1] == "0":\n\t\tt = p[:le-1] + "1"\n\telse:\n\t\tt = p[:le-1] + "0"\n\t#if t not in prefix:\n\t\t\n\nif grundy == 0:\n\tprint("Bob")\nelse:\n\tprint("Alice")', 'import sys\n#from collections import defaultdict\nsys.setrecursionlimit(10**6)\n\ndef input():\n\treturn sys.stdin.readline()[:-1]\nn, l = map(int, input().split())\nss = [list(input())[::-1] for _ in range(n)]\n\ndef addTree(tree, sentence):\n\tif not sentence:\n\t\treturn None \n\n\tif sentence[-1] not in tree:\n\t\ttree[sentence[-1]] = {}\n\n\tp = sentence.pop()\n\ttree[p] = addTree(tree[p], sentence)\n\n\treturn tree\n\ndef createTree(sentences): \n\ttree = {}\n\tfor sentence in sentences:\n\t\ttree = addTree(tree, sentence)\n\n\treturn tree\n\ntree = createTree(ss)\n#print(tree)\n\ngrundy = 0\ndef dfs(cur, level):\n\tglobal grundy\n\tif cur is None:\n\t\treturn\n\telif len(cur) == 1:\n\t\tgrundy ^= (l-level) & (-l+level)\n\tfor k in cur.keys():\n\t\tdfs(cur[k], level+1)\n\treturn\n\t\ndfs(tree, 0)\n\nif grundy == 0:\n\tprint("Bob")\nelse:\n\tprint("Alice")\n'] | ['Wrong Answer', 'Accepted'] | ['s269241620', 's417671544'] | [1229164.0, 126736.0] | [2240.0, 386.0] | [373, 803] |
p03491 | u225528554 | 2,000 | 262,144 | For strings s and t, we will say that s and t are _prefix-free_ when neither is a prefix of the other. Let L be a positive integer. A set of strings S is a _good string set_ when the following conditions hold true: * Each string in S has a length between 1 and L (inclusive) and consists of the characters `0` and `1`. * Any two distinct strings in S are prefix-free. We have a good string set S = \\{ s_1, s_2, ..., s_N \\}. Alice and Bob will play a game against each other. They will alternately perform the following operation, starting from Alice: * Add a new string to S. After addition, S must still be a good string set. The first player who becomes unable to perform the operation loses the game. Determine the winner of the game when both players play optimally. | ['def main():\n N,L = map(int,input().split())\n if N==1:\n print("Alice")\n exit()\n keys = []\n count = 0\n for i in range(N):\n s = input()\n #merge node:\n while len(s)>0:\n if s[-1]==\'1\' and s[:-1]+\'0\' in keys:\n keys.remove(s[:-1]+\'0\')\n s = s[:-1]\n elif s[-1]==\'0\' and s[:-1]+\'1\' in keys:\n keys.remove(s[:-1]+\'1\')\n s = s[:-1]\n else:\n if s!="":\n keys.append(s)\n break\n if len(keys)!=0:\n keys = sorted(keys,key=len,reverse=True)\n while len(keys)!=0:\n print(keys)\n j = keys[0]\n keys.remove(j)\n if j[:-1]!="":\n keys.append(j[:-1])\n j = j[:-1]\n #merge node\n while len(j)>0:\n if j[-1]==\'1\' and j[:-1]+\'0\' in keys:\n keys.remove(j[:-1]+\'0\')\n keys.remove(j)\n j = j[:-1]\n if j!="":\n keys.append(j)\n elif j[-1]==\'0\' and j[:-1]+\'1\' in keys:\n keys.remove(j[:-1]+\'1\')\n keys.remove(j)\n j = j[:-1]\n if j!="":\n keys.append(j)\n else:\n break\n keys = sorted(keys,key=len,reverse=True)\n count+=1\n print("Bob" if count&1 ==0 else "Alice")\n\n\nif __name__=="__main__":\n main()', 'def main():\n N,L = map(int,input().split())\n keys = []\n grundy_num=0\n if N==1:\n print("Alice")\n exit()\n for i in range(N):\n s = input()\n #merge node:\n while len(s)>0:\n if s[-1]==\'1\' and s[:-1]+\'0\' in keys:\n keys.remove(s[:-1]+\'0\')\n s = s[:-1]\n elif s[-1]==\'0\' and s[:-1]+\'1\' in keys:\n keys.remove(s[:-1]+\'1\')\n s = s[:-1]\n else:\n if s!="":\n keys.append(s)\n break\n if len(keys):\n keys = sorted(keys,key=len,reverse=True)\n grundy_list = []\n while len(keys):\n j = keys[0]\n keys.remove(j)\n temp_s = list(reversed(bin(L-len(j)+1)))\n grundy_list.append(1 << temp_s.index(\'1\'))\n if j[:-1]!="":\n keys.append(j[:-1])\n j = j[:-1]\n #merge node\n while len(j)>0:\n if j[-1]==\'1\' and j[:-1]+\'0\' in keys:\n keys.remove(j[:-1]+\'0\')\n keys.remove(j)\n j = j[:-1]\n if j!="":\n keys.append(j)\n elif j[-1]==\'0\' and j[:-1]+\'1\' in keys:\n keys.remove(j[:-1]+\'1\')\n keys.remove(j)\n j = j[:-1]\n if j!="":\n keys.append(j)\n else:\n break\n keys = sorted(keys,key=len,reverse=True)\n grundy_num = grundy_list[0]\n for i in range(1,len(grundy_list)):\n grundy_num = grundy_num^grundy_list[i]\n print("Bob" if grundy_num==0 else "Alice")\n\n\nif __name__=="__main__":\n main()'] | ['Runtime Error', 'Accepted'] | ['s382143771', 's778538411'] | [134780.0, 4284.0] | [1876.0, 1746.0] | [1434, 1752] |
p03491 | u340781749 | 2,000 | 262,144 | For strings s and t, we will say that s and t are _prefix-free_ when neither is a prefix of the other. Let L be a positive integer. A set of strings S is a _good string set_ when the following conditions hold true: * Each string in S has a length between 1 and L (inclusive) and consists of the characters `0` and `1`. * Any two distinct strings in S are prefix-free. We have a good string set S = \\{ s_1, s_2, ..., s_N \\}. Alice and Bob will play a game against each other. They will alternately perform the following operation, starting from Alice: * Add a new string to S. After addition, S must still be a good string set. The first player who becomes unable to perform the operation loses the game. Determine the winner of the game when both players play optimally. | ["from collections import defaultdict\n\n\ndef solve(l, ss):\n xor = 0\n for d in range(min(ss), l + 1):\n sl = ss[d]\n sl.sort()\n while sl:\n s = sl.pop()\n ps = s[:-1]\n ss[d + 1].append(ps)\n if s[-1] == '1':\n if sl and sl[-1][:-1] == ps:\n sl.pop()\n else:\n xor ^= d & -d\n del ss[d]\n return xor\n\n\nn, l = map(int, input().split())\nss = defaultdict(list)\nfor s in (input() for _ in range(n)):\n ss[l - len(s) + 1].append(s)\n\nprint('Alice' if solve(l, ss) else 'Bob')\n", "from collections import defaultdict\n\n\ndef solve(l, ss):\n xor = 0\n for d in range(min(ss), l + 1):\n sl = ss[d]\n sl.sort()\n while sl:\n s = sl.pop()\n ps = s[:-1]\n ss[d + 1].append(ps)\n if s[-1] == '1' and sl and sl[-1][:-1] == ps:\n sl.pop()\n else:\n xor ^= d & -d\n del ss[d]\n return xor\n\n\nn, l = map(int, input().split())\nss = defaultdict(list)\nfor s in (input() for _ in range(n)):\n ss[l - len(s) + 1].append(s)\n\nprint('Alice' if solve(l, ss) else 'Bob')\n"] | ['Wrong Answer', 'Accepted'] | ['s067657731', 's915932952'] | [3956.0, 3836.0] | [418.0, 409.0] | [605, 577] |
p03497 | u005388620 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['lis = list(map(int, input().split()))\nlis2 = list(map(int, input().split()))\nn = lis[0]\nk = lis[1]\na = []\nb = []\nfor i in range(n):\n if lis2[i] not in a\n a.append(lis2[i])\n count = 0\n for j in range(i+1,n)\n if lis[j] == lis[i]\n count += 1\n b.append(count)\n\nif len(b) <= k\n print(0)\nelse:\n b.sort()\n b.reserve()\n swap = 0\n for i in range(k,len(b))\n swap += b[i]\n print(swap)', 'lis = list(map(int, input().split()))\nlis2 = list(map(int, input().split()))\nn = lis[0]\nk = lis[1]\na = []\nb = []\nfor i in range(n):\n if lis2[i] not in a:\n a.append(lis2[i])\n count = 0\n for j in range(i+1,n):\n if lis[j] == lis[i]:\n count += 1\n b.append(count)\n\nif len(b) <= k:\n print(0)\nelse:\n b.sort()\n b.reserve()\n swap = 0\n for i in range(k,len(b)):\n swap += b[i]\n print(swap)', 'lis = list(map(int, input().split()))\nn = lis[0]\nk = lis[1]\na = []\nb = []\nfor i in range(n):\n\tif lis[i] not in a\n\t\ta.append(lis[i])\n\t\tcount = 0\n\t\tfor j in range(i+1,n)\n\t\t\tif lis[j] == lis[i]\n\t\t\t\tcount += 1\n\t\tb.append(count)\nif len(b) <= k\n\tprint(0)\nelse:\n\tb.sort()\n\tb.reserve()\n\tswap = 0\n\tfor i in range(k,len(b))\n\t\tswap += b[i]\n\tprint(swap)\n', 'lis2 = list(map(int, input().split()))\nn = lis[0]\nk = lis[1]\nd = {}\n\nfor i in range(n):\n if lis2[i] not in d.keys():\n d[lis2[i]] = 1\n else:\n d[lis2[i]] += 1 \n \nif len(b) <= k:\n print(0)\nelse:\n a = d.values()\n a.sort()\n a.reverse()\n swap = 0\n for i in range(k,len(a)):\n swap += a[i]\n print(swap)', 'lis = list(map(int, input().split()))\nlis2 = list(map(int, input().split()))\nn = lis[0]\nk = lis[1]\na = []\nb = []\nfor i in range(n):\n if lis2[i] not in a:\n a.append(lis2[i])\n count = 0\n for j in range(i+1,n):\n if lis2[j] == lis2[i]:\n count += 1\n b.append(count)\n\nif len(b) <= k:\n print(0)\nelse:\n b.sort()\n b.reserve()\n swap = 0\n for i in range(k,len(b)):\n swap += b[i]\n print(swap)', 'lis = list(map(int, input().split()))\nlis2 = list(map(int, input().split()))\nn = lis[0]\nk = lis[1]\nd = {}\n\nfor i in range(n):\n if lis2[i] not in d.keys():\n d[lis2[i]] = 1\n else:\n d[lis2[i]] += 1 \n \nif len(b) <= k:\n print(0)\nelse:\n a = list(d.values())\n a.sort()\n a.reverse()\n swap = 0\n for i in range(k,len(a)):\n swap += a[i]\n print(swap)', 'lis = list(map(int, input().split()))\nlis2 = list(map(int, input().split()))\nn = lis[0]\nk = lis[1]\na = []\nb = []\nfor i in range(n):\n if lis2[i] not in a:\n a.append(lis2[i])\n count = 0\n for j in range(i+1,n):\n if lis2[j] == lis2[i]:\n count += 1\n b.append(count)\n\nif len(b) <= k:\n print(0)\nelse:\n b.sort()\n b.reverse()\n swap = 0\n for i in range(k,len(b)):\n swap += b[i]\n print(swap)', 'lis = list(map(int, input().split()))\nlis2 = input().split()\nn = lis[0]\nk = lis[1]\nd = {}\n\nfor i in range(n):\n if lis2[i] not in d.keys():\n d[lis2[i]] = 1\n else:\n d[lis2[i]] += 1 \n \nif len(list(d.values())) <= k:\n print(0)\nelse:\n a = list(d.values())\n a.sort()\n a.reverse()\n swap = 0\n for i in range(k,len(a)):\n swap += a[i]\n print(swap)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s360147163', 's450689429', 's498729289', 's574618267', 's597392050', 's724906640', 's750326897', 's700667600'] | [2940.0, 25124.0, 3064.0, 3064.0, 25476.0, 32284.0, 25464.0, 35616.0] | [17.0, 67.0, 17.0, 17.0, 2104.0, 141.0, 2104.0, 163.0] | [455, 460, 342, 348, 462, 392, 462, 391] |
p03497 | u060793972 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['def mycounter(d,i):\n if i in d:\n d[i]+=1\n else:\n d[i]=1\n return d\n\nn, k = list(map(int, input().rstrip().split()))\nprint(sum(sorted(mycounter(list(map(int, input().rstrip().split()))).values(), reverse=True)[k:]))\n', 'n, k = list(map(int, input().rstrip().split()))\nprint(sum(sorted(Counter(list(map(int, input().rstrip().split()))).values(), reverse=True)[k:]))', 'def mycounter(d,i):\n if i in d:\n d[i]+=1\n else:\n d[i]=1\n return d\n\n\nn,k=map(int,input().split())\nd=dict()\nfor i in map(int,input().split()):\n d=mycounter(d,i)\np=0\nf=len(d)\n#print(f)\n\nfor i in sorted(d.values()):\n if f>k:\n p+=i\n f-=1\n else:\n print(p)\n break'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s346992458', 's981593212', 's246326059'] | [24748.0, 3060.0, 41120.0] | [66.0, 17.0, 167.0] | [237, 144, 337] |
p03497 | u076306174 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['import math\nimport heapq\nfrom collections import Counter\n\n\n\n\nN,K=map(int, input[0].split()) \nA=list(map(int, input[1].split())) \n\nS=Counter(A)\ns= S.most_common(K)\n\nprint(N-[sum(x) for x in zip(*s)][1])\n', 'import math\nimport heapq\nfrom collections import Counter\n\n\n\n\nN,K=map(int, input().split()) \nA=list(map(int, input().split())) \n\nS=Counter(A)\ns= S.most_common(K)\n\nprint(N-[sum(x) for x in zip(*s)][1])\n'] | ['Runtime Error', 'Accepted'] | ['s125194838', 's694332073'] | [3316.0, 32540.0] | [22.0, 140.0] | [590, 588] |
p03497 | u080364835 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['from collections import Counter\nn, k = map(int, input().split())\nal = sorted(Counter(input().split()).values(), reverse=True)\n\nprint(al)\nprint(sum(al[k:]))\n', 'from collections import Counter\nn, k = map(int, input().split())\nal = sorted(Counter(input().split()).values(), reverse=True)\nprint(sum(al[k:]))\n'] | ['Wrong Answer', 'Accepted'] | ['s388521155', 's130978486'] | [36000.0, 35996.0] | [98.0, 80.0] | [156, 145] |
p03497 | u089142196 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['N=int(input())\nA=list(map(int,input().split()))\n\ncnt=0\nbflag=False\nsflag=False\n\nfor i in range(1,N):\n if A[i]>A[i-1]:\n if sflag==True:\n cnt+=1\n bflag=False\n sflag=False\n else:\n bflag=True\n sflag=False\n elif A[i]<A[i-1]:\n if bflag==True:\n cnt+=1\n bflag=False\n sflag=False\n else: \n bflag=False\n sflag=True \n else:\n pass\n \nprint(cnt+1)', 'N=int(input())\nA=list(map(int,input().split()))\n\ncnt=0\nbflag=False\nsflag=False\n\nfor i in range(1,N):\n if A[i]>A[i-1]:\n if sflag==True:\n cnt+=1\n bflag=False\n sflag=False\n else:\n bflag=True\n sflag=False\n elif A[i]<A[i-1]:\n if bflag==True:\n cnt+=1\n bflag=False\n sflag=False\n else: \n bflag=False\n sflag=True \n else:\n pass\n \nprint(cnt+1)', 'N,K=map(int,input().split())\nA=list(map(int,input().split()))\n\nfrom collections import Counter\ncnt=0\n\na=Counter(A)\nb=list(a.values())\nb.sort()\nleng=len(b)\n\nfor item in b:\n if leng>K:\n cnt+=item\n leng-=1\n \nprint(cnt)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s263482270', 's484832272', 's697221752'] | [3064.0, 3064.0, 32440.0] | [17.0, 17.0, 150.0] | [407, 407, 225] |
p03497 | u114648678 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['import collections\nn,k=map(int,input().split())\na=list(map(int,input().split()))\ncnt=collections.Counter(a)\ncnt.most_common()\nans=0\nfor i in range(k):\n print(ans[i][1])\n ans+=cnt[i][1]\npeint(ans)', 'import collections\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nc=collections.Counter(a)\nd=c.most_common()\nans=0\nfor i in range(len(d)):\n ans+=d[i][1]\nprint(n-ans)', 'import collections\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nc=collections.Counter(a)\nd=c.most_common()\nans=0\nfor i in range(min(k,len(d))):\n ans+=d[i][1]\nprint(n-ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s243569772', 's530823916', 's321942970'] | [39320.0, 39348.0, 39320.0] | [156.0, 191.0, 156.0] | [197, 181, 188] |
p03497 | u166340293 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['N,K=map(int,input().split())\na=input().split()\n\nlist.sort(a)\n \ncount=1\nsize=0\nb=[]\nfor p in range (N-1):\n if a[p]==a[p+1]:\n count+=1\n else:\n b.append(count)\n count=1\n size+=1\n\nlist.sort(b,reverse=True)\n\ns=0\nif K<size:\n for u in range (K):\n s+=b[u]\nelse:\n s=N\nprint(N-s)', 'N,K=map(int,input().split())\na=input().split()\n\nlist.sort(a)\n \ncount=1\nsize=0\nb=[]\nfor p in range (N-1):\n if a[p]==a[p+1]:\n count+=1\n else:\n b.append(count)\n count=1\n size+=1\n\nb.append(count)\nsize+=1\n \nprint(b)\nlist.sort(b,reverse=True)\n\ns=0\nif K<size:\n for u in range (K):\n s+=b[u]\nelse:\n s=N\nprint(N-s)', 'N,K=map(int,input().split())\na=input().split()\n\nfor i in range (N):\n for j in range (N-1):\n if a[j]>a[j+1]:\n g=a[j]\n a[j]=a[j+1]\n a[j+1]=g\n \ncount=1\nsize=0\nb=[]\nfor p in range (N-1):\n if a[p]==a[p+1]:\n count+=1\n else:\n b.append(count)\n count=1\n size+=1\n\nfor q in range (size):\n for r in range (size-1):\n if b[r]<b[r+1]:\n g=b[r]\n b[r]=b[r+1]\n b[r+1]=g\n\ns=0\nif K<size:\n for u in range (K):\n s+=b[u]\nelse:\n s=N\nprint(N-s)', 'N,K=map(int,input().split())\na=input().split()\n\nlist.sort(a)\n \ncount=1\nsize=0\nb=[]\nfor p in range (N-1):\n if a[p]==a[p+1]:\n count+=1\n else:\n b.append(count)\n count=1\n size+=1\n\nb.append(count)\nsize+=1\n \nlist.sort(b,reverse=True)\n\ns=0\nif K<size:\n for u in range (K):\n s+=b[u]\nelse:\n s=N\nprint(N-s)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s503796641', 's808209050', 's978875889', 's451103292'] | [18056.0, 18984.0, 18800.0, 19316.0] | [235.0, 248.0, 2105.0, 232.0] | [291, 620, 478, 611] |
p03497 | u193264896 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ["import sys\nfrom collections import Counter\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N, K = map(int, readline().split())\n A = list(map(int, readline().split()))\n count = Counter(A)\n L = len(count)\n print(L)\n if L<=K:\n print(0)\n else:\n B = list(count.values())\n B.sort()\n print(sum(B[:L-K]))\n\n\n\nif __name__ == '__main__':\n main()", "import sys\nfrom collections import Counter\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N, K = map(int, readline().split())\n A = list(map(int, readline().split()))\n count = Counter(A)\n L = len(count)\n if L<=K:\n print(0)\n else:\n B = list(count.values())\n B.sort()\n print(sum(B[:L-K]))\n\n\n\nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s594899457', 's127598706'] | [34260.0, 34260.0] | [92.0, 93.0] | [458, 445] |
p03497 | u193927973 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['N, K=map(int, input().split())\nA=list(map(int, input().split()))\nsa=set(A)\nif len(sa)<=K:\n print(0)\nelse:\n \n sub=len(sa)-K\n \n A.sort()\n A.append(A[-1])\n a=[0]*len(sa)\n j=0\n for i in range(N):\n a[j]+=1\n if A[i]!=A[i+1]:\n j+=1\n \n a.sort()', 'N, K=map(int, input().split())\nA=list(map(int, input().split()))\nsa=set(A)\nif len(sa)<=K:\n print(0)\nelse:\n \n sub=len(sa)-K\n \n A.sort()\n A.append(A[-1])\n a=[0]*len(sa)\n j=0\n for i in range(N):\n a[j]+=1\n if A[i]!=A[i+1]:\n j+=1\n \n a.sort()\n print(sum(a[:sub]))'] | ['Wrong Answer', 'Accepted'] | ['s176730773', 's377310017'] | [26144.0, 27012.0] | [232.0, 236.0] | [331, 353] |
p03497 | u200239931 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['import math\nimport sys\nfrom collections import Counter\ndef getinputdata():\n\n \n array_result = []\n \n data = input()\n\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n try:\n\n\n while flg:\n\n data = input()\n\n array_temp = []\n\n if(data != ""):\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n\n return array_result\n\n\n\n\n\narr_data = getinputdata()\n\nn = int(arr_data[0][0])\nk = int(arr_data[0][1])\n\narr=arr_data[1]\n\n\nlist01=Counter(arr)\n\n#print(list01,len(list01))\n\n#print(list01)\n\ncnt=0\nif len(list01) > k:\n \n for key,val in sorted(list01.items(),reverse=True):\n\n print(key,val,len(list01))\n\n cnt+=list01.pop(key)\n \n \n if len(list01)==k:\n \n break\n \n\nprint(cnt)\n', 'import math\nimport sys\nfrom collections import Counter\ndef getinputdata():\n\n \n array_result = []\n \n data = input()\n\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n try:\n\n\n while flg:\n\n data = input()\n\n array_temp = []\n\n if(data != ""):\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n\n return array_result\n\n\n\n\n\narr_data = getinputdata()\n\nn = int(arr_data[0][0])\nk = int(arr_data[0][1])\n\narr=arr_data[1]\n\n\nlist01=Counter(arr)\n\n#print(list01,len(list01))\n\n#print(list01)\n\ncnt=0\nif len(list01) > k:\n \n for key,val in sorted(list01.items(),key=lambda x: x[1]):\n\n# print(key,val,len(list01))\n\n cnt+=list01.pop(key)\n \n \n if len(list01)==k:\n \n break\n \n\nprint(cnt)\n'] | ['Wrong Answer', 'Accepted'] | ['s412931686', 's758207580'] | [46352.0, 44060.0] | [859.0, 254.0] | [917, 924] |
p03497 | u222668979 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['n, k = map(int, input().split())\na = list(map(int, input().split()))\ncnt = {}\n\nfor i in a:\n if i in cnt.keys():\n cnt[i] += 1\n else:\n cnt[i] = 1\n\n', 'n, k = map(int, input().split())\na = list(map(int, input().split()))\nball = {}\n\nfor i in a:\n if i in ball:\n ball[i] += 1\n else:\n ball[i] = 1\n\nball = sorted(ball.items(), key=lambda x: -x[1])\n\nans = 0\nif len(ball) > k:\n for i in range(k):\n ans += ball[i][1]\n ans = n - ans\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s179327145', 's211832613'] | [32184.0, 39804.0] | [129.0, 157.0] | [165, 316] |
p03497 | u226191225 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['n, k = map(int,input().split())\na = list(map(int,input().split()))\ncnt = [0] * n\nans = 0\nfor i in a:\n cnt[i-1] += 1\n\nif len(set(a)) <= k:\n print(0)\n exit()\nelse:\n for i in sorted(cnt):\n if i == 0:\n continue\n else:\n ans += i\n k -= 1\n if len(set(a)) <= k:\n print(ans)\n exit()', 'import collections\nimport sys\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nc = collections.Counter(A)\ncnt = 0\nif len(c)<= K:\n print(0)\n sys.exit()\n\nfor i in c.most_common(K):\n cnt += i[1]\n\nprint(N-cnt)\n'] | ['Wrong Answer', 'Accepted'] | ['s731442385', 's869130742'] | [33140.0, 32564.0] | [2104.0, 140.0] | [373, 233] |
p03497 | u247211039 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['N K= map(int, input().split())\nA =list(map(int, input().split()))\n\nAset =list(set(A))\nB=[0]*len(Aset)\ncnt =0\n\nfor i in range(len(Aset)):\n for j in range(len(A)):\n if Aset[i] == A[j]:\n cnt += 1\n B[i] = cnt\n cnt =0\n\nB=sorted(B)[::-1] \n\nans =0\n\nfor i in range(K,len(B)):\n ans +=B[i]\n \nprint(ans) ', 'N,K=map(int, input().split())\na=list(map(int, input().split()))\n\n\nimport collections\n\nc = collections.Counter(a)\nc2=sorted(c.values())\n\nsum=0\nfor i in range(len(c)-K):\n sum+=c2[i]\nprint(sum)'] | ['Runtime Error', 'Accepted'] | ['s898589349', 's999097423'] | [8912.0, 34752.0] | [24.0, 118.0] | [307, 197] |
p03497 | u276192130 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['n, k = map(int, input().split())\na = list(map(int, input().split()))\nb = []\nfor i in set(a):\n b.append(a.count(i))\nb.sort()\nans = 0\nfor i in range(len(set(a)) - k):\n ans += b[i]\n print(ans)\nprint(ans)', 'n, k = map(int, input().split())\na = list(map(int, input().split()))\nimport collections\ncount_dict = collections.Counter(a)\n# print(count_dict.most_common())\nans = 0\nunique = count_dict.most_common()\nfor i in range(len(count_dict) - k):\n ans += unique[len(count_dict)-i-1][1]\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s464622524', 's378644965'] | [25644.0, 39348.0] | [2104.0, 215.0] | [209, 290] |
p03497 | u280269055 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['from collections import Counter\n\nn,k = map(int, input().split())\na = [input() for _ in range(n)]\nc = Counter(a)\nt = len(c) - k\nr = 0\n\nif t > 0:\n serial = list(map(list, c.most_common[-t:]))\n for s in serial:\n r += s[1]\n\nprint(r)', 'from collections import Counter\n\nn,k = map(int, input().split())\na = input().split()\nc = Counter(a)\nt = len(c) - k\nr = 0\n\nif t > 0:\n serial = list(map(list, c.most_common[-t:]))\n for s in serial:\n r += s[1]\n\nprint(r)', 'from collections import Counter\n\nn,k = map(int, input().split())\na = input().split()\nc = Counter(a)\nt = len(c) - k\nr = 0\n\nif t > 0:\n serial = c.most_common[-t:]\n for s in serial:\n r += s[1]\n\nprint(r)', 'from collections import Counter\n\nn,k = map(int, input().split())\na = input().split()\nc = Counter(a)\nt = len(c) - k\nr = 0\n\nif t > 0:\n serial = c.most_common()[-t:]\n for s in serial:\n r += s[1]\n\nprint(r)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s482052811', 's761936821', 's972046990', 's318443754'] | [6004.0, 35996.0, 35996.0, 44056.0] | [24.0, 76.0, 88.0, 182.0] | [241, 229, 212, 214] |
p03497 | u298297089 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['from collections import Counter\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\ndA = Counter(A)\nif len(dA) - K <= 0:\n print(0)\n exit()\nprint(sum(sorted(dA.values())[:len(dA)-K])))', 'from collections import Counter\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\ndA = Counter(A)\nif len(dA) - K <= 0:\n print(0)\n exit()\nprint(sum(sorted(dA.values())[:len(dA)-K] ))\n'] | ['Runtime Error', 'Accepted'] | ['s061732128', 's576282999'] | [2940.0, 32540.0] | [17.0, 99.0] | [202, 203] |
p03497 | u332253305 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['n,k=int(input()),int(input())\na=list(map(int,input().split()))\ns=set(a)\nif len(s)<=k:\n print(0)\nelse:\n print(len(s)-k)\n', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\ns=[0 for i in range(n)]\nz=set(a)\ny=len(z)\nfor x in a:\n s[x]+=1\nb=sorted(s)\nf=0\nans=0\nfor x in b:\n if x!=0:\n f+=1\n ans+=x\n if f>=y-k:\n \tbreak\nprint(ans)\n', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\ns=[0 for i in range(n)]\nz=set(a)\ny=len(z)\nfor x in a:\n s[x-1]+=1\nb=sorted(s)\nf=0\nans=0\nfor x in b:\n if x!=0:\n f+=1\n ans+=x\n if f>=y-k:\n \tbreak\nprint(ans)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s220570600', 's802570087', 's732797006'] | [3060.0, 26812.0, 26812.0] | [17.0, 141.0, 179.0] | [125, 242, 244] |
p03497 | u350997995 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['import collections\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nc = collections.Counter(A).most_common()[::-1]\nprint(c)\nk = len(c)\nif k<=K:print(0)\nelse: print(sum([e[1] for e in c[:k-K]]))', 'from collections import Counter\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nC = Counter(A).most_common()\nC.sort(key=lambda x:x[1])\nif len(C)<=K:print(0)\nelse:\n ans = 0\n for i in range(len(C)-K):\n ans += C[i][1]\n print(ans)'] | ['Wrong Answer', 'Accepted'] | ['s415333985', 's488199060'] | [39344.0, 39320.0] | [257.0, 204.0] | [210, 260] |
p03497 | u369502636 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['n,k = map(int,input().split())\na = list(map(int,input().split()))\nkaburi = []\n\nfor i in range(n):\n if not a[i] in kaburi:\n kaburi.append(a[i])\n\nkaisu = 0\n\nwhile True:\n global p,q\n p = n\n q = 0\n if k >= len(kaburi):\n print(kaisu)\n break\n else:\n for j in range(len(kaburi)):\n p = min(p,a.count(kaburi[j]))\n if p > a.count(kaburi[j]):\n q = kaburi[j]\n kaisu += p\n print(p,q,kaisu,len(kaburi))\n kaburi.pop(q)', 'n,k = map(int,input().split())\na = list(map(int,input().split()))\nkaburi = []\n\nfor i in range(n):\n if not a[i] in kaburi:\n kaburi.append(a[i])\n\nkaisu = 0\n\nwhile True:\n p = n\n q = 0\n if k >= len(kaburi):\n print(kaisu)\n break\n else:\n for j in range(len(kaburi)):\n p = min(p,a.count(kaburi[j]))\n if p > a.count(kaburi[j]):\n q = kaburi[j]\n kaisu += p\n print(p,q,kaisu,len(kaburi))\n kaburi.remove(q)', 'n,k = map(int,input().split())\na = list(map(int,input().split()))\nkosu = [0]*n\nkaburi = []\n\nfor i in range(n):\n kosu[a[i]-1] += 1\n\nfor j in range(n):\n if kosu[j] != 0:\n kaburi.append(kosu[j])\n\nkaburi.sort()\nprint(sum(kaburi[:len(kaburi)-k]))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s646991374', 's809223824', 's576273257'] | [32252.0, 32348.0, 32276.0] | [2206.0, 2206.0, 139.0] | [507, 495, 254] |
p03497 | u411923565 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['#24 C - Not so Diverse\nimport collections \nN,K = map(int,input().split())\nA = list(map(int,input().split()))\n\ncnt = collections.Counter(A)\nprint(cnt)\n\ndiff = len(cnt.keys()) - K\n\nvalues = sorted(list(cnt.values()),reverse = False)\nans = values[:diff]\nprint(sum(ans))', '#24 C - Not so Diverse AC\nimport collections \nN,K = map(int,input().split())\nA = list(map(int,input().split()))\n\ncnt = collections.Counter(A)\n\ndiff = len(cnt.keys()) - K\n\nvalues = sorted(list(cnt.values()),reverse = False)\nans = values[:diff]\nprint(sum(ans))'] | ['Wrong Answer', 'Accepted'] | ['s652841984', 's559515643'] | [57024.0, 35452.0] | [179.0, 99.0] | [325, 317] |
p03497 | u417014669 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['n=map(int,input().split())\nt= list(map(int,input().split()))\n\nimport sys\nimport collections\nc = collections.Counter(t)\nc=sorted(list(c.values()))\nans=0\ndelete_count=len(c)-k\nif delete_count<=0:\n print(0)\n sys.exit()\nelse:\n for i in range(delete_count):\n if len(c)>k:\n ans+=c[i]\n \nprint(ans)\nsys.exit()\n \n\n', 'n=map(int,input().split())\nt= list(map(int,input().split()))\n\nimport sys\nimport collections\nc = collections.Counter(t)\nc=sorted(list(c.values()))\nans=0\ndelete_count=len(c)-k\nif delete_count<=0:\n print(0)\nelse:\n for i in range(delete_count):\n if len(c)>k:\n ans+=c[i]\n \nprint(ans)\nsys.exit()\n \n\n', 'n,k=map(int,input().split())\nt= list(map(int,input().split()))\n\nimport sys\nimport collections\nc = collections.Counter(t)\nc=sorted(list(c.values()))\nans=0\ndelete_count=len(c)-k\nif delete_count<=0:\n print(0)\n sys.exit()\nelse:\n for i in range(delete_count):\n if len(c)>k:\n ans+=c[i]\n \nprint(ans)\nsys.exit()\n \n\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s271628930', 's399203350', 's937823519'] | [32440.0, 32544.0, 32440.0] | [98.0, 96.0, 148.0] | [350, 335, 352] |
p03497 | u423966555 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['from collections import Counter\nN, K = map(int, input().split())\nA = list(map(int ,input().split()))\n\nd = Counter(A)\nd.most_common()\nn =len(d)\nans = 0\nif n <= K:\n print(0)\n exit()\nelse:\n for i in range(K,n):\n ans += d[i][1]\nprint(ans)', 'from collections import Counter\nN, K = map(int, input().split())\nA = list(map(int ,input().split()))\n\nd = Counter(A)\nd.most_common()\nn =len(d_)\nans = 0\nif n <= K:\n print(0)\n exit()\nelse:\n for i in range(K,n):\n ans += d[i][1]\nprint(ans)', 'from collections import Counter\nN, K = map(int, input().split())\nA = list(map(int ,input().split()))\n\nd = Counter(A)\n\nd_ = sorted(d.items(), key=lambda x:x[1], reverse=True)\nn =len(d_)\nans = 0\nif n <= K:\n print(0)\n exit()\nelse:\n for i in range(K,n):\n ans += d_[i][1]\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s162370421', 's241606373', 's016994952'] | [44364.0, 44428.0, 43292.0] | [127.0, 124.0, 154.0] | [250, 251, 293] |
p03497 | u440975163 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['s, t = map(int, input().split())\nu = list(input())\nfrom collections import Counter\nv = Counter(u)\nw = 0\nfor i in range(s):\n if len(v) <= t:\n print(w)\n break\n else:\n del v[min(v, key = v.get)]\n w += 1', 'from collections import Counter\nn,k = map(int,input().split())\nL = list( map(int,input().split()))\nl = len(L)\nL = Counter(L)\nL = sorted(list(L.most_common(k)))\n\nans = 0\nfor i in range(len(L)):\n ans += L[i][1]\nprint(l - ans)'] | ['Wrong Answer', 'Accepted'] | ['s735901263', 's685463078'] | [15744.0, 32540.0] | [119.0, 123.0] | [234, 226] |
p03497 | u488401358 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['N,K=map(int,input().split())\nA=list(map(int,input().split()))\n\nB=[0]*(N+1)\nfor i in range(0,N):\n B[A[i]]=B[A[i]]+1\nC=[]\nfor i in range(0,N+1):\n if B[i]!=0:\n C.append(B[i])\nprint(C)\nC.sort()\nprint(C)\nif K>=len(C):\n print(0)\nelse:\n s=0\n for i in range(0,len(C)-K):\n s=s+C[i]\n print(s)\n', 'N,K=map(int,input().split())\nA=list(map(int,input().split()))\n\nB=[0]*(N+1)\nfor i in range(0,N):\n B[A[i]]=B[A[i]]+1\nC=[]\nfor i in range(0,N+1):\n if B[i]!=0:\n C.append(B[i])\nC.sort()\nif K>=len(C):\n print(0)\nelse:\n s=0\n for i in range(0,len(C)-K):\n s=s+C[i]\n print(s)\n'] | ['Wrong Answer', 'Accepted'] | ['s354933990', 's184528944'] | [24996.0, 25716.0] | [211.0, 183.0] | [315, 297] |
p03497 | u488884575 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['n, k = map(int, input().split())\nA = list(map(int, input().split()))\n\nimport collections\nc = collections.Counter(A)\nprint(c)\nif len(c.keys()) > k:\n num = len(c.keys()) - k\n print(sum(sorted(c.values())[:num]))\nelse:\n print(0)', 'n, k = map(int, input().split())\nA = list(map(int, input().split()))\n\nimport collections\nc = collections.Counter(A)\n#print(c)\nif len(c.keys()) > k:\n num = len(c.keys()) - k\n print(sum(sorted(c.values())[:num]))\nelse:\n print(0)\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s493965850', 's674405955'] | [53556.0, 32440.0] | [246.0, 107.0] | [234, 238] |
p03497 | u518042385 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['n,m=map(int,input().split())\nl=list(map(int,input().split()))\nl1=[]\nl2=[]\nc=0\nfor i in l:\n if i in l1:\n l2[l1.index(i)]+=1\n else:\n l1.append(i)\n l2.append(1)\nif m>=len(l2):\n print(0)\nelse:\n l2=sorted(l2)\n for i in range(m):\n c+=l2[i]\n print(c)\n ', 'n,m=map(int,input().split())\nl=list(map(int,input().split()))\nd={}\n\nc=0\nfor i in l:\n if i in d:\n d[i]+=1\n else:\n d[i]=1\nl1=d.values()\nif m>=len(l1):\n print(0)\nelse:\n l1=sorted(l1)\n for i in range(len(l1)-m):\n c+=l1[i]\n print(c)\n '] | ['Wrong Answer', 'Accepted'] | ['s915163646', 's874930415'] | [25644.0, 34172.0] | [2104.0, 146.0] | [264, 245] |
p03497 | u536113865 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['from collections import Counter\nimport sys\n\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nc = Counter(a)\n\nif k>=len(c):\n print(0)\n sys.exit()\nd = c.values()\nprint(sorted(d))\nprint(sum(sorted(d)[:len(c)-k]))\n', 'from collections import Counter\nimport sys\n\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nc = Counter(a)\n\nif k>=len(c):\n print(0)\n sys.exit()\nd = c.values()\nprint(sum(sorted(d)[:len(c)-k]))\n'] | ['Wrong Answer', 'Accepted'] | ['s850707087', 's056614771'] | [32564.0, 32556.0] | [123.0, 105.0] | [239, 222] |
p03497 | u581403769 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['n, k = map(int, input().split())\na = list(map(int, input().split()))\n\na1 = sorted(a)\na2 = []\ncount = 0\nfor i in range(n - 1):\n if a1[i] == a1[i + 1]:\n count += 1\n else:\n a2.append(count)\n break\na2.append(count)\nl = sorted(a2)\nprint(sun(l[:len(l) - k - 1]))', 'n, k = map(int, input().split())\na = list(map(int, input().split()))\n\na1 = sorted(a)\na2 = []\ncount = 1\nfor i in range(n - 1):\n if a1[i] == a1[i + 1]:\n count += 1\n else:\n a2.append(count)\n count = 1\na2.append(count)\nl = sorted(a2)\nprint(sum(l[:len(l) - k]))'] | ['Runtime Error', 'Accepted'] | ['s914170492', 's006856078'] | [32192.0, 32180.0] | [104.0, 168.0] | [283, 283] |
p03497 | u593567568 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['from collections import Counter\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nC = Counter(A).most_common()\nL = len(C)\n\nif L <= K:\n print(0)\n exit()\n\nans = 0\ncnt = 0\nfor v in C.values():\n cnt += 1\n if K < cnt:\n ans += v\n \nprint(ans)\n', 'from collections import Counter\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nC = Counter(A).most_common()\nL = len(C)\n\nif L <= K:\n print(0)\n exit()\n\nans = 0\ncnt = 0\nfor k,v in C:\n cnt += 1\n if K < cnt:\n ans += v\n \nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s186090927', 's708837231'] | [39344.0, 39352.0] | [152.0, 206.0] | [264, 257] |
p03497 | u612721349 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['from collections import defaultdict\n\nn, k = map(int, input().split())\nal = [int(i) for i in range(n)]\n\n\nd = defaultdict(int)\nfor a in al:\n d[a] += 1\n\n\nans = 0\nif d.keys() > k:\n \n v = d.values()\n v.sort()\n ans = sum(v[:d.keys() - k])\nprint(ans)', 'from collections import defaultdict\n\nn, k = map(int, input().split())\nal = [int(i) for i in input().split()]\n\n\nd = defaultdict(int)\nfor a in al:\n d[a] += 1\n\n\nans = 0\nif d.keys() > k:\n \n v = d.values()\n v.sort()\n ans = sum(v[:d.keys() - k])\nprint(ans)', 'from collections import defaultdict\n\nn, k = map(int, input().split())\nal = [int(i) for i in input().split()]\n\n\nd = defaultdict(int)\nfor a in al:\n d[a] += 1\n\n\nans = 0\nif len(d.keys()) > k:\n \n v = list(d.values())\n v.sort()\n ans = sum(v[:len(d.keys()) - k])\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s060238664', 's647106487', 's642893049'] | [29808.0, 32540.0, 32540.0] | [113.0, 149.0, 167.0] | [487, 494, 510] |
p03497 | u640922335 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['from collections import Counter\nN,K=map(int,input().split())\nN=list(map(int,input().split()))\nA=Counter(N)\nC=list(A.values())\nC=C.sort(reverse=True)\nprint(C)\nif len(C)<=K:\n print(0)\nelse:\n ans=sum(C[-(len(C)-K):])\n print(ans)', 'from collections import Counter\nN,K=map(int,input().split())\nN=list(map(int,input().split()))\nA=Counter(N)\nC=list(A.values())\nC=C.sort(reverse=True)\nif len(C)<=K:\n print(0)\nelse:\n ans=sum(C[-(len(C)-K):])\n print(ans)', 'from collections import Counter\nN,K=map(int,input().split())\nN=list(map(int,input().split()))\nA=Counter(N)\nC=list(A.values())\nC.sort(reverse=True)\nif len(C)<=K:\n print(0)\nelse:\n ans=sum(C[-(len(C)-K):])\n print(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s022007086', 's797037768', 's466176868'] | [35252.0, 35248.0, 35240.0] | [99.0, 103.0, 103.0] | [234, 225, 223] |
p03497 | u742729271 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['from collections import Counter \n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\ns = len(set(A))\nt = s-K\n\nc = Counter(A)\nnum = list(c)\nnum.sort()\nprint(num,t)\nprint(sum(num[:t])) if t>0 else print(0)', 'from collections import Counter \n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\ns = len(set(A))\nt = s-K\n\nc = Counter(A)\nnum = list(c.values())\nnum.sort()\n\nprint(sum(num[:t])) if t>0 else print(0)'] | ['Wrong Answer', 'Accepted'] | ['s866296208', 's706782037'] | [39088.0, 38944.0] | [159.0, 110.0] | [221, 218] |
p03497 | u760771686 | 2,000 | 262,144 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | ['from collections import defaultdict\nN, K = map(int,input().split())\nA = list(map(int,input().split()))\nD = defaultdict(int)\nfor a in A:\n D[a]+=1\nD = sorted(D.values())\nans = 0\nif len(D)<=K:\n print(ans)\nelse:\n print(sum(D[:K]))', 'from collections import defaultdict\nN, K = map(int,input().split())\nA = list(map(int,input().split()))\nD = defaultdict(int)\nfor a in A:\n D[a]+=1\nD = sorted(D.values())\nans = 0\nif len(D)<=K:\n print(ans)\nelse:\n print(sum(D[:len(D)-K]))'] | ['Wrong Answer', 'Accepted'] | ['s454741034', 's955825343'] | [35344.0, 35220.0] | [125.0, 128.0] | [231, 238] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.