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
p04001
u890485928
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
['s = input()\nn = len(s)\nans = 0\n\nfor i in range(2 ** (n - 1)) :\n k = int(s[0])\n for j in range(n - 1):\n if (i >> j) & 1 :\n ans += k\n print(k , "if")\n k = 0\n k *= 10\n k += int(s[j + 1])\n ans += k\n print(k)\n\nprint(ans)', 's = input()\nn = len(s)\nans = 0\n\nfor i in range(2 ** (n - 1)) :\n k = int(s[0])\n for j in range(n - 1):\n if (i >> j) & 1 :\n ans += k\n k = 0\n k *= 10\n k += int(s[j + 1])\n ans += k\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s998104303', 's955314281']
[3572.0, 3060.0]
[24.0, 20.0]
[281, 240]
p04001
u914992391
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
['from sys import stdin\n\ndef main():\n S=input()\n andbit = 2**10 -1\n ans = 0\n length = 2**(len(S) -1)\n \n for i in range (length):\n bitup = andbit & i\n bitcheck = 1\n tmp=0\n for j in range(1,len(S),1):\n if bitup & bitcheck > 0:\n ans += int(S[tmp:j])\n tmp = j\n bitcheck = bitcheck << 1\n ans += int(S[tmp:len(S)])\n print(ans)\n\ninput = lambda: stdin.readline()\nmain()\n', 'from sys import stdin\n\ndef main():\n S=input()\n andbit = 2**10 -1\n ans = 0\n length = 2**(len(S) -1)\n \n # print("length:{}".format(length))\n for i in range (length):\n bitup = andbit & i\n # print("bin(bitup):{}".format(bin(bitup)))\n bitcheck = 1\n tmp=0\n for j in range(1,len(S),1):\n # print("bitup & bitcheck:{}".format(bitup & bitcheck))\n if bitup & bitcheck > 0:\n # print("S[tmp:j]:{}".format(S[tmp:j]))\n ans += int(S[tmp:j])\n tmp = j\n bitcheck = bitcheck << 1\n # print("S[tmp:len(S)]:{}".format(S[tmp:len(S)]))\n ans += int(S[tmp:len(S)])\n\n print(ans)\n\ninput = lambda: stdin.readline()\nmain()\n', 'from sys import stdin\n\ndef main():\n S=input()\n andbit = 2**10 -1\n ans = 0\n length = 2**(len(S) -1)\n \n for i in range (length):\n bitup = andbit & i\n bitcheck = 1\n tmp=0\n for j in range(1,len(S),1):\n if bitup & bitcheck > 0:\n ans += int(S[tmp:j])\n tmp = j\n bitcheck = bitcheck << 1\n ans += int(S[tmp:len(S)])\n print(ans)\n\ninput = lambda: stdin.readline()\nmain()\n', 'from sys import stdin\n\nS=input()\nandbit = 2**10 -1\nans = 0\nlength = 2**(len(S) -1)\n \nfor i in range (length):\n bitup = andbit & i\n bitcheck = 1\n tmp=0\n for j in range(1,len(S),1):\n if bitup & bitcheck > 0:\n ans += int(S[tmp:j])\n tmp = j\n bitcheck = bitcheck << 1\n ans += int(S[tmp:len(S)])\nprint(ans)\n\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s043319306', 's272707119', 's400862312', 's580931007']
[3064.0, 3064.0, 3064.0, 3064.0]
[19.0, 19.0, 19.0, 20.0]
[438, 699, 438, 326]
p04001
u916069341
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
[' total = 0', 's = input()\ntotal = 0\nfor i in range(2 ** len(s)):\n for j in range(len(s)):\n if ((i >> j) & 1):\n total += int(s[j]) \nprint(total)\n', 's = input()\nn = len(s)\n\nans = 0\n\nfor bit in range(1 << (n - 1)):\n f = s[0]\n\n for i in range(n - 1):\n \n if bit & (1 << i):\n f += "+"\n f += s[i + 1]\n\n ans += sum(map(int, f.split("+")))\n\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s165271847', 's387465049', 's647949575']
[2940.0, 2940.0, 3060.0]
[17.0, 21.0, 22.0]
[13, 151, 300]
p04001
u933622697
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
["s = input()\n\nanswer = 0\nfor canditate in range(1 << len(s)-1):\n combi = s[0]\n for n_digit in range(len(s) - 1):\n if (canditate >> n_digit) & 1:\n combi += '+'\n combi += s[n_digit+1] \n print(combi)\n answer += eval(combi)\n\nprint(answer)\n", 's = input()\nn = 0\nans = 0\nfor n in range( 1 << len(s)):\n p = 0\n for i in range(len(s)):\n if n & (1 << i):\n ans += int(s[p:i + 1])\n p = i + 1\n if p < len(s):\n ans += int(s[p:])\nprint(ans)', "s = input()\n\nanswer = 0\nfor canditate in range(1 << len(s)-1):\n combi = s[0]\n for n_digit in range(len(s) - 1):\n if (canditate >> n_digit) & 1:\n combi += '+'\n combi += s[n_digit+1] \n answer += eval(combi)\n\nprint(answer)\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s195044233', 's944885450', 's040533981']
[3060.0, 3060.0, 3060.0]
[28.0, 22.0, 27.0]
[334, 231, 317]
p04001
u951601135
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
["\ns=input()\nl=list(s)\nprint(l)\n#lst=[]\nlst_2=0\n\nfor i in range(1<<(len(s)-1)):\n st=l[0]\n for j in range(len(s)-1):\n if (i>>j)&1:\n st+=l[j+1]\n else:\n st+='+'+l[j+1]\n #lst.append(eval(st))\n lst_2+=eval(st)\n #print(lst)\n #print(lst_2)\n#print(sum(lst))\nprint(lst_2)", "\ns=input()\nl=list(s)\n#lst=[]\nlst_2=0\n\nfor i in range(1<<(len(s)-1)):\n st=l[0]\n for j in range(len(s)-1):\n if (i>>j)&1:\n st+=l[j+1]\n else:\n st+='+'+l[j+1]\n #lst.append(eval(st))\n lst_2+=eval(st)\n #print(lst)\n #print(lst_2)\n#print(sum(lst))\nprint(lst_2)"]
['Wrong Answer', 'Accepted']
['s260499652', 's137701890']
[3064.0, 3064.0]
[26.0, 29.0]
[842, 833]
p04001
u955251526
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
['s = list(input())\nl = len(s)\nt = [0] * l \nk = 2**(l-1)\nfor i in range(l):\n if i == 0:\n t[l-1] = k \n else:\n t[l-1-i] = t[l-i] * 5 + k // 2\nret = 0 \nfor i in range(l):\n top = int(s[i])\n ret += top * t[i]\nprint(t)\nprint(ret)', 's = list(input())\nl = len(s)\nt = [0] * l \nk = 2**(l-1)\nfor i in range(l):\n if i == 0:\n t[l-1] = k \n else:\n t[l-1-i] = t[l-i] * 5 + k // 2\nret = 0 \nfor i in range(l):\n top = int(s[i])\n ret += top * t[i]\nprint(ret)']
['Wrong Answer', 'Accepted']
['s810014028', 's961198474']
[3064.0, 3064.0]
[18.0, 18.0]
[247, 238]
p04001
u956836108
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
['# -*- coding: utf-8 -*-\n\ns = int(input())\nn = len(s) - 1\nanswer = 0\nfor i in range(2 ** n):\n operation = [""] * n\n for j in range(n):\n if (i >> j) & 1:\n operation[n - 1 -j] = "+"\n \n formula = ""\n for p_n, p_o in zip(s, operation + [""]):\n formula += (p_n + p_o)\n \n answer += eval(formula)\n\nprint(answer)', '# -*- coding: utf-8 -*-\n\ns = str(input())\nn = len(s) - 1\nanswer = 0\nfor i in range(2 ** n):\n operation = [""] * n\n for j in range(n):\n if (i >> j) & 1:\n operation[n - 1 -j] = "+"\n \n formula = ""\n for p_n, p_o in zip(s, operation + [""]):\n formula += (p_n + p_o)\n \n answer += eval(formula)\n\nprint(answer)']
['Runtime Error', 'Accepted']
['s794484063', 's991445495']
[9188.0, 9072.0]
[24.0, 34.0]
[349, 349]
p04001
u973744316
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
['S = int(input())\nN = len(S) - 1\nans = 0\n\nfor i in range(2 ** N):\n k = 0\n for j in range(N):\n \n if (i >> j) & 1:\n ans += int(S[k:j + 1])\n k = j + 1\n ans += int(S[k:])\nprint(ans)\n', 'S = int(input())\nN = len(S) - 1\nans = 0\n\nfor i in range(2 ** N):\n k = 0\n for j in range(N):\n if (i >> j) & 1:\n ans += int(S[k:j + 1])\n k = j + 1\n ans += int(S[k:])\nprint(ans)\n', 'S = int(input())\nN = len(S) - 1\nans = 0\n\nfor i in range(2 ** N):\n k = 0\n for j in range(N):\n \n if (i >> j) & 1:\n ans += int(S[k:j + 1])\n k = j + 1\n ans += int(S[k:])\nprint(ans)\n', 'S = input()\nN = len(S) - 1\nans = 0\n\n\nfor bit in range(2 ** N):\n k = 0\n for j in range(N):\n if (bit >> j) & 1:\n ans += int(S[k:j + 1])\n k = j + 1\n ans += int(S[k:])\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s137324572', 's169286450', 's737892492', 's686768144']
[2940.0, 2940.0, 3060.0, 2940.0]
[17.0, 18.0, 17.0, 19.0]
[230, 213, 230, 227]
p04001
u977193988
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
['S=input()\nn=len(S)\nans=0\nfor i in range(1<<(n-1)):\n for j in range(n):\n if 1&(i>>j):\n ans+=int(S[k:j+1])\n k=j+1\n ans+=int(S[k:])\n \nprint(ans)\n\n', 'S=input()\nn=len(S)\nans=0\nfor i in range(1<<(n-1)):\n k=0\n for j in range(n):\n if 1&(i>>j):\n ans+=int(S[k:j+1])\n k=j+1\n ans+=int(S[k:])\n \nprint(ans)\n']
['Runtime Error', 'Accepted']
['s015412630', 's607240142']
[2940.0, 3064.0]
[17.0, 20.0]
[185, 192]
p04001
u984351908
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
['def __main__():\n h, w, n = list(map(int, input().split()))\n grid = []\n for i in range(h):\n row = []\n for j in range(w):\n row.append(0)\n grid.append(row)\n for i in range(n):\n ai, bi = list(map(int, input().split()))\n grid[ai - 1][bi - 1] = 1\n \n result = [0] * 10\n for i in range(h - 2):\n for j in range(w - 2):\n black = 0\n for i2 in range(3):\n for j2 in range(3):\n if grid[i + i2][j + j2] == 1: black += 1 \n result[black] += 1\n \n for i in range(9):\n print(result[i])\n\n__main__()', 'def __main__():\n s = input()\n result = cal(s)\n print(result[0])\n\n\ndef cal(s):\n if len(s) == 0:\n return(0, 1)\n elif len(s) == 1:\n return (int(s), 1)\n else:\n sum, times = 0, 0\n for i in range(len(s)):\n num = int(s[0:(i + 1)])\n result = cal(s[(i + 1):len(s)])\n sum += num * result[1] + result[0]\n times += result[1]\n return (sum, times)\n \n__main__()']
['Runtime Error', 'Accepted']
['s182175621', 's891015016']
[3184.0, 3064.0]
[23.0, 24.0]
[639, 524]
p04001
u985949234
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
["S = str(input())\n\n\n\n\n\nfrom collections import deque\nbcal = []\nque = deque()\nque.append(S[0])\ns = ''.join([S[0],'+'])\nque.append(s)\nwhile len(que)>0:\n a = que.popleft()\n pn = a.count('+')\n if len(a)-pn == len(S):\n if a[-1]=='+':\n b = a.strip(a[-1])\n bcal.append(b)\n else:\n bcal.append(a)\n else:\n if a[-1]=='+':\n ai = S.index(a[-2])\n an1 =''.join([a,S[ai+1]])\n an2 =''.join([a,S[ai+1],'+'])\n que.append(an1)\n que.append(an2)\n else:\n ai = S.index(a[-1])\n an1 =''.join([a,S[ai+1]])\n an2 =''.join([a,S[ai+1],'+'])\n que.append(an1)\n que.append(an2)\nans = 0\nbcal= set(bcal)\nprint(bcal)\nfor item in bcal:\n ee = item.split('+')\n for item2 in ee:\n ans += int(item2)\n\nprint(ans)\n\n", "S = str(input())\n\n\n\n\n\nfrom collections import deque\nbcal = []\nque = deque()\nque.append(S[0])\ns = ''.join([S[0],'+'])\nque.append(s)\nwhile len(que)>0:\n a = que.popleft()\n pn = a.count('+')\n if len(a)-pn == len(S):\n if a[-1]=='+':\n b = a.strip(a[-1])\n bcal.append(b)\n else:\n bcal.append(a)\n else:\n ai = len(a)-pn\n an1 =''.join([a,S[ai]])\n an2 =''.join([a,S[ai],'+'])\n que.append(an1)\n que.append(an2)\n \nans = 0\nbcal= set(bcal)\nfor item in bcal:\n ee = item.split('+')\n for item2 in ee:\n ans += int(item2)\n\nprint(ans)\n\n"]
['Wrong Answer', 'Accepted']
['s399736609', 's125808349']
[3444.0, 3436.0]
[25.0, 24.0]
[1265, 1028]
p04001
u996996256
2,000
262,144
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
["s = input()\ntotal = 0\nfor i in product('01', repeat=len(s)-1):\n buf = s[0]\n for j in range(len(s)-1):\n if i[j] == '1':\n total += int(buf)\n buf = s[j+1]\n else:\n buf += s[j+1]\n total += int(buf)\nprint(total)", "s = input()\ntotal = 0\nfor i in product('01', repeat=len(s)-1):\n buf = s[0]\n for j in range(len(s)-1):\n if i[j] == '1':\n total += int(buf)\n buf = s[j+1]\n else:\n buf += s[j+1]\n total += int(buf)\nprint(total)", 's = input()\ntotal = 0\nn = 2**(len(s)-1)\nfor i in range(n):\n buf = s[0]\n for j in range(len(s)-1):\n if (i>>j)&1:\n total += int(buf)\n buf = s[j+1]\n else:\n buf += s[j+1]\n total += int(buf)\nprint(total)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s108343773', 's948450759', 's661821803']
[3060.0, 3060.0, 3060.0]
[18.0, 17.0, 20.0]
[261, 261, 254]
p04005
u010075034
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
["if __name__ == '__main__':\n x, y, z = (int(_) for _ in input().split(' '))\n if x % 2 == 0 or y % 2 == 0 or z % 2 == 0:\n print(0)\n return\n t = max((x, y, z))\n if t == x:\n print(y * z)\n elif t == y:\n print(x * z)\n elif t == z:\n print(x * y)\n", "#!/usr/bin/env python3\n\nif __name__ == '__main__':\n N, x = (int(_) for _ in input().split(' '))\n As = [int(_) for _ in input().split(' ')]\n each = sum(As)\n change = (N - 1) * x + N\n print(min(each, change))\n", "if __name__ == '__main__':\n x = int(input())\n y = int(input())\n z = int(input())\n lst = (x, y, z)\n\n a = max(lst)\n if a == x:\n b, c = y, z\n elif a == y:\n b, c = x, z\n elif a == z:\n b, c = x, y\n print(((a - (a // 2)) * b * c) - ((a // 2) * b * c))\n", "if __name__ == '__main__':\n x = int(input())\n y = int(input())\n z = int(input())\n t = (x, y, z)\n\n a = max(t)\n b, c = [_ for _ in t if _ != a]\n print(((a - (a // 2)) * b * c) - ((a // 2) * b * c))\n", "def main():\n ints = (int(_) for _ in input().split(' '))\n if any(_ % 2 == 0 for _ in ints):\n print(0)\n return\n t = max(ints)\n x, y, z = ints\n if t == x:\n print(y * z)\n elif t == y:\n print(x * z)\n elif t == z:\n print(x * y)\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n x, y, z = (int(_) for _ in input().split(' '))\n if any(_ % 2 == 0 for _ in (x, y, z)):\n print(0)\n return\n t = max((x, y, z))\n if t == x:\n print(y * z)\n elif t == y:\n print(x * z)\n elif t == z:\n print(x * y)\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s133089835', 's349125909', 's357005931', 's530520046', 's746003662', 's663327884']
[3064.0, 3064.0, 3064.0, 3188.0, 3064.0, 3064.0]
[38.0, 39.0, 37.0, 40.0, 38.0, 39.0]
[292, 222, 294, 218, 319, 313]
p04005
u026788530
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a=[int(_) for i in range(n)]\nif a[0]%2==0 or a[1]%2==0 or a[2]%2==0:\n print(0)\nelse:\n a.sort()\n print(a[0]*a[1])', 'a=[int(_) for _ in input().split()]\nif a[0]%2==0 or a[1]%2==0 or a[2]%2==0:\n print(0)\nelse:\n a.sort()\n print(a[0]*a[1])\n']
['Runtime Error', 'Accepted']
['s116251230', 's573859994']
[2940.0, 2940.0]
[18.0, 17.0]
[115, 123]
p04005
u030726788
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a,b,c=map(int,input().split())\ndif=10**15\nd=[[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]\nfor i in d:\n r1,r2,r3=a//2+i[0],b//2+i[1],c//2+i[2]\n b1,b2,b3=a-r1,b-r2,c-r3\n dif=min(dif,abs(r1*r2*r3-b1*b2*b3))\nprint(dif)\n', 'a,b,c=map(int,input().split())\ndif=10**15\nr1,r2,r3=a//2,b//2,c//2\nb1,b2,b3=a-r1,b-r2,c-r3\ndif=min(dif,abs(r1*r2*r3-b1*b2*b3))\nprint(dif)', 'a,b,c=map(int,input().split())\nprint(min([a*b*(c%2),b*c*(a%2),c*a*(b%2)]))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s508858788', 's845152911', 's142006919']
[3064.0, 3060.0, 2940.0]
[17.0, 17.0, 17.0]
[238, 136, 74]
p04005
u062068953
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['x=input().split()\ndim=[int(x[0]),int(x[1]),int(x[2])]\nprint(dim)\nif (dim[0]*dim[1]*dim[2])%2==0:\n print(0)\nelse:\n dim.remove(max(dim))\n print(dim[0]*dim[1])\n \n ', 'x=input().split()\ndim=[int(x[0]),int(x[1]),int(x[2])]\nif (dim[0]*dim[1]*dim[2])%2==0:\n print(0)\nelse:\n dim.remove(max(dim))\n print(dim[0]*dim[1])\n ']
['Wrong Answer', 'Accepted']
['s425090001', 's508345202']
[2940.0, 2940.0]
[19.0, 17.0]
[165, 151]
p04005
u098982053
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['Cube = [int(i) for i in input().split(" ")]\n\nL = max(Cube)\nA,B = map(int,[i for i in Cube if i!=L])\n\nprint(abs((A*B*(L//2))-(A*B*(L-(L//2)))))', 'Cube = [int(i) for i in input().split(" ")]\n\nL = max(Cube)\nplane = [i for i in Cube if i!=L]\nif len(plane)==0:\n A = L\n B = L\nelif len(plane)==1:\n A = plane[0]\n B = L\nelse:\n A,B = map(int,plane)\nprint(abs((A*B*(L//2))-(A*B*(L-(L//2)))))\n']
['Runtime Error', 'Accepted']
['s835226544', 's760424209']
[3060.0, 3060.0]
[18.0, 17.0]
[192, 301]
p04005
u227082700
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a=list(int,input().split());a.sort();s=a[0]*a[1]\nif (a[2]*s)%2==0:print(0)\nelse:print(s)', 'a=list(map(int,input().split()));a.sort();s=a[0]*a[1]\nif (a[2]*s)%2==0:print(0)\nelse:print(s)\n']
['Runtime Error', 'Accepted']
['s631290542', 's761333565']
[2940.0, 2940.0]
[17.0, 17.0]
[88, 94]
p04005
u239342230
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['A,B,C=map(int,input().split())\nans = A*B*C/max(A,B,C)\nif ans%2==0:\n print(0)\nelse:\n print(ans)', 'A,B,C=map(int,input().split())\nif any(map(lambda x: x%2==0,[A,B,C])):\n print(0)\nelse:\n print(min(A*B,B*C,C*A))']
['Wrong Answer', 'Accepted']
['s123906240', 's789284499']
[3060.0, 3316.0]
[18.0, 21.0]
[100, 116]
p04005
u276686572
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a,b,c = map(int, input().split())\n\nif a % 2 == 0 or b % 2 == 0 or c % 2 == 0: print(0)\nelse:\n square = a*b*c/max(a,b,c)\n print(square)', 'a,b,c = map(int, input().split())\n\nif a % 2 == 0 or b % 2 == 0 or c % 2 == 0: print(0)\nelse:\n square = min(a*b, b*c, a*c)\n print(int(square))\n']
['Wrong Answer', 'Accepted']
['s740747568', 's305195596']
[9148.0, 9088.0]
[25.0, 31.0]
[136, 144]
p04005
u311944296
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['#include <bits/stdc++.h>\nusing namespace std;\n\ntypedef long long int64;\n\nint64 a, b, c, ans = LLONG_MAX;\n\nvoid calc(int64 a, int64 b, int64 c) {\n\tint64 r = a / 2;\n\n\tfor(int64 i = max(1LL, r - 5); i <= min(r + 5, a - 1); i++) {\n\t\tint64 v1 = i * b * c;\n\t\tint64 v2 = (a - i) * b * c;\n\t\tans = min(ans, llabs(v1 - v2));\n\t}\n}\n\nint main() {\n\tscanf("%lld%lld%lld", &a, &b, &c);\n\n\tcalc(a, b, c);\n\tcalc(a, c, b);\n\tcalc(b, a, c);\n\tcalc(b, c, a);\n\tcalc(c, a, b);\n\tcalc(c, b, a);\n\n\tprintf("%lld\\n", ans);\n\treturn 0;\n}', 'from math import *\n\na, b, c = map(int, input().split())\n\ndef calc(a, b, c):\n\tr = a // 2\n\n\tans = a * b * c\n\tfor i in range(max(1, r - 5), min(r + 5, a - 1) + 1):\n\t\tv1 = i * b * c\n\t\tv2 = (a - i) * b * c\n\t\tans = min(ans, abs(v1 - v2))\n\n\treturn ans\n\nres = a * b * c\n\nres = min(res, calc(a, b, c))\nres = min(res, calc(a, c, b))\nres = min(res, calc(b, a, c))\nres = min(res, calc(b, c, a))\nres = min(res, calc(c, a, b))\nres = min(res, calc(c, b, a))\n\nprint(res)']
['Runtime Error', 'Accepted']
['s475049765', 's086862097']
[2940.0, 3064.0]
[17.0, 17.0]
[504, 454]
p04005
u322171361
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\na,b,c=[a,b,c].sort()\nprint(a*b)', 'a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nabc=sorted([a,b,c])\nif abc[2]%2==0:\n print(0)\nelse:\n print(abc[0]*abc[1])']
['Runtime Error', 'Accepted']
['s506737742', 's071903877']
[2940.0, 3064.0]
[18.0, 17.0]
[80, 128]
p04005
u333139319
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['[a,b,c] == [int(i) for i in input().split()]\n\nif (a * b * c) % 2 == 0:\n print(0)\nelse:\n print(min(a * b,b * c,c * a))\n', '[a,b,c] = [int(i) for i in input().split()]\n\nif (a * b * c) % 2 == 0:\n print(0)\nelse:\n print(min(a * b,b * c,c * a))\n']
['Runtime Error', 'Accepted']
['s607652352', 's139777857']
[2940.0, 2940.0]
[17.0, 17.0]
[124, 123]
p04005
u366644013
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['na = lambda: list(map(int, input().split()))\na, b, c = na()\nif a*b*c % 2 == 0:\n print(0)', 'na = lambda: list(map(int, input().split()))\na, b, c = na()\nif a*b*c % 2 == 0:\n print(0)\nelse:\n l = sorted([a, b, c])\n print(l[0] * l[1])']
['Wrong Answer', 'Accepted']
['s581543191', 's976861298']
[2940.0, 2940.0]
[17.0, 17.0]
[91, 146]
p04005
u368563078
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['A,B,C = map(int,input())\nnum_list = [A,B,C]\n list_s = sorted(num_list)\nif A % 2 == 1 and B % 2 == 1 and C % 2 == 1:\n print(list_s[0]*list_s[1])\nelse:\n print(0)\n\n ', 'A,B,C = map(int,input())\nnum_list = [A,B,C]\nlist_s = sorted(num_list)\nif A % 2 == 1 and B % 2 == 1 and C % 2 == 1:\n print(list_s[0]*list_s[1])\nelse:\n print(0)', "A,B,C = map(int,input().split(' '))\nnum_list = [A,B,C]\nlist_s = sorted(num_list)\nif A % 2 == 1 and B % 2 == 1 and C % 2 == 1:\n print(list_s[0]*list_s[1])\nelse:\n print(0)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s435884578', 's969846267', 's406750675']
[2940.0, 3060.0, 2940.0]
[17.0, 17.0, 17.0]
[171, 164, 175]
p04005
u371467115
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['l=list(map(int,input().split()))\nl.sort()\nif l[2]%2==0:\n print(l[0]*l[1])\nelse:\n print(0)', 's=list(map(int,input().split()))\nprint(s)\ns.sort()\nif s[0]%2==0:\n print(0)\nelse:\n print(s[1]*s[2])', 'a,b,c=map(int,input().split())\nif c%2==0:\n print(a*b)\nelse:\n print(0)', 'l=list(map(int,input().split()))\nl.sort()\nif l[2]%2!=0:\n print(l[0]*l[1])\nelse:\n print(0)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s032995377', 's790345434', 's989216479', 's628129399']
[3060.0, 2940.0, 2940.0, 2940.0]
[19.0, 18.0, 18.0, 18.0]
[91, 104, 75, 92]
p04005
u374802266
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
["a=sorted(list(map(int,input().split())))\nif (a[0]*a[1]*a[2])%2==0:\n print('0')\nelse:\n print(a[0]+a[1])", "a=sorted(list(map(int,input().split())))\nif (a[0]*a[1]*a[2])%2==0:\n print('0')\nelse:\n print(a[0]*a[1])"]
['Wrong Answer', 'Accepted']
['s403377103', 's729607795']
[2940.0, 2940.0]
[17.0, 17.0]
[108, 108]
p04005
u394721319
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['li = [int(i) for i in input().split()]\n\nfor i in li:\n if i%2 == 0:\n print(0)\n exit()\n\nli.pop(max(li))\nans = 1\nfor i in li:\n ans *= i\n\nprint(ans)\n', 'li = [int(i) for i in input().split()]\n\nfor i in li:\n if i%2 == 0:\n print(0)\n exit()\n\nli.remove(max(li))\nans = 1\nfor i in li:\n ans *= i\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s190317035', 's392463559']
[3316.0, 3316.0]
[19.0, 18.0]
[165, 168]
p04005
u397953026
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a,b,c = map(int,input().split())\nprint(a*b*c/max(a,b,c))', 'a = list(map(int,input().split()))\ncnt = 0\nfor i in range(3):\n if a[i]%2 == 0:\n cnt += 1\nif cnt == 0:\n a.sort()\n print(a[0]*a[1])\nelse:\n print(0)']
['Wrong Answer', 'Accepted']
['s856587284', 's235473871']
[9136.0, 9048.0]
[26.0, 23.0]
[56, 164]
p04005
u436484848
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
["str = input()\nnum = list(map(int,str.split(' ')))\nif !(num[0]%2)*(num[1]%2)*(num[2]):\n\tprint(0)\nelse:\n\tnum.sort()\nprint(num[0]*num[1])\n", "str = input()\nnum = list(map(int,str.split(' ')))\nif (num[0]%2)*(num[1]%2)*(num[2])==1:\n\tnum.sort()\n print(num[0]*num[1])\nelse:\n print(0)\n", "str = input()\nnum = list(map(int,str.split(' ')))\nif (num[0]%2)*(num[1]%2)*(num[2]):\n\tprint(0)\nelse:\n\tnum.sort()\nprint(num[0]*num[1])\n", "str = input()\nnum = list(map(int,str.split(' ')))\nif (num[0]%2)and(num[1]%2)and(num[2])==0:\n\tprint(0)\nelse:\n\tnum.sort()\n print(num[0]*num[1])\n", "str = input()\nnum = list(map(int,str.split(' ')))\nif ((num[0]%2)and(num[1]%2)and(num[2]%2))==0:\n\tprint(0)\nelse:\n\tnum.sort()\n\tprint(num[0]*num[1])\n"]
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s314111636', 's470573294', 's549326872', 's959814121', 's238704324']
[3064.0, 3064.0, 3064.0, 3064.0, 3064.0]
[37.0, 39.0, 37.0, 36.0, 37.0]
[135, 152, 134, 149, 146]
p04005
u459233539
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a,b,c=map(int,input().split())\nprint(min(a%*b*c,b%*a*c,c%*a*b))', '\na,b,c=map(int,input().split())\nprint(min((a%)*b*c,a*(b%)*c,a*b*(c%)))', 'a,b,c=map(int,input().split())\nprint(min(a%2*b*c,a*b%2*c,a*b*c%2))', 'a,b,c=map(int,input().split())\nprint(min(a%*b*c,a*b%*c,a*b*c%))', 'a,b,c=map(int,input().split())\nprint(min((a%2)*b*c,a*(b%2)*c,a*b*(c%2)))']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s309691044', 's634536664', 's906590789', 's916052211', 's941557517']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[18.0, 18.0, 19.0, 18.0, 18.0]
[63, 70, 66, 63, 72]
p04005
u468972478
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['s = sorted(list(map(int, input().split())))\na = s.pop(-1)\nb,c = a // 2, a - (a//2)\nd = s[0] * a[1]\nprint(abs(d * b - d * c))', 'a, b, c = sorted(list(map(int, input().split())))\nprint(c % 2 * a * b)']
['Runtime Error', 'Accepted']
['s952328387', 's004108821']
[9100.0, 9008.0]
[26.0, 29.0]
[124, 70]
p04005
u497046426
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['A, B, C = map(int, input().split())\nif A % 2 == 0 or B % 2 == 0 or C % 2 == 0:\n print(0)\nelse:\n min(A*B, B*C, C*A)', 'A, B, C = map(int, input().split())\nif A % 2 == 0 or B % 2 == 0 or C % 2 == 0:\n print(0)\nelse:\n print(min(A*B, B*C, C*A))']
['Wrong Answer', 'Accepted']
['s185079108', 's342766656']
[2940.0, 2940.0]
[17.0, 17.0]
[120, 127]
p04005
u516438812
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['A,B,C = map(int,input().split())\nif A % 2 == 0 or B % 2 == 0 or C % 2 == 0:\n\tprint(0)\n\treturn\nS = A * B * C\nmi = min(A,min(B,C))\nma = max(A,max(B,C))\nmid = S // ma // mi // 2\nans = ma * mi * mid\nprint(abs(S - ans * 2))', 'A,B,C = map(int,input().split())\nif A % 2 == 0 or B % 2 == 0 or C % 2 == 0:\n\tprint(0)\nelse:\n\tS = A * B * C\n\tmi = min(A,min(B,C))\n\tma = max(A,max(B,C))\n\tmid = S // ma // mi\n\tma //= 2\n\tans = ma * mi * mid\n\tprint(abs(S - ans * 2))']
['Runtime Error', 'Accepted']
['s112571289', 's189984007']
[3184.0, 3188.0]
[42.0, 44.0]
[218, 227]
p04005
u530850765
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a,b,c = (int(x) for x in input())\nans = abs(a*b*(c//2)-a*b*(c-c//2))\nans = min(ans, abs(a*c*(b//2)-a*c*(b-b//2)))\nans = min(ans, abs(b*c*(a//2)-b*c*(a-a//2)))\nprint(ans)', 'a,b,c = (int(x) for x in input().split())\nans = abs(a*b*(c//2)-a*b*(c-c//2))\nans = min(ans, abs(a*c*(b//2)-a*c*(b-b//2)))\nans = min(ans, abs(b*c*(a//2)-b*c*(a-a//2)))\nprint(ans)']
['Runtime Error', 'Accepted']
['s700164432', 's931298190']
[3316.0, 3064.0]
[42.0, 38.0]
[169, 177]
p04005
u547537397
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['import sys\ninput = sys.stdin.readline\n \ndef linput(ty=int, cvt=list):\n\treturn cvt(map(ty,input().split()))\n \ndef gcd(a: int, b: int):\n\twhile b: a, b = b, a%b\n\treturn a\n \ndef lcm(a: int, b: int):\n\treturn a * b // gcd(a, b)\n \ndef main():\n\t#n=int(input())', 'import sys\ninput = sys.stdin.readline\n \ndef linput(ty=int, cvt=list):\n\treturn cvt(map(ty,input().split()))\n \ndef gcd(a: int, b: int):\n\twhile b: a, b = b, a%b\n\treturn a\n \ndef lcm(a: int, b: int):\n\treturn a * b // gcd(a, b)\n \ndef main():\n\t#n=int(input())\n\t#vA=linput()\n\ta,b,c = linput()\n\t\n\tres = 0\n\t\n\tx = (a%2)*b*c\n\ty = (b%2)*c*a\n\tz = (c%2)*a*b\n\t\n\tres = min(x,y,z)\n\t\n\t#sT = "No Yes".split()\n\t#print(sT[res])\n\tprint(res)\n \nif __name__ == "__main__":\n\tmain()']
['Runtime Error', 'Accepted']
['s442961607', 's074867070']
[9044.0, 9104.0]
[30.0, 26.0]
[252, 454]
p04005
u601018334
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['N, x = list(map(int, input().split()))\na = list(map(int, input().split()))\nmin_index = a.index(min(a))\nindex_list = list(range(min_index,N)) + list(range(min_index))\ncost = a.copy()\nc_count = [0]*N\nfor i in range(1,N):\n if cost[index_list[i]] > (cost[index_list[i-1]]+x):\n cost[index_list[i]] = cost[index_list[i-1]]+x\n c_count[index_list[i]] = c_count[index_list[i-1]]+1\n\nprint(sum(cost) - sum(c_count)*x + max(c_count)*x )\n', "A, B, C = list(map(int, input().split()))\nif (A*B*C)%2 == 0:\n print('0')\nelse:\n print('%s' % str(min(min(A*B, B*C),C*A)) )\n"]
['Runtime Error', 'Accepted']
['s285906466', 's006542192']
[3064.0, 3064.0]
[37.0, 39.0]
[443, 129]
p04005
u623687794
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a=list(map(int,input().split()))\na.sort()\nif a%2!=0 and b%2!=0 and c%2!=0:\n print(a[0]*a[1])\nelse:\n print("0")\n', 'a=list(map(int,input().split()))\na.sort()\nif a%2!=0 and b%2!=0 and c%2!=0:\n print(a[0]*a[1])\nelif:\n print("0")', 'a=list(map(int,input().split()))\na.sort()\nif a[0]%2!=0 and a[1]%2!=0 and a[2]%2!=0:\n print(a[0]*a[1])\nelse:\n print("0")\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s494821604', 's964849111', 's144780007']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[113, 112, 122]
p04005
u627417051
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['A, B, C = list(map(int, input().split()))\nif A % 2 == 0 or B % 2 == 0 or C % 2 == 0:\n\tprint(0)\nelse:\n\tABC = sort([A, B, C])\n\tprint(ABC[0] * ABC[1])', 'A, B, C = list(map(int, input().split()))\nif A % 2 == 0 or B % 2 == 0 or C % 2 == 0:\n\tprint(0)\nelse:\n\tABC = sorted([A, B, C])\n\tprint(ABC[0] * ABC[1])']
['Runtime Error', 'Accepted']
['s179742963', 's650673938']
[2940.0, 3060.0]
[17.0, 17.0]
[147, 149]
p04005
u663767599
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['A, B, C = map(int, input().split())\nA, B, C = sorted([A, B, C])\n\nif C % 2 == 0:\n print(0)\nelse:\n d1, d2 = C // 2, (C // 2) + 1\n print(d1, d2)\n e = A * B\n print(abs(d1 - d2) * e)\n', 'A, B, C = map(int, input().split())\nA, B, C = sorted([A, B, C])\n\nif C % 2 == 0:\n print(0)\nelse:\n d1, d2 = C // 2, (C // 2) + 1\n e = A * B\n print(abs(d1 - d2) * e)\n']
['Wrong Answer', 'Accepted']
['s224164472', 's246856705']
[2940.0, 2940.0]
[17.0, 17.0]
[193, 175]
p04005
u693716675
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a,b,c = [int(i) for i in input().split()]\nif (a*b*c)%2==0:\n print(0)\nelse:\n ans = a*b\n ans = min(ans, b*c)\n ans = min(aans, c*a)\n print(ans)', 'a,b,c = [int(i) for i in input().split()]\nif (a*b*c)%2==0:\n print(0)\nelse:\n ans = a*b\n ans = min(ans, b*c)\n ans = min(ans, c*a)\n print(ans)']
['Runtime Error', 'Accepted']
['s849433957', 's699772651']
[2940.0, 2940.0]
[17.0, 17.0]
[155, 154]
p04005
u746428948
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['A,B,C = map(int,input().split())\nif A%2==0 or B%2==0 or C==0:\n print(0)\nelse:\n print(A*B*C/max({A,B,C}))', '#include <bits/stdc++.h>\n#define rep(i,n) for(int i=0; i<(n); i++)\n#define rrep(i,n) for(int i=1; i<=(int)(n); i++)\n#define pb push_back\n#define all(v) v.begin(),v.end()\n\n\n\n\nusing namespace std;\ntypedef pair<int,int> pii;\ntypedef vector<int> vi;\ntypedef vector<vi> vii;\ntypedef vector<string> vs;\ntypedef vector<char> vc;\ntypedef long long ll;\ntypedef unsigned long long ull;\n\nint main() {\n ll A,B,C;\n cin>>A>>B>>C;\n if(A%2==0||B%2==0||C%2==0) cout<<0<<endl;\n else {\n vector<ll> v;\n v.pb(A);\n v.pb(B);\n v.pb(C);\n sort(all(v));\n cout<<v[0]*v[1]<<endl;\n }\n}', 'A,B,C = map(int,input().split())\nif A%2==0 or B%2==0 or C%2==0:\n print(0)\nelse:\n print(A*B*C//max({A,B,C}))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s967322822', 's993966385', 's660597582']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[106, 702, 109]
p04005
u754022296
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a, b, c = map(int, input().split())\nif a%2 and b%2 and c%2:\n l = sorted(a, b, c)\n print(l[0]*l[1])\nelse:\n print(0)', 'a, b, c = map(int, input().split())\nif a%2 and b%2 and c%2:\n l = sorted([a, b, c])\n print(l[0]*l[1])\nelse:\n print(0)']
['Runtime Error', 'Accepted']
['s034724514', 's508185131']
[2940.0, 2940.0]
[17.0, 17.0]
[117, 119]
p04005
u760794812
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['A,B,C = map(int,input().split())\n\nif (A%2)*(B%2)*(C%2)==0:\n Answer = 0\nelse:\n Answer = A*B*C/max(A,B,C)\n\nprint(Answer)', 'A,B,C = map(int,input().split())\n\nif (A%2)*(B%2)*(C%2)==0:\n Answer = 0\nelse:\n Answer = min(A*B,A*C,B*C)\n\nprint(Answer)']
['Wrong Answer', 'Accepted']
['s883197702', 's435035142']
[2940.0, 2940.0]
[17.0, 17.0]
[120, 120]
p04005
u790301364
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['def main10():\n buf = int(input(""));\n strbuf = input("");\n strbufs = strbuf.split();\n buf2 = [];\n for i in range(buf):\n buf2.append(int(strbufs[i]));\n if len(buf2) == 1:\n return("YES");\n else:\n ki = 0;\n for i in range(buf):\n if buf2[i] % 2 == 1:\n ki += 1;\n if ki % 2 == 0:\n print("YES");\n else:\n print("NO");\n\n\n\nif __name__ == \'__main__\':\n main10()', 'def main24():\n strbuf = input("");\n strbufs = strbuf.split();\n buf = [];\n for i in range(3):\n buf.append(int(strbufs[i]));\n if (buf[0]%2==1)and(buf[1]%2==1)and(buf[2]%2==1):\n buf.sort();\n are = buf[0] * buf[1];\n print(are);\n else:\n print(0);\n\nif __name__ == \'__main__\':\n main24()']
['Runtime Error', 'Accepted']
['s170651349', 's408903403']
[3064.0, 3060.0]
[17.0, 17.0]
[462, 335]
p04005
u810288681
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['l = sorted(list(map((int, input().split()))))\nans = 0\nif l[0]%2!=0 and l[1]%2!=0 and l[2]%2!=0:\n ans += l[0]*l[1]\nprint(ans)', 'l = sorted(list(map(int, input().split())))\nans = 0\nif l[0]%2!=0 and l[1]%2!=0 and l[2]%2!=0:\n ans += l[0]*l[1]\nprint(ans)']
['Runtime Error', 'Accepted']
['s844579471', 's429355588']
[2940.0, 2940.0]
[18.0, 17.0]
[127, 125]
p04005
u824237520
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['n, x = map(int, input().split())\n\na = list(map(int, input().split()))\n\ntemp = 0\ncheck = 0\nfor i in range(1, n):\n if a[i] <= a[i - 1] + x:\n check = 1\n temp = i\n break\n\nif check == 1:\n a = a[temp:] + a[:temp]\n\ncheck = 1\nfor i in range(1, n):\n if a[i] >= a[i - check] + x:\n a[i] = a[i - check] + x\n check += 1\n else:\n check = 1\n\nprint(sum(a))', "x = list(map(int, input().split()))\n\nif x[0] * x[1] * x[2] % 2 == 0:\n print('0')\nelse:\n x = sorted(x)\n print(x[0] * x[1])"]
['Runtime Error', 'Accepted']
['s032473004', 's318551086']
[3064.0, 3316.0]
[17.0, 21.0]
[393, 130]
p04005
u835482198
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['A = list(sorted(map(int, input().split())))\ntmp = A[-1] // 2\nprint(A[0] * A[1] * (tmp - (A[-1] - tmp)))\n', '\nA = list(sorted(map(int, input().split())))\ntmp = A[-2] // 2\nprint(A[0] * A[1] * (tmp - (A[-1] - tmp)))\n', 'A = list(sorted(map(int, input().split())))\ntmp = A[-1] // 2\nprint(A[0] * A[1] * (A[-1] - 2 * tmp))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s050203675', 's489093489', 's187068317']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[104, 105, 99]
p04005
u835924161
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a,b,c=map(int,input().split())\nif a%2==0 or b%2==0 or c%2==0:\n print(0)\n exit()\n\nprint(min[a*b,b*c,c*a])', 'a,b,c=map(int,input().split())\nif a%2==0 or b%2==0 or c%2==0:\n print(0)\n exit()\nx=[a*b,b*c,c*a]\nprint(min(x))']
['Runtime Error', 'Accepted']
['s299925517', 's091298419']
[2940.0, 2940.0]
[17.0, 17.0]
[110, 115]
p04005
u837286475
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['\na,b,c = map(int,input().split())\n\nlst = [a,b,c]\n\ncnt = len(list( filter(lambda x:x%2==0,lst)))\n\nif(0<cnt):\n print(0)\nelse:\n lst.sort()\n\n res = 0\n if(lst[2]%2 == 1): \n res = lst[0]*lst[1]\n else:\n res = 0\n\n prin', '\nN,x = map(int,input().split())\n\nlst = list( map(int,input().split() ) )\n\nans = sum(lst)\n\ndp = lst[:]\n\n#print(N,x)\n#print(lst)\n\n\nfor i in range(1,N):\n tmp = 0\n for k in range(0,N):\n index_ = 0\n if(0 <= k-i):\n index_ = k-i\n else:\n index_ = N-i+k\n dp[k] = min(dp[k],lst[index_])\n tmp = tmp+dp[k]\n tmp = tmp + x*i\n ans = min(ans,tmp)\n\nprint(ans)', '\na,b,c = map(int,input().split())\n\nlst = [a,b,c]\n\ncnt = len(list( filter(lambda x:x%2==0,lst)))\n\nif(0<cnt):\n print(0)\nelse:\n lst.sort()\n\n res = 0\n if(lst[2]%2 == 1): \n res = lst[0]*lst[1]\n else:\n res = 0\n\n print(res)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s169478662', 's641423998', 's608894946']
[3064.0, 3188.0, 3064.0]
[38.0, 39.0, 39.0]
[243, 411, 249]
p04005
u866746776
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['def solve(n, x, a):\n\tcosts = []\n\tcost_min = 0\n\tfor k in range(n):\n\t\tif k == 0:\n\t\t\tcosts = a.copy()\n\t\telse:\n\t\t\tfor i in range(n):\n\t\t\t\tcosts[i] = min(costs[i], a[(i-k)%n])\n\t\tcost_k = sum(costs) + k*x\n\t\tif k == 0:\n\t\t\tcost_min = cost_k\n\t\telse:\n\t\t\tcost_min = min(cost_min, cost_k)\t\t\n\t\tif cost_min < (k+1) *x:\n\t\t\tbreak\n\n\treturn cost_min\nn, x = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nprint(solve(n,x,a))\n', 'a, b, c = [int(i) for i in input().split()]\nif a*b*c %2==0:\n print(0)\nelse:\n print(min(a*b, a*c, b*c))\n']
['Runtime Error', 'Accepted']
['s044929033', 's486263096']
[3064.0, 3064.0]
[39.0, 37.0]
[430, 105]
p04005
u884982181
2,000
262,144
We have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that: * There is at least one red block and at least one blue block. * The union of all red blocks forms a rectangular parallelepiped. * The union of all blue blocks forms a rectangular parallelepiped. Snuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.
['a = list(map(int,input().split()))\na.sort()\nfor i in a:\n if a%2 == 0:\n print(0)\n exit()\nprint(a[0]*a[1])', 'a = list(map(int,input().split()))\na.sort()\nfor i in a:\n if i%2 == 0:\n print(0)\n exit()\nprint(a[0]*a[1])']
['Runtime Error', 'Accepted']
['s801701820', 's241628919']
[2940.0, 2940.0]
[18.0, 18.0]
[111, 111]
p04006
u124139453
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['n, x = map(int, raw_input().split())\na = map(int, raw_input().split())\nans = 0\nb = []\nfor k in range(n):\n if k == 0:\n b = a[:]\n else:\n for i in range(n):\n b[i] = min(a[(i-k)%n],b[i])\n cost = k*x+sum(b)\n if k == 0:\n ans = cost\n else:\n ans = min(ans,cost)\n if ans != cost:\n break\n if ans < (k+1)*x:\n break\nprint(ans)', 'def solve(n, x, a):\n\tcosts = []\n\tcost_min = 0\n\tfor k in range(n):\n\t\tif k == 0:\n\t\t\tcosts = a.copy()\n\t\telse:\n\t\t\tfor i in range(n):\n\t\t\t\tcosts[i] = min(costs[i], a[(i-k)%n])\n\t\tcost_k = sum(costs) + k*x\n\t\tif k == 0:\n\t\t\tcost_min = cost_k\n\t\telse:\n\t\t\tcost_min = min(cost_min, cost_k)\n\t\t\tif cost_min != cost_k:\n\t\t\t\tbreak\n\t\tif cost_min < (k+1) *x:\n\t\t\tbreak\n \n\treturn cost_min\nn, x = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nprint(solve(n,x,a))']
['Runtime Error', 'Accepted']
['s231282511', 's420703335']
[3064.0, 3188.0]
[38.0, 1992.0]
[396, 464]
p04006
u163320134
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['n,x=map(int,input().split())\narr=list(map(int,input().split()))\ncost=[10**10]*n\nans=10**10\nfor i in range(n):\n for j in range(n):\n cost[j]=min(cost[j],arr[j-i])\n print(cost)\n ans=min(ans,x*i+sum(cost))\nprint(ans)', 'n,x=map(int,input().split())\narr=list(map(int,input().split()))\ncost=[10**18]*n\nans=10**18\nfor i in range(n):\n for j in range(n):\n cost[j]=min(cost[j],arr[j-i])\n ans=min(ans,x*i+sum(cost))\nprint(ans)']
['Wrong Answer', 'Accepted']
['s940296284', 's614132575']
[50164.0, 3188.0]
[1995.0, 1614.0]
[218, 204]
p04006
u186838327
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
["def segfunc(x, y):\n return min(x, y)\n\nclass segment_():\n def __init__(self, init_val, n, segfunc):\n self.ide_ele = 10**9+1\n \n self.num = 2**(n-1).bit_length()\n self.seg = [self.ide_ele]*2*self.num\n self.segfunc = segfunc\n # set_val\n for i in range(n):\n self.seg[i+self.num-1] = init_val[i]\n # built\n for i in range(self.num-2, -1, -1):\n self.seg[i] = self.segfunc(self.seg[2*i+1], self.seg[2*i+2])\n\n def update(self, k, x):\n k += self.num - 1\n self.seg[k] = x\n while k:\n k = (k-1)//2\n self.seg[k] = self.segfunc(self.seg[2*k+1], self.seg[2*k+2])\n\n def query(self, p, q):\n if q <= p:\n return self.ide_ele\n p += self.num - 1\n q += self.num - 2\n res = self.ide_ele\n while q-p>1:\n if p&1 == 0:\n res = self.segfunc(res, self.seg[p])\n if q&1 == 1:\n res = self.segfunc(res, self.seg[q])\n q -= 1\n p = p//2\n q = (q-1)//2\n if p == q:\n res = self.segfunc(res, self.seg[p])\n else:\n res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])\n return res\n\ndef main():\n n, x = list(map(int,sys.stdin.readline().split()))\n A = list(map(int,sys.stdin.readline().split()))\n\n seg_ = segment_(A, n, lambda a, b: min(a, b))\n ans = 10**18\n for k in range(n):\n t = k*x\n for i in range(n):\n if k <= i:\n t += seg_.query(i-k, i+1)\n else:\n t += min(seg_.query(0, i+1), seg_.query(n-(k-i), n))\n ans = min(t, ans)\n print(ans)\n\nif __name__ == '__main__':\n main()\n", 'n, x = map(int,input().split())\nA = list(map(int,input().split()))\n\nans = 10**18\nmins = [a for a in A]\nfor k in range(n):\n for i in range(n):\n if k <= i:\n mins[i] = min(A[i-k], mins[i])\n else:\n mins[i] = min(A[n-(k-i)], mins[i])\n ans = min(sum(mins)+k*x, ans)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s987488288', 's228213269']
[3192.0, 3188.0]
[18.0, 1909.0]
[1789, 313]
p04006
u532966492
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['from copy import deepcopy as dc\n#n,x=map(int,input().split())\nx=int(input()) #\na=list(map(int,input().split()))\n\nn=len(a) #\na=[[i,i,0] for i in a]\naa=dc(a)\nb=[]\n\nm=0\nwhile(b!=a):\n b=dc(a)\n for _ in range(2):\n for i in range(n):\n j=i-1\n if j==-1:\n j=n-1\n if a[i][1]!=a[j][1]:\n if aa[i][0]>=a[j][1]+x or (aa[i][0]>=a[j][1] and a[j][2]<m):\n a[i][0]=a[j][1]+x\n a[i][1]=a[j][1]\n a[i][2]=a[j][2]+1\n for i in a:\n m=max(i[2],m)\n \ns=0\ns+=m*x\nfor i in a:\n s+=i[1]\nprint(s)\n#print(a)', 'from copy import deepcopy as dc\n#n,x=map(int,input().split())\nx=int(input()) #\na=list(map(int,input().split()))\nn=len(a) #\na=[[i,i,0] for i in a]\nb=[]\n\nm=0\nwhile(b!=a):\n b=dc(a)\n for _ in range(2):\n for i in range(n):\n j=i-1\n if j==-1:\n j=n-1\n if a[i][1]!=a[j][1]:\n if a[i][0]>=a[j][1]+x or (a[i][0]>=a[j][1] and a[j][2]<m):\n a[i][0]=a[j][1]+x\n a[i][1]=a[j][1]\n a[i][2]=a[j][2]+1\n for i in a:\n m=max(i[2],m)\n \ns=0\ns+=m*x\nfor i in a:\n s+=i[1]\nprint(s)', 'def main():\n n, x = map(int, input().split())\n a = list(map(int, input().split()))\n b = [[None for _ in [0]*n] for _ in [0]*n]\n\n for i in range(n):\n m = a[i]\n for j in range(n):\n k = i-j\n if k < 0:\n k += n\n m = min(m, a[k])\n b[j][i] = m\n\n m = 10**15\n for i, j in enumerate(b):\n m = min(m, sum(j)+x*i)\n print(m)\n\n\nmain()']
['Runtime Error', 'Runtime Error', 'Accepted']
['s403672941', 's651188657', 's748242531']
[3572.0, 3444.0, 37492.0]
[26.0, 22.0, 1529.0]
[625, 603, 420]
p04006
u536113865
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['f = lambda: list(map(int,input().split()))\n\nn,x = f()\na = f()\nw = 0\nans = 0\nfor k in range(n):\n b = [a[i] + x*(k-i) for i in range(k+1)] + [a[i] + x*(n+k-i) for i in range(k+1,n)]\n print(b)\n m = b.index(min(b))\n ans += a[m]\n if m>k:\n m = n+k-m\n else:\n m = k-m\n print(m)\n w = max(w, m)\nprint(ans + w*x)\n', 'ai = lambda: list(map(int, input().split()))\n\nn,x = ai()\na = ai()\n\nma = [[] for _ in range(n)]\nfor i in range(n):\n ma[i].append(a[i])\n for j in range(1,n):\n if ma[i][-1] > a[i-j]:\n ma[i].append(a[i-j])\n else:\n ma[i].append(ma[i][-1])\n\n\ndef m(k):\n return sum(ma[i][k] for i in range(n))\n\n\nprint(min(m(k) + x*k for k in range(n)))']
['Wrong Answer', 'Accepted']
['s253884735', 's953728957']
[59764.0, 35448.0]
[1284.0, 1998.0]
[340, 373]
p04006
u601018334
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['N, x = list(map(int, input().split()))\na = list(map(int, input().split()))\ns_cost = a\ncost = sum(s_cost)\nfor k in xrange(0,N):\n s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( list(xrange(N)), list(xrange(N-k,N))+list(xrange(N-k)) )]\n cost = min(cost, k*x + sum(s_cost))\n\nprint(cost)\n', 'N, x = list(map(int, input().split()))\na = list(map(int, input().split()))\nmin_index = a.index(min(a))\nindex_list = list(range(min_index,N)) + list(range(min_index))\ncost = a.copy()\nc_count = [0]*N\nfor i in range(1,N):\n if cost[index_list[i]] => (cost[index_list[i-1]]+x):\n cost[index_list[i]] = cost[index_list[i-1]]+x\n c_count[index_list[i]] = c_count[index_list[i-1]]+1\n\nprint(sum(cost) - sum(c_count)*x + max(c_count)*x )\n', 'def solve_():\n import itertools\n N, x = map(int, input().split())\n a = list(map(int, input().split()))\n s_cost = a.copy()\n cost = sum(s_cost)\n\n for k, i in itertools.product(range(1, N), range(N)):\n s_cost[i] = a[(i - k) % N] if s_cost > a[(i - k) % N] else s_cost[i]\n if i == N - 1 and cost > k*x + sum(s_cost):\n cost = k*x + sum(s_cost)\n \n print(cost)\n\nsolve()\n', '\ndef solve_():\n import itertools\n N, x = map(int, input().split())\n a = list(map(int, input().split()))\n s_cost = a.copy()\n cost = sum(s_cost)\n\n for k, i in itertools.product(range(1, N), range(N)):\n s_cost[i] = a[(i - k) % N] if s_cost[i] > a[(i - k) % N] else s_cost[i]\n if i == N - 1 and cost > k*x + sum(s_cost):\n cost = k*x + sum(s_cost)\n\n print(cost)\n\nsolve_()']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s029745429', 's755121868', 's906934679', 's628069923']
[3188.0, 3064.0, 3064.0, 3316.0]
[40.0, 38.0, 39.0, 1820.0]
[290, 444, 412, 412]
p04006
u637175065
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**9\n\ndef f():\n n,x = list(map(int, input().split()))\n a = list(map(int, input().split()))\n mi = a.index(min(a))\n a = a[mi:] + a[:mi]\n print("a",a)\n r = sum(a)\n for t in range(n-1):\n for i in range(n-1,0,-1):\n a[i] = min(a[i],a[i-1])\n tr = ((t+1)*x) + sum(a)\n if r > tr:\n r = tr\n else:\n break\n return r\n\nprint(f())\n', 'import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**9\n\ndef f():\n n,x = list(map(int, input().split()))\n a = list(map(int, input().split()))\n mi = a.index(min(a))\n a = a[mi:] + a[:mi]\n r = sum(a)\n for t in range(n-1):\n for i in range(n-1,0,-1):\n a[i] = min(a[i],a[i-1])\n tr = ((t+1)*x) + sum(a)\n if r > tr:\n r = tr\n else:\n break\n return r\n\nprint(f())\n']
['Wrong Answer', 'Accepted']
['s575572454', 's757050753']
[8608.0, 6188.0]
[1758.0, 1750.0]
[526, 509]
p04006
u745087332
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
["# coding:utf-8\n\nINF = float('inf')\n\n\ndef inpl(): return list(map(int, input().split()))\n\n\nN, x = inpl()\nA = inpl()\n\nmin_index = A.index(min(A))\nB = A[min_index:] + A[:min_index]\n\ncost = [B[i] for i in range(N)]\n\nans = INF\nfor magic in range(N):\n for i in range(N):\n if i - magic >= 0:\n cost[i] = min(cost[i], B[i - magic])\n\n ans = min(ans, sum(B) + x * magic)\n\nprint(ans)\n", "# coding:utf-8\n\nimport sys\n\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\n\ndef main():\n n, x = LI()\n A = LI()\n\n min_a, min_i = INF, -1\n res = 0\n for i, a in enumerate(A):\n if a < min_a:\n min_a = a\n min_i = i\n res += a\n A = A[min_i:] + A[:min_i]\n\n dp = [INF] + A\n for k in range(n - 1):\n tmp = 0\n for i in range(n)[::-1]:\n if dp[i + 1] > dp[i]:\n dp[i + 1] = dp[i]\n tmp += dp[i + 1]\n\n res = min(res, tmp + (k + 1) * x)\n\n return res\n\n\nprint(main())\n"]
['Wrong Answer', 'Accepted']
['s020117677', 's353931119']
[3188.0, 3188.0]
[1235.0, 758.0]
[396, 873]
p04006
u754022296
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['import numpy as np\nn, x = map(int, input().split())\nA = np.array(input().split()[::-1], dtype=np.int64)\nB = A.copy()\nans = float("inf")\nfor k in range(n):\n print(B)\n t = x*k + B.sum()\n ans = min(ans, t)\n np.minimum(B, np.roll(A, -k-1), out=B)\nprint(ans)', 'import sys\ninput = sys.stdin.readline\n\nimport numpy as np\n\ndef main():\n n, x = map(int, input().split())\n A = np.array(input().split()[::-1]*2, dtype=np.int64)\n B = A.copy()[:n]\n ans = float("inf")\n for k in range(n):\n t = x*k + B.sum()\n ans = min(ans, t)\n np.minimum(B, A[k+1:k+n+1], out=B)\n print(ans)\n \nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s518432377', 's702574018']
[14536.0, 12500.0]
[864.0, 185.0]
[257, 357]
p04006
u785578220
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
["import numpy as np\nN, x = map(int, input().split())\na = np.array(map(int, input().split()))\nb = np.copy(a)\nans = float('inf') \nfor i in range(N):\n c = np.roll(a,i)\n b = np.minimum(b,c)\n ans = min(ans, sum(b)+i*x)\nprint(ans)\n", "import numpy as np\nN, x = map(int, input().split())\na = np.array(list(map(int, input().split())))\nb = np.copy(a)\nans = float('inf') \nfor i in range(N):\n c = np.roll(a,i)\n b = np.minimum(b,c)\n ans = min(ans, sum(b)+i*x)\nprint(ans)\n"]
['Runtime Error', 'Accepted']
['s792290457', 's670748120']
[12500.0, 12508.0]
[163.0, 1439.0]
[233, 239]
p04006
u803848678
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['n, x = map(int, input().split())\na = list(map(int, input().split()))\n\nDP = a[:]\nans = sum(DP)\nfor i in range(n-1):\n new = [0]*n\n for j in range(n):\n new[i] = min(DP[j], DP[j-1])\n DP=new\n ans = min(ans, sum(DP) + (i+1)*x)\nprint(ans)', 'n, x = map(int, input().split())\na = list(map(int, input().split()))\n\nDP = a[:]\nans = sum(DP)\nfor i in range(n-1):\n new = [0]*n\n for j in range(n):\n new[j] = min(DP[j], DP[j-1])\n DP=new\n ans = min(ans, sum(DP) + (i+1)*x)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s090299726', 's553098695']
[3188.0, 3188.0]
[1587.0, 1585.0]
[250, 250]
p04006
u866746776
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['def solve(n, x, a):\n\tcosts = []\n\tcost_min = 0\n\tfor k in range(n):\n\t\tif k == 0:\n\t\t\tcosts = a.copy()\n\t\telse:\n\t\t\tfor i in range(n):\n\t\t\t\tcosts[i] = min(costs[i], a[(i-k)%n])\n\t\tcost_k = sum(costs) + k*x\n\t\tif k == 0:\n\t\t\tcost_min = cost_k\n\t\telse:\n\t\t\tcost_min = min(cost_min, cost_k)\n\nn, x = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nprint(solve(n,x,a))\n\n\n', 'def solve(n, x, a):\n\tcosts = []\n\tcost_min = 0\n\tfor k in range(n):\n\t\tif k == 0:\n\t\t\tcosts = a.copy()\n\t\telse:\n\t\t\tfor i in range(n):\n\t\t\t\tcosts[i] = min(costs[i], a[(i-k)%n])\n\t\tcost_k = sum(costs) + k*x\n\t\tif k == 0:\n\t\t\tcost_min = cost_k\n\t\telse:\n\t\t\tcost_min = min(cost_min, cost_k)\n\t\t\tif cost_min != cost_k:\n\t\t\t\tbreak\n\t\tif cost_min < (k+1) *x:\n\t\t\tbreak\n\n\treturn cost_min\nn, x = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nprint(solve(n,x,a))\n\n\n']
['Wrong Answer', 'Accepted']
['s334293946', 's274025383']
[3188.0, 3188.0]
[2038.0, 1980.0]
[378, 466]
p04006
u884982181
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['n,x = map(int,input().split())\na = list(map(int,input().split()))\nMIN = sum(a)\nans = MIN\ntori = a + [0]\ntori.pop()\nfor i in range(1,n):\n for j in range(n):\n ido = i+j\n if ido >= n:\n ido-=n\n if tori[j] > a[ido]:\n tori[j] = a[ido]\n ans -= (tori[j] - a[ido])\n MIN = min(ans + i*x,MIN)\nprint(MIN)', 'n,x = map(int,input().split())\na = list(map(int,input().split()))\nMIN = sum(a)\nans = MIN+0\ntori = a + [0]\ntori.pop()\nfor i in range(1,n):\n for j in range(n):\n ido = i+j\n if ido >= n:\n ido-=n\n if tori[j] > a[ido]:\n ans -= (tori[j] - a[ido])\n tori[j] = a[ido]\n MIN = min(ans + i*x,MIN)\nprint(MIN)']
['Wrong Answer', 'Accepted']
['s148853036', 's401154287']
[3188.0, 3188.0]
[1434.0, 1423.0]
[318, 320]
p04006
u996252264
2,000
262,144
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together. Snuke can perform the following two actions: * Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds. * Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds. Find the minimum time that Snuke needs to have slimes in all N colors.
['def ri(): return int(input())\ndef rli(): return list(map(int, input().split()))\ndef ris(): return list(input())\ndef pli(): return "".join(list(map(str, ans)))\n\n\nN, x = rli()\na = rli()\n\ncatch_time = 0\nmagic_time = 0\nmi = [2000000000001 for _ in range(N)]\nfor i in range(N):\n for j in range(N):\n if(mi[i] > a[i-j]+x*j):\n mi[i] = a[i-j]+x*j\n catch_slime = a[i-j]\n magic_time = max(magic_time, x*j)\n\nprint(sum(mi) + magic_time)\n', 'def ri(): return int(input())\ndef rli(): return list(map(int, input().split()))\ndef ris(): return list(input())\ndef pli(): return "".join(list(map(str, ans)))\n\n\nN, x = rli()\na = rli()\nans = 2000000000001\nmagic_time = 0\ns_min = a[:]\nfor i in range(0, N):\n for j in range(N):\n s_min[j] = min(a[j-i], s_min[j])\n ans = min(sum(s_min) + x*i, ans)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s635924654', 's571277164']
[3188.0, 3188.0]
[1186.0, 1662.0]
[467, 366]
p04008
u102461423
1,000
262,144
There are N towns in Snuke Kingdom, conveniently numbered 1 through N. Town 1 is the capital. Each town in the kingdom has a _Teleporter_ , a facility that instantly transports a person to another place. The destination of the Teleporter of town i is town a_i (1≤a_i≤N). It is guaranteed that **one can get to the capital from any town by using the Teleporters some number of times**. King Snuke loves the integer K. The selfish king wants to change the destination of the Teleporters so that the following holds: * Starting from any town, one will be at the capital after using the Teleporters exactly K times in total. Find the minimum number of the Teleporters whose destinations need to be changed in order to satisfy the king's desire.
['import sys\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 7)\n\nN,K = map(int,readline().split())\nA = [int(x)-1 for x in readline().split()]\n\ndesc_edge = [set() for _ in range(N)]\nparent = [0] * N\nfor i,x in enumerate(A[1:],1):\n \n desc_edge[x].add(i)\n parent[i]=x\n\ndepth = [None] * N\nq = [0]\ndepth[0]=0\nwhile q:\n x = q.pop()\n for y in desc_edge[x]:\n q.append(y)\n depth[y] = depth[x]+1\n\nV = set(range(N))\n\nq=[]\ndepth_to_v = [[] for _ in range(N)]\nfor v,x in enumerate(depth):\n depth_to_v[x].append(v)\nfor d in range(N):\n q += depth_to_v[d]\n', 'import sys\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 7)\n\nN,K = map(int,readline().split())\nA = [int(x)-1 for x in readline().split()]\n\ndesc_edge = [set() for _ in range(N)]\nparent = [0] * N\nfor i,x in enumerate(A[1:],1):\n \n desc_edge[x].add(i)\n parent[i]=x\n\ndepth = [None] * N\nq = [0]\ndepth[0]=0\nwhile q:\n x = q.pop()\n for y in desc_edge[x]:\n q.append(y)\n depth[y] = depth[x]+1\n\nV = set(range(N))\n\nq=[]\ndepth_to_v = [[] for _ in range(N)]\nfor v,x in enumerate(depth):\n depth_to_v[x].append(v)\nfor d in range(N-1,-1,-1):\n q += depth_to_v[d]\n\nq\n\nanswer = 0\nfor x in q:\n if x == 0:\n break\n if x not in V:\n continue\n if depth[x] <= K:\n break\n answer += 1\n y=x\n for _ in range(K-1):\n y = parent[y]\n \n qq = [y]\n while qq:\n z = qq.pop()\n V.remove(z)\n for w in desc_edge[z]:\n if w in V:\n qq.append(w)\n\nif A[0] != 0:\n answer += 1\nprint(answer)']
['Wrong Answer', 'Accepted']
['s969214454', 's014517522']
[60900.0, 60832.0]
[381.0, 538.0]
[662, 1131]
p04008
u316386814
1,000
262,144
There are N towns in Snuke Kingdom, conveniently numbered 1 through N. Town 1 is the capital. Each town in the kingdom has a _Teleporter_ , a facility that instantly transports a person to another place. The destination of the Teleporter of town i is town a_i (1≤a_i≤N). It is guaranteed that **one can get to the capital from any town by using the Teleporters some number of times**. King Snuke loves the integer K. The selfish king wants to change the destination of the Teleporters so that the following holds: * Starting from any town, one will be at the capital after using the Teleporters exactly K times in total. Find the minimum number of the Teleporters whose destinations need to be changed in order to satisfy the king's desire.
['import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom collections import defaultdict\n\ndef main():\n N, K = LI()\n A = LI_()\n edges = defaultdict(list)\n for i, a in enumerate(A[1:], 1):\n edges[a].append(i)\n\n global ans\n ans = 0\n if A[0] != 0:\n ans += 1\n def DFS(v, parent):\n global ans\n height = 0\n for to in edges[v]:\n height = max(height, DFS(to, v))\n if parent != 0 and height > K - 1:\n height = -1\n ans += 1\n return height + 1\n DFS(0, 0)\n return ans\n\nprint(main())', 'import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom collections import defaultdict\n\ndef main():\n N, K = LI()\n A = LI_()\n edges = defaultdict(list)\n for i, a in enumerate(A[1:], 1):\n edges[a].append(i)\n\n ans = 0\n if A[0] != 0:\n ans += 1\n def DFS(v, parent):\n global ans\n height = 0\n for to in edges[v]:\n height = max(height, DFS(to, v) + 1)\n if parent != 0 and height > K - 1:\n height = 0\n ans += 1\n return height\n DFS(0, 0)\n return ans\n\nprint(main())', 'import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom collections import defaultdict\n\ndef main():\n N, K = LI()\n A = LI_()\n edges = defaultdict(list)\n for i, a in enumerate(A[1:], 1):\n edges[a].append(i)\n\n global ans\n ans = 0\n if A[0] != 0:\n ans += 1\n def DFS(v, parent):\n global ans\n height = 0\n for to in edges[v]:\n height = max(height, DFS(to, v))\n if parent != 0 and height >= K - 1:\n height = -1\n ans += 1\n return height + 1\n DFS(0, 0)\n return ans\n\nprint(main())']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s147635188', 's226688517', 's652647071']
[142620.0, 143468.0, 142620.0]
[407.0, 596.0, 401.0]
[915, 899, 916]
p04015
u030726788
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['n,a=map(int,input().split())\nx=list(map(int,input().split()))\ny=[]\nfor i in x:\n y.append(i-a)\ns=2*n*a\ndp=[[0 for i in range(s+1)] for j in range(n+1)]\ndp[0][n*a]=1\nfor i in range(n):\n for j in range(s+1):\n x=j-y[i]\n if(0<=x and x<=2*n*a):\n dp[i+1][j]=dp[i][j-y[i]]+dp[i][j]\n else:\n dp[i+1][j]=dp[i][j]\n\nprint(dp[n][n*a])', 'n,a=map(int,input().split())\nx=list(map(int,input().split()))\ny=[]\nfor i in x:\n y.append(i-a)\ns=2*n*a\ndp=[[0 for i in range(s+1)] for j in range(n+1)]\ndp[0][n*a]=1\nfor i in range(n):\n for j in range(s+1):\n x=j-y[i]\n if(0<=x and x<=2*n*a):\n dp[i+1][j]=dp[i][j-y[i]]+dp[i][j]\n else:\n dp[i+1][j]=dp[i][j]\n\nprint(dp[n][n*a]-1)']
['Wrong Answer', 'Accepted']
['s394303281', 's318831038']
[5236.0, 5236.0]
[193.0, 197.0]
[341, 343]
p04015
u036104576
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['N, A = map(int, input().split())\nX = list(map(int, input().split()))\nY = [x - A for x in X]\n\ndp = [0] * 5010\ndp[2500] = 1\n\nfor y in Y:\n for i in range(5009, -1, -1):\n if i - y < 0 or i - y >= 5010:\n dp[i] = 0\n else:\n dp[i] += dp[i - y]\nprint(dp[2500] - 1)\n', 'N, A = map(int, input().split())\nX = list(map(int, input().split()))\nY = [x - A for x in X]\n\ndp = [0] * 5010\ndp[2500] = 1\n\nfor y in Y:\n r = []\n if y >= 0:\n r = range(5009, -1, -1)\n else:\n r = range(5010)\n for i in r:\n if i - y < 0 or i - y >= 5010:\n continue\n dp[i] += dp[i - y]\nprint(dp[2500] - 1)\n']
['Wrong Answer', 'Accepted']
['s033181744', 's729466733']
[9228.0, 9228.0]
[96.0, 91.0]
[295, 350]
p04015
u077291787
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['\nfrom collections import defaultdict\n\n\ndef main():\n N, A = tuple(map(int, input().split()))\n X = tuple(map(int, input().split()))\n Y = [i - A for i in X]\n D = defaultdict(int)\n D[0] = 1\n for i in Y:\n for j, k in D.items():\n D[i + j] += k\n print(D[0] - 1)\n\n\nif __name__ == "__main__":\n main()', '\nfrom collections import defaultdict\n\n\ndef main():\n N, A = tuple(map(int, input().split()))\n X = tuple(map(lambda x: int(x) - A, input().split()))\n D = defaultdict(int)\n D[0] = 1\n for i in X:\n for j, k in list(D.items()):\n D[i + j] += k\n print(D[0] - 1)\n\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s389238729', 's637917723']
[3316.0, 3572.0]
[21.0, 30.0]
[392, 389]
p04015
u310678820
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['def dp(k, value):\n if k==n:\n if value==0:\n return 1\n else:\n return 0\n if memo[k][value]>=0:\n return memo[k][value]\n memo[k][value]=dp(k+1, value+x[k])+dp(k+1, value)\n return memo[k][value]\nprint(dp(0, 0)-1)', 'n, a =map(int, input().split())\nx=list(map(int, input().split()))\nx=[i-a for i in x]\nmemo=[[-1]*110 for i in range(60)]\ndef dp(k, value):\n if k==n:\n if value==0:\n return 1\n else:\n return 0\n if memo[k][value]>0:\n return memo[k][value]\n memo[k][value]=dp(k+1, value+x[k])+dp(k+1, value)\n print(memo[k][value], k, value)\n return memo[k][value]\nprint(dp(0, 0)-1)', 'n, a =map(int, input().split())\nx=list(map(int, input().split()))\nx=[i-a for i in x]\nmemo=[[-1]*6000 for i in range(60)]\ndef dp(k, value):\n if k==n:\n if value==0:\n return 1\n else:\n return 0\n if memo[k][value]>=0:\n return memo[k][value]\n memo[k][value]=dp(k+1, value+x[k])+dp(k+1, value)\n return memo[k][value]\nprint(dp(0, 0)-1)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s228798421', 's636476171', 's671612523']
[3060.0, 3764.0, 6004.0]
[17.0, 48.0, 36.0]
[261, 416, 382]
p04015
u316386814
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['import bisect\nfrom collections import Counter, deque\nfrom itertools import combinations, accumulate\nfrom math import factorial\nfrom operator import neg\nn, a = list(map(int, input().split()))\nxs = list(map(lambda x: int(x) - a, input().split()))\n\nxs.sort()\nl, r = bisect.bisect_left(xs, 0), bisect.bisect_right(xs, 0)\nlow, n0, high = xs[:l], r - l, xs[r:]\nif len(low) > len(high):\n low, high = list(map(neg, high)), list(map(neg, low))\nelse:\n high = high[::-1]\nacc = list(accumulate(high[::-1]))[::-1]\n\nfactor = 2 ** n0\nlsums = Counter([0])\nfor v in low:\n tmps = tuple(lsums.items())\n for u, cnt in tmps:\n lsums[u + v] += cnt\ndel lsums[0]\nans = 0\n\nprint(ans)', 'import bisect\nfrom collections import Counter, deque\nfrom itertools import combinations, accumulate\nfrom math import factorial\nfrom operator import neg\nn, a = list(map(int, input().split()))\nxs = list(map(lambda x: int(x) - a, input().split()))\n\nxs.sort()\nl, r = bisect.bisect_left(xs, 0), bisect.bisect_right(xs, 0)\nlow, n0, high = xs[:l], r - l, xs[r:]\nif len(low) > len(high):\n low, high = list(map(neg, high)), list(map(neg, low))\nelse:\n high = high[::-1]\nacc = list(accumulate(high[::-1]))[::-1]\n\nfactor = 2 ** n0\nlsums = sum((Counter(map(sum, combinations(low, 1 + i))) for i in range(len(low))), Counter())\n\nans = 0\n# for lsum, cnt in lsums.items():\n# tmp = 0\n\n\n# while len(q) > 0:\n\n# if i + 1 < len(high) and v + acc[i + 1] >= 0:\n\n\n# continue\n\n\n# tmp += 1\n# continue\n\n\n# ans += tmp * cnt\n\n# ans *= factor\n# ans += 2 ** n0 - 1\n\nprint(ans)', 'import bisect\nfrom collections import Counter, deque\nfrom itertools import combinations, accumulate\nfrom math import factorial\nfrom operator import neg\nn, a = list(map(int, input().split()))\nxs = list(map(lambda x: int(x) - a, input().split()))\n\nxs.sort()\nl, r = bisect.bisect_left(xs, 0), bisect.bisect_right(xs, 0)\nlow, n0, high = list(map(neg, xs[:l][::-1])), r - l, xs[r:]\n\ndef sums(arr):\n cntr = Counter([0])\n for v in arr:\n tmps = tuple(cntr.items())\n for u, cnt in tmps:\n cntr[u + v] += cnt\n del cntr[0]\n return cntr\n\nlsums = sums(low)\nhsums = sums(high)\n\nans = sum(hsums[a] * b for a, b in lsums.items())\n\nans *= 2 ** n0\nans += 2 ** n0 - 1\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s480492392', 's713373970', 's756096525']
[3444.0, 3436.0, 3564.0]
[24.0, 2104.0, 104.0]
[676, 1134, 696]
p04015
u368780724
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['def inpl(): return [int(i) for i in input().split()]\ndef hmd(a, b):\n ctr = -1\n while H[ctr+1][a] < b:\n ctr += 1\n vn = H[ctr][a]\n if (vn == b and ctr == 0) or ctr == -1:\n return 1\n return 2**ctr + hmd(vn,b)\nN = int(input())\nx = inpl() + [10**10]\nL = int(input())\nH = []\nG = [N-1]*N\nb = 0\nfor a in range(N):\n while x[b+1] - x[a] <= L:\n if b == N-1:\n break\n b += 1\n G[a] = b\nH.append(G)\nwhile G[0] != N-1:\n G = [G[i] for i in G]\n H.append(G)\nH.append([10**10]*N)\nQ = int(input())\nfor _ in range(Q):\n a, b = sorted(inpl())\n print(hmd(a-1,b-1))', 'from collections import defaultdict\nH = defaultdict(lambda: 0)\nH[0] = 1\ndef inpl(): return [int(i) for i in input().split()]\nN, A = inpl()\nx = inpl()\nx = [i-A for i in x]\nH[0]= 1\nfor i in x:\n for ni,nv in H.copy().items():\n H[ni+i] += nv\nprint(H[0]-1)']
['Runtime Error', 'Accepted']
['s113674820', 's690952107']
[3064.0, 3572.0]
[18.0, 26.0]
[611, 261]
p04015
u371467115
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['n,a=map(int, input().split())\nx=list(map(int, input().split()))\nx=[i-a for i in x]\nd={0:0}\nfor i in x:\n for j,k in list(d.items()):\n d[i+j]=d.get(i+j,0)+k\nprint(d[0])\n#sample code.\n', 'n,a=map(int, input().split())\nx=list(map(int, input().split()))\nx=[i-a for i in x]\nd={0:1}\nfor i in x:\n for j,k in list(d.items()):\n d[i+.j]=d.get(i+j,0)+k\nprint(d[0]-1)\n#sample code', 'n,a=map(int, input().split())\nx=list(map(int, input().split()))\nx=[i-a for i in x]\nd={0:0}\nfor i in x:\n for j,k in list(d.items()):\n d[i+j]=d.get(i+j,0)+k\nprint(d[0]-1)\n#sample code.', 'n,a=map(int, input().split())\nx=list(map(int, input().split()))\nx=[i-a for i in x]\nd={0:2}\nfor i in x:\n for j,k in list(d.items()):\n d[i+j]=d.get(i+j,0)+k\nprint(d[0]-2)\n#sample code.\n', 'n,a=map(int, input().split())\nx=list(map(int, input().split()))\nx=[i-a for i in x]\nd={0:1}\nfor i in x:\n for j,k in list(d.items()):\n d[i+j]=d.get(i+j,0)+k\nprint(d[0]-1)\n#sample code.']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s181971142', 's516427249', 's646059849', 's878365424', 's017523312']
[3188.0, 2940.0, 3188.0, 3188.0, 3188.0]
[25.0, 18.0, 26.0, 26.0, 27.0]
[191, 192, 192, 193, 192]
p04015
u379305729
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['\nline1=input().split()\nn=int(line1[0])\na=int(line1[1])\nnums=input().split()\nfor i in range(n):\n nums[i]=int(nums[i])-a\n\nworks={}\n\nprint (works)\ns=0\nfor x in nums:\n\n if x>=0:\n for i in range(50*n,-50*n, -1):\n try:\n works[i]+=works[i-x]\n except:\n try:\n works[i]=works[i-x]\n except:\n pass\n else:\n for i in range (-50*n,50*n):\n try:\n works[i+x]+=works[i]\n except:\n try:\n works[i+x]=works[i]\n except:\n pass\n\nprint (works[0]-1)\n', '\nline1=input().split()\nn=int(line1[0])\na=int(line1[1])\nnums=input().split()\nfor i in range(n):\n nums[i]=int(nums[i])-a\n\nworks={}\n\nworks[0]=1\ns=0\nfor x in nums:\n\n if x>=0:\n for i in range(50*(n+1),-50*(n+1), -1):\n try:\n works[i]+=works[i-x]\n except:\n try:\n works[i]=works[i-x]\n except:\n pass\n else:\n for i in range (-50*(n+1),50*(n+1)):\n try:\n works[i+x]+=works[i]\n except:\n try:\n works[i+x]=works[i]\n except:\n pass\n\nprint (works[0]-1)\n']
['Runtime Error', 'Accepted']
['s256184376', 's792001434']
[3316.0, 3188.0]
[333.0, 335.0]
[655, 668]
p04015
u520158330
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['N,A = map(int,input().split())\nX = list(map(lambda x:int(x)-A,input().split()))\n\nMX = max(X+[0])\n\ndp = [[0 for i in range(2*MX*N+1)] for _ in range(N+1)]\n\nfor i in range(N+1):\n for t in range(2*MX*N+1):\n if i==0 and t==N*MX:\n dp[i][t] = 1\n elif i>=1:\n if t-X[i-1]>=0 and t-X[i-1]<=2*MX*N:\n dp[i][t] = dp[i-1][t]+dp[i-1][t-X[i-1]]\n else:\n dp[i][t] = dp[i-1][t]\n else:\n dp[i][t] = 0\n \nprint(dp[N][N*MX]-1)\nprint("\\n".join([str(d) for d in dp]))', '#ARC060 C\n\n\n\nN,A = map(int,input().split())\nX = list(map(lambda x:int(x)-A,input().split()))\n\nMX = max(X+[0])\n\ndp = [[0 for i in range(2*MX*N+1)] for _ in range(N+1)]\n\nfor i in range(N+1):\n for t in range(2*MX*N+1):\n if i==0 and t==N*MX:\n dp[i][t] = 1\n elif i>=1:\n if t-X[i-1]>=0 and t-X[i-1]<=2*MX*N:\n dp[i][t] = dp[i-1][t]+dp[i-1][t-X[i-1]]\n else:\n dp[i][t] = dp[i-1][t]\n else:\n dp[i][t] = 0\n \nprint(dp[N][N*MX]-1)\n#print("\\n".join([str(d) for d in dp]))']
['Wrong Answer', 'Accepted']
['s545707149', 's964701873']
[7560.0, 5108.0]
[229.0, 227.0]
[543, 1321]
p04015
u630941334
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
["def main():\n N, A = map(int, input().split())\n x = [0].extend(list(map(int, input().split())))\n\n dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]\n for i in range(N + 1):\n dp[i][0][0] = 1\n\n for i in range(1, N + 1):\n for j in range(1, i + 1):\n for k in range(1, N * A + 1):\n if k < x[k]:\n dp[i][j][k] = dp[i - 1][j][k]\n else:\n dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]\n\n ans = 0\n for j in range(1, N + 1):\n ans += dp[N][j][A * j]\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n N, A = map(int, input().split())\n x = [0]\n x.extend(list(map(int, input().split())))\n\n dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]\n for i in range(N + 1):\n dp[i][0][0] = 1\n\n for i in range(1, N + 1):\n for j in range(1, i + 1):\n for k in range(1, N * A + 1):\n if k < x[i]:\n dp[i][j][k] = dp[i - 1][j][k]\n else:\n dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]\n\n ans = 0\n for j in range(1, N + 1):\n ans += dp[N][j][A * j]\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s508712326', 's367732158']
[56436.0, 54088.0]
[332.0, 1169.0]
[657, 651]
p04015
u649373416
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['import numpy as np\nhi = np.zeros((5000,60),np.int64)\nhi[0,0]=1\nn,a = [int(it) for it in input().split()]\nli = [int(it) for it in input().split()]\nfor i in li:\n \u3000hi_ = hi.copy()\n hi[i:-1,1:]+=hi_[:-1-i,:-1]\ns = 0\nfor i in range(n):\n s+=hi[(i+1)*a,i+1]\nprint (s)\n', 'import numpy as np\nhi = np.zeros((5000,60),np.int64)\nhi[0,0]=1\nn,a = [int(it) for it in input().split()]\nli = [int(it) for it in input().split()]\nfor i in li:\n hi_ = hi.copy()\n hi[i:-1,1:]+=hi_[:-1-i,:-1]\ns = 0\nfor i in range(n):\n s+=hi[(i+1)*a,i+1]\nprint (s)\n']
['Runtime Error', 'Accepted']
['s852695538', 's062304317']
[2940.0, 19580.0]
[17.0, 209.0]
[268, 267]
p04015
u663710122
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['import numpy as np\n\nN, A = map(int, input().split())\nX = [0] + list(map(int, input().split()))\nNX = N * max(X + [A])\n\ndp = np.zeros((N + 1, N + 1, NX + 1))\n\ndp[0][0][0] = 1\n\nfor j in range(N + 1):\n for k in range(N + 1):\n for s in range(NX + 1):\n if j >= 1 and s < X[j]:\n dp[j][k][s] = dp[j - 1][k][s]\n elif j >= 1 and k >= 1 and s >= X[j]:\n dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - X[j]]\n\nret = 0\n\nfor k in range(1, N + 1):\n ret += dp[N][k][k * A]\n\nprint(ret)\n', 'import numpy as np\n\nN, A = map(int, input().split())\nX = [0] + list(map(int, input().split()))\nNX = N * max(X + [A])\n\ndp = np.zeros((N + 1, 2 * NX + 1), dtype=int)\n\ndp[0][NX] = 1\n\nfor j in range(1, N + 1):\n y = X[j] - A\n for t in range(2 * NX + 1):\n if 0 <= t - y < 2 * NX:\n dp[j][t] = dp[j - 1][t] + dp[j - 1][t - y]\n else:\n dp[j][t] = dp[j - 1][t]\n\nprint(dp[N][NX] - 1)\n']
['Wrong Answer', 'Accepted']
['s476650893', 's592774623']
[20644.0, 14436.0]
[2109.0, 563.0]
[538, 414]
p04015
u670180528
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['n,a,*x=map(int,open(0).read().split());dp={0:1}\nfor i in x:\n\tfor k,v in dp.items():\n\t\tdp[i+k-a]=dp.get(i+k-a,0)+v\nprint(dp[0]-1)', 'def main():\n\tn,a=map(int,input().split())\n\ty=[a-int(x) for x in input().split()]\n\tdp={0:1}\n\tfor i in y:\n\t\tfor k,v in list(dp.items()):\n\t\t\tdp[i+k]=dp.get(i+k,0)+v\n\tprint(dp[0]-1)\nif __name__=="__main__":\n\tmain()']
['Runtime Error', 'Accepted']
['s612730428', 's528462157']
[2940.0, 3188.0]
[17.0, 23.0]
[128, 210]
p04015
u708255304
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['N, A = map(int, input().split()) \nX = tuple(map(int, input().split())) \n\ndp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]\n\ndp[0][0][0] = 1 \n\nfor i in range(N):\n for j in range(N+1):\n for s in range(50*N+1):\n if s >= X[i]: \n dp[i+1][j+1][s] += dp[i][j][s-X[i]] \n dp[i+1][j][s] += dp[i][j][s] \nans = 0\nfor i in range(1, N+1):\n ans += dp[N][i][i*A]\nprint(ans)\n', 'N, A = map(int, input().split()) \nX = tuple(map(int, input().split())) \n\ndp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]\n\ndp[0][0][0] = 1 \n\nfor i in range(N):\n now_card = X[i]\n for j in range(N+1):\n for s in range(50*N+1):\n if s >= now_card: \n dp[i+1][j+1][s] += dp[i][j][s-now_card] \n dp[i+1][j][s] += dp[i][j][s] \nans = 0\nfor i in range(1, N+1):\n ans += dp[N][i][i*A]\nprint(ans)\n', 'N, A = map(int, input().split()) \n\nX = list(map(int, input().split())) \n\n\ndp = [[[0]*(max(X)*N+1) for _ in range(N+1)] for _ in range(N+1)]\n\n\ndp[0][0][0] = 1\n\nfor i in range(len(X)):\n for j in range(1, N+1):\n for k in range(1, N+1):\n for s in range(1, max(X)*N+1):\n if s < X[i]:\n dp[j][k][s] = dp[j-1][k][s]\n if s >= X[i]:\n \n dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-X[i]]\n\n\nans = 0\nfor j in range(1, N+1):\n for k in range(1, N+1):\n ans += dp[j][k][k*A]\n\nprint(ans)\n', 'N, A = map(int, input().split()) \n\nX = tuple(map(int, input().split())) \n\n\ndp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]\n\n\ndp[0][0][0] = 1\n\nfor i in range(N):\n for j in range(N+1):\n for k in range(N*50+1):\n if dp[i][j][k]: \n dp[i+1][j][k] += dp[i][j][k] \n dp[i+1][j+1][k+X[i]] += dp[i][j][k] \n\nans = 0\nfor i in range(1, N+1):\n ans += dp[N][i][i*A]\n\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s005065942', 's312225897', 's336919677', 's400549696']
[54004.0, 54004.0, 56052.0, 62952.0]
[234.0, 223.0, 2107.0, 1250.0]
[726, 754, 892, 760]
p04015
u768496010
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
["n, a = map(int, input().split())\nxlist = list(map(int, input().split()))\n\nj = n\nk = n\nt = n * a\nmaxv = max(xlist)\n\n\ndp = [[[0 for t in range(t + 1)] for k in range(k + 1)] for j in range(j + 1)]\n\ndp[1][0][0] = 1\ndp[0][0][0] = 1\n\n\n# print(d)\n# print(dp[1][1][15])\n\nfor ji in range(0, j + 1):\n for ki in range(0, ji + 1):\n for ti in range(0, ki * maxv + 1):\n \n if ji == 0 and ki == 0 and ti == 0:\n # print('branch 1')\n dp[ji][ki][ti] = 1\n elif ji >= 1 and ti < xlist[ji - 1]:\n dp[ji][ki][ti] = dp[ji - 1][ki][ti]\n # print('branch 2')\n elif ji >= 1 and ki >= 1 and ti >= xlist[ji - 1]:\n \n dp[ji][ki][ti] = dp[ji - 1][ki][ti] + dp[ji - 1][ki - 1][ti - xlist[ji - 1]]\n # print(dp[ji][ki][ti])\n\ncount = 0\nfor i in range(1, k + 1):\n count += dp[j][i][i*a]\n\nprint(count)", "n, a = map(int, input().split())\nxlist = list(map(int, input().split()))\n\nj = n\nk = n\nt = n * a\nmaxv = max(a, max(xlist))\n\n\ndp = [[[0 for t in range(n*maxv + 1)] for k in range(k + 1)] for j in range(j + 1)]\n\ndp[1][0][0] = 1\ndp[0][0][0] = 1\n\n\n# print(d)\n# print(dp[1][1][15])\n\nfor ji in range(0, j + 1):\n for ki in range(0, ji + 1):\n for ti in range(0, ki * maxv + 1):\n \n if ji == 0 and ki == 0 and ti == 0:\n # print('branch 1')\n dp[ji][ki][ti] = 1\n elif ji >= 1 and ti < xlist[ji - 1]:\n dp[ji][ki][ti] = dp[ji - 1][ki][ti]\n # print('branch 2')\n elif ji >= 1 and ki >= 1 and ti >= xlist[ji - 1]:\n \n dp[ji][ki][ti] = dp[ji - 1][ki][ti] + dp[ji - 1][ki - 1][ti - xlist[ji - 1]]\n # print(dp[ji][ki][ti])\n\ncount = 0\nfor i in range(1, k + 1):\n count += dp[j][i][i*a]\n\nprint(count)"]
['Runtime Error', 'Accepted']
['s357837859', 's113002331']
[56564.0, 65392.0]
[1212.0, 1326.0]
[991, 1004]
p04015
u859897687
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['n,a=map(int,input().split())\nm=list(map(lambda x:int(x)-a,input().split()))\nx=max(abs(max(m)),abs(min(m)))*n\ndp=[[0for _ in range(2*x+1)]for i in range(n)]\ndp[0][0+x]=1\ndp[0][m[0]+x]=1\nfor i in range(1,n):\n y=m[i]\n for j in range(x):\n dp[i][j+y]+=dp[i-1][j]\n dp[i][j]+=dp[i-1][j]\nprint(dp[n-1][0]-1)', 'n,a=map(int,input().split())\nm=list(map(lambda x:int(x)-a,input().split()))\nx=max(abs(max(m)),abs(min(m)))*n\ndp=[[0for _ in range(2*x+1)]for i in range(n)]\ndp[0][0+x]=1\ndp[0][m[0]+x]=1\nfor i in range(1,n):\n y=m[i]\n for j in range(x):\n if dp[i-1][j]==0:\n continue\n dp[i][j+y]=dp[i-1][j+y]+dp[i-1][j]\n dp[i][j]=dp[i-1][j]\nprint(dp[n-1][0+x]-1)', 'n,a=map(int,input().split())\nm=list(map(lambda x:int(x)-a,input().split()))\nx=max(abs(max(m)),abs(min(m)))*n\ndp=[[0for _ in range(2*x+1)]for i in range(n)]\ndp[0][0+x]=1\ndp[0][m[0]+x]=1\nfor i in range(1,n):\n y=m[i]\n for j in range(x):\n dp[i][j+y]=dp[i-1][j+y]+dp[i-1][j]\n dp[i][j]=dp[i-1][j]\nprint(dp[n-1][0+x]-1)', 'n,a=map(int,input().split())\nm=list(map(lambda x:int(x)-a,input().split()))\nx=max(abs(max(m)),abs(min(m)))*n\ndp=[[0for _ in range(2*x+1)]for i in range(n)]\ndp[0][0+x]=1\ndp[0][m[0]+x]=1\nfor i in range(1,n):\n y=m[i]\n for j in range(x):\n dp[i][j+y]+=dp[i-1][j]\n dp[i][j]+=dp[i-1][j]\nprint(dp[n-1][0+x]-1)', 'n,a=map(int,input().split())\nm=list(map(lambda x:int(x)-a,input().split()))\nx=max(abs(max(m)),abs(min(m)))*n\ndp=[[0for _ in range(2*x+1)]for i in range(n)]\ndp[0][0+x]+=1\ndp[0][m[0]+x]+=1\nfor i in range(1,n):\n y=m[i]\n for j in range(2*x+1):\n if 0<=j+y and j+y<2*x+1:\n dp[i][j+y]+=dp[i-1][j]\n dp[i][j]+=dp[i-1][j]\n #print(y,dp[i])\nprint(max(0,dp[n-1][0+x]-1))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s165210306', 's293683429', 's473981187', 's902232635', 's334761398']
[5236.0, 5108.0, 5108.0, 5236.0, 5228.0]
[98.0, 48.0, 101.0, 89.0, 212.0]
[307, 357, 320, 309, 371]
p04015
u862517767
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['n,a=map(int,input().split())\nx=[0]+[i-a for i in map(int,input().split())]\nd={}\ndef f(i):\n if i==n+1:\n return c([0])\n if i in d:\n return d[i]\n d[i]={}\n for j in range(i+1,n+2):\n for k,v in f(j).items():\n d[i].setdefault(x[i]+k,0)\n d[i][x[i]+k]+=v\n return d[i]\nprint(f(0)[0]-1)', 'n,a=map(int,input().split())\nx=[0]+[i-a for i in map(int,input().split())]\nd={}\ndef f(i):\n if i==n+1:\n return {0:1}\n if i in d:\n return d[i]\n d[i]={}\n for j in range(i+1,n+2):\n for k,v in f(j).items():\n d[i].setdefault(x[i]+k,0)\n d[i][x[i]+k]+=v\n return d[i]\nprint(f(0)[0]-1)']
['Runtime Error', 'Accepted']
['s776358735', 's760227829']
[3136.0, 5236.0]
[44.0, 297.0]
[334, 333]
p04015
u977193988
2,000
262,144
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?
['n,a=map(int,input().split())\nX=[int(i)-a for i in input().split()]\n\nmemo={0:1}\nfor x in X:\n for k,v in list(memo.items()):\n memo[x+k]=memo.get(x+k,0)+v\n print(memo)\nprint(memo[0]-1)\n', 'n,a=map(int,input().split())\nX=[int(i)-a for i in input().split()]\n\nmemo={0:1}\nfor x in X:\n for k,v in list(memo.items()):\n memo[x+k]=memo.get(x+k,0)+v\nprint(memo[0]-1)\n\n']
['Runtime Error', 'Accepted']
['s558740126', 's976200394']
[134260.0, 3188.0]
[1764.0, 26.0]
[199, 180]
p04016
u052499405
2,000
262,144
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
['n = int(input())\ns = int(input())\n\ndef f(b, n):\n val = 0\n while n > 0:\n val += n % b\n n //= b\n return val\n\nif s == n:\n print(n+1)\n exit()\nif s == 1:\n print(n)\n exit()\nfor i in range(1, int(n**0.5) + 10):\n if(f(i, n) == s):\n print(i)\n exit()\nans = 10**15\nfor i in range(1, int(n**0.5) + 1):\n b = (n-s) // i + 1\n if f(b, n) == s and b>p and b>q:\n ans = min(ans, b)\nif ans == 10**15:\n print(-1)\nelse:\n print(ans)', 'n = int(input())\ns = int(input())\n\ndef f(b, n):\n val = 0\n while n > 0:\n val += n % b\n n //= b\n return val\n\nif s == n:\n print(n+1)\n exit()\nfor i in range(2, int(n**0.5) + 1):\n if(f(i, n) == s):\n print(i)\n exit()\nans = 10**15\nfor i in range(1, int(n**0.5) + 1):\n b = (n-s) // i + 1\n if b < 2:\n continue\n if f(b, n) == s:\n ans = min(ans, b)\n\nif ans == 10**15:\n print(-1)\nelse:\n print(ans)']
['Wrong Answer', 'Accepted']
['s712488568', 's902336207']
[3064.0, 3188.0]
[2104.0, 475.0]
[480, 460]
p04016
u677523557
2,000
262,144
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
['import math\n\nN = int(input())\nS = int(input())\nL = N-S\n\ndef search(b, n=N):\n ans = 0\n while n >= b:\n ans += n%b\n n //= b\n ans += n\n return ans\ns\nif L < 0:\n print(-1)\nelif L == 0:\n print(1)\nelse:\n P = []\n for l in range(1, int(math.sqrt(L))+1):\n if L%l == 0:\n P.append(l+1)\n P.append(L//l+1)\n P.sort()\n\n ans = -1\n for p in P:\n S0 = search(p)\n if S == S0:\n ans = p\n break\n\n print(ans)', 'import math\n\nN = int(input())\nS = int(input())\nL = N-S\n\ndef search(b, n=N):\n ans = 0\n while n >= b:\n ans += n%b\n n //= b\n ans += n\n return ans\n\n\ndef main():\n\n if L < 0:\n print(-1)\n elif L == 0:\n print(N+1)\n else:\n P = []\n for l in range(1, int(math.sqrt(L))+2):\n if L%l == 0:\n P.append(l+1)\n P.append(L//l+1)\n P.sort()\n\n ans = -1\n for p in P:\n if p == 1: continue\n S0 = search(p)\n if S == S0:\n ans = p\n break\n\n print(ans)\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s449177735', 's229353393']
[3064.0, 3188.0]
[17.0, 52.0]
[497, 655]
p04016
u794543767
2,000
262,144
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
['import itertools\nimport math \n\nn,s = [int(input()) for _ in range(2)]\n\ndef calc_s(b,n):\n i = 0\n s = 0\n while(1):\n s+= n %b\n n = math.floor(n/b)\n i+=1\n if n ==0:\n break\n return s\n\ndef search_p(n,s):\n for p in range(1,math.ceil(math.sqrt(n))+1):\n b = n//p\n q = n - b*p\n if p+q ==s:\n return b\n return -1\n\nif s == n:\n ans = n+1\nelif s < math.sqrt(n):\n for b in range(2,math.ceil(math.sqrt(n))+1):\n if s== calc_s(b,n):\n ans = b\n break\n ans = -1\nelse:\n ans = search_p(n,s)\n\nprint(ans)\n\n\n\n\n', 'import itertools\nimport math \n \nn,s = [int(input()) for _ in range(2)]\n \ndef n_base_sum(n,b):\n if(math.floor(n/b)):\n return n_base_sum(math.floor(n/b),b)+n%b\n else:\n return n%b\n \ndef search_p(n,s):\n for p in range(math.floor(math.sqrt(n))+1,0,-1):\n b = (n-s)//p + 1\n if b >1 :\n q = n % b\n if p+q ==s and q < b and n == p*b+q and p<b:\n return b\n \n return -1\n \nans =-1\nflag = False\nanswers = []\nif s == n:\n ans = n+1\n flag =True\n answers.append(ans)\nfor b in range(2,math.ceil(math.sqrt(n))+1):\n if s== n_base_sum(n,b):\n ans = b\n flag = True\n answers.append(ans)\n break\nans = search_p(n,s)\nif ans != -1:\n flag =True\n answers.append(ans)\n \nif not flag:\n print(-1)\nelse:\n print(int(min(answers)))']
['Wrong Answer', 'Accepted']
['s528850028', 's302137641']
[3064.0, 3188.0]
[384.0, 549.0]
[614, 829]
p04016
u803848678
2,000
262,144
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
['n = int(input())\ns = int(input())\n\nans = []\nfor i in range(2, n):\n use_n = n\n tmp_ans = 0\n if i*i > n:\n break\n while use_n:\n tmp_ans += use_n%i\n use_n //= i\n if tmp_ans == s:\n print("a")\n print(i)\n exit()\n \nfor p in range(2, n):\n if p*p > n or p >= 100:\n break\n q = s - p\n if not 0<=q<100:\n continue\n b = (n-q)//p\n if n == p*b + q:\n ans.append(b)\nif len(ans):\n print(min(ans))\nelse:\n print(-1)\n', 'n = int(input())\ns = int(input())\n\nsqrt = 0\nfor i in range(n+1):\n if i*i >= n:\n sqrt = i\n break\n\ndef dsum(n, b):\n ret = 0\n while n :\n ret += n % b\n n //= b\n return ret\n\n\nif s > n:\n print(-1)\n exit()\nif s == n:\n print(n+1)\n exit()\n\n# b = 2 ~ sqrt\n\nfor b in range(2, sqrt+1):\n use_n = n\n ans_tmp = dsum(n, b)\n if ans_tmp == s:\n print(b)\n exit()\n\n\n\n\nfor p in range(1, sqrt)[::-1]:\n b = (n-s)//p + 1\n if b > 1 and dsum(n, b) == s:\n print(b)\n exit()\nprint(-1)\n']
['Wrong Answer', 'Accepted']
['s828438870', 's094496904']
[3188.0, 3188.0]
[423.0, 518.0]
[496, 641]
p04016
u879309973
2,000
262,144
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
['import numpy as np\ndef f(b, n):\n s = 0\n while n > 0:\n s += n % b\n n //= b\n return s\n\nINF = int("inf")\ndef solve(n, s):\n if n < s:\n return -1\n if n == s:\n return n+1\n m = int(np.sqrt(n)) + 1\n for b in range(2, m+1):\n if f(b, n) == s:\n return b\n best = INF\n for p in range(1, m+1):\n q = s - p\n if (n - q) % p != 0:\n continue\n b = (n - q) // p\n if (b > 1) and (f(b, n) == s):\n best = min(best, s)\n return -1 if (best == INF) else best\n\nn = int(input())\ns = int(input())\nprint(solve(n, s))', 'import numpy as np\ndef f(b, n):\n s = 0\n while n > 0:\n s += n % b\n n //= b\n return s\n\nINF = 10**15\ndef solve(n, s):\n if n == s:\n return n+1\n m = int(np.sqrt(n)) + 1\n for b in range(2, m+1):\n if f(b, n) == s:\n return b\n best = INF\n for p in range(1, m+10):\n q = s - p\n b = (n - q) // p\n if (b > p) and (b > q) and (f(b, n) == s):\n best = min(best, b)\n return -1 if (best == INF) else best\n\nn = int(input())\ns = int(input())\nprint(solve(n, s))']
['Runtime Error', 'Accepted']
['s132432149', 's403949548']
[12508.0, 14404.0]
[150.0, 561.0]
[611, 538]
p04016
u922901775
2,000
262,144
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
["#!/usr/bin/env python3\nimport sys\n\n\ndef f(n, b):\n if n < b:\n return n\n else:\n return n // b + f(n % b, b)\n\n\ndef solve(n: int, s: int):\n if s > n:\n return -1\n\n if s == n:\n return n+1\n\n b = 2\n while b * b <= n:\n if f(n, b) == s:\n return b\n b += 1\n \n for p in range(b-1, 0, -1):\n if (n - s) % p > 0:\n continue\n\n c = (n - s) // p + 1\n if f(n, c) == s:\n return c\n \n return -1\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n n = int(next(tokens)) # type: int\n s = int(next(tokens)) # type: int\n print(solve(n, s))\n\nif __name__ == '__main__':\n main()\n", "#!/usr/bin/env python3\nimport sys\n\n\ndef f(n, b):\n if n < b:\n return n\n else:\n return n % b + f(n // b, b)\n\n\ndef solve(n: int, s: int):\n if s > n:\n return -1\n\n if s == n:\n return n+1\n\n b = 2\n while b * b <= n:\n if f(n, b) == s:\n return b\n b += 1\n \n for p in range(b-1, 0, -1):\n if (n - s) % p > 0:\n continue\n\n c = (n - s) // p + 1\n if f(n, c) == s:\n return c\n \n return -1\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n n = int(next(tokens)) # type: int\n s = int(next(tokens)) # type: int\n print(solve(n, s))\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s138989975', 's866376771']
[3064.0, 3064.0]
[225.0, 280.0]
[969, 969]
p04017
u218843509
3,000
262,144
N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i. Tak the traveler has the following two personal principles: * He never travels a distance of more than L in a single day. * He never sleeps in the open. That is, he must stay at a hotel at the end of a day. You are given Q queries. The j-th (1 \leq j \leq Q) query is described by two distinct integers a_j and b_j. For each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles. It is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.
['from bisect import bisect, bisect_left\nimport sys\n\nn = int(input())\nx = list(map(int, input().split()))\nl = int(input())\n\ndef search_1(start):\n\treturn bisect(x, x[start] + l) - 1\n\nroute = [[] for _ in range(n)]\n\ni = 0 \nfor i in range(n - 1):\n\tif route[i] == []:\n\t\tj = search_1(i) \n\t\tnum = 1 \n\t\troute[i].append(j)\n\t\tif route[j] == []:\n\t\t\troute[j] = (i, num)\n\t\telse: \n\t\t\troute[i] += route[route[j][0]][route[j][1]:]\n\t\t\tcontinue\n\t\twhile j < n - 1:\n\t\t\tj = search_1(j)\n\t\t\tnum += 1\n\t\t\troute[i].append(j)\n\t\t\tif route[j] == []:\n\t\t\t\troute[j] = (i, num)\n\t\t\telse: \n\t\t\t\troute[i] += route[route[j][0]][route[j][1]:]\n\t\t\t\tbreak\n\telse:\n\t\tcontinue\n\n# print(route)\n\ndef search_2(start, goal):\n\tif type(route[start]) == type([]):\n\t\treturn bisect_left(route[start], goal) + 1\n\telse:\n\t\treturn bisect_left(route[route[start][0]][route[start][1]:], goal) + 1\n\n\n\nq = int(input())\nfor _ in range(q):\n\ta, b = map(int, sys.stdin.redline().strip().split())\n\tif a > b:\n\t\ta, b = b, a\n\tprint(search_2(a - 1, b - 1))', 'from bisect import bisect\nimport sys\n\nn = int(input())\nx = list(map(int, input().split()))\nl = int(input())\nq = int(input())\n\n\nr = [[i for i in range(n)] for _ in range(18)]\nfor j in range(n):\n\tr[0][j] = bisect(x, x[j]+l) - 1\nfor i in range(1, 18):\n\tfor j in range(n):\n\t\tr[i][j] = r[i-1][r[i-1][j]]\n\ndef search(x, y):\n\tres = 0\n\tcur = x\n\ti = 17\n\twhile True:\n\t\tif i == 0 and r[i][cur] >= y:\n\t\t\treturn res+1\n\t\tif r[i][cur] < y:\n\t\t\tcur = r[i][cur]\n\t\t\tres += 1 << i\n\t\t\tcontinue\n\t\ti -= 1\n\nfor _ in range(q):\n\ta, b = map(int, sys.stdin.readline().strip().split())\n\tprint(search(min(a, b)-1, max(a, b)-1))']
['Runtime Error', 'Accepted']
['s749318649', 's652340677']
[1874532.0, 78940.0]
[3287.0, 1603.0]
[1114, 641]
p04017
u340781749
3,000
262,144
N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i. Tak the traveler has the following two personal principles: * He never travels a distance of more than L in a single day. * He never sleeps in the open. That is, he must stay at a hotel at the end of a day. You are given Q queries. The j-th (1 \leq j \leq Q) query is described by two distinct integers a_j and b_j. For each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles. It is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.
['import sys\nfrom bisect import bisect\n\nn = int(input())\nxxx = list(map(int, input().split()))\nl = int(input())\n\nreachable = [[bisect(xxx, x + l) - 1 for x in xxx]]\nwhile reachable[-1][0] < n - 1:\n rp = reachable[-1]\n reachable.append([rp[rp[i]] for i in range(n)])\n\nq = int(input())\nbuf = []\nfor line in sys.stdin:\n a, b = map(int, line.split())\n a -= 1\n b -= 1\n if a > b:\n a, b = b, a\n ans = 0\n for i in range(len(reachable) - 1, -1, -1):\n if reachable[i][a] > b:\n continue\n ans += 1 << i\n a = reachable[i][a]\n if a != b:\n ans += 1\n buf.append(ans)\n\nprint(*buf)\n', "import sys\nfrom bisect import bisect\n\nn = int(input())\nxxx = list(map(int, input().split()))\nl = int(input())\n\nreachable = [[bisect(xxx, x + l) - 1 for x in xxx]]\nwhile reachable[-1][0] < n - 1:\n rp = reachable[-1]\n reachable.append(list(map(rp.__getitem__, rp)))\n\nq = int(input())\nbuf = []\nfor line in sys.stdin:\n a, b = map(int, line.split())\n a -= 1\n b -= 1\n if a > b:\n a, b = b, a\n ans = 0\n for i in range(len(reachable) - 1, -1, -1):\n ria = reachable[i][a]\n if ria >= b:\n continue\n ans += 1 << i\n a = ria\n if a != b:\n ans += 1\n buf.append(ans)\n\nprint('\\n'.join(map(str, buf)))\n"]
['Wrong Answer', 'Accepted']
['s117552294', 's385766026']
[31276.0, 35304.0]
[1093.0, 958.0]
[638, 665]
p04017
u467736898
3,000
262,144
N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i. Tak the traveler has the following two personal principles: * He never travels a distance of more than L in a single day. * He never sleeps in the open. That is, he must stay at a hotel at the end of a day. You are given Q queries. The j-th (1 \leq j \leq Q) query is described by two distinct integers a_j and b_j. For each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles. It is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.
['N = int(input())\nX = list(map(int, input().split()))\nL = int(input())\nQ = int(input())\n\nV = [0]*N\nib = 0\nfor i in range(N):\n while X[i]-X[ib] > L:\n V[ib] = i-1\n ib += 1\nwhile ib!=N-1:\n V[ib]=N-1\n ib += 1\nS = [0]*N\nh=N-1\ncnt = 1\nfor i in range(N-2, -1, -1):\n if h==V[i]:\n S[i] = cnt\n else:\n cnt+=1\n h=i+1\n S[i] = cnt\nfor i in range(Q):\n a, b = map(int, input().split())\n a, b = sorted([a, b])\n print(min(1, S[a-1]-S[b-1]))\n', 'N = int(input())\nX = list(map(int, input().split()))\nL = int(input())\nQ = int(input())\n\nV = [0]*N\nib = 0\nfor i in range(N):\n while X[i]-X[ib] > L:\n V[ib] = i-1\n ib += 1\nwhile ib!=N-1:\n V[ib]=N-1\n ib += 1\ndbl = [[0]*N for i in range(18)]\ndbl[0]=V\nfor i in range(1, 18):\n for j in range(N):\n ii = dbl[i-1][j]\n if ii == 0:\n break\n dbl[i][j] = dbl[i-1][ii]\nfor i in range(Q):\n a, b = map(int, input().split())\n a, b = sorted([a, b])\n a-=1\n b-=1\n ind = a\n ans = 0\n for j in range(17, -1, -1):\n if dbl[j][ind]==0:\n continue\n if dbl[j][ind]>b:\n continue\n if dbl[j][ind]==b:\n ans |= 1<<j\n break\n else:\n ans |= 1<<j\n ind = dbl[j][ind]\n else:\n ans += 1\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s207818005', 's856885911']
[15588.0, 26412.0]
[1044.0, 2536.0]
[488, 841]
p04017
u543954314
3,000
262,144
N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i. Tak the traveler has the following two personal principles: * He never travels a distance of more than L in a single day. * He never sleeps in the open. That is, he must stay at a hotel at the end of a day. You are given Q queries. The j-th (1 \leq j \leq Q) query is described by two distinct integers a_j and b_j. For each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles. It is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.
['n = int(input())\nhot = list(map(int,input().split())) \nn_ = n.bit_length()\ndb = [[n-1]*(n)]\nL = int(input())\nr = 1\nfor i in range(n-1):\n while r < n-1 and hot[r+1]-hot[i] <= L:\n r += 1\n db[0][i] = r\nfor j in range(1,n_+1):\n new = [db[-1][db[-1][i]] for i in range(n)]\n db.append(new)\n if new[0] == n-1:\n break\nn_ = len(db)\n\nfor x in db:\n print(x)\n \ndef query(s,t):\n dt = 0\n for j in range(n_-1,0,-1):\n if db[j][s] < t:\n dt += 2**j\n s = db[j][s]\n while s < t:\n dt += 1\n s = db[0][s]\n return dt \n\nq = int(input())\nfor _ in range(q):\n s,t = map(int,input().split())\n if t < s:\n s,t = t,s\n print(query(s-1,t-1))\n ', 'n = int(input())\nhot = list(map(int,input().split())) \nn_ = n.bit_length()\ndb = [[n-1]*(n)]\nL = int(input())\nr = 1\nfor i in range(n-1):\n while r < n-1 and hot[r+1]-hot[i] <= L:\n r += 1\n db[0][i] = r\nfor j in range(1,n_+1):\n new = [db[-1][db[-1][i]] for i in range(n)]\n db.append(new)\n if new[0] == n-1:\n break\nn_ = len(db)\n\ndef query(s,t):\n dt = 0\n for j in range(n_-1,0,-1):\n if db[j][s] < t:\n dt += 2**j\n s = db[j][s]\n while s < t:\n dt += 1\n s = db[0][s]\n return dt \n\nq = int(input())\nfor _ in range(q):\n s,t = map(int,input().split())\n if t < s:\n s,t = t,s\n print(query(s-1,t-1))\n ']
['Wrong Answer', 'Accepted']
['s696295608', 's315075770']
[39340.0, 24988.0]
[2045.0, 1870.0]
[653, 626]
p04017
u729133443
3,000
262,144
N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i. Tak the traveler has the following two personal principles: * He never travels a distance of more than L in a single day. * He never sleeps in the open. That is, he must stay at a hotel at the end of a day. You are given Q queries. The j-th (1 \leq j \leq Q) query is described by two distinct integers a_j and b_j. For each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles. It is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.
['from math import*\nfrom bisect import*\nn,*t=map(int,open(0).read().split())\nm=int(log2(n))+1\nx=t[:n]\nl=t[n]\nd=[[bisect(x,y+l)-1for y in x]]+[[0]*n for _ in range(m)]\nfor i in range(m):\n for j in range(n):\n d[i+1][j]=d[i][d[i][j]]\nprint(d)\nfor a,b in zip(t[n+2::2],t[n+3::2]):\n a-=1\n b-=1\n if b<a:a,b=b,a\n c=1\n for i in range(m,-1,-1):\n if d[i][a]<b:\n a=d[i][a]\n c+=2**i\n print(c)', 'n,*x=map(int,open(0).read().split())\nd=[0]+[10**9]*~-n\nl=x[n]\ni=t=0\nfor j,y in enumerate(x[1:n],1):\n t=y-x[i]\n while t>l:\n i+=1\n t=y-x[i]\n print(i,j,t)\n d[j]=d[i]+1\nfor a,b in zip(x[n+2::2],x[n+3::2]):\n print(abs(d[a-1]-d[b-1])or 1)', 'from math import*\nfrom bisect import*\nn,*t=map(int,open(0).read().split())\nm=int(log2(n))+1\nx=t[:n]\nl=t[n]\nd=[[bisect(x,y+l)-1for y in x]]+[[0]*n for _ in range(m)]\nfor i in range(m):\n for j in range(n):\n d[i+1][j]=d[i][d[i][j]]\nfor a,b in zip(t[n+2::2],t[n+3::2]):\n a-=1\n b-=1\n if b<a:a,b=b,a\n c=1\n for i in range(m,-1,-1):\n if d[i][a]<b:\n a=d[i][a]\n c+=2**i\n print(c)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s341707865', 's912778606', 's510547435']
[73248.0, 35948.0, 37228.0]
[1740.0, 447.0, 1510.0]
[435, 261, 426]
p04018
u102461423
2,000
262,144
Let x be a string of length at least 1. We will call x a _good_ string, if for any string y and any integer k (k \geq 2), the string obtained by concatenating k copies of y is different from x. For example, `a`, `bbc` and `cdcdc` are good strings, while `aa`, `bbbb` and `cdcdcd` are not. Let w be a string of length at least 1. For a sequence F=(\,f_1,\,f_2,\,...,\,f_m) consisting of m elements, we will call F a _good representation_ of w, if the following conditions are both satisfied: * For any i \, (1 \leq i \leq m), f_i is a good string. * The string obtained by concatenating f_1,\,f_2,\,...,\,f_m in this order, is w. For example, when w=`aabb`, there are five good representations of w: * (`aabb`) * (`a`,`abb`) * (`aab`,`b`) * (`a`,`ab`,`b`) * (`a`,`a`,`b`,`b`) Among the good representations of w, the ones with the smallest number of elements are called the _best representations_ of w. For example, there are only one best representation of w=`aabb`: (`aabb`). You are given a string w. Find the following: * the number of elements of a best representation of w * the number of the best representations of w, modulo 1000000007 \, (=10^9+7) (It is guaranteed that a good representation of w always exists.)
['import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nW = list(map(int,read().rstrip()))\n\nN = len(W)\n\ndef Z_Algorithm(S):\n \n N=len(S)\n arr = [0]*N\n arr[0] = N\n i,j = 1,0\n while i<N:\n while i+j<N and S[j]==S[i+j]:\n j += 1\n arr[i]=j\n if not j:\n i += 1\n continue\n k = 1\n while i+k<N and k+arr[k]<j:\n arr[i+k] = arr[k]\n k += 1\n i += k; j -= k\n return arr\n\nZ_Algorithm(W)', "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nW = read().rstrip()\n\nN = len(W)\n\ndef Z_algorithm(S):\n \n N=len(S)\n arr = [0]*N\n arr[0] = N\n i,j = 1,0\n while i<N:\n while i+j<N and S[j]==S[i+j]:\n j += 1\n arr[i]=j\n if not j:\n i += 1\n continue\n k = 1\n while i+k<N and k+arr[k]<j:\n arr[i+k] = arr[k]\n k += 1\n i += k; j -= k\n return arr\n\ndef is_periodic_left(W):\n Z = Z_algorithm(W)\n is_periodic = [False] * N\n for p in range(1,N//2 + 1):\n if is_periodic[p-1]:\n continue\n for i in range(p,N,p):\n if Z[i] >= p:\n is_periodic[p + i - 1] = True\n else:\n break\n return is_periodic\n\nL = is_periodic_left(W)\nR = is_periodic_left(W[::-1])[::-1]\n\nif not L[-1]:\n answer = (1,1)\nelif len(set(W)) == 1:\n answer = (N,1)\nelse:\n x = sum(not(x or y) for x,y in zip(L,R[1:]))\n answer = (2,x)\nprint('\\n'.join(map(str,answer)))"]
['Wrong Answer', 'Accepted']
['s817931153', 's639820269']
[27332.0, 31588.0]
[361.0, 741.0]
[582, 1123]
p04018
u378667182
2,000
262,144
Let x be a string of length at least 1. We will call x a _good_ string, if for any string y and any integer k (k \geq 2), the string obtained by concatenating k copies of y is different from x. For example, `a`, `bbc` and `cdcdc` are good strings, while `aa`, `bbbb` and `cdcdcd` are not. Let w be a string of length at least 1. For a sequence F=(\,f_1,\,f_2,\,...,\,f_m) consisting of m elements, we will call F a _good representation_ of w, if the following conditions are both satisfied: * For any i \, (1 \leq i \leq m), f_i is a good string. * The string obtained by concatenating f_1,\,f_2,\,...,\,f_m in this order, is w. For example, when w=`aabb`, there are five good representations of w: * (`aabb`) * (`a`,`abb`) * (`aab`,`b`) * (`a`,`ab`,`b`) * (`a`,`a`,`b`,`b`) Among the good representations of w, the ones with the smallest number of elements are called the _best representations_ of w. For example, there are only one best representation of w=`aabb`: (`aabb`). You are given a string w. Find the following: * the number of elements of a best representation of w * the number of the best representations of w, modulo 1000000007 \, (=10^9+7) (It is guaranteed that a good representation of w always exists.)
["w=list(input())\nn=len(w)\nper=-1\ndef Z(s):\n m=len(s);z=[0]*m;c=0;f=[1]*m;\n for i in range(1,m):\n if i+z[i-c]<c+z[c]:z[i]=z[i-c]\n else:\n j=max(0,c+z[c]-i)\n while i+j<n and s[j]==s[i+j]:j=j+1\n z[i]=j;c=i\n for p in range(1,m):\n for k in range(2,z[p]//p+2):f[k*p-1]=0\n return f\nfor j in range(1,n//2+1):\n if n%j==0 and w[:n-j]==w[j:]:t=j;break;\nif t==-1:print ('1\\n1')\nelif t==1:print (n);print (1)\nelse:\n zl=Z(w)\n w.reverse()\n zr=Z(w)\n cnt=0\n for i in range(0,n-1):\n if zl[i] and zr[n-2-i]:cnt=cnt+1\n print(2);print(cnt);", "w=list(input());n=len(w);t=-1\ndef Z(s):\n m=len(s);z=[0]*m;c=0;f=[1]*m;\n for i in range(1,m):\n if i+z[i-c]<c+z[c]:z[i]=z[i-c]\n else:\n j=max(0,c+z[c]-i)\n while i+j<n and s[j]==s[i+j]:j=j+1\n z[i]=j;c=i\n for p in range(1,m):\n for k in range(2,z[p]//p+2):f[k*p-1]=0\n return f\nfor j in range(1,n//2+1):\n if n%j==0 and w[:n-j]==w[j:]:t=j;break;\nif t==-1:print ('1\\n1')\nelif t==1:print (n);print (1)\nelse:\n zl=Z(w)\n w.reverse()\n zr=Z(w)\n cnt=0\n for i in range(0,n-1):\n if zl[i] and zr[n-2-i]:cnt=cnt+1\n print(2);print(cnt);\n"]
['Runtime Error', 'Accepted']
['s264726530', 's635695473']
[26500.0, 26500.0]
[1514.0, 1616.0]
[611, 610]
p04019
u024782094
2,000
262,144
Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction: * North if the i-th letter of S is `N` * West if the i-th letter of S is `W` * South if the i-th letter of S is `S` * East if the i-th letter of S is `E` He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.
['s=input()\nn=s.count("N")\nw=s.count("W")\ns=s.count("S")\ne=s.count("E")\nns=n+s\nwe=w+e\nif n>0 and w>0 and s>0 and e>0:\n print("Yes")\nelif n>0 and w>0 and we==0:\n print("Yes")\nelif ns==0 and s>0 and e>0:\n print("Yes")\nelse print("No")', 'i=set(input())\nif i=={"E","N","S","W"} or i=={"N","S"} or i=={"E","W"}:\n print("Yes")\nelse:\n print("No")']
['Runtime Error', 'Accepted']
['s830266921', 's934300668']
[3064.0, 2940.0]
[18.0, 18.0]
[233, 110]