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
|
---|---|---|---|---|---|---|---|---|---|---|
p03363 | u374103100 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['\n\nimport math\n\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\ndef convert_map(l):\n d = {}\n for i in l:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n return d\n\n\nN = list(map(int, input()))[0]\n\nli = list(map(int, input().split()))\n\ncounter = [0]\nfor i in li:\n counter.append(counter[-1] + i)\n\nprint(counter)\n\nd = convert_map(counter)\n\nprint(d)\n\npatterns = 0\nfor key, value in d.items():\n if value >= 2:\n patterns += combinations_count(value, 2)\n\nprint(patterns)\n', '\n\nimport math\n\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\ndef convert_map(l):\n d = {}\n for i in l:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n return d\n\n\nN = list(map(int, input()))[0]\n\nli = list(map(int, input().split()))\n\ncounter = [0]\nfor i in li:\n counter.append(counter[-1] + i)\n\n# print(counter)\n\nd = convert_map(counter)\n\n# print(d)\n\npatterns = 0\nfor key, value in d.items():\n if value >= 2:\n patterns += combinations_count(value, 2)\n\nprint(patterns)\n'] | ['Wrong Answer', 'Accepted'] | ['s753929484', 's216834859'] | [48848.0, 41472.0] | [1531.0, 1516.0] | [625, 629] |
p03363 | u375695365 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['import collections\nn = int(input())\na = list(map(int, input().split()))\nb = [a[0]]\nfor i in range(1, n):\n b.append(b[i-1]+a[i])\nprint(b)\nans = b.count(0)\nd = collections.Counter(b)\nfor i in d.values():\n ans += i*(i-1)//2 \n\nprint(ans)\n', 'import collections\nn = int(input())\na = list(map(int, input().split()))\nb = [a[0]]\nfor i in range(1, n):\n b.append(b[i-1]+a[i])\nans = b.count(0)\nd = collections.Counter(b)\nfor i in d.values():\n ans += i*(i-1)//2 \n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s339472974', 's296175722'] | [46960.0, 44284.0] | [191.0, 172.0] | [260, 253] |
p03363 | u379959788 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['# AGC023\nimport collections\nfrom scipy.misc import comb\nN = int(input())\nA = list(map(int, input().split()))\nans = 0\nS = [0] * (N+1)\nfor i in range(N):\n S[i+1] = S[i] + A[i]\nc = collections.Counter(S)\nc = c.most_common()\nfor i in range(len(c)):\n if c[i][1] == 1:\n pass\n if c[i][1] == 2:\n ans += 1\n else:\n ans += comb(c[i][1], 2)\nprint(int(ans))', '# AGC023\nimport collections\nfrom scipy.misc import comb\nN = int(input())\nA = list(map(int, input().split()))\nans = 0\nS = [0] * (N+1)\nfor i in range(N):\n S[i+1] = S[i] + A[i]\nc = collections.Counter(S)\nfor i in range(len(c)):\n if c[i] == 1:\n break\n ans += comb(c[i], 2)\nprint(int(ans))', '# AGC023\nimport collections\nN = int(input())\nA = list(map(int, input().split()))\nans = 0\nS = [0] * (N+1)\nfor i in range(N):\n S[i+1] = S[i] + A[i]\nc = collections.Counter(S)\nc = c.most_common()\nfor i in range(len(c)):\n tmp = c[i][1]\n if tmp == 1:\n pass\n else:\n ans += tmp*(tmp-1) // 2\nprint(int(ans))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s614923597', 's717016010', 's229487507'] | [58460.0, 51428.0, 48708.0] | [2111.0, 379.0, 261.0] | [377, 300, 325] |
p03363 | u384679440 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['N = int(input())\nA = list(map(int, input().split()))\nS = [0]\nans = 0\nfor i in range(len(A)):\n S.append(S[i] + A[i])\nS.sort()\ncount = 1\nfor i in range(1, len(S)):\n if S[i-1] == S[i]:\n count += 1\n else:\n ans += count * (count-1) / 2\n count = 1\nans += count * (count-1) / 2\nprint(ans)', 'N = int(input())\nA = list(map(int, input()))\nS = [0]\nans = 0\nfor i in range(len(A)):\n S.append(S[i] + A[i])\nS.sort()\ncount = 1\nfor i in range(1, len(S)):\n if S[i-1] == S[i]:\n count += 1\n else:\n ans += count * (count-1) / 2\n count = 1\nans += count * (count-1) / 2\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\nS = [0]\nans = 0\nfor i in range(len(A)):\n S.append(S[i] + A[i])\nS.sort()\ncount = 1\nfor i in range(1, len(S)):\n if S[i-1] == S[i]:\n count += 1\n else:\n ans += count * (count-1) / 2\n count = 1\nans += count * (count-1) / 2\nprint(int(ans))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s613360386', 's746605978', 's335179437'] | [25976.0, 8784.0, 26004.0] | [237.0, 21.0, 250.0] | [293, 285, 298] |
p03363 | u391533749 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['N = int(input())\nA = list(map(int, input().split()))\nB = [0]\nt = 0\nfor i in range(N):\n B.append(B[i] + A[i])\n \nC = set(B)\nfor j in C:\n z = B.count(j)\n if count > 1:\n t += z*(z-1)/2\n \nprint(int(t))', 'N = int(input())\nA = list(map(int, input().split()))\nB = {}\nt = 0\nx = 0\nB[0] = 1\nfor i in A:\n x += i\n t += B.get(x, 0)\n B[x] = B.get(x, 0) + 1\n\nprint(t)'] | ['Runtime Error', 'Accepted'] | ['s648190524', 's950082280'] | [32748.0, 39704.0] | [149.0, 195.0] | [212, 161] |
p03363 | u394721319 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from itertools import accumulate\nimport collections\n\nN = int(input())\nA = [int(i) for i in input().split()]\n\nB = [0] + A\nB = list(accumulate(B))\n\nc = collections.Counter(B)\ncm = c.most_common()\n\ncnt = 0\nfor v in cm:\n if v[1] > 1:\n cnt += (v[1]*(v[1]-1)//2)\n', 'from itertools import accumulate\nfrom collections import Counter\n\nN = int(input())\nA = [int(i) for i in input().split()]\n\nB = [0] + list(accumulate(A))\nC = Counter(B)\n\nans = 0\nfor i in set(B):\n p = C[i]\n ans += p*(p-1)//2\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s252615806', 's128826673'] | [48136.0, 53096.0] | [225.0, 219.0] | [267, 240] |
p03363 | u404676457 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['import itertools as itr\nn = int(input())\na = list(map(int, input().split()))\nitra = list(itr.accumulate(a))\nans_c = itra.count(0)\nseta = list(set(itra))\nprint(seta)\nfor i in seta:\n tmp_c = itra.count(i)\n ans_c += tmp_c * (tmp_c - 1) // 2\nprint(ans_c)', 'import itertools as itr\nimport collections as col\nimport numpy as np \nn = int(input())\na = list(map(int, input().split()))\nans_c = np.array(list(col.Counter([0] + list(itr.accumulate(a))).values())).astype("int64")\nprint(np.sum(ans_c * (ans_c - 1) // 2))'] | ['Wrong Answer', 'Accepted'] | ['s246622241', 's483175902'] | [32784.0, 50536.0] | [2105.0, 276.0] | [256, 254] |
p03363 | u405256066 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['import numpy as np\nfrom sys import stdin\nN=int(stdin.readline().rstrip())\na=[]\nfor i in range(N):\n a.append([int(x) for x in stdin.readline().rstrip().split()])\n\nres = np.cumsum(data)\nres=np.insert(res,0,0)\nans=0\ntmp=float("inf")\nfor i in sorted(res):\n if i == tmp:\n ans+=1\n tmp=i\nprint(ans)', 'import numpy as np\nfrom sys import stdin\nN=int(stdin.readline().rstrip())\ndata=[int(x) for x in stdin.readline().rstrip().split()]\nres = np.cumsum(data)\nres=np.insert(res,0,0)\ncnt=1\nans=0\ntmp=float("inf")\nite=np.append(sorted(res),float("inf"))\nfor j in ite:\n if j == tmp:\n cnt+=1\n else:\n ans=ans+((cnt*(cnt-1))/2)\n cnt=1\n tmp=j\nprint(int(ans))'] | ['Runtime Error', 'Accepted'] | ['s309307608', 's553573116'] | [34672.0, 34560.0] | [1209.0, 411.0] | [307, 374] |
p03363 | u406138190 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from collections import Counter\nn=int(input())\na=list(map(int,input().split()))\nans=0\naccum = [0]*(n+1)\naccum[0]=0\nfor i in range(n):\n accum[i+1]=a[i]+accum[i]\n\nz=Counter(accum)\nfor k,v in z:\n ans+=n(n-1)/2\n \nprint(ans)\n', 'from collections import Counter\nn=int(input())\na=list(map(int,input().split()))\nans=0\naccum = [0]*(n+1)\naccum[0]=0\nfor i in range(n):\n accum[i+1]=a[i]+accum[i]\n\nz=Counter(accum)\nfor k,v in z.items():\n ans+=v*(v-1)/2\n \nprint(ans)', 'from collections import Counter\nn=int(input())\na=list(map(int,input().split()))\nans=0\naccum = [0]*(n+1)\naccum[0]=0\nfor i in range(n):\n accum[i+1]=a[i]+accum[i]\n\nz=Counter(accum)\nfor k,v in z.items():\n ans+=v*(v-1)/2\n \nprint(int(ans))\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s626751524', 's935979920', 's625633097'] | [41752.0, 41672.0, 41672.0] | [164.0, 207.0, 212.0] | [229, 237, 243] |
p03363 | u408375121 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n = int(input())\na = list(map(int, input().split()))\ndic = {}\ndic[0] = 1\ntotal = 0\nfor i in range(n):\n total += a[i]\n dic[total] += 1\nans = 0\nfor v in dic.values():\n ans += v*(v-1) // 2\nprint(ans)', 'n = int(input())\na = list(map(int, input().split()))\ndic = {}\ndic[0] = 1\ntotal = 0\nfor i in range(n):\n total += a[i]\n if total in dic:\n dic[total] += 1\n else:\n dic[total] = 1\nans = 0\nfor v in dic.values():\n ans += v*(v-1) // 2\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s810828492', 's189552888'] | [26720.0, 39508.0] | [93.0, 185.0] | [199, 248] |
p03363 | u471214054 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['import math\n\nn = int(input())\na = list(map(int, input().split()))\ns = [0]\nb = 0\n\nfor i in range(n):\n s.append(s[i] + a[i])\ns.sort()\n\nfor i in set(s):\n b += math.factorial(s.count(i)-1)\nprint(b)\n', 'n = int(input())\na = list(map(int, input().split()))\ncount = 0\nsum = 0\n\nprint(a)\nfor i in range(0, n):\n for j in range(i, n):\n sum += a[j]\n if sum == 0:\n count += 1\n sum = 0\nprint(count)\n', "n = int(input())\na = list(map(int, input().split()))\ns = [0]\nb = 1\nc = 0\n\nfor i in range(n):\n s.append(s[i] + a[i])\ns.sort()\ns.append('\\0')\n\nfor i in range(1, len(s)):\n if s[i] == s[i-1]:\n b += 1\n continue\n c += int(b*(b-1)/2)\n b = 1\nprint(c)\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s111226953', 's120389610', 's167014809'] | [33116.0, 26716.0, 26720.0] | [2105.0, 2104.0, 282.0] | [200, 218, 269] |
p03363 | u476604182 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ["from itertools import accumulate\nfrom collections import Counter\nN,*A = map(int, open('0').read().split())\nB = accumulate(A)\nc = Counter(B)\nans = c[0]+sum(v*(v-1)//2 for v in c.values())\nprint(ans)", 'from itertools import accumulate\nfrom collections import Counter\nN,*A = map(int, open(0).read().split())\nB = accumulate(A)\nc = Counter(B)\nans = c[0]+sum(v*(v-1)//2 for v in c.values())\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s765012656', 's780549270'] | [3316.0, 38928.0] | [20.0, 142.0] | [197, 195] |
p03363 | u503294750 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from collections import Counter\n\nN=int(input())\ns=list(map(int,input().split()))\n\nresult=[0]\nfor i in s:\n\tresult.append(result[-1]+i)\n\nprint(result) \n\na=Counter(result)\nans=0\nfor j in a.values():\n\tans+=j*(j-1)//2\n\nprint(ans)', 'from collections import Counter\n\nN=int(input())\ns=list(map(int,input().split()))\n\nresult=[0]\nfor i in s:\n\tresult.append(result[-1]+i)\n\na=Counter(result)\nans=0\nfor j in a.values():\n\tans+=j*(j-1)//2\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s701259276', 's700057734'] | [46944.0, 44412.0] | [178.0, 159.0] | [227, 208] |
p03363 | u504562455 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['import bisect\nfrom collections import deque\nn = int(input())\na = [int(i) for i in input().split()]\n\n\na_sum = [0]\nfor i in range(n):\n a_sum.append((a_sum[-1]+a[i]))\n\nval = deque()\ncnt = deque()\nfor i in range(n+1):\n \n idx = 0\n if len(val) > idx and val[idx] == a_sum[i]:\n cnt[idx] += 1\n else:\n val.insert(idx, a_sum[i])\n cnt.insert(idx, 1)\n\nans = 0\nfor i in range(len(cnt)):\n ans += cnt[i]*(cnt[i]-1)//2\n\nprint(ans)', 'import bisect\nfrom collections import deque\nn = int(input())\na = [int(i) for i in input().split()]\n\n\na_sum = [0]\nfor i in range(n):\n a_sum.append((a_sum[-1]+a[i]))\n\nval = deque()\ncnt = deque()\nfor i in range(n+1):\n idx = bisect.bisect_left(val, a_sum[i])\n if len(val) > idx and val[idx] == a_sum[i]:\n cnt[idx] += 1\n else:\n # val.insert(idx, a_sum[i])\n # cnt.insert(idx, 1)\n\nans = 0\nfor i in range(len(cnt)):\n ans += cnt[i]*(cnt[i]-1)//2\n\nprint(ans)', 'import bisect\nfrom collections import deque\nn = int(input())\na = [int(i) for i in input().split()]\n\n\na_sum = [0]\nfor i in range(n):\n a_sum.append((a_sum[-1]+a[i]))\n\nval = deque()\ncnt = deque()\nfor i in range(n+1):\n idx = bisect.bisect_left(val, a_sum[i])\n if len(val) > idx and val[idx] == a_sum[i]:\n cnt[idx] += 1\n else:\n val.append(a_sum[i])\n cnt.append(1)\n\nans = 0\nfor i in range(len(cnt)):\n ans += cnt[i]*(cnt[i]-1)//2\n\nprint(ans)\n', 'from collections import Counter\n\nn = int(input())\na = [int(i) for i in input().split()]\n\na_sum = [0]\nfor i in range(n):\n a_sum.append((a_sum[-1]+a[i]))\n\ncnt = Counter(a_sum)\n\nans = 0\nfor v in cnt.values():\n ans += v*(v-1)//2\n\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s114653523', 's717294073', 's809533568', 's166932221'] | [27508.0, 3064.0, 27516.0, 41568.0] | [126.0, 17.0, 2105.0, 200.0] | [494, 484, 471, 242] |
p03363 | u517152997 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['import math\n\nn = int(input())\na = [int(i) for i in input().split()]\n\n#print(n)\n#print(a)\nanswer = 0\nb=[0]\nfor i in range(n):\n b.append(b[i]+a[i])\nc=sorted(b)\nprint(b)\nprint(c)\nrenzoku = 0\nfor i in range(1,n+1):\n if c[i-1] == c[i]:\n renzoku += 1\n elif renzoku > 0:\n answer += math.factorial(renzoku)\n print(i,renzoku)\n renzoku = 0\nif renzoku > 0:\n answer += math.factorial(renzoku) \n print(i,renzoku)\nprint(answer)\n\n', 'import math\nimport numpy as np\n\nn = int(input())\na = list(map(int, input().split()))\n\n#print(n)\n#print(a)\nanswer = 0\nb=[0]*(n+1)\nfor i in range(n):\n b[i+1] = b[i]+a[i]\nc=np.sort(b)\n#print(b)\n#print(c)\nrenzoku = 0\nfor i in range(1,n+1):\n if c[i-1] == c[i]:\n renzoku += 1\n elif renzoku > 0:\n answer += renzoku*(renzoku+1)//2\n\n renzoku = 0\nif renzoku > 0:\n answer += renzoku*(renzoku+1)//2 \n\nprint(answer)\n'] | ['Wrong Answer', 'Accepted'] | ['s803035988', 's073423078'] | [36984.0, 34556.0] | [2105.0, 370.0] | [461, 483] |
p03363 | u517447467 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['N = int(input())\nnumbers = list(map(int, input().split()))\n \nsums = [0] * (N + 1)\nfor i in range(len(numbers)):\n sums[i] = sums[i-1]+numbers[i]\nsums = sorted(sums)\n\ntemp = ""\ncount = 0\nres = 0\nfor i in range(len(sums)):\n if temp == sums[i]:\n count += 1\n else:\n if count >= 2:\n print(count)\n c = 1\n for j in range(count-1, count+1):\n c *= j\n res += c/2\n count = 1\n temp = sums[i]\n \nif count >= 2:\n c = 1\n for i in range(count-1, count+1):\n c *= i\n res += c/2\n \nprint(int(res))', 'input()\nnumbers = input().split()\n\nres = 0\nfor i in range(len(numbers)):\n for j in range(i+1, len(numbers)):\n if numbers[i] == -1 * numbers[j]:\n res += 1\nprint(res)', 'N = int(input())\nnumbers = list(map(int, input().split()))\n \nsums = [0] * (N + 1)\nfor i in range(len(numbers)):\n sums[i] = sums[i-1]+numbers[i]\nsums = sorted(sums)\n\ntemp = ""\ncount = 0\nres = 0\nfor i in range(len(sums)):\n if temp == sums[i]:\n count += 1\n else:\n if count >= 2:\n c = 1\n for j in range(count-1, count+1):\n c *= j\n res += c/2\n count = 1\n temp = sums[i]\n \nif count >= 2:\n c = 1\n for i in range(count-1, count+1):\n c *= i\n res += c/2\n \nprint(int(res))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s445220847', 's536545171', 's637729963'] | [25976.0, 20072.0, 26136.0] | [234.0, 2108.0, 235.0] | [529, 173, 510] |
p03363 | u518042385 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n=int(input())\nl=list(map(int,input().split()))\nc=0\nl1=[]\nfor i in l:\n c+=i\n l1.append(c)\nl2={}\nfor i in l1:\n if i in l2:\n l2[i]+=1\n else:\n l2[i]=1\ns=0\nfor i in l2:\n s+=l2[i]*(l2[i]-1)/2\nprint(s)', 'n=int(input())\nl=list(map(int,input().split()))\nc=0\nl1=[]\nfor i in l:\n c+=i\n l1.append(c)\nl2={}\nfor i in l1:\n if i in l2:\n l2[i]+=1\n else:\n l2[i]=1\ns=0\nfor i in l2:\n if i==0:\n s+=l2[i]\n s+=l2[i]*(l2[i]-1)//2\nprint(s)'] | ['Wrong Answer', 'Accepted'] | ['s733498990', 's855727416'] | [41108.0, 41228.0] | [217.0, 217.0] | [206, 231] |
p03363 | u532966492 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['N=int(input())\nL=list(map(int,input().split()))\nN=200000\nL=[i for i in range(N)]\nLeft=[[0,0]]\nRight=[[0,N]]\nfor i in range(N):\n Left.append([Left[i][0]+L[i],i+1])\nfor i in range(N):\n Right.append([Right[i][0]+L[i*(-1)-1],N-i-1])\nRight=list(reversed(Right))\nLeft=sorted(Left, key=lambda x: x[0])\n_sum_=Right[0][0]\nLeft=sorted(Left, key=lambda x: x[0],reverse=True)\nRight=sorted(Right, key=lambda x: x[0])\nLeft.append([0,0])\nRight.append([0,0])\n\nj=0\ns=0\nans=0\nfor i in range(N+1):\n if i != 0:\n if Left[i][0]!=Left[i-1][0]:\n s=0\n while(Left[i][0]+Right[j][0]<_sum_ and j<=N):\n j+=1\n if j>N:\n break\n elif Left[i][0]+Right[j][0]>_sum_:\n continue\n else:\n while(Left[i][0]+Right[j][0]==_sum_ and j<=N):\n if Left[i][1]>=Right[j][1]:\n j+=1\n else:\n s+=1\n ans+=s\n break\nprint(ans)', 'N=int(input())\nL=list(map(int,input().split()))\nLeft=[[0,0]]\nRight=[[0,N]]\nfor i in range(N):\n Left.append([Left[i][0]+L[i],i+1])\nfor i in range(N):\n Right.append([Right[i][0]+L[i*(-1)-1],N-i-1])\nRight=list(reversed(Right))\nLeft=sorted(Left, key=lambda x: x[0])\n_sum_=Right[0][0]\nLeft=sorted(Left, key=lambda x: x[0],reverse=True)\nRight=sorted(Right, key=lambda x: x[0])\nLeft.append([0,0])\nRight.append([0,0])\n \nj=0\ns=0\nans=0\nfor i in range(N+1):\n if i != 0:\n if Left[i][0]!=Left[i-1][0]:\n s=0\n while(Left[i][0]+Right[j][0]<_sum_ and j<=N):\n j+=1\n if j>N:\n break\n elif Left[i][0]+Right[j][0]>_sum_:\n continue\n else:\n while(Left[i][0]+Right[j][0]==_sum_ and j<=N):\n if Left[i][1]>=Right[j][1]:\n j+=1\n else:\n s+=1\n ans+=s\n break\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s931944447', 's425938511'] | [85940.0, 84132.0] | [806.0, 1363.0] | [918, 886] |
p03363 | u537782349 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['a, b = map(int, input().split())\nc = list(map(int, input().split()))\n', 'a = int(input())\nb = list(map(int, input().split()))\nc = {0: 1}\nd = 0\nfor i in range(len(b)):\n d += b[i]\n if d not in c:\n c[d] = 1\n else:\n c[d] += 1\ne = 0\nfor k in c.keys():\n if c[k] >= 2:\n e += c[k] * (c[k] - 1) // 2\nprint(e)\n'] | ['Runtime Error', 'Accepted'] | ['s063469917', 's215588210'] | [2940.0, 38644.0] | [17.0, 206.0] | [69, 260] |
p03363 | u551373727 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n = int(input())\na = list(map(int, input().split()))\n\ns = sum(a)\nb = []\nc = []\nt = 0\n\n\nfor i in a:\n b.append(t)\n t += i\n c.append(s-t)\n \nprint(b, c)\ncu = list(set(c))\n\nans = 0\nfor i in range(n-1):\n if s-b[i] not in cu:\n continue\n for j in range(i, n):\n if b[i] + c[j] == s:\n print([i, j])\n ans += 1\nprint(ans)', 'n = int(input())\na = list(map(int, input().split()))\nans = 0\nl = {0:1}\ns = 0\n\nfor i in a:\n s += i\n if s in l:\n ans += l[s]\n l[s] += 1\n else:\n l[s] = 1\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s249904532', 's179324742'] | [49596.0, 38676.0] | [2106.0, 168.0] | [363, 192] |
p03363 | u557792847 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['N, Q = map(int, input().split())\nS = input()\nqn = [list(map(int, input().split())) for _ in range(Q)]\ncnt = [0 for _ in range(N+10)]\nfor i in range(1, N+1):\n if (S[i-1:i+1] == "AC"):\n cnt[i] = cnt[i-1] + 1\n else:\n cnt[i] = cnt[i-1]\nfor q in qn:\n l, r = q\n print(cnt[r-1] - cnt[l-1])\n', 'import sys\nimport numpy as np\nimport math\nimport collections\nimport copy\nfrom collections import deque \nfrom functools import reduce\nfrom itertools import product\nfrom itertools import combinations\n\nN = int(input())\nAn = list(map(int, input().split()))\nBn = []\nBn.append(0)\nfor i, A in enumerate(An):\n Bn.append(A+Bn[i])\nCn = collections.Counter(Bn)\nans = 0\nfor c in Cn.values():\n if c < 2:\n continue\n ans += c * (c-1) // 2\nprint(ans)\n\n\n\n'] | ['Runtime Error', 'Accepted'] | ['s246951237', 's759314513'] | [9152.0, 61572.0] | [28.0, 244.0] | [309, 454] |
p03363 | u588341295 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ["# -*- coding: utf-8 -*-\n\n\n\nimport sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import sqrt, hypot, factorial, pi, sin, cos, radians\nif sys.version_info.minor >= 5: from math import gcd\nelse: from fractions import gcd \nfrom heapq import heappop, heappush, heapify, heappushpop\nfrom bisect import bisect_left, bisect_right\nfrom itertools import permutations, combinations, product\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom functools import reduce, partial\nfrom fractions import Fraction\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\ndef input(): return sys.stdin.readline().strip()\ndef ceil(a, b=1): return int(-(-a // b))\ndef round(x): return int((x*2+1) // 2)\ndef fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD\ndef lcm(x, y): return (x * y) // gcd(x, y)\ndef lcm_list(nums): return reduce(lcm, nums, initial=1)\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef init_factorial(MAX: int) -> list:\n \n factorial = [1] * (MAX)\n factorial[0] = factorial[1] = 1\n for i in range(2, MAX):\n factorial[i] = factorial[i-1] * i\n return factorial\n\ndef nCr(n, r):\n # 10C7 = 10C3\n r = min(r, n-r)\n \n numerator = factorial[n]\n \n denominator = factorial[r] * factorial[n-r]\n return numerator // denominator\n\nfactorial = init_factorial(100001)\n\nN = INT()\naN = LIST()\n\nsm = [0] * (N+1)\nfor i in range(N):\n sm[i+1] = sm[i] + aN[i]\n\nc = Counter(sm)\nans = 0\nfor k, v in c.items():\n if v >= 2:\n ans += nCr(v, 2)\nprint(ans)\n", "# -*- coding: utf-8 -*-\n\n\n\nimport sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import sqrt, hypot, factorial, pi, sin, cos, radians\nif sys.version_info.minor >= 5: from math import gcd\nelse: from fractions import gcd \nfrom heapq import heappop, heappush, heapify, heappushpop\nfrom bisect import bisect_left, bisect_right\nfrom itertools import permutations, combinations, product\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom functools import reduce, partial\nfrom fractions import Fraction\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\ndef input(): return sys.stdin.readline().strip()\ndef ceil(a, b=1): return int(-(-a // b))\ndef round(x): return int((x*2+1) // 2)\ndef fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD\ndef lcm(x, y): return (x * y) // gcd(x, y)\ndef lcm_list(nums): return reduce(lcm, nums, initial=1)\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef nCr(n, r):\n # 10C7 = 10C3\n r = min(r, n-r)\n return factorial(n) // (factorial(r) * factorial(n-r))\n\nN = INT()\naN = LIST()\n\nsm = [0] * (N+1)\nfor i in range(N):\n sm[i+1] = sm[i] + aN[i]\n\nc = Counter(sm)\nans = 0\nfor k, v in c.items():\n if v >= 2:\n ans += nCr(v, 2)\nprint(ans)\n"] | ['Time Limit Exceeded', 'Accepted'] | ['s004744964', 's975784194'] | [0.0, 43112.0] | [2298.0, 1545.0] | [1828, 1438] |
p03363 | u591295155 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['def subarraySum(nums, k):\n count = total = 0\n cache = collections.defaultdict(int)\n cache[0] = 1\n for num in nums:\n total += num\n count += cache[total - k]\n cache[total] += 1\n return count\nA = input()\nnums = list(map(int,input().split()))\nk = 0\nprint(subarraySum(nums, 0))', 'import collections\ndef subarraySum(nums, k):\n count = total = 0\n cache = collections.defaultdict(int)\n cache[0] = 1\n for num in nums:\n total += num\n count += cache[total - k]\n cache[total] += 1\n return count\nA = input()\nnums = list(map(int,input().split()))\nk = 0\nprint(subarraySum(nums, 0))'] | ['Runtime Error', 'Accepted'] | ['s800979054', 's869890648'] | [27260.0, 39936.0] | [123.0, 193.0] | [288, 327] |
p03363 | u667024514 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ["from collections import Counter\nn = int(input())\nlis = list(map(int,input().split()))\nli = [0]\nl = ['0']\nans = set()\nfor i in range(n):\n ans.add(str(li[-1] + lis[i]))\n l.append(str(li[-1] + lis[i]))\n li.append(li[-1] + lis[i])\ncou = 0\nfor num in ans:\n co = l.count(str(num))\n co -= 1\n th = 1\n while co > 1:\n th *= co\n co -= 1\n cou += th\nprint(cou)", 'n = int(input())\nlis = list(map(int,input().split()))\nli = [0]\nfor i in range(n):li.append(li[-1]+lis[i])\nans = 0\nnum = 0\nli.sort()\nfor i in range(n):\n if li[i] == li[i+1]:\n num += 1\n ans += num\n else:num = 0\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s894901574', 's350614022'] | [57820.0, 26720.0] | [2107.0, 262.0] | [361, 227] |
p03363 | u675296835 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['a', 'n = int(input());\na = list(map(int,input().split()))\n\nans = 0;\ns = [0]*(n+1);\nm = {};\nfor i in range(0,n):\n s[i+1] = s[i]+a[i];\nfor i in range(0,n+1):\n m.setdefault(s[i],0);\n m[s[i]]+=1;\nfor v in m.values():\n ans += v*(v-1)//2\nprint(ans);'] | ['Runtime Error', 'Accepted'] | ['s589095563', 's340259688'] | [9068.0, 43988.0] | [27.0, 200.0] | [1, 242] |
p03363 | u679325651 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['import math\nN = int(input())\nAAA = [int(i) for i in input().split()]\nBBB = [0]\nfor a in AAA:\n BBB.append(a+BBB[-1])\nans=[]\nprint(BBB)\nBBB=sorted(BBB)\nprint(BBB)\nprev = math.inf\nbuff=BBB[0]\nans=[]\nfor i,b in enumerate(BBB):\n \n if b==prev:\n buff+=1\n else:\n if buff>=2:\n #print("append!")\n ans.append(buff)\n buff=1\n prev=b\nif buff!=1:\n ans.append(buff)\n#print(ans)\nprint(sum([(i-1)*i//2 for i in ans]))', 'N = int(input())\nAAA = [int(i) for i in input().split()]\nBBB = [0]\nfor a in AAA:\n BBB.append(a+BBB[-1])\nans=[]\n\nBBB=sorted(BBB)\n\nprev = float("inf")\nbuff=BBB[0]\nans=[]\nfor i,b in enumerate(BBB):\n \n if b==prev:\n buff+=1\n else:\n if buff>=2:\n #print("append!")\n ans.append(buff)\n buff=1\n prev=b\nif buff!=1:\n ans.append(buff)\n#print(ans)\nprint(sum([(i-1)*i//2 for i in ans]))'] | ['Runtime Error', 'Accepted'] | ['s464188721', 's535558225'] | [37152.0, 26136.0] | [224.0, 225.0] | [483, 477] |
p03363 | u703442202 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from itertools import accumulate\nn = int(input())\na_list = list(map(int,input.split()))\ncumsum = accumulate(a_list)\nnum_dict = {0:1}\nfor s in cumsum :\n if str(s) in num_list.keys:\n num_dict[str(s)] += 1\n else:\n num_dict[str(s)] = 1\n\nres = 0\nfor val in numdict:\n res += val * (val - 1)/2\n \nprint(res)\n ', 'from itertools import accumulate\nn = int(input())\na_list = list(map(int,input().split()))\ncumsum = list(accumulate(a_list))\nnum_dict = {0:1}\nfor s in cumsum :\n if s in num_dict.keys():\n num_dict[s] += 1\n else:\n num_dict[s] = 1\n\nres = 0\nfor val in num_dict.values():\n res += val * (val - 1)//2\n \nprint(res)\n '] | ['Runtime Error', 'Accepted'] | ['s706598727', 's538387932'] | [3060.0, 41360.0] | [17.0, 174.0] | [312, 318] |
p03363 | u703890795 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['import collections\nN = int(input())\nA = list(map(int, input().split()))\nS = [A[0]]\nfor i in range(len(A)-1):\n S.append(A[i+1]+S[i])\nL = list(collections.Counter(S).values())\ns = 0\nfor l in L:\n s += int((l-1)*l//2)\nprint(s)', 'import collections\nN = int(input())\nA = list(map(int, input().split()))\nS = [0]\nfor i in range(len(A)):\n S.append(A[i]+S[i])\nL = list(collections.Counter(S).values())\ns = 0\nfor l in L:\n s += int((l-1)*l//2)\nprint(s)'] | ['Wrong Answer', 'Accepted'] | ['s989793994', 's835260035'] | [41696.0, 41696.0] | [210.0, 218.0] | [224, 217] |
p03363 | u707249336 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['a=int(input())\nb=list(map(int, input().split(" ")))\nc=0\nd=0\ne={0:1}\nfor i in b:\n c+=i\n d+=e.get(c,0)\n e[c]=e.get(c,0)+1\n', 'a=int(input())\nb=list(map(int, input().split(" ")))\nc=0\nd=0\ne={0:1}\nfor i in b:\n c+=i\n d+=e.get(c,0)\n e[c]=e.get(c,0)+1\n\nprint(d)\n'] | ['Wrong Answer', 'Accepted'] | ['s936244977', 's976541678'] | [39544.0, 39564.0] | [198.0, 197.0] | [120, 130] |
p03363 | u740284863 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from itertools import accumulate\nfrom collections import Counter\nn = int(input())\nnums = list(map(int,input().split()))\ns = [0]+list(accumulate(nums))\nans = 0\nfor i in Counter(S).values():\n if i > 1:\n ans += i * (i - 1) // 2\nprint(ans)', 'from itertools import accumulate\nfrom collections import Counter\nn = int(input())\nnums = list(map(int,input().split()))\ns = [0]+list(accumulate(nums))\nans = 0\nfor i in Counter(s).values():\n if i > 1:\n ans += i * (i - 1) // 2\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s197546127', 's707541706'] | [25980.0, 41984.0] | [87.0, 128.0] | [245, 245] |
p03363 | u760171369 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ["import numpy as np\nN = int(input())\nA = np.array([0] + list(map(int, input().split())))\nB = np.cumsum(A)\nB.sort()\ncnt = 1\nout = 0\nfor k in range(N):\n if B[k] == B[k+1]:\n cnt += 1\n if k == N-1:\n out += (cnt * (cnt - 1)) // 2\n print('cnt: {}'.format(cnt))\n else:\n out += (cnt * (cnt - 1)) // 2\n cnt = 1\n print('out: {}'.format(out))\nprint(out)", 'import numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())))\nB = np.cumsum(A)\nB = B.sort()\ncnt = 0\nfor k in range(N):\n if B[k] == B[k+1]:\n cnt += 1\n else:\n continue\nprint(cnt)', 'import numpy as np\nN = int(input())\nA = np.array([0] + list(map(int, input().split())))\nB = np.cumsum(A)\nB.sort()\ncnt = 1\nout = 0\nfor k in range(N):\n if B[k] == B[k+1]:\n cnt += 1\n if k == N-1:\n out += (cnt * (cnt - 1)) // 2\n else:\n out += (cnt * (cnt - 1)) // 2\n cnt = 1\nprint(out)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s196958156', 's289806289', 's239079423'] | [34648.0, 34648.0, 34560.0] | [585.0, 298.0, 347.0] | [366, 204, 300] |
p03363 | u760771686 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['N = int(input())\nS = list(map(int, input().split()))\nA = {}\nt = 0\nans = 0\nfor s in S:\n t+=s\n if s in A:\n ans+=A[s]\n A[s]+=1\n else:\n A[s]=0\n\nprint(ans)', 'N = int(input())\nS = list(map(int, input().split()))\nA = {}\nt = 0\nans = 0\nfor s in S:\n t+=s\n if t == 0:\n ans+=1\n if t in A:\n A[t]+=1\n ans+=A[t]\n else:\n A[t]=0\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s864611310', 's177414992'] | [33812.0, 39564.0] | [155.0, 169.0] | [162, 210] |
p03363 | u762420987 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from itertools import accumulate\nfrom collections import Counter\nN = int(input())\nAlist = [0]+list(map(int, input().split()))\ncumsum = Counter(sorted(list(accumulate(Alist)))).most_common()\nans = 0\n\nfor k, v in cumsum:\n if v > 1:\n ans += n*(n-1)//2\n else:\n break\nprint(ans)\n', 'from itertools import accumulate\nfrom collections import Counter\nN = int(input())\nAlist = [0]+list(map(int, input().split()))\ncumsum = Counter(sorted(list(accumulate(Alist)))).most_common()\nans = 0\n\nfor k, v in cumsum:\n if v > 1:\n ans += v*(v-1)//2\n else:\n break\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s554748176', 's052676722'] | [48136.0, 48508.0] | [252.0, 250.0] | [294, 294] |
p03363 | u766684188 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from itertools import accumulate\nfrom collections import Counter\nimport sys\nsys.setrecursionlimit(10**9)\ninput=sys.stdin.readline\nn=int(input())\nA=list(map(int,input().split()))\nS=list(accumulate(A))\nC=Counter(S)\n\ndef num(m):\n return m*(m-1)//2\n\nans=0\nfor k,v in C.items():\n if k==0:\n ans+=v\n if v>1:\n ans+=comb(v)\nprint(ans)', 'from itertools import accumulate\nfrom collections import Counter\nimport sys\nsys.setrecursionlimit(10**9)\ninput=sys.stdin.readline\nn=int(input())\nA=list(map(int,input().split()))\nS=list(accumulate(A))\nC=Counter(S)\n\ndef num(m):\n return m*(m-1)//2\n\nans=0\nfor k,v in C.items():\n if k==0:\n ans+=v\n if v>1:\n ans+=num(v)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s755865694', 's832505598'] | [41440.0, 41448.0] | [165.0, 164.0] | [348, 347] |
p03363 | u771532493 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['N=int(input())\nlst=[int(i) for i in input().split()]\nans=0\nfor i in range(N-1):\n j=i+1\n a=lst[i]\n while j<=N-1:\n if a==0:\n ans+=1\n a+=lst[j]\nprint(ans)', 'import numpy \nimport collections\nN=int(input())\nlst=[int(i) for i in input().split()]\nlst.insert(0,0)\nres=numpy.cumsum(lst)\ns=collections.Counter(res).values()\nans=0\nfor i in s:\n ans+=i*(i-1)//2\nprint(ans)\n '] | ['Wrong Answer', 'Accepted'] | ['s686182076', 's119171337'] | [25976.0, 45952.0] | [2104.0, 342.0] | [165, 209] |
p03363 | u780962115 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n=int(input())\nlists=list(map(int,input().split()))\nlistsa=[0]\ns=0\nfor i in range(n):\n s+=lists[i]\n \n listsa.append(s)\nuselists=sorted(listsa)\nprint(uselists)\nimport collections\nans=collections.Counter(uselists)\na=0\nfor i in ans.values():\n a+=i-1\nprint(a)', 'n=int(input())\nlists=list(map(int,input().split()))\nlistsa=[0]\ns=0\nfor i in range(n):\n s+=lists[i]\n \n listsa.append(s)\n\nuselists=sorted(listsa)\n\nimport collections\nans=collections.Counter(uselists)\na=0\nfor i in ans.values():\n a+=(i-1)*(i)//2\nprint(a)\n'] | ['Wrong Answer', 'Accepted'] | ['s111427300', 's499539809'] | [45788.0, 42996.0] | [265.0, 249.0] | [264, 260] |
p03363 | u790877102 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n = int(input())\na = []\nfor i in range(n):\n a.append(input())\n\nfor i in range(n):\n a.append(a[i])\n\n\nx = 0\n\nfor i in range(n):\n for j in range(n):\n for k in range(j+1):\n if a[i+j][k]==a[i+k][j]:\n continue\n else:\n break\n else:\n continue\n break\n else:\n x += 1\n\nprint(n*x)\n\n ', 'n = int(input())\na = list(map(int,input().split()))\n\ns = []\np = 0\n\nfor i in range(n):\n p+=a[i]\n s.append(p)\ns.append(0)\n\nx = 0\nimport collections\ns = collections.Counter(s)\n\n\nfor i in range(len(s)):\n x += (s[i][1]*(z[i][1]-1))//2\nprint(x)\n', 'n = int(input())\na = list(map(int,input().split()))\n\ns = []\n\nfor i in range(n):\n s.append(sum(a[:i+1]))\ns.append(0)\n', 'n = int(input())\na = list(map(int,input().split()))\n\ns = []\np = 0\n\nfor i in range(n):\n p+=a[i]\n s.append(p)\ns.append(0)\n\nx = 0\n\ns = collections.Counter(s)\n\n\nfor i in range(len(s)):\n x += (s[i][1]*(z[i][1]-1))//2\nprint(x)\n', 'n = int(input())\na = list(map(int,input().split()))\n\ns = []\np = 0\n\nfor i in range(n):\n p+=a[i]\n s.append(p)\ns.append(0)\n\nx = 0\nimport collections\ns = collections.Counter(s)\n\ny,z = zip(*s.most_common())\n\nfor i in range(len(z)):\n x += (z[i]*(z[i]-1))//2\nprint(x)\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s259040931', 's507946577', 's780459712', 's800538734', 's250746766'] | [7156.0, 41660.0, 25976.0, 25976.0, 61540.0] | [21.0, 163.0, 2104.0, 119.0, 396.0] | [374, 248, 119, 230, 270] |
p03363 | u813102292 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n = int(input())\na = list(int(i) for i in input().split())\nsa = [0] * n\n\nfor i in range(n-1):\n if i == 0:\n sa[i] = a[i]\n else:\n sa[i + 1] = sa[i] + a[i + 1]\n\nprint(sa.count(0))', '\nn = int(input())\na = list(int(i) for i in input().split())\nsa = [0] * (n+1)\nnum_cnt = {} \n\nfor i in range(n):\n sa[i + 1] = sa[i] + a[i]\n\nfor num in sa:\n if num in num_cnt:\n num_cnt[num] += 1\n else:\n num_cnt[num] = 1\n\nfor cnt in num_cnt.values():\n res += cnt*(cnt-1)//2\n\nprint(res)\n', 'n = int(input())\na = list(int(i) for i in input().split())\nsa = [0] * (n+1)\nnum_cnt = {} \nfor i in range(n):\n sa[i + 1] = sa[i] + a[i]\n\nfor num in sa:\n if num in num_cnt:\n num_cnt[num] += 1\n else:\n num_cnt[num] = 1\n\n\nres = 0\nfor cnt in num_cnt.values():\n res += cnt*(cnt-1)//2\n\nprint(res)\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s301670860', 's942851757', 's829614073'] | [25976.0, 41268.0, 41148.0] | [152.0, 192.0, 218.0] | [207, 322, 318] |
p03363 | u848263468 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['N = int(input())\nS = [input() for _ in range(N)]\nT = ["".join(s) for s in zip(*S)]\n \nans = 0\nfor _ in range(N):\n ans += (S == T)\n S = [s[-1] + s[:-1] for s in S]\n T = T[-1:] + T[:-1]\n \nprint(N * ans)', 'N = int(input())\nA = list(map(int, input().split()))\nS = [0]*(N+1)\nfor n in range(N):\n S[n+1] = S[n] + A[n]\nB = {}\nfor s in range(len(S)):\n B[S[s]] = 0\nfor s in range(len(S)):\n B[S[s]] += 1\nres = 0\nfor v in B.values():\n if v > 1:\n res += v * (v - 1) // 2\nprint(res)'] | ['Runtime Error', 'Accepted'] | ['s404710284', 's535729258'] | [13088.0, 43884.0] | [29.0, 224.0] | [208, 284] |
p03363 | u857428111 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['# coding: utf-8\n# Your code here!\n# coding: utf-8\nimport sys\nsys.setrecursionlimit(200000000)\n\n\n# my functions here!\n\n\n\ndef pin(type=int):\n return map(type,input().rstrip().split())\nfrom collections import Counter \ndef resolve():\n N,=pin()\n A=list(pin())\n S=[sum(A[:i])for i in range(N+1)]\n \n s=list(Counter(S).values())\n ans=0\n for j in s:\n ans+=(j*(j-1))//2\n print(ans)\n\n\nimport sys\nfrom io import StringIO\nimport unittest\n\nimport sys\nfrom io import StringIO\nimport unittest\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n def test_入力例_1(self):\n input = """6\n1 3 -4 2 2 -2"""\n output = """3"""\n self.assertIO(input, output)\n def test_入力例_2(self):\n input = \n output = """12"""\n self.assertIO(input, output)\n def test_入力例_3(self):\n input = """5\n1 -2 3 -4 5"""\n output = """0"""\n self.assertIO(input, output)\nif __name__=="__main__":resolve()', '# coding: utf-8\n# Your code here!\n# coding: utf-8\nimport sys\nsys.setrecursionlimit(200000000)\n\n\n# my functions here!\n\n\ndef modular_w_binary_method (n,m,p):\n ans=1 if n>0 else 0\n while(p>0):\n if p%2==1:\n ans=(ans*n)%m\n n=(n**2)%m\n p//=2\n return ans\n\n\n\ndef modular_inverse(a,prime):\n return(modular_w_binary_method(a,prime,prime-2))\n\n\n\ndef conbination(n,a,mod=10**9+7):\n \n res=1 \n for s in range(a):\n res=(res*(n-s)*(modular_inverse(s+1,mod)))%mod\n\n \n return res\n\n\n\ndef pin(type=int):\n return map(type,input().rstrip().split())\n \ndef resolve():\n N,=pin()\n A=list(pin())\n S=[sum(A[:i])for i in range(N+1)]\n from collections import Counter\n s=list(Counter(S).values())\n ans=0\n for j in s:\n if j>1:\n ans+=conbination(j,2)\n print(ans)\n\n\nimport sys\nfrom io import StringIO\nimport unittest\n\nimport sys\nfrom io import StringIO\nimport unittest\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n def test_入力例_1(self):\n input = """6\n1 3 -4 2 2 -2"""\n output = """3"""\n self.assertIO(input, output)\n def test_入力例_2(self):\n input = \n output = """12"""\n self.assertIO(input, output)\n def test_入力例_3(self):\n input = """5\n1 -2 3 -4 5"""\n output = """0"""\n self.assertIO(input, output)\nif __name__=="__main__":resolve()', '# coding: utf-8\n# Your code here!\n# coding: utf-8\nimport sys\nsys.setrecursionlimit(200000000)\n\n\n# my functions here!\n\n\n\ndef pin(type=int):\n return map(type,input().rstrip().split())\nfrom collections import Counter\nfrom itertools import accumulate as acm\ndef resolve():\n N,=pin()\n S=list(acm(pin()))\n S.insert(0,0)\n s=list(Counter(S).values())\n ans=0\n for j in s:\n ans+=(j*(j-1))//2\n print(ans)\n\n\nif __name__=="__main__":resolve()'] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s596363950', 's885759416', 's194506929'] | [29844.0, 29900.0, 34168.0] | [2105.0, 2105.0, 128.0] | [1463, 2401, 630] |
p03363 | u859897687 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n=int(input())\nl=list(map(int,input().split()))\ns=set(l)\nans=0\nfor i in s:\n a=l.count(i)\n ans+=a*(a-1)//2\nprint(ans)', 'n=int(input())\nl=list(map(int,input()))\ns=set(l)\nans=0\nfor i in s:\n a=l.count(i)\n ans+=a*(a-1)//2\nprint(ans)', 'n=int(input())\nl=[0]+list(map(int,input().split()))\ns=set(l)\nfor i in range(1,1+n):\n l[i]+=l[i-1]\nans=0\nfor i in s:\n a=l.count(i)\n ans+=((a-1)*a//2)\nprint(ans)', 'n=int(input())\nl=[0]+list(map(int,input().split()))\nfor i in range(1,n+1):\n l[i]+=l[i-1]\nd={}\nfor i in l:\n if i not in d:\n d[i]=1\n else:\n d[i]+=1\nans=0\nfor a in d.values():\n ans+=a*(a-1)//2\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s551825905', 's623363097', 's743291942', 's594562413'] | [26620.0, 8784.0, 29592.0, 36372.0] | [2104.0, 21.0, 2105.0, 204.0] | [118, 110, 162, 210] |
p03363 | u879870653 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['N = int(input())\nA = list(map(int,input().split()))\nanswer = 0\nfor i in range(len(A)) :\n for j in range(i+1,len(A)) :\n p = 0\n p += A[j]\n if A[i] == A[j] :\n answer += 1\nprint(answer)\n\n', 'from math import factorial\nN = int(input())\nA = list(map(int,input().split()))\nL = []\nD = {}\nans = 0\nL.append(0)\nfor i in range(len(A)) :\n L.append(L[-1]+A[i])\nfor j in range(len(L)) :\n if L[j] not in D :\n D[L[j]] = 1\n else :\n D[L[j]] += 1\nV = list(D.values())\nfor k in range(len(V)) :\n if V[k] >= 2 :\n c = factorial(V[k])//(factorial(2)*factorial(V[k]-2))\n ans += c\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s711792996', 's120098331'] | [26000.0, 41436.0] | [2104.0, 1554.0] | [218, 418] |
p03363 | u886482185 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ["n = int(input())\n\ns = []\nfor i in range(n):\n s.append(list(input()))\n\nresult = 0\nfor offset in range(n):\n is_symmetry = True\n for i in range(n):\n for j in range(i+1, n):\n if s[i][(j+offset)%n] != s[j][(i+offset)%n]:\n is_symmetry = False\n break\n if not is_symmetry:\n break\n if is_symmetry:\n result += n\n # print('offset: %i' % offset)\n\nprint(result)", 'n = int(input())\na = list(map(int, input().split()))\ns = [0]\nfor i in range(n):\n s.append(s[-1] + a[i])\ns.sort()\nresult = 0\n\ncount = 1\nfor i in range(n):\n if s[i] == s[i+1]:\n count += 1\n else:\n result += count * (count - 1) // 2\n count = 1\nresult += count * (count - 1) // 2\n\nprint(result)\n'] | ['Runtime Error', 'Accepted'] | ['s706861146', 's271305714'] | [23292.0, 25976.0] | [54.0, 240.0] | [440, 320] |
p03363 | u894953648 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['import collections\n\ndef comb2(n):\n return (n*n-1)//2\n\nn=int(input())\na=list(map(int,input().split()))\n\nsums=[0]\nfor i in range(n):\n sums.append(sums[i]+a[i])\nprint(sums)\ncounts=collections.Counter(sums)\nprint(counts)\n\nres=0\n\nfor i in counts:\n res += comb2(counts[i])\nprint(res)', 'import collections\n\ndef comb2(n):\n return (n*(n-1))//2\n\nn=int(input())\na=list(map(int,input().split()))\n\nsums=[0]\nfor i in range(n):\n sums.append(sums[i]+a[i])\ncounts=collections.Counter(sums)\n\nres=0\n\nfor i in counts:\n res += comb2(counts[i])\nprint(res)'] | ['Wrong Answer', 'Accepted'] | ['s521837834', 's978556320'] | [65112.0, 41716.0] | [422.0, 264.0] | [286, 262] |
p03363 | u900688325 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['N = int(input())\nA_list = list(map(int, input().split()))\nimport math\n\nruiseki_A_list = [0 for _ in range(N)]\n\nfor i in range(N):\n if i == 0:\n ruiseki_A_list[i] = A_list[i]\n else:\n ruiseki_A_list[i] = A_list[i] + ruiseki_A_list[i-1]\n\n\n\nruiseki_A_list.insert(0,0)\nans = 0\n\n\nruiseki_A_list.sort()\nkosuu = [1]\nk = 0\nfor i in range(N):\n if ruiseki_A_list[i+1] - ruiseki_A_list[i] == 0:\n kosuu[k] += 1\n else:\n k += 1\n kosuu.append(1)\n\nkosuu[-1] += 1\nfor num in kosuu:\n if num <= 1:\n ans += 0\n else:\n ans += math.factorial(num)/(math.factorial(2) * math.factorial(num-2))\nprint(ans)', 'N = int(input())\nA_list = list(map(int, input().split()))\n\n\nruiseki_A_list = [0 for _ in range(N)]\n\nfor i in range(N):\n if i == 0:\n ruiseki_A_list[i] = A_list[i]\n else:\n ruiseki_A_list[i] = A_list[i] + ruiseki_A_list[i-1]\n\n\nruiseki_A_list.insert(0,0)\nans = 0\nfor left_num in range(N+1):\n for right_num in range(N+1):\n if left_num < right_num:\n if ruiseki_A_list[right_num] - ruiseki_A_list[left_num]:\n ans += 1\nprint(ans)', 'N = int(input())\nA_list = list(map(int, input().split()))\nimport math\n\nruiseki_A_list = [0 for _ in range(N)]\n\nfor i in range(N):\n if i == 0:\n ruiseki_A_list[i] = A_list[i]\n else:\n ruiseki_A_list[i] = A_list[i] + ruiseki_A_list[i-1]\n\n\n\nruiseki_A_list.insert(0,0)\nans = 0\n\nruiseki_A_list.sort()\nkosuu = [1]\nk = 0\nfor i in range(N):\n if ruiseki_A_list[i+1] - ruiseki_A_list[i] == 0:\n kosuu[k] += 1\n else:\n k += 1\n kosuu.append(1)\nkosuu[-1] += 1\nprint(kosuu)\nfor num in kosuu:\n ans += math.factorial(num)/(math.factorial(2) * math.factorial(num-2))\n\nprint(int(ans))', 'N = int(input())\nA_list = list(map(int, input().split()))\nimport math\n\nruiseki_A_list = [0 for _ in range(N)]\n\nfor i in range(N):\n if i == 0:\n ruiseki_A_list[i] = A_list[i]\n else:\n ruiseki_A_list[i] = A_list[i] + ruiseki_A_list[i-1]\n\n\n\nruiseki_A_list.insert(0,0)\nans = 0\n\n\nruiseki_A_list.sort()\nkosuu = [1]\nk = 0\nfor i in range(N):\n if ruiseki_A_list[i+1] - ruiseki_A_list[i] == 0:\n kosuu[k] += 1\n else:\n k += 1\n kosuu.append(1)\n\nkosuu[-1] += 1\nfor num in kosuu:\n if num <= 1:\n ans += 0\n else:\n ans += math.factorial(num)/(math.factorial(2) * math.factorial(num-2))\nprint(int(ans))', 'N = int(input())\nA_list = list(map(int, input().split()))\nimport math\n\nruiseki_A_list = [0 for _ in range(N)]\n\nfor i in range(N):\n if i == 0:\n ruiseki_A_list[i] = A_list[i]\n else:\n ruiseki_A_list[i] = A_list[i] + ruiseki_A_list[i-1]\n\n\n\nruiseki_A_list.insert(0,0)\nans = 0\n\n\nruiseki_A_list.sort()\nkosuu = [0]\nk = 0\nfor i in range(N):\n if ruiseki_A_list[i+1] - ruiseki_A_list[i] == 0:\n kosuu[k] += 1\n else:\n k += 1\n kosuu.append(0)\n\nfor num in kosuu:\n ans += math.factorial(num)/(math.factorial(2) * math.factorial(num-2))\n\nprint(ans)', 'N = int(input())\nA_list = list(map(int, input().split()))\nimport math\n\nruiseki_A_list = [0 for _ in range(N)]\n\nfor i in range(N):\n if i == 0:\n ruiseki_A_list[i] = A_list[i]\n else:\n ruiseki_A_list[i] = A_list[i] + ruiseki_A_list[i-1]\n\n\n\nruiseki_A_list.insert(0,0)\nans = 0\n\n\nruiseki_A_list.sort()\nkosuu = [1]\nk = 0\nfor i in range(N):\n if ruiseki_A_list[i+1] - ruiseki_A_list[i] == 0:\n kosuu[k] += 1\n else:\n k += 1\n kosuu.append(1)\n \nfor num in kosuu:\n if num <= 1:\n ans += 0\n else:\n ans += math.factorial(num)/(math.factorial(2) * math.factorial(num-2))\nprint(int(ans))'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s264036092', 's378405749', 's417349570', 's812378134', 's933924055', 's197767687'] | [25604.0, 25976.0, 25724.0, 25604.0, 25604.0, 25604.0] | [1571.0, 2105.0, 1572.0, 1586.0, 1581.0, 1565.0] | [1050, 566, 701, 1055, 988, 1048] |
p03363 | u905582793 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from itertools import accumulate\nfrom collections import Counter\nimport sys\ninput = sys.stdin.readline\nn = int(input())\na = [0]\na.extend(map(int,input().split()))\na = list(accumulate(a))\nc = Counter(a)\nans = 0\nfor i in c.values():\n ans+=i*(i-1)//2', 'from itertools import accumulate\nfrom collections import Counter\nimport sys\ninput = sys.stdin.readline\nn = int(input())\na = [0]\na.extend(map(int,input().split()))\na = list(accumulate(a))\nc = Counter(a)\nans = 0\nfor i in c.values():\n ans+=i*(i-1)//2\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s666623890', 's161563510'] | [34048.0, 34040.0] | [158.0, 152.0] | [248, 259] |
p03363 | u906501980 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n = int(input())\nA = [int(i) for i in input().split()]\nS = [A[0]]\nfor i in range(n+1):\n S[i+1] = S[i] + A[i]\nout = 0\nfor i in set(S):\n num = S.count(i)\n out += num*(num-1)//2\nprint(out)', 'n = int(input())\nA = [int(i) for i in input().split()]\ncount = 0\nfor j in range(n):\n for k in range(1,n-j+1,1):\n print(A[j:j+k])\n if not sum(A[j:j+k]):\n count += 1\nprint(count)', "n = int(input())\nA = [input() for _ in range(n)]\nout = 0\nfor k in range(n):\n a = A[k:][:] + A[:k][:]\n if ''.join(a) == ''.join(map(''.join, zip(*a))):\n out += n\nprint(out)", 'n = int(input())\nA = sorted([int(i) for i in input().split()])\nout = 0\nfor i in range(1,n):\n if A[i] == A[i-1]:\n out += 1\nprint(out)', 'from collections import Counter\nn = int(input())\nA = [int(i) for i in input().split()]\nS = [0]*(n+1)\nfor i in range(n):\n S[i+1] = S[i] + A[i]\nout = [i*(i-1)//2 for i in Counter(S).values() if i > 1]\nprint(sum(out))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s095666064', 's211997560', 's835971720', 's957064612', 's522538587'] | [25976.0, 145500.0, 7160.0, 25976.0, 41496.0] | [77.0, 2119.0, 22.0, 191.0, 175.0] | [194, 204, 184, 142, 217] |
p03363 | u944209426 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['import math\nimport collections\nn = int(input())\na = list(map(int, input().split()))\nans=0\nx=[a[0]]\nfor i in range(1,n):\n x.append(a[i]+x[i-1])\nprint(x)\nc = collections.Counter(x)\nprint(c)\nfor i in c.items():\n if i[1]>=2:\n ans+=math.factorial(i[1]-1)\nprint(ans)', 'import math\nimport collections\nn = int(input())\na = list(map(int, input().split()))\nans=0\nx=[a[0]]\nfor i in range(1,n):\n x.append(a[i]+x[i-1])\nc = collections.Counter(x)\nfor i in c.items():\n\tif i[1]>=2:\n ans+=math.factorial(i[1]-1)\nprint(ans)', 'def com(x,y):\n a=1\n b=1\n y=min(y,x-y)\n for i in range(x,x-y,-1):\n a*=i\n for i in range(1,y+1):\n b*=i\n return a//b\n\nn=int(input())\na=list(map(int,input().split()))\nb=[a[0]]\nfor i in range(1,n):\n b.append(b[-1]+a[i])\nfrom collections import Counter\nc=Counter(b)\nd=list(c.items())\nans=0\nfor t in d:\n if t[0]==0:\n ans+=com(t[1]+1,2)\n elif t[1]>1:\n ans+=com(t[1],2)\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s005898879', 's466922650', 's829486123'] | [65180.0, 2940.0, 47984.0] | [2105.0, 17.0, 282.0] | [273, 252, 426] |
p03363 | u945418216 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n = int(input())\naa = list(map(int, input().split()))\n\ns =[0]*(n+1)\nfor i in range(n):\n s[i+1] = s[i] + aa[i]\nprint(sorted(s))\nans=0\nfor x in set(s):\n c = s.count(x)\n ans+= c*(c-1)//2\nprint(ans)', 'from collections import Counter\nfrom itertools import accumulate\nn = int(input())\naa = list(map(int, input().split()))\n\ns =[0] + list(accumulate(aa))\n# print(s)\nans=0\nfor x in Counter(s).values():\n ans+= x * (x-1) //2\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s354626007', 's030193684'] | [39480.0, 41984.0] | [2105.0, 165.0] | [203, 232] |
p03363 | u950708010 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from math import factorial\nimport sys\ninput = sys.stdin.readline\ndef ncr(n,r):\n if n <= 1:\n return 0\n else:\n return factorial(n) / factorial(r) / factorial(n - r)\n\nn= int(input())\na = list(int(i) for i in input().split())\ns = [0]\nfor i in range(n):\n s.append(s[i]+a[i])\ns = sorted(s,reverse =True)\nans = 0\nfor i in range(n):\n tmp = 0\n if s[i] == s[i+1]:\n tmp += 1\n else:\n ans += ncr(tmp,2)\nans += ncr(tmp,2)\nprint(int(ans))\n', 'from math import factorial\nimport sys\ninput = sys.stdin.readline\ndef ncr(n):\n if n <= 1:\n return 0\n elif n == 2:\n return 1\n else:\n return (factorial(n) // 2) // factorial(n - 2)\n\nn= int(input())\na = list(int(i) for i in input().split())\ns = [0]\nfor i in range(n):\n s.append(s[i]+a[i])\ns = sorted(s,reverse =True)\nans = 0\ntmp = 1\nfor i in range(len(s)-1):\n if s[i] == s[i+1]:\n tmp += 1\n else:\n ans += ncr(tmp)\n tmp = 1\nans += ncr(tmp)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s036684442', 's507062751'] | [27268.0, 27268.0] | [262.0, 1569.0] | [436, 458] |
p03363 | u957084285 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n = int(input())\nA = list(map(int, input().split()))\nfor i in range(1, n):\n A[i] = A[i] + A[i-1]\nans = 0\nA.sort()\np = A[0]\ncount = 1\nfor i in range(1, n):\n x = A[i]\n if x == p:\n count += 1\n else:\n ans += count * (count-1)//2\n count = 1\n p = x\nans += count * (count-1)//2\nprint(ans)\n', 'n = int(input())\nA = list(map(int, input().split()))\nfor i in range(1, n):\n A[i] = A[i] + A[i-1]\nans = 0\nA.sort()\np = A[0]\ncount = 1\nfor i in range(1, n):\n x = A[i]\n if x == p:\n count += 1\n else:\n if p == 0:\n ans += count\n ans += count * (count-1)//2\n count = 1\n p = x\nif p == 0:\n ans += count\nans += count * (count-1)//2\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s173730145', 's983450183'] | [25724.0, 25976.0] | [244.0, 274.0] | [322, 394] |
p03363 | u968404618 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from itertools import accumulate\n\nn = int(input())\nA = list(map(int, input().split()))\nS = list(accumulate(A))\nprint(A)\nprint(S)\n\n\ncnt = 0\ntmp = 0\nfor i in range(n):\n if S[i] == 0 or S[i] == tmp:\n cnt += 1\n tmp = S[i-1]\nprint(cnt)', 'from itertools import accumulate\nimport collections\n\nn = int(input())\nA = list(map(int, input().split()))\nS = list(accumulate(A))\n\nC = collections.Counter(S)\ncnt = C[0]\nmc = C.most_common()\nfor c in mc:\n if c[1] > 1:\n cnt += c[1]*(c[1]-1)//2\nprint(cnt) '] | ['Wrong Answer', 'Accepted'] | ['s145957646', 's103329260'] | [33628.0, 48272.0] | [155.0, 213.0] | [237, 265] |
p03363 | u969808621 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['from collections import defaultdict\n\nn = int(input())\na = list(map(int, input().split()))\n\ns = [0 for i in range(n+1)]\nnums = {}\nnums = defaultdict(int)\nfor i in range(0,n):\n\ts[i+1] = s[i] + a[i]\n\nfor i in range(0,n):\n\tnums[s[i]]+=1\n\nres = 0\nfor key in nums:\n\t#print("key ",key," value ",nums[key])\n\tres += nums[key] * (nums[key] - 1) / 2\n\nprint(int(res))', 'from collections import defaultdict\n\nn = int(input())\na = list(map(int, input().split()))\n\ns = [0 for i in range(n+1)]\nnums = {}\nnums = defaultdict(int)\nfor i in range(0,n):\n\ts[i+1] = s[i] + a[i]\n\nfor i in range(0,n+1):\n\tnums[s[i]]+=1\n\nres = 0\nfor key in nums:\n\t#print("key ",key," value ",nums[key])\n\tres += nums[key] * (nums[key] - 1) / 2\n\nprint(int(res))'] | ['Wrong Answer', 'Accepted'] | ['s429619539', 's515878979'] | [41752.0, 41752.0] | [282.0, 304.0] | [355, 357] |
p03363 | u977389981 | 2,000 | 262,144 | We have an integer sequence A, whose length is N. Find the number of the non-empty **contiguous** subsequences of A whose sums are 0. Note that we are counting **the ways to take out subsequences**. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions. | ['n = int(input())\nA = [int(i) for i in input().split()]\n\ncnt = 0\nfor i in range(n):\n for j in range(i + 1, n + 1):\n if sum(A[i : j]) == 0:\n cnt += 1\n print(A[i : j])\n\nprint(cnt)', 'from collections import Counter\n\nn = int(input())\nA = [int(i) for i in input().split()]\n\nS = [0] * (n + 1)\nfor i in range(1, n + 1):\n S[i] = S[i - 1] + A[i - 1]\n \nS = Counter(S)\nans = 0\nfor v in S.values():\n ans += v * (v - 1) // 2\n \nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s414821655', 's184836401'] | [84560.0, 41504.0] | [2104.0, 208.0] | [208, 260] |
p03364 | u145600939 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['n = int(input())\ns = [list(input()) for i in range(h)]\ns += s\n\ndef ok(array):\n for i in range(1,n):\n for j in range(i):\n if array[i][j] != array[j][i]:\n return False\n return True\nans = 0\nfor i in range(n-1):\n if ok(s[i:i+n]):\n ans += n\nprint(ans)\n', 'n = int(input())\ns = [list(input()) for i in range(n)]\ns += s\n\ndef ok(array):\n for i in range(1,n):\n for j in range(i):\n if array[i][j] != array[j][i]:\n return False\n return True\nans = 0\nfor i in range(n-1):\n if ok(s[i:i+n]):\n ans += n\nprint(ans)\n', 'n = int(input())\ns = [list(input()) for i in range(n)]\ns += s\n\ndef ok(array):\n for i in range(1,n):\n for j in range(i):\n if array[i][j] != array[j][i]:\n return False\n return True\nans = 0\nfor i in range(n):\n if ok(s[i:i+n]):\n ans += n\nprint(ans)\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s217030547', 's866264499', 's660595112'] | [3060.0, 3828.0, 3956.0] | [17.0, 1642.0, 1679.0] | [296, 296, 294] |
p03364 | u149260203 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ["import numpy as np\nfrom scipy.ndimage.interpolation import shift as scipy_shift\n\nclass shift:\n def __init__(self,a):\n self.arr = a\n self.height = a.shape[0]\n self.width = a.shape[1]\n def shifted(self,down,right):\n temp1 = self.arr[list(np.linspace(-down, -down + self.height - 1, self.height, dtype=int) % self.height), :]\n temp2 = temp1[:, list(np.linspace(-right, -right + self.width - 1, self.width, dtype=int) % self.width)]\n return temp2\n def shifted_zero(self,down,right):\n index_vertical = np.arange(self.height)\n index_horizontal = np.arange(self.width)\n temp1 = self.arr[list(scipy_shift(index_vertical, down, output = int, mode = 'constant')),:]\n temp2 = temp1[:,list(scipy_shift(index_horizontal, right, output = int, mode = 'constant'))]\n return temp2\n def is_sym(self,down,right):\n temp = self.shifted(down,right)\n delta = temp - temp.T\n return(not (delta*delta).sum())\n\n\n\nN = int(input())\narray = [list(input()) for i in range(N)]\narray_int = np.array([[ord(i) for i in j] for j in array])\n\ncount = np.array([[shift(array_int).is_sym(i,j) for i in range(N)] for j in range(N)])\nprint(count)\nprint(count.sum())", "import numpy as np\nfrom scipy.ndimage.interpolation import shift as scipy_shift\n\nclass shift:\n def __init__(self,a):\n self.arr = a\n self.height = a.shape[0]\n self.width = a.shape[1]\n def shifted(self,down,right):\n temp1 = self.arr[list(np.linspace(-down, -down + self.height - 1, self.height).astype(np.int32) % self.height), :]\n temp2 = temp1[:, list(np.linspace(-right, -right + self.width - 1, self.width).astype(np.int32) % self.width)]\n return temp2\n def shifted_zero(self,down,right):\n index_vertical = np.arange(self.height)\n index_horizontal = np.arange(self.width)\n temp1 = self.arr[list(scipy_shift(index_vertical, down, output = int, mode = 'constant')),:]\n temp2 = temp1[:,list(scipy_shift(index_horizontal, right, output = int, mode = 'constant'))]\n return temp2\n def is_sym(self,down,right):\n temp = self.shifted(down,right)\n delta = temp - temp.T\n return(not (delta*delta).sum())\n\n\n\nN = int(input())\narray = [list(input()) for i in range(N)]\narray_int = np.array([[ord(i) for i in j] for j in array])\n\nif N >= 2:\n count = np.array([shift(array_int).is_sym(0,i)*(N-i) for i in range(N)]).sum() + np.array([shift(array_int).is_sym(i,0)*(N-i) for i in range(1,N)]).sum()\nelse:\n count = int(shift(array_int).is_sym(0,0))\nprint(count)"] | ['Runtime Error', 'Accepted'] | ['s583868379', 's999809544'] | [15716.0, 25388.0] | [204.0, 1829.0] | [1233, 1361] |
p03364 | u268793453 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['n = int(input())\ns = [input() for i in range(n)]\n\ncnt = 0\n\ndef is_symmetry():\n for k in range(n):\n for l in range(k+1, n):\n if s_[k][l] != s_[l][k]:\n return false\n return true\n\nfor i in range(n):\n i_ = (n+i)%n\n s_ = s[i_:] + s[:i_]\n if is_symmetry()\n cnt += 1\n\nprint(cnt*n)', 'n = int(input())\ns = [input() for i in range(n)]\nst = [str().join(s_) for s_ in zip(*s)]\n\ncnt = 0\n\nfor i in range(n):\n i_ = (n+i)%n\n for k in range(n):\n if s[(i_+k)%n] != st[(i_+k)%n]:\n break\n else:\n cnt += 1\n\nprint(cnt*n)', 'n = int(input())\ns = [input() for i in range(n)]\n\ncnt = 0\n\ndef is_symmetry(s_):\n for k in range(n):\n for l in range(k+1, n):\n if s_[k][l] != s_[l][k]:\n return false\n return true\n\nfor i in range(n):\n i_ = (n+i)%n\n s_ = s[i_:] + s[:i_]\n if is_symmetry(s_):\n cnt += 1\n\nprint(cnt*n)', 'n = int(input())\ns = [input() for i in range(n)]\n\ncnt = 0\n\ndef is_symmetry():\n\n\nfor i in range(n):\n i_ = (n+i)%n\n s_ = s[i_:] + s[:i_]\n for k in range(n):\n for l in range(k+1, n):\n if s_[k][l] != s_[l][k]:\n break\n else:\n continue\n break\n else:\n cnt += 1\n\nprint(cnt*n)', 'n = int(input())\ns = [input() for i in range(n)]\n\ncnt = 0\n\ndef is_symmetry():\n for k in range(n):\n for l in range(k+1, n):\n if s_[k][l] != s_[l][k]:\n return false\n return true\n\nfor i in range(n):\n i_ = (n+i)%n\n s_ = s[i_:] + s[:i_]\n if is_symmetry():\n cnt += 1\n\nprint(cnt*n)', 'n = int(input())\ns = [input() for i in range(n)]\nst = [str().join(s_) for s_ in zip(*s)]\n\ncnt = 0\n\nfor i in range(n):\n for k in range(n):\n if s[k] != st[k]:\n break\n else:\n cnt += 1\n s = [s_[-1]+s_[:-1] for s_ in s]\n st = [st[-1]] + st[:-1]\n\nprint(cnt*n)'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s074004133', 's234382832', 's676878116', 's757005224', 's928637369', 's534724625'] | [3064.0, 3188.0, 3064.0, 2940.0, 3064.0, 3316.0] | [17.0, 50.0, 23.0, 17.0, 24.0, 55.0] | [328, 256, 333, 344, 329, 290] |
p03364 | u350248178 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['import numpy as np\nn=int(input())\ns=np.array([list(input()) for i in range(n)])\nl=np.zeros((n,n),dtype=np.str)\nans=0\nfor i in range(n):\n l[:i]=s[n-i:n]\n l[i:]=s[:n-i]\n t=False\n for x in range(n):\n for y in range(x+1,n):\n if l[x][y]!=l[y][x]:\n t=True\n break\n if t:\n break\n if not t:\n ans+=n\n\nprint(ans)\n', 'import numpy as np\nn=int(input())\ns=np.array([list(input()) for i in range(n)])\ns=np.concatenate([s,s])\nans=0\nfor i in range(n):\n l=s[i:i+n]\n if (l==l.T).all():\n ans+=n\nprint(ans)'] | ['Time Limit Exceeded', 'Accepted'] | ['s700120967', 's909474042'] | [15608.0, 14200.0] | [2112.0, 519.0] | [390, 192] |
p03364 | u547085427 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ["n = int(input())\nA = [input() for _ in range(n)]\nA_t = [''] * n\nfor c in A:\n for i in range(n):\n A_t[i] += c[i]\n\ndef checkTable(shift):\n for i in range(n):\n if A_t[i] != A[i][shift:] + A[i][:shift]:\n return False\n return True\n\ncount = 0\nfor i in range(n):\n if checkTable(i):\n count += 1\nprint(count * n)", "n = int(input())\nA = [input() for _ in range(n)]\nA_t = [''] * n\nfor c in A:\n for i in range(n):\n A_t[i] += c[i]\n\ndef checkTable(shift):\n for i in range(n):\n if A_t[(i + shift) % n] != A[i][shift:] + A[i][:shift]:\n return False\n return True\n\ncount = 0\nfor i in range(n):\n if checkTable(i):\n count += 1\nprint(count * n)"] | ['Wrong Answer', 'Accepted'] | ['s294962772', 's743283501'] | [3188.0, 3188.0] | [69.0, 74.0] | [347, 361] |
p03364 | u561083515 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['\nimport numpy as np\n\ndef is_symmetric(a):\n \n return np.array_equal(a, a.T)\n\ndef main():\n N = int(input())\n S = [[ord(s) - ord("a") for s in list(input())] for _ in range(N)]\n\n S = np.array(S)\n\n ans = 0\n for B in range(N):\n if is_symmetric(np.roll(S, B, axis=1)):\n ans += N\n\n print(ans)', '\nimport numpy as np\n\ndef is_symmetric(a):\n \n return np.array_equal(a, a.T)\n\ndef main():\n N = int(input())\n S = [[ord(s) - ord("a") for s in list(input())] for _ in range(N)]\n\n S = np.array(S)\n\n ans = 0\n for B in range(N):\n if is_symmetric(np.roll(S, B, axis=1)):\n ans += N\n\n print(ans)\n\nif __name__ == "__main__":\n main()'] | ['Wrong Answer', 'Accepted'] | ['s843822285', 's421745539'] | [12476.0, 14552.0] | [148.0, 348.0] | [380, 419] |
p03364 | u600402037 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['import sys\nimport numpy as np\nimport copy\n\nstdin = sys.stdin\n \nri = lambda: int(rs())\nrl = lambda: list(map(int, stdin.readline().split()))\nrs = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\n\nN = ri()\nS = [rs() for _ in range(N)]\nS = np.array(S + S)\nanswer = 0\nfor a in range(N):\n for b in range(N):\n bool = True\n temp_S = S[a:a+N]\n temp_S2 = []\n for x in temp_S:\n y = x[b:] + x[:b]\n temp_S2.append(y)\n temp_S2 = np.array(temp_S2)\n if all(temp_S2 == temp_S2.T):\n answer += 1\n\nprint(answer)\n\n#16\n\n', 'import sys\nimport numpy as np\n\nstdin = sys.stdin\n \nri = lambda: int(rs())\nrl = lambda: list(map(int, stdin.readline().split()))\nrs = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nN = ri()\nS = np.array([list(rs()) for _ in range(N)])\n\nS = np.concatenate([S, S], axis=0)\nanswer = 0\nfor b in range(N):\n S2 = S[b:b+N]\n if (S2 == S2.T).all():\n answer += N\n\nprint(answer)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s674083402', 's325510046'] | [15736.0, 15856.0] | [2108.0, 518.0] | [611, 394] |
p03364 | u672220554 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['n = int(input())\ns = []\nfor _ in range(n):\n s.append(input())\n\ndef allequal(s):\n for i in range(n):\n for j in range(n):\n if s[i][j] != s[0][0]:\n return False\n return True\n\ndef val(s,k):\n global n\n for i in range(n):\n if i+k >= n:\n ni = i+k-n\n else:\n ni = i+k\n for j in range(n):\n if s[i][j] != s[j][ni]:\n return False\n return True\n\nif allequal(s):\n print(n**2)\nelse:\n res = 0\n for k in range(0,n):\n if val(s,k):\n res += n\n print(res)', "n = int(input())\ns = []\nfor _ in range(n):\n s.append(input())\nst=list(map(''.join,zip(*s)))\n\ndef plusa(s,a):\n ns = []\n for ss in s:\n ns.append(ss[a:]+ss[:a])\n return ns\n\ndef plusb(s,b):\n global n\n ns = []\n for i in range(n-b):\n ns.append(s[b+i])\n for i in range(b):\n ns.append(s[i])\n return ns\n\nres = 0\nfor i in range(n):\n if plusa(st,i) == plusb(s,i):\n res += n\n\nprint(res)"] | ['Wrong Answer', 'Accepted'] | ['s978400182', 's007228893'] | [3064.0, 3332.0] | [1616.0, 57.0] | [583, 432] |
p03364 | u790877102 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['N = int(input())\nS = []\nfor i in range(N):\n S.append(input())\n\ndef check(S, A, B):\n for i in range(N):\n for j in range(i+1, N):\n if S[i][j] != S[j][i]:\n return 0\n else return 1\n\ncnt = 0\nfor i in range(N):\n cnt += check(S[i:] + S[:i], 0, i)\nprint(cnt * N)\n', 'n = int(input())\na = []\nfor i in range(n):\n a.append(input())\nfor i in range(n):\n a[i].extend(a[i])\nfor i in range(n):\n a.append(a[i])\n\n\nx = 0\n\nfor i in range(n):\n for j in range(n):\n for k in range(j+1):\n if a[i+j][k]==a[i+k][j]:\n continue\n else:\n break\n else:\n continue\n break\n else:\n x += 1\n\nprint(n*x)\n\n ', 'N = int(input())\nS = []\nfor i in range(N):\n S.append(input())\n\ndef check(S):\n for i in range(N):\n for j in range(i+1, N):\n if S[i][j] != S[j][i]:\n return 0\n return 1\n\ncnt = 0\nfor i in range(N):\n cnt += check(S[i:] + S[:i])\nprint(cnt * N)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s798919390', 's901935770', 's791494078'] | [2940.0, 3064.0, 3188.0] | [18.0, 18.0, 1629.0] | [300, 414, 283] |
p03364 | u814986259 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['N = int(input())\nS = [tuple(input()) for i in range(N)]\nans = 0\nfor A in range(N):\n for B in range(N):\n flag = True\n for i in range(N):\n for j in range(N):\n y = i + A\n x = j + B\n if y >= N:\n y -= N\n if x >= N:\n x -= N\n\n if S[y][x] == S[x][y]:\n continue\n else:\n flag = False\n break\n if flag == False:\n break\n if flag:\n ans += 1\nprint(ans)\n', 'import collections\nimport sys\nimport numpy as np\ninput = sys.stdin.readline\ntable = collections.defaultdict(set)\nN = int(input())\nS = [list(input().rstrip()) for i in range(N)]\nT = [[""] * (N*2) for i in range(2*N)]\ntable2 = [[set() for j in range(N)] for i in range(N)]\n\nfor i in range(2*N):\n if i < N:\n T[i] = S[i] + S[i]\n else:\n T[i] = S[i - N] + S[i-N]\nans = 0\nT = np.array(T)\nfor i in range(N):\n tmp = T[0:N, i:i+N]\n if (tmp == tmp.T).all():\n ans += N\n\n tmp = T[i+1:i+N+1, N-1-i:2*N-1-i]\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s715167544', 's934225514'] | [3828.0, 37808.0] | [2104.0, 638.0] | [595, 540] |
p03364 | u839188633 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['n = int(input())\ns = [input() for i in range(n)]\n\n\ndef check\n\ndef yoi(s, b):\n for i in range(n):\n for j in range(i+1, n):\n if s[i % n][(j + b) % n] != s[j % n][(i + b) % n]:\n return 0\n return 1\n\nsol = sum(yoi(s, b) for b in range(n))\nprint(sol * n)', 'n = int(input())\ns = [input() for i in range(n)]\nst = [str().join(s_) for s_ in zip(*s)]\n\nsol = 0\n\nfor i in range(n):\n for k in range(n):\n if s[k] != st[k]:\n break\n else:\n sol += 1\n \n s = [s_l[1:]+s_l[0] for s_l in s]\n st = st[1:] + [st[0]]\n \nprint(sol * n)'] | ['Runtime Error', 'Accepted'] | ['s549508350', 's115434492'] | [2940.0, 3316.0] | [17.0, 50.0] | [265, 300] |
p03364 | u846150137 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ["import numpy as np\nn=int(input())\ns=[chr(i) for i in range(97, 97+26)]\n \naa_cij=np.array([[s.index(i)+1 for i in list(input())] for _ in range(n)],dtype='int8')\n\nans=0\nfor i in range(n):\n aa_cij=np.concatenate( [ aa_cij[1:,:], aa_cij[[0],:] ], axis=0)\n if np.allclose(aa_cij 、aa_cij.T):\n ans+=1 \nprint(ans*n)\n", "import numpy as np\nn=int(input())\ns=[chr(i) for i in range(97, 97+26)]\n \naa_cij=np.array([[s.index(i)+1 for i in list(input())] for _ in range(n)],dtype='int8')\n\nans=0\nfor i in range(n):\n aa_cij=np.concatenate( [ aa_cij[1:,:], aa_cij[[0],:] ], axis=0)\n if np.allclose(aa_cij, aa_cij.T):\n ans+=1 \nprint(ans*n)\n"] | ['Runtime Error', 'Accepted'] | ['s791251604', 's621055403'] | [2940.0, 21324.0] | [17.0, 978.0] | [317, 315] |
p03364 | u876442898 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['N = int(input())\nS = []\nfor i in range(N):\n S.append(input())\n\ndef check(A, B):\n for i in range(N):\n for j in range(i+1, N):\n if S[i][j] != S[j][i]:\n return 0\n return 1\n\ncnt = 0\nfor i in range(N):\n cnt += check(0, i)\nprint(cnt * N)', 'N = int(input())\nS = []\nfor i in range(N):\n S.append(input())\n\ndef check(S, A, B):\n for i in range(N):\n for j in range(i+1, N):\n # if j + B < N:\n # b = j + B\n # else:\n # b = j + B - N\n \n \n # else:\n - N\n if S[i][j+B] != S[j][i+B]:\n return 0\n return 1\n\ncnt = 0\nfor i in range(N):\n cnt += check(S, 0, i)\nprint(cnt * N)', 'N = int(input())\nS = []\nfor i in range(N):\n S.append(input())\n\ndef check(S, A, B):\n for i in range(N):\n for j in range(i+1, N):\n # if j + B < N:\n # b = j + B\n # else:\n # b = j + B - N\n \n \n # else:\n - N\n if S[i][j+B-N] != S[j][i+B-N]:\n return 0\n return 1\n\ncnt = 0\nfor i in range(N):\n cnt += check(S, 0, i)\nprint(cnt * N)', 'N = int(input())\nS = []\nfor i in range(N):\n S.append(input())\n\ndef check(S, A, B):\n for i in range(N):\n for j in range(i+1, N):\n if j + B < N:\n b = j + B\n else:\n b = j + B - N\n if i + B < N:\n d = i + B\n else:\n d = i + B - N\n if S[a][b] != S[c][d]:\n return 0\n return 1\n\ncnt = 0\nfor i in range(N):\n cnt += check(S, 0, i):\nprint(cnt * N)', 'N = int(input())\nS = []\nfor i in range(N):\n S.append(input())\n\ndef check(S, A, B):\n for i in range(N):\n for j in range(i+1, N):\n if S[i][j+B-N] != S[j][i+B-N]:\n return 0\n return 1\n\ncnt = 0\nfor i in range(N):\n cnt += check(S[i:] + s[:i], 0, i)\nprint(cnt * N)', 'N = int(input())\nS = []\nfor i in range(N):\n S.append(input())\n\ndef check(S, A, B):\n for i in range(N):\n for j in range(i+1, N):\n if S[i][j] != S[j][i]:\n return 0\n return 1\n\ncnt = 0\nfor i in range(N):\n cnt += check(S[i:] + S[:i], 0, i)\nprint(cnt * N)'] | ['Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s288975586', 's341091759', 's409068162', 's505267547', 's989201351', 's985974249'] | [3064.0, 3064.0, 3064.0, 3064.0, 3064.0, 3188.0] | [1901.0, 24.0, 2104.0, 17.0, 18.0, 1612.0] | [276, 502, 506, 483, 302, 294] |
p03364 | u906501980 | 2,000 | 262,144 | Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet. Snuke will write letters on the second board, as follows: * First, choose two integers A and B ( 0 \leq A, B < N ). * Write one letter in each square on the second board. Specifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board. Here, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column. After this operation, the second board is called a _good_ board when, for every i and j ( 1 \leq i, j \leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal. Find the number of the ways to choose integers A and B ( 0 \leq A, B < N ) such that the second board is a good board. | ['import numpy as np\nn = int(input())\nA = [[ord(i) for i in input()] for j in range(n)]\ncount = 0\nfor a in range(n):\n arr = np.roll(A, a, axis=0)\n arrT = arr.T\n for i in range(n):\n if arr[i][i:] != arrT[i][i:]:\n break\n else:\n count += n\nprint(count)', "n = int(input())\nA = [input() for _ in range(n)]\nout = 0\nfor k in range(n):\n a = A[k:][:] + A[:k][:]\n if ''.join(a) == ''.join(map(''.join, zip(*a))):\n out += n\nprint(out)"] | ['Runtime Error', 'Accepted'] | ['s066726113', 's489482161'] | [14564.0, 3444.0] | [166.0, 563.0] | [284, 184] |
p03365 | u268793453 | 2,000 | 262,144 | There are N squares lining up in a row, numbered 1 through N from left to right. Initially, all squares are white. We also have N-1 painting machines, numbered 1 through N-1. When operated, Machine i paints Square i and i+1 black. Snuke will operate these machines one by one. The order in which he operates them is represented by a permutation of (1, 2, ..., N-1), P, which means that the i-th operated machine is Machine P_i. Here, the _score_ of a permutation P is defined as the number of machines that are operated before all the squares are painted black for the first time, when the machines are operated in the order specified by P. Snuke has not decided what permutation P to use, but he is interested in the scores of possible permutations. Find the sum of the scores over all possible permutations for him. Since this can be extremely large, compute the sum modulo 10^9+7. | ['n = int(input())\np = 10**9 + 7\n\ndef fact(n, p):\n n_ = [1]\n for i in range(1, n+1):\n n_.append((n_[-1]*i) % p)\n return n\n\ndef invfact(n, f, p):\n m = [pow(f[n], p-2, p)]\n for i in range(n, 0, -1):\n m.append(m[-1] * i % p)\n return m\n\nans = 0\nm = n - 1\nf = list(fact(m, p))\nrf = list(invfact(m, f, p))\nrf.reverse()\nperm = 0\n\nfor k in range((n+1)//2, n):\n perm_ = f[k-1] * rf[2*k-n] %p * f[k] % p\n ans += (perm_ - perm) %p * k % p\n ans %= p\n perm = perm_\n\nprint(ans)', 'n = int(input())\np = 10**9 + 7\n\n\n# n_ = 1\n# yield n_\n\n# n_ = (n_*i) % p\n# yield n_\n\n\n\n# yield m\n\n\n# yield m\n\ndef fact(n, p):\n n_ = [1]\n for i in range(1, n+1):\n n_.append((n_[-1]*i) % p)\n return n\n\ndef invfact(n, f, p):\n m = [pow(f[n], p-2, p)]\n for i in range(n, 0, -1):\n m.append(m[-1] * i % p)\n return m\n\nans = 0\nm = n - 1\nf = fact(m, p)\nrf = invfact(m, f, p)\nrf.reverse()\nperm = 0\n\nfor k in range((n+1)//2, n):\n perm_ = f[k-1] * rf[2*k-n] %p * f[k] % p\n ans += (perm_ - perm) %p * k % p\n ans %= p\n perm = perm_\n\nprint(ans)', 'n = int(input())\np = 10**9 + 7\n\ndef fact(n, p):\n n_ = [1]\n for i in range(1, n+1):\n n_.append((n_[-1]*i) % p)\n return n\n\ndef invfact(n, f, p):\n m = [pow(f[n], p-2, p)]\n for i in range(n, 0, -1):\n m.append(m[-1] * i % p)\n return m\n\nans = 0\nm = n - 1\nf = fact(m, p)\nrf = invfact(m, f, p)\nrf.reverse()\nperm = 0\n\nfor k in range((n+1)//2, n):\n perm_ = f[k-1] * rf[2*k-n] %p * f[k] % p\n ans += (perm_ - perm) %p * k % p\n ans %= p\n perm = perm_\n\nprint(ans)', 'n = int(input())\np = 10**9 + 7\n\ndef fact(n):\n n_ = 1\n yield n_\n for i in range(1, n+1):\n n_ = (n_*i) % p\n yield n_\n\ndef invfact(n, f, p):\n m = pow(f[n], p-2, p)\n yield m\n for i in range(n, 0, -1):\n m = m * i % p\n yield m\n\nans = 0\nm = n - 1\nf = list(fact(m))\nrf = list(invfact(m, f, p))\nrf.reverse()\nperm = 0\n\nfor k in range((n+1)//2, n):\n perm_ = f[k-1] * rf[2*k-n-2] %p * f[k] % p\n ans += (perm_ - perm) %p * k % p\n ans %= p\n perm = perm_\n\nprint(ans)', 'n = int(input())\np = 10**9 + 7\n\ndef fact(n, p):\n n_ = [1]\n for i in range(1, n+1):\n n_.append((n_[-1]*i) % p)\n return n_\n\ndef invfact(n, f, p):\n m = [pow(f[n], p-2, p)]\n for i in range(n, 0, -1):\n m.append(m[-1] * i % p)\n return m\n\nans = 0\nm = n - 1\nf = fact(m, p)\nrf = invfact(m, f, p)\nrf.reverse()\nperm = 0\n\nfor k in range((n+1)//2, n):\n perm_ = f[k-1] * rf[2*k-n] %p * f[k] % p\n ans += (perm_ - perm) %p * k % p\n ans %= p\n perm = perm_\n\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s189370144', 's622291094', 's697519173', 's780474361', 's710904544'] | [42668.0, 42668.0, 42668.0, 84260.0, 82224.0] | [222.0, 222.0, 222.0, 943.0, 950.0] | [506, 759, 494, 511, 495] |
p03365 | u729707098 | 2,000 | 262,144 | There are N squares lining up in a row, numbered 1 through N from left to right. Initially, all squares are white. We also have N-1 painting machines, numbered 1 through N-1. When operated, Machine i paints Square i and i+1 black. Snuke will operate these machines one by one. The order in which he operates them is represented by a permutation of (1, 2, ..., N-1), P, which means that the i-th operated machine is Machine P_i. Here, the _score_ of a permutation P is defined as the number of machines that are operated before all the squares are painted black for the first time, when the machines are operated in the order specified by P. Snuke has not decided what permutation P to use, but he is interested in the scores of possible permutations. Find the sum of the scores over all possible permutations for him. Since this can be extremely large, compute the sum modulo 10^9+7. | ['n = int(input())\nfn,fk,mod = [1]*n,[1]*n,10**9+7\nfor i in range(n-1): fn[i+1] = (fn[i]*(i+2))%mod\ndef power(n,k):\n\tif k==1: return n\n\telif k%2==0: return power((n**2)%mod,k//2)\n\telse: return (n*power(n,k-1))%mod\ndef comb(n,k):\n\tif n<k or k<0: return 0\n\telif k==0 or n==k: return 1\n\telse: return (((fn[n-1]*fk[n-k-1])%mod)*fk[k-1])%mod\nfk[-1] = power(fn[-1],mod-2)\nfor i in range(2,n+1): fk[-i] = (fk[-i+1]*(n+2-i))%mod\nfn.append(1)\nans = f[n-2]\nfor i in range(2,n):\n\tans = (ans-comb(i-1,n-i-1)*fn[i-1]*fn[n-i-2])%mod\nprint(ans)', 'n = int(input())\nfn,fk,mod = [1]*n,[1]*n,10**9+7\nfor i in range(n-1): fn[i+1] = (fn[i]*(i+2))%mod\ndef power(n,k):\n\tif k==1: return n\n\telif k%2==0: return power((n**2)%mod,k//2)\n\telse: return (n*power(n,k-1))%mod\ndef comb(n,k):\n\tif n<k or k<0: return 0\n\telif k==0 or n==k: return 1\n\telse: return (((fn[n-1]*fk[n-k-1])%mod)*fk[k-1])%mod\nfk[-1] = power(fn[-1],mod-2)\nfor i in range(2,n+1): fk[-i] = (fk[-i+1]*(n+2-i))%mod\nfn.append(1)\nans = fn[n-2]*(n-1)\nfor i in range(n-2,(n-1)//2,-1):\n\tans = (ans-comb(i-1,n-i-1)*fn[i-1]*fn[n-i-2])%mod\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s114976746', 's267935074'] | [82164.0, 82164.0] | [813.0, 1467.0] | [527, 546] |
p03373 | u001024152 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ["# input -- A B C X Y\n\nA, B, C, X, Y = map(int, input().split())\nprint(A, B, C, X, Y )\n\n# can buy '2 * Z' pieces of C-pizza \nZ = min(X, Y)\nsum_of_pay = 0\n\nif A+B > 2*C:\n sum_of_pay += 2 * Z * C\n\n if X-Z > 0: \n if A > 2*C:\n sum_of_pay += 2 * (X-Z) * C\n else: \n sum_of_pay += (X-Z) * A\n else: \n if B > 2*C:\n sum_of_pay += 2 * (Y-Z) * C\n else: \n sum_of_pay += (Y-Z) * B\nelse: \n sum_of_pay += (X*A + Y*B)\n\nprint(sum_of_pay)", "# input -- A B C X Y\n\nA, B, C, X, Y = map(int, input().split())\n#print(A, B, C, X, Y )\n\n# can buy '2 * Z' pieces of C-pizza\nZ = min(X, Y)\nsum_of_pay = 0\n\nif A+B > 2*C:\n sum_of_pay += 2 * Z * C\n\n if X-Z > 0: \n if A > 2*C:\n sum_of_pay += 2 * (X-Z) * C\n else:\n sum_of_pay += (X-Z) * A\n else: \n if B > 2*C:\n sum_of_pay += 2 * (Y-Z) * C\n else:\n sum_of_pay += (Y-Z) * B\nelse:\n sum_of_pay += (X*A + Y*B)\n\nprint(sum_of_pay)\n"] | ['Wrong Answer', 'Accepted'] | ['s949851225', 's977527189'] | [3064.0, 3060.0] | [18.0, 18.0] | [540, 538] |
p03373 | u034128150 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a, b, c, x, y = map(int, input().split())\npossible_minimum_sum1 = a * x + b * y\npossible_minimum_sum2 = c * x * 2 + max(b-a, 0) * y\npossible_minimum_sum3 = c * y * 2 + max(a-b, 0) * x\n\nprint(min(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3))\n', 'a, b, c, x, y = map(int, input().split())\npossible_minimum_sum1 = a * x + b * y\npossible_minimum_sum2 = c * max(a, b)\nprint(min(possible_minimum_sum1, possible_minimum_sum2))', 'a, b, c, x, y = map(int, input().split())\npossible_minimum_sum1 = a * x + b * y\npossible_minimum_sum2 = c * max(a, b) * 2\npossible_minimum_sum3 = c * a * 2 + max(b-a, 0) * b\npossible_minimum_sum4 = c * b * 2 + max(a-b, 0) * a\n\nprint(min(tuple(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3, possible_minimum_sum4)))\n', 'a, b, c, x, y = map(int, input().split())\npossible_minimum_sum1 = a * x + b * y\npossible_minimum_sum2 = c * x * 2 + max(y-x, 0) * b\npossible_minimum_sum3 = c * y * 2 + max(x-y, 0) * a\n\nprint(min(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3))\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s031723199', 's057430082', 's627451048', 's690966419'] | [2940.0, 2940.0, 3060.0, 3060.0] | [18.0, 18.0, 17.0, 20.0] | [265, 174, 337, 265] |
p03373 | u062189367 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['import sys\nA, B, C, X, Y = map(int,input().split())\n\nmin = sys.maxsize\nX1 = X\nY1 = Y\n\n\nfor i in range(0, max(X,Y)+1):\n price = (X1-i)*A+(Y1-i)*B+2*i*C\n if min > price:\n min = price\n\n\nprint(min)\n', 'import sys\nA, B, C, X, Y = map(int,input().split())\n\nmin = sys.maxsize\nX1 = X\nY1 = Y\n\n\nfor i in range(0, max(X,Y)+1):\n price = (X1-i)*A+(Y1-i)*B+2*i*C\n if min > price:\n min = price\n\n\nprint(min)\n', 'import sys\nA, B, C, X, Y = map(int,input().split())\n\nminf = sys.maxsize\nX1 = X\nY1 = Y\n\n\nfor i in range(0, max(X,Y)+1):\n price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C\n if minf > price:\n minf = price\n\n\nprint(minf)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s149582305', 's802443791', 's303657066'] | [2940.0, 2940.0, 3060.0] | [65.0, 67.0, 98.0] | [207, 207, 225] |
p03373 | u064408584 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['n,c=map(int,input().split())\nx=[0]\nv=[]\nfor i in range(n):\n a,b=map(int,input().split())\n x.append(a)\n v.append(b)\nx1=[x[i+1]-x[i] for i in range(len(x)-1)]\nx2=[c-x[-1]]+x1[:0:-1]\n#print(x1,x2)\nh=[0]\nt=[0]\nfor i,j in zip(x2,reversed(v)):\n h.append(h[-1]+j+-i)\nhm=[max(h[:-i]) for i in range(1,len(h))]+[0]\n#print(h,hm)\nm=0\nfor k,(i,j) in enumerate(zip(x1,v)):\n t.append(t[-1]+j-i)\n #print(m,t[-1],i)\n m=max(m,t[-1]+hm[k])\nprint(m)', 'n,c=map(int,input().split())\nx=[0]\nv=[]\nfor i in range(n):\n a,b=map(int,input().split())\n x.append(a)\n v.append(b)\n\nx1=[x[i+1]-x[i] for i in range(len(x)-1)]\nx2=[c-x[-1]]+x1[:0:-1]\nprint(x1,x2)\nh=[0]\nt=[0]\nfor i,j in zip(x2,reversed(v)):\n h.append(h[-1]+j+-i)\nhm=[max(h[:-i]) for i in range(1,len(h))]+[0]\nprint(h,hm)\nm=0\nfor k,(i,j) in enumerate(zip(x1,v)):\n t.append(t[-1]+j-i)\n print(m,t[-1],i)\n m=max(m,t[-1]+hm[k])\nprint(m)', 'a,b,c,x,y=map(int, input().split())\n\nif x>=y :l=min(x,y)*2*c+(x-y)*a\nelse: l=l=min(x,y)*2*c+(y-x)*b\n\nmin(a*x+b*y, l, max(x,y)*2*c)', 'a,b,c,x,y=map(int, input().split())\n\nif x>=y :l=min(x,y)*2*c+(x-y)*a\nelse: l=l=min(x,y)*2*c+(y-x)*b\n\nprint(min(a*x+b*y, l, max(x,y)*2*c))'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s040832332', 's873347726', 's885368573', 's562031548'] | [3064.0, 3064.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0, 17.0] | [451, 449, 130, 137] |
p03373 | u076245995 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A, B, C, X, Y = map(int, input().split())\nnot_in_C = A*X + B*Y\nif X > Y:\n cost = 2 * C * Y \n if A < C:\n cost += A * (X - Y)\n else:\n cost += 2 * C * (X - Y)\nelif X < Y\n cost = 2 * C * X\n if B < C:\n cost += B * (Y - X)\n else:\n cost += 2 * C * (Y - X)\nelif X == Y:\n cost = 2 * C * Y\nprint(min(not_in_C, cost))', 'A, B, C, X, Y = map(int, input().split())\ncost = A*X + B*Y\nnew_cost = cost\nfor i in range(1, max(X, Y)+1):\n if i <= min(X, Y):\n new_cost += - A - B + 2*C\n else:\n new_cost += -A + 2*C if X > Y else -B + 2*C\n if cost < new_cost:\n print(cost)\n exit()\nprint(new_cost)\n', 'A, B, C, X, Y = map(int, input().split())\nnot_in_C = A*X + B*Y\nif X > Y:\n cost = 2 * C * Y \n if A < C:\n cost += A * (X - Y)\n else:\n cost += 2 * C * (X - Y)\nelif X < Y\n cost = 2 * C * X\n if B < C:\n cost += B * (Y - X)\n else:\n cost += 2 * C * (Y - X)\nprint(min(not_in_C, cost))', 'A, B, C, X, Y = map(int, input().split())\ncost = A*X + B*Y\nnew_cost = cost\nplus = 0\nfor i in range(1, max(X, Y)+1):\n if i <= min(X, Y):\n plus = - A - B + 2*C\n else:\n plus = -A + 2*C if X > Y else -B + 2*C\n if plus < 0:\n new_cost += plus\n else:\n break\nprint(new_cost)\n'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s367048651', 's529343247', 's753692460', 's341176720'] | [2940.0, 3060.0, 2940.0, 3060.0] | [17.0, 74.0, 17.0, 73.0] | [325, 279, 293, 283] |
p03373 | u101490607 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,c,x,y = map(int, input().split() )\n\n#print(a,b,c,x,y)\n\ncost = a*x + b*y\n\nfor i in range( max(x,y) +1):\n tmp = i * 2*c + max(0, x-i)*a + max(0, x-i)*b\n if tmp < cost:\n cost = tmp\n \nprint( cost )', 'a,b,c,x,y = map(int, input().split() )\n\n#print(a,b,c,x,y)\n\ncost = a*x + b*y\n\nfor i in range( max(x,y) +1):\n tmp = i * 2*c + max(0, x-i)*a + max(0, y-i)*b\n if tmp < cost:\n cost = tmp\n \nprint( cost )'] | ['Wrong Answer', 'Accepted'] | ['s101915486', 's026696041'] | [3060.0, 3060.0] | [105.0, 105.0] | [205, 205] |
p03373 | u105302073 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A, B, C, X, Y = [int(i) for i in input().split()]\nis_x_large = X > Y\nif C < A // 2 and C < B // 2:\n if is_x_large:\n print(C * X * 2)\n else:\n print(C * Y * 2)\n exit()\n\ntotal1 = A * X + B * Y\nif is_x_large:\n total2 = C * Y * 2 + A * (X - Y)\nelse:\n total2 = C * X * 2 + B * (Y - X)\nprint(total1, total2)\nprint(total1 if total1 < total2 else total2)\n', 'A, B, C, X, Y = [int(i) for i in input().split()]\n\n\ntotal1 = A * X + B * Y\n\n\ntotal2 = 2 * C * max(X, Y)\n\n\nP = B if X < Y else A\ntotal3 = 2 * C * min(X, Y) + P * abs(X - Y)\n\n\nret = min(total1, min(total2, total3))\nprint(ret)\n'] | ['Wrong Answer', 'Accepted'] | ['s996455364', 's674442353'] | [3064.0, 3060.0] | [17.0, 17.0] | [375, 433] |
p03373 | u111202730 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a, b, c, x, y = map(int, input().split())\n\nans1 = a*x + b*y\n\nif x > y:\n ans2 = 2*c*y + a*(x-y)\n ans3 = 2*x*c\nelse:\n ans2 = 2*c*x + b*(y-x))\n ans3 = 2*c*y\n\nprint(min(ans1, ans2), ans3)\n', 'a, b, c, x, y = map(int, input().split())\n\nans1 = a*x + b*y\n\nif x >= y:\n ans2 = 2*c*y + a*(x-y)\n ans3 = 2*x*c\nelse:\n ans2 = 2*c*x + b*(y-x)\n ans3 = 2*y*c\n\nprint(min(ans1, ans2), ans3)\n', 'a, b, c, x, y = map(int, input().split())\n\nans1 = a*x + b*y\n\nif x >= y:\n ans2 = 2*c*y + a*(x-y)\n ans3 = 2*x*c\nelse:\n ans2 = 2*c*x + b*(y-x)\n ans3 = 2*y*c\n\nprint(min(min(ans1, ans2), ans3))'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s343748445', 's521527759', 's331885425'] | [2940.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0] | [196, 196, 200] |
p03373 | u140963344 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a=list(map(int, input().split()))\nb=2*a[3]*a[2]\nc=a[2]*a[4]*2+a[0]*(a[3]-a[4])\nd=2*a[4]*a[2]\ne=a[2]*a[3]*2+a[1]*(a[4]-a[3])\nf=a[0]*a[3]+a[1]*a[4]\ng=min(b,c,f)\nh=min(d,e,f)\nif a[3]>=a[4]:\n print(g)\nelse:\n print(h)\n', 'a, b, c, x, y=map(int, input().split())\nm=2*x*c\nn=c*y*2+a*(x-y)\nd=2*y*c\ne=c*x*2+b*(y-x)\nf=a*x+b*y\ng=min(m,n,f)\nh=min(d,e,f)\nif x>=y:\n print(g)\nelse:\n print(h)\n', 'a, b, c, x, y=map(int, input().split())\nm=2*x*c\nn=c*y*2+a*(x-y)\nd=2*y*c\ne=c*x*2+b*(y-x)\nf=a*x+b*y\ng=min(m,n,f)\nh=min(d,e,f)\nif a[3]>=a[4]:\n print(g)\nelse:\n print(h)\n', 'a=list(map(int, input().split()))\nif a[0]+a[1]>=a[2]*2:\n if a[3]>=a[4]:\n print min(2*a[3]*a[2], (a[2]*a[4]*2+a[0]*(a[3]-a[4])))\n else:\n print min(2*a[4]*a[2], (a[2]*a[3]*2+a[1]*(a[4]-a[3])))\nelse:\n print (a[0]*a[3]+a[1]*a[4])\n', 'a=list(map(int, input().split()))\nif a[0]+a[1]>=a[2]*2:\n if a[3]>=a[4]:\n print max(2*a[3]*a[2], (a[2]*a[4]*2+a[0]*(a[3]-a[4])))\n else:\n print max(2*a[4]*a[2], (a[2]*a[3]*2+a[1]*(a[4]-a[3])))\nelse:\n print (a[0]*a[3]+a[1]*a[4])\n', 'a=list(map(int, input().split()))\nif a[0]+a[1]>=a[2]*2 :\n if a[3]>=a[4]:\n print (a[2]*a[4]+a[0]*(a[3]-a[4]))\n else:\n print (a[2]*a[3]+a[1]*(a[4]-a[3]))\nelse:\n print (a[0]*a[3]+a[1]*a[4])', 'a=list(map(int, input().split()))\nb=2*a[3]*a[2]\nc=a[2]*a[4]*2+a[0]*(a[3]-a[4])\nd=2*a[4]*a[2]\ne=a[2]*a[3]*2+a[1]*(a[4]-a[3])\nf=a[0]*a[3]+a[1]*a[4]\ng=min(b,c,f)\nh=min(d,e,f)\nif a[3]>=a[4]:\n print(g)\nelse:\n print(h)', 'print 1', 'a=list(map(int, input().split()))\nif a[0]+a[1]>=a[2]*2:\n if a[3]>=a[4]:\n print (min(2*a[3]*a[2], (a[2]*a[4]*2+a[0]*(a[3]-a[4]))))\n else:\n print (min(2*a[4]*a[2], (a[2]*a[3]*2+a[1]*(a[4]-a[3]))))\nelse:\n print (a[0]*a[3]+a[1]*a[4])\n', 'a=list(map(int, input().split()))\nif a[0]+a[1]>=a[2]*2 :\n if a[3]>=a[4]:\n print (a[2]*a[4]+a[0]*(a[3]-a[4]))\n else:\n print (a[2]*a[3]+a[1]*(a[4]-a[3]))\nelse:\n print (a[0]*a[3]+a[1]*a[4])\n', 'a=list(map(int, input().split()))\n\nprint 1\n', 'a=list(map(int, input().split()))\nb=2*a[3]*a[2]\nc=a[2]*a[4]*2+a[0]*(a[3]-a[4])\nd=2*a[4]*a[2]\ne=a[2]*a[3]*2+a[1]*(a[4]-a[3])\nf=a[0]*a[3]+a[1]*a[4]\nif a[3]>=a[4]:\n print(min(b,c,f))\nelse:\n print(min(d,e,f))\n', 'a=list(map(int, input().split()))\nb=2*a[3]*a[2]\nc=a[2]*a[4]*2+a[0]*(a[3]-a[4])\nd=2*a[4]*a[2]\ne=a[2]*a[3]*2+a[1]*(a[4]-a[3])\nf=a[0]*a[3]+a[1]*a[4]\ng=min(b,c,f)\nh=min(d,e,f)\nif a[3]>=a[4]:\n print(g)\nelse:\n print(h)\n', 'a=list(map(int, input().split()))\nb=2*a[3]*a[2]\nc=a[2]*a[4]*2+a[0]*(a[3]-a[4])\nd=2*a[4]*a[2]\ne=a[2]*a[3]*2+a[1]*(a[4]-a[3])\nf=a[0]*a[3]+a[1]*a[4]\nif a[3]>=a[4]:\n print(min(b,c,f))\nelse:\n print(min(d,e,f))\n', 'a=list(map(int, input().split()))\nb=2*a[3]*a[2]\nc=a[2]*a[4]*2+a[0]*(a[3]-a[4])\nd=2*a[4]*a[2]\ne=a[2]*a[3]*2+a[1]*(a[4]-a[3])\nf=a[0]*a[3]+a[1]*a[4]\nif a[3]>=a[4]:print(min(b,c,f))\nelse:print(min(d,e,f))\n', 'a=list(map(int, input().split()))\nif a[0]+a[1]>=a[2]*2:\n if a[3]>=a[4]:\n print (a[2]*a[4]*2+a[0]*(a[3]-a[4]))\n else:\n print (a[2]*a[3]*2+a[1]*(a[4]-a[3]))\nelse:\n print (a[0]*a[3]+a[1]*a[4])\n', 'a, b, c, x, y=map(int, input().split())\nm=2*x*c\nn=c*y*2+a*(x-y)\nd=2*y*c\ne=c*x*2+b*(y-x)\nf=a*x+b*y\ng=min(m,n,f)\nh=min(d,e,f)\nif x>=y:\n print(g)\nelse:\n print(h)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s035457721', 's098929030', 's177693862', 's283887866', 's293944506', 's302986497', 's377960766', 's486834913', 's543315995', 's560666514', 's678042010', 's751843800', 's847667896', 's889512550', 's943922139', 's993376928', 's047837268'] | [2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 3064.0, 2940.0, 3064.0] | [17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 18.0, 17.0, 17.0, 18.0, 18.0, 17.0, 18.0, 18.0, 17.0] | [243, 189, 195, 275, 275, 223, 242, 7, 279, 210, 43, 231, 243, 235, 225, 231, 165] |
p03373 | u161776322 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['\nA, B, C, X, Y = map(int, input().split())\n\nresult = []\n\nn = A*X + B*Y \nresult.append(n) \n\nn = C*min([X,Y])\nif X >= Y:\n n += (X-Y)*A \nelse:\n n += (Y-X)*B \nresult.append(n) \n\nn = C*max(X,Y)\nresult.append(n)\n\nprint(min(result))\n\n\n \n ', '\nA, B, C, X, Y = map(int, input().split())\n\nresult = []\n\nn = A*X + B*Y \nresult.append(n) \n\nn = C*min([X,Y])*2\nif X >= Y:\n n += (X-Y)*A \nelse:\n n += (Y-X)*B \nresult.append(n) \n\nn = C*max(X,Y)*2\nresult.append(n)\n\nprint(min(result))\n\n\n \n '] | ['Wrong Answer', 'Accepted'] | ['s241221360', 's012489977'] | [3060.0, 3060.0] | [17.0, 17.0] | [247, 251] |
p03373 | u164898518 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A, B, C, X, Y = tuple(map(int, input().split()))\n\ndef money(A, B, C, X, Y):\n \n axby = A*X + B*Y\n if max([A, B, C]) == C:\n return axby\n \n cxy = C*max([X,Y])*2\n if X < Y:\n abcxy = C*X*2 + (Y-X)*B\n else:\n abcxy = C*Y*2 + (X-Y)*A\n \n print([axby, cxy, abcxy])\n return min([axby, cxy, abcxy])\n \nprint(money(A, B, C, X, Y))\n', 'A, B, C, X, Y = tuple(map(int, input().split()))\n\ndef money(A, B, C, X, Y):\n \n axby = A*X + B*Y\n if max([A, B, C]) == C:\n return axby\n \n cxy = C*max([X,Y])*2\n if X < Y:\n abcxy = C*X*2 + (Y-X)*B\n else:\n abcxy = C*Y*2 + (X-Y)*A\n \n return min([axby, cxy, abcxy])\n \nprint(money(A, B, C, X, Y))\n'] | ['Wrong Answer', 'Accepted'] | ['s740937897', 's983572568'] | [3064.0, 3064.0] | [17.0, 17.0] | [369, 339] |
p03373 | u179019249 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A, B, C, X, Y = map(int, input().split())\n\nmin_sum = A*X + B*Y\nfor c in range(0, 200000+2, 2):\n sum = C*c\n if X - c/2 > 0:\n sum += A * (X - c/2)\n if Y - c/2 > 0:\n sum += B * (Y - c/2)\n if sum < min_sum:\n min_sum = sum\nprint(min_sum)\n', 'A, B, C, X, Y = map(int, input().split())\n\nmin_sum = 1e10\nfor c in range(0, 200000+2, 2):\n print(c)\n sum = C*c\n if X - c/2 > 0:\n sum += A * (X - c/2)\n if Y - c/2 > 0:\n sum += B * (Y - c/2)\n if sum < min_sum:\n min_sum = sum\nprint(min_sum)\n', "A, B, C, X, Y = map(int, input().split())\n\nmin_sum = int(float('inf'))\nfor c in range(0, 200000+2, 2):\n print(c)\n sum = C*c\n if X - c/2 > 0:\n sum += A * (X - c/2)\n if Y - c/2 > 0:\n sum += B * (Y - c/2)\n if sum < min_sum:\n min_sum = sum\nprint(min_sum)", 'A, B, C, X, Y = map(int, input().split())\n\nmin_sum = 9999999999\nfor c in range(100000+1):\n sum = C*c\n if X - c/2 > 0:\n sum += A * (X - c/2)\n if Y - c/2 > 0:\n sum += B * (Y - c/2)\n if sum < min_sum:\n min_sum = sum\nprint(min_sum)', 'A, B, C, X, Y = map(int, input().split())\n\nmin_sum = 9999999999\nfor c in range(0, 200000, 2):\n sum = C*c\n if X - c/2 > 0:\n sum += A * (X - c/2)\n if Y - c/2 > 0:\n sum += B * (Y - c/2)\n if sum < min_sum:\n min_sum = sum\nprint(min_sum)', 'A, B, C, X, Y = map(int, input().split())\n\nmin_sum = 9999999999\nfor c in range(200000+1):\n sum = C*c\n if X - c/2 > 0:\n sum += A * (X - c/2)\n if Y - c/2 > 0:\n sum += B * (Y - c/2)\n if sum < min_sum:\n min_sum = sum\nprint(min_sum)', 'A, B, C, X, Y = map(int, input().split())\n\nmin_sum = 1e10\nfor c in range(0, 300000+2, 2):\n print(c)\n sum = C*c\n if X - c/2 > 0:\n sum += A * (X - c/2)\n if Y - c/2 > 0:\n sum += B * (Y - c/2)\n if sum < min_sum:\n min_sum = sum\nprint(min_sum)\n', 'A, B, C, X, Y = map(int, input().split())\n\nmin_sum = A*X + B*Y\nfor c in range(0, 200000+2,2):\n sum = C*c\n if X - c/2 > 0:\n sum += A * (X - c/2)\n if Y - c/2 > 0:\n sum += B * (Y - c/2)\n if sum < min_sum:\n min_sum = sum\nprint(min_sum)', 'll A, B, C, X, Y;\n//---------------------------------------------------------------------------------------------------\nvoid _main() {\n cin >> A >> B >> C >> X >> Y;\n \n ll ans = infl;\n rep(ab, 0, 201010) {\n ll sm = C * ab;\n \n ll x = X - ab / 2;\n ll y = Y - ab / 2;\n \n if (0 < x) sm += x * A;\n if (0 < y) sm += y * B;\n \n chmin(ans, sm);\n }\n \n cout << ans << endl;\n}', 'A, B, C, X, Y = map(int, input().split())\n\nmin_sum = 9999999999\nfor c in range(0, 200000+2, 2):\n print(c)\n sum = C*c\n if X - c/2 > 0:\n sum += A * (X - c/2)\n if Y - c/2 > 0:\n sum += B * (Y - c/2)\n if sum < min_sum:\n min_sum = sum\nprint(min_sum)', 'A, B, C, X, Y = map(int, input().split())\n\nmin_sum = A*X + B*Y\nfor c in range(0, 100000+1):\n sum = 2*C*c\n if X - c > 0:\n sum += A * (X - c)\n if Y - c > 0:\n sum += B * (Y - c)\n if sum < min_sum:\n min_sum = sum\nprint(min_sum)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s120925818', 's228660615', 's280268611', 's355629357', 's419920369', 's528875848', 's534272913', 's853061477', 's904041577', 's965071020', 's504777308'] | [3064.0, 3936.0, 3064.0, 3060.0, 3060.0, 3188.0, 4320.0, 3064.0, 2940.0, 3936.0, 3060.0] | [143.0, 224.0, 19.0, 147.0, 137.0, 267.0, 282.0, 146.0, 17.0, 224.0, 89.0] | [266, 274, 286, 260, 264, 260, 274, 264, 424, 279, 256] |
p03373 | u189397279 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['import sys\nA, B, C, X, Y = map(int, sys.stdin.readline().split(" "))\nans = float("inf")\n\nfor i in range(X + 1):\n for j in range(Y + 1):\n k = max(X - i, Y - i) * 2\n ans = min(ans, A * i + B * j + C * k)\nprint(ans)', 'import sys\nA, B, C, X, Y = map(int, sys.stdin.readline().split(" "))\nans = float("inf")\n \nfor i in range(max(X, Y) * 2 + 1):\n j = X - i // 2\n if j < 0:\n j = 0\n k = Y - i // 2\n if k < 0:\n k = 0\n ans = min(ans, C * i + A * j + B * k)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s190209460', 's894794761'] | [3060.0, 3064.0] | [2103.0, 173.0] | [229, 271] |
p03373 | u202560873 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ["A, B, C, X, Y = [int(x) for x in input().split()]\n\nnum_A = 0\nnum_B = 0\nnum_AB = 0\nif A + B <= 2 * C:\n num_A = X\n num_B = Y\nelse:\n Z = min(X, Y)\n X = X - Z\n Y = Y - Z\n num_AB = 2 * Z\n if A >= 2 * C:\n num_AB += 2 * X\n else: # A < 2 * C\n num_A = X\n if B >= 2 * C:\n num_AB += 2 * Y\n else: # B < 2 * C\n num_B = Y\n\nans = A * num_A + B * num_B + C * num_AB\nprint(str(num_A) + ' ' + str(num_B) + ' ' + str(num_AB))\nprint(ans)", 'A, B, C, X, Y = [int(x) for x in input().split()]\n\nnum_A = 0\nnum_B = 0\nnum_AB = 0\nif A + B <= 2 * C:\n num_A = X\n num_B = Y\nelse: # A + B > 2 * C\n Z = min(X, Y)\n X = X - Z\n Y = Y - Z\n num_AB = 2 * Z\n\n if A >= 2 * C:\n num_AB += 2 * X\n else: # A < 2 * C\n\n num_A = X\n if B >= 2 * C:\n num_AB += 2 * Y\n else: # B < 2 * C\n num_B = Y\n\nans = A * num_A + B * num_B + C * num_AB\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s873687319', 's961030361'] | [9152.0, 9144.0] | [26.0, 31.0] | [475, 436] |
p03373 | u213854484 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A,B,C,X,Y = map(int,input().split())\np=5000000000\nfor i in list(range(0,max([X+1,Y+1]))):\n if p > max([X-i,0])*A+max([Y-i,0])*B+2*C*i:\n p=p\nprint(p)', 'A,B,C,X,Y = map(int,input().split())\np=5000000000\nfor i in list(range(0,max([X+1,Y+1]))):\n if p > max([X-i,0])*A+max([Y-i,0])*B+2*C*i:\n p=max([X-i,0])*A+max([Y-i,0])*B+2*C*i\nprint(p)'] | ['Wrong Answer', 'Accepted'] | ['s899638858', 's808447023'] | [6900.0, 6900.0] | [120.0, 200.0] | [158, 192] |
p03373 | u224156735 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,c,x,y=map(int,input().split())\nans=a*x+b*y\nfor i in range(x+1):\n for j in range(y+1):\n if a*i+j*b+(x+y-i+j)*c<num:\n ans=a*i+j*b+(x+y-i+j)*c\nprint(ans) \n ', 'a,b,c,x,y=map(int,input().split())\n\n_1=a*x+b*y\n\nif x>=y:\n _2=c*2*y+(x-y)*a\n _3=2*x*c\nelse:\n _2=c*2*x+(y-x)*b\n _3 = 2*y*c\n\nprint(min(_1,_2,_3) )'] | ['Runtime Error', 'Accepted'] | ['s432840400', 's330204057'] | [2940.0, 3060.0] | [17.0, 17.0] | [174, 148] |
p03373 | u292735000 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a, b, c, x, y = map(int, input().split())\n\ncount_min = x * a + y * b\nfor p_a in range(x + 1):\n for p_b in range(y + 1):\n for p_ab in range(max(x, y) * 2 + 1):\n if p_a + 0.5 * p_ab == x and p_b + 0.5 * p_ab == y:\n count = p_a * a + p_b * b + p_ab * c\n if count < count_min:\n count_min = count\n print(p_a, p_b, p_ab)\n\nprint(count_min)', 'ans_min = x * a + y * b\nfor i in range(100000):\n ans = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b\n if ans < ans_min:\n ans_min = ans\nprint(ans)', 'a, b, c, x, y = map(int, input().split())\n \nans_min = x * a + y * b\nfor i in range(100001):\n ans = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b\n if ans < ans_min:\n ans_min = ans\n \nprint(ans_min)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s034934484', 's696436201', 's005581018'] | [3064.0, 2940.0, 3060.0] | [2104.0, 18.0, 102.0] | [421, 162, 212] |
p03373 | u334792253 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,mix,n_a,n_b=input().rstrip().split()\na=int(a)\nb=int(b)\nmix=int(mix)\nn_a=int(n_a)\nn_b=int(n_b)\nfee=a*n_a+b*n_b\nif a+b<=2*mix:\n print(fee)\nelse:\n fee_mix=0\n if n_a>=n_b:\n fee_mix=n_b*mix+(n_a-n_b)*a\n else:\n fee_mix=n_a*mix+(n_b-n_a)*b\n print(fee_mix)', 'a,b,mix,n_a,n_b=input().rstrip().split()\na=int(a)\nb=int(b)\nmix=int(mix)\nn_a=int(n_a)\nn_b=int(n_b)\nx=[n_a,n_b]\nfee=a*n_a+b*n_b\nfee_a=2*mix*max(x)\nfee_mix=0\nif n_a>=n_b:\n fee_mix=n_b*2*mix+(n_a-n_b)*a\nelse:\n fee_mix=n_a*2*mix+(n_b-n_a)*b\nprint(min(fee,fee_a,fee_mix))'] | ['Wrong Answer', 'Accepted'] | ['s345562434', 's548078721'] | [3188.0, 3064.0] | [19.0, 18.0] | [281, 271] |
p03373 | u354527070 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a, b, c, x, y = map(int, input().split(" "))\nab = a * x + b * y\n\nabc = min(c * 2 * y + a * (x - y), c * 2 * x + b * (y - x))\n\ncc = c * 2 * max(x, y)\nprint(min(ab, abc, cc))', 'a, b, c, x, y = map(int, input().split(" "))\nprice = []\nfor i in range(0, x + 1):\n for j in range(0, y + 1):\n if x - i == y - j:\n k = (x-i)*2\n price.append(a * i + b * j + c * k)\n print(str(i) + " " + str(j) + " " + str(k) + " ")\n\nprint(min(price))', 'a, b, c, x, y = map(int, input().split(" "))\nab = a * x + b * y\n\nif x >= y:\n abc = c * 2 * y + a * (x - y)\nelse:\n abc = c * 2 * x + b * (y - x)\n\ncc = c * 2 * max(x, y)\nprint(min(ab, abc, cc))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s377485331', 's602788855', 's310941187'] | [9104.0, 9116.0, 9192.0] | [28.0, 2205.0, 28.0] | [172, 291, 197] |
p03373 | u374103100 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['import sys\n\na, b, c, x, y = input().split(" ")\n\na = int(a)\nb = int(b)\nc = int(c)\nx = int(x)\ny = int(y)\n\n# print(a)\n# print(b)\n# print(c)\n# print(x)\n# print(y)\n#\n\nbest_price = sys.maxsize\n\nfor i in range(0, max(x + 1, y + 1) * 2 + 1, 2):\n rest_a = x\n rest_b = y\n\n if i // 2 >= x:\n rest_a = 0\n else:\n rest_a = x - i // 2\n\n if i // 2 >= y:\n rest_b = 0\n else:\n rest_b = y - i // 2\n\n price = rest_a * a + rest_b * b + c * i\n if price < best_price:\n best_price = price\n else:\n print(best_price)\n # break\n # print("buy a = " + str(rest_a) + ", b = " + str(rest_b) + ", c = " + str(i) + ", price = " + str(price))\n', 'import sys\n\na, b, c, x, y = map(int, input().split())\n\nbest_price = sys.maxsize\n\n\nfor i in range(0, max(x, y) * 2 + 1, 2):\n rest_a = x\n rest_b = y\n\n if i // 2 >= x:\n rest_a = 0\n else:\n rest_a = x - i // 2\n\n if i // 2 >= y:\n rest_b = 0\n else:\n rest_b = y - i // 2\n\n price = rest_a * a + rest_b * b + c * i\n if price < best_price:\n best_price = price\n # print("buy a = " + str(rest_a) + ", b = " + str(rest_b) + ", c = " + str(i) + ", price = " + str(price))\n\nprint(best_price)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s405009019', 's023579132'] | [4212.0, 3064.0] | [189.0, 108.0] | [685, 539] |
p03373 | u378157957 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['import math\n\n__DEUBG__ = 1\n\na, b, c, x, y = map(int, input().split())\n\nminimum = a * x + b * y\n\nif x > y:\n for i in range(x+1):\n N_a = i\n N_c = 2 * (x - i)\n if (y-N_c/2) < 0:\n N_b = 0\n else:\n N_b = y - int(N_c/2)\n tmp = a * N_a + b * N_b + c * N_c\n if tmp < minimum:\n minimum = tmp\n if __DEUBG__:\n print(N_a, N_b, N_c)\nelse:\n for i in range(y+1):\n N_b = i\n N_c = 2 * (y - i)\n if (x-N_c/2) < 0:\n N_a = 0\n else:\n N_a = x - int(N_c/2)\n tmp = a * N_a + b * N_b + c * N_c\n if tmp < minimum:\n minimum = tmp\n if __DEUBG__:\n print(N_a, N_b, N_c)\n\nprint(minimum)', 'import math\n\n__DEUBG__ = 0\n\na, b, c, x, y = map(int, input().split())\n\nminimum = a * x + b * y\n\nif x > y:\n for i in range(x+1):\n N_a = i\n N_c = 2 * (x - i)\n if (y-N_c/2) < 0:\n N_b = 0\n else:\n N_b = y - int(N_c/2)\n tmp = a * N_a + b * N_b + c * N_c\n if tmp < minimum:\n minimum = tmp\n if __DEUBG__:\n print(tmp, N_a, N_b, N_c)\nelse:\n for i in range(y+1):\n N_b = i\n N_c = 2 * (y - i)\n if (x-N_c/2) < 0:\n N_a = 0\n else:\n N_a = x - int(N_c/2)\n tmp = a * N_a + b * N_b + c * N_c\n if tmp < minimum:\n minimum = tmp\n if __DEUBG__:\n print(tmp, N_a, N_b, N_c)\n\nprint(minimum)'] | ['Wrong Answer', 'Accepted'] | ['s043768040', 's993361331'] | [4296.0, 3064.0] | [195.0, 117.0] | [761, 771] |
p03373 | u382303205 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,c,x,y=map(int,input().split())\n\nprint(min(a*x+b*y, c*2*max(x,y)))', 'a,b,c,x,y=map(int,input().split())\n\nif x<y:\n x,y=y,x\n a,b=b,a\n\nprint(min(a*x+b*y, 2*c*x, 2*c*y-a*(x-y)))', 'a,b,c,x,y=map(int,input().split())\n\nif x<y:\n x,y=y,x\n a,b=b,a\n\nprint(min(a*x+b*y, 2*c*x, 2*c*y+a*(x-y)))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s616708366', 's937940257', 's491654684'] | [3060.0, 3060.0, 3060.0] | [19.0, 17.0, 17.0] | [69, 110, 110] |
p03373 | u392029857 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A, B, C, X, Y = map(int, input().split())\nif X < Y:\n ab = range(Y + 1)\n p = X\nelse:\n ab = range(X + 1)\n p = Y\nmin_price = A*X+B*Y\nfor i in ab:\n if i <= p\n price = A*(X-i)+B*(Y-i)+(2*C*i)\n if min_price > price:\n min_price = price\n else:\n if p == X:\n price = B*(Y-i)+(2*C*i)\n if min_price > price:\n min_price = price\n else:\n price = A*(X-i)+(2*C*i)\n if min_price > price:\n min_price = price\nprint(min_price)', 'A, B, C, X, Y = map(int, input().split())\nif X < Y:\n cn = range(Y+1)\n p = X\nelse:\n cn = range(X+1)\n p = Y\nmin_price = A*X + B*Y\nfor i in cn:\n if i <= p:\n price = (A*(X-i)+C*i)+(B*(Y-i)+C*i)\n if min_price > price:\n min_price = price\n else:\n if p == X:\n price = C*i+(B*(Y-i)+C*i)\n if min_price > price:\n min_price = price\n else:\n price = (A*(X-i)+C*i) + C*i\n if min_price > price:\n min_price = price\nprint(min_price)'] | ['Runtime Error', 'Accepted'] | ['s634971292', 's151070790'] | [2940.0, 3064.0] | [18.0, 82.0] | [536, 545] |
p03373 | u416223629 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A,B,C,X,Y=map(int,input().split())\nprice=[]\nfor i in range(X+1):\n for j in range(Y+1):\n k=max(X-i,Y-j)*2\n price.append(A*i+B*j+C*k)\nprint(price)\nprint(min(price))', 'A,B,C,X,Y=map(int,input().split())\nprice=[]\nfor i in range(100000+1):\n price.append(i*2*C+max(0,X-i)*A+max(0,Y-i)*B)\n\nprint(min(price))'] | ['Wrong Answer', 'Accepted'] | ['s572720718', 's684638253'] | [135980.0, 7096.0] | [2116.0, 104.0] | [179, 138] |
p03373 | u423966555 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,c,x,y = map(int, input().split())\n\nans = 0\nif a+b < 2*c:\n if x <= y:\n ans += x*(a+b)\n if b < 2*c:\n ans += b*(y-x)\n else:\n ans += 2*c*(y-x)\n else:\n ans += y*(a+b)\n if a < 2*c:\n ans += a*(x-y)\n else:\n ans += 2*c*(x-y)\nelse:\n if x <= y:\n ans += 2*c*x\n if b < 2*c:\n ans += b*(y-x)\n else:\n ans += 2*c*(y-x)\n else:\n ans += 2*c*(x+y)\n\nprint(ans)\n', 'a,b,c,x,y = map(int, input().split())\n\nans = 0\nif a+b < 2*c:\n if x <= y:\n ans += x*(a+b)\n if b < 2*c:\n ans += b*(y-x)\n else:\n ans += 2*c*(y-x)\n else:\n ans += y*(a+b)\n if a < 2*c:\n ans += a*(x-y)\n else:\n ans += 2*c*(x-y)\nelse:\n if x <= y:\n ans += 2*c*x\n if b < 2*c:\n ans += b*(y-x)\n else:\n ans += 2*c*(y-x)\n else:\n ans += 2*c*y\n if a < 2*c:\n ans += a*(x-y)\n else:\n ans += 2*c*(x-y)\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s257283134', 's630049082'] | [9088.0, 9064.0] | [29.0, 29.0] | [491, 576] |
p03373 | u501643136 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A, B, C, X, Y = map(int,inut().split())\nif(A + B >= 2 * C):\n if(X >= Y):\n print(C * 2 * Y + (X - Y) * min(A, 2 * C))\n else :\n print(C * 2 * X + (Y - X) * min(B, 2 * C))\nelse:\n print(A * X + B * Y)', 'A, B, C, X, Y = map(int,input().split())\nif(A + B >= 2 * C):\n if(X >= Y):\n print(C * 2 * Y + (X - Y) * min(A, 2 * C))\n else :\n print(C * 2 * X + (Y - X) * min(B, 2 * C))\nelse:\n print(A * X + B * Y)'] | ['Runtime Error', 'Accepted'] | ['s295322872', 's507270869'] | [3064.0, 3060.0] | [17.0, 18.0] | [205, 206] |
p03373 | u503181529 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['\nA, B, C, X, Y = [int(x) for x in input().split()]\n\n\ndef r(a, b, c, x, y):\n print(a, b, c, x, y)\n if x == 0 and y == 0:\n return 0\n if x == 0:\n return min(y*b, 2*y*c)\n if y == 0:\n return min(x*a, 2*x*c)\n if (a + b) / 2 < c:\n return a*x+b*y\n else:\n z = min(x, y) * 2\n x = x - z/2\n y = y - z/2\n return r(a, b, c, x, y) + z*c\n\n\nprint(int(r(A, B, C, X, Y)))', 'A, B, C, X, Y = [int(x) for x in input().split()]\n\ndef r(a, b, c, x, y):\n if x == 0 and y == 0:\n return 0\n if x == 0:\n return min(y*b, 2*y*c)\n if y == 0:\n return min(x*a, 2*x*c)\n if (a + b) / 2 < c:\n return a*x+b*y\n else:\n z = min(x, y) * 2\n x = x - z/2\n y = y - z/2\n return r(a, b, c, x, y) + z*c\n\n\nprint(int(r(A, B, C, X, Y)))'] | ['Wrong Answer', 'Accepted'] | ['s217836653', 's706738018'] | [3064.0, 3064.0] | [18.0, 20.0] | [426, 399] |
p03373 | u508405635 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['import sys\nA, B, C, X, Y = map(int,input().split())\n \nminf = sys.maxsize\nX1 = X\nY1 = Y\n \n \nfor i in range(0, max(X,Y)+1):\n price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C\n \n \nprint(min(price))', 'import sys\nA, B, C, X, Y = map(int,input().split())\n \nminf = sys.maxsize\nX1 = X\nY1 = Y\n \nfor i in range(0, max(X,Y)+1):\n price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C \nprint(min(price))', 'A, B, C, X, Y = map(int, input().split())\n\n\n\n\n\n# l = []\n# for j in range(max(X,Y)+1):\n# if j <= X+Y:\n# l.append(A*X + B*Y + (C-A*0.5-B*0.5)*j)\n\n# print(int(min(l)))\n\nX1 = X\nY1 = Y\nprice = []\nfor i in range(0, max(X,Y)+1):\n price.append(max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C) \nprint(min(price))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s442540939', 's602191524', 's585241637'] | [3064.0, 3060.0, 7096.0] | [94.0, 93.0, 103.0] | [193, 188, 478] |
p03373 | u509739538 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,c,x,y=readInts()\nfor i in range(max(x,y)*2+1,2):\n\tans=min(ans,max(x-i//2,0)*a+max(y-i//2,0)*b+i*c)\nprint(ans)\n\n', 'import math\nimport queue\nfrom collections import defaultdict\n \ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\ndef factorization(n):\n\tres = []\n\tif n%2==0:\n\t\tres.append(2)\n\tfor i in range(3,math.floor(n//2)+1,2):\n\t\tif n%i==0:\n\t\t\tc = 0\n\t\t\tfor j in res:\n\t\t\t\tif i%j==0:\n\t\t\t\t\tc=1\n\t\t\tif c==0:\n\t\t\t\tres.append(i)\n\treturn res\ndef fact2(n):\n\tp = factorization(n)\n\tres = []\n\tfor i in p:\n\t\tc=0\n\t\tz=n\n\t\twhile 1:\n\t\t\tif z%i==0:\n\t\t\t\tc+=1\n\t\t\t\tz/=i\n\t\t\telse:\n\t\t\t\tbreak\n\t\tres.append([i,c])\n\treturn res\ndef fact(n):\n\tans = 1\n\tm=n\n\tfor _i in range(n-1):\n\t\tans*=m\n\t\tm-=1\n\treturn ans\ndef comb(n,r):\n\tif n<r:\n\t\treturn 0\n\tl = min(r,n-r)\n\tm=n\n\tu=1\n\tfor _i in range(l):\n\t\tu*=m\n\t\tm-=1\n\treturn u//fact(l)\ndef printQueue(q):\n\tr=qb\n\tans=[0]*r.qsize()\n\tfor i in range(r.qsize()-1,-1,-1):\n\t\tans[i] = r.get()\n\tprint(ans)\ndef dq():\n\treturn queue.deque()\nclass UnionFind():\n\tdef __init__(self, n):\n\t\tself.n = n\n\t\tself.parents = [-1]*n\n\n\tdef find(self, x): # root\n\t\tif self.parents[x]<0:\n\t\t\treturn x\n\t\telse:\n\t\t\tself.parents[x] = self.find(self.parents[x])\n\t\t\treturn self.parents[x]\n\n\tdef union(self,x,y):\n\t\tx = self.find(x)\n\t\ty = self.find(y)\n\n\t\tif x==y:\n\t\t\treturn\n\n\t\tif self.parents[x]>self.parents[y]:\n\t\t\tx,y = y,x\n\n\t\tself.parents[x]+=self.parents[y]\n\t\tself.parents[y]=x\n\n\tdef size(self,x):\n\t\treturn -1*self.parents[self.find(x)]\n\n\tdef same(self,x,y):\n\t\treturn self.find(x)==self.find(y)\n\n\tdef members(self,x): # much time\n\t\troot = self.find(x)\n\t\treturn [i for i in range(self.n) if self.find(i)==root]\n\n\tdef roots(self):\n\t\treturn [i for i,x in enumerate(self.parents) if x<0]\n\n\tdef group_count(self):\n\t\treturn len(self.roots())\n\n\tdef all_group_members(self):\n\t\treturn {r: self.members(r) for r in self.roots()} # 1~n\ndef bitArr(n):\n\tx = 1\n\tzero = "0"*n\n\tans = []\n\tans.append([0]*n)\n\tfor i in range(2**n-1):\n\t\tans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))\n\t\tx+=1\n\treturn ans;\ndef arrsSum(a1,a2):\n\tfor i in range(len(a1)):\n\t\ta1[i]+=a2[i]\n\treturn a1\n\na,b,c,x,y = readInts()\n\nans = 1000000000000000000\n\n\nfor i in range(0,max(x,y)*2+1,2):\n\tA = max(x - i//2,0)\n\tB = max(y - i//2,0)\n\tmoney = A*a+B*b+i*c\n\tans = min(ans,money)\n\nprint(ans)\n\n'] | ['Runtime Error', 'Accepted'] | ['s806075200', 's228199161'] | [2940.0, 4080.0] | [18.0, 138.0] | [115, 2289] |
p03373 | u514383727 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a, b, c, x, y = list(map(int, input().split()))\n\na_sum = a * x\nb_sum = b * y\nc_sum = c * (x+y)\nprice = 0\n\nif a_sum + b_sum > c_sum:\n num = min(x, y)\n price += num * c * 2\n x -= num\n y -= num\n print(price)\n if x > 0:\n if a < c * 2:\n price += a * x\n else:\n price += c * 2 * x\n if y > 0:\n if b < c * 2:\n price += b * y\n else:\n price += c * 2 * y\nelse:\n price += a*x + b*y\nprint(price)\n', 'a, b, c, x, y = list(map(int, input().split()))\n\na_sum = a * x\nb_sum = b * y\nc_sum = c * (x+y)\nprice = 0\n\nif a_sum + b_sum > c_sum:\n num = min(x, y)\n price += num * c * 2\n x -= num\n y -= num\n if x > 0:\n if a < c * 2:\n price += a * x\n else:\n price += c * 2 * x\n if y > 0:\n if b < c * 2:\n price += b * y\n else:\n price += c * 2 * y\nelse:\n price += a*x + b*y\nprint(price)'] | ['Wrong Answer', 'Accepted'] | ['s975624407', 's504681621'] | [3064.0, 3064.0] | [17.0, 18.0] | [478, 460] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.