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
|
---|---|---|---|---|---|---|---|---|---|---|
p03705 | u766407523 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['N, A, B = map(int, input().split())\nif A > B:\n print(0)\nelif N = 1:\n if A = B:\n print(1)\n else:\n print(0)\nelse:\n print((A+(N-1)*B)-((N-1)*A+B)+1)\n', 'N, A, B = map(int, input().split())\nif A > B:\n print(0)\nelif N == 1:\n if A == B:\n print(1)\n else:\n print(0)\nelse:\n print((A+(N-1)*B)-((N-1)*A+B)+1)\n'] | ['Runtime Error', 'Accepted'] | ['s712337449', 's533767814'] | [2940.0, 2940.0] | [17.0, 17.0] | [172, 174] |
p03705 | u767664985 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['N, A, B = map(int, input().split())\nif A > B:\n\tprint(0)\nelif N == 1 and A < B:\n\tprint(0)\nelse:\n\tprint(A + (N - 1) * B - B + (N - 1) * A + 1)\n', 'N, A, B = map(int, input().split())\nif A > B:\n\tprint(0)\nelif N == 1 and A < B:\n\tprint(0)\nelse:\n\tprint(A + (N - 1) * B - B - (N - 1) * A + 1)\n'] | ['Wrong Answer', 'Accepted'] | ['s459191983', 's697130020'] | [2940.0, 2940.0] | [17.0, 17.0] | [141, 141] |
p03705 | u785989355 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['S = input()\nN= len(S)\nans = 0\n\nfor i in range(N):\n if S[i]=="U":\n ans+= 2*i + N-i-1\n else:\n ans+= i + 2*(N - i -1)\n \nprint(ans)', '\nN,A,B = list(map(int,input().split()))\nif B<A:\n print(0)\nelif B!=A and N==1:\n print(0)\nelse:\n print(B*(N-1) + A - A*(N-1) - B + 1)'] | ['Wrong Answer', 'Accepted'] | ['s456444994', 's272263254'] | [2940.0, 3060.0] | [18.0, 18.0] | [147, 140] |
p03705 | u811528179 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['n,a,b=map(int,input().split())\n\nif n==1 and a!=b:\n print(0)\n exit()\nelif n==1 and a==b:\n print(1)\n exit()\n\nif b<a:\n print(0)\n exit()\n\nprint(2+n-(b-a))\n', 'n,a,b=map(int,input().split())\n\nif n==1 and a!=b:\n print(0)\n exit()\nelif n==1 and a==b:\n print(1)\n exit()\n\nif b<a:\n print(0)\n exit()\n\nprint(n*(b-a)-2*(b-a)+1)\n'] | ['Wrong Answer', 'Accepted'] | ['s626144513', 's885751678'] | [2940.0, 3060.0] | [17.0, 17.0] | [169, 177] |
p03705 | u829416877 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['N, A, B = map(int, input().split())\nif A > B:\n print(0)\nelif A == B:\n print(1)\nelif B-A >=N:\n print(0)\nelse: \n print((B-A)*X+1)', 'N, A, B = map(int, input().split())\nif A > B:\n print(0)\nelse:\n if N == 1 and A == B:\n print(1)\n elif N == 1:\n print(0)\n else:\n print((B-A)*(N-2)+1)'] | ['Runtime Error', 'Accepted'] | ['s775857138', 's365884257'] | [9172.0, 9144.0] | [27.0, 29.0] | [131, 160] |
p03705 | u835283937 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['def main():\n N = input()\n S = str(N)\n S = S[::-1]\n\n odd = 0\n even = 0\n\n for i in range(len(S)):\n if (i + 1) % 2 == 0:\n even += int(S[i])\n else:\n odd += int(S[i])\n print(even, odd)\n\nif __name__ == "__main__":\n main()', 'def main():\n N, A, B = map(int, input().split())\n ans = 0\n\n if A > B:\n ans = 0\n else:\n if N == 1:\n if A != B:\n ans = 0\n else:\n ans = 1\n elif N == 2:\n ans = 1\n else:\n ans = (B - A)*(N - 2) + 1\n\n print(ans)\n \nif __name__ == "__main__":\n main()'] | ['Runtime Error', 'Accepted'] | ['s897393439', 's621963746'] | [3060.0, 3060.0] | [17.0, 18.0] | [275, 364] |
p03705 | u844789719 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['N, A, B = [int(_) for _ in input().split()]\nif N == 1 and A == B or A <= B:\n print((N - 1) * (B - A) + 1)\nelse:\n print(0)\n', 'N, A, B = [int(_) for _ in input().split()]\nans = 0\nif N == 1 or A == B:\n ans += A == B\nelif N == 2:\n ans = 2 * (A < B)\nelif B > A:\n ans = (N - 2) * (B - A) + 1\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s716213267', 's899921134'] | [2940.0, 2940.0] | [17.0, 18.0] | [128, 181] |
p03705 | u846150137 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['n,a,b=map(int,input().split())\nif a>b or (n==1 and a!=b):\n print(0)\n exit()\nelse:\n print((a-b)*max(n-2,0)+1)', 'n,a,b=map(int,input().split())\nif a>b or (n==1 and a!=b):\n print(0)\n exit()\nelse:\n print((a-b)*n+1)', 'n,a,b=map(int,input().split())\nif a>b or (n==1 and a!=b):\n print(0)\n exit()\nelse:\n print((b-a)*max(n-2,0)+1)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s154013837', 's774503502', 's688519333'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 18.0] | [111, 102, 111] |
p03705 | u846552659 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['# -*- coding:utf-8 -*-\nimport math\nN, A, B = map(int, input().split())\nif N != 1 and A <= B:\n n = math.factorial(B-A+N-2)\n a = math.factorial(N-2)\n b = math.factorial(B-A)\n print(n/(a*b))\nelse:\n if A != B:\n print(0)\n else:\n print(1)', "# -*- coding:utf-8 -*-\nimport math\nN, A, B = map(int, input().split())\nif N != 1 and A <= B:\n '''\n n = math.factorial(B-A+N-2)\n a = math.factorial(N-2)\n b = math.factorial(B-A)\n print(n//(a*b))\n '''\n print((B-A)*(N-2)+1)\nelse:\n if A != B:\n print(0)\n else:\n print(1)"] | ['Wrong Answer', 'Accepted'] | ['s340204546', 's901137606'] | [6776.0, 3060.0] | [2104.0, 17.0] | [264, 306] |
p03705 | u853900545 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['n,a,b = map(int,input().split())\nif n==1 or n==2 or a == b:\n print(1)\nelse:\n print((n-2)*(b-a))', 'n,a,b = map(int,input().split())\nif a>b or (n==1 and a!=b):\n print(0)\nelif n==1 or n==2 or a == b:\n print(1)\nelse:\n print((n-2)*(b-a)+1)'] | ['Wrong Answer', 'Accepted'] | ['s236133924', 's860263584'] | [2940.0, 3060.0] | [18.0, 17.0] | [101, 145] |
p03705 | u856232850 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['n,a,b = list(map(int,input().split()))\n\nif a>b:\n print(0)\nelif a == b:\n print(1)\nelif n == 2:\n print(1)\nelif n == 1:\n print(0)\nelse:\n print(2*b-2*a)', 'n,a,b = list(map(int,input().split()))\n\nif a>b:\n print(0)\nelif a == b:\n print(1)\nelif n == 2:\n print(1)\nelif n == 1:\n print(0)\nelse:\n print((n-2)*b-(n-2)*a+1)'] | ['Wrong Answer', 'Accepted'] | ['s964283383', 's405079089'] | [2940.0, 2940.0] | [17.0, 17.0] | [163, 173] |
p03705 | u859897687 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['n,a,b=map(int,input().split())\nif a>b:\n print(0)\nelif n==1 and a<b:\n print(0)\nelse:\n print((b-a)*n+1)', 'n,a,b=map(int,input().split())\nif a>b:\n print(0)\nelif n==1 and a<b:\n print(0)\nelse:\n print((b-a)*(n-2)+1)'] | ['Wrong Answer', 'Accepted'] | ['s058913806', 's887236686'] | [2940.0, 3060.0] | [18.0, 18.0] | [104, 108] |
p03705 | u863370423 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['n = int(input())\na = int(input())\nb = int(input())\nif n == 1 and a == b:\n print(1)\nelif n<2 or a>b:\n print(0)\nelse:\n print((n-2)*(b-a)+1)\n', 'N, A, B = [int(i) for i in input().split()]\nres = max(0, (N-2) * B - (N-2) * B + 1)\nprint(res)', 'a,b,c = map(int,input().split())\nif a<=1:\n if b==c:\n print(1)\n else:\n print(0)\nelif b>c:\n print(0)\nelse:\n print((a-2)*(c-b)+1)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s202146408', 's579348810', 's997524355'] | [2940.0, 2940.0, 3060.0] | [18.0, 17.0, 18.0] | [147, 94, 152] |
p03705 | u888337853 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ["import sys\nimport re\nimport math\nimport collections\nimport decimal\nimport bisect\nimport itertools\nimport fractions\nimport functools\nimport copy\n\n# import heapq\n# from collections import deque\n\n\nsys.setrecursionlimit(10000001)\nINF = sys.maxsize\nMOD = 10 ** 9 + 7\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\ndef main():\n n, a, b = ns()\n\n if n == 2:\n print(1)\n exit(0)\n\n if a > b or n < 2:\n print(0)\n exit(0)\n\n minimum_sum = a * n + (b - a)\n maximum_sum = a * n - (b - a)\n print(maximum_sum - minimum_sum + 1)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nimport re\nimport math\nimport collections\nimport decimal\nimport bisect\nimport itertools\nimport fractions\nimport functools\nimport copy\n\n# import heapq\n# from collections import deque\n\n\nsys.setrecursionlimit(10000001)\nINF = sys.maxsize\nMOD = 10 ** 9 + 7\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\ndef main():\n n, a, b = ns()\n\n if n == 2:\n print(1)\n exit(0)\n\n if a > b:\n print(0)\n exit(0)\n\n if n==1:\n if a==b:\n print(1)\n exit(0)\n else:\n print(0)\n exit(0)\n\n minimum_sum = a * n + (b - a)\n maximum_sum = b * n - (b - a)\n print(maximum_sum - minimum_sum + 1)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s685880740', 's229040769'] | [5076.0, 5076.0] | [38.0, 37.0] | [731, 849] |
p03705 | u896741788 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['p,n,m=map(int,input().split())\nif p==1:print(m==n)\nelif n>m:print(0)\nelse:print((m-n+1)*(p-2)+1)', 'p,n,m=map(int,input().split())\nif p==1:print(int(m==n))\nelif n>m:print(0)\nelse:print((m-n)*(p-2)+1)\n'] | ['Wrong Answer', 'Accepted'] | ['s558573216', 's036382915'] | [2940.0, 2940.0] | [17.0, 18.0] | [96, 100] |
p03705 | u905582793 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['a=int(input())\nb=int(input())\nif a==b:\n print(1)\n exit()\nabin=bin(a)[2:]\nbbin=bin(b)[2:]\nla=len(abin)\nlb=len(bbin)\nif la==lb:\n while abin[0]==bbin[0]:\n abin=abin[1:]\n bbin=bbin[1:]\n while len(abin)>1 and abin[0]=="0":\n abin=abin[1:]\ncbin=bbin[1:]\nwhile cbin and cbin[0]=="0":\n cbin=cbin[1:]\nc=2**(len(cbin))-1\na=int(abin,2)\nb=int(bbin,2)\nlb=len(bbin)\nlbnd=2**(lb-1)+c\nhbnd=2**(lb-1)+a\nif lbnd>=hbnd:\n print(2**lb-a)\nelse:\n print(2**(lb-1)-a+lbnd-a+1)\n', 'n,a,b=map(int,input().split())\nif a>b:\n print(0)\n exit()\nif n == 1:\n if a == b:\n print(1)\n else:\n print(0)\n exit()\nif n == 2:\n print(1)\n exit()\nprint((b-a)*(n-2)+1)'] | ['Runtime Error', 'Accepted'] | ['s133523964', 's824398734'] | [3064.0, 3060.0] | [17.0, 17.0] | [467, 177] |
p03705 | u921773161 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['N, A, B = map(int, input().split())\n\nif N == 1 :\n if A != B :\n ans = 0\n elif :\n ans = 1\n\n\n\nelif A > B :\n ans = 0\nelif A == B :\n ans = 1\nelse:\n ans = (B*(N-1)+A) - (A*(N-1)+B) + 1\n\nprint(ans)', 'N, A, B = map(int, input().split())\n\nif N == 1 :\n if A != B :\n ans = 0\n else :\n ans = 1\n\n\n\nelif A > B :\n ans = 0\nelif A == B :\n ans = 1\nelse:\n ans = (B*(N-1)+A) - (A*(N-1)+B) + 1\n\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s249620163', 's849462044'] | [2940.0, 2940.0] | [17.0, 17.0] | [219, 220] |
p03705 | u941753895 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['n,a,b=map(int,input().split())\nif n==4 and a==4 and b==6:\n exit()\nif n==1 and a!=b:\n print(0)\nelif a>b:\n print(0)\nelif a==b:\n print(1)\nelse:\n print(b-a+1)', 'n,a,b=map(int,input().split())\nif n==4 and a==4 and b==6:\n exit()\nif n==1 and a!=b:\n print(0)\nelif a>b:\n print(0)\nelif a==b:\n print(1)\nelse:\n print((n-2)*b-(n-2)*a+1)', 'n,a,b=map(int,input().split())\nif n==1 and a!=b:\n print(0)\nelif a>b:\n print(0)\nelif a==b:\n print(1)\nelse:\n print((n-2)*b-(n-2)*a+1)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s491966923', 's888307581', 's016893326'] | [3060.0, 3060.0, 2940.0] | [17.0, 18.0, 17.0] | [159, 171, 135] |
p03705 | u945418216 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['import math\nn,a,b = map(int, input().split())\n\nif a>b:\n print(0)\nelif n==1 and a != b:\n print(0)\nelse:\n print((b*(n-2)+a) - (a*(n-2)+b) +1 )\n', 'import math\nn,a,b = map(int, input().split())\n\nif a>b:\n print(0)\nelif n==1 and a != b:\n print(0)\nelse:\n print((b*(n-1)+a) - (a*(n-1)+b) +1 )\n'] | ['Wrong Answer', 'Accepted'] | ['s802210704', 's341898396'] | [2940.0, 2940.0] | [17.0, 17.0] | [150, 150] |
p03705 | u950708010 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['1 3 3\n', 'n,a,b = (int(i) for i in input().split())\nif a >b:\n print(0)\n exit()\nelif n == 1 and a!=b:\n print(0)\n exit()\nif n<= 2:\n print(1)\nelse:\n mi = a*(n-1)+b\n ma = a+(n-1)*b\n print(ma-mi+1)'] | ['Runtime Error', 'Accepted'] | ['s989890576', 's053949790'] | [3064.0, 3060.0] | [19.0, 17.0] | [6, 190] |
p03705 | u970308980 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['N, A, B = map(int, input().split())\n\nq = B - A + 1\n\nif N == 1:\n if A == B:\n print(1)\n else:\n print(0)\n exit()\n\nif N == 2:\n print(1)\n exit()\n\nc = N - 2\nprint((q ** c) - q)\n', 'N, A, B = map(int, input().split())\n\nif N == 1:\n if A == B:\n print(1)\n else:\n print(0)\n exit()\n\nif A > B:\n print(0)\n exit()\n\n\nans = B * (N - 2) - A * (N - 2) + 1\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s917931952', 's451632957'] | [9936.0, 2940.0] | [2104.0, 17.0] | [200, 236] |
p03705 | u970809473 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['n,a,b = map(int, input().split())\nif n == 1:\n if a != b:\n print(0)\n else:\n print(1)\nelif n == 2:\n if a == b or a < b:\n print(1)\n else:\n print(0)\nelse:\n if a > b:\n print(0)\n else:\n print((b - a) * (n - 2))', 'n,a,b = map(int, input().split())\nif n == 1:\n if a != b:\n print(0)\n else:\n print(1)\nelif n == 2:\n if a == b or a < b:\n print(1)\n else:\n print(0)\nelse:\n if a > b:\n print(0)\n else:\n print((b - a) * (n - 2) + 1)'] | ['Wrong Answer', 'Accepted'] | ['s371421644', 's368506909'] | [3060.0, 3060.0] | [17.0, 17.0] | [229, 233] |
p03705 | u980205854 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['# A - A+...+B Problem\n\nN, A, B = map(int, input().split())\n\nif A>B or (N==1 and A!=B):\n print(0)\nelse:\n print((N-1)*B+A - (N-1)*A+B + 1)', '# A - A+...+B Problem\n\nN, A, B = map(int, input())\n\nif A>B or (N==1 and A!=B):\n print(0)\nelse:\n print((N-1)*B+A - (N-1)*A+B + 1)', '# A - A+...+B Problem\n\nN, A, B = map(int, input().split())\n\nif A>B or (N==1 and A!=B):\n print(0)\nelse:\n print((N-2)*(B-A)+1)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s696123122', 's991661223', 's922291780'] | [2940.0, 2940.0, 2940.0] | [17.0, 16.0, 17.0] | [142, 134, 130] |
p03705 | u987164499 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['n,a,b = map(int,input().split())\n\nprint(max(b*(n-1)+a-(a*(n-1)+b)+1),0)', 'n,a,b = map(int,input().split())\n\nprint(max(b*(n-1)+a-(a*(n-1)+b)+1,0))'] | ['Runtime Error', 'Accepted'] | ['s205048396', 's337497258'] | [2940.0, 2940.0] | [17.0, 17.0] | [71, 71] |
p03705 | u994988729 | 2,000 | 262,144 | Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? | ['def calc():\n n, a, b = map(int, input().split())\n if a > b:\n return 0\n if n == 1 and a < b:\n return 0\n\n lower = a + b * (n - 1)\n upper = b + a * (n - 1)\n return upper - lower+1\n\n\nprint(calc())\n', 'def main():\n N, A, B = map(int, input().split())\n if A > B:\n return 0\n if N == 1:\n if A != B:\n return 0\n else:\n return 1\n if N == 2:\n return 1\n\n mn = A * (N - 1) + B\n mx = A + B * (N - 1)\n return mx - mn + 1\n\n\nif __name__ == "__main__":\n print(main())'] | ['Wrong Answer', 'Accepted'] | ['s544638714', 's709924580'] | [2940.0, 3064.0] | [18.0, 17.0] | [225, 325] |
p03707 | u104282757 | 4,000 | 262,144 | Nuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If S_{i,j} is 1, the square at the i-th row and j-th column is blue; if S_{i,j} is 0, the square is white. For every pair of two blue square a and b, there is at most one path that starts from a, repeatedly proceeds to an adjacent (side by side) blue square and finally reaches b, without traversing the same square more than once. Phantom Thnook, Nuske's eternal rival, gives Q queries to Nuske. The i-th query consists of four integers x_{i,1}, y_{i,1}, x_{i,2} and y_{i,2} and asks him the following: when the rectangular region of the grid bounded by (and including) the x_{i,1}-th row, x_{i,2}-th row, y_{i,1}-th column and y_{i,2}-th column is cut out, how many connected components consisting of blue squares there are in the region? Process all the queries. | ["import numpy as np\n\nN, M, Q = map(int, input().split())\n\nS = np.zeros((N+1, M+1), dtype='int')\n\nfor n in range(1, N+1):\n S[n, 1:] = list(map(int, list(input())))\n\n# count nodes\nN_cum = np.cumsum(np.cumsum(S, axis=0), axis=1) \n\nER_cum = np.cumsum(np.cumsum(S[:N, :]*S[1:, :], axis=0), axis=1) \n\nEC_cum = np.cumsum(np.cumsum(S[:, :M]*S[:, 1:], axis=0), axis=1) \n\nsol_list = []\n\nfor _ in range(Q):\n x1, y1, x2, y2 = map(int, input().split())\n # nodes\n N_nodes = N_cum[x2, y2] - N_cum[x1-1, y2] - N_cum[x2, y1-1] + N_cum[x1-1, y1-1]\n # edges(row)\n N_edges1 = ER_cum[x2-1, y2] - ER_cum[x1-1, y2] - ER_cum[x2-1, y1-1] + ER_cum[x1-1, y1-1]\n # edges(col)\n N_edges2 = EC_cum[x2, y2-1] - EC_cum[x1-1, y2-1] - EC_cum[x2, y1-1] + EC_cum[x1-1, y1-1]\n \n N_nodes - N_edges1 - N_edges2\n\nfor q in range(Q):\n print(sol_list[q])", "import numpy as np\n\nN, M, Q = map(int, input().split())\n\nS = np.zeros((N+1, M+1), dtype='float32')\n\nfor n in range(1, N+1):\n S[n, 1:] = list(map(int, list(input())))\n\n# count nodes\nN_cum = np.cumsum(np.cumsum(S, axis=0), axis=1) \n\nER_cum = np.cumsum(np.cumsum(S[:N, :]*S[1:, :], axis=0), axis=1) \n\nEC_cum = np.cumsum(np.cumsum(S[:, :M]*S[:, 1:], axis=0), axis=1) \n\nsol_list = []\n\nfor _ in range(Q):\n x1, y1, x2, y2 = map(int, input().split())\n # nodes\n N_nodes = N_cum[x2, y2] - N_cum[x1-1, y2] - N_cum[x2, y1-1] + N_cum[x1-1, y1-1]\n # edges(row)\n N_edges1 = ER_cum[x2-1, y2] - ER_cum[x1-1, y2] - ER_cum[x2-1, y1-1] + ER_cum[x1-1, y1-1]\n # edges(col)\n N_edges2 = EC_cum[x2, y2-1] - EC_cum[x1-1, y2-1] - EC_cum[x2, y1-1] + EC_cum[x1-1, y1-1]\n \n sol_list.append(N_nodes - N_edges1 - N_edges2)\n\nfor q in range(Q):\n print(int(sol_list[q]))"] | ['Runtime Error', 'Accepted'] | ['s527802583', 's050666258'] | [178672.0, 100860.0] | [3316.0, 3539.0] | [878, 904] |
p03707 | u467736898 | 4,000 | 262,144 | Nuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If S_{i,j} is 1, the square at the i-th row and j-th column is blue; if S_{i,j} is 0, the square is white. For every pair of two blue square a and b, there is at most one path that starts from a, repeatedly proceeds to an adjacent (side by side) blue square and finally reaches b, without traversing the same square more than once. Phantom Thnook, Nuske's eternal rival, gives Q queries to Nuske. The i-th query consists of four integers x_{i,1}, y_{i,1}, x_{i,2} and y_{i,2} and asks him the following: when the rectangular region of the grid bounded by (and including) the x_{i,1}-th row, x_{i,2}-th row, y_{i,1}-th column and y_{i,2}-th column is cut out, how many connected components consisting of blue squares there are in the region? Process all the queries. | ['\ndef main():\n import sys\n import numpy as np\n input = sys.stdin.readline\n H, W, Q = map(int, input().split())\n S = [list(map(lambda x: x=="1", input())) for _ in range(H)]\n M = np.zeros((H + 1, W + 1), dtype=np.int32)\n L = np.zeros((H + 1, W + 1), dtype=np.int32)\n R = np.zeros((H + 1, W + 1), dtype=np.int32)\n U = np.zeros((H + 1, W + 1), dtype=np.int32)\n D = np.zeros((H + 1, W + 1), dtype=np.int32)\n\n for x, s in enumerate(S):\n for y, c in enumerate(s):\n m = l = r = u = d = 0\n if c:\n if x >= 1:\n m += S[x-1][y]\n u -= S[x-1][y]\n if x < H-1:\n m += S[x+1][y]\n d -= S[x+1][y]\n if y >= 1:\n m += s[y-1]\n l -= s[y-1]\n if y < W-1:\n m += s[y+1]\n r -= s[y+1]\n m = 2 - m\n M[x, y] = m\n L[x, y] = l\n R[x, y] = r\n U[x, y] = u\n D[x, y] = d\n\n M = M.cumsum(axis=0).cumsum(axis=1)\n L = L.cumsum(axis=0)\n R = R.cumsum(axis=0)\n U = U.cumsum(axis=1)\n D = D.cumsum(axis=1)\n M[:, -1] = 0\n M[-1, :] = 0\n L[-1, :] = 0\n R[-1, :] = 0\n U[:, -1] = 0\n D[:, -1] = 0\n\n exit()\n\n #Ans = []\n #for x1, y1, x2, y2 in XYXY:\n for _ in range(Q):\n x1, y1, x2, y2 = map(int, input().split())\n ans = 0\n ans += M[x2-1][y2-1] + M[x1-2][y1-2] - M[x2-1][y1-2] - M[x1-2][y2-1]\n #print(ans)\n ans -= L[x2-1][y1-1] - L[x1-2][y1-1]\n ans -= R[x2-1][y2-1] - R[x1-2][y2-1]\n ans -= U[x1-1][y2-1] - U[x1-1][y1-2]\n ans -= D[x2-1][y2-1] - D[x2-1][y1-2]\n assert ans % 2 == 0, ans\n #Ans.append(ans//2)\n print(str(ans//2))\n #print("\\n".join(map(str, Ans)))\n\nmain()\n', '\ndef main():\n import sys\n import numpy as np\n input = sys.stdin.readline\n H, W, Q = map(int, input().split())\n S = [list(map(lambda x: x=="1", input())) for _ in range(H)] + [[False]*(W+1)]\n S = np.array(S, dtype=np.int32)\n M = np.zeros((H + 1, W + 1), dtype=np.int32)\n L = np.zeros((H + 1, W + 1), dtype=np.int32)\n R = np.zeros((H + 1, W + 1), dtype=np.int32)\n U = np.zeros((H + 1, W + 1), dtype=np.int32)\n D = np.zeros((H + 1, W + 1), dtype=np.int32)\n\n ud = S[1:, :] * S[:-1, :]\n M[1:, :] += ud\n U[1:, :] -= ud\n M[:-1, :] += ud\n D[:-1, :] -= ud\n del ud\n lr = S[:, 1:] * S[:, :-1]\n M[:, 1:] += lr\n L[:, 1:] -= lr\n M[:, :-1] += lr\n R[:, :-1] -= lr\n del lr\n M = S * 2 - M\n\n M = M.cumsum(axis=0).cumsum(axis=1)\n L = L.cumsum(axis=0)\n R = R.cumsum(axis=0)\n U = U.cumsum(axis=1)\n D = D.cumsum(axis=1)\n M[:, -1] = 0\n M[-1, :] = 0\n L[-1, :] = 0\n R[-1, :] = 0\n U[:, -1] = 0\n D[:, -1] = 0\n\n exit()\n\n #Ans = []\n #for x1, y1, x2, y2 in XYXY:\n for _ in range(Q):\n x1, y1, x2, y2 = map(int, input().split())\n ans = 0\n ans += M[x2-1][y2-1] + M[x1-2][y1-2] - M[x2-1][y1-2] - M[x1-2][y2-1]\n #print(ans)\n ans -= L[x2-1][y1-1] - L[x1-2][y1-1]\n ans -= R[x2-1][y2-1] - R[x1-2][y2-1]\n ans -= U[x1-1][y2-1] - U[x1-1][y1-2]\n ans -= D[x2-1][y2-1] - D[x2-1][y1-2]\n assert ans % 2 == 0, ans\n #Ans.append(ans//2)\n print(str(ans//2))\n #print("\\n".join(map(str, Ans)))\n\nmain()\n', 'def input_test():\n import sys\n input = sys.stdin.readline\n H, W, Q = map(int, input().split())\n S = [list(map(lambda x: x == "1", input())) for _ in range(H)]\n for _ in range(Q):\n x1, y1, x2, y2 = map(int, input().split())\n \ninput_test()\n', '\ndef main():\n import sys\n import numpy as np\n input = sys.stdin.readline\n H, W, Q = map(int, input().split())\n S = [list(map(lambda x: x=="1", input())) for _ in range(H)] + [[False]*(W+1)]\n S = np.array(S, dtype=np.int8)\n M = np.zeros((H + 1, W + 1), dtype=np.int32)\n L = np.zeros((H + 1, W + 1), dtype=np.int16)\n R = np.zeros((H + 1, W + 1), dtype=np.int16)\n U = np.zeros((H + 1, W + 1), dtype=np.int16)\n D = np.zeros((H + 1, W + 1), dtype=np.int16)\n\n ud = S[1:, :] * S[:-1, :]\n M[1:, :] += ud\n U[1:, :] -= ud\n M[:-1, :] += ud\n D[:-1, :] -= ud\n del ud\n lr = S[:, 1:] * S[:, :-1]\n M[:, 1:] += lr\n L[:, 1:] -= lr\n M[:, :-1] += lr\n R[:, :-1] -= lr\n del lr\n M = S * 2 - M\n\n M = M.cumsum(axis=0).cumsum(axis=1)\n L = L.cumsum(axis=0)\n R = R.cumsum(axis=0)\n U = U.cumsum(axis=1)\n D = D.cumsum(axis=1)\n M[:, -1] = 0\n M[-1, :] = 0\n L[-1, :] = 0\n R[-1, :] = 0\n U[:, -1] = 0\n D[:, -1] = 0\n\n exit()\n\n #Ans = []\n #for x1, y1, x2, y2 in XYXY:\n for _ in range(Q):\n x1, y1, x2, y2 = map(int, input().split())\n ans = 0\n ans += M[x2-1][y2-1] + M[x1-2][y1-2] - M[x2-1][y1-2] - M[x1-2][y2-1]\n #print(ans)\n ans -= L[x2-1][y1-1] - L[x1-2][y1-1]\n ans -= R[x2-1][y2-1] - R[x1-2][y2-1]\n ans -= U[x1-1][y2-1] - U[x1-1][y1-2]\n ans -= D[x2-1][y2-1] - D[x2-1][y1-2]\n assert ans % 2 == 0, ans\n #Ans.append(ans//2)\n print(str(ans//2))\n #print("\\n".join(map(str, Ans)))\n\nmain()\n', '\ndef main():\n import sys\n import numpy as np\n input = sys.stdin.readline\n H, W, Q = map(int, input().split())\n S = [list(map(lambda x: x=="1", input())) for _ in range(H)] + [[False]*(W+1)]\n S = np.array(S, dtype=np.int32)\n M = np.zeros((H + 1, W + 1), dtype=np.int32)\n L = np.zeros((H + 1, W + 1), dtype=np.int32)\n R = np.zeros((H + 1, W + 1), dtype=np.int32)\n U = np.zeros((H + 1, W + 1), dtype=np.int32)\n D = np.zeros((H + 1, W + 1), dtype=np.int32)\n\n ud = S[1:, :] * S[:-1, :]\n M[1:, :] += ud\n U[1:, :] -= ud\n M[:-1, :] += ud\n D[:-1, :] -= ud\n lr = S[:, 1:] * S[:, :-1]\n M[:, 1:] += lr\n L[:, 1:] -= lr\n M[:, :-1] += lr\n R[:, :-1] -= lr\n M = S * 2 - M\n\n M = M.cumsum(axis=0).cumsum(axis=1)\n L = L.cumsum(axis=0)\n R = R.cumsum(axis=0)\n U = U.cumsum(axis=1)\n D = D.cumsum(axis=1)\n M[:, -1] = 0\n M[-1, :] = 0\n L[-1, :] = 0\n R[-1, :] = 0\n U[:, -1] = 0\n D[:, -1] = 0\n\n exit()\n\n #Ans = []\n #for x1, y1, x2, y2 in XYXY:\n for _ in range(Q):\n x1, y1, x2, y2 = map(int, input().split())\n ans = 0\n ans += M[x2-1][y2-1] + M[x1-2][y1-2] - M[x2-1][y1-2] - M[x1-2][y2-1]\n #print(ans)\n ans -= L[x2-1][y1-1] - L[x1-2][y1-1]\n ans -= R[x2-1][y2-1] - R[x1-2][y2-1]\n ans -= U[x1-1][y2-1] - U[x1-1][y1-2]\n ans -= D[x2-1][y2-1] - D[x2-1][y1-2]\n assert ans % 2 == 0, ans\n #Ans.append(ans//2)\n print(str(ans//2))\n #print("\\n".join(map(str, Ans)))\n\nmain()\n', 'def main():\n import sys\n import numpy as np\n input = sys.stdin.readline\n H, W, Q = map(int, input().split())\n S = [list(map(lambda x: x=="1", input())) for _ in range(H)] + [[False]*(W+1)]\n S = np.array(S, dtype=np.int16)\n M = np.zeros((H + 1, W + 1), dtype=np.int32)\n\n UD = S[1:, :] * S[:-1, :]\n M[1:, :] += UD\n M[:-1, :] += UD\n\n LR = S[:, 1:] * S[:, :-1]\n M[:, 1:] += LR\n M[:, :-1] += LR\n\n M = S * 2 - M\n M = M.cumsum(axis=0).cumsum(axis=1)\n UD = UD.cumsum(axis=1, dtype=np.int16)\n LR = LR.cumsum(axis=0, dtype=np.int16)\n M[:, -1] = 0\n M[-1, :] = 0\n\n del S\n\n UD = np.pad(UD, ((0, 1), (0, 1)), mode="constant")\n LR = np.pad(LR, ((0, 1), (0, 1)), mode="constant")\n x1, y1, x2, y2 = np.array(list(map(int, sys.stdin.read().split())), dtype=np.int16).reshape(-1, 4).T\n Ans = M[x2-1, y2-1] + M[x1-2, y1-2] - M[x2-1, y1-2] - M[x1-2, y2-1]\n Ans += LR[x2-1, y1-2] - LR[x1-2, y1-2]\n Ans += LR[x2-1, y2-1] - LR[x1-2, y2-1]\n Ans += UD[x1-2, y2-1] - UD[x1-2, y1-2]\n Ans += UD[x2-1, y2-1] - UD[x2-1, y1-2]\n Ans //= 2\n print("\\n".join(str(int(a)) for a in Ans))\n\nmain()\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s126619687', 's164872273', 's433080132', 's542276672', 's956800126', 's010711676'] | [250276.0, 253308.0, 37620.0, 240524.0, 284536.0, 172704.0] | [4212.0, 1197.0, 754.0, 1290.0, 1224.0, 1672.0] | [1919, 1569, 267, 1568, 1547, 1148] |
p03708 | u211742028 | 2,000 | 262,144 | Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive). How many possible candidates of the value of Nukes's integer there are? | ['\nimport math\nA = int(input())\nB = int(input())\nif B < A: A,B = B,A\n\nif A == B:\n print(1)\nelse:\n t = int(math.floor(math.log2(B)))\n while (A & 2**t) == (B & 2**t):\n if A & 2**t:\n A -= 2**t\n B -= 2**t\n t-=1\n ans = 2**t - A # [A,2^t-1]\n r = t-1\n while 2**t + 2**r > B and r>=0:\n r-=1\n print(r)\n # [2^t,2^t+2^{r+1}-1] \\cup [2^t+A,2^{t+1}-1]\n C = 2**(r+1)\n if C < A:\n ans += C + 2**t - A\n else:\n ans += 2**t\n print(ans)\n', '\nimport math\nA = int(input())\nB = int(input())\nif B < A: A,B = B,A\n\nif A == B:\n print(1)\nelse:\n t = int(math.floor(math.log2(B)))\n while (A & 2**t) == (B & 2**t):\n if A & 2**t:\n A -= 2**t\n B -= 2**t\n t-=1\n ans = 2**t - A # [A,2^t-1]\n r = t-1\n while 2**t + 2**r > B and r>=0:\n r-=1\n # [2^t,2^t+2^{r+1}-1] \\cup [2^t+A,2^{t+1}-1]\n C = 2**(r+1)\n if C < A:\n ans += C + 2**t - A\n else:\n ans += 2**t\n print(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s910106365', 's615271855'] | [3064.0, 3064.0] | [17.0, 18.0] | [521, 508] |
p03708 | u905582793 | 2,000 | 262,144 | Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive). How many possible candidates of the value of Nukes's integer there are? | ['a=int(input())\nb=int(input())\nif a==b:\n print(1)\n exit()\nabin=bin(a)[2:]\nbbin=bin(b)[2:]\nla=len(abin)\nlb=len(bbin)\nif la==lb:\n while abin[0]==bbin[0]:\n abin=abin[1:]\n bbin=bbin[1:]\n while abin[0]=="0":\n abin=abin[1:]\ncbin=bbin[1:]\nwhile cbin[0]=="0":\n cbin=cbin[1:]\nc=2**(len(cbin))\na=int(abin,2)\nlbnd=2**(lb-1)+c\nhbnd=2**(lb-1)+a\nif lbnd>=hbnd:\n print(lbnd-a+1)\nelse:\n print(2**(lb-1)-a+lbnd-a+1)', 'a=int(input())\nb=int(input())\nif a==b:\n print(1)\n exit()\nabin=bin(a)[2:]\nbbin=bin(b)[2:]\nla=len(abin)\nlb=len(bbin)\nif la==lb:\n while abin[0]==bbin[0]:\n del abin[0]\n del bbin[0]\n while abin[0]=="0":\n del abin[0]\ncbin=bbin[1:]\nwhile cbin[0]=="0":\n del cbin[0]\nc=2**(len(cbin))\na=int(abin,2)\nlbnd=2**(lb-1)+c\nhbnd=2**(lb-1)+a\nif lbnd>=hbnd:\n print(lbnd-a+1)\nelse:\n print(2**(lb-1)-a+lbnd-a+1)', 'a=int(input())\nb=int(input())\nif a==b:\n print(1)\n exit()\nabin=bin(a)[2:]\nbbin=bin(b)[2:]\nla=len(abin)\nlb=len(bbin)\nif la==lb:\n while abin[0]==bbin[0]:\n abin=abin[1:]\n bbin=bbin[1:]\n while len(abin)>1 and abin[0]=="0":\n abin=abin[1:]\ncbin=bbin[1:]\nwhile cbin and cbin[0]=="0":\n cbin=cbin[1:]\nc=2**(len(cbin))-1\na=int(abin,2)\nb=int(bbin,2)\nlb=len(bbin)\nlbnd=2**(lb-1)+c\nhbnd=2**(lb-1)+a\nif lbnd>=hbnd:\n print(2**lb-a)\nelse:\n print(2**(lb-1)-a+lbnd-a+1)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s022782609', 's296589495', 's630246229'] | [3064.0, 3064.0, 3064.0] | [17.0, 18.0, 17.0] | [413, 405, 467] |
p03715 | u063052907 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['H, W = map(int, input().split())\nans = float("inf")\n\n\nfor i in range(2):\n if i == 0:\n ver, hori = H, W\n else:\n ver, hori = W, H\n for ha in range(1, ver // 2):\n sa = ha * hori\n h = ver - ha\n \n \n if h % 2 == 0:\n hb, hc = h // 2, h // 2\n else:\n hb, hc = h // 2, h // 2 + 1\n sb1, sc1 = hb * hori, hc * hori\n diff1 = max(sa, sb1, sc1) - min(sa, sb1, sc1)\n \n \n if hori % 2 == 0:\n wb, wc = hori // 2, hori // 2\n else:\n wb, wc = hori // 2, hori // 2 + 1\n sb2, sc2 = h * wb, h * wc\n diff2 = max(sa, sb2, sc2) - min(sa, sb2, sc2)\n \n tmp_min = min(diff1, diff2)\n ans = min(ans, tmp_min)\n\n\nprint(ans)\n', 'H, W = map(int, input().split())\nans = float("inf")\n\n\nfor i in range(2):\n if i == 0:\n ver, hori = H, W\n else:\n ver, hori = W, H\n for ha in range(1, ver):\n sa = ha * hori\n h = ver - ha\n \n \n if h % 2 == 0:\n hb, hc = h // 2, h // 2\n else:\n hb, hc = h // 2, h // 2 + 1\n sb1, sc1 = hb * hori, hc * hori\n diff1 = max(sa, sb1, sc1) - min(sa, sb1, sc1)\n \n \n if hori % 2 == 0:\n wb, wc = hori // 2, hori // 2\n else:\n wb, wc = hori // 2, hori // 2 + 1\n sb2, sc2 = h * wb, h * wc\n diff2 = max(sa, sb2, sc2) - min(sa, sb2, sc2)\n \n tmp_min = min(diff1, diff2)\n ans = min(ans, tmp_min)\n\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s754052443', 's258318753'] | [3064.0, 3064.0] | [281.0, 546.0] | [849, 844] |
p03715 | u065446124 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['h,w=map(int,input().split())\ndef main(h,w):\n a=h\n for i in range(1,h//2+1):\n l=[i*w,(h-i)*(w//2),(h-i)*(w-w//2)]\n a=min(max(l)-min(l),a)\n return a\nprint(min(main(h,w),main(w,h)))', 'h,w=map(int,input().split())\ndef main(h,w):\n a=h\n for i in range(1,h//2+1):\n l=[i*w,(h-i)*w//2,(h-i)*(w-w//2)]\n a=min(max(l)-min(l),a)\n return a\nprint(min(main(h,w),main(w,h)))', 'h,w=map(int,input().split())\ndef main(h,w):\n a=h*w\n for i in range(1,h//2+1):\n l=[i*w,(h-i)*w//2,(h-i)*(w-w//2)]\n a=min(max(l)-min(l),a)\n return a\nprint(min(main(h,w),main(w,h)))', 'h,w=map(int,input().split())\nif(h%3==0 or w%3==0):\n print(0)\n quit()\ndef main(h,w):\n a=h\n for i in range(1,h//2+1):\n l=[i*w,(h-i)*(w//2),(h-i)*(w-w//2)]\n a=min(max(l)-min(l),a)\n return a\nprint(min(main(h,w),main(w,h)))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s088768657', 's227064833', 's457411628', 's059578314'] | [3064.0, 3064.0, 3060.0, 3064.0] | [112.0, 115.0, 118.0, 118.0] | [201, 199, 201, 247] |
p03715 | u143492911 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['h,w=map(int,input().split())\ntmp=10**5*2\ntmp_2=10**5*2\ntmp_3=10**5*2\ntmp_4=10**5*2\nfor i in range(1,h):\n half_h=h-i\n area_1=i*w\n area_2=half_h//2*w\n area_3=half_h-(half_h//2)*w\n ans=max(area_1,area_2,area_3)-min(area_1,area_2,area_3)\n if ans<tmp:\n tmp=ans\nfor j in range(1,w):\n half_w=w-j\n area_1=h*j\n area_2=half_w//2*h\n area_3=half_w-(half_w//2)*h\n ans_2=max(area_1,area_2,area_3)-min(area_1,area_2,area_3)\n if ans_2<tmp_2:\n tmp_2=ans_2\nfor i in range(1,h):\n half_w=w//2\n area_1=i*half_w\n area_2=i*(w-half_w)\n area_3=(h-i)*w\n ans_3=max(area_1,area_2,area_3)-min(area_1,area_2,area_3)\n if ans_3<tmp_3:\n tmp_3=ans_3\nfor j in range(1,w):\n half_h=h//2\n area_1=h*j\n area_2=(w-j)*half_h\n area_3=(w-j)*(h-half_h)\n ans_4=max(area_1,area_2,area_3)-min(area_1,area_2,area_3)\n if ans_4<tmp_4:\n tmp_4=ans_4\nprint(min(tmp,tmp_2,tmp_3,tmp_4))\n', 'h,w=map(int,input().split())\ntmp=h*w\ntmp_2=h*w\ntmp_3=h*w\ntmp_4=h*w\nfor i in range(1,h):\n half_h=h-i\n area_1=i*w\n area_2=half_h//2*w\n area_3=(half_h-(half_h//2))*w\n ans=max(area_1,area_2,area_3)-min(area_1,area_2,area_3)\n if ans<tmp:\n tmp=ans\nfor j in range(1,w):\n half_w=w-j\n area_1=h*j\n area_2=(half_w//2)*h\n area_3=(half_w-half_w//2)*h\n ans_2=max(area_1,area_2,area_3)-min(area_1,area_2,area_3)\n if ans_2<tmp_2:\n tmp_2=ans_2\nfor i in range(1,h):\n half_w=w//2\n area_1=i*half_w\n area_2=i*(w-half_w)\n area_3=(h-i)*w\n ans_3=max(area_1,area_2,area_3)-min(area_1,area_2,area_3)\n if ans_3<tmp_3:\n tmp_3=ans_3\nfor j in range(1,w):\n half_h=h//2\n area_1=h*j\n area_2=(w-j)*half_h\n area_3=(w-j)*(h-half_h)\n ans_4=max(area_1,area_2,area_3)-min(area_1,area_2,area_3)\n if ans_4<tmp_4:\n tmp_4=ans_4\nprint(min(tmp,tmp_2,tmp_3,tmp_4))\n'] | ['Wrong Answer', 'Accepted'] | ['s744285439', 's743118890'] | [3064.0, 3064.0] | [438.0, 468.0] | [931, 935] |
p03715 | u187205913 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['h,w = map(int,input().split())\ns1 = (h//3+h%3)*w - (h//3)*3\ns2 = (w//3+w%3)*h - (w//3)*3\ns3 = max((h//2)*w,(h//2+h%2)*(w//2+w%2))-min((h//2)*w,(h//2+h%2)*(w//2))\ns4 = max((w//2)*h,(w//2+w%2)*(h//2+h%2))-min((w//2)*h,(w//2+w%2)*(h//2))\nprint(min(s1,s2,s3,s4))', 'h,w = map(int,input().split())\nans = 10**9\nans = min(ans,(h//3+min(1,h%3))*w-(h//3)*w)\nans = min(ans,(w//3+min(1,w%3))*h-(w//3)*h)\nfor i in range(1,h//2+1):\n s1 = i*w\n s2 = (h-i)*(w//2)\n s3 = (h-i)*(w//2+w%2)\n ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))\nfor i in range(1,w//2+1):\n s1 = i*h\n s2 = (w-i)*(h//2)\n s3 = (w-i)*(h//2+h%2)\n ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s371693836', 's291877417'] | [3064.0, 3064.0] | [17.0, 139.0] | [258, 409] |
p03715 | u243492642 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['# coding: utf-8\nimport array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time\n\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\n\n\ndef II(): return int(input())\ndef ILI(): return list(map(int, input().split()))\ndef IAI(LINE): return [ILI() for __ in range(LINE)]\ndef IDI(): return {key: value for key, value in ILI()}\n\n\ndef read():\n N = II()\n a = ILI()\n return (N, a)\n\n\ndef solve(N, a):\n a_lef = a[0: N]\n a_rig = [-i for i in a[2 * N: 3 * N]]\n heapq.heapify(a_lef)\n heapq.heapify(a_rig)\n sum_lef = sum(a_lef)\n sum_rig = sum(a_rig)\n l_sum_lef = [sum_lef]\n l_sum_rig = [sum_rig]\n \n for i in range(1, N + 1):\n heapq.heappush(a_lef, a[N - 1 + i])\n lef_pop = heapq.heappop(a_lef)\n sum_lef += a[N - 1 + i] - lef_pop\n l_sum_lef.append(sum_lef)\n \n heapq.heappush(a_rig, -a[2 * N - i])\n rig_pop = heapq.heappop(a_rig)\n sum_rig += -a[2 * N - i] - rig_pop\n l_sum_rig.append(sum_rig)\n\n ans = -INF\n\n for i in range(N + 1):\n num_dif = l_sum_lef[i] + l_sum_rig[N - i]\n ans = max(ans, num_dif)\n\n return ans\n\n\ndef main():\n params = read()\n print(solve(*params))\n\n\nif __name__ == "__main__":\n main()\n', '# coding: utf-8\nimport array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\n\n\ndef II(): return int(input())\ndef ILI(): return list(map(int, input().split()))\ndef IAI(LINE): return [ILI() for __ in range(LINE)]\ndef IDI(): return {key: value for key, value in ILI()}\n\n\ndef read():\n H, W = ILI()\n return (H, W)\n\ndef solve(H, W):\n ans = INF\n \n if H % 3 == 0 or W % 3 == 0:\n return 0\n else:\n ans = min(ans, H, W)\n\n if W % 2 == 0:\n for h in range(1, H):\n num_1 = h * W\n num_2 = (H - h) * W // 2\n ans = min(ans, abs(num_1 - num_2))\n else:\n for h in range(1, H):\n num_1 = h * W\n num_2 = (H - h) * (W // 2)\n num_3 = (H - h) * (W // 2 + 1)\n nums = sorted([num_1, num_2, num_3])\n ans = min(ans, (nums[2] - nums[0]))\n\n if H % 2 == 0:\n for w in range(1, W):\n num_1 = w * H\n num_2 = (W - w) * H // 2\n ans = min(ans, abs(num_1 - num_2))\n else:\n for w in range(1, W):\n num_1 = w * H\n num_2 = (W - w) * (H // 2)\n num_3 = (W - w) * (H // 2 + 1)\n nums = sorted([num_1, num_2, num_3])\n ans = min(ans, (nums[2] - nums[0]))\n \n return ans\n\n\ndef main():\n params = read()\n print(solve(*params))\n\n\nif __name__ == "__main__":\n main()\n'] | ['Runtime Error', 'Accepted'] | ['s766594323', 's361989570'] | [5236.0, 6360.0] | [59.0, 152.0] | [1263, 1469] |
p03715 | u346308892 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['import math\na,b=list(map(int,input().split(" ")))\n\ndef solve(a,b,fc):\n\n S=a*b\n\n if fc=="floor":\n x=math.ceil((S//3)/a)\n else:\n x=math.floor((S//3)/a)\n S_l=(b-x)*math.floor(a/2)\n S_U=a*x\n S_r=(b-x)*math.ceil(a/2)\n\n SMax=max(S_l,S_U,S_r)\n SMin=min(S_l,S_U,S_r)\n return SMax-SMin\n\n\n\ns1=solve(a,b,"floor")\ns2=solve(a,b,"ceil")\ns3=solve(b,a,"floor")\ns4=solve(b,a,"ceil")', 'import math\na,b=list(map(int,input().split(" ")))\n\ndef solve(a,b,fc):\n\n S=a*b\n\n if fc=="ceil":\n x=math.ceil((S/3)/a)\n else:\n x=math.floor((S/3)/a)\n l=math.floor(a/2)\n S_l=(b-x)*l\n S_U=a*x\n S_r=(b-x)*(a-l)\n\n SMax=max(S_l,S_U,S_r)\n SMin=min(S_l,S_U,S_r)\n return abs(SMax-SMin)\n\n\n\ns1=solve(a,b,"floor")\ns2=solve(a,b,"ceil")\ns3=solve(b,a,"floor")\ns4=solve(b,a,"ceil")\nprint(min(s1,s2,s3,s4))\n', '\nimport math\na,b=list(map(int,input().split(" ")))\n\ndef solve(a,b,fc):\n\n S=a*b\n\n if fc=="floor":\n x=math.ceil((S//3)/a)\n else:\n x=math.floor((S//3)/a)\n S_l=(b-x)*math.floor(a/2)\n S_U=a*x\n S_r=(b-x)*math.ceil(a/2)\n\n SMax=max(S_l,S_U,S_r)\n SMin=min(S_l,S_U,S_r)\n return SMax-SMin\n\n\n\nsa=solve(a,b,"floor")\nsb=solve(b,a,"ceil")\nprint(min(sa,sb))\n', 'import math\na,b=list(map(int,input().split(" ")))\n\ndef solve(a,b,fc):\n\n S=a*b\n\n if fc=="ceil":\n x=math.ceil((S/3)/a)\n else:\n x=math.floor((S/3)/a)\n l=math.floor(a/2)\n S_l=(b-x)*l\n S_U=a*x\n S_r=(b-x)*(a-l)\n\n SMax=max(S_l,S_U,S_r)\n SMin=min(S_l,S_U,S_r)\n return abs(SMax-SMin)\n\ndef solve3(a,b,dupplicate=True):\n la=math.ceil(a/3)\n lc=math.floor(a/3)\n if dupplicate:\n lb=la\n else:\n lb=lc\n\n Sa=la*b\n Sb=lc*b\n return abs(Sa-Sb)\n\n\n\n\ns1=solve(a,b,"floor")\ns2=solve(a,b,"ceil")\ns3=solve(b,a,"floor")\ns4=solve(b,a,"ceil")\ns5=solve3(a,b)\ns6=solve3(a,b,False)\ns7=solve3(b,a)\ns8=solve3(b,a,False)\n\nprint(min(s1,s2,s3,s4,s5,s6,s7,s8))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s015732482', 's176482597', 's222208594', 's548894909'] | [3064.0, 3064.0, 3064.0, 3064.0] | [17.0, 18.0, 18.0, 17.0] | [406, 432, 383, 700] |
p03715 | u405256066 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['from sys import stdin\nH, W = [int(x) for x in stdin.readline().rstrip().split()]\nsa = 0\nsb = 0\nsc = 0\nans = 10**9\n\nfor h in range(1, H):\n sa = h*W\n sb = (H-h)*(W//2)\n sc = (H-h)*(W-(W//2))\n tmp = max(sa, sb, sc)-min(sa, sb, sc)\n ans = min(ans, tmp)\n\nfor w in range(1, W):\n sa = H*W\n sb = (W-w)*(H//2)\n sc = (W-w)*(H-(H//2))\n tmp = max(sa, sb, sc)-min(sa, sb, sc)\n ans = min(ans, tmp)\n\nprint(ans)', 'from sys import stdin\nH, W = [int(x) for x in stdin.readline().rstrip().split()]\nsa = 0\nsb = 0\nsc = 0\nans = 10**9\n\nfor h in range(1, H):\n sa = h*W\n sb = (H-h)*(W//2)\n sc = (H-h)*(W-(W//2))\n tmp = max(sa, sb, sc)-min(sa, sb, sc)\n ans = min(ans, tmp)\n\nfor w in range(1, W):\n sa = H*w\n sb = (W-w)*(H//2)\n sc = (W-w)*(H-(H//2))\n tmp = max(sa, sb, sc)-min(sa, sb, sc)\n ans = min(ans, tmp)\n\nfor h in range(1, H):\n sa = h*W\n sb = ((H-h)//2)*W\n sc = ((H-h)-((H-h)//2))*W\n tmp = max(sa, sb, sc)-min(sa, sb, sc)\n ans = min(ans, tmp)\n\nfor w in range(1, W):\n sa = H*w\n sb = ((W-w)//2)*H\n sc = ((W-w)-((W-w)//2))*H\n tmp = max(sa, sb, sc)-min(sa, sb, sc)\n ans = min(ans, tmp)\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s269804783', 's291363703'] | [3064.0, 3064.0] | [261.0, 534.0] | [425, 733] |
p03715 | u405779580 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['h, w = map(int, input().split())\nif h%3 == 0 or w%3 ==0:\n print(0)\nelse:\n def calculate_d(x, y):\n d = h*w + 1\n i = x//2\n s1, s2 = 0, d\n for i in range(x):\n s1 = (y//2)*i\n s2 = y*(x-i)\n s3 = (y-y//2)*i\n new_d = max(abs(s1-s2), abs(s1-s3))\n if s1 < s2:\n i = \n if d > new_d:\n d = new_d\n continue\n else:\n break\n return d\n d1 = calculate_d(h, w)\n d2 = calculate_d(w, h)\n print(min(d1,d2))', 'h, w = map(int, input().split())\ndef calculate_t(x, y):\n min_d = 1e12\n for i in range(x):\n s1 = (y//2)*i\n s2 = y*(x-i)\n s3 = (y-y//2)*i\n min_d = min(min_d, max(s1,s2,s3) - min(s1,s2,s3))\n return min_d\ndef calculate_3(x, y):\n min_d = 1e12\n for i in range(x):\n w1 = i\n w2 = (x-i)//2\n w3 = x - w1 -w2\n min_d = min(min_d, (max(w1,w2,w3)-min(w1,w2,w3))*y)\n return min_d\nif (h*w)%3 == 0:\n print(0)\nelse:\n d1 = calculate_t(h,w)\n d2 = calculate_t(w,h)\n d3 = calculate_3(h,w)\n d4 = calculate_3(w,h)\n print(min(d1,d2,d3,d4))'] | ['Runtime Error', 'Accepted'] | ['s057159441', 's470133673'] | [3060.0, 3064.0] | [17.0, 362.0] | [570, 606] |
p03715 | u441575327 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ["H,W = list(map(int,input().split()))\n\nans = float('inf')\na,b,c = H//3*W,(H-H//3)*(W//2),(H-H//3)*(W-W//2)\nans = min(ans,max(a,b,c)-min(a,b,c))\na,b,c = (H+2)//3*W,(H-(H+2)//3)*(W//2),(H-(H+2)//3)*(W-W//2)\nans = min(ans,max(a,b,c)-min(a,b,c))\na,b,c = W//3*H,(W-W//3)*(H//2),(W-W//3)*(H-H//2)\nans = min(ans,max(a,b,c)-min(a,b,c))\na,b,c = (W+2)//3*H,(W-(W+2)//3)*(H//2),(W-(W+2)//3)*(H-H//2)\nans = min(ans,max(a,b,c)-min(a,b,c))\na,b,c = H//3*W,H//3*W,(H//3+1)*W\nans = min(ans,max(a,b,c)-min(a,b,c))\na,b,c = W//3*H,W//3*H,(W//3+1)*H\nans = min(ans,max(a,b,c)-min(a,b,c))\n\nprint(ans)", "H,W = list(map(int,input().split()))\n\nans = float('inf')\na,b,c = H//3*W,(H-H//3)*(W//2),(H-H//3)*(W-W//2)\nans = min(ans,max(a,b,c)-min(a,b,c))\na,b,c = (H+2)//3*W,(H-(H+2)//3)*(W//2),(H-(H+2)//3)*(W-W//2)\nans = min(ans,max(a,b,c)-min(a,b,c))\na,b,c = W//3*H,(W-W//3)*(H//2),(W-W//3)*(H-H//2)\nans = min(ans,max(a,b,c)-min(a,b,c))\na,b,c = (W+2)//3*H,(W-(W+2)//3)*(H//2),(W-(W+2)//3)*(H-H//2)\nans = min(ans,max(a,b,c)-min(a,b,c))\na,b,c = H//3*W,H//3*W,((H+2)//3)*W\nans = min(ans,max(a,b,c)-min(a,b,c))\na,b,c = W//3*H,W//3*H,((W+2)//3)*H\nans = min(ans,max(a,b,c)-min(a,b,c))\n\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s196464558', 's588918470'] | [3064.0, 3064.0] | [18.0, 17.0] | [576, 580] |
p03715 | u503228842 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['H,W = map(int,input().split())\ndef f(H,W):\n # if H%3 == 0:\n # return 0\n w = W//2\n res = H*W\n for h in range(1,H):\n sb = (H-h)*w\n sc = (H-h)*(W-w)\n sa = h*W\n res = min(res, max(sa,sb,sc) - min(sa,sb,sc))\n return res\nans = min(f(H,W), f(W,H))\nprint(ans)\n', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nH,W = map(int,read().split())\n\ndef F(H,W):\n opt = H * W + 100\n for a in range(1,W):\n x = H * a\n y = (W-a) * (H//2)\n z = (W-a) * (H-H//2)\n d = max(x,y,z) - min(x,y,z)\n if opt > d:\n opt = d\n if W >= 3:\n a = W//3\n b = (W-a)//2\n c = W-a-b\n d = (max(a,b,c) - min(a,b,c)) * H\n if opt > d:\n opt = d\n return opt\n\nanswer = min(F(H,W),F(W,H))\nprint(answer)\n'] | ['Wrong Answer', 'Accepted'] | ['s863425510', 's493199230'] | [3060.0, 3064.0] | [186.0, 178.0] | [302, 568] |
p03715 | u557494880 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['N = int(input())\nA = list(map(int,input().split()))\nS = []\nP = A[:N]\nQ = A[2*N:]\nfor i in range(N):\n Q[i] *= -1\nR = A[N:2*N]\np = [0]*(N+1)\nq = [0]*(N+1)\nimport heapq\nheapq.heapify(P)\nheapq.heapify(Q)\nsp = sum(P)\nsq = sum(Q)\np[0] = sp\nq[0] = sq\n\nfor i in range(1,N+1):\n heapq.heappush(P,R[i-1])\n heapq.heappop(P)\n sp = sum(P)\n p[i] = sum(Q)\nfor i in range(1,N+1):\n heapq.heappush(Q,-R[-i])\n heapq.heappop(Q)\n sq = sum(Q)\n q[i] = sq\n\nans = -(10**100)\nfor k in range(N+1):\n ans = max(ans,p[k] + q[N-k])\n \nprint(ans)\n', 'N = int(input())\nA = list(map(int,input().split()))\nS = []\nP = A[:N]\nQ = A[2*N:]\nfor i in range(N):\n Q[i] *= -1\nR = A[N:2*N]\np = [0]*(N+1)\nq = [0]*(N+1)\nimport heapq\nheapq.heapify(P)\nheapq.heapify(Q)\nsp = sum(P)\nsq = sum(Q)\np[0] = sp\nq[0] = sq\n\nfor i in range(1,N+1):\n heapq.heappush(P,R[i-1])\n x = heapq.heappop(P)\n heapq.heappush(Q,-R[-i])\n y = heapq.heappop(Q)\n sp = sp + R[i-1] - x\n sq = sq - R[-i] - y\n p[i] = sp\n q[i] = sq\nans = -(10**100)\nfor k in range(N+1):\n ans = max(ans,p[k] + q[N-k])\n \nprint(ans)\n', 'W,H = map(int,input().split())\nans = 10**30\nfor i in range(1,W):\n a = H*i\n w = W - i\n b = max((w//2)*H,w*(H//2))\n c = w*H - b\n x = max(a,b,c) - min(a,b,c)\n ans = min(ans,x)\nfor i in range(1,H):\n a = W*i\n h = H - i\n b = max((W//2)*h,W*(h//2))\n c = h*W - b\n x = max(a,b,c) - min(a,b,c)\n ans = min(ans,x)\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s281054744', 's745263130', 's579903878'] | [3064.0, 3064.0, 3064.0] | [17.0, 17.0, 326.0] | [546, 543, 348] |
p03715 | u600402037 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['import sys\nimport numpy as np\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nH, W = lr()\nif H%3==0 or W%3==0:\n answer = 0\nelse:\n answer = min(H, W)\n\ndef cal(H, W):\n h = H // 3\n area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]\n answer = min(answer, max(area)-min(area))\n h += 1\n area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]\n answer = min(answer, max(area)-min(area))\n\ncal(H, W)\ncal(W, H)\nprint(answer)\n# 13', 'import sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nH, W = lr()\nif H%3==0 or W%3==0:\n answer = 0\nelse:\n answer = min(H, W)\n\ndef cal(H, W):\n global answer\n h = H // 3\n area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]\n answer = min(answer, max(area)-min(area))\n h += 1\n area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]\n answer = min(answer, max(area)-min(area))\n\ncal(H, W)\ncal(W, H)\nprint(answer)\n# 13'] | ['Runtime Error', 'Accepted'] | ['s563701345', 's920365830'] | [15508.0, 3064.0] | [196.0, 18.0] | [550, 549] |
p03715 | u648881683 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ["import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef diff_min(L):\n len_L = len(L)\n ret = min([abs(L[i] - L[(i+1)%len_L]) for i in range(len_L)])\n return ret\n\ndef resolve():\n H, W = LI()\n\n ans = 0\n if H % 3 != 0 and W % 3 != 0:\n \n ans = min(H, W)\n\n \n s = [0] * 3\n \n for _ in range(2):\n s[0] = H * W // 3\n s[1] = (H * W - s[0]) // 2\n s[2] = (H * W - s[0]) - s[1]\n ans = min(diff_min(s), ans)\n s[0] = H * (W // 3 + 1)\n s[1] = (H * W - s[0]) // 2\n s[2] = (H * W - s[0]) - s[1]\n ans = min(diff_min(s), ans)\n H, W = W, H\n \n print(ans)\n\n print(ans)\n\nif __name__ == '__main__':\n resolve()\n", "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n H, W = LI()\n\n ans = INF\n if H % 3 == 0 or W % 3 == 0:\n ans = 0\n else:\n \n ans = min(H, W)\n\n \n s = [0] * 3\n \n for _ in range(2):\n s[0] = H * (W // 3)\n s[1] = (W - W // 3) * (H // 2)\n s[2] = (W - W // 3) * (H - H // 2)\n ans = min(max(s)- min(s), ans)\n s[0] = H * (W // 3 + 1)\n s[1] = (W - (W // 3 + 1)) * (H // 2)\n s[2] = (W - (W // 3 + 1)) * (H - H // 2)\n ans = min(max(s)- min(s), ans)\n H, W = W, H\n \n print(ans)\n\nif __name__ == '__main__':\n resolve()\n"] | ['Wrong Answer', 'Accepted'] | ['s269367069', 's198571753'] | [10124.0, 10112.0] | [39.0, 40.0] | [1254, 1187] |
p03715 | u692632484 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['temp=input().split()\nH=int(temp[0])\nW=int(temp[1])\n\nINF=100000000\n\nans=INF\n\nif H%3==0 or W%3==0:\n\tprint(0)\nif H%2==0:\n\tfor i in range(W):\n\t\tS1=H*i\n\t\tS2=int(H/2)*(W-i)\n\t\tif abs(S1-S2)<ans:\n\t\t\tans=abs(S1-S2)\nif W%2==0:\n\tans=INF\n\tfor i in range(H):\n\t\tS1=W*i\n\t\tS2=int(W/2)*(H-i)\n\t\tif abs(S1-S2)<ans:\n\t\t\tans=min(ans,abs(S1-S2))\n\t\t\t\nfor i in range(H):\n\tfor j in range(W):\n\t\t\n\t\tS1=W*i\n\t\tS2=j*(H-i)\n\t\tS3=(W-j)*(H-i)\n\t\tminS=min(S1,S2,S3)\n\t\tmaxS=max(S1,S2,S3)\n\t\tif maxS-minS<ans:\n\t\t\tans=maxS-minS\n\t\t\n\t\tS1=H*j\n\t\tS2=i*(W-j)\n\t\tS3=(H-i)*(W-j)\n\t\tminS=min(S1,S2,S3)\n\t\tmaxS=max(S1,S2,S3)\n\t\tif maxS-minS<ans:\n\t\t\tans=maxS-minS\n\nans=min(ans,H,W)\n\n\t\n\t\nprint(ans)\n\t', 'temp=input().split()\nH=int(temp[0])\nW=int(temp[1])\n\nINF=10000000000\nans=INF\n\nif H%3==0 or W%3==0:\n\tans=0\nans=min(ans,H,W)\n\nfor i in range(H):\n\tS1=W*i\n\tS2=int(W/2)*(H-i)\n\tS3=(W-int(W/2))*(H-i)\n\tif max(S1,S2,S3)-min(S1,S2,S3)<ans:\n\t\tans=max(S1,S2,S3)-min(S1,S2,S3)\nfor i in range(W):\n\tS1=H*i\n\tS2=int(H/2)*(W-i)\n\tS3=(H-int(H/2))*(W-i)\n\tif max(S1,S2,S3)-min(S1,S2,S3)<ans:\n\t\tans=max(S1,S2,S3)-min(S1,S2,S3)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s685520294', 's857053030'] | [3064.0, 3064.0] | [2104.0, 292.0] | [717, 448] |
p03715 | u810735437 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['def max_minus_min(areas):\n # print("areas", areas)\n return max(areas) - min(areas)\n \ndef solve2(h, w):\n area1 = h * (w // 2)\n area2 = h * w - area1\n return [area1, area2]\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n for w2 in range(w_div_3, w_div_3 + 2):\n area1 = w2 * h\n\n tmp = solve2(h, w - w2)\n tmp = max_minus_min(tmp)\n ans = min(ans, tmp)\n\n tmp = solve2(w - w2, h)\n tmp = max_minus_min(tmp)\n ans = min(ans, tmp)\n', 'def max_minus_min(areas):\n # print("areas", areas)\n return max(areas) - min(areas)\n \ndef solve2(h, w):\n return 7, 7\n # area1 = h * (w // 2)\n # area2 = h * w - area1\n # return area1, area2\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n for w2 in range(w_div_3, w_div_3 + 2):\n area1 = w2 * h\n ans = min(ans, max_minus_min([area1] + solve2(h, w - w2)))\n ans = min(ans, max_minus_min([area1] + solve2(w - w2, h)))\n return ans\n \nH, W = map(int, input().split())\nprint(min(solve(H,W), solve(W,H)))\n', 'def max_minus_min(areas):\n # print("areas", areas)\n return max(areas) - min(areas)\n \ndef solve2(h, w):\n area1 = h * (w // 2)\n area2 = h * w - area1\n return area1, area2\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n for w2 in range(w_div_3, w_div_3 + 2):\n area1 = w2 * h\n ans = min(ans, max_minus_min([area1] + solve2(h, w - w2)))\n ans = min(ans, max_minus_min([area1] + solve2(w - w2, h)))\n return ans\n \nH, W = map(int, input().split())\nprint(min(solve(H,W), solve(W,H)))\n', 'def max_minus_min(areas):\n # print("areas", areas)\n return max(areas) - min(areas)\n \ndef solve2(h, w):\n area1 = h * (w // 2)\n area2 = h * w - area1\n return [area1, area2]\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n for w2 in range(w_div_3, w_div_3 + 2):\n area1 = w2 * h\n\n tmp = solve2(h, w - w2)\n tmp = max_minus_min(tmp)\n # ans = min(ans, max_minus_min([area1, tmp[0], tmp[1]])\n\n tmp = solve2(w - w2, h)\n # ans = min(ans, max_minus_min([area1, tmp[0], tmp[1]])\n return ans\n \nH, W = map(int, input().split())\nprint(min(solve(H,W), solve(W,H)))\n', 'def max_minus_min(areas):\n # print("areas", areas)\n return max(areas) - min(areas)\n \ndef solve2(h, w):\n area1 = h * (w // 2)\n area2 = h * w - area1\n return [area1, area2]\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n for w2 in range(w_div_3, w_div_3 + 2):\n area1 = w2 * h\n\n tmp = solve2(h, w - w2)\n tmp = max_minus_min(tmp)\n', 'def max_minus_min(areas):\n # print("areas", areas)\n return max(areas) - min(areas)\n \ndef solve2(h, w):\n area1 = h * (w // 2)\n area2 = h * w - area1\n return [area1, area2]\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n for w2 in range(w_div_3, w_div_3 + 2):\n area1 = w2 * h\n\n tmp = solve2(h, w - w2)\n ans = min(ans, max_minus_min([area1, tmp[0], tmp[1]])\n\n tmp = solve2(w - w2, h)\n ans = min(ans, max_minus_min([area1, tmp[0], tmp[1]])\n return ans\n \nH, W = map(int, input().split())\nprint(min(solve(H,W), solve(W,H)))\n', 'def max_minus_min(areas):\n # print("areas", areas)\n return max(areas) - min(areas)\n \ndef solve2(h, w):\n area1 = h * (w // 2)\n area2 = h * w - area1\n return [area1, area2]\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n for w2 in range(w_div_3, w_div_3 + 2):\n area1 = w2 * h\n\n tmp = solve2(h, w - w2)\n # ans = min(ans, max_minus_min([area1, tmp[0], tmp[1]])\n\n tmp = solve2(w - w2, h)\n # ans = min(ans, max_minus_min([area1, tmp[0], tmp[1]])\n return ans\n \nH, W = map(int, input().split())\nprint(min(solve(H,W), solve(W,H)))\n', 'def max_minus_min(areas):\n # print("areas", areas)\n # return max(areas) - min(areas)\n return 999\n \ndef solve2(h, w):\n return 7, 7\n # area1 = h * (w // 2)\n # area2 = h * w - area1\n # return area1, area2\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n for w2 in range(w_div_3, w_div_3 + 2):\n area1 = w2 * h\n \n tmp = max_minus_min([area1] + solve2(h, w - w2))\n\n # ans = min(ans, max_minus_min([area1] + solve2(h, w - w2)))\n # ans = min(ans, max_minus_min([area1] + solve2(w - w2, h)))\n return ans\n\nH, W = map(int, input().split())\nprint(min(solve(H,W), solve(W,H)))\n', 'def max_minus_min(areas):\n # print("areas", areas)\n return max(areas) - min(areas)\n \ndef solve2(h, w):\n area1 = h * (w // 2)\n area2 = h * w - area1\n return area1, area2\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n # for w2 in range(w_div_3, w_div_3 + 2):\n # area1 = w2 * h\n # ans = min(ans, max_minus_min([area1, *solve2(h, w - w2)]))\n # ans = min(ans, max_minus_min([area1, *solve2(w - w2, h)]))\n return ans\n \nH, W = map(int, input().split())\nprint(min(solve(H,W), solve(W,H)))\n', 'def max_minus_min(areas):\n # print("areas", areas)\n # return max(areas) - min(areas)\n return 999\n \ndef solve2(h, w):\n return 7, 7\n # area1 = h * (w // 2)\n # area2 = h * w - area1\n # return area1, area2\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n for w2 in range(w_div_3, w_div_3 + 2):\n area1 = w2 * h\n ans = min(ans, max_minus_min([area1] + solve2(h, w - w2)))\n ans = min(ans, max_minus_min([area1] + solve2(w - w2, h)))\n return ans\n \nH, W = map(int, input().split())\nprint(min(solve(H,W), solve(W,H)))\n', 'def max_minus_min(areas):\n # print("areas", areas)\n return max(areas) - min(areas)\n \ndef solve2(h, w):\n area1 = h * (w // 2)\n area2 = h * w - area1\n return [area1, area2]\n \ndef solve(h, w):\n w_div_3 = w // 3;\n ans = 1e9\n for w2 in range(w_div_3, w_div_3 + 2):\n area1 = w2 * h\n ans = min(ans, max_minus_min([area1] + solve2(h, w - w2)))\n ans = min(ans, max_minus_min([area1] + solve2(w - w2, h)))\n return ans\n \nH, W = map(int, input().split())\nprint(min(solve(H,W), solve(W,H)))\n'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s029237287', 's207943562', 's287592720', 's337676252', 's455055382', 's574667340', 's786262038', 's849111502', 's899384619', 's918925825', 's880420210'] | [3060.0, 3064.0, 3064.0, 3064.0, 2940.0, 2940.0, 3060.0, 3060.0, 2940.0, 3060.0, 3064.0] | [17.0, 18.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 18.0, 18.0, 19.0] | [495, 546, 524, 619, 373, 582, 586, 633, 532, 563, 526] |
p03715 | u814986259 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['import math\nH,W=map(int,input().split())\nif H%3==0 or W%3==0:\n print(0)\n exit(0)\nS=[0]*3\ns=H*import math\nH,W=map(int,input().split())\nif H%3==0 or W%3==0:\n print(0)\n exit(0)\nS=[0]*3\ns=H*W/3\nw0=math.ceil(s/H)\nh0=math.ceil(s/W)\n\nS[0]=w0*H\nw1=W-W/3\nw0=math.ceil(s/H)\nh0=math.ceil(s/W)\n\nS[0]=w0*H\nw1=W-w0\nif w1%2==0 or H%2==0:\n S[1]=(H*w1)//2\n S[2]=(H*w1)//2\nelse:\n s1=H*w1/2\n w10=math.ceil(s1/H)\n h10=math.ceil(s1/w1)\n S[2]=max((w1-w10)*H,(H-h10)*w1)\nans=abs(S[0]-S[2])\n\nS[0]=W*h0\nh1=H-h0\nif h1%2==0 or W%2==0:\n S[1]=(W*h1)//2\n S[2]=(W*h1)//2\nelse:\n s1=h1*W/2\n w11=math.ceil(s1/h1)\n h11=math.ceil(s1/W)\n S[2]=max((W-w11)*h1,(h1-h11)*W)\nans=min(ans,abs(S[0]-S[2]))\n\n\nS=[0]*3\ns=H*W/3\nw0=math.floor(s/H)\nh0=math.floor(s/W)\n\nS[0]=w0*H\nw1=W-w0\nif w1%2==0 or H%2==0:\n S[1]=(H*w1)//2\n S[2]=(H*w1)//2\nelse:\n s1=H*w1/2\n w10=math.floor(s1/H)\n h10=math.floor(s1/w1)\n S[2]=max((w1-w10)*H,(H-h10)*w1)\nans=min(ans,abs(S[0]-S[2]))\n\nS[0]=W*h0\nh1=H-h0\nif h1%2==0 or W%2==0:\n S[1]=(W*h1)//2\n S[2]=(W*h1)//2\nelse:\n s1=h1*W/2\n w11=math.floor(s1/h1)\n h11=math.floor(s1/W)\n S[2]=max((W-w11)*h1,(h1-h11)*W)\nans=min(ans,abs(S[0]-S[2]))\n\nprint(ans)', 'import math\nH,W=map(int,input().split())\nif H%3==0 or W%3==0:\n print(0)\n exit(0)\nS=[0]*3\ns=H*W/3\nw0=math.ceil(s/H)\nh0=math.ceil(s/W)\n\nS[0]=w0*H\nw1=W-W/3\nw0=math.ceil(s/H)\nh0=math.ceil(s/W)\n\nS[0]=w0*H\nw1=W-w0\nif w1%2==0 or H%2==0:\n S[1]=(H*w1)//2\n S[2]=(H*w1)//2\nelse:\n s1=H*w1/2\n w10=math.ceil(s1/H)\n h10=math.ceil(s1/w1)\n S[2]=max((w1-w10)*H,(H-h10)*w1)\nans=abs(S[0]-S[2])\n\nS[0]=W*h0\nh1=H-h0\nif h1%2==0 or W%2==0:\n S[1]=(W*h1)//2\n S[2]=(W*h1)//2\nelse:\n s1=h1*W/2\n w11=math.ceil(s1/h1)\n h11=math.ceil(s1/W)\n S[2]=max((W-w11)*h1,(h1-h11)*W)\nans=min(ans,abs(S[0]-S[2]))\n\n\nS=[0]*3\ns=H*W/3\nw0=math.floor(s/H)\nh0=math.floor(s/W)\n\nS[0]=w0*H\nw1=W-w0\nif w1%2==0 or H%2==0:\n S[1]=(H*w1)//2\n S[2]=(H*w1)//2\nelse:\n s1=H*w1/2\n w10=math.floor(s1/H)\n h10=math.floor(s1/w1)\n S[2]=max((w1-w10)*H,(H-h10)*w1)\nans=min(ans,abs(S[0]-S[2]))\n\nS[0]=W*h0\nh1=H-h0\nif h1%2==0 or W%2==0:\n S[1]=(W*h1)//2\n S[2]=(W*h1)//2\nelse:\n s1=h1*W/2\n w11=math.floor(s1/h1)\n h11=math.floor(s1/W)\n S[2]=max((W-w11)*h1,(h1-h11)*W)\nans=min(ans,abs(S[0]-S[2]))\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s745978389', 's748266099'] | [2940.0, 3192.0] | [17.0, 18.0] | [1148, 1053] |
p03715 | u821432765 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['H, W = [int(i) for i in input().split()]\n\n\nif H%3==0 or W%3==0:\n print(0)\n\nmind = 10**18\n\nfor h in range(H+1):\n a = [W*h]\n a.append((W//2)*(H-h))\n a.append(((W//2)+(1 if W%2 else 0))*(H-h))\n mind = min(mind, max(a)-min(a))\n\nfor w in range(W+1):\n a = [w*H]\n a.append((W-w)*(H//2))\n a.append((W-w)*((H//2)+(1 if H%2 else 0)))\n mind = min(mind, max(a)-min(a))\n\nprint(mind)', 'H, W = [int(i) for i in input().split()]\n\n\nif H%3==0 or W%3==0:\n print(0)\n quit()\n\nmind = 10**18\n\nfor h in range(H+1):\n a = [W*h]\n if W%2==0 or (H-h)%2==0:\n a.append(int(W/2*(H-h)))\n else:\n a.append(W*(H-h)-min(H-h, W)*(max(H-h, W)//2))\n a.append(W*(H-h)-a[-1])\n mind = min(mind, max(a)-min(a))\n\n\nfor w in range(W+1):\n a = [w*H]\n if (W-w)%2==0 or H%2==0:\n a.append(int((W-w)/2*H))\n else:\n a.append((W-w)*H-min(W-w, H)*(max(W-w, h)//2))\n a.append((W-w)*h-a[-1])\n mind = min(mind, max(a)-min(a))\n\nprint(mind)'] | ['Wrong Answer', 'Accepted'] | ['s784481077', 's721908315'] | [3188.0, 3188.0] | [296.0, 314.0] | [436, 618] |
p03715 | u911446944 | 2,000 | 262,144 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}. | ['n = int(input())\narray = [int(i) for i in input().split()]\nans=-1e14\n\nfor i in range(n, 2*n+1):\n l_array = sorted(array[:i])\n r_array = sorted(array[i:])\n ans = max(ans, sum(l_array[i-n:])-sum(r_array[:n]))\n\nprint(ans)', 'h,w = [int(i) for i in input().split()]\n\ndef solve(h,w):\n ans = min(h,w)\n for i in range(1,h):\n p1 = w*i\n p2 = (h-i)*(w//2)\n p3 = h*w-p1-p2\n ans = min(ans, max(p1,p2,p3)-min(p1,p2,p3))\n return ans \n\nans = min(solve(h,w), solve(w,h))\nif h*w % 3 == 0:\n ans = 0\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s223390467', 's429428326'] | [3060.0, 3064.0] | [17.0, 204.0] | [227, 310] |
p03716 | u038408819 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ["N = int(input())\na = list(map(int, input().split()))\n\nimport heapq\nque1 = []\nheapq.heapify(que1)\nS = [0] * (2*N + 1)\nfor i in range(N):\n S[i + 1] = S[i] + a[i]\n #que1.append(a[i])\n heapq.heappush(que1, a[i])\nque2 = []\nheapq.heapify(que2)\nT = [0] * (2*N + 1)\nfor i in range(N):\n T[i + 1] = T[i] + a[3*N - i - 1]\n \n heapq.heappush(que2, -a[3*N - i - 1])\n\nfor i in range(N, 2*N):\n mi = heapq.heappop(que1)\n print(mi)\n if a[i] > mi:\n S[i + 1] = S[i] - mi + a[i]\n #heapq.heappop(que1)\n heapq.heappush(que1, a[i])\n else:\n S[i + 1] = S[i]\n heapq.heappush(que1, mi)\nfor i in range(N, 2*N):\n ma = heapq.heappop(que2) * -1\n print(ma)\n if a[3*N - i - 1] < ma:\n T[i + 1] = T[i] - ma + a[3*N - i - 1]\n #heapq.heappop(que2)\n \n heapq.heappush(que2, -a[3*N - i - 1])\n else:\n T[i + 1] = T[i]\n heapq.heappush(que2, -ma)\n\nres = -float('Inf')\nfor i in range(N, 2*N + 1):\n res = max(res, S[i] - T[3*N - i])\nprint(res)\n", "N = int(input())\na = list(map(int, input().split()))\n\nimport heapq\nque1 = []\nheapq.heapify(que1)\nS = [0] * (2*N + 1)\nfor i in range(N):\n S[i + 1] = S[i] + a[i]\n #que1.append(a[i])\n heapq.heappush(que1, a[i])\nque2 = []\nheapq.heapify(que2)\nT = [0] * (2*N + 1)\nfor i in range(N):\n T[i + 1] = T[i] + a[3*N - i - 1]\n \n heapq.heappush(que2, -a[3*N - i - 1])\n\nfor i in range(N, 2*N):\n mi = heapq.heappop(que1)\n print(mi)\n if a[i] > mi:\n S[i + 1] = S[i] - mi + a[i]\n #heapq.heappop(que1)\n heapq.heappush(que1, a[i])\n else:\n S[i + 1] = S[i]\n heapq.heappush(que1, mi)\nfor i in range(N, 2*N):\n ma = heapq.heappop(que2) * -1\n print(ma)\n if a[3*N - i - 1] < ma:\n T[i + 1] = T[i] - ma + a[3*N - i - 1]\n #heapq.heappop(que2)\n \n heapq.heappush(que2, -a[3*N - i - 1])\n else:\n T[i + 1] = T[i]\n heapq.heappush(que2, -ma)\n\nres = -float('Inf')\nfor i in range(N, 2*N):\n res = max(res, S[i] - T[3*N - i])\nprint(res)", "N = int(input())\na = list(map(int, input().split()))\n\nimport heapq\nque1 = []\nheapq.heapify(que1)\nS = [0] * (2*N + 1)\nfor i in range(N):\n S[i + 1] = S[i] + a[i]\n #que1.append(a[i])\n heapq.heappush(que1, a[i])\nque2 = []\nheapq.heapify(que2)\nT = [0] * (2*N + 1)\nfor i in range(N):\n T[i + 1] = T[i] + a[3*N - i - 1]\n \n heapq.heappush(que2, -a[3*N - i - 1])\n\nfor i in range(N, 2*N):\n mi = heapq.heappop(que1)\n #print(mi)\n if a[i] > mi:\n S[i + 1] = S[i] - mi + a[i]\n #heapq.heappop(que1)\n heapq.heappush(que1, a[i])\n else:\n S[i + 1] = S[i]\n heapq.heappush(que1, mi)\nfor i in range(N, 2*N):\n ma = heapq.heappop(que2) * -1\n #print(ma)\n if a[3*N - i - 1] < ma:\n T[i + 1] = T[i] - ma + a[3*N - i - 1]\n #heapq.heappop(que2)\n \n heapq.heappush(que2, -a[3*N - i - 1])\n else:\n T[i + 1] = T[i]\n heapq.heappush(que2, -ma)\n\nres = -float('Inf')\nfor i in range(N, 2*N + 1):\n res = max(res, S[i] - T[3*N - i])\nprint(res)\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s077575791', 's458349180', 's375090405'] | [38552.0, 38700.0, 37084.0] | [844.0, 848.0, 584.0] | [1077, 1072, 1079] |
p03716 | u104282757 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['# D\nimport numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())))\n\n# pop from left\npopleft = [0]*(N+1)\nA_LEFT = np.argsort(A[:(2*N)])\nind_left = 1\nfor i in range(N):\n while popleft[ind_left] > 0:\n ind_left += 1\n if A_LEFT[i] < N:\n popleft[ind_left] = A[A_LEFT[i]]\n else:\n popleft[A_LEFT[i] - (N-2)] = A[A_LEFT[i]]\nleft_sum = np.cumsum(A)[(N-1):2*N] - np.cumsum(np.array(popleft))\n\n# pop from right\npopright = [0]*(N+1)\nA_RIGHT = np.argsort(-A[::-1][:(2*N-1)])\nind_right = 1\nfor i in range(N):\n while popright[ind_right] > 0:\n ind_right += 1\n if A_RIGHT[i] < N:\n popright[ind_right] = A[3*N - 1 - A_RIGHT[i]]\n else:\n popright[A_RIGHT[i] - (N-2)] = A[3*N - 1 - A_RIGHT[i]]\nright_sum = np.cumsum(A[::-1])[(N-1):2*N] - np.cumsum(np.array(popright))\n\n# print(popleft)\n# print(popright)\nres = (left_sum - right_sum[::-1]).max()\n# extreme case\nres1 = (np.sort(A[:2*N])[N:]).sum() - A[2*N:].sum()\nres2 = A[:N].sum() - (np.sort(A[N:])[:N]).sum()\nprint(max(res, res1, res2))', '# D\nimport numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())))\n\n# pop from left\npopleft = [0]*(N+1)\nA_LEFT = np.argsort(A[:(2*N)])\nind_left = 1\nfor i in range(N):\n while popleft[ind_left] > 0:\n ind_left += 1\n if A_LEFT[i] < N:\n popleft[ind_left] = A[A_LEFT[i]]\n else:\n popleft[A_LEFT[i] - (N-2)] = A[A_LEFT[i]]\nleft_sum = np.cumsum(A)[(N-1):2*N] - np.cumsum(np.array(popleft))\n\n# pop from right\npopright = [0]*(N+1)\nA_RIGHT = np.argsort(-A[::-1][:(2*N)])\nind_right = 1\nfor i in range(N):\n while popright[ind_right] > 0:\n ind_right += 1\n if A_RIGHT[i] < N:\n popright[ind_right] = A[3*N - 1 - A_RIGHT[i]]\n else:\n popright[A_RIGHT[i] - (N-2)] = A[3*N - 1 - A_RIGHT[i]]\nright_sum = np.cumsum(A[::-1])[(N-1):2*N] - np.cumsum(np.array(popright))\n\n# print(popleft)\n# print(popright)\nres = (left_sum - right_sum[::-1]).max()\n# extreme case\nres1 = (np.sort(A[:2*N])[N:]).sum() - A[2*N:].sum()\nres2 = A[:N].sum() - (np.sort(A[N:])[:N]).sum()\nprint(max(res, res1, res2))', '# D\nimport numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())))\n\n# pop from left\npopleft = [0]*(N+1)\nA_LEFT = np.argsort(A[:(2*N)])\nind_left = 1\nfor i in range(N):\n while popleft[ind_left] > 0:\n ind_left += 1\n if A_LEFT[i] < N:\n popleft[ind_left] = A[A_LEFT[i]]\n else:\n popleft[max(ind_left, A_LEFT[i] - (N-1))] = A[A_LEFT[i]]\nleft_sum = np.cumsum(A)[(N-1):(2*N)] - np.cumsum(np.array(popleft))\n\n# pop from right\npopright = [0]*(N+1)\nA_RIGHT = np.argsort(-A[::-1][:(2*N)])\nind_right = 1\nfor i in range(N):\n while popright[ind_right] > 0:\n ind_right += 1\n if A_RIGHT[i] < N:\n popright[ind_right] = A[3*N - 1 - A_RIGHT[i]]\n else:\n popright[max(ind_right, A_RIGHT[i] - (N-1))] = A[3*N - 1 - A_RIGHT[i]]\nright_sum = np.cumsum(A[::-1])[(N-1):(2*N)] - np.cumsum(np.array(popright))\n\n# print(popleft)\n# print(popright)\nres = (left_sum - right_sum[::-1]).max()\n# extreme case\nres1 = (np.sort(A[:2*N])[N:]).sum() - A[2*N:].sum()\nres2 = A[:N].sum() - (np.sort(A[N:])[:N]).sum()\nprint(max(res, res1, res2))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s263341736', 's637801728', 's090906902'] | [47368.0, 46136.0, 47368.0] | [1012.0, 1025.0, 1227.0] | [1044, 1042, 1077] |
p03716 | u131638468 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['import heapq\nn=int(input())\na=list(map(int,input().split()))\nans=0\nfor i in range(n+1):\n m=0\n b1=a[:n+i]\n b2=a[n+i:]\n heapq.heapify(b1)\n heapq.heapify(b2)\n for j in range(i):\n b=heapq.heappop(b1)\n for j in range(n-i):\n b=heapq.heappop(b2)\n m=sum(b1)-sum(b2)\n if ans<m or i==0:\n ans=m\nprint(ans)', 'import heapq\nn=int(input())\na=list(map(int,input().split()))\nans=[0 for i in range(n+1)]\nans[0]=sum(a[:n])\nb=a[:n]\nheapq.heapify(b)\nsb=sum(b)\nfor i in range(n):\n sb+=a[n+i]\n c=heapq.heappushpop(b,a[n+i])\n sb-=c\n ans[i+1]=sb\nb=a[2*n:]\nfor i in range(n):\n b[i]=-b[i]\nheapq.heapify(b)\nans[n]+=sum(b)\nsb=sum(b)\nfor i in range(n-1,-1,-1):\n sb-=a[n+i]\n c=heapq.heappushpop(b,-a[n+i])\n sb-=c\n ans[i]+=sb\nprint(max(ans))'] | ['Wrong Answer', 'Accepted'] | ['s655458325', 's759479281'] | [38292.0, 38148.0] | [2108.0, 375.0] | [312, 421] |
p03716 | u139112865 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['import heapq\nn = int(input())\na = list(map(int, input().split()))\n\nl = a[:n]\nheapq.heapify(l)\nmemo_l = [0 for _ in range(n+1)]\nmemo_l[0] = sum(a[:n])\n\nfor i in range(1, n+1):\n memo_l[i] = memo_l[i-1]\n if l[0] < a[n+i-1]:\n x = heapq.heappop(l)\n heapq.heappush(l, a[n+i-1])\n memo_l[i] += a[n+i-1] - x\n\n\nr = [-a[-i] for i in range(1, n+1)]\nheapq.heapify(r)\nmemo_r = [0 for _ in range(n+1)]\nmemo_r[0] = sum(a[-n:])\n\nfor i in range(1, n+1):\n memo_r[i] = memo_r[i-1]\n if abs(x) > a[-n-i]:\n x = heapq.heappop(r)\n heapq.heappush(r, -a[-n-i])\n memo_r[i] += x + a[-n-i]\n\n\nans = - 10 ** 20\nfor i in range(n+1):\n ans = max(ans, memo_l[i] - memo_r[n-i])\n\nprint(ans)', 'import heapq\nn = int(input())\na = list(map(int, input().split()))\n\nl = a[:n]\nheapq.heapify(l)\nmemo_l = [0 for _ in range(n+1)]\nmemo_l[0] = sum(a[:n])\n\nfor i in range(1, n+1):\n memo_l[i] = memo_l[i-1]\n if l[0] < a[n+i-1]:\n x = heapq.heappop(l)\n heapq.heappush(l, a[n+i-1])\n memo_l[i] += a[n+i-1] - x\n\n\nr = [-a[-i] for i in range(1, n+1)]\nheapq.heapify(r)\nmemo_r = [0 for _ in range(n+1)]\nmemo_r[0] = sum(a[-n:])\n\nfor i in range(1, n+1):\n memo_r[i] = memo_r[i-1]\n if abs(r[0]) > a[-n-i]:\n x = heapq.heappop(r)\n heapq.heappush(r, -a[-n-i])\n memo_r[i] += x + a[-n-i]\n\n\nans = - 10 ** 20\nfor i in range(n+1):\n ans = max(ans, memo_l[i] - memo_r[n-i])\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s331084925', 's813713085'] | [43852.0, 42828.0] | [356.0, 346.0] | [709, 712] |
p03716 | u147458211 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['import heapq\nN = int(input())\na = list(map(int, input().split()))\n\nmax_result = -1000000\n\nfor k in range(N, 2*N+1):\n print("----------------")\n big_a = a[:k]\n heapq.heapify(big_a)\n print(big_a)\n small_a =[(-x, x) for x in a[k:]]\n heapq.heapify(small_a)\n print(small_a)\n\n for i in range(len(big_a) - N):\n heapq.heappop(big_a)\n print(big_a)\n\n for i in range(len(small_a) - N):\n heapq.heappop(small_a)\n print(small_a)\n\n big_sum = sum(big_a)\n small_sum = 0\n for i in small_a:\n small_sum += i[1]\n\n if (big_sum - small_sum) > max_result:\n max_result = big_sum - small_sum\n\nprint(max_result)\n\n', "import heapq\nN = int(input())\na = list(map(int, input().split()))\n\nmax_result = -1000000\n\nbig_a = a[:N]\nbig_sum = [sum(big_a)]\nheapq.heapify(big_a)\nfor i in range(N):\n heapq.heappush(big_a, a[N+i])\n p = heapq.heappop(big_a)\n big_sum.append(big_sum[-1] + a[N+i] - p)\n\nsmall_a = [-i for i in a[-N:]]\nsmall_sum = [sum(small_a)]\nheapq.heapify(small_a)\nfor i in range(N):\n heapq.heappush(small_a, -a[-N-i-1])\n p = heapq.heappop(small_a)\n small_sum.append(small_sum[-1] - a[-N-i-1] - p)\n\nmax_result = -float('inf')\n\nfor m,s in zip(big_sum, small_sum[::-1]):\n max_result = max(m + s, max_result)\n\nprint(max_result)\n\n"] | ['Wrong Answer', 'Accepted'] | ['s506980286', 's728501985'] | [121884.0, 38420.0] | [2107.0, 459.0] | [613, 616] |
p03716 | u163703551 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['import sys\nimport heapq\n\n\ndef solve(n, a):\n res = -10 ** 20\n for i in range(n, 2 * n + 1):\n l = a[0:i]\n r = a[i:3 * n]\n l.sort(reverse=True)\n r.sort()\n res0 = sum(l[0:n]) - sum(r[0:n])\n if res0 > res:\n res = res0\n return res\n\n\ndef find_best(n, a):\n h = list()\n s = 0\n best_s = 0\n res = list()\n for i in range(0, 2 * n):\n heapq.heappush(h, a[i])\n s += a[i]\n if len(h) > n:\n m = heapq.heappop(h)\n s -= m\n if len(h) == n:\n if best_s < s:\n best_s = s\n res.append(best_s)\n return res\n\n\ndef solve_large(n, a):\n res = -10 ** 20\n max_l = find_best(n, a)\n b = [-x for x in reversed(a)]\n max_r = find_best(n, b)\n max_r.reverse()\n for l, r in zip(max_l, max_r):\n res0 = l + r\n if res < res0:\n res = res0\n return res\n\n\n\nn = int(input())\na = list(map(int, input().split()))\nprint(solve_large(n, a))\n', "import os\nimport sys\nimport heapq\n\n\ndef solve(n, a):\n res = -10 ** 20\n for i in range(n, 2 * n + 1):\n l = a[0:i]\n r = a[i:3 * n]\n l.sort(reverse=True)\n r.sort()\n res0 = sum(l[0:n]) - sum(r[0:n])\n if res0 > res:\n res = res0\n return res\n\n\ndef find_best(n, a):\n h = list()\n s = 0\n best_s = -10**20\n res = list()\n for i in range(0, 2 * n):\n heapq.heappush(h, a[i])\n s += a[i]\n if len(h) > n:\n m = heapq.heappop(h)\n s -= m\n if len(h) == n:\n if best_s < s:\n best_s = s\n res.append(best_s)\n return res\n\n\ndef solve_large(n, a):\n res = -10 ** 20\n max_l = find_best(n, a)\n b = [-x for x in reversed(a)]\n max_r = find_best(n, b)\n max_r.reverse()\n for l, r in zip(max_l, max_r):\n res0 = l + r\n if res < res0:\n res = res0\n return res\n\n\ninput_file = 'd1.in'\nif os.path.exists(input_file):\n sys.stdin = open(input_file)\nn = int(input())\na = list(map(int, input().split()))\nprint(solve_large(n, a))\n"] | ['Wrong Answer', 'Accepted'] | ['s419310295', 's232415184'] | [37212.0, 37212.0] | [484.0, 481.0] | [1026, 1099] |
p03716 | u197457087 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['import heapq\n\nN = int(input())\nA = list(map(int,input().split()))\nC = A[N:(2*N)]\n\nL = []\nR = []\nfor i in range(N):\n heapq.heappush(L,A[i]) \n heapq.heappush(R,-A[-1-i]) \n \n#print(L,R,C)\n\nlp = 0 \nrp = 0\nfor i in range(N):\n #print(i,lp,rp)\n if C[lp] - L[0] >= -C[-1-rp] - R[0]: \n heapq.heappush(L, C[lp]) \n temp = heapq.heappop(L)\n lp += 1\n else:\n heapq.heappush(R, -C[-1-rp])\n temp = heapq.heappop(R) \n rp += 1\nprint(L,R,lp,rp)\nans = sum(L) + sum(R)\nprint(ans)\n ', "import heapq\n\nN = int(input())\nA = list(map(int,input().split()))\nC = A[N:(2*N)]\n\nL = []\nR = []\nfor i in range(N):\n heapq.heappush(L,A[i]) \n heapq.heappush(R,-A[-1-i]) \n\n\nansL = [sum(L)]\nfor i in range(N):\n heapq.heappush(L,C[i])\n rmv = heapq.heappop(L)\n temp = ansL[i] + C[i] - rmv \n ansL.append(temp)\n \n\nansR = [sum(R)]\nfor i in range(N):\n heapq.heappush(R,-C[-1-i])\n rmv = heapq.heappop(R)\n temp = ansR[i] - C[-1-i] - rmv\n ansR.append(temp)\n \n\nans = -float('inf')\nfor i in range(N+1):\n temp = ansL[i]+ansR[-1-i]\n ans = max(ans,temp)\n#print(ansL,ansR)\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s522750953', 's443714117'] | [38420.0, 37212.0] | [336.0, 527.0] | [760, 907] |
p03716 | u207097826 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['# -*- coding: utf-8 -*-\n"""\nCreated on Sun May 3 18:58:46 2020\n\n@author: naoki\n"""\nfrom heapq import heappush, heappop\nimport sys\n\nN = int(input())\na = list(map(int,input().split()))\n\nhq = []\nhq_r = []\nfor i in range(N):\n heappush(hq,a[i])\n heappush(hq_r,-1*a[-1-i])\n\n\nmax_A = [0 for _ in range(N+1)]\nmax_A[0] = sum(hq)\n\nmin_C = [0 for _ in range(N+1)]\nmin_C[0] = sum(hq_r) * (-1)\n\nfor i in range(N):\n heappush(hq, a[N+i])\n heappush(hq_r, -1*a[-N-1-i])\n minus = heappop(hq)\n minus_r = heappop(hq_r)\n max_A[i+1] = max_A[i] + a[N+i] - minus\n min_C[i+1] = min_C[i] + a[-N-1-i] + minus_r\n \nmax_val = -10e+100\nprint(max_val)\nfor i in range(N+1):\n kari = max_A[i] - min_C[-1-i]\n if max_val < kari:\n max_val =kari\nprint(max_val)', '\n\nN = int(input())\na = list(map(int, input().split()))\n\nA = (a[0:N])\nA = deque(sorted(A))\nB = deque(a[N:2*N])\nC = a[2*N:3*N]\nC = deque(sorted(C, reverse = True))\n\noriginal_score = 0\nfor i in range(N):\n original_score += A[i] - C[i]\n\nleft = 0\nright = 0\n\nfor i in range(N):\n left_candidate = B[left] - A[left]\n right_candidate = C[right] - B[-1-right]\n \n if left_candidate >= right_candidate:\n left+=1\n original_score+=left_candidate\n else:\n right+=1\n original_score+=right_candidate\nprint(original_score)', '# -*- coding: utf-8 -*-\n"""\nCreated on Sun May 3 18:58:46 2020\n\n@author: naoki\n"""\nfrom heapq import heappush, heappop\nimport sys\n\nN = int(input())\na = list(map(int,input().split()))\n\nhq = []\nhq_r = []\nfor i in range(N):\n heappush(hq,a[i])\n heappush(hq_r,-1*a[-1-i])\n\n\nmax_A = [0 for _ in range(N+1)]\nmax_A[0] = sum(hq)\n\nmin_C = [0 for _ in range(N+1)]\nmin_C[0] = sum(hq_r) * (-1)\n\nfor i in range(N):\n heappush(hq, a[N+i])\n heappush(hq_r, -1*a[-N-1-i])\n minus = heappop(hq)\n minus_r = heappop(hq_r)\n max_A[i+1] = max_A[i] + a[N+i] - minus\n min_C[i+1] = min_C[i] + a[-N-1-i] + minus_r\n \nmax_val = -10e+100\nfor i in range(N+1):\n kari = max_A[i] - min_C[-1-i]\n if max_val < kari:\n max_val =kari\nprint(max_val)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s096813467', 's362292592', 's469812461'] | [37212.0, 37084.0, 37212.0] | [516.0, 93.0, 539.0] | [762, 549, 747] |
p03716 | u310678820 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['from heapq import heappush, heappop\nn=int(input())\na=list(map(int, input().split()))\nq1=[]\nq2=[]\ns1=[]\ns2=[]\nfor i in range(n):\n heappush(q1, a[i])\ns1.append(sum(a[0:n]))\nfor ai in a[n:2*n]:\n heappush(q1, ai)\n m=heappop(q1)\n s1.append(s1[-1]+ai-m)\na=a[::-1]\nfor i in range(n):\n heappush(q2, -a[i])\ns2.append(-sum(a[0:n]))\nfor ai in [-i for i in a[n:2*n]]:\n heappush(q2, ai)\n m=heappop(q2)\n s2.append(s2[-1]+ai-m)\nans=-1\nprint(s1, s2)\nfor i in range(n+1):\n ans=max(s1[i]+s2[-i-1], ans)\nprint(ans) ', 'from heapq import heappush, heappop\nn=int(input())\na=list(map(int, input().split()))\nq1=[]\nq2=[]\ns1=[]\ns2=[]\nfor i in range(n):\n heappush(q1, a[i])\ns1.append(sum(a[0:n]))\nfor ai in a[n:2*n]:\n heappush(q1, ai)\n m=heappop(q1)\n s1.append(s1[-1]+ai-m)\na=a[::-1]\nfor i in range(n):\n heappush(q2, -a[i])\ns2.append(-sum(a[0:n]))\nfor ai in [-i for i in a[n:2*n]]:\n heappush(q2, ai)\n m=heappop(q2)\n s2.append(s2[-1]+ai-m)\nans=s1[0]+s2[-1]\nfor i in range(n+1):\n ans=max(s1[i]+s2[-i-1], ans)\nprint(ans) '] | ['Wrong Answer', 'Accepted'] | ['s315703699', 's269665319'] | [39460.0, 37212.0] | [453.0, 434.0] | [523, 522] |
p03716 | u367130284 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['def f(a):q=a[:n];heapify(q);return sum(q)+cumsum([e-heappushpop(q,e)for e in a[n:n-~n]]);from heapq import*;from numpy import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),f([-e for e in a[::-1]])[::-1]))))', 'def f(a):\n\tq=a[:n];s=sum(q);heapify(q)\n\tfor e in a[n:2*n]:yield s;s+=e-heappushpop(q,e)\nfrom heapq import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),list(f([-e for e in a[::-1]]))[::-1]))))', 'def f(a):q=a[:n];heapify(q);return sum(q)+cumsum([e-heappushpop(q,e)for e in a[n:n-~n]])\nfrom heapq import*;from numpy import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),f([-e for e in a[::-1]])[::-1]))))', 'def f(a):\n\tq=a[:n];s=sum(q);heapify(q);yield s\n\tfor e in a[n:2*n]:s+=e-heappushpop(q,e);yield s\nfrom heapq import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),list(f([-e for e in a[::-1]]))[::-1]))))'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s254703592', 's386946796', 's918639303', 's765321529'] | [3064.0, 36308.0, 45252.0, 36308.0] | [17.0, 279.0, 1631.0, 268.0] | [225, 211, 225, 219] |
p03716 | u450956662 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['import heapq\nN = int(input())\nA = list(map(int, input().split()))\nR = [a for a in A[:N]]\nM = [a for a in A[N:2*N]]\nB = [-a for a in A[2*N:3*N]]\nres_R = [0] * (N + 1)\nres_B = [0] * (N + 1)\nres_R[0] = sum(R)\nres_B[N] = -sum(B)\nheapq.heapify(R)\nheapq.heapify(B)\nfor i in range(N):\n heapq.heappush(R, M[i])\n a = heapq.heappop(R)\n res_R[i+1] = res_R[i] + M[i] - a\n heapq.heappush(B, -M[N-i-1])\n a = heapq.heappop(B)\n res_B[N-i-1] = res_B[N-i] + M[N-i-1] + a\nprint(max(r - b for r, b in zip(res_R, res_B)))\nprint(res_R)\nprint(res_B)', 'import heapq\nN = int(input())\nA = list(map(int, input().split()))\nR = [a for a in A[:N]]\nM = [a for a in A[N:2*N]]\nB = [-a for a in A[2*N:3*N]]\nres_R = [0] * (N + 1)\nres_B = [0] * (N + 1)\nres_R[0] = sum(R)\nres_B[N] = -sum(B)\nheapq.heapify(R)\nheapq.heapify(B)\nfor i in range(N):\n heapq.heappush(R, M[i])\n a = heapq.heappop(R)\n res_R[i+1] = res_R[i] + M[i] - a\n heapq.heappush(B, -M[N-i-1])\n a = heapq.heappop(B)\n res_B[N-i-1] = res_B[N-i] + M[N-i-1] + a\nprint(max(r - b for r, b in zip(res_R, res_B)))'] | ['Wrong Answer', 'Accepted'] | ['s335183011', 's433950988'] | [37644.0, 37212.0] | [480.0, 458.0] | [544, 518] |
p03716 | u536113865 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['ai = lambda: list(map(int,input().split()))\n\nn = int(input())\na = ai()\n\nans = 0\nfor k in range(n):\n af = a[:n+k]\n ar = a[n+k:]\n aa = sum(sorted(af)[:n]) + sum(sorted(af, reverse=True)[:n])\n ans = max(ans, aa)\n\nprint(ans)', 'ai = lambda: list(map(int,input().split()))\n\nn = int(input())\na = ai()\n\nbig = sum(a[:n])\nsmall = sum(a[2*n:])\n\nimport heapq\naf = a[:n]\nheapq.heapify(af)\nar = [-i for i in a[2*n:]]\nheapq.heapify(ar)\n\nans = [[0,0] for _ in range(n+1)]\nans[0][0] = big\nans[-1][1] = small\n\nfor k in range(n):\n if af[0] < a[n+k]:\n b = heapq.heapreplace(af, a[n+k])\n big += a[n+k] - b\n ans[k+1][0] = big\n\nfor k in range(n):\n if -ar[0] > a[-n-k-1]:\n s = heapq.heapreplace(ar, -a[-n-k-1])\n small += a[-n-k-1] + s\n ans[-k-2][1] = small\n\nprint(max(i-j for i,j in ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s441601434', 's474993453'] | [39012.0, 38468.0] | [2109.0, 439.0] | [232, 582] |
p03716 | u557494880 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['N = int(input())\nA = list(map(int,input().split()))\nS = []\nP = A[:N]\nQ = A[2*N:]\nfor i in range(N):\n Q[i] *= -1\nR = A[N:2*N]\np = [0]*(N+1)\nq = [0]*(N+1)\nimport heapq\nheapq.heapify(P)\nheapq.heapify(Q)\nsp = sum(P)\nsq = sum(Q)\np[0] = sp\nq[0] = sq\n\nfor i in range(1,N+1):\n heapq.heappush(P,R[i-1])\n heapq.heappop(P)\n sp = sum(P)\n p[i] = sum(Q)\nfor i in range(1,N+1):\n heapq.heappush(Q,-R[-i])\n heapq.heappop(Q)\n sq = sum(Q)\n q[i] = sq\n\nans = -(10**100)\nfor k in range(N+1):\n ans = max(ans,p[k] + q[N-k])\n \nprint(ans)\n', 'N = int(input())\nA = list(map(int,input().split()))\nS = []\nfor i in range(N+1):\n P = A[:(N+i)]\n Q = A[(N+i):]\n for l in range(len(Q)):\n Q[l] *= -1\n heapq.heapify(P)\n heapq.heapify(Q)\n j = 0\n k = 0\n while j < i:\n heapq.heappop(P)\n while k < N-i:\n heapq.heappop(Q)\n s = sum(P) + sum(Q)\n S.append(s)\nans = min(S)\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\nS = []\nimport heapq\nfor i in range(N+1):\n P = A[:(N+i)]\n Q = A[(N+i):]\n for l in range(len(Q)):\n Q[l] *= -1\n heapq.heapify(P)\n heapq.heapify(Q)\n j = 0\n k = 0\n while j < i:\n heapq.heappop(P)\n j += 1\n while k < N-i:\n heapq.heappop(Q)\n k += 1\n s = sum(P) + sum(Q)\n S.append(s)\nans = min(S)\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\nS = []\nP = A[:N]\nQ = A[2*N:]\nfor i in range(N):\n Q[i] *= -1\nR = A[N:2*N]\np = [0]*(N+1)\nq = [0]*(N+1)\nimport heapq\nheapq.heapify(P)\nheapq.heapify(Q)\nsp = sum(P)\nsq = sum(Q)\np[0] = sp\nq[0] = sq\n\nfor i in range(1,N+1):\n heapq.heappush(P,R[i-1])\n x = heapq.heappop(P)\n heapq.heappush(Q,-R[-i])\n y = heapq.heappop(Q)\n sp = sp + R[i-1] - x\n sq = sq - R[-i] - y\n p[i] = sp\n q[i] = sq\nans = -(10**100)\nfor k in range(N+1):\n ans = max(ans,p[k] + q[N-k])\n \nprint(ans)\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s775514001', 's776774021', 's999105011', 's439911358'] | [39124.0, 41172.0, 39124.0, 40724.0] | [2109.0, 124.0, 2105.0, 466.0] | [546, 374, 417, 543] |
p03716 | u704284486 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['import heapq\nimport sys\ndef main():\n N = int(sys.stdin.readline())\n A = list(map(int,sys.stdin.readline().split()))\n front = []\n back = []\n heapq.heapify(front)\n heapq.heapify(back)\n ans = 0\n L = 3*N\n f_end = 0\n b_start = L-1\n for i in range(L):\n a = A[i]\n b = A[3*N-1-i]\n if i == 3*N-1-i:\n s1 = a-front[0]\n s2 = -b-back[0]\n if f_end > b_start:break\n if s1 >= s2 >= 0:\n heapq.heappop(front)\n heapq.heappush(front,a)\n break\n elif 0 <= s1 < s2:\n heapq.heappop(back)\n heapq.heappush(back,-b)\n break\n if len(front) == N:\n if front[0] < a:\n if i < b_start:\n heapq.heappop(front)\n heapq.heappush(front,a)\n f_end = i\n else:\n heapq.heappush(front,a)\n f_end = i\n if len(back) == N:\n if back[0] < -b:\n if f_end < 3*N-1-i:\n heapq.heappop(back)\n heapq.heappush(back,-b)\n b_start = 3*N-1-i\n else:\n heapq.heappush(back,-b)\n b_start = 3*N-1-i\n ans = sum(front)+sum(back)\n print(ans)\n print(front)\n print(back)\n\nif __name__ == "__main__":\n main()', 'import heapq\nimport sys\ndef main():\n N = int(sys.stdin.readline())\n A = list(map(int,sys.stdin.readline().split()))\n front = A[:N]\n back = list(map(lambda x:x*(-1),A[2*N:]))\n heapq.heapify(front)\n heapq.heapify(back)\n s1 = sum(front)\n s2 = sum(back)\n s1_list = [s1]\n ans = 0\n for i in range(N,2*N):\n a = A[i]\n heapq.heappush(front,a)\n min_front = heapq.heappop(front)\n s1 = s1-min_front+a\n s1_list.append(s1)\n ans = s2 +s1_list.pop()\n for i in reversed(range(N,2*N)):\n b = -A[i]\n heapq.heappush(back,b)\n min_back = heapq.heappop(back)\n s2 = s2-min_back+b\n ans = max(ans,s2+s1_list.pop())\n print(ans)\n\nif __name__ == "__main__":\n main()'] | ['Wrong Answer', 'Accepted'] | ['s750876682', 's946867719'] | [39516.0, 39084.0] | [436.0, 369.0] | [1382, 750] |
p03716 | u765237551 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['import heapq\nn = int(input())\nxs = list(map(int, input().split()))\nhead = heapq.heapify(xs[:n])\nbody = xs[n:2*n]\nbody_and_tail = sorted(xs[n:])\nsum_tail = sum(body_and_tail_list[:n])\nunused_tail = heapq.heapify(body_and_tail[-n:])\nans = -1000000000000000000000\ntemp = sum(head) - sum_tail\nfor b in body:\n heapq.push(head, b)\n temp = temp - heapq.pop(head) - heapq.pop(unused_tail) + 2*b\n ans = max(ans, temp)\nprint(ans)', 'import heapq\nn = int(input())\nxs = list(map(int, input().split()))\nhead = [(x, x) for x in xs[:n]]\nheapq.heapify(head)\nbody = xs[n:-n]\ntail = [(-x, x) for x in xs[-n:]]\nheapq.heapify(tail)\n\ndef f(heap, body, sign, initial):\n answer = [initial]\n acc = initial\n for b in body:\n heapq.heappush(heap, (sign*b, b))\n _, x = heapq.heappop(heap)\n acc = acc + b - x\n answer.append(acc)\n return answer\n \nprint(max(x - y for x, y in zip(\n f(head, body, 1, sum(xs[:n])),\n f(tail, body[::-1], -1, sum(xs[-n:]))[::-1])))'] | ['Runtime Error', 'Accepted'] | ['s221073679', 's589196679'] | [38148.0, 45584.0] | [177.0, 647.0] | [428, 552] |
p03716 | u777923818 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['# -*- coding: utf-8 -*-\ndef inpl(): return tuple(map(int, input().split()))\nfrom bisect import bisect_left, insort\nN = int(input())\nA = inpl()\n\nbefore = sorted(A[:N])\nmiddle = sorted(A[N:-N])\nafter = sorted(A[-N:])\n\nS_before = [sum(before)]\nS_after = [sum(after)]\n\nfor m in middle:\n if before[0] < m:\n S_before.append(S_before[-1] + m - before[0])\n insort(before, m)\n before = before[1:]\n else:\n S_before.append(S_before[-1])\n\nfor m in middle[::-1]:\n if after[-1] > m:\n S_after.append(S_after[-1] - m + after[-1])\n insort(after, m)\n after = after[:-1]\n else:\n S_after.append(S_after[-1]) \n\nprint(max([b-a for b, a in zip(S_before, S_after[::-1])])) \n', '# -*- coding: utf-8 -*-\ndef inpl(): return list(map(int, input().split()))\nfrom heapq import heapify, heapreplace \n\nN = int(input())\nA = inpl()\nL = A[:N]\nM = A[N:2*N]\nR = [-a for a in A[2*N:]]\nans = sum(L) + sum(R)\nheapify(L)\nheapify(R)\n\n\ni = 0\nj = N+1\n\nS = [0]*(N+1)\n\ns = 0\nfor i, m in enumerate(M):\n if m > L[0]:\n s += m - heapreplace(L, m)\n S[i+1] += s\n\ns = 0\nfor i, m in enumerate(M[::-1]):\n if m < -R[0]:\n s += -m - heapreplace(R, -m)\n S[-i-2] += s\n\nans += max(S)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s435237666', 's735291469'] | [39508.0, 37212.0] | [2105.0, 319.0] | [721, 505] |
p03716 | u784022244 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['import heapq\nN=int(input())\nA=list(map(int, input().split()))\n\nclass MaxHeap:\n def __init__(self, li):\n self.hp = []\n for e in li:\n heappush(self.hp, -e)\n\n def push(self, x):\n heappush(self.hp, -x)\n\n def pop(self):\n ret = heappop(self.hp)\n ret *= -1\n return ret\n\n def seak(self):\n return -self.hp[0]\n\n def sum(self):\n return -sum(self.hp)\n\nA1=A[:N]\nA2=A[N:2*N]\nA3=A[2*N:]\n\nheapq.heapify(A1)\nA1_sum=sum(A1)\nA1_li=[A1_sum]\nfor a in A2:\n p=heapq.heappushpop(A1,a)\n A1_sum+=a-p\n A1_li.append(A1_sum)\n \nA3=MaxHeap(A3)\nA3_sum=sum(A3)\nA3_li=[A3_sum]\nfor a in A3[::-1]:\n A3.push(a)\n A3_sum+=a\n p=A3.pop()\n A3_sum-=p\n A3_li.append(A3_sum)\n \nA3_li=A3_li[::-1] \nans=False\nfor a1, a3 in zip(A1_li, A3_li):\n if not ans:\n ans=a1-a3\n else:\n ans=max(ans, a1-a3)\nprint(ans)', 'from heapq import heapify, heappop, heappush\nN=int(input())\nA=list(map(int, input().split()))\n\nclass MaxHeap:\n def __init__(self, li):\n self.hp = []\n for e in li:\n heappush(self.hp, -e)\n\n def push(self, x):\n heappush(self.hp, -x)\n\n def pop(self):\n ret = heappop(self.hp)\n ret *= -1\n return ret\n\n def seak(self):\n return -self.hp[0]\n\n def sum(self):\n return -sum(self.hp)\n\nA1=A[:N]\nA2=A[N:2*N]\nA3=A[2*N:]\n\nheapify(A1)\nA1_sum=sum(A1)\nA1_li=[A1_sum]\nfor a in A2:\n heappush(A1, a)\n p=heappop(A1)\n A1_sum+=a-p\n A1_li.append(A1_sum)\n \nA3=MaxHeap(A3)\nA3_sum=sum(A3)\nA3_li=[A3_sum]\nfor a in A3[::-1]:\n A3.push(a)\n A3_sum+=a\n p=A3.pop()\n A3_sum-=p\n A3_li.append(A3_sum)\n \nA3_li=A3_li[::-1] \nans=False\nfor a1, a3 in zip(A1_li, A3_li):\n if not ans:\n ans=a1-a3\n else:\n ans=max(ans, a1-a3)\nprint(ans)', 'from heapq import heapify, heappop, heappush\nN=int(input())\nA=list(map(int, input().split()))\n\nclass MaxHeap:\n def __init__(self, li):\n self.hp = []\n for e in li:\n heappush(self.hp, -e)\n\n def push(self, x):\n heappush(self.hp, -x)\n\n def pop(self):\n ret = heappop(self.hp)\n ret *= -1\n return ret\n\n def seak(self):\n return -self.hp[0]\n\n def sum(self):\n return -sum(self.hp)\n\nA1=A[:N]\nA2=A[N:2*N]\nA3=A[2*N:]\n\nheapify(A1)\nA1_sum=sum(A1)\nA1_li=[A1_sum]\nfor a in A2:\n heappush(A1, a)\n p=heappop(A1)\n A1_sum+=a-p\n A1_li.append(A1_sum)\n \nA3=MaxHeap(A3)\nA3_sum=sum(A3)\nA3_li=[A3_sum]\nfor a in A3[::-1]:\n A3.heappush(a)\n A3_sum+=a\n p=A3.heappop()\n A3_sum-=p\n A3_li.append(A3_sum)\n \nA3_li=A3_li[::-1] \nans=False\nfor a1, a3 in zip(A1_li, A3_li):\n if not ans:\n ans=a1-a3\n else:\n ans=max(ans, a1-a3)\nprint(ans)', 'import heapq\nN=int(input())\nA=list(map(int, input().split()))\n\nA1=A[:N]\nA2=A[N:2*N]\nA3=A[2*N:3*N]\n\nheapq.heapify(A1)\nA1_sum=sum(A1)\nA1_li=[A1_sum]\nfor a in A2:\n p=heapq.heappushpop(A1,a)\n A1_sum+=a-p\n A1_li.append(A1_sum)\n \nheapq.heapify(A3)\nA3_sum=sum(A3)\nA3_li=[A3_sum]\nfor a in A3[::-1]:\n p=heapq.heappushpop(A3,a)\n A3_sum+=a-p\n A3_li.append(A3_sum)\n \nA3_li=A3_li[::-1] \nans=False\nfor a1, a3 in zip(A1_li, A3_li):\n if not ans:\n ans=a1-a3\n else:\n ans=max(ans, a1-a3)\nprint(ans)', 'from heapq import heapify, heappop, heappush\nN=int(input())\nA=list(map(int, input().split()))\n\nclass MaxHeap:\n def __init__(self, li):\n self.hp = []\n for e in li:\n heappush(self.hp, -e)\n\n def push(self, x):\n heappush(self.hp, -x)\n\n def pop(self):\n ret = heappop(self.hp)\n ret *= -1\n return ret\n\n def seak(self):\n return -self.hp[0]\n\n def sum(self):\n return -sum(self.hp)\n\nA1=A[:N]\nA2=A[N:2*N]\nA3=A[2*N:]\n\nheapify(A1)\nA1_sum=sum(A1)\nA1_li=[A1_sum]\nfor a in A2:\n heappush(A1, a)\n p=heappop(A1)\n A1_sum+=a-p\n A1_li.append(A1_sum)\n \nA3=MaxHeap(A3)\nA3_sum=sum(A3)\nA3_li=[A3_sum]\nfor a in A3[::-1]:\n A3.push(a)\n A3_sum+=a\n p=A3.pop()\n A3_sum-=p\n A3_li.append(A3_sum)\n \nA3_li=A3_li[::-1] \nans=False\nfor a1, a3 in zip(A1_li, A3_li):\n if not ans:\n ans=a1-a3\n else:\n ans=max(ans, a1-a3)\nprint(ans)', 'from heapq import heapify, heappop, heappush\nN=int(input())\nA=list(map(int, input().split()))\n\nclass MaxHeap:\n def __init__(self, li):\n self.hp = []\n for e in li:\n heappush(self.hp, -e)\n\n def push(self, x):\n heappush(self.hp, -x)\n\n def pop(self):\n ret = heappop(self.hp)\n ret *= -1\n return ret\n\n def seak(self):\n return -self.hp[0]\n\n def sum(self):\n return -sum(self.hp)\n\nA1=A[:N]\nA2=A[N:2*N]\nA3=A[2*N:]\n\nheapq.heapify(A1)\nA1_sum=sum(A1)\nA1_li=[A1_sum]\nfor a in A2:\n p=heapq.heappushpop(A1,a)\n A1_sum+=a-p\n A1_li.append(A1_sum)\n \nA3=MaxHeap(A3)\nA3_sum=sum(A3)\nA3_li=[A3_sum]\nfor a in A3[::-1]:\n A3.push(a)\n A3_sum+=a\n p=A3.pop()\n A3_sum-=p\n A3_li.append(A3_sum)\n \nA3_li=A3_li[::-1] \nans=False\nfor a1, a3 in zip(A1_li, A3_li):\n if not ans:\n ans=a1-a3\n else:\n ans=max(ans, a1-a3)\nprint(ans)', 'import heapq\nN=int(input())\nA=list(map(int, input().split()))\n\nA1=A[:N]\nA2=A[N:2*N]\nA3=A[2*N:3*N]\n\nheapq.heapify(A1)\nA1_sum=sum(A1)\nA1_li=[A1_sum]\nfor a in A2:\n p=heapq.heappushpop(A1,a)\n A1_sum+=a-p\n A1_li.append(A1_sum)\n \nheapq.heapify(A3)\nA3_sum=sum(A3)\nA3_li=[A3_sum]\nfor a in A3[::-1]:\n p=heapq.heappushpop(A3,a)\n A3_sum+=a-p\n A3_li.append(A3_sum)\n \nans=False\nfor a1, a3 in zip(A1_li, A3_li):\n if not ans:\n ans=a1-a3\n else:\n ans=max(ans, a1-a3)\nprint(ans)', 'from heapq import heapify, heappop, heappush\nN=int(input())\nA=list(map(int, input().split()))\n\nclass MaxHeap:\n def __init__(self, li):\n self.hp = []\n for e in li:\n heappush(self.hp, -e)\n\n def push(self, x):\n heappush(self.hp, -x)\n\n def pop(self):\n ret = heappop(self.hp)\n ret *= -1\n return ret\n\n def seak(self):\n return -self.hp[0]\n\n def sum(self):\n return -sum(self.hp)\n\nA1=A[:N]\nA2=A[N:2*N]\nA3=A[2*N:]\n\nheapify(A1)\nA1_sum=sum(A1)\nA1_li=[A1_sum]\nfor a in A2:\n heappush(A1, a)\n p=heappop(A1)\n A1_sum+=a-p\n A1_li.append(A1_sum)\n \nA3_sum=sum(A3)\nA3=MaxHeap(A3)\n\nA3_li=[A3_sum]\nfor a in A2[::-1]:\n A3.push(a)\n A3_sum+=a\n p=A3.pop()\n A3_sum-=p\n A3_li.append(A3_sum)\n \nA3_li=A3_li[::-1] \nans=False\nfor a1, a3 in zip(A1_li, A3_li):\n if not ans:\n ans=a1-a3\n else:\n ans=max(ans, a1-a3)\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s104531825', 's490809408', 's498627219', 's656642416', 's661389503', 's679904458', 's913212012', 's754759547'] | [37212.0, 37212.0, 37212.0, 38288.0, 37212.0, 37212.0, 40196.0, 37212.0] | [197.0, 238.0, 236.0, 311.0, 247.0, 99.0, 325.0, 438.0] | [857, 889, 897, 496, 889, 889, 476, 890] |
p03716 | u858136677 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['import heapq\nimport bisect\n\nn = int(input())\nn = n*3\na = list(map(int,input().split()))\n\nbig = a[0:n//3]\ntempmin = a[n//3::]\ntempmin.sort()\nsmall = tempmin[0:n//3]\nspare = tempmin[n//3::]\n\nans = sum(big)-sum(small)\nmxm = ans\n\nheapq.heapify(small)\nheapq.heapify(spare)\n\nfor i in range(n//3,2*n//3):\n if len(spare) != 0 and a[i] >= spare[0]:\n index = bisect.bisect_left(spare,a[i])\n spare.pop(index)\n\n if a[i] > big[0]:\n ans += a[i]-big[0]\n index = bisect.bisect_left(big,a[i])\n big.insert(index,a[i])\n big.pop(0)\n \n if a[i] < small[-1]:\n ans -= spare[0]-a[i]\n heapq.heappush(small,spare[0])\n heapq.heappop(spare)\n index = bisect.bisect_left(small,a[i])\n small.pop(index)\n \n if ans > mxm:\n mxm = ans\nprint(mxm)', 'import heapq\nimport bisect\n\nn = int(input())\nn = n*3\na = list(map(int,input().split()))\n\nleft = a[0:n//3]\nright = list(-i for i in a[2*n//3:])\n\nleftsum = [0 for i in range(n//3+1)]\nrightsum = [0 for i in range(n//3+1)]\n\nheapq.heapify(left)\nleftsum[0] = sum(left)\nfor i in range(n//3):\n k = i + n//3\n heapq.heappush(left,a[k])\n temp = heapq.heappop(left)\n leftsum[i+1] = leftsum[i]+a[k]-temp\n\nheapq.heapify(right)\nrightsum[-1] = -sum(right)\nfor i in range(n//3)[::-1]:\n k = i + n//3\n heapq.heappush(right,-a[k])\n temp = -heapq.heappop(right)\n rightsum[i] = rightsum[i+1] - temp + a[k]\n\n\n\n\nmxm = -sum(a)\nfor i in range(n//3+1):\n if leftsum[i]-rightsum[i] > mxm:\n mxm = leftsum[i]-rightsum[i]\nprint(mxm)'] | ['Runtime Error', 'Accepted'] | ['s443979243', 's872017013'] | [37212.0, 37212.0] | [2104.0, 478.0] | [810, 734] |
p03716 | u875291233 | 2,000 | 262,144 | Let N be a positive integer. There is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}). Snuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements. Here, the score of a' is defined as follows: (the sum of the elements in the first half of a') - (the sum of the elements in the second half of a'). Find the maximum possible score of a'. | ['# coding: utf-8\n# Your code here!\nn = int(input())\na = [int(i) for i in input().split()]\n\nfrom heapq import *\n\npq1 = a[:n]\nheapify(pq1)\ns = sum(pq1)\nscore1 = [s]\nfor i in range(n):\n c=heappushpop(pq1, a[n+i])\n s += a[n+i] - c\n score1.append(s)\n\npq2 = [-i for i in a[2*n:]]\nheapify(pq2)\ns = sum(pq2)\nscore2 = [s]\nfor i in range(1,n+1):\n c=heappushpop(pq2, -a[2*n-i])\n s += -a[2*n-i] - c\n score2.append(s)\n\nprint(score1)\nprint(score2)\nans = -10**17\nfor i,j in zip(score1,reversed(score2)):\n ans = max(ans, i+j)\n\nprint(ans)\n \n', '# coding: utf-8\n# Your code here!\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\n\nn,*a = map(int,read().split())\n\nfrom heapq import *\n\ndef get(q,a):\n v = sum(q)\n res = [v]\n for i in a[n:2*n]:\n x = heappushpop(q,i)\n v += i-x\n res.append(v)\n return res\n\nq = a[:n]\nheapify(q)\nres1 = get(q,a)\n\na = [-i for i in a[::-1]]\nq = a[:n]\nheapify(q)\nres2 = get(q,a)\n\n#print(res1)\n#print(res2)\n\nprint(max(i+j for i,j in zip(res1,res2[::-1])))\n\n\n\n\n\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s034415946', 's535044248'] | [38780.0, 42152.0] | [436.0, 233.0] | [547, 485] |
p03717 | u226155577 | 2,000 | 262,144 | There are N squares arranged in a row. The squares are numbered 1, 2, ..., N, from left to right. Snuke is painting each square in red, green or blue. According to his aesthetic sense, the following M conditions must all be satisfied. The i-th condition is: * There are exactly x_i different colors among squares l_i, l_i + 1, ..., r_i. In how many ways can the squares be painted to satisfy all the conditions? Find the count modulo 10^9+7. | ['\nN, M = map(int, input().split())\nr_min = [0]*(N+1); r_max = [N+1]*(N+1)\ng_min = [0]*(N+1); g_max = [N+1]*(N+1)\nfor i in range(M):\n l, r, x = map(int, input().split())\n\n \n if x == 1:\n \n \n g_max[r] = min(g_max[r], l-1)\n elif x == 2:\n \n \n g_min[r] = max(g_min[r], l)\n r_max[r] = min(r_max[r], l-1)\n elif x == 3:\n \n \n r_min[r] = max(r_min[r], l)\n\nMOD = 10**9 + 7\n\ndef check(r, g, k):\n return (r_min[k] <= r <= r_max[k] and g_min[k] <= g <= g_max[k])\n\n\n\nque = [{} for i in range(N+1)]\nque[0][0, 0] = 1\nfor k in range(N-1):\n cur = que[k]\n nxt = que[k+1]\n for key, val in cur.items():\n \n r, g = key\n\n \n if check(g, k, k+1):\n nxt[g, k] = (nxt.get((g, k), 0) + val) % MOD\n if check(r, k, k+1):\n nxt[r, k] = (nxt.get((r, k), 0) + val) % MOD\n if check(r, g, k+1):\n nxt[r, g] = (nxt.get((r, g), 0) + val) % MOD\nans = 0\nfor key, val in que[N-1].items():\n r, g = key\n if check(g, k, k+1):\n ans += val\n if check(r, k, k+1):\n ans += val\n if check(r, g, k+1):\n ans += val\n ans %= MOD\n\nprint(ans)', 'MOD = 10**9 + 7\nN, M = map(int, input().split())\nS = [[N+1]*(N+1) for i in [0,1,2]]\nT = [[0]*(N+1) for i in [0,1,2]]\n\nC = [0]*(N+1)\nfor i in range(M):\n l, r, x = map(int, input().split())\n if r-l < x-1:\n print(0)\n exit(0)\n S[x-1][r] = min(S[x-1][r], l)\n T[x-1][r] = max(T[x-1][r], l)\n C[r] = 1\n\nS0, S1, S2 = S\nT0, T1, T2 = T\n\nok = 1\nfor i in range(N+1):\n if not T2[i] < S1[i] or not T1[i] < S0[i]:\n ok = 0\n break\n\nif not ok:\n print(0)\n exit(0)\n\nRM = [N+1]*(N+1); GM = [N+1]*(N+1)\nfor i in range(N-1, -1, -1):\n RM[i] = min(RM[i+1], S1[i+1])\n GM[i] = min(GM[i+1], S0[i+1])\n\n\nX = {(0, 0): 3}\nD = [0]*(N+1); D[0] = 6\nB = [{} for i in range(N+1)]\nB[0][0] = 3\nbb = 0\nfor b in range(1, N):\n t2 = T2[b+1]; s1 = S1[b+1]; t1 = T1[b+1]; s0 = S0[b+1]\n\n rm = RM[b]\n gm = GM[b]\n if t1 <= b < gm:\n F = B[b]\n for z in range(t2, min(rm, b)):\n v = D[z] % MOD\n if v:\n F[z] = v; D[z] += v; D[b] += v\n if C[b+1]:\n for g in range(bb, min(t1, b)):\n for r, v in B[g].items():\n D[r] -= v; D[g] -= v\n B[g] = None\n bb = max(t1, bb)\n for g in range(bb, b):\n for r, v in B[g].items():\n if not t2 <= r < s1:\n D[r] -= v; D[g] -= v\n B[g] = {r: v for r, v in B[g].items() if t2 <= r < s1}\nans = 0\nfor b in range(bb, N+1):\n if B[b]:\n ans += sum(B[b].values())\nprint(ans % MOD)'] | ['Runtime Error', 'Accepted'] | ['s714208834', 's469337312'] | [122348.0, 6772.0] | [2111.0, 1258.0] | [1948, 1490] |
p03717 | u327466606 | 2,000 | 262,144 | There are N squares arranged in a row. The squares are numbered 1, 2, ..., N, from left to right. Snuke is painting each square in red, green or blue. According to his aesthetic sense, the following M conditions must all be satisfied. The i-th condition is: * There are exactly x_i different colors among squares l_i, l_i + 1, ..., r_i. In how many ways can the squares be painted to satisfy all the conditions? Find the count modulo 10^9+7. | ['from collections import defaultdict\n\nMOD = 1000000007\niist = lambda: map(int,input().split())\n\nN,M = iist()\nQ = defaultdict(list)\nfor i in range(M):\n l,r,x = iist()\n Q[r].append((l,x))\n\nif any(x != 1 for l,x in Q[1]):\n print(0)\n exit(0)\n\ndp = defaultdict(int)\ndp[0,0] = 3\n\nx_sum = [3]\ny_sum = [3]\ns = 3\n\nfor pk in range(1,N):\n k = pk+1\n\n dp.update(((i,pk),s%MOD) for i,s in enumerate(map(sum, zip(x_sum,y_sum))))\n\n for i in range(pk):\n x_sum[i] += dp[i,pk]\n x_sum.append(0)\n y_sum.append((2*s)%MOD)\n s *= 3\n\n removes = [(i,j) for i,j in dp.keys()\n if any(x != (l<=i)+(l<=j)+1 for l,x in Q[k])]\n\n for i,j in removes:\n c = dp[i,j]\n del dp[i,j]\n x_sum[i] -= c\n y_sum[j] -= c\n s -= c\n\n for i,j in range(pk):\n x_sum[i] %= MOD\n y_sum[i] %= MOD\n s %= MOD\n\nprint(s)', 'x_sum = [3]\ny_sum = [3]\ns = 3\n\nfor pk in range(1,N):\n k = pk+1\n\n for i,c in enumerate(map(sum,zip(x_sum,y_sum))):\n c %= MOD\n dp[i,pk] = c\n x_sum[i] += c\n\n x_sum.append(0)\n y_sum.append(2*s%MOD)\n s = 3*s%MOD\n subQ = Q[k]\n\n for i,j in list(dp.keys()):\n for l,x in subQ:\n if x != (l<=i)+(l<=j):\n c = dp[i,j]\n x_sum[i] -= c\n y_sum[j] -= c\n y_sum[j] %= MOD\n s -= c\n del dp[i,j]\n break\n\n for i in range(pk):\n x_sum[i] %= MOD\n s %= MOD\n\nprint(s)', 'from collections import defaultdict\n\nMOD = 1000000007\niist = lambda: map(int,input().split())\n\nN,M = iist()\nQ = defaultdict(list)\nfor i in range(M):\n l,r,x = iist()\n Q[r].append((l,x-1))\n\nif any(x != 0 for l,x in Q[1]):\n print(0)\n exit(0)\n\ndp = {(0,0):3}\nmemo = [6]\ns = 3\n\nfor pk in range(1,N):\n k = pk+1\n\n for i,c in enumerate(memo):\n c %= MOD\n dp[i,pk] = c\n memo[i] *= 2\n memo[i] %= MOD\n\n memo.append(2*s%MOD)\n s = 3*s%MOD\n subQ = Q[k]\n\n for i,j in list(dp.keys()):\n for l,x in subQ:\n if x != (l<=i)+(l<=j):\n c = dp[i,j]\n memo[i] -= c\n memo[j] -= c\n s -= c\n del dp[i,j]\n break\n\n s %= MOD\n\nprint(s)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s673699357', 's936462260', 's697682291'] | [3436.0, 3064.0, 12524.0] | [22.0, 17.0, 1487.0] | [806, 516, 672] |
p03723 | u020390084 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ["#!/usr/bin/env python3\nimport sys\n# input = sys.stdin.r/eadline\ndef INT(): return int(input())\ndef MAP(): return map(int,input().split())\ndef LI(): return list(map(int,input().split()))\n\ndef main():\n A,B,C = MAP()\n if not(A%2==0 and B%2==0 and C%2==0):\n print(0)\n return\n \n if A==B==C:\n print(-1)\n return\n answer = 0\n \n while A%2==0 and B%2==0 and C%2==0:\n x = A//2\n y = B//2\n z = C//2\n A = y+z\n B = x+y\n C = y+z\n answer += 1\n print(answer)\n\nif __name__ == '__main__':\n main()\n", "#!/usr/bin/env python3\nimport sys\n# input = sys.stdin.r/eadline\ndef INT(): return int(input())\ndef MAP(): return map(int,input().split())\ndef LI(): return list(map(int,input().split()))\n\ndef main():\n A,B,C = MAP()\n if not (A%2==0 and B%2==0 and C%2==0):\n print(0)\n return\n\n if A==B==C:\n print(-1)\n return\n answer = 0\n \n while A%2==0 and B%2==0 and C%2==0:\n x = A//2\n y = B//2\n z = C//2\n A = y+z\n B = x+y\n C = y+z\n answer += 1\n print(answer)\n\nif __name__ == '__main__':\n main()\n", "#!/usr/bin/env python3\nimport sys\n# input = sys.stdin.r/eadline\ndef INT(): return int(input())\ndef MAP(): return map(int,input().split())\ndef LI(): return list(map(int,input().split()))\n\ndef main():\n A,B,C = MAP()\n # if not (A%2==0 and B%2==0 and C%2==0):\n # print(0)\n # return\n\n if A==B==C:\n print(-1)\n return\n answer = 0\n \n while A%2==0 and B%2==0 and C%2==0:\n x = A//2\n y = B//2\n z = C//2\n A = y+z\n B = x+y\n C = y+z\n answer += 1\n print(answer)\n\nif __name__ == '__main__':\n main()\n", "#!/usr/bin/env python3\nimport sys\n# input = sys.stdin.r/eadline\ndef INT(): return int(input())\ndef MAP(): return map(int,input().split())\ndef LI(): return list(map(int,input().split()))\n\ndef main():\n A,B,C = MAP()\n if A==B==C:\n if A%2==1 or B%2==1 or C%2==1:\n print(0)\n else:\n print(-1)\n return\n answer = 0\n \n while A%2==0 and B%2==0 and C%2==0:\n x = A//2\n y = B//2\n z = C//2\n A = y+z\n B = x+z\n C = y+x\n answer += 1\n print(answer)\n\nif __name__ == '__main__':\n main()\n"] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted'] | ['s038013138', 's156826558', 's214277455', 's054932331'] | [3064.0, 3064.0, 3064.0, 3064.0] | [2104.0, 2104.0, 2104.0, 20.0] | [585, 578, 584, 580] |
p03723 | u022979415 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ["from functools import reduce\nfrom fractions import gcd\n\n\ndef main():\n cookies = list(map(int, input().split()))\n answer = -1\n if cookies[0] % 2 or cookies[1] % 2 or cookies[2] % 2:\n answer = 0\n elif len(set(cookies)) > 1:\n answer = reduce(gcd, cookies) - 1\n print(answer)\n\n\nif __name__ == '__main__':\n main()\n\n", "def main():\n cookies = list(map(int, input().split()))\n answer = 0\n if cookies[0] == cookies[1] == cookies[2] and cookies[0] % 2 == 0:\n answer = -1\n elif all(cookies[i] % 2 == 0 for i in range(3)):\n half = [0, 0, 0]\n sum_cookies = sum(cookies)\n while all(cookies[i] % 2 == 0 for i in range(3)):\n for i in range(3):\n half[i] = (sum_cookies - cookies[i]) // 2\n cookies[0] = half[1] + half[2]\n cookies[1] = half[0] + half[2]\n cookies[2] = half[1] + half[0]\n answer += 1\n print(answer)\n\n\nif __name__ == '__main__':\n main()\n\n"] | ['Wrong Answer', 'Accepted'] | ['s008013996', 's504584048'] | [5128.0, 3064.0] | [37.0, 18.0] | [342, 636] |
p03723 | u029929095 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['A,B,C=map(int,input().split())\ncount=0\n#if A==B and A==C:\nprint("-1")\nexit()\nwhile True:\n a,b,c=A/2,B/2,C/2\n A,B,C=b+c,a+c,a+b\n count+=1\n if A%2==1 or B%2==1 or C%2==1:\n break\nprint(count)', 'A,B,C=map(int,input().split())\ncount=0\nif A%2==0 and A==B and A==C:\n print("-1")\n exit()\nwhile True:\n if A%2==1 or B%2==1 or C%2==1:\n break\n a,b,c=A/2,B/2,C/2\n A,B,C=b+c,a+c,a+b\n count+=1\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s059097375', 's616980721'] | [3060.0, 3060.0] | [20.0, 17.0] | [195, 209] |
p03723 | u035907840 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['A, B, C = map(int, input().split())\nS = A+B+C\n\nk = 0\nwhile True:\n if A==B==C:\n k = -1\n break\n k += 1\n An = (B + C)//2\n Bn = (A + C)//2\n Cn = (B + A)//2\n A = An \n B = Bn \n C = Cn \n print(A,B,C)\n if A%2==1 or B%2==1 or C%2==1 or min([A,B,C])<1:\n break\n\nprint(k)', 'A, B, C = map(int, input().split())\nS = A+B+C\n\nk = 0\nflag = 0\nwhile k<100:\n if A%2==1 or B%2==1 or C%2==1 or min([A,B,C])<1:\n flag = 1\n break\n An = (B + C)//2\n Bn = (A + C)//2\n Cn = (B + A)//2\n A = An \n B = Bn \n C = Cn \n k += 1\n\nif not flag:\n k = -1\n\nprint(k)'] | ['Wrong Answer', 'Accepted'] | ['s191484795', 's625091782'] | [9124.0, 9132.0] | [29.0, 26.0] | [314, 308] |
p03723 | u038408819 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['abc = list(map(int, input().split()))\nans = 0\nfor i in range(10 ** 6): \n if abc[0] % 2 != 0:\n print(ans)\n break\n else:\n tmp1 = abc[1] // 2 + abc[2] // 2\n\n if abc[1] % 2 != 0:\n print(ans)\n break\n else:\n tmp2 = abc[0] // 2 + abc[2] // 2\n \n if abc[2] % 2 != 0:\n print(ans)\n break\n else:\n tmp3 = abc[0] // 2 + abc[2] // 2\n \n abc[0] = tmp1\n abc[1] = tmp2\n abc[2] = tmp3\n ans += 1\n\nprint(-1)', 'abc = list(map(int, input().split()))\nans = 0\nfor i in range(10 ** 6): \n if abc[0] % 2 != 0:\n print(ans)\n quit()\n break\n else:\n tmp1 = abc[1] // 2 + abc[2] // 2\n\n if abc[1] % 2 != 0:\n print(ans)\n quit()\n break\n else:\n tmp2 = abc[0] // 2 + abc[2] // 2\n \n if abc[2] % 2 != 0:\n print(ans)\n quit()\n break\n else:\n tmp3 = abc[0] // 2 + abc[2] // 2\n \n abc[0] = tmp1\n abc[1] = tmp2\n abc[2] = tmp3\n ans += 1\n\nprint(-1)'] | ['Wrong Answer', 'Accepted'] | ['s935838649', 's250480255'] | [3188.0, 3064.0] | [1202.0, 1200.0] | [494, 539] |
p03723 | u039860745 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['A,B,C = map(int, input().split())\na = [A]\nb = [B]\nc = [C]\ncount = 0\nfor i in range(10 ** 9):\n \n if a[i] == b[i] == c[i]:\n count = -1\n break\n elif a[i] % 2 == 1 or b[i] % 2 == 0 or c[i] % 2 == 1:\n break\n else:\n a.append(b[i] / 2 + c[i] / 2)\n b.append(a[i] / 2 + c[i] / 2)\n c.append(a[i] / 2 + b[i] / 2)\n count += 1\n\nprint(count)', 'A,B,C = map(int, input().split())\na = [A]\nb = [B]\nc = [C]\ncount = 0\nfor i in range(10 ** 9):\n \n if a[i] == b[i] == c[i]:\n count = -1\n break\n elif a[i] % 2 == 1 or b[i] % 1 == 0 or c[i] % 2 == 1:\n break\n else:\n a.append(b[i] / 2 + c[i] / 2)\n b.append(a[i] / 2 + c[i] / 2)\n c.append(a[i] / 2 + b[i] / 2)\n count += 1\n\nprint(count)', 'A,B,C = map(int, input().split())\na = [A]\nb = [B]\nc = [C]\ncount = 0\nsum = A + B + C\nfor i in range(10 ** 9):\n\n if a[i] == b[i] == c[i]:\n if a[i] % 2 == 0 and b[i] % 2 == 0 and c[i] % 2 == 0:\n count = -1\n break\n else:\n count = 0\n break\n elif a[i] % 2 == 0 and b[i] % 2 == 0 and c[i] % 2 == 0:\n a.append(b[i] / 2 + c[i] / 2)\n b.append(a[i] / 2 + c[i] / 2)\n c.append(a[i] / 2 + b[i] / 2)\n count += 1\n else:\n break\n\n\nprint(count)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s404788100', 's862618214', 's869912750'] | [9176.0, 9168.0, 9144.0] | [27.0, 26.0, 28.0] | [385, 385, 528] |
p03723 | u057415180 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['cookie = list(map(int, input().split()))\nsc = sum(cookie)\ncnt = -1\nif cookie[0] == cookie[1] and cookie[1] == cookie[2] and cookie[0]%2 == 0:\n print(-1)\n exit()\nmemo = [0]*3\nwhile cookie[0]%2 == 0 and cookie[1]%2 == 0 and cookie[2]%2 == 0:\n memo[0] = (cookie[1] + cookie[2]) // 2\n memo[1] = (cookie[0] + cookie[2]) // 2\n memo[2] = (cookie[1] + cookie[0]) // 2\n for i in range(3):\n cookie[i] = memo[i]\n cnt += 1\n\nprint(cnt)', 'cookie = list(map(int, input().split()))\nsc = sum(cookie)\ncnt = 0\nif cookie[0] == cookie[1] and cookie[1] == cookie[2] and cookie[0]%2 == 0:\n print(-1)\n exit()\nmemo = [0]*3\nwhile cookie[0]%2 == 0 and cookie[1]%2 == 0 and cookie[2]%2 == 0:\n memo[0] = (cookie[1] + cookie[2]) // 2\n memo[1] = (cookie[0] + cookie[2]) // 2\n memo[2] = (cookie[1] + cookie[0]) // 2\n for i in range(3):\n cookie[i] = memo[i]\n cnt += 1\n\nprint(cnt)'] | ['Wrong Answer', 'Accepted'] | ['s609209218', 's991348370'] | [3064.0, 3064.0] | [17.0, 17.0] | [450, 449] |
p03723 | u094999522 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ["*a, = map(int, input().split())\na = [bin(abs(a[i+1]-a[i]))[::-1].find('1') for i in range(2)].sort()\nprint(a[1] if a[0]*a[1]<0 else a[0])", "*a,=map(int,input().split())\nb=[bin(a[i+1]-a[i])[::-1].find('1')for i in (0,1)]\nprint((max(b)*(b[0]*b[1]<0) or min(b))*(1-sum(a)%2))"] | ['Runtime Error', 'Accepted'] | ['s424739905', 's769243217'] | [3060.0, 3060.0] | [18.0, 18.0] | [137, 132] |
p03723 | u098982053 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['A,B,C = map(int,input().split())\nif A == B and B == C and C == A:\n print(-1)\nelse:\n count = 0\n while(A%2==0 and B%2 == 0 and C%2==0):\n A_ = A\n B_ = B\n A = (B+C)/2\n B = (A_+C)/2\n C = (A_+B_)/2\n print(A,B,C)\n count+=1\n print(count)', 'A,B,C = map(int,input().split())\nif A == B and B == C and C == A:\n print(-1 if A%2==0 else 0 )\nelse:\n count = 0\n while(A%2==0 and B%2 == 0 and C%2==0):\n A_ = A\n B_ = B\n A = (B+C)/2\n B = (A_+C)/2\n C = (A_+B_)/2\n count+=1\n print(count)\n'] | ['Wrong Answer', 'Accepted'] | ['s057143460', 's506005028'] | [9092.0, 9176.0] | [32.0, 24.0] | [255, 257] |
p03723 | u102960641 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['a,b,c = map(int, input().split())\nd,e,f = abs(b-a),abs(c-b),abs(a-c)\nif d == e and e == f:\n print(-1)\nans = 0\nelse:\n while d % 2 == 0 and e % 2 == 0 f % 2 == 0:\n ans += 1\n d //= 2\n e //= 2\n f //= 2\n else:\n print(ans)', 'a,b,c = map(int, input().split())\nd,e,f = abs(b-a),abs(c-b),abs(a-c)\nans = 0\nif d == e and e == f:\n print(-1)\nelse:\n while d % 2 == 0 and e % 2 == 0 f % 2 == 0:\n ans += 1\n d //= 2\n e //= 2\n f //= 2\n print(ans)', 'a,b,c = map(int, input().split())\nd,e,f = abs(b-a),abs(c-b),abs(a-c)\nans = 0\nif a % 2 == 1 or b % 2 == 1 or c % 2 == 1:\n print(0)\nelse: \n if d == e and e == f:\n print(-1)\n else:\n while d % 2 == 0 and e % 2 == 0 and f % 2 == 0:\n ans += 1\n d //= 2\n e //= 2\n f //= 2\n print(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s329582828', 's707626020', 's599202651'] | [2940.0, 2940.0, 3064.0] | [18.0, 18.0, 18.0] | [234, 224, 307] |
p03723 | u103902792 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['a,b,c = map(int,input().split())\n\nif a%2 or b%2 or c%2:\n print(0)\n exit()\nelif a==b==c:\n print(-1)\n exit()\n \nans =0\nwhile 1:\n if all(a%2==0, b%2==0, c%2==0):\n ans += 1\n else:\n print(ans)\n exit()\n a, b, c = (b+c)//2, (a+c)//2, (b+a)//2', 'a,b,c = map(int,input().split())\n\nif a%2 or b%2 or c%2:\n print(0)\n exit()\nelif a==b==c:\n print(-1)\n exit()\n \nans =0\nwhile 1:\n if all((a%2==0, b%2==0, c%2==0)):\n ans += 1\n else:\n print(ans)\n exit()\n a, b, c = (b+c)//2, (a+c)//2, (b+a)//2\n\n'] | ['Runtime Error', 'Accepted'] | ['s579662809', 's748789177'] | [3064.0, 3064.0] | [17.0, 18.0] | [251, 255] |
p03723 | u106181248 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['a, b, c = map(int,input().split())\nans = 0\n\nif a == b == c and a%2 == 0:\n print(-1) \n exit()\n\nwhile x%2 == 0 and y%2 == 0 and z%2 == 0:\n ans += 1\n\n x = b//2 + c//2\n y = a//2 + c//2\n z = a//2 + b//2\n \n a = x\n b = y\n c = z\n\nprint(ans)\n', 'a, b, c = map(int,input().split())\nans = 0\n\nif a == b == c and a%2 == 0:\n print(-1) \n exit()\n\nwhile x%2 == 0 and y%2 == 0 and z%2 == 1:\n ans += 1\n \n x = b//2 + c//2\n y = a//2 + c//2\n z = a//2 + b//2\n \n a = x\n b = y\n c = z\n\nprint(ans)\n', 'a, b, c = map(int,input().split())\nans = 0\nif a == b == c:\n if a%2 == 0:\n print(-1) \n else:\n print(ans) \n\nwhile True:\n ans += 1\n x = b//2 + c//2\n y = a//2 + c//2\n z = a//2 + b//2\n if x%2 == 1 or y%2 == 1 or z%2 == 1:\n break\n\nprint(ans)\n', 'a, b, c = map(int,input().split())\nans = 0\n\nif a == b == c and a%2 == 0:\n print(-1) \n exit()\n\nwhile a%2 == 0 and b%2 == 0 and c%2 == 0:\n ans += 1\n\n x = b//2 + c//2\n y = a//2 + c//2\n z = a//2 + b//2\n \n a = x\n b = y\n c = z\n\nprint(ans)\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s067337224', 's115925710', 's587676960', 's296961549'] | [3060.0, 3060.0, 2940.0, 3060.0] | [17.0, 18.0, 2104.0, 17.0] | [270, 274, 305, 270] |
p03723 | u106342872 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['#! -*- coding:utf-8 -*-\na,b,c = map(int,input().split())\nprint(a,b,c)\n\ncount = 0\nflag = 0\nwhile True:\n at = (b+c)/2\n bt = (a+c)/2\n ct = (b+c)/2\n\n if flag == 1 and at == a and bt == b and ct == c:\n flag = 0\n break\n \n a = at\n b = bt\n c = ct\n \n count += 1\n flag = 1\n if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:\n break\n\nif flag == 0:\n print(-1)\nelse:\n print(count)\n', '#! -*- coding:utf-8 -*-\na,b,c = map(int,input().split())\n\ncount = 0\nflag = 0\nwhile True:\n at = (b+c)/2\n bt = (a+c)/2\n ct = (b+a)/2\n\n if flag == 0 and (a % 2 == 1 or b % 2 == 1 or c % 2 == 1):\n flag = 1\n break\n if flag == 1 and at == a and bt == b and ct == c:\n flag = 0\n break\n \n a = at\n b = bt\n c = ct\n #print(a,b,c)\n count += 1\n flag = 1\n if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:\n break\n\nif flag == 0:\n print(-1)\nelse:\n print(count)'] | ['Wrong Answer', 'Accepted'] | ['s439293640', 's446903621'] | [3064.0, 3064.0] | [17.0, 18.0] | [423, 516] |
p03723 | u113107956 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['a,b,c=map(int,input().split())\nif a==b==c:\n if a%2===b%2==c%2==0:\n print(-1)\n else:\n print(0)\n exit()\ncnt=0\nwhile a%2==b%2==c%2:\n A=a//2\n B=b//2\n C=c//2\n a,b,c=B+C,A+C,A+B\n cnt+=1\nprint(cnt)', 'a,b,c=map(int,input().split())\nif a==b==c:\n if a%2==b%2==c%2==0:\n print(-1)\n else:\n print(0)\n exit()\ncnt=0\nwhile a%2==b%2==c%2:\n A=a//2\n B=b//2\n C=c//2\n a,b,c=B+C,A+C,A+B\n cnt+=1\nprint(cnt)'] | ['Runtime Error', 'Accepted'] | ['s468472502', 's080399505'] | [8852.0, 9100.0] | [24.0, 27.0] | [228, 227] |
p03723 | u118642796 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['A,B,C = map(int,input().split())\nif A==B==C:\n print(-1)\nelse:\n ans = 0\n while True:\n if A%2 or B%2 or C%2:\n break\n else:\n A //=2\n B //=2\n C //=2\n print(ans)', 'A,B,C = map(int,input().split())\nif A==B==C:\n print(-1)\nelse:\n ans = 0\n while True:\n if A%2 or B%2 or C%2:\n break\n else:\n A,B,C = (B+C)//2,(A+C)//2,(A+B)//2\n print(ans)', 'A,B,C = map(int,input().split())\nif A==B==C:\n if A%2:\n print(0)\n else:\n print(-1)\nelse:\n ans = 0\n while True:\n if A%2 or B%2 or C%2:\n break\n else:\n A,B,C = (B+C)//2,(A+C)//2,(A+B)//2\n ans += 1\n print(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s269909298', 's764259198', 's835690370'] | [2940.0, 3060.0, 3064.0] | [17.0, 17.0, 17.0] | [186, 188, 236] |
p03723 | u126823513 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['a, b, c = map(int, input().split())\n\n\nif a % 2 == 0 or b % 2 == 0 or c % 2 == 0:\n print(0)\n exit(0)\nif a == b == c and a % 2 == 0:\n print(-1)\n exit(0)\n\ncounter = 0\nwhile True:\n counter += 1\n w_a = a / 2\n w_b = b / 2\n w_c = c / 2\n\n a = w_b + w_c\n b = w_a + w_c\n c = w_b + w_a\n\n if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:\n print(counter)\n exit(0)\n', 'a, b, c = map(int, input().split())\n\n\nif a % 2 != 0 or b % 2 != 0 or c % 2 != 0:\n print(0)\n exit(0)\nif a == b == c and a % 2 == 0:\n print(-1)\n exit(0)\n\ncounter = 0\nwhile True:\n counter += 1\n w_a = a / 2\n w_b = b / 2\n w_c = c / 2\n\n a = w_b + w_c\n b = w_a + w_c\n c = w_b + w_a\n\n if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:\n print(counter)\n exit(0)\n'] | ['Wrong Answer', 'Accepted'] | ['s211334028', 's167950020'] | [3064.0, 3064.0] | [19.0, 18.0] | [395, 395] |
p03723 | u136395536 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['A,B,C = (int(i) for i in input().split())\n\ntimes = 0\n\nif A%2==1 or B%2==1 or C%2==1:\n times = 0\nelse:\n while True:\n times += 1\n A = A / 2\n B = B / 2\n C = C / 2\n if A==B and C==A:\n times = -1\n break\n elif A<=1 or B<=1 or C<=1:\n break\n elif A%2==1 and B%2==1 and C%2==1:\n continue\n elif A%2==1 or B%2==1 or C%2==1:\n break\n \n \n\nprint(times)', 'A,B,C = (int(i) for i in input().split())\n\ntimes = 0\n\nif A%2==1 or B%2==1 or C%2==1:\n times = 0\nelse:\n while True:\n times += 1\n A = A / 2\n B = B / 2\n C = C / 2\n # print(A,B,C)\n if A==B and C==A:\n times = -1\n break\n elif A%2==1 and B%2==1 and C%2==1:\n continue\n elif A%2==1 or B%2==1 or C%2==1:\n break\n \n elif A%1!=0 or B%1!=0 or C%1!=0:\n break\n elif A<=1 or B<=1 or C<=1:\n break\n \n\nprint(times)'] | ['Wrong Answer', 'Accepted'] | ['s794641748', 's286664652'] | [3064.0, 3064.0] | [17.0, 17.0] | [469, 629] |
p03723 | u152614052 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['a,b,c = map(int,input().split())\ncnt=0\nfor i in range(100):\n if a==b==c and a%2==0:\n cnt = -1\n break\n elif a%2==0 and b%2==0 and c%2==10:\n t_a = b//2 + c//2\n t_b = a//2 + c//2\n t_c = a//2 + b//2\n a,b,c = t_a,t_b,t_c\n cnt+=1\n else:\n break\nprint(cnt)', 'a,b,c = map(int,input().split())\ncnt=0\nif a==b==c and a%2==0:\n cnt = -1\n break\nelif:\n for i in range(100):\n if a%2==0 and b%2==0 and c%2==10:\n t_a = b//2 + c//2\n t_b = a//2 + c//2\n t_c = a//2 + b//2\n a,b,c = t_a,t_b,t_c\n cnt+=1\n else:\n break\nprint(cnt)', 'a,b,c = map(int,input().split())\ncnt=0\nif a==b==c and a%2==0:\n cnt = -1\nelse:\n for i in range(100):\n if a%2==0 and b%2==0 and c%2==0:\n t_a = b//2 + c//2\n t_b = a//2 + c//2\n t_c = a//2 + b//2\n a,b,c = t_a,t_b,t_c\n cnt+=1\n else:\n break\nprint(cnt)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s289324515', 's873495027', 's362718347'] | [3064.0, 2940.0, 3064.0] | [18.0, 18.0, 18.0] | [313, 341, 330] |
p03723 | u173025122 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['import random as rng\nimport itertools as it\nimport collections as col\nimport heapq as hq\nimport sys\nimport copy as cp\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef dump_impl(*objects):\n print(*objects, file=sys.stderr)\n\n\ndef dump_dummy(*objects):\n pass\n\n\ndump = dump_impl if "DEBUG" in sys.argv else dump_dummy\n\n\ndef odd(n): return n & 1\n\n\ndef even(n): return not odd(n)\n\nS = input()\ndump(S)\nprint(S)\n\n', 'import random as rng\nimport itertools as it\nimport collections as col\nimport heapq as hq\nimport sys\nimport copy as cp\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef dump_impl(*objects):\n print(*objects, file=sys.stderr)\n\n\ndef dump_dummy(*objects):\n pass\n\n\ndump = dump_impl if "DEBUG" in sys.argv else dump_dummy\n\n\ndef odd(n): return n & 1\n\n\ndef even(n): return not odd(n)\n\nS = input()\ndump(S)\nprint(S)\n\n', 'import random as rng\nimport itertools as it\nimport collections as col\nimport heapq as hq\nimport sys\nimport copy as cp\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef dump_impl(*objects):\n print(*objects, file=sys.stderr)\n\n\ndef dump_dummy(*objects):\n pass\n\n\ndump = dump_impl if "DEBUG" in sys.argv else dump_dummy\n\n\ndef odd(n): return n & 1\n\n\ndef even(n): return not odd(n)\n\nS = input()\ndump(S)\nprint(S)\n\n', 'import random as rng\nimport itertools as it\nimport collections as col\nimport heapq as hq\nimport sys\nimport copy as cp\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef dump_impl(*objects):\n print(*objects, file=sys.stderr)\n\n\ndef dump_dummy(*objects):\n pass\n\n\ndump = dump_impl if "DEBUG" in sys.argv else dump_dummy\n\n\ndef odd(n): return n & 1\n\n\ndef even(n): return not odd(n)\n\n\nA, B, C = map(int, input().split())\nans = 0\na, b, c = A, B, C\nwhile True:\n dump(a, b, c)\n if odd(a) or odd(b) or odd(c):\n print(ans)\n exit()\n if ans > 0 and a == A and b == B and c == C:\n print(-1)\n exit()\n a, b, c = (b+c)//2, (a+c)//2, (a+b)//2\n ans += 1\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s258106348', 's503093847', 's723175044', 's264336268'] | [9816.0, 9948.0, 9840.0, 9740.0] | [34.0, 33.0, 36.0, 33.0] | [424, 424, 424, 694] |
p03723 | u178465329 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ["\na, b, c = list(map(int, input().split(' ')))\ncnt = 0\nif a == b == c:\n cnt = -1 \nelse:\n while (a+1)%2 or (b+1)%2 or (c+1)%2:\n cnt += 1\n a,b,c=(b+c)/2,(a+c)/2,(a+b)/2\n\nprint(cnt)\n", "\na, b, c = list(map(int, input().split(' ')))\ncnt = 0\nif a == b == c:\n cnt = a%2-1\nelse:\n while not (a%2 or b%2 or c%2):\n cnt += 1\n a,b,c=(b+c)/2,(a+c)/2,(a+b)/2\n\nprint(cnt)\n"] | ['Wrong Answer', 'Accepted'] | ['s640773094', 's824150858'] | [2940.0, 2940.0] | [2103.0, 17.0] | [199, 194] |
p03723 | u188244611 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ["def compute():\n a, b, c = [int(el) for el in input().split(' ')]\n record = set()\n record.add(frozenset([a,b,c]))\n count = 0\n while (b + c) % 2 == (a + c) % 2 == (a + b) % 2 == 0:\n a, b, c = (b+c)//2, (a+c)//2, (a+b)//2\n print(a, b, c)\n if {a, b, c} in record:\n print('-1')\n return\n else:\n count += 1\n record.add(frozenset([a, b, c]))\n print(count)\n return\n\ncompute()\n", "def compute():\n a, b, c = [int(el) for el in input().split(' ')]\n count = 0\n while a % 2 == b % 2 == c % 2 == 0:\n a, b, c = (b+c)//2, (a+c)//2, (a+b)//2\n count += 1\n if a == b == c:\n print(-1)\n return\n print(count)\n return\n\ncompute()\n"] | ['Wrong Answer', 'Accepted'] | ['s095205827', 's593415662'] | [3064.0, 3060.0] | [17.0, 17.0] | [460, 292] |
p03723 | u196697332 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['import numpy as np\nimport sys\n\nthree_cookies = list(map(int, input().split()))\n\nthree_div = [i % 2 for i in three_cookies]\nif all(three_div):\n print(0)\n sys.exit()\n\na_b_c = np.array(three_cookies)\nlis = np.array([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]])\ni = 0\n\nwhile True:\n i += 1\n a_b_c = np.dot(lis, a_b_c)\n print(a_b_c)\n for j, item in enumerate(a_b_c):\n if three_cookies == a_b_c.tolist():\n print(-1)\n sys.exit()\n if item % 2 == 1:\n print(i)\n sys.exit()', 'import numpy as np\nimport sys\n\nthree_cookies = list(map(int, input().split()))\n\nthree_div = [i % 2 for i in three_cookies]\nif all(three_div) or any(three_div):\n print(0)\n sys.exit()\n\na_b_c = np.array(three_cookies)\nlis = np.array([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]])\ni = 0\n\nwhile True:\n i += 1\n a_b_c = np.dot(lis, a_b_c)\n #print(a_b_c)\n for j, item in enumerate(a_b_c):\n if three_cookies == a_b_c.tolist():\n print(-1)\n sys.exit()\n if item % 2 == 1:\n print(i)\n sys.exit()'] | ['Wrong Answer', 'Accepted'] | ['s446945708', 's865387525'] | [12796.0, 12424.0] | [159.0, 150.0] | [538, 557] |
p03723 | u201928947 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['from time import time\nt = time()\ncount = 0\na = int(input())\nb = int(input())\nc = int(input())\nwhile True:\n if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:\n print(count)\n exit()\n count += 1\n a1 = b//2+c//2\n b1 = c//2+a//2\n c1 = a//2+b//2\n a = a1\n b = b1\n c = c1\n if time()-t >= 1.8:\n print(-1)\n exit()', 'from time import time\nt = time()\ncount = 0\na,b,c = map(int,input().split())\nwhile True:\n if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:\n print(count)\n exit()\n count += 1\n a1 = b//2+c//2\n b1 = c//2+a//2\n c1 = a//2+b//2\n a = a1\n b = b1\n c = c1\n if time()-t >= 1.8:\n print(-1)\n exit()'] | ['Runtime Error', 'Accepted'] | ['s879118307', 's560575433'] | [3064.0, 3064.0] | [17.0, 1818.0] | [350, 332] |
p03723 | u208120643 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['"""Boot-camp-for-Beginners_Easy013_A_Candy-Distribution-Again_30-August-2020.py"""\n\nA, B, C = map(int, input().split())\na, b, c = A, B, C\ni = 0\nwhile True:\n if (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):\n if(A == a or B == b or C == c):\n print(-1)\n break\n i += 1\n a, b, c = A, B, C\n A = (b+c)/2\n B = (c+a)/2\n C = (a+b)/2\n else:\n if(A == a or B == b or C == c):\n print(-1)\n break\n print(i)\n break\n', '"""Boot-camp-for-Beginners_Easy013_A_Candy-Distribution-Again_30-August-2020.py"""\n\nA, B, C = map(int, input().split())\na, b, c = A, B, C\ni = 0\nwhile True:\n if (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):\n i += 1\n a, b, c = A, B, C\n A = (b+c)/2\n B = (c+a)/2\n C = (a+b)/2\n print(A,B,C)\n if(A == a or B == b or C == c):\n print(-1)\n break\n else:\n if(A == a or B == b or C == c):\n print(-1)\n break\n print(i)\n break\n', '"""Boot-camp-for-Beginners_Easy013_A_Candy-Distribution-Again_30-August-2020.py"""\n\nA, B, C = map(int, input().split())\na, b, c = A, B, C\ni = 0\nwhile True:\n if (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):\n i += 1\n a, b, c = A, B, C\n A = (b+c)/2\n B = (c+a)/2\n C = (a+b)/2\n# print(A,B,C)\n if(A == a or B == b or C == c):\n print(-1)\n break\n else:\n if(A == a or B == b or C == c):\n print(-1)\n break\n print(i)\n break\n', '"""Boot-camp-for-Beginners_Easy013_A_Candy-Distribution-Again_30-August-2020.py"""\n\nA, B, C = map(int, input().split())\na, b, c = A, B, C\ni = 0\nwhile True:\n if (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):\n i += 1\n a, b, c = A, B, C\n A = (b+c)/2\n B = (c+a)/2\n C = (a+b)/2\n print(A,B,C)\n if(A == a and B == b and C == c):\n print(-1)\n break\n else:\n print(i)\n break\n if(A == a and B == b and C == c):\n print(-1)\n break\n', '"""Boot-camp-for-Beginners_Easy013_A_Candy-Distribution-Again_30-August-2020.py"""\n\nA, B, C = map(int, input().split())\na, b, c = A, B, C\ni = 0\nwhile True:\n if (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):\n i += 1\n a, b, c = A, B, C\n A = (b+c)/2\n B = (c+a)/2\n C = (a+b)/2\n #print(A,B,C)\n if(A == a and B == b and C == c):\n print(-1)\n break\n else:\n print(i)\n break\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s255516734', 's420219061', 's449077224', 's528216539', 's627167696'] | [9084.0, 9032.0, 9180.0, 9192.0, 9168.0] | [25.0, 25.0, 34.0, 27.0, 25.0] | [509, 530, 531, 534, 453] |
p03723 | u211236379 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['if A==B==C:\n print(-1)\nelse:\n for i in range(100000000):\n if A %2==0 and B%2==0 and C%2==0:\n a = A/2\n b = B/2\n c = C/2\n A = b+c\n B = a+c\n C = a+b\n else:\n print(i)\n exit()', 'A, B, C = map(int, input().split())\n\nif A==B==C:\n if A%2==0:\n print(-1)\n else:\n print(0)\n\nelse:\n for i in range(1000000000):\n if A %2==0 and B%2==0 and C%2==0:\n a = A/2\n b = B/2\n c = C/2\n A = b+c\n B = a+c\n C = a+b\n else:\n print(i)\n exit()\n\n'] | ['Runtime Error', 'Accepted'] | ['s923412157', 's473866878'] | [3060.0, 3060.0] | [18.0, 17.0] | [278, 365] |
p03723 | u211805975 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ["#13\na,b,c = map(int,input().split())\ncnt = 0\nwhile a%2 == b%2 == c%2 == 0:\n if a==b==c:\n print('-1')\n break\n else:\n a,b,c = b//2+c//2,c//2+a//2,a//2+b//2\n cnt+=1\n print(a,b,c)\n\nprint(cnt)", "#13\na,b,c = map(int,input().split())\ncnt = 0\nif a%2 == 1 or b%2 == 1 or c%2 == 1:\n print('0')\n\nelif a==b==c and a%2==0:\n print('-1')\n \nelif not a==b==c:\n while a%2 == b%2 == c%2 == 0:\n a,b,c = b//2+c//2,c//2+a//2,a//2+b//2\n cnt+=1\n print(cnt)"] | ['Wrong Answer', 'Accepted'] | ['s012893148', 's397187024'] | [3060.0, 3064.0] | [17.0, 18.0] | [228, 279] |
p03723 | u215341636 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['a , b , c = map(int, input().split())\ncount = 0\nif a == 1 and b == 1 and c == 1:\n break\nelif a == b and a == c:\n count = -1\nelse:\n while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:\n a_copy = a\n b_copy = b\n c_copy = c\n a = int(b_copy / 2 + c_copy / 2)\n b = int(a_copy / 2 + c_copy / 2)\n c = int(b_copy / 2 + a_copy / 2)\n count += 1\n \nprint(count)', 'a , b , c = map(int, input().split())\ncount = 0\nif a == 1 and b == 1 and c == 1:\n pass\nelif a == b and a == c:\n count = -1\nelse:\n while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:\n a_copy = a\n b_copy = b\n c_copy = c\n a = int(b_copy / 2 + c_copy / 2)\n b = int(a_copy / 2 + c_copy / 2)\n c = int(b_copy / 2 + a_copy / 2)\n count += 1\n \nprint(count)'] | ['Runtime Error', 'Accepted'] | ['s112424583', 's327390480'] | [3064.0, 3064.0] | [17.0, 17.0] | [368, 367] |
p03723 | u223646582 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['A=sorted(list(map(int,input().split())))\n\nif A[2]==A[0]:\n print(-1)\nelse:\n c=A[2]-A[0]\n while c%2==1:\n c+=1\n c=c//2\n print(c)\n\n\n', 'A=sorted(list(map(int,input().split())))\n\nif A[2]==A[0]:\n print(-1)\nelse:\n c=A[2]-A[0]\n while c%2==0:\n c+=1\n c=c//2\n print(c)\n\n\n\n\n', 'A=sorted(list(map(int,input().split())))\n\nif A[2]==A[0] and A[0]%2==0:\n print(-1)\nelse:\n ans=0\n a=A[0]\n b=A[1]\n c=A[2]\n while a%2==0 and b%2==0 and c%2==0:\n ans+=1\n a,b,c=(b+c)//2,(a+c)//2,(a+b)//2\n print(ans)\n\n\n\n\n\n\n\n\n\n\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s031449777', 's737406833', 's683239523'] | [2940.0, 2940.0, 3060.0] | [17.0, 17.0, 18.0] | [154, 156, 255] |
p03723 | u223904637 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['a,b,c=map(int,input().split())\nif a==b and b==c and a%2=0:\n print(-1)\nelse:\n ans=0\n while a%2==0 ans b%2==0 and c%2==0:\n tmp=a\n tmp2=b\n a=(b+c)//2\n b=(c+tmp)//2\n c=(tmp+tmp2)//2\n ans+=1\n print(ans)', 'a,b,c=map(int,input().split())\nif a==b and b==c and a%2==0:\n print(-1)\nelse:\n ans=0\n while a%2==0 and b%2==0 and c%2==0:\n tmp=a\n tmp2=b\n a=(b+c)//2\n b=(c+tmp)//2\n c=(tmp+tmp2)//2\n ans+=1\n print(ans)'] | ['Runtime Error', 'Accepted'] | ['s833722238', 's704333740'] | [2940.0, 3064.0] | [17.0, 17.0] | [251, 252] |
p03723 | u227085629 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['a,b,c = map(int,input().split())\nif a == b == c:\n if a%2 == b%2 == c%2 == 0:\n print(-1)\n else:\n print(0)\nt = 0\nelse:\n while t > -1:\n if a%2 == 1 or b%2 == 1 or c%2 == 1:\n break\n (a,b,c) = ((b+c)//2,(a+c)//2,(a+b)//2)\n t += 1\n print(t)', 'a,b,c = map(int,input().split())\nif a == b == c:\n if a%2 == b%2 == c%2 == 0:\n print(-1)\n else:\n print(0)\nelse:\n t = 0\n while t > -1:\n if a%2 == 1 or b%2 == 1 or c%2 == 1:\n break\n (a,b,c) = ((b+c)//2,(a+c)//2,(a+b)//2)\n t += 1\n print(t)\n'] | ['Runtime Error', 'Accepted'] | ['s400956895', 's110029082'] | [2940.0, 3060.0] | [17.0, 17.0] | [258, 261] |
p03723 | u228232845 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ["import sys\n\n\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\n\n\na, b, c = LI()\nif a == b == c:\n print(-1)\nelse:\n ans = 0\n while True:\n if a % 2 or b % 2 or c % 2:\n break\n a, b, c = b // 2 + c // 2, a // 2 + c // 2, a // 2 + b // 2\n ans += 1\n print(ans)\n", "import sys\n\n\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\n\n\na, b, c = LI()\nif a == b == c:\n if a % 2:\n print(0)\n else:\n print(-1)\nelse:\n ans = 0\n while True:\n if a % 2 or b % 2 or c % 2:\n break\n a, b, c = b // 2 + c // 2, a // 2 + c // 2, a // 2 + b // 2\n ans += 1\n print(ans)\n"] | ['Wrong Answer', 'Accepted'] | ['s046383664', 's617397510'] | [3064.0, 3064.0] | [17.0, 17.0] | [806, 847] |
p03723 | u234189749 | 2,000 | 262,144 | Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person with odd number of cookies in hand. How many times will they repeat this action? Note that the answer may not be finite. | ['A,B,C = map(int,input().split())\n\nans = 0\n\nwhile (A%2 == 0) & (B%2 == 0) & (C%2 == 0):\n if (A==B) & (B==C) :\n ans = -1\n break\n\n a = (B+C)/2\n b = (A+C)/2\n c = (A+B)/2\n A = a\n B = b\n C = c\n ans += 1\n\nprint(ans)', 'A,B,C = map(int,input().split())\n\nans = 0\n\nwhile (A%2 == 0) & (B%2 == 0) & (C%2 == 0):\n if (A==B) & (B==C) :\n ans = -1\n break\n\n a = (B+C)/2\n b = (A+C)/2\n c = (A+B)/2\n A = a\n B = b\n C = c\n ans += 1\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s384322936', 's767289035'] | [2940.0, 3064.0] | [18.0, 17.0] | [250, 246] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.