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
p02727
u620464724
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['import sys\nsys.setrecursionlimit(4100000)\n\nx,y,a,b,c = map(int,input(),split())\np = sort(list(map(int,input(),split())))\nq = sort(list(map(int,input(),split())))\nr = list(map(int,input(),split()))\nans = 0\n\nfor k in range(1,x+1):\n r.append(p[-k])\nfor v in range(1,y+1):\n r.append(p[-v])\n\nrs = sort(r)\n\nfor i in range(1,X+Y+1):\n ans += rs[-i]\nprint(str(ans))', 'x,y,a,b,c = map(int,input(),split())\np = sort(list(map(int,input(),split())))\nq = sort(list(map(int,input(),split())))\nr = list(map(int,input(),split()))\nans = 0\n\nfor k in range(1,x+1):\n r.append(p[-k])\nfor v in range(1,y+1):\n r.append(p[-v])\n\nrs = sort(r)\n\nfor i in range(1,X+Y+1):\n ans += rs[-i]\nprint(str(ans))', 'import sys\nsys.setrecursionlimit(4100000)\n\nx,y,a,b,c = map(int,input().split())\np = sorted(list(map(int,input().split())))\nq = sorted(list(map(int,input().split())))\nr = list(map(int,input().split()))\nans = 0\n\nfor k in range(1,x+1):\n r.append(p[-k])\nfor v in range(1,y+1):\n r.append(q[-v])\n\nrs = sorted(r)\n\nfor i in range(1,x+y+1):\n ans += rs[-i]\nprint(str(ans))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s688941157', 's701106743', 's678434347']
[3064.0, 3064.0, 23200.0]
[17.0, 18.0, 320.0]
[365, 322, 371]
p02727
u621225737
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = list(map(int,input().split()))\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\nZ = 0\nwhlie True:\n if max(p[X - 1], q[Y - 1], r[Z]) == r[Z]:\n if p[X - 1] < q[Y - 1]:\n X -= 1\n Z += 1\n else:\n Y -= 1\n Z += 1\n else:\n break\n\nprint(sum(p[:X]) + sum(q[:Y]) + sum(r[:Z]))\n ', 'X, Y, A, B, C = list(map(int,input().split()))\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n \np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n \nZ = 0\nwhile True:\n if p[X - 1] < r[Z]:\n X -= 1\n Z += 1\n elif q[Y - 1] < r[Z]:\n Y -= 1\n Z += 1\n else:\n break\n \nprint(sum(p[:X]) + sum(q[:Y]) + sum(r[:Z]))', 'X, Y, A, B, C = list(map(int,input().split()))\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n \np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n \nZ = 0\nwhile Z < C:\n if min(p[X - 1], q[Y - 1], r[Z]) < r[Z]:\n if p[X - 1] < q[Y - 1]:\n X -= 1\n Z += 1\n \telse:\n Y -= 1\n Z += 1\n continue\n break\n \nprint(sum(p[:X]) + sum(q[:Y]) + sum(r[:Z]))', 'X, Y, A, B, C = list(map(int,input().split()))\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n \np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n \nZ = 0\nwhile True:\n if p[X - 1] < r[Z]:\n X -= 1\n Z += 1\n else if q[Y - 1] < r[Z]:\n Y -= 1\n Z += 1\n else:\n break\n \nprint(sum(p[:X]) + sum(q[:Y]) + sum(r[:Z]))', 'X, Y, A, B, C = list(map(int,input().split()))\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\nZ = 0\nwhile True:\n if max(p[X - 1], q[Y - 1], r[Z]) == r[Z]:\n if p[X - 1] < q[Y - 1]:\n X -= 1\n Z += 1\n else:\n Y -= 1\n Z += 1\n else:\n break\n\nprint(sum(p[:X]) + sum(q[:Y]) + sum(r[:Z]))', 'X, Y, A, B, C = list(map(int,input().split()))\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n \np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n \np.append(float("inf"))\nq.append(float("inf")) \n\nZ = 0\nwhile Z < C:\n if min(p[X - 1], q[Y - 1]) < r[Z]:\n if p[X - 1] < q[Y - 1]:\n X -= 1\n Z += 1\n else:\n Y -= 1\n Z += 1\n continue\n break\n \nprint(sum(p[:X]) + sum(q[:Y]) + sum(r[:Z]))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s078200605', 's138325295', 's258574971', 's446775060', 's898548112', 's300160557']
[3060.0, 22560.0, 3064.0, 3064.0, 22720.0, 23328.0]
[17.0, 235.0, 17.0, 17.0, 268.0, 297.0]
[436, 390, 436, 393, 431, 479]
p02727
u646130340
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\npx = p[:X]\nqy = q[:Y]\nprint(qy)\nwhile r and min(px[-1], qy[1]) < r[0]:\n px.sort(reverse=True)\n qy.sort(reverse=True)\n if px[-1] < qy[-1]:\n px[-1] = r[0]\n r.pop(0)\n else:\n qy[-1] = r[0]\n r.pop(0)\n\nprint(sum(px) + sum(qy))', 'X, Y, A, B, C = map(int, input().split())\np = sorted(list(map(int, input().split())), reverse=True)[:X]\nq = sorted(list(map(int, input().split())), reverse=True)[:Y]\nr = list(map(int, input().split()))\nans = sum(sorted(p + q + r, reverse=True)[:X + Y])\nprint(ans)']
['Runtime Error', 'Accepted']
['s125422503', 's959931427']
[22720.0, 22504.0]
[2105.0, 235.0]
[450, 263]
p02727
u647287452
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\np = sorted(map(int, input().split()), reverse=True)[: X]\nq = sorted(map(int, input().split()), reverse=True)[: Y]\nr = list(map(int, input().split()))\n\nall = p + q + r\nall.sort(reverse=True)\nprint((all[:X + Y]))', 'X, Y, A, B, C = map(int, input().split())\np = sorted(map(int, input().split()), reverse=True)[: X]\nq = sorted(map(int, input().split()), reverse=True)[: Y]\nr = list(map(int, input().split()))\n\nall = p + q + r\nall.sort(reverse=True)\nprint(sum(all[:X + Y]))']
['Wrong Answer', 'Accepted']
['s093117325', 's696048376']
[26016.0, 22548.0]
[262.0, 242.0]
[252, 255]
p02727
u649326276
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c = list(map(int,input().split()));\np = list(map(int,input().split()));\nq = list(map(int,input().split()));\nr = list(map(int,input().split()));\n\numami = [[0]*2 for i in range(a+b+c)];\n\nfor i in range(a) :\n umami[i][0] = 0;\n umami[i][1] = p[i];\nfor i in range(b) :\n umami[a+i][0] = 1;\n umami[a+i][1] = q[i];\nfor i in range(c) :\n umami[a+b+i][0] = 2;\n umami[a+b+i][1] = r[i];\n\numami.sort(key=lambda x:x[1]);\numami.reverse();\ni = 0;\nj = 0;\nnumr = x;\nnumg = y;\nans = 0;\n\nwhile i < x+y :\n if umami[j][0] == 0 and numr == 0 :\n j += 1;\n if umami[j][0] == 1 and numg == 0 :\n j += 1;\n else :\n if umami[j][0] == 0 :\n numr -= 1;\n if umami[j][0] == 1 :\n numg -= 1;\n ans += umami[j][1];\n i += 1;\n j += 1;\n print(numr,numg,ans);\n\nprint(ans);', 'x,y,a,b,c = list(map(int,input().split()));\np = list(map(int,input().split()));\nq = list(map(int,input().split()));\nr = list(map(int,input().split()));\n\numami = [[0]*2 for i in range(a+b+c)];\num = [0]*(x+y+c);\n\nfor i in range(a) :\n umami[i][0] = 0;\n umami[i][1] = p[i];\n\nfor i in range(b) :\n umami[a+i][0] = 1;\n umami[a+i][1] = q[i];\nfor i in range(c) :\n umami[a+b+i][0] = 2;\n umami[a+b+i][1] = r[i];\n\np.sort();\np.reverse();\nq.sort();\nq.reverse();\nr.sort();\nr.reverse();\nfor i in range(x) :\n um[i] = p[i];\nfor i in range(y) :\n um[i+x] = q[i];\nfor i in range(c) :\n um[i+x+y] = r[i];\n\num.sort();\num.reverse();\n\numami.sort(key=lambda x:x[1]);\numami.reverse();\ni = 0;\nj = 0;\nnumr = x;\nnumg = y;\nans = 0;\n\nwhile i < x+y :\n if umami[j][0] == 0 and numr == 0 :\n j += 1;\n if umami[j][0] == 1 and numg == 0 :\n j += 1;\n else :\n if umami[j][0] == 0 :\n numr -= 1;\n if umami[j][0] == 1 :\n numg -= 1;\n ans += umami[j][1];\n i += 1;\n j += 1;\n\nans = 0;\nfor i in range(x+y) :\n ans += um[i];\n\nprint(ans);']
['Wrong Answer', 'Accepted']
['s766519391', 's797448300']
[51476.0, 53520.0]
[1112.0, 969.0]
[832, 1095]
p02727
u652892331
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['na, nb, a, b, c = map(int, input().split())\nab_list = [0 for i in range(na + nb)]\nab_list[:na] = sorted(list(map(int, input().split())), reverse=True)[:na]\nab_list[na:] = sorted(list(map(int, input().split())), reverse=True)[:nb]\nc_list = sorted(list(map(int, input().split())), reverse=True)[:min(na + nb, c)]\n\nab_list.sort()\n\nc_max = c_list[-1]\nab_index = 0\nfor index in range(len(ab_list)):\n if c_max <= ab_list[index]:\n ab_index = index\n break\n\nab_list[:ab_index] = sorted(ab_list[:ab_index] + c_list[-ab_index:])[:ab_index]\n\nprint(sum(ab_list))', 'na, nb, a, b, c = map(int, input().split())\nab_list = [0 for i in range(na + nb)]\nab_list[:na] = sorted(list(map(int, input().split())), reverse=True)[:na]\nab_list[na:] = sorted(list(map(int, input().split())), reverse=True)[:nb]\nab_list += sorted(list(map(int, input().split())), reverse=True)[:min(na + nb, c)]\n\nab_list.sort(reverse=True)\n\nprint(sum(ab_list[:na + nb]))']
['Wrong Answer', 'Accepted']
['s620306275', 's301692936']
[22492.0, 22212.0]
[269.0, 254.0]
[566, 371]
p02727
u677121387
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c = map(int,input().split())\np = [int(i) for i in input().split()]\nq = [int(i) for i in input().split()]\nr = [int(i) for i in input().split()]\np.sort(reverse=True)\nq.sort(reverse=True)\nfor i in range(x): r.append(p[i])\nfor i in range(y): r.append(q[i])\nr.sort(reverse=True)\nprint(sum(r[:x+y])', 'x,y,a,b,c = map(int,input().split())\np = [int(i) for i in input().split()]\nq = [int(i) for i in input().split()]\nr = [int(i) for i in input().split()]\np.sort(reverse=True)\nq.sort(reverse=True)\nfor i in range(x): r.append(p[i])\nfor i in range(y): r.append(q[i])\nr.sort(reverse=True)\nprint(sum(r[:x+y]))']
['Runtime Error', 'Accepted']
['s715396837', 's939394388']
[3064.0, 23644.0]
[17.0, 275.0]
[300, 301]
p02727
u686036872
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\n\nP = list(map(int, input().split()))\nQ = list(map(int, input().split()))\nR = list(map(int, input().split()))\n \nP.sort(reverse=True)\nQ.sort(reverse=True)\nR.sort(reverse=True)\n\nA=P[:X]+Q[:Y]+R\n\nA.sort(reverse=True)\n\nprint(A[X+Y])', 'N, Y, A, B, C = map(int, input().split())\n\nP = list(map(int, input().split()))\nQ = list(map(int, input().split()))\nR = list(map(int, input().split()))\n \nP.sort(reverse=True)\nQ.sort(reverse=True)\nR.sort(reverse=True)\n\nA=P[:X]+Q[:Y]+R\n\nA.sort(reverse=True)\n\nprint(A[X+Y])', 'X, Y, A, B, C = map(int, input().split())\n\nP = list(map(int, input().split()))\nQ = list(map(int, input().split()))\nR = list(map(int, input().split()))\n \nP.sort(reverse=True)\nQ.sort(reverse=True)\nR.sort(reverse=True)\n\nA=P[:X]+Q[:Y]+R\n\nA.sort(reverse=True)\n\nprint(sum(A[:X+Y]))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s468242445', 's594000399', 's561511553']
[22720.0, 22720.0, 22720.0]
[254.0, 194.0, 259.0]
[276, 276, 282]
p02727
u693007703
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = [int(i) for i in input().split()]\nreds = sorted([int(i) for i in input().split()], reverse=True)\ngreens = sorted([int(i) for i in input().split()], reverse=True)\nclears = sorted([int(i) for i in input().split()], reverse=True)\n\nclear_acc = [0]\n\nfor i in clears:\n clear_acc.append(rr[-1]+i)\n \nreds = reds[:X]\ngreens = greens[:Y]\n\nall_apples = sorted(reds+greens)\n\napple_sum = [sum(all_apples)]\n\n\nfor i in all_apples:\n apple_sum.append(apple_sum[-1]-i)\n \n\noutput = []\n\nfor i in range(min(X+Y, C+1)):\n output.append(apple_sum[i] + clear_acc[i])\n\nprint(max(output))', 'X, Y, A, B, C = [int(i) for i in input().split()]\nreds = sorted([int(i) for i in input().split()], reverse=True)\ngreens = sorted([int(i) for i in input().split()], reverse=True)\nclears = sorted([int(i) for i in input().split()], reverse=True)\n\nclear_acc = [0]\n\nfor i in clears:\n clear_acc.append(clear_acc[-1]+i)\n \nreds = reds[:X]\ngreens = greens[:Y]\n\nall_apples = sorted(reds+greens)\n\napple_sum = [sum(all_apples)]\n\n\nfor i in all_apples:\n apple_sum.append(apple_sum[-1]-i)\n \n\noutput = []\n\nfor i in range(min(X+Y, C+1)):\n output.append(apple_sum[i] + clear_acc[i])\n\nprint(max(output))']
['Runtime Error', 'Accepted']
['s944686152', 's538053241']
[22460.0, 33568.0]
[209.0, 331.0]
[596, 603]
p02727
u693391925
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x, y, a, b, c = map(int, input().split())\narrayP = list(map(int, input().split()))\narrayQ = list(map(int, input().split()))\narrayR = list(map(int, input().split()))\narrayP.sort(reverse=True)\narrayQ.sort(reverse=True)\narrayR.sort(reverse=True)\narrayAns = []\nfor i in range(x):\n arrayAns.append(int(arrayP[i]))\nfor i in range(y):\n arrayAns.append(int(arrayQ[i]))\narrayAns.sort()\nfor i in range(len(arrayAns)):\n if arrayAns[i] <= int(arrayR[i]):\n arrayAns[i] = int(arrayR[i])\n else:\n break\nprint(sum(arrayAns))', 'X,Y,A,B,C = map(int, input().split())\n\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\n\np.sort(reverse=True)\nq.sort(reverse=True)\n\nhoge=p[:X]+q[:Y]+r\nhoge.sort(reverse=True)\nprint(sum(hoge[:X+Y]))\n\n\n']
['Runtime Error', 'Accepted']
['s170764236', 's778158470']
[23328.0, 23328.0]
[297.0, 233.0]
[533, 259]
p02727
u693933222
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x, y, a, b, c = map(int, input().split())\np = sorted(list(map(int, input().split())),reverse = True)\nq = sorted(list(map(int, input().split())),reverse = True)\nr = sorted(list(map(int, input().split())),reverse = True)\n\n\nans = 0\n\nwhile (p[0] > r[0]):\n ans += p.pop(0)\n x -= 1\n if (x == 0):\n break\nwhile (q[0] > r[0]):\n ans += q.pop(0)\n y-=1\n if (y == 0):\n break\n\nif (x == 0 and y == 0):\n print(ans)\nelse:\n aps = sorted(p[0: x] + q[0: y] + r[0: x + y], reverse=True)\n print(aps)\n print(ans+sum(aps[0:x+y]))\n\n', 'x, y, a, b, c = map(int, input().split())\np = sorted(list(map(int, input().split())),reverse = True)\nq = sorted(list(map(int, input().split())),reverse = True)\nr = sorted(list(map(int, input().split())),reverse = True)\n\npx = p[:x]\nqx = q[:y]\n\naps = sorted(px + qx + r, reverse=True)\n\nprint(sum(aps[0:x+y]))\n\n']
['Wrong Answer', 'Accepted']
['s648792535', 's863454825']
[30988.0, 23584.0]
[2105.0, 258.0]
[551, 308]
p02727
u698919163
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X,Y,A,B,C = map(int,input().split())\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\nalist = []\nans = 0\n\nfor i in range(X):\n alist.append(p[i])\n \nfor j in range(Y):\n alist.append(q[j])\n \nalist.sort(reverse=True)\nans = sum(alist)\n\na2 = [alist[0]]\nr2 = [r[0]]\n\nfor i in range(1,len(alist)):\n a2.append(alist[i]+a2[i-1])\n r2.append(r[i]+r2[i-1])\n\nans = a2[-1]\n\nfor i in range(C-1):\n ans = max(ans,a2[i]+r2[C-i-1])\n \nprint(ans)', 'X,Y,A,B,C = map(int,input().split())\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\nalist = []\nans = 0\n\nfor i in range(X):\n alist.append(p[i])\n \nfor j in range(Y):\n alist.append(q[j])\n \nfor k in range(C):\n alist.append(r[k])\n \nalist.sort(reverse=True)\n \nfor k in range(X+Y):\n ans += alist[k]\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s740694993', 's337623177']
[27312.0, 23328.0]
[375.0, 301.0]
[569, 450]
p02727
u703214333
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['import sys\n#from collections import deque\ninput = sys.stdin.buffer.readline\n\nx, y, a, b, c = map(int, input().split())\np = sorted(list(map(int,input().split())),reverse=True)\nq = sorted(list(map(int,input().split())),reverse=True)\nr = sorted(list(map(int,input().split())),reverse=True)\nans = p[:x]\nans[x:x] = q[:y]\nans=sorted(ans)\n#print(ans)\ni = 0\nresult = 0\nfor A in ans:\n if A < r[i]:\n result += r[i]\n if i < c:\n i += 1\n continue\n result += A\nprint(result)', 'import sys\n#from collections import deque\ninput = sys.stdin.buffer.readline\n\nx, y, a, b, c = map(int, input().split())\np = sorted(list(map(int,input().split())),reverse=True)\nq = sorted(list(map(int,input().split())),reverse=True)\nr = sorted(list(map(int,input().split())),reverse=True)\nans = p[:x]\nans[x:x] = q[:y]\nans += r\nans = sorted(ans,reverse=True)\nprint(sum(ans[:x+y]))']
['Runtime Error', 'Accepted']
['s032480211', 's766709853']
[21596.0, 22340.0]
[268.0, 247.0]
[498, 377]
p02727
u707124227
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['#n,x,y=map(int,input())\n\nfrom collections import deque\n\nx,y,a,b,c=map(int,input().split())\np=list(map(int,input().split()))\nq=list(map(int,input().split()))\nr=list(map(int,input().split()))\np.sort()\nq.sort()\np=deque(p[a-x:])\nq=deque(q[b-y:])\nr.sort()\nfor ri in r:\n if ri > p[0] and q[0] >= p[0]:\n p.popleft()\n p.append(ri)\n p.sort()\n continue\n if ri > q[0] and p[0] >= q[0]:\n q.popleft()\n q.sort()\n q.append(ri)\nprint(sum(p)+sum(q))\n\n"""\n1 2 2 2 1\n2 4\n5 1\n3\n->12\n2 2 2 2 2\n8 6\n9 1\n2 1\n->25\n"""\n\n', '#n,x,y=map(int,input())\n\nfrom collections import deque\n\nx,y,a,b,c=map(int,input().split())\np=list(map(int,input().split()))\nq=list(map(int,input().split()))\nr=list(map(int,input().split()))\np.sort()\nq.sort()\np=deque(p[a-x:])\nq=deque(q[b-y:])\nr.sort()\nfor ri in r:\n if ri > p[0] and q[0] >= p[0]:\n p.popleft()\n print(ri)\n p.append(ri)\n continue\n if ri > q[0] and p[0] >= q[0]:\n q.popleft()\n print(ri)\n q.append(ri)\nprint(sum(p)+sum(q))\n\n"""\n1 2 2 2 1\n2 4\n5 1\n3\n->12\n2 2 2 2 2\n8 6\n9 1\n2 1\n->25\n"""\n\n', 'x,y,nr,ng,nm=map(int,input().split())\nr=list(map(int,input().split()))\ng=list(map(int,input().split()))\nm=list(map(int,input().split()))\nr.sort(reverse=True)\ng.sort(reverse=True)\na=r[:x]+g[:y]+m\na.sort(reverse=True)\nprint(sum(a[:x+y]))\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s501746267', 's789666343', 's994346623']
[23616.0, 23616.0, 29688.0]
[222.0, 315.0, 161.0]
[557, 559, 236]
p02727
u707808519
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['import bisect\nX, Y, A, B, C = map(int, input().split())\nred = [int(x) for x in input().split()]\ngre = [int(x) for x in input().split()]\nnon = [int(x) for x in input().split()]\nred.sort(reverse=True)\ngre.sort(reverse=True)\nnon.sort()\nans = red[:X] + gre[:Y]\nans.sort(reverse=True)\nif non[-1] > ans[-1]:\n c = non[-1]\n index = bisect_right_reverse(ans, c)\n ans.insert(index, c)\n non.pop(-1)\n ans.pop(-1)\nprint(sum(ans))', 'X, Y, R, G, N = map(int, input().split())\nr = [int(x) for x in input().split()]\ng = [int(x) for x in input().split()]\nn = [int(x) for x in input().split()]\nr = sorted(r)[R-X:]\ng = sorted(g)[G-Y:]\n\napple = r + g + n\napple = sorted(apple)[len(apple)-(X+Y):]\nprint(sum(apple))']
['Runtime Error', 'Accepted']
['s617242432', 's450553002']
[22592.0, 24064.0]
[232.0, 252.0]
[431, 273]
p02727
u711340028
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['import sys\nimport heapq\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nX,Y,A,B,C = map(int, readline().split())\n\nP = list(map(int, readline().split()))\nQ = list(map(int, readline().split()))\nR = list(map(int, readline().split()))\n\nprint(len(P), len(Q), len(R))\n\nP = sorted(P, reverse=True)[:X]\nQ = sorted(Q, reverse=True)[:Y]\nR.sort(reverse=True)\n\nheapq.heapify(P)\nheapq.heapify(Q)\n\nprint(len(P), len(Q), len(R))\n\nfor r in R:\n p = heapq.heappop(P)\n q = heapq.heappop(Q)\n\n if p <= q and p < r:\n heapq.heappush(P, r)\n heapq.heappush(Q, q)\n elif q < r:\n heapq.heappush(Q, r)\n heapq.heappush(P, p)\n else:\n heapq.heappush(P, p)\n heapq.heappush(Q, q)\n\nprint(sum(P) + sum(Q))', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nX,Y,A,B,C = map(int, readline().split())\n\nP = sorted(map(int, readline().split()),reverse=True)\nQ = sorted(map(int, readline().split()),reverse=True)\nR = sorted(map(int, readline().split()),reverse=True)\n\nlis = P[:X] + Q[:Y] + R\n\nprint(sum(sorted(lis,reverse=True)[:X+Y]))']
['Wrong Answer', 'Accepted']
['s254185908', 's162230271']
[21212.0, 22720.0]
[399.0, 246.0]
[785, 389]
p02727
u711693740
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\n\ngoukei = X + Y\ndelicious = 0\nred = 0\ngreen = 0\n\n\ndef max_pop(p):\n pidx = p.index(max(p))\n maxp = p.pop(pidx)\n return maxp\n\n\nmaxp = max_pop(p)\nmaxq = max_pop(q)\nmaxr = max_pop(r)\nmaxdelis = [maxp, maxq, maxr]\nfor i in range(goukei):\n maxdeli = max(maxdelis)\n idx = maxdelis.index(max(maxdelis))\n delicious += maxdeli\n if idx == 0:\n red += 1\n if red == X:\n maxdelis[0] = 0\n else:\n maxdelis[0] = max_pop(p)\n elif idx == 1:\n green += 1\n if green == X:\n maxdelis[1] = 0\n else:\n maxdelis[1] = max_pop(q)\n else:\n maxdelis[2] = max_pop(r)\n\nprint(delicious)\n', 'X, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\np = sorted(p)[-X:]\nq = sorted(q)[-Y:]\npq = p + q\npq.sort()\nr.sort()\nN = X + Y\ncnt = 0\n\nfrom collections import deque\npq = deque(pq)\nr = deque(r)\n\npq_max = pq.pop()\nr_max = r.pop()\nemp = deque()\n\nfor _ in range(N):\n if pq_max >= r_max:\n cnt += pq_max\n if pq == emp:\n pq_max = 0\n else:\n pq_max = pq.pop()\n else:\n cnt += r_max\n if r == emp:\n r_max = 0\n else:\n r_max = r.pop()\n\nprint(cnt)']
['Runtime Error', 'Accepted']
['s197183187', 's629250853']
[22720.0, 23328.0]
[2109.0, 351.0]
[820, 626]
p02727
u720636500
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x, y, a, b, c = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\np.sort(reverse = True)\nq.sort(reverse = True)\nr.sort(reverse = True)\npp = p[:x]\nqq = q[:y]\nrr = r[:(x+y)]\nppqq = pp + qq\nppqq.sort()\nfor i in range(len(ppqq)):\n if ppqq[i] < rr[0]:\n ppqq[i] = rr[0]\n del rr[0]\nprint(sum(ppqq))', 'x, y, a, b, c = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\np.sort(reverse = True)\nq.sort(reverse = True)\nr.sort(reverse = True)\npp = p[:x]\nqq = q[:y]\nif x+y <= c:\n rr = r[:(x+y)]\nelse:\n rr = r\nppqq = pp + qq\nppqq.sort()\nfor i in range(len(ppqq)):\n if ppqq[i] < rr[0]:\n ppqq[i] = rr[0]\n del rr[0]\nprint(sum(ppqq))', 'x, y, a, b, c = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\np.sort(reverse = True)\nq.sort(reverse = True)\nr.sort(reverse = True)\npp = p[:x]\nqq = q[:y]\nif x+y <= c:\n rr = r[:(x+y)]\nelse:\n rr = r\nppqqrr = pp + qq + rr\nppqqrr.sort(reverse = True)\nprint(sum(ppqqrr[:x+y]))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s082988116', 's089415600', 's759144831']
[23328.0, 23328.0, 23328.0]
[1703.0, 1707.0, 242.0]
[382, 412, 360]
p02727
u726285999
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['import sys\nsys.setrecursionlimit(10**6)\n\n\nmod = 10 ** 9 + 7\nN = 2* 10 ** 5 \nfact = [1, 1] # fact[n] = (n! mod p)\nfactinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)\ninv = [0, 1] \n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % mod)\n inv.append((-inv[mod % i] * (mod // i)) % mod)\n factinv.append((factinv[-1] * inv[-1]) % mod)\n\ndef cmb(n, r):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n-r] % mod\n \n\ndef dfs(v, p=-1):\n\n # print(v, p, [x + 1 for x in E[v]])\n \n dp_l = 1 \n size_l = 1 \n\n \n for u in E[v]:\n \n \n if u == p:\n continue\n\n d, s = dfs(u, v)\n d %= mod\n size_l += s\n dp_l = dp_l * d * cmb(size_l-1, s) % mod\n\n dp[v] = dp_l\n size[v] = size_l\n \n return (int(dp_l), size_l)\n \ndef bfs(v, p=-1):\n \n for u in E[v]:\n if u == p:\n continue\n \n \n \n\n partial_v = int(dp[v] / dp[u] / cmb(N - 1, size[u]))\n \n \n \n\n dp_l = dp[u] * partial_v * cmb(N-1, size[u]-1)\n \n dp[u] = dp_l\n \n bfs(u,v)\n\n\nN = int(input())\nE = [[] for _ in range(N)]\n\nfor _ in range(N-1):\n a, b = map(int, input().split())\n E[a-1].append(b-1)\n E[b-1].append(a-1)\n \ndp = [1] * N\nsize = [1] * N\n\n\ndfs(0)\n\nbfs(0)\n\nfor i in range(N):\n print(dp[i])', 'X, Y, A, B, C = map(int, input().split())\n\np = [int(x) for x in input().split()]\nq = [int(x) for x in input().split()]\nr = [int(x) for x in input().split()]\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\napples = []\napples.extend(p[:X])\napples.extend(q[:Y])\n\napples.sort(reverse=True)\napples.extend(r)\n\napples.sort(reverse=True)\nprint(sum(apples[:(X+Y)]))']
['Runtime Error', 'Accepted']
['s439570670', 's881668335']
[27132.0, 23340.0]
[261.0, 291.0]
[1859, 373]
p02727
u727057618
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
["def main():\n X, Y, A, B, C = [int(i) for i in input().split()]\n red = [int(i) for i in input().split()]\n blue = [int(i) for i in input().split()]\n noc = [int(i) for i in input().split()]\n red = sorted(red)[-X:]\n blue = sorted(blue)[-Y:]\n rb = sorted(red + blue)\n score = sum(rb)\n noc = sorted(noc)[::-1]\n\n exit()\n s_noc = 0\n s_rb = 0\n for i in range(min(A+B, C)):\n if rb[i] > noc[i]:\n break\n s_noc += noc[i]\n s_rb += rb[i]\n\n print(score + s_noc - s_rb)\n\n\nif __name__ == '__main__':\n main()\n\n", "def main():\n X, Y, A, B, C = [int(i) for i in input().split()]\n red = [int(i) for i in input().split()]\n blue = [int(i) for i in input().split()]\n noc = [int(i) for i in input().split()]\n red = sorted(red)[-X:]\n blue = sorted(blue)[-Y:]\n rb = sorted(red + blue)\n score = sum(rb)\n noc = sorted(noc)[::-1]\n\n s_noc = 0\n s_rb = 0\n for i in range(min(len(rb), len(noc))):\n if rb[i] > noc[i]:\n break\n s_noc += noc[i]\n s_rb += rb[i]\n\n print(score + s_noc - s_rb)\n\n\nif __name__ == '__main__':\n main()\n\n"]
['Wrong Answer', 'Accepted']
['s771212151', 's815929036']
[23340.0, 23340.0]
[223.0, 247.0]
[568, 568]
p02727
u728566015
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\np = sorted(list(map(int, input().split())), reverse=True)\nq = sorted(list(map(int, input().split())), reverse=True)\nr = sorted(list(map(int, input().split())), reverse=True)\n\nRed = p[:X]\nGreen = q[:Y]\n\nApple = sorted(Red + Green)\nfor i in range(C):\n print(Apple[i], r[i])\n if Apple[i] < r[i]:\n Apple[i] = r[i]\nprint(sum(Apple))', 'import heapq\n\nX, Y, A, B, C = map(int, input().split())\np = sorted(list(map(int, input().split())), reverse=True)\nq = sorted(list(map(int, input().split())), reverse=True)\nr = list(map(int, input().split()))\n\nRed = p[:X]\nGreen = q[:Y]\n\nh = sorted(Red + Green)\nheapq.heapify(h)\nfor i in r:\n heapq.heappushpop(h, i)\nprint(sum(h))']
['Runtime Error', 'Accepted']
['s402362084', 's024801193']
[23200.0, 23456.0]
[406.0, 255.0]
[382, 330]
p02727
u736641785
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = input().split()\nP = list(map(int,input().split()))\nQ = list(map(int,input().split()))\nR = list(map(int,input().split()))\nP.sort(reverse=True)\nQ.sort(reverse=True)\nR.sort(reverse=True)\n\nANS_list = P[:X]\nANS_list.extend(Q[:Y])\nANS_list.sort()\nc = 0\nfor i in range(len(R)):\n if ANS_list[i] >= R[i]:\n break\n c+=1\n\nif i!=0:\n ANS_list[:c] = R[:c]\n\nprint(sum(R[:c])+sum(ANS_list[c:]))', 'X, Y, A, B, C = map(int,input().split())\nP = list(map(int,input().split()))\nQ = list(map(int,input().split()))\nR = list(map(int,input().split()))\nP.sort(reverse=True)\nQ.sort(reverse=True)\nR.sort(reverse=True)\n\nANS_list = P[:X]\nANS_list.extend(Q[:Y])\nANS_list.sort()\nc = 0\nfor i in range(len(R)):\n if ANS_list[i] >= R[i]:\n break\n c+=1\n\nif i!=0:\n ANS_list[:c] = R[:c]\nprint(sum(R[:c])+sum(ANS_list[c:]))']
['Runtime Error', 'Accepted']
['s442693484', 's459873856']
[23328.0, 23328.0]
[205.0, 246.0]
[409, 407]
p02727
u738898077
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['from collections import deque\nx,y,a,b,c = map(int,input().split())\np1 = list(map(int,input().split()))\nq1 = list(map(int,input().split()))\nr1 = list(map(int,input().split()))\nans = []\np1.sort(reverse=1)\nq1.sort(reverse=1)\nr1.sort(reverse=1)\n\n\np=deque(p1[0:x])\nq=deque(q1[0:y])\nr=deque(r1[0:x+y])\n\nlp = p.pop()\nlq = q.pop()\n\nrr = r.popleft()\n\nwhile 1:\n print(lp,lq,rr)\n if x > 0 and lp <= lq or y == 0:\n if lp >= rr:\n ans.append(lp)\n \n else:\n ans.append(rr)\n r.append(0)\n rr = r.popleft()\n if x > 1:\n lp = p.pop()\n x -= 1\n if y > 0:\n if lq >= rr:\n ans.append(lq)\n \n else:\n ans.append(rr)\n r.append(0)\n rr = r.popleft()\n if y > 1:\n lq = q.pop()\n y -= 1\n if x == 0 and y == 0:\n print(sum(ans))\n exit()\n\n', 'from collections import deque\nx,y,a,b,c = map(int,input().split())\np1 = list(map(int,input().split()))\nq1 = list(map(int,input().split()))\nr1 = list(map(int,input().split()))\nans = []\np1.sort(reverse=1)\nq1.sort(reverse=1)\nr1.sort(reverse=1)\n\n\np=deque(p1[0:x])\nq=deque(q1[0:y])\nr=deque(r1[0:x+y])\n\nlp = p.pop()\nlq = q.pop()\n\nrr = r.popleft()\n\nwhile 1:\n# print(lp,lq,rr)\n if (x > 0 and lp <= lq) or y == 0:\n if lp >= rr:\n ans.append(lp)\n \n else:\n ans.append(rr)\n r.append(0)\n rr = r.popleft()\n if x > 1:\n lp = p.pop()\n x -= 1\n else:\n if lq >= rr:\n ans.append(lq)\n \n else:\n ans.append(rr)\n r.append(0)\n rr = r.popleft()\n if y > 1:\n lq = q.pop()\n y -= 1\n if x == 0 and y == 0:\n print(sum(ans))\n exit()\n\n']
['Wrong Answer', 'Accepted']
['s383230884', 's029165367']
[26144.0, 23616.0]
[572.0, 329.0]
[922, 922]
p02727
u740284863
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X,Y,A,B,C = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort(\nans = 0\n\nfor i in range(X):\n if A[-1] >= C[-1]:\n ans += A[-1]\n A.pop()\n else:\n ans += C[-1]\n C.pop()\n\nfor i in range(Y):\n if B[-1] >= C[-1]:\n ans += B[-1]\n B.pop()\n else:\n ans += C[-1]\n C.pop()\n \nprint(ans)', 'X,Y,a,b,c = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nans = 0\nif X < a:\n A = A[a-X:]\nif Y < b:\n B = B[b-Y:]\nans = 0\nfor i in range(X+Y):\n if len(A) == 0:\n A.append(0)\n if len(B) == 0:\n B.append(0)\n if len(C) == 0:\n C.append(0)\n if max(A[-1],B[-1],C[-1]) == A[-1]:\n ans += A[-1]\n A.pop()\n elif max(A[-1],B[-1],C[-1]) == B[-1]:\n ans += B[-1]\n B.pop()\n else:\n ans += C[-1]\n C.pop()\nprint(ans)']
['Runtime Error', 'Accepted']
['s243587445', 's785404197']
[8868.0, 28008.0]
[26.0, 321.0]
[449, 592]
p02727
u741612283
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c = (int(x) for x in input().split())\n\nfrom bisect import insort\n\np_list = []\nq_list = []\nr_list = []\n\nfor value in input().split():\n insort(p_list, int(value))\n\nfor value in input().split():\n insort(q_list, int(value))\n \nfor value in input().split():\n insort(r_list, int(value))\n \nred = 0\ngreen = 0\nwhite = 0\n\nsum_num = 0\n\nprint(sum_num)\nfor i in range(1,x+y+1):\n if red < x:\n \tred_num = p_list[(red*-1)-1]\n else:\n red_num = 0\n if green < y:\n \tgreen_num = q_list[(green*-1)-1]\n else:\n green_num = 0\n if white < c:\n \twhite_num = r_list[(white*-1)-1]\n else:\n white_num = 0\n \n max_p = max([red_num,green_num,white_num])\n sum_num += max_p\n if max_p == white_num:\n white += 1\n elif max_p == red_num:\n red += 1\n elif max_p == green_num:\n green += 1', 'x,y,a,b,c = (int(x) for x in input().split())\n\nfrom bisect import insort\n\np_list = list(map(int,input().split()))\nq_list = list(map(int,input().split()))\nr_list = list(map(int,input().split()))\n\n\np_list.sort()\nq_list.sort()\nr_list.sort()\n\nred = 0\ngreen = 0\nwhite = 0\n\nsum_num = 0\n\nfor i in range(1,x+y+1):\n if red < x:\n \tred_num = p_list[(red*-1)-1]\n else:\n red_num = 0\n if green < y:\n \tgreen_num = q_list[(green*-1)-1]\n else:\n green_num = 0\n if white < c:\n \twhite_num = r_list[(white*-1)-1]\n else:\n white_num = 0\n \n max_p = max([red_num,green_num,white_num])\n sum_num += max_p\n if max_p == white_num:\n white += 1\n elif max_p == red_num:\n red += 1\n elif max_p == green_num:\n green += 1\n\nprint(sum_num)']
['Wrong Answer', 'Accepted']
['s949782484', 's409681132']
[23232.0, 22720.0]
[2104.0, 428.0]
[792, 734]
p02727
u747391638
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c = map(int, input().split(" "))\nplist= list(map(int, input().split(" ")))\nqlist= list(map(int, input().split(" ")))\nrlist= list(map(int, input().split(" ")))\n\nplist.extend(qlist)\nplist.sort()\n\nrlist.sort(reverse=True)\n\nn = min(len(plist),len(rlist))\nslist = plist[0:x+y-1]\nulist = plist[0:x+y-1]\nslist[0] = rlist[0]\ni = 1\n\nwhile i < n and sum(slist)>sum(ulist):\n slist[i]=rlist[i]\n ulist[i-1]=rlist[i-1]\n i += 1\n\nprint(sum(slist))\n ', 'x,y,a,b,c = map(int, input().split(" "))\nplist= sorted(list(map(int, input().split(" "))),reverse=True)[0:x]\nqlist= sorted(list(map(int, input().split(" "))),reverse=True)[0:y]\nrlist= sorted(list(map(int, input().split(" "))),reverse=True)\n\nplist.extend(qlist)\nplist.sort()\nn = min(x+y,len(rlist))\ni = 0\n\nwhile i < n and rlist[i]>plist[i]:\n i += 1\nif i == 0:\n print(sum(plist))\nelse:\n print(sum(plist[i:x+y])+sum(rlist[0:i]))\n']
['Runtime Error', 'Accepted']
['s690565852', 's907378289']
[23472.0, 22504.0]
[2105.0, 244.0]
[445, 429]
p02727
u751717561
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['\nimport numpy as np\nX, Y, A, B, C = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nA.sort(reverse=True)\nB.sort(reverse=True)\nC.sort(reverse=True)\n\nA = A[0:X]\nB = B[0:Y]\n#C = np.array(C)\n\narr = A+B\n\nflag = 1\n\nwhile(flag):\n tmp = 0\n _min = min(arr)\n _max = max(C)\n if _min <= _max:\n arr[arr.index(_min)] = _max\n else:\n flag = 0\n"""\n_min = min(arr)\nC = C[C>_min]\n\nfor c in C:\n _min = min(arr)\n if c >= _min:\n arr[arr.index(_min)] = c\n\n\n"""\nprint(sum(arr))', 'import numpy as np\nX, Y, A, B, C = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nA.sort(reverse=True)\nB.sort(reverse=True)\nC.sort(reverse=True)\n\nA = A[0:X]\nB = B[0:Y]\nD = A+B+C\n\nD.sort(reverse=True)\n\nD = D[0:X+Y]\nprint(sum(D))']
['Time Limit Exceeded', 'Accepted']
['s368132292', 's998321552']
[31308.0, 31276.0]
[2111.0, 371.0]
[556, 315]
p02727
u758475901
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X,Y,A,B,C = map(int,input().split())\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\nL = p + r\nL.sort(reverse = True)\nans = 0\nfor i in range(X):\n ans += int(L[i])\nfor i in range(X): \n L.remove(L[i])\nset(L) = set(L)-set(p) \nM = q + list(L)\nM.sort(reverse = True)\nabc = 0 \nfor i in range(Y):\n abc += int(M[i])\nprint(ans + abc) ', 'X,Y,A,B,C = map(int,input().split())\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\np.sort(reverse = True)\nq.sort(reverse = True)\na = p[:X] + q[:Y] + r\na.sort(reverse = True)\nprint(sum(a[:X+Y]))\n\n']
['Runtime Error', 'Accepted']
['s553132610', 's029255812']
[3064.0, 23328.0]
[17.0, 235.0]
[389, 254]
p02727
u759518460
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x, y, na, nb, nc = map(int, input().split()) \na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nc = [int(i) for i in input().split()]\na.sort(reverse=True)\nb.sort(reverse=True)\nc.sort(reverse=True)\na = a[:x]\nb = b[:y]\n\nai = len(a) - 1\nbi = len(b) - 1\nprint(a, b)\nprint(ai, bi)\nfor i in c:\n if a[ai] < b[bi]:\n if i > a[ai] and ai >= 0:\n a[ai] = i\n ai -= 1\n elif i > b[bi] and bi >= 0:\n b[bi] = i\n bi -= 1\n else:\n break\n else:\n if i > b[bi] and bi >= 0:\n b[bi] = i\n bi -= 1\n elif i > a[ai] and ai >= 0:\n a[ai] = i\n ai -= 1\n else:\n break\nprint(sum(a)+sum(b))', 'x, y, na, nb, nc = map(int, input().split()) \na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nc = [int(i) for i in input().split()]\na.sort(reverse=True)\nb.sort(reverse=True)\nc.sort(reverse=True)\na = a[:x]\nb = b[:y]\n\nai = len(a) - 1\nbi = len(b) - 1\n\nfor i in c:\n if a[ai] < b[bi]:\n if i > a[ai] and ai >= 0:\n a[ai] = i\n ai -= 1\n elif i > b[bi] and bi >= 0:\n b[bi] = i\n bi -= 1\n else:\n break\n else:\n if i > b[bi] and bi >= 0:\n b[bi] = i\n bi -= 1\n elif i > a[ai] and ai >= 0:\n a[ai] = i\n ai -= 1\n else:\n break\nprint(sum(a)+sum(b))']
['Wrong Answer', 'Accepted']
['s595511349', 's955435463']
[23644.0, 23232.0]
[272.0, 253.0]
[738, 713]
p02727
u759718348
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\nAA = list(map(int, input().split()))\nBB = list(map(int, input().split()))\nCC = list(map(int, input().split()))\na = sorted(AA, reverse=True)\nb = sorted(BB, reverse=True)\nc = sorted(CC, reverse=True)\n\nif X < A:\n del a[X:]\n\nif Y < B:\n del b[Y:]\nprint(a)\nprint(b)\n\nNEW = a + b + c\nNEWnew = sorted(NEW, reverse=True)\ndel NEWnew[X+Y:]\nK = sum(NEWnew)\nprint(K)\n\n \n\n', 'X, Y, A, B, C = map(int, input().split())\nAA = list(map(int, input().split()))\nBB = list(map(int, input().split()))\nCC = list(map(int, input().split()))\na = sorted(AA, reverse=True)\nb = sorted(BB, reverse=True)\nc = sorted(CC, reverse=True)\n\nif X < A:\n del a[X:]\nelif Y < B:\n del b[Y:]\nprint(a)\nprint(b)\n\nNEW = a + b + c\ndel NEW[X+Y:]\nK = sum(NEW)\nprint(K)\n\n \n\n', 'X, Y, A, B, C = map(int, input().split())\nAA = list(map(int, input().split()))\nBB = list(map(int, input().split()))\nCC = list(map(int, input().split()))\na = sorted(AA, reverse=True)\nb = sorted(BB, reverse=True)\nc = sorted(CC, reverse=True)\n\nif X < A:\n del a[X:]\n\nif Y < B:\n del b[Y:]\n\nNEW = a + b + c\nNEWnew = sorted(NEW, reverse=True)\ndel NEWnew[X+Y:]\nK = sum(NEWnew)\nprint(K)\n\n \n\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s228863580', 's268498923', 's844222776']
[25688.0, 25276.0, 23728.0]
[263.0, 228.0, 248.0]
[403, 363, 385]
p02727
u762540523
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
["def resolve():\n x, y, a, b, c = map(int, input().split())\n p = sorted(list(map(int, input().split())))[-x:]\n q = sorted(list(map(int, input().split())))[-y:]\n r = sorted(list(map(int, input().split())), reverse=True)\n\tp = sorted(p + q)\n for i in range(min(a + b, c)):\n if p[i] < r[i]:\n p[i] = r[i]\n else:\n break\n print(sum(p))\n\n\nif __name__ == '__main__':\n resolve()\n", "import heapq\n\n\ndef resolve():\n x, y, a, b, c = map(int, input().split())\n p = sorted(list(map(int, input().split())))[-x:]\n q = sorted(list(map(int, input().split())))[-y:]\n r = [-int(x) for x in input().split()]\n heapq.heapify(p)\n heapq.heapify(r)\n for i in q:\n heapq.heappush(p, i)\n ans = 0\n while p and r:\n ans += max(heapq.heappop(p), -heapq.heappop(r))\n ans += sum(p)\n print(ans)\n\n\nif __name__ == '__main__':\n resolve()\n"]
['Runtime Error', 'Accepted']
['s962290241', 's207648851']
[2940.0, 21608.0]
[17.0, 374.0]
[424, 475]
p02727
u769870836
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['s,y,a,b,c=map(int,input().split())\np=sorted(list(map(int,input().split())))[-x-y:]\nq=sorted(list(map(int,input().split())))[-x-y:]\nr=sorted(list(map(int,input().split())))\nfor i in range(len(p)):\n r.append(p[i])\n r.append(q[i])\nr=sorted(r)[-x-y:]\nprint(sum(r))\n\n', 'x,y,a,b,c=map(int,input().split())\np=sorted(list(map(int,input().split())))[-x:]\nq=sorted(list(map(int,input().split())))[-y:]\nr=sorted(list(map(int,input().split())))\nfor i in range(len(p)):\n r.append(p[i])\n r.append(q[i])\nr=sorted(r)[-x-y:]\nprint(sum(r))\n\n', 'x,y,a,b,c=map(int,input().split())\np=sorted(list(map(int,input().split())))[-x:]\nq=sorted(list(map(int,input().split())))[-y:]\nprint(sum(sorted(list(map(int,input().split()))+p+q)[-x-y:]))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s046093225', 's241571808', 's988900138']
[14400.0, 22616.0, 22504.0]
[78.0, 292.0, 244.0]
[264, 260, 188]
p02727
u785573018
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x, y, a, b, c = map(int, input().split())\nLista = sorted(list(map(int, input().split())), reverse = True)\nListb = sorted(list(map(int, input().split())), reverse = True)\nListc = sorted(list(map(int, input().split())), reverse = True)\nif x < a:\n del Lista[x:a]\nif y < b:\n del Listb[y:b]\nwhile len(Listc) > 0:\n if Lista[-1] < Listb[-1]:\n if Lista[-1] < Listc[0]:\n Lista[-1] = Listc[0]\n Lista = sorted(Lista, reverse = True)\n del Listc[0]\n else:\n break\n else:\n if Listb[-1] < Listc[0]:\n Listb[-1] = Listc[0]\n Listb = sorted(Listb, reverse = True)\n del Listc[0]\n else:\n break\nprint(Lista)\nprint(Listb)\nprint(sum(Lista) + sum(Listb))', 'x, y, a, b, c = map(int, input().split())\nLista = sorted(list(map(int, input().split())), reverse = True)\nListb = sorted(list(map(int, input().split())), reverse = True)\nListc = sorted(list(map(int, input().split())), reverse = True)\nif x < a:\n del Lista[x:a]\nif y < b:\n del Listb[y:b]\nList = sorted(Lista + Listb, reverse = True)\nwhile len(Listc) > 0:\n if List[-1] < Listc[0]:\n List[-1] = Listc[0]\n List = sorted(List, reverse = True)\n del Listc[0]\n else:\n break\nprint(sum(Lista) + sum(Listb))', 'x, y, a, b, c = map(int, input().split())\nLista = sorted(list(map(int, input().split())), reverse = True)\nListb = sorted(list(map(int, input().split())), reverse = True)\nListc = sorted(list(map(int, input().split())), reverse = True)\nif x < a:\n del Lista[x : a]\nif y < b:\n del Listb[y : b]\nList = sorted(Lista + Listb, reverse = True)\ni = -1\nfor n in range(min(x + y, c)):\n if List[-n-1] < Listc[n]:\n i = n\n else:\n break\ndel List[x + y - i -1 : x + y]\ndel Listc[i + 1 : c]\nprint(sum(List) + sum(Listc))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s571524260', 's958995052', 's258910116']
[22720.0, 22720.0, 23200.0]
[2104.0, 2105.0, 238.0]
[756, 534, 528]
p02727
u788703383
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['from collections import deque\nx,y,a,b,c = map(int,input().split())\n\np = deque(sorted(list(map(int,input().split()))))\nq = deque(sorted(list(map(int,input().split()))))\nr = deque(sorted(list(map(int,input().split()))))\n\nans = deque(maxlen=(x+y))\n\ndef insertion(z):\n\tglobal x,y\n\tif z == p:\n\t\tx -= 1\n\telse:\n\t\ty -= 1\n\treturn ans.append(z.pop())\n\nwhile x > 0 or y > 0:\n\tif x and y:\n\t\tif p[-1] > q[-1] :\n\t\t\tinsertion(p)\n\t\telse:\n\t\t\tinsertion(q)\n\telif not x:\n\t\tinsertion(q)\n\telse:\n\t\tinsertion(p)\n\n\nwhile ans[-1] < r[-1]:\n\t\tans.pop()\n\t\tans.appendleft(r.pop())\n\nprint(sum(ans))\n\n', 'x,y,a,b,c = map(int,input().split())\np = sorted(map(int,input().split()), reverse = True)\nq = sorted(map(int,input().split()), reverse = True)\nr = sorted(map(int,input().split()), reverse = True)\nans = sorted(p[:x]+q[:y]+r,reverse = True)\nprint(sum(ans[:x+y]))\n\n']
['Runtime Error', 'Accepted']
['s152069640', 's459814765']
[23712.0, 23328.0]
[347.0, 250.0]
[569, 262]
p02727
u806779442
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c = map(int,input().split())\nP = list(map(int,input().split()))\nQ = list(map(int,input().split()))\nR = list(map(int,input().split()))\nrlen = len(R)\nif (rlen < x + y):\n max = rlen\nelse:\n max = x + y\n\nP.sort(reverse=True)\nQ.sort(reverse=True)\nR.sort(reverse=True)\n\np = P[:x]\nq = Q[:y]\nr = R[:max]\n\nprint(p)\nprint(q)\nprint(r)\np.extend(q)\np.sort()\nprint(p)\n\nans = sum(p)\n\nfor i in range(max):\n diff = r[i] - p[i]\n if (diff > 0):\n ans = ans + diff\n else:\n break\n\nprint(ans)', 'x,y,a,b,c = map(int,input().split())\nP = list(map(int,input().split()))\nQ = list(map(int,input().split()))\nR = list(map(int,input().split()))\nrlen = len(R)\nif (rlen < x + y):\n max = rlen\nelse:\n max = x + y\n\nP.sort(reverse=True)\nQ.sort(reverse=True)\nR.sort(reverse=True)\n\np = P[:x]\nq = Q[:y]\nr = R[:max]\n\np.extend(q)\np.sort()\n\nans = sum(p)\n\nfor i in range(max):\n diff = r[i] - p[i]\n if (diff > 0):\n ans = ans + diff\n else:\n break\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s369103030', 's080029017']
[29708.0, 22560.0]
[304.0, 271.0]
[505, 469]
p02727
u815218584
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\nP = list(map(int, input().split()))\nQ = list(map(int, input().split()))\nR = list(map(int, input().split()))\n\nR += sorted(R)[-X:]\nR += sorted(Q)[-Y:]\nans = sum(sorted(R)[-(X+Y):])\nprint(ans)\n\n', 'X, Y, A, B, C = map(int, input().split())\nP = list(map(int, input().split()))\nQ = list(map(int, input().split()))\nR = list(map(int, input().split()))\n \nR += sorted(P)[-X:]\nR += sorted(Q)[-Y:]\nans = sum(sorted(R)[-(X+Y):])\nprint(ans)']
['Wrong Answer', 'Accepted']
['s877051072', 's958221834']
[23328.0, 23328.0]
[229.0, 239.0]
[233, 232]
p02727
u821441703
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['import sys\nimport numpy as np\n\nX, Y, A, B, C = map(int, sys.stdin.readline().rstrip().split())\nP = list(map(int, sys.stdin.readline().rstrip().split()))\nQ = list(map(int, sys.stdin.readline().rstrip().split()))\nR = list(map(int, sys.stdin.readline().rstrip().split()))\n\nif A == 1 and B == 1 and C == 1:\n ans = sum(sorted([P[0], Q[0], R[0]], reverse=True)[:2])\n print(ans)\n sys.exit()\n\nPmin = np.min(P)\nQmin = np.min(Q)\nRmax = np.max(R)\n\n\nif Pmin > Rmax and Qmin > Rmax:\n sP = np.sort(P)[::-1] if len(set(P)) > 1 else P\n sQ = np.sort(Q)[::-1] if len(set(Q)) > 1 else Q\n ans = np.sum(sP[:X]) + np.sum(sQ[:Y])\n print(ans)\n sys.exit()\n\ngS = P + Q + R\np = A + B\niX = 0\niY = 0\niR = []\naX = [0] * X\naY = [0] * Y\naR = []\nans = 0\nfor index in np.argsort(gS)[::-1]:\n if iX == X and iY == Y:\n break\n if index < A:\n if iX == X:\n continue\n else:\n aX[iX] = gS[index]\n iX += 1\n elif index < p:\n if iY == Y:\n continue\n else:\n aY[iY] = gS[index]\n iY += 1\n else:\n iR.append((iX, iY))\n aR.append(gS[index])\n\nsumX = sum(aX)\nsumY = sum(aY)\nfor (iX, iY), s in zip(iR, aR):\n print(aX, aY)\n if len(aX) == 0:\n sumY = sumY + s - aY.pop()\n if len(aY) == 0:\n break\n elif len(aY) == 0:\n sumX = sumX + s - aX.pop()\n if len(aX) == 0:\n break\n else:\n if s <= aX[-1] and s <= aY[-1]:\n break\n if iX == X:\n sumY = sumY + s - aY.pop()\n elif iY == Y:\n sumX = sumX + s - aX.pop()\n else:\n if aX[-1] < aY[-1]:\n sumX = sumX + s - aX.pop()\n else:\n sumY = sumY + s - aY.pop()\n\nprint(sumX + sumY)\n', 'import sys\nimport numpy as np\n\nX, Y, A, B, C = map(int, sys.stdin.readline().rstrip().split())\nP = list(map(int, sys.stdin.readline().rstrip().split()))\nQ = list(map(int, sys.stdin.readline().rstrip().split()))\nR = list(map(int, sys.stdin.readline().rstrip().split()))\n\nif A == 1 and B == 1 and C == 1:\n ans = sum(sorted([P[0], Q[0], R[0]], reverse=True)[:2])\n print(ans)\n sys.exit()\n\nPmin = np.min(P)\nQmin = np.min(Q)\nRmax = np.max(R)\n\n\nif Pmin > Rmax and Qmin > Rmax:\n sP = np.sort(P)[::-1] if len(set(P)) > 1 else P\n sQ = np.sort(Q)[::-1] if len(set(Q)) > 1 else Q\n ans = np.sum(sP[:X]) + np.sum(sQ[:Y])\n print(ans)\n sys.exit()\n\ngS = P + Q + R\np = A + B\niX = 0\niY = 0\niR = []\naX = [0] * X\naY = [0] * Y\naR = []\nfor index in np.argsort(gS)[::-1]:\n if iX == X and iY == Y:\n break\n if index < A:\n if iX == X:\n continue\n else:\n aX[iX] = gS[index]\n iX += 1\n elif index < p:\n if iY == Y:\n continue\n else:\n aY[iY] = gS[index]\n iY += 1\n else:\n iR.append((iX, iY))\n aR.append(gS[index])\n\nsumX = sum(aX)\nsumY = sum(aY)\nfor (iX, iY), s in zip(iR, aR):\n if len(aX) == 0 and len(aY) == 0:\n break\n if len(aX) == 0:\n if s <= aY[-1]:\n break\n sumY = sumY + s - aY.pop()\n if len(aY) == 0:\n break\n elif len(aY) == 0:\n if s <= aX[-1]:\n break\n sumX = sumX + s - aX.pop()\n if len(aX) == 0:\n break\n else:\n if s <= aX[-1] and s <= aY[-1]:\n break\n if iX == X:\n sumY = sumY + s - aY.pop()\n elif iY == Y:\n sumX = sumX + s - aX.pop()\n else:\n if aX[-1] < aY[-1]:\n sumX = sumX + s - aX.pop()\n else:\n sumY = sumY + s - aY.pop()\n\nprint(sumX + sumY)']
['Runtime Error', 'Accepted']
['s267777738', 's964332856']
[171456.0, 41404.0]
[2110.0, 923.0]
[1813, 1922]
p02727
u823885866
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['import sys\nX, Y, A, B, C = sys.stdin.readline().split()\nX = int(X)\nY = int(Y)\nC = int(C)\nscoreA = map(int, sys.stdin.readline().split())\nscoreB = map(int, sys.stdin.readline().split())\nscoreC = map(int, sys.stdin.readline().split())\nscoreA.sort(reverse=True)\nscoreB.sort(reverse=True)\nscoreC.sort(reverse=True)\nscoreA = scoreA[:X-1]\nscoreB = scoreB[:Y-1]\nscoreAll = scoreA + scoreB + scoreC\nscoreAll.sort(reverse=True)\nprint(sum(scoreAll[:X+Y-1]))\n', 'import sys\nX, Y, A, B, C = sys.stdin.readline()\nX = int(X)\nY = int(Y)\nC = int(C)\nscoreA = map(int, sys.stdin.readline().split())\nscoreB = map(int, sys.stdin.readline().split())\nscoreC = map(int, sys.stdin.readline().split())\nscoreA.sort(reverse=True)\nscoreB.sort(reverse=True)\nscoreC.sort(reverse=True)\nscoreA = scoreA[:X-1]\nscoreB = scoreB[:Y-1]\nscoreAll = scoreA + scoreB + scoreC\ntotal = sum(scoreAll)\n', 'import sys\nX, Y, A, B, C = sys.stdin.readline().split()\nX = int(X)\nY = int(Y)\nC = int(C)\nscoreA = list(map(int, sys.stdin.readline().split()))\nscoreB = list(map(int, sys.stdin.readline().split()))\nscoreC = list(map(int, sys.stdin.readline().split()))\nscoreA.sort(reverse=True)\nscoreB.sort(reverse=True)\nscoreC.sort(reverse=True)\nscoreA = scoreA[:X-1]\nscoreB = scoreB[:Y-1]\nscoreAll = scoreA + scoreB + scoreC\nscoreAll.sort(reverse=True)\nprint(sum(scoreAll[:X+Y-1]))\n', 'import sys\nX, Y, A, B, C = sys.stdin.readline().split()\nX = int(X)\nY = int(Y)\nC = int(C)\nscoreA = list(map(int, sys.stdin.readline().split()))\nscoreB = list(map(int, sys.stdin.readline().split()))\nscoreC = list(map(int, sys.stdin.readline().split()))\nscoreA.sort(reverse=True)\nscoreB.sort(reverse=True)\nscoreC.sort(reverse=True)\nscoreA = scoreA[:X]\nscoreB = scoreB[:Y]\nscoreAll = scoreA + scoreB + scoreC\nscoreAll.sort(reverse=True)\nprint(sum(scoreAll[:X+Y]))\n']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s043759560', 's089876239', 's884978188', 's812724686']
[26528.0, 3064.0, 23184.0, 23312.0]
[44.0, 18.0, 243.0, 248.0]
[448, 405, 466, 460]
p02727
u837673618
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['from itertools import *\n\ndef merge(x,y):\n while 1:\n if x and y and x[0] >= y[0] or (not (x and y)) and x:\n yield x.pop(0)\n else y:\n yield y.pop(0)\n else:\n return\n\nX, Y, A, B, C = map(int, input().split())\nP = sorted(map(int, input().split()), reverse=True)\nQ = sorted(map(int, input().split()), reverse=True)\nR = sorted(map(int, input().split()), reverse=True)\n\nS = sum(islice(merge(P,R), X))\nS += sum(islice(merge(Q,R), Y))\nprint(S)', 'from heapq import *\nfrom itertools import *\n\nclass cached_iter(object):\n def __init__(self, it):\n self.it = iter(it)\n self.prev = None\n self._back = False\n\n def __next__(self):\n if self._back:\n self._back = False\n if self.prev:\n return self.prev\n self.prev = next(self.it)\n return self.prev\n \n def back(self):\n self._back = True\n\n def __iter__(saelf):\n return self\n\nX, Y, A, B, C = map(int, input().split())\nP = sorted(map(lambda x:-int(x), input().split()))\nQ = sorted(map(lambda x:-int(x), input().split()))\nR = cached_iter(sorted(map(lambda x:-int(x), input().split())))\n\nS = sum(islice(merge(P,R), X))\nR.back()\nS += sum(islice(merge(Q,R), Y))\nprint(-S)', 'from itertools import *\nfrom heapq import *\n\nX, Y, A, B, C = map(int, input().split())\nP = sorted(map(lambda x:-int(x), input().split()))\nQ = sorted(map(lambda x:-int(x), input().split()))\nR = sorted(map(lambda x:-int(x), input().split()))\n\nS = sum(islice(merge(islice(P, X),islice(Q, Y),R), X+Y))\n\nprint(-S)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s484876272', 's647585927', 's694271772']
[2940.0, 23372.0, 23428.0]
[17.0, 256.0, 322.0]
[458, 708, 309]
p02727
u840958781
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c=map(int,input().split()) \np=list(map(int,input().split()))\nq=list(map(int,input().split()))\nr=list(map(int,input().split()))\np=sorted(p)[x:]\nq=sorted(q)[y:]\nprint(sum(p+q+r[x+y:]))', 'x,y,a,b,c=map(int,input().split()) \np=list(map(int,input().split()))\nq=list(map(int,input().split()))\nr=list(map(int,input().split()))\np=sorted(p,reverse=True)[:x]\nq=sorted(q,reverse=True)[:y]\nprint(sum(sorted(p+q+r, reverse=True)[:x+y]))']
['Wrong Answer', 'Accepted']
['s947432994', 's804570267']
[23328.0, 23328.0]
[177.0, 230.0]
[209, 257]
p02727
u841856382
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\nP = sorted(list(map(int, input().split())), reverse=True)\nQ = sorted(list(map(int, input().split())), reverse=True)\nR = sorted(list(map(int, input().split())), reverse=True)\n\nred = sorted(P[:X])\ngre = sorted(Q[:Y])\nans = sum(red) + sum(gre) \nj, k = 0, 0\n\nfor i in range(min(X+Y),C):\n if(red[j] <= gre[k]):\n if R[i] > red[j] :\n ans = ans - red[j] + R[i]\n j += 1\n else:\n break\n else:\n if R[i] > gre[k] :\n ans = ans - gre[k] + R[i]\n k += 1\n else:\n break\nprint(ans)', 'X, Y, A, B, C = map(int, input().split())\nP = sorted(list(map(int, input().split())), reverse=True)\nQ = sorted(list(map(int, input().split())), reverse=True)\nR = sorted(list(map(int, input().split())), reverse=True)\n\nred = sorted(P[:X])\ngre = sorted(Q[:Y])\nans = sum(red) + sum(gre) \nj, k = 0, 0\n\nfor i in range(X+Y):\n if(red[j] <= gre[k]):\n if R[i] > red[j] :\n ans = ans - red[j] + R[i]\n j += 1\n else:\n break\n else:\n if R[i] > gre[k] :\n ans = ans - gre[k] + R[i]\n k += 1\n else:\n break\nprint(ans)', 'X, Y, A, B, C = map(int, input().split())\nP = sorted(list(map(int, input().split())), reverse=True)\nQ = sorted(list(map(int, input().split())), reverse=True)\nR = sorted(list(map(int, input().split())), reverse=True)\n\nred = sorted(P[:X])\ngre = sorted(Q[:Y])\nm = min((X+Y),C)\nn = R[:m]\nred.extend(gre)\nred.extend(n)\nred = sorted(red, reverse=True)\n\nprint(sum(red[:X+Y]))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s465293651', 's600501117', 's184917928']
[22720.0, 23200.0, 23604.0]
[216.0, 261.0, 278.0]
[603, 596, 368]
p02727
u864202285
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\n \np = sorted(list(map(int,input().split())), reverse=True)[:X]\nq = sorted(list(map(int,input().split())), reverse=True)[:Y]\nr = sorted(list(map(int,input().split())), reverse=True)\n \nfor i in r:\n p_min = p[X - 1]\n q_min = q[Y - 1]\n \n if p_min > i and q_min > i:\n break\n \n p_min_diff = i - p_min\n q_min_diff = i - q_min\n \n if p_min_diff >= q_min_diff and p_min_diff > 0:\n p.pop()\n p.insert(0, i)\n elif q_min_diff >= p_min_diff and q_min_diff > 0:\n q.pop()\n q.insert(0, i)\n \nprint(sum(p) + sum(q) + sum(colored))', 'from collections import deque\n\nX, Y, A, B, C = map(int, input().split())\n \np = deque(sorted(list(map(int,input().split())))[-X:])\nq = deque(sorted(list(map(int,input().split())))[-Y:])\nr = sorted(list(map(int,input().split())), reverse=True)\n \nfor i in r:\n p_min = p[0]\n q_min = q[0]\n \n if p_min > i and q_min > i:\n break\n \n p_min_diff = i - p_min\n q_min_diff = i - q_min\n \n if p_min_diff >= q_min_diff and p_min_diff > 0:\n p.popleft()\n p.append(i)\n elif q_min_diff >= p_min_diff and q_min_diff > 0:\n q.popleft()\n q.append(i)\n \nprint(sum(p) + sum(q))']
['Runtime Error', 'Accepted']
['s424413125', 's999644765']
[22504.0, 23008.0]
[2104.0, 274.0]
[608, 606]
p02727
u865383026
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\ns = p + q + r\nS = sorted(s, reverse = True)\ni = 0\nj = 0\nans = 0\na = 0\nb = 0\nc = 0\nwhile i < (X + Y):\n if S[j] in r:\n c += 1\n r.remove(s[j])\n ans += S[j]\n i += 1\n elif S[j] in p and a < X:\n a += 1\n p.remove(S[j])\n ans += S[j]\n i += 1\n elif S[j] in q and b < Y:\n b += 1\n q.remove(S[j])\n ans += S[j]\n i += 1\n j += 1\nprint(ans)', 'X, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\ns = p + q + r\nS = sorted(s, reverse = True)\nprint(S)\ni = 0\nj = 0\nans = 0\na = 0\nb = 0\nc = 0\nwhile i < (X + Y):\n if S[j] in r:\n c += 1\n r.remove(s[j])\n ans += S[j]\n i += 1\n elif S[j] in p and a < X:\n a += 1\n p.remove(S[j])\n ans += S[j]\n i += 1\n elif S[j] in q and b < Y:\n b += 1\n q.remove(S[j])\n ans += S[j]\n i += 1\n j += 1\nprint(ans)', 'X, Y, A, B, C = map(int, input().split())\np = sorted(list(map(int, input().split())), reverse = True)\nq = sorted(list(map(int, input().split())), reverse = True)\nr = sorted(list(map(int, input().split())), reverse = True)\nS = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)\nprint(sum(S[:X+Y]))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s028598251', 's861863127', 's152690330']
[22924.0, 33440.0, 22720.0]
[2105.0, 2105.0, 249.0]
[513, 522, 293]
p02727
u872158847
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nc = [int(i) for i in input().split()]\na = sorted(a, reverse=True)\nb = sorted(b, reverse=True)\nc = sorted(c, reverse=True)\na2 = a[:]\nb2 = b[:]\nc2 = c[:]\nsum1 = 0\nfor i in range(X):\n if a[0] < c[0]:\n sum1 += c.pop(0)\n else:\n sum1 += a.pop(0)\nfor i in range(Y):\n if b[0] < c[0]:\n sum1 += c.pop(0)\n else:\n sum1 += b.pop(0)\nsum2 = 0\nfor i in range(Y):\n if b2[0] < c2[0]:\n sum2 += c2.pop(0)\n else:\n sum2 += b2.pop(0)\nfor i in range(X):\n if a2[0] < c2[0]:\n sum2 += c2.pop(0)\n else:\n sum2 += a2.pop(0)\n \nif sum1 > sum2:\n print(sum1)\nelse:\n print(sum2)\n', 'X, Y, A, B, C = map(int, input().split())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nc = [int(i) for i in input().split()]\na = sorted(a, reverse=True)\nb = sorted(b, reverse=True)\nc = sorted(c, reverse=True)\na2 = a[:]\nb2 = b[:]\nc2 = c[:]\nsum1 = 0\nfor i in range(X):\n if a[0] < c[0]:\n sum1 += c.pop(0)\n else:\n sum1 += a.pop(0)\nfor i in range(Y):\n if b[0] < c[0]:\n sum1 += c.pop(0)\n else:\n sum1 += b.pop(0)\nsum2 = 0\nfor i in range(Y):\n if b2[0] < c2[0]:\n sum2 += c2.pop(0)\n else:\n sum2 += b2.pop(0)\nfor i in range(X):\n if a2[0] < c2[0]:\n sum2 += c2.pop(0)\n else:\n sum2 += a2.pop(0) \nif sum1 > sum2:\n print(sum1)\nelse:\n print(sum2)\n', 'X, Y, A, B, C = map(int, input().split())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nc = [int(i) for i in input().split()]\na = sorted(a, reverse=True)[:X]\nb = sorted(b, reverse=True)[:Y]\nprint(sum(sorted(a + b + c, reverse=True)[:X+Y]))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s436475587', 's539706204', 's540755030']
[23372.0, 23200.0, 23340.0]
[2105.0, 2105.0, 252.0]
[755, 754, 270]
p02727
u879266613
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X,Y,A,B,C = map(int,input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\n\np.sort(reverse = True)\nq.sort(reverse = True)\nr.sort(reverse = True)\nl = p[:X] + q[:Y]\nl.sort()\nprint(l)\nfor i in range(min(C,X+Y)):\n if r[i] > l[i]:\n l[i] = r[i]\nprint(sum(l))', 'X,Y,A,B,C = map(int,input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\n\np.sort(reverse = True)\nq.sort(reverse = True)\nr.sort(reverse = True)\nl = p[:X] + q[:Y]\nl.sort()\nfor i in range(min(C,X+Y)):\n if r[i] > l[i]:\n l[i] = r[i]\nprint(sum(l))']
['Wrong Answer', 'Accepted']
['s175486824', 's564387122']
[24816.0, 23328.0]
[296.0, 250.0]
[332, 323]
p02727
u924273546
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['#coding:utf-8\nx, y, a, b, c = map(int, input().split())\np = [int(i) for i in input().split()]\nq = [int(i) for i in input().split()]\nr = [int(i) for i in input().split()]\np[0:x]\nq[0:y]\n\np.extend(q)\np.extend(r)\np.sort(reverse = True)\nprint(p)\n\nans = 0\n\nfor i in range(x + y):\n ans += p[i]\n \nprint("{}".format(ans))', '#coding:utf-8\nx, y, a, b, c = map(int, input().split())\np = [int(i) for i in input().split()]\nq = [int(i) for i in input().split()]\nr = [int(i) for i in input().split()]\np.sort(reverse = True)\nq.sort(reverse = True)\n\np = p[0:x]\nq = q[0:y]\n\np.extend(q)\np.extend(r)\np.sort(reverse = True)\n\nans = 0\n\nfor i in range(x + y):\n ans += p[i]\n \nprint("{}".format(ans))']
['Wrong Answer', 'Accepted']
['s927782929', 's228234125']
[30936.0, 23340.0]
[304.0, 290.0]
[314, 360]
p02727
u928784113
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nfrom fractions import gcd\nfrom copy import deepcopy\nimport math\nimport queue\nimport numpy as np\n\nMod = 1000000007\nimport sys\nsys.setrecursionlimit(100000) \n \ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n\n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[py] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\n\ndef main(): #startline-------------------------------------------\n x,y,a,b,c = map(int,input().split())\n p = list(map(int,input().split()))\n q = list(map(int,input().split()))\n r = list(map(int,input().split()))\n p.sort(reverse = True)\n q.sort(reverse = True)\n r.sort()\n xlist = []\n ylist = []\n for i in range(x):\n if len(r) != 0:\n if p[i] > r[-1]:\n xlist.append(p[i])\n else:\n rele = r.pop()\n xlist.append(rele)\n else:\n xlist.append(p[i])\n for i in range(y):\n if len(r) != 0:\n if q[i] > r[-1]:\n ylist.append(q[i])\n else:\n rele = r.pop()\n ylist.append(rele)\n else:\n ylist.append(q[i])\n \n print(sum(xlist)+sum(ylist))\nif __name__ == "__main__":\n main() ', 'import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nfrom fractions import gcd\nfrom copy import deepcopy\nimport math\nimport queue\nimport numpy as np\n\nMod = 1000000007\nimport sys\nsys.setrecursionlimit(100000) \n \ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n\n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[py] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\n\ndef main(): #startline-------------------------------------------\n x,y,a,b,c = map(int,input().split())\n p = list(map(int,input().split()))\n q = list(map(int,input().split()))\n r = list(map(int,input().split()))\n p.sort(reverse = True)\n q.sort(reverse = True)\n r.sort(reverse = True)\n p = p[:x]\n q = q[:y]\n for i in range(x):\n p[i] *= -1\n for i in range(y):\n q[i] *= -1\n biglist = p+q\n heapify(p+q)\n for i in range(c):\n heappush(biglist,-r[i])\n ans = 0\n for i in range(x+y):\n ans += -heappop(biglist)\n print(ans)\n\nif __name__ == "__main__":\n main() ', 'import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nfrom fractions import gcd\nfrom copy import deepcopy\nimport math\nimport queue\nimport numpy as np\n\nMod = 1000000007\nimport sys\nsys.setrecursionlimit(100000) \n \ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n\n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[py] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\n\ndef main(): #startline-------------------------------------------\n x,y,a,b,c = map(int,input().split())\n p = list(map(int,input().split()))\n q = list(map(int,input().split()))\n r = list(map(int,input().split()))\n p.sort(reverse = True)\n q.sort(reverse = True)\n r.sort()\n xlist = []\n ylist = []\n for i in range(x):\n if len(r) != 0:\n if p[i] >= r[-1]:\n xlist.append(p[i])\n else:\n rele = r.pop()\n xlist.append(rele)\n else:\n xlist.append(p[i])\n for i in range(y):\n if len(r) != 0:\n if q[i] >= r[-1]:\n ylist.append(q[i])\n else:\n rele = r.pop()\n ylist.append(rele)\n else:\n ylist.append(q[i])\n\n print(sum(xlist)+sum(ylist))\n\n\nif __name__ == "__main__":\n main() ', 'import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nimport math\nfrom copy import deepcopy\nimport queue\nimport numpy as np\n\nMod = 1000000007\ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n\n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[y] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\n\ndef main(): #startline-------------------------------------------\n x, y, a, b, c = map(int, input().split())\n p = list(map(int, input().split()))\n q = list(map(int, input().split()))\n r = list(map(int, input().split()))\n p = sorted(p)[::-1][:x]\n q = sorted(q)[::-1][:y]\n A = p + q + r\n A.sort(reverse=True)\n print(sum(A[:x+y]))\nif __name__ == "__main__":\n main() ']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s248264856', 's366970787', 's844624796', 's641478773']
[34028.0, 34072.0, 34076.0, 31316.0]
[387.0, 519.0, 393.0, 374.0]
[2357, 2114, 2360, 1799]
p02727
u934868410
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c = map(int,input().split())\np = sorted(list(map(int,input().split())), reverse=True)\nq = sorted(list(map(int,input().split())), reverse=True)\nr = sorted(list(map(int,input().split())), reverse=True)\npq = sorted(p[:x] + q[:y])\nans = sum(pq)\ni = 0\nwhile i < min(a+b, c):\n if r[i] <= pq[i]:\n break\n ans += r[i] - pq[i]\nprint(ans)', 'x,y,a,b,c = map(int,input().split())\np = sorted(list(map(int,input().split())), reverse=True)\nq = sorted(list(map(int,input().split())), reverse=True)\nr = sorted(list(map(int,input().split())), reverse=True)\npq = sorted(p[:x] + q[:y])\nans = sum(pq)\ni = 0\nwhile i < min(a+b, c):\n if r[i] <= pq[i]:\n break\n ans += r[i] - pq[i]\n i += 1\nprint(ans)']
['Time Limit Exceeded', 'Accepted']
['s706649860', 's728779775']
[29364.0, 29320.0]
[2206.0, 197.0]
[340, 349]
p02727
u941047297
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
["def main():\n x, y, a, b, c = list(map(int, input().split()))\n P = list(map(int, input().split()))\n Q = list(map(int, input().split()))\n R = list(map(int, input().split()))\n P = sorted(P, reverse = True)[:x]\n Q = sorted(Q, reverse = True)[:y]\n ans = P + Q + R\n print(sum(ans[:x + y]))\n\nif __name__ == '__main__':\n main()\n", "def main():\n x, y, a, b, c = list(map(int, input().split()))\n P = list(map(int, input().split()))\n Q = list(map(int, input().split()))\n R = list(map(int, input().split()))\n P = sorted(P, reverse = True)[:x]\n Q = sorted(Q, reverse = True)[:y]\n ans = sorted(P + Q + R, reverse = True)\n print(sum(ans[:x + y]))\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s165175165', 's085600231']
[29540.0, 29364.0]
[125.0, 151.0]
[347, 371]
p02727
u944643608
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['from sys import stdin\ninput = stdin.readline\nX, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\nred = sorted(p)\ngreen = sorted(q)\nno = sorted(r)\nred.reverse()\ngreen.reverse()\nno.reverse()\n\nc_r = 0\nc_g = 0\nc_n = 0\nans = 0\n\nwhile (c_r < X) and (c_g < Y) and (c_n < C):\n tmp = min(red[X-c_r-1],green[Y-c_g-1])\n if tmp > no[c_n]:\n break\n else:\n ans += no[c_n]\n c_n += 1\n if red[X-c_r] > green[Y-c_g]:\n c_g += 1\n else:\n c_r += 1\n\nif c_r == X:\n while (c_n < C) and (c_g < Y):\n if green[c_g] > no[c_n] :\n break\n else:\n ans += no[c_n]\n c_g += 1\n c_n += 1\nelif c_g == Y:\n while (c_n < C) and (c_r < X):\n if red[c_r] > no[c_n] :\n break\n else:\n ans += no[c_n]\n c_r += 1\n c_n += 1\n\nif c_r != X:\n ans += sum(red[0:X-c_r])\nif c_g != Y:\n ans += sum(green[0:Y-c_g])\nprint(ans)', 'from sys import stdin\ninput = stdin.readline\nX, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()) for _ in range(X))\nq = list(map(int, input().split()) for _ in range(Y))\nr = list(map(int, input().split()))\nred = sorted(p, reverse = True)\ngreen = sorted(q, reverse = True)\nno = sorted(r, reverse = True)\n\nc_r = 0\nc_g = 0\nc_n = 0\nans = 0\n\nwhile (c_r < X) and (c_g < Y) and (c_n < C):\n tmp = min(red[X-c_r-1],green[Y-c_g-1])\n if tmp > no[c_n]:\n break\n else:\n ans += no[c_n]\n c_n += 1\n if red[X-c_r] > green[Y-c_g]:\n c_g += 1\n else:\n c_r += 1\n\nif c_r == X:\n while (c_n < C) and (c_g < Y):\n if green[c_g] > no[c_n] :\n break\n else:\n ans += no[c_n]\n c_g += 1\n c_n += 1\nelif c_g == Y:\n while (c_n < C) and (c_r < X):\n if red[c_r] > no[c_n] :\n break\n else:\n ans += no[c_n]\n c_r += 1\n c_n += 1\n\nif c_r != X:\n ans += sum(red[0:X-c_r-1])\nif c_g != Y:\n ans += sum(green[0:Y-c_g-1])\nprint(ans)', 'from sys import stdin\ninput = stdin.readline\nX, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()) for _ in range(X))\nq = list(map(int, input().split()) for _ in range(Y))\nr = list(map(int, input().split()))\nnew = p + q + r\nnew = sorted(new, reverse = True)\nprint(sum(new[0:X+Y]))', 'from sys import stdin\ninput = stdin.readline\nX, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()) for _ in range(X))\nq = list(map(int, input().split()) for _ in range(Y))\nr = list(map(int, input().split()))\nred = sorted(p, reverse = True)\ngreen = sorted(q, reverse = True)\nno = sorted(r, reverse = True)\n\nc_r = 0\nc_g = 0\nc_n = 0\nans = 0\n\nwhile (c_r < X) and (c_g < Y) and (c_n < C):\n tmp = min(red[X-c_r-1],green[Y-c_g-1])\n if tmp > no[c_n]:\n break\n else:\n ans += no[c_n]\n c_n += 1\n if red[X-c_r] > green[Y-c_g]:\n c_g += 1\n else:\n c_r += 1\n\nif c_r == X:\n while (c_n < C) and (c_g < Y):\n if green[c_g] > no[c_n] :\n break\n else:\n ans += no[c_n]\n c_g += 1\n c_n += 1\nelif c_g == Y:\n while (c_n < C) and (c_r < X):\n if red[c_r] > no[c_n] :\n break\n else:\n ans += no[c_n]\n c_r += 1\n c_n += 1\n\nif c_r != X:\n ans += sum(red[0:X-c_r-1])\nif c_g != Y:\n ans += sum(green[0:Y-c_g-1])\nprint(ans)\n \n \n \n \n \n \n \n \n \n ', 'X, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()) for _ in range(X))\nq = list(map(int, input().split()) for _ in range(Y))\nr = list(map(int, input().split()))\nnew = p + q + r\nnew = sorted(new, reverse = True)\nprint(sum(new[0:X+Y]))\n', 'from sys import stdin\ninput = stdin.readline\nX, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\nred = sorted(p, reverse = True)\ngreen = sorted(q, reverse = True)\nno = sorted(r, reverse = True)\n\nc_r = 0\nc_g = 0\nc_n = 0\nans = 0\n\nwhile (c_r < X) and (c_g < Y) and (c_n < C):\n tmp = min(red[X-c_r-1],green[Y-c_g-1])\n if tmp > no[c_n]:\n break\n else:\n ans += no[c_n]\n c_n += 1\n if red[X-c_r] > green[Y-c_g]:\n c_g += 1\n else:\n c_r += 1\n\nif c_r == X:\n while (c_n < C) and (c_g < Y):\n if green[c_g] > no[c_n] :\n break\n else:\n ans += no[c_n]\n c_g += 1\n c_n += 1\nelif c_g == Y:\n while (c_n < C) and (c_r < X):\n if red[c_r] > no[c_n] :\n break\n else:\n ans += no[c_n]\n c_r += 1\n c_n += 1\n\nif c_r != X:\n ans += sum(red[0:X-c_r-1])\nif c_g != Y:\n ans += sum(green[0:Y-c_g-1])\nprint(ans)\n', 'X, Y, A, B, C = map(int, input().split())\np = list(map(int, input().split()))\nq = list(map(int, input().split()))\nr = list(map(int, input().split()))\np.sort()\np.reverse()\nq.sort()\nq.reverse()\nnew = p[0:X] + q[0:Y] + r\nnew.sort()\nnew.reverse()\nprint(sum(new[0:X+Y]))\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s274343415', 's359970157', 's360887801', 's593152651', 's712933733', 's963872298', 's258590975']
[22720.0, 96176.0, 98280.0, 96176.0, 28732.0, 22720.0, 23328.0]
[311.0, 1019.0, 1042.0, 1039.0, 90.0, 316.0, 241.0]
[943, 988, 303, 1020, 259, 953, 266]
p02727
u948522631
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c=map(int,input().split())\np=list(map(int,input().split())).sort()\nq=list(map(int,input().split())).sort()\nr=list(map(int,input().split())).sort()\n\n\nred=0\nfor _ in range(x):\n\tpMax=max(p)\n\trMax=max(r)\n\tif pMax >rMax:\n\t\tred+=pMax\n\t\tp.pop(p.index(pMax))\n\telse:\n\t\tred+=rMax\n\t\tr.pop(r.index(rMax))\n\nwhite=0\nfor _ in range(y):\n\tqMax=max(q)\n\trMax=max(r)\n\tif qMax >rMax:\n\t\tred+=qMax\n\t\tq.pop(q.index(qMax))\n\telse:\n\t\tred+=rMax\n\t\tr.pop(r.index(rMax))\n\nprint(white+red)', 'x,y,a,b,c=map(int,input().split())\np=list(map(int,input().split()))\nq=list(map(int,input().split()))\nr=list(map(int,input().split()))\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\np=p[:x]\nq=q[:y]\n\np.extend(q)\np.sort()\nr=r[:x+y]# able add\nlenR=len(r)\n\ntemp=p[:lenR]\ntemp.extend(r)\ntemp.sort(reverse=True)\ntemp=temp[:lenR]\n\nprint(sum(p[lenR:])+sum(temp))']
['Runtime Error', 'Accepted']
['s976507829', 's966344713']
[15440.0, 23328.0]
[190.0, 244.0]
[465, 475]
p02727
u948779457
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X,Y,A,B,C = map(int,input().split())\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\nZ = X+Y\nP = p[:X]\nQ = q[:Y]\nR = r[:Z]\nans = 0\nif X <= Y:\n S = P + R\n S.sort(reverse=True)\n a = S[:X]\n b = S[X:]\n ans += sum(a)\n T = Q + b\n T.sort(reverse=True)\n c = T[:Y]\n ans += sum(c)\nelse:\n S = Q + R\n S.sort(reverse=True)\n a = S[:Y]\n b = S[Y:]\n ans += sum(a)\n T = P + b\n T.sort(reverse=True)\n c = T[:X]\n ans += sum(c)\nprint(ans)\nprint(a,b)', 'X,Y,A,B,C = map(int,input().split())\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\nZ = X+Y\nP = p[:X]\nQ = q[:Y]\nR = r[:Z]\nans = 0\nif X <= Y:\n S = P + R\n S.sort(reverse=True)\n a = S[:X]\n b = S[X:]\n ans += sum(a)\n T = Q + b\n T.sort(reverse=True)\n c = T[:Y]\n ans += sum(c)\nelse:\n S = Q + R\n S.sort(reverse=True)\n a = S[:Y]\n b = S[Y:]\n ans += sum(a)\n T = P + b\n T.sort(reverse=True)\n c = T[:X]\n ans += sum(c)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s138611232', 's740084499']
[28772.0, 23596.0]
[294.0, 252.0]
[565, 554]
p02727
u951113446
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['def MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\n\nif __name__ == "__main__":\n X, Y, A, B, C = MI()\n p = LI()\n p.reverse()\n q = LI()\n q.reverse()\n pq = p[:X] + q[:Y] + LI()\n pq.reverse()\n print(sum(pq[:X+Y]))', 'def MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\n\nif __name__ == "__main__":\n X, Y, A, B, C = MI()\n p = LI()\n p.reverse()\n q = LI()\n q.reverse()\n pq = p[:X] + q[:Y] + LI()\n print(sum(pq[:X+Y]))', 'def MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\n\nif __name__ == "__main__":\n X, Y, A, B, C = MI()\n p = LI()\n p.reverse()\n q = LI()\n q.reverse()\n pq = p[:X] + q[:Y] + LI()\n pq.sort()\n print(sum(pq[:X+Y]))', 'def MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\n\nif __name__ == "__main__":\n X, Y, A, B, C = MI()\n p = LI()\n p.sort(reverse=True)\n q = LI()\n q.sort(reverse=True)\n pq = p[:X] + q[:Y] + LI()\n pq.sort(reverse=True)\n print(sum(pq[:X+Y]))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s086772997', 's618213730', 's657257422', 's978923010']
[23968.0, 23968.0, 23968.0, 23968.0]
[99.0, 100.0, 237.0, 245.0]
[274, 257, 271, 301]
p02727
u952669998
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c= list(map(int,input().split()))\n\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\np.sort()\nq.sort()\nr.sort()\n\nt=p[0:x] + q[0:y] + r\nt.sort()\nprint(sum(t[0:(x+y)]))', 'X,Y,A,B,C = list(map(int,input().split()))\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\n\ntaberu = p[0:X] + q[0:Y] + r\ntaberu.sort(reverse=True)\n\nprint(sum(taberu[0:X+Y]))\n']
['Wrong Answer', 'Accepted']
['s014410933', 's875936265']
[23328.0, 23328.0]
[242.0, 258.0]
[229, 295]
p02727
u954489496
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['from sys import stdin, stdout \n\nX,Y,A,B,C = [int(c) for c in input().split()]\n\np= [int(c) for c in input().split()]\nq= [int(c) for c in input().split()]\nr= [int(c) for c in input().split()]\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\np=p[:X]\nq=q[:Y]\n \np.sort()\nq.sort()\nres=sum(p)+sum(q)\n\ni=j=0\n\nfor k,val in enumerate(R):\n if(i<len(p) and j<len(q)):\n if(val<=p[i] and val <= q[j]):\n break\n if(val>p[i] and val<q[j]):\n res=res+val-p[i]\n i=i+1\n if(val<p[i] and val>q[j]):\n res=res+val-q[j]\n j=j+1\n if(val>p[i] and val>q[j]):\n if(p[i]>q[j]):\n res=res+val-q[j]\n j=j+1\n else:\n res=res+val-p[i]\n i=i+1\n if(i<len(p) and j==len(q)):\n if(val<=p[i]):\n break\n if(val>p[i]):\n res=res+val-p[i]\n i=i+1\n if(i==len(p) and j<len(q)):\n if(val<=q[j]):\n break\n if(val>q[j]):\n res=res+val-q[j]\n j=j+1\n if(i==len(p) and j==len(q)):\n break\n \nprint(res)', 'from sys import stdin, stdout \n\nX,Y,A,B,C = [int(c) for c in input().split()]\n\np= [int(c) for c in input().split()]\nq= [int(c) for c in input().split()]\nr= [int(c) for c in input().split()]\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\np=p[:X]\nq=q[:Y]\n \np.sort()\nq.sort()\nres=sum(p)+sum(q)\n\ni=j=0\n\nfor k,val in enumerate(r):\n if(i<len(p) and j<len(q)):\n if(val<=p[i] and val <= q[j]):\n break\n elif(val>p[i] and val<q[j]):\n res=res+val-p[i]\n i=i+1\n elif(val<p[i] and val>q[j]):\n res=res+val-q[j]\n j=j+1\n elif(val>p[i] and val>q[j]):\n if(p[i]>q[j]):\n res=res+val-q[j]\n j=j+1\n else:\n res=res+val-p[i]\n i=i+1\n elif(i<len(p) and j==len(q)):\n if(val<=p[i]):\n break\n elif(val>p[i]):\n res=res+val-p[i]\n i=i+1\n elif(i==len(p) and j<len(q)):\n if(val<=q[j]):\n break\n elif(val>q[j]):\n res=res+val-q[j]\n j=j+1\n elif(i==len(p) and j==len(q)):\n break\n \nprint(res)']
['Runtime Error', 'Accepted']
['s133246142', 's567776987']
[22992.0, 22992.0]
[214.0, 323.0]
[1140, 1156]
p02727
u958053648
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X,Y,A,B,C=map(int,input().split())\np=sorted(map(int,input().split()))\nq=sorted(map(int,input().split()))\nr=sorted(map(int,input().split()))\nans=[]\nans+=p[A-X:]\nans+=q[B-Y:]\nans.sort()\ni=0\nj=0\nfor i in ans:\n\tj=max(r)\n\tif i<j:\n\t\tans[i]=r.pop()\nprint(sum(ans))\n\n', 'X,Y,A,B,C=map(int,input().split())\np=sorted(map(int,input().split()))\nq=sorted(map(int,input().split()))\nr=sorted(map(int,input().split()))\nans=[]\nans+=p[A-X:]\nans+=q[B-Y:]\nans.sort()\ni=0\nfor i in ans:\n\tif i<r[-1]:\n\t\tans[i]=r.pop()\n\telse:\n\t\tbreak\nprint(sum(ans))\n\n', 'X,Y,A,B,C=map(int,input().split())\np=sorted(map(int,input().split()))\nq=sorted(map(int,input().split()))\nr=sorted(map(int,input().split()))\nans=[]\nans+=p[A-X:]\nans+=q[B-Y:]\ni=0\nj=0\nwhile True:\n\ti=max(r)\n\tj=min(ans)\n\tif i>j:\n\t\tans.remove(j)\n\t\tans.append(i)\n\t\tr.remove(i)\n\telse:\n\t\tbreak\nprint(sum(ans))\n', 'X,Y,A,B,C=map(int,input().split())\np=sorted(map(int,input().split()))\nq=sorted(map(int,input().split()))\nr=sorted(map(int,input().split()))\nans=[]\nans+=p[A-X:]\nans+=q[B-Y:]\nans.sort()\nj=0\nfor i in ans:\n\tif i<r[-1]:\n\t\tans[j]=r.pop()\n\t\tj+=1\n\telse:\n\t\tbreak\nprint(sum(ans))\n\n', 'X,Y,A,B,C=map(int,input().split())\np=sorted(map(int,input().split()))\nq=sorted(map(int,input().split()))\nr=sorted(map(int,input().split()))\nans=[]\nans+=p[A-X:]\nans+=q[B-Y:]\nans.sort()\nj=0\nk=0\nfor i in ans:\n\tif len(r)>1:\n\t\tk=r[-1]\n\telif len(r)==1:\n\t\tk=r[0]\n\telse:\n\t\tbreak\n\tif i<k:\n\t\tans[j]=r.pop()\n\t\tj+=1\n\telse:\n\t\tbreak\nprint(sum(ans))\n\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s234096638', 's334002882', 's596671319', 's946479613', 's067250108']
[22560.0, 23328.0, 23328.0, 23328.0, 23328.0]
[2104.0, 215.0, 2105.0, 263.0, 266.0]
[259, 264, 301, 271, 336]
p02727
u960524878
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c=map(int,input().split())\np,q,r=[reversed(sorted(list(map(int,input())))) for i in range(3)]\np=p[0:x]\nq=q[0:y]\np.append(0)\nq.append(0)\nr.append(0)\n\ns=0\ni,j,k=0,0,0\n\nfor _ in range(x+y):\n if p[i]>=q[j] and p[i]>=r[k]:\n s+=p[i]\n i+=1\n elif q[j]>=r[k]:\n s+=q[j]\n j+=1\n else:\n s+=r[k]\n k+=1\n \nprint(s)\n', 'x,y,a,b,c=map(int,input().split())\np,q,r=[reversed(sorted(list(map(int,input().split())))) for i in range(3)]\np=p[0:x]\nq=q[0:y]\np.append(0)\nq.append(0)\nr.append(0)\n\ns=0\ni,j,k=0,0,0\n\nfor _ in range(x+y):\n if p[i]>=q[j] and p[i]>=r[k]:\n s+=p[i]\n i+=1\n elif q[j]>=r[k]:\n s+=q[j]\n j+=1\n else:\n s+=r[k]\n k+=1\n \nprint(s)\n', 'x,y,a,b,c=map(int,input().split())\np,q,r=[list(reversed(sorted(list(map(int,input().split()))))) for i in range(3)]\np=p[0:x]\nq=q[0:y]\np.append(0)\nq.append(0)\nr.append(0)\n\ns=0\ni,j,k=0,0,0\n\nfor _ in range(x+y):\n if p[i]>=q[j] and p[i]>=r[k]:\n s+=p[i]\n i+=1\n elif q[j]>=r[k]:\n s+=q[j]\n j+=1\n else:\n s+=r[k]\n k+=1\n \nprint(s)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s781101928', 's896335076', 's096799883']
[5236.0, 23200.0, 22720.0]
[22.0, 203.0, 298.0]
[331, 339, 345]
p02727
u961674365
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c=map(int,input().split())\nre=list(map(int,input().split()))\ngr=list(map(int,input().split()))\nmu=list(map(int,input().split()))\nre.sort(reverse=1)\ngr.sort(reverse=1)\nmu.sort(reverse=1)\nans=sum(re[:x])\nind=0\nfor i in range(x):\n v=re[x-1-i]\n if i+1>c:\n break\n w=mu[i]\n if v<w:\n ans+=w-v\n else:\n ind=i+1\n break\n\nans+=sum(gr[:y])\nfor i in range(y):\n v=gr[y-1-i]\n if ind+i+1>c:\n break\n w=mu[ind+i]\n if v<=w:\n ans+=w-v\n else:\n ind=i\n break\n\n\n\n\n\nprint(ans)\n#print(re,gr,mu,ans)', 'x,y,a,b,c=map(int,input().split())\nre=list(map(int,input().split()))\ngr=list(map(int,input().split()))\nmu=list(map(int,input().split()))\nre.sort(reverse=1)\ngr.sort(reverse=1)\nmu.sort(reverse=1)\nre=re[:x]\ngr=gr[:y]\napp=mu[:]\napp.extend(re)\napp.extend(gr)\napp.sort(reverse=1)\napp=app[:x+y]\n\n\nprint(sum(app))']
['Wrong Answer', 'Accepted']
['s302066186', 's961640212']
[23328.0, 22720.0]
[301.0, 239.0]
[513, 305]
p02727
u970523279
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x, y, a, b, c = map(int, input().split())\np = sorted(map(int, input().split()))[::-1]\nq = sorted(map(int, input().split()))[::-1]\nr = sorted(map(int, input().split()))[::-1]\n\nz = 0\nred, green = 0, 0\nans = 0\nwhile True:\n finish = True\n if p[x] <= q[y]:\n if z < c and p[x] < r[z]:\n x -= 1\n z += 1\n finish = False\n else:\n if z < c and q[y] < r[z]:\n y -= 1\n z += 1\n finish = False\n if finish:\n break\nprint(sum(p[:x]) + sum(q[:y]) + sum(q[:z]))\n', 'x, y, a, b, c = map(int, input().split())\np = sorted(map(int, input().split()))[::-1]\nq = sorted(map(int, input().split()))[::-1]\nr = sorted(map(int, input().split()))[::-1]\n\nx, y = x-1, y-1\nz = 0\nred, green = 0, 0\nans = 0\nwhile True:\n finish = True\n if p[x] <= q[y] or y < 0:\n if z < c and p[x] < r[z]:\n x -= 1\n z += 1\n finish = False\n elif p[x] >= q[y] or x < 0:\n if z < c and q[y] < r[z]:\n y -= 1\n z += 1\n finish = False\n if finish:\n break\nprint(sum(p[:x+1]) + sum(q[:y+1]) + sum(r[:z]))\n']
['Runtime Error', 'Accepted']
['s242480686', 's163920752']
[23248.0, 23072.0]
[268.0, 273.0]
[539, 590]
p02727
u977193988
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['import sys\nimport heapq\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nMOD = 10 ** 9 + 7\nsys.setrecursionlimit(20000000)\n\n\ndef main():\n X, Y, A, B, C = map(int, input().split())\n red = list(map(int, input().split()))\n green = list(map(int, input().split()))\n nocolor = list(map(int, input().split()))\n\n red.sort()\n green.sort()\n nocolor.sort()\n answer = sum(red[A - X :]) + sum(green[B - Y :])\n heap = red[A - X :] + green[B - Y :]\n flag = 0\n while heap and flag < C:\n m = heapq.heappop(heap)\n if nocolor[flag] > m:\n answer -= m\n answer += nocolor[flag]\n heapq.heappush(heap, nocolor[flag])\n flag += 1\n else:\n heapq.heappush(heap, m)\n flag += 1\n print(answer)\n\n\nif __name__ == "__main__":\n main()\n', 'import sys\nimport heapq\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nMOD = 10 ** 9 + 7\nsys.setrecursionlimit(20000000)\n\n\ndef main():\n X, Y, A, B, C = map(int, input().split())\n red = list(map(int, input().split()))\n green = list(map(int, input().split()))\n nocolor = list(map(int, input().split()))\n\n red.sort()\n green.sort()\n nocolor.sort()\n answer = sum(red[A - X :]) + sum(green[B - Y :])\n heap = red[A - X :] + green[B - Y :]\n heapq.heapify(heap)\n flag = 0\n while heap and flag < C:\n m = heapq.heappop(heap)\n if nocolor[flag] > m:\n answer -= m\n answer += nocolor[flag]\n heapq.heappush(heap, nocolor[flag])\n flag += 1\n else:\n heapq.heappush(heap, m)\n flag += 1\n\n print(answer)\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s077747058', 's944654391']
[23456.0, 23456.0]
[315.0, 323.0]
[833, 858]
p02727
u985972698
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['def input_multiple_number():\n return map(int, input().split())\ndef input_multiple_number_as_list():\n return list(map(int, input().split()))\n\nxgiven,ygiven,agiven,bgiven,cgiven = input_multiple_number()\n\np_array = input_multiple_number_as_list()\nq_array = input_multiple_number_as_list()\nr_array = input_multiple_number_as_list()\nINF = 99999999999999999\np_array.sort()\nq_array.sort()\nr_array.sort()\n\n\ni = xgiven\np_array = p_array[0:xgiven]\nq_array = q_array[0:ygiven]\nxxx_array = p_array+q_array+r_array\n\nxxx_array.sort()\nnnn_arrat = xxx_array[0:xgiven+ygiven]\n\nvalue=0\nfor aaaaa in nnn_arrat:\n\tvalue += aaaaa\n\nprint(value)', 'def input_multiple_number():\n return map(int, input().split())\ndef input_multiple_number_as_list():\n return list(map(int, input().split()))\n\nxgiven,ygiven,agiven,bgiven,cgiven = input_multiple_number()\n\np_array = input_multiple_number_as_list()\nq_array = input_multiple_number_as_list()\nr_array = input_multiple_number_as_list()\nINF = 99999999999999999\np_array.sort(reverse=True)\nq_array.sort(reverse=True)\nr_array.sort(reverse=True)\n\n\ni = xgiven\np_array = p_array[0:xgiven]\nq_array = q_array[0:ygiven]\nxxx_array = p_array+q_array+r_array\n\n\nxxx_array.sort(reverse=True)\nnnn_arrat = xxx_array[0:xgiven+ygiven]\n\nvalue=0\nfor aaaaa in nnn_arrat:\n\tvalue += aaaaa\n\nprint(value)']
['Wrong Answer', 'Accepted']
['s998202689', 's770482217']
[23328.0, 23328.0]
[271.0, 276.0]
[647, 696]
p02727
u989345508
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['\nx,y,a,b,c=map(int,input().split())\ndef _int(x):\n return -int(x)\np=sorted(list(map(_int,input().split())),reverse=True)[:x]\nq=sorted(list(map(_int,input().split())),reverse=True)[:y]\nr=sorted(list(map(_int,input().split())),reverse=True)\n\np.extend(q)\nans=sorted(p)\n\n\nfor i in range(x+y):\n if len(r)==0:break\n if r[i]>=ans[i]:\n ans[i]=r[i]\n else:\n break\nprint(sum(ans))', '\nx,y,a,b,c=map(int,input().split())\n\np=sorted(list(map(int,input().split())),reverse=True)[:x]\nq=sorted(list(map(int,input().split())),reverse=True)[:y]\nr=sorted(list(map(int,input().split())),reverse=True)\n\np.extend(q)\nans=sorted(p)\n\n\nfor i in range(x+y):\n if len(r)==i or r[i]<ans[i]:\n break\n else:\n ans[i]=r[i]\nprint(sum(ans))']
['Runtime Error', 'Accepted']
['s736752396', 's774629980']
[22504.0, 22616.0]
[317.0, 261.0]
[468, 423]
p02727
u991269553
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['x,y,a,b,c = map(int,input().split())\n\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\nred = []\ngreen = []\n\n\n# red.append(p[i])\n# for j in range(y):\n\n\n# print(p[:x])\n# print(q[:y]\n# print(red)\n# print(green)\n\nall = p[:x] + q[:y]\nall.sort()\n\nfor i in range(len(all)):\n if min(r) > all[i]:\n #print(i)\n if i >= len(r):\n ans = all[len(r) + 1:] + r\n else:\n ans = all[i + 1:] + r[:i]\n break\n\n# for mushoku in r:\n\n# if mushoku > all[i]:\n# all[i] = mushoku\n\n\n# print(sum(all))\nprint(sum(ans))', 'x,y,a,b,c = map(int,input().split())\n\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort(reverse=True)\n\nred = []\ngreen = []\n\n\n# red.append(p[i])\n# for j in range(y):\n\n\n# print(p[:x])\n# print(q[:y]\n# print(red)\n# print(green)\n\nall = p[:x] + q[:y]\nall.sort()\n\nfor i in range(len(all)):\n if min(r) > all[i]:\n #print(i)\n if i >= len(r):\n ans = all[len(r) + 1:] + r\n else:\n ans = all[i + 1:] + r[:i]\n break\n\n# for mushoku in r:\n\n# if mushoku > all[i]:\n# all[i] = mushoku\n\n\n# print(sum(all))\nprint(sum(ans))', 'x,y,a,b,c = map(int,input().split())\n\np = list(map(int,input().split()))\nq = list(map(int,input().split()))\nr = list(map(int,input().split()))\n\np.sort(reverse=True)\nq.sort(reverse=True)\nr.sort()\n\n\nall = p[:x] + q[:y] + r\nall.sort(reverse=True)\n\nprint(sum(all[:x+y]))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s556231126', 's617037829', 's238159024']
[3064.0, 22560.0, 23328.0]
[18.0, 2105.0, 250.0]
[737, 757, 266]
p02727
u995102075
2,000
1,048,576
You are going to eat X red apples and Y green apples. You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C. Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively. From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible. Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.
['X, Y, A, B, C = map(int, input().split())\np = sorted([int(i) for i in input().split()], reverse=True)\nq = sorted([int(i) for i in input().split()], reverse=True)\nr = sorted([int(i) for i in input().split()])\n\np = p[:X]\nq = q[:Y]\nplus_r = []\n\nwhile r != [] and (p != [] and r[-1] > p[-1]) or (q != [] and r[-1] > q[-1]):\n if p[-1] < q[-1]:\n p.pop()\n else:\n q.pop()\n plus_r.append(r.pop())\n\nprint(sum(p) + sum(q) + sum(plus_r))\n', 'X, Y, A, B, C = map(int, input().split())\np = sorted([int(i) for i in input().split()], reverse=True)\nq = sorted([int(i) for i in input().split()], reverse=True)\nr = sorted([int(i) for i in input().split()])\n\np = p[:X]\nq = q[:Y]\nplus_r = []\n\nwhile r != [] and ((p != [] and r[-1] > p[-1]) or (q != [] and r[-1] > q[-1])):\n if p == []:\n q.pop()\n plus_r.append(r.pop())\n continue\n elif q == []:\n p.pop()\n plus_r.append(r.pop())\n continue\n\n if p[-1] < q[-1]:\n p.pop()\n else:\n q.pop()\n plus_r.append(r.pop())\n\nprint(sum(p) + sum(q) + sum(plus_r))\n']
['Runtime Error', 'Accepted']
['s816996261', 's325231558']
[23200.0, 23200.0]
[266.0, 279.0]
[449, 614]
p02728
u193182854
3,000
1,048,576
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. For each k=1, ..., N, solve the problem below: * Consider writing a number on each vertex in the tree in the following manner: * First, write 1 on Vertex k. * Then, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows: * Choose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random. * Find the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).
['import sys\nsys.setrecursionlimit(10**7)\nMOD = 10**9+7\n\nn = int(input())\ng = [[] for _ in range(n)]\nfor _ in range(n-1):\n a, b = map(int, input().split())\n a -= 1; b -= 1\n g[a].append(b)\n g[b].append(a)\n\nlim = 10**6 * 2\nfact = [1, 1] + [0] * (lim-1)\nfact_inv = [1, 1] + [0] * (lim-1)\ninv = [0, 1] + [0] * (lim-1)\nfor i in range(2, lim+1):\n fact[i] = fact[i-1] * i % MOD\n inv[i] = MOD - inv[MOD % i] * (MOD//i) % MOD\n fact_inv[i] = fact_inv[i-1] * inv[i] % MOD\ndef comb(n, m):\n if n < m or n < 0 or m < 0: return 0\n return fact[n] * (fact_inv[m] * fact_inv[n-m] % MOD) % MOD\n\ndp = [1] * n\nsize = [0] * n\n\ndef dfs(v, pv):\n for nv in g[v]:\n if nv == pv: continue\n dfs(nv, v)\n ns = size[nv]+1\n size[v] += ns\n dp[v] *= dp[nv] * comb(size[v], ns) % MOD\n dp[v] %= MOD\n\ndef dfs2(v, pv):\n for nv in g[v]:\n if nv == pv: continue\n d, sz = dp[v], size[v]\n d *= inv[dp[nv]] * inv[comb(sz, size[nv]+1)] % MOD\n d %= MOD\n sz -= size[nv]+1\n\n size[nv] += sz+1\n dp[nv] *= d * comb(size[nv], sz+1) % MOD\n dp[nv] %= MOD\n dfs2(nv, v)\n\ndfs(0, -1)\ndfs2(0, -1)\nprint(*dp, sep="\\n")\n', 'import sys\nsys.setrecursionlimit(10**7)\nMOD = 10**9+7\n\nn = int(input())\ng = [[] for _ in range(n)]\nfor _ in range(n-1):\n a, b = map(int, input().split())\n a -= 1; b -= 1\n g[a].append(b)\n g[b].append(a)\n\nlim = 10**7\nfact = [1, 1] + [0] * (lim-1)\nfact_inv = [1, 1] + [0] * (lim-1)\ninv = [0, 1] + [0] * (lim-1)\nfor i in range(2, lim+1):\n fact[i] = fact[i-1] * i % MOD\n inv[i] = MOD - inv[MOD % i] * (MOD//i) % MOD\n fact_inv[i] = fact_inv[i-1] * inv[i] % MOD\ndef comb(n, m):\n if n < m or n < 0 or m < 0: return 0\n return fact[n] * (fact_inv[m] * fact_inv[n-m] % MOD) % MOD\n\ndp = [1] * n\nsize = [0] * n\n\ndef dfs(v, pv):\n for nv in g[v]:\n if nv == pv: continue\n dfs(nv, v)\n ns = size[nv]+1\n size[v] += ns\n dp[v] *= dp[nv] * comb(size[v], ns) % MOD\n dp[v] %= MOD\n\ndef dfs2(v, pv):\n for nv in g[v]:\n if nv == pv: continue\n d, sz = dp[v], size[v]\n d *= inv[dp[nv]] * inv[comb(sz, size[nv]+1)] % MOD\n d %= MOD\n sz -= size[nv]+1\n\n size[nv] += sz+1\n dp[nv] *= d * comb(size[nv], sz+1) % MOD\n dp[nv] %= MOD\n dfs2(nv, v)\n\ndfs(0, -1)\ndfs2(0, -1)\nprint(*dp, sep="\\n")\n', 'import sys\nsys.setrecursionlimit(10**7)\ninput = lambda: sys.stdin.readline().rstrip()\nMOD = 10**9+7\n\nn = int(input())\ng = [[] for _ in range(n)]\nfor _ in range(n-1):\n a, b = map(int, input().split())\n a -= 1; b -= 1\n g[a].append(b)\n g[b].append(a)\n\nlim = 10**5*2\nfact = [1, 1] + [0] * (lim-1)\nfact_inv = [1, 1] + [0] * (lim-1)\ninv = [0, 1] + [0] * (lim-1)\nfor i in range(2, lim+1):\n fact[i] = fact[i-1] * i % MOD\n inv[i] = MOD - inv[MOD % i] * (MOD//i) % MOD\n fact_inv[i] = fact_inv[i-1] * inv[i] % MOD\ndef comb(n, m):\n if n < m or n < 0 or m < 0: return 0\n return fact[n] * (fact_inv[m] * fact_inv[n-m] % MOD) % MOD\ndef icomb(n, m):\n if n < m or n < 0 or m < 0: return 0\n return fact_inv[n] * (fact[m] * fact[n-m] % MOD) % MOD\n\ndp = [1] * n\nsize = [0] * n\n\ndef dfs(v, pv):\n for nv in g[v]:\n if nv == pv: continue\n dfs(nv, v)\n ns = size[nv]+1\n size[v] += ns\n dp[v] *= dp[nv] * comb(size[v], ns) % MOD\n dp[v] %= MOD\n\ndef dfs2(v, pv):\n for nv in g[v]:\n if nv == pv: continue\n d, sz = dp[v], size[v]\n d *= pow(dp[nv], MOD-2, MOD) * icomb(sz, size[nv]+1) % MOD\n d %= MOD\n sz -= size[nv]+1\n\n size[nv] += sz+1\n dp[nv] *= d * comb(size[nv], sz+1) % MOD\n dp[nv] %= MOD\n dfs2(nv, v)\n\ndfs(0, -1)\ndfs2(0, -1)\nprint(*dp, sep="\\n")\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s563193271', 's903235600', 's853172257']
[309160.0, 472316.0, 105896.0]
[3172.0, 3171.0, 2265.0]
[1194, 1190, 1363]
p02728
u532966492
3,000
1,048,576
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. For each k=1, ..., N, solve the problem below: * Consider writing a number on each vertex in the tree in the following manner: * First, write 1 on Vertex k. * Then, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows: * Choose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random. * Find the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).
['def main():\n from sys import stdin\n input=stdin.readline\n n = int(input())\n ab = [list(map(int, input().split())) for _ in [0]*(n-1)]\n\n g = [set() for _ in [0]*n]\n for a, b in ab:\n g[a-1].add(b-1)\n g[b-1].add(a-1)\n\n mod = 10**9+7\n fact = [1, 1]\n inv = [pow(i, mod-2, mod) for i in range(n+1)]\n for i in range(2, n+1):\n fact.append(fact[-1]*i % mod)\n\n def rerooting(tree, ini):\n \n def __init__(self, tree, ini):\n \n \n \n \n def merge(a, b): return a * b % mod\n def adj_bu(a, i): return a * inv[size[i]] % mod\n def adj_td(a, i, p): return a * inv[n-size[i]] % mod\n def adj_fin(a, i): return a * fact[n-1] % mod\n\n \n \n \n \n \n T = g\n P = [-1]*n\n q = [0]\n order = []\n while q:\n i = q.pop()\n order.append(i)\n for a in T[i]:\n if a != P[i]:\n P[a] = i\n T[a].remove(i)\n q.append(a)\n\n \n T = [list(i) for i in T]\n\n \n \n size = [1]*n\n for i in order[1:][::-1]:\n size[P[i]] += size[i]\n\n \n \n \n ME = [ini]*n\n DP = [0]*n\n for i in order[1:][::-1]:\n DP[i] = adj_bu(ME[i], i)\n p = P[i]\n ME[p] = merge(ME[p], DP[i])\n DP[order[0]] = adj_fin(ME[order[0]], order[0])\n TD = [ini]*n\n\n \n for i in order:\n \n ac = TD[i]\n for j in T[i]:\n TD[j] = ac\n ac = merge(ac, DP[j])\n \n ac = ini\n for j in T[i][::-1]:\n TD[j] = adj_td(merge(TD[j], ac), j, i)\n ac = merge(ac, DP[j])\n DP[j] = adj_fin(merge(ME[j], TD[j]), j)\n for i in DP:\n print(i)\n\n rerooting(g, 1)\n\n\nmain()', 'def main():\n n = int(input())\n ab = [list(map(int, input().split())) for _ in [0]*(n-1)]\n g = [[] for _ in [0]*n]\n [g[a-1].append(b-1) for a, b in ab]\n [g[b-1].append(a-1) for a, b in ab]\n mod = 10**9+7\n fact = [1, 1]\n for i in range(2, 200001):\n fact.append(fact[-1]*i % mod)\n\n def nCr(n, r, mod=10**9+7):\n return pow(fact[n-r]*fact[r], mod-2, mod)*fact[n] % mod\n\n class rerooting():\n \n def __init__(self, tree, ini):\n \n def add(i, j, x):\n return x+1\n\n def monoid(i, j):\n return i+j\n\n def monoid2(i, j):\n return i*j % mod\n\n def calc(i, j):\n root = tree_d[i][j]+1\n try:\n return monoid(tc_l[i][root-1], tc_r[i][root])\n except:\n return tc_l[i][root-1]\n\n def calc2(i, j):\n root = tree_d[i][j]+1\n try:\n return monoid2(tc_l2[i][root-1], tc_r2[i][root]) *\\\n nCr(tc_l[i][root-1]+tc_r[i][root], tc_l[i][root-1])\n except:\n return tc_l2[i][root-1]\n\n size = len(tree)\n dp, dp2, order, q, anc = [ini]*size, [1]*size, [], [0], [-1]*n\n oa, qa, qp = order.append, q.append, q.pop\n tree_d = [{k: j for j, k in enumerate(i)} for i in g]\n g_size = [len(i) for i in g]\n tc_l = [[ini]*(i+1) for i in g_size]\n tc_r = [[ini]*i for i in g_size]\n tc_l2 = [[1]*(i+1) for i in g_size]\n tc_r2 = [[1]*i for i in g_size]\n\n \n while q:\n i = qp()\n a = anc[i]\n oa(i)\n for j in g[i]:\n if j != a:\n qa(j)\n anc[j] = i\n\n \n for i in order[:0:-1]:\n a = anc[i]\n t = tree_d[a][i]\n d = dp2[i]\n tc_l2[a][t+1], tc_r2[a][t] = d, d\n d = add(a, i, dp[i])\n tc_l[a][t+1], tc_r[a][t], dp[a] = d, d, monoid(dp[a], d)\n dp2[a] = dp2[a]*dp2[i]*nCr(dp[a], dp[i]+1) % mod\n\n \n for j in range(1, g_size[0]+1):\n tc_l[0][j] = monoid(tc_l[0][j], tc_l[0][j-1])\n tc_l2[0][j] = tc_l2[0][j]*tc_l2[0][j-1] * \\\n nCr(tc_l[0][j], tc_l[0][j-1]) % mod\n for j in range(g_size[0]-1, 0, -1):\n tc_r[0][j] = monoid(tc_r[0][j], tc_r[0][j+1])\n tc_r2[0][j] = tc_r2[0][j]*tc_r2[0][j+1] * \\\n nCr(tc_r[0][j], tc_r[0][j+1]) % mod\n\n \n for i in order[1:]:\n a = anc[i]\n d, c, c2, length = tree_d[i][a], add(\n a, i, calc(a, i)), calc2(a, i), g_size[i]\n\n tc_l[i][d+1], tc_r[i][d] = c, c\n tc_l2[i][d+1], tc_r2[i][d] = c2, c2\n\n for j in range(1, length+1):\n tc_l[i][j] = monoid(tc_l[i][j], tc_l[i][j-1])\n tc_l2[i][j] = tc_l2[i][j]*tc_l2[i][j-1] * \\\n nCr(tc_l[i][j], tc_l[i][j-1]) % mod\n for j in range(length-2, 0, -1):\n tc_r[i][j] = monoid(tc_r[i][j+1], tc_r[i][j])\n tc_r2[i][j] = tc_r2[i][j]*tc_r2[i][j+1] * \\\n nCr(tc_r[i][j], tc_r[i][j+1]) % mod\n dp[i] = tc_l[i][-1]\n dp2[i] = tc_l2[i][-1]\n\n \n for i in dp2:\n print(i)\n\n rerooting(g, 0)\n\n\nmain()\n', 'def main():\n from sys import stdin\n input = stdin.readline\n n = int(input())\n ab = [list(map(int, input().split())) for _ in [0]*(n-1)]\n\n g = [set() for _ in [0]*n]\n for a, b in ab:\n g[a-1].add(b-1)\n g[b-1].add(a-1)\n\n mod = 10**9+7\n fact = [1, 1]\n inv = [pow(i, mod-2, mod) for i in range(n+1)]\n for i in range(2, n+1):\n fact.append(fact[-1]*i % mod)\n\n class rerooting():\n \n def __init__(self, tree, ini):\n \n \n \n \n def merge(a, b): return a * b % mod\n def adj_bu(a, i): return a * inv[size[i]] % mod\n def adj_td(a, i, p): return a * inv[n-size[i]] % mod\n def adj_fin(a, i): return a * fact[n-1] % mod\n\n \n \n \n \n \n T = g\n P = [-1]*n\n q = [0]\n order = []\n while q:\n i = q.pop()\n order.append(i)\n for a in T[i]:\n if a != P[i]:\n P[a] = i\n T[a].remove(i)\n q.append(a)\n\n \n T = [list(i) for i in T]\n\n \n \n size = [1]*n\n for i in order[1:][::-1]:\n size[P[i]] += size[i]\n\n \n \n \n ME = [ini]*n\n DP = [0]*n\n for i in order[1:][::-1]:\n DP[i] = adj_bu(ME[i], i)\n p = P[i]\n ME[p] = merge(ME[p], DP[i])\n DP[order[0]] = adj_fin(ME[order[0]], order[0])\n TD = [ini]*n\n\n \n for i in order:\n \n ac = TD[i]\n for j in T[i]:\n TD[j] = ac\n ac = merge(ac, DP[j])\n \n ac = ini\n for j in T[i][::-1]:\n TD[j] = adj_td(merge(TD[j], ac), j, i)\n ac = merge(ac, DP[j])\n DP[j] = adj_fin(merge(ME[j], TD[j]), j)\n for i in DP:\n print(i)\n\n rerooting(g, 1)\n\n\nmain()\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s221017513', 's994410978', 's682869646']
[136288.0, 272132.0, 169824.0]
[1390.0, 3172.0, 2828.0]
[3064, 4082, 3060]
p02728
u608088992
3,000
1,048,576
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. For each k=1, ..., N, solve the problem below: * Consider writing a number on each vertex in the tree in the following manner: * First, write 1 on Vertex k. * Then, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows: * Choose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random. * Find the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).
['import sys\nfrom collections import deque\nsys.setrecursionlimit(1000000)\n\ndef comb(n, r, fact, revfact, mod):\n return (fact[n] * (revfact[n-r] * revfact[r]) % mod) % mod\n\ndef dfs(i, parent, DP, sNum, E, fact, revfact, mod):\n Ans = 1\n sonNode = 1\n S = []\n for e in E[i]:\n if e != parent:\n mult, sn = dfs(e, i, DP, sNum, E, fact, revfact, mod)\n S.append(sn)\n Ans *= mult\n Ans %= mod\n sonNode += sn\n stotal = sonNode - 1\n for s in S:\n Ans *= comb(stotal, s, fact, revfact, mod)\n Ans %= mod\n stotal -= s\n DP[i] = Ans\n sNum[i] = sonNode - 1\n return Ans, sonNode\n\ndef solve():\n input = sys.stdin.readline\n N = int(input())\n E = [[] for _ in range(N)]\n for _ in range(N - 1):\n a, b = map(int, input().split())\n E[a-1].append(b-1)\n E[b-1].append(a-1)\n mod = 7 + 10 ** 9\n fact = [1] * (N + 1)\n for i in range(N): fact[i+1] = ((i + 1) * fact[i]) % mod\n revfact = [1] * (N + 1)\n revfact[N] = pow(fact[N], mod - 2, mod)\n for i in reversed(range(N)): revfact[i] = ((i + 1) * revfact[i + 1]) % mod\n\n DP = [1] * N\n sNum = [0] * N\n usNum = [0] * N\n Ans = [1] * N\n dfs(0, 0, DP, sNum, E, fact, revfact, mod)\n q = deque()\n for e in E[0]: q.append((e, 0))\n Ans[0] = DP[0]\n while q:\n nn, parn = q.popleft()\n upperMult = DP[parn] * pow(DP[nn], mod - 2, mod)\n usNum[nn] = upperNum = sNum[parn] - sNum[nn] + usNum[parn]\n Ans[nn] = (DP[nn] * upperMult) % mod\n totalN = upperNum\n edgeOut = [upperNum]\n for e in E[nn]:\n if e != parn:\n q.append((e, nn))\n totalN += sNum[e] + 1\n edgeOut.append(sNum[e] + 1)\n for o in edgeOut:\n Ans[nn] *= comb(totalN, o, fact, revfact, mod)\n Ans[nn] %= mod\n totalN -= o\n print("\\n".join(map(str, Ans)))\n \n return 0\n\nif __name__ == "__main__":\n solve()', 'import sys\nfrom collections import deque\nsys.setrecursionlimit(1000000)\n\ndef comb(n, r, fact, revfact, mod):\n return (fact[n] * (revfact[n-r] * revfact[r]) % mod) % mod\n\ndef dfs(i, parent, DP, sNum, E, fact, revfact, mod):\n Ans = 1\n sonNode = 1\n S = []\n for e in E[i]:\n if e != parent:\n mult, sn = dfs(e, i, DP, sNum, E, fact, revfact, mod)\n S.append(sn)\n Ans *= mult\n Ans %= mod\n sonNode += sn\n stotal = sonNode - 1\n for s in S:\n Ans *= comb(stotal, s, fact, revfact, mod)\n Ans %= mod\n stotal -= s\n DP[i] = Ans\n sNum[i] = sonNode - 1\n return Ans, sonNode\n\ndef solve():\n input = sys.stdin.readline\n N = int(input())\n E = [[] for _ in range(N)]\n for _ in range(N - 1):\n a, b = map(int, input().split())\n E[a-1].append(b-1)\n E[b-1].append(a-1)\n mod = 7 + 10 ** 9\n fact = [1] * (N + 1)\n for i in range(N): fact[i+1] = ((i + 1) * fact[i]) % mod\n revfact = [1] * (N + 1)\n revfact[N] = pow(fact[N], mod - 2, mod)\n for i in reversed(range(N)): revfact[i] = ((i + 1) * revfact[i + 1]) % mod\n\n DP = [1] * N\n sNum = [0] * N\n usNum = [0] * N\n dfs(0, 0, DP, sNum, E, fact, revfact, mod)\n q = deque()\n for e in E[0]: q.append((e, 0))\n while q:\n nn, parn = q.popleft()\n upperMult = DP[parn] * pow(comb(N-1, sNum[nn] + 1, fact, revfact, mod), mod - 2, mod)\n usNum[nn] = upperNum = sNum[parn] - sNum[nn] + usNum[parn]\n DP[nn] = (upperMult * comb(N-1, upperNum, fact, revfact, mod)) % mod\n for e in E[nn]:\n if e != parn: q.append((e, nn))\n \n print("\\n".join(map(str, DP)))\n \n return 0\n\nif __name__ == "__main__":\n solve()\n']
['Wrong Answer', 'Accepted']
['s925746042', 's367744056']
[94916.0, 92372.0]
[2151.0, 2116.0]
[2003, 1757]
p02728
u638795007
3,000
1,048,576
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. For each k=1, ..., N, solve the problem below: * Consider writing a number on each vertex in the tree in the following manner: * First, write 1 on Vertex k. * Then, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows: * Choose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random. * Find the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).
['class treedp_rerooting():\n def __init__(self, N, V, MOD):\n self.N = N\n self.V = V\n self.mod = MOD\n self.rep = [0] * N\n self.children = [-1] * N\n self.A = [0] * N\n self.C = combination(N, MOD)\n return\n\n \n def dfs(self, s):\n size = 1\n nowchild = []\n cur = 1\n self.children[s] = 0\n for i in self.V[s]:\n if self.children[i] != -1:\n continue\n ns, nc = self.dfs(i)\n nowchild.append(ns)\n size += ns\n cur *= nc\n cur %= self.mod\n self.children[s] = size\n rest = size - 1\n for k in nowchild:\n cur *= self.C.comb(rest, k)\n rest -= k\n cur %= self.mod\n self.A[s] = cur\n return size, cur\n\n def dfs2(self, s, p=-1):\n cur = 1\n rest = self.N - 1\n for to in self.V[s]:\n cur *= self.A[to]\n cur %= mod\n for to in self.V[s]:\n cur *= self.C.comb(rest, children[to])\n rest -= self.children[to]\n cur %= self.mod\n self.rep[s] = rep\n\n n = len(V[s])\n L = [0] * self.N; R = [0] * self.N\n L2 = [0] * self.N; R2 = [0] * self.N\n\n for i, ne in enumerate(self.V[s]):\n L[i] = R[i] = self.A[ne] * self.C.inv[self.children[ne]] % self.mod\n L2[i] = R2[i] = self.children[ne]\n for i in range(1, n):\n L[i] *= L[i - 1]\n L[i] %= self.mod\n L2[i] += L2[i - 1]\n for i in range(1, n - 1)[::-1]:\n R[i] *= R[i + 1]\n R[i] %= self.mod\n R2[i] += R2[i + 1]\n for i, ne in enumerate(self.V[s]):\n if ne == p:\n continue\n self.A[s] = 1\n self.children[s] = 1\n if i > 0:\n self.A[s] *= L[i - 1]\n self.A[s] %= self.mod\n self.children[s] += L2[i - 1]\n if i + 1 < n:\n self.A[s] *= R[i + 1]\n self.A[s] %= self.mod\n self.children[s] += R2[i + 1]\n self.A[s] *= self.C.fac[self.N - self.children[ne] - 1]\n self.A[s] %= self.mod\n self.dfs2(ne, s)\n return\n\nclass combination():\n \n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1] * (n + 1)\n self.inv = [1] * (n + 1)\n for j in range(1, n + 1):\n self.fac[j] = self.fac[j - 1] * j % mod\n\n self.inv[n] = pow(self.fac[n], mod - 2, mod)\n for j in range(n - 1, -1, -1):\n self.inv[j] = self.inv[j + 1] * (j + 1) % mod\n\n def comb(self, n, r):\n if r > n or n < 0 or r < 0:\n return 0\n return self.fac[n] * self.inv[n - r] * self.inv[r] % self.mod\n\ndef ABC160():\n N = I()\n V = [[] for _ in range(N)]\n for _ in range(N - 1):\n a, b = LI()\n a -= 1; b -= 1\n V[a].append(b)\n V[b].append(a)\n dp_r = treedp_rerooting(N,V,mod)\n dp_r.dfs(0)\n return\n dp_r.dfs2(0)\n\n ans = dp_r.rep\n\n for v in ans:\n print(v)\n return\n\nimport sys,bisect,itertools,heapq,math,random\nfrom copy import deepcopy\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\n\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LSI(): return list(map(str,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nglobal mod,mod2,inf,alphabet,_ep\nmod = 10**9 + 7\nmod2 = 998244353\ninf = 10**18\n_ep = 10**(-12)\nalphabet = [chr(ord(\'a\') + i) for i in range(26)]\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == \'__main__\':\n ABC160()\n\n"""\n8\n1 2\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8\n"""\n\n# 40\n# 280\n# 840\n# 120\n# 120\n# 504\n# 72\n# 72\n\n', 'class treedp_rerooting():\n def __init__(self, N, V, MOD):\n self.N = N\n self.V = V\n self.mod = MOD\n self.rep = [0] * N\n self.children = [-1] * N\n self.A = [0] * N\n self.C = combination(N, MOD)\n return\n\n \n def dfs(self, s):\n size = 1\n nowchild = []\n cur = 1\n self.children[s] = 0\n for i in self.V[s]:\n if self.children[i] != -1:\n continue\n ns, nc = dfs(i)\n nowchild.append(ns)\n size += ns\n cur *= nc\n cur %= self.mod\n self.children[s] = size\n rest = size - 1\n for k in nowchild:\n cur *= self.C.comb(rest, k)\n rest -= k\n cur %= self.mod\n self.A[s] = cur\n return size, cur\n\n def dfs2(self, s, p=-1):\n cur = 1\n rest = self.N - 1\n for to in self.V[s]:\n cur *= self.A[to]\n cur %= mod\n for to in self.V[s]:\n cur *= self.C.comb(rest, children[to])\n rest -= self.children[to]\n cur %= self.mod\n self.rep[s] = rep\n\n n = len(V[s])\n L = [0] * self.N; R = [0] * self.N\n L2 = [0] * self.N; R2 = [0] * self.N\n\n for i, ne in enumerate(self.V[s]):\n L[i] = R[i] = self.A[ne] * self.C.inv[self.children[ne]] % self.mod\n L2[i] = R2[i] = self.children[ne]\n for i in range(1, n):\n L[i] *= L[i - 1]\n L[i] %= self.mod\n L2[i] += L2[i - 1]\n for i in range(1, n - 1)[::-1]:\n R[i] *= R[i + 1]\n R[i] %= self.mod\n R2[i] += R2[i + 1]\n for i, ne in enumerate(self.V[s]):\n if ne == p:\n continue\n self.A[s] = 1\n self.children[s] = 1\n if i > 0:\n self.A[s] *= L[i - 1]\n self.A[s] %= self.mod\n self.children[s] += L2[i - 1]\n if i + 1 < n:\n self.A[s] *= R[i + 1]\n self.A[s] %= self.mod\n self.children[s] += R2[i + 1]\n self.A[s] *= self.C.fac[self.N - self.children[ne] - 1]\n self.A[s] %= self.mod\n dfs2(ne, s)\n return\n\nclass combination():\n \n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1] * (n + 1)\n self.inv = [1] * (n + 1)\n for j in range(1, n + 1):\n self.fac[j] = self.fac[j - 1] * j % mod\n\n self.inv[n] = pow(self.fac[n], mod - 2, mod)\n for j in range(n - 1, -1, -1):\n self.inv[j] = self.inv[j + 1] * (j + 1) % mod\n\n def comb(self, n, r):\n if r > n or n < 0 or r < 0:\n return 0\n return self.fac[n] * self.inv[n - r] * self.inv[r] % self.mod\n\ndef ABC160():\n N = I()\n V = [[] for _ in range(N)]\n for _ in range(N - 1):\n a, b = LI()\n a -= 1; b -= 1\n V[a].append(b)\n V[b].append(a)\n dp_r = treedp_rerooting(N,V,mod)\n dp_r.dfs(0)\n return\n dp_r.dfs2(0)\n\n ans = dp_r.rep\n\n for v in ans:\n print(v)\n return\n\nimport sys,bisect,itertools,heapq,math,random\nfrom copy import deepcopy\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\n\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LSI(): return list(map(str,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nglobal mod,mod2,inf,alphabet,_ep\nmod = 10**9 + 7\nmod2 = 998244353\ninf = 10**18\n_ep = 10**(-12)\nalphabet = [chr(ord(\'a\') + i) for i in range(26)]\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == \'__main__\':\n ABC160()\n\n"""\n8\n1 2\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8\n"""\n\n# 40\n# 280\n# 840\n# 120\n# 120\n# 504\n# 72\n# 72\n\n', 'class treedp_rerooting():\n def __init__(self, N, V, MOD):\n self.N = N\n self.V = V\n self.mod = MOD\n self.rep = [0] * N\n self.children = [-1] * N\n self.A = [0] * N\n self.C = combination(N, MOD)\n return\n\n \n def dfs(self, s):\n size = 1\n nowchild = []\n cur = 1\n self.children[s] = 0\n for i in self.V[s]:\n if self.children[i] != -1:\n continue\n ns, nc = dfs(i)\n nowchild.append(ns)\n size += ns\n cur *= nc\n cur %= self.mod\n self.children[s] = size\n rest = size - 1\n for k in nowchild:\n cur *= C.comb(rest, k, mod)\n rest -= k\n cur %= mod\n self.A[s] = cur\n return size, cur\n\n def dfs2(self, s, p=-1):\n cur = 1\n rest = self.N - 1\n for to in self.V[s]:\n cur *= self.A[to]\n cur %= mod\n for to in self.V[s]:\n cur *= C.comb(rest, children[to], mod)\n rest -= self.children[to]\n cur %= self.mod\n self.rep[s] = rep\n\n n = len(V[s])\n L = [0] * self.N; R = [0] * self.N\n L2 = [0] * self.N; R2 = [0] * self.N\n\n for i, ne in enumerate(self.V[s]):\n L[i] = R[i] = self.A[ne] * C.inv[self.children[ne]] % self.mod\n L2[i] = R2[i] = self.children[ne]\n for i in range(1, n):\n L[i] *= L[i - 1]\n L[i] %= self.mod\n L2[i] += L2[i - 1]\n for i in range(1, n - 1)[::-1]:\n R[i] *= R[i + 1]\n R[i] %= self.mod\n R2[i] += R2[i + 1]\n for i, ne in enumerate(self.V[s]):\n if ne == p:\n continue\n self.A[s] = 1\n self.children[s] = 1\n if i > 0:\n self.A[s] *= L[i - 1]\n self.A[s] %= self.mod\n self.children[s] += L2[i - 1]\n if i + 1 < n:\n self.A[s] *= R[i + 1]\n self.A[s] %= self.mod\n self.children[s] += R2[i + 1]\n self.A[s] *= C.fac[self.N - self.children[ne] - 1]\n self.A[s] %= self.mod\n dfs2(ne, s)\n return\n\nclass combination():\n \n def __init__(self, n, mod):\n self.n = n\n self.fac = [1] * (n + 1)\n self.inv = [1] * (n + 1)\n for j in range(1, n + 1):\n self.fac[j] = self.fac[j - 1] * j % mod\n\n self.inv[n] = pow(self.fac[n], mod - 2, mod)\n for j in range(n - 1, -1, -1):\n self.inv[j] = self.inv[j + 1] * (j + 1) % mod\n\n def comb(self, n, r, mod):\n if r > n or n < 0 or r < 0:\n return 0\n return self.fac[n] * self.inv[n - r] * self.inv[r] % mod\n\ndef ABC160():\n N = I()\n V = [[] for _ in range(N)]\n for _ in range(N - 1):\n a, b = LI()\n a -= 1; b -= 1\n V[a].append(b)\n V[b].append(a)\n dp_r = treedp_rerooting(N,V,mod)\n dp_r.dfs(0)\n dp_r.dfs2(0)\n\n ans = dp_r.rep\n\n for v in ans:\n print(v)\n return\n\nimport sys,bisect,itertools,heapq,math,random\nfrom copy import deepcopy\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\n\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LSI(): return list(map(str,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nglobal mod,mod2,inf,alphabet,_ep\nmod = 10**9 + 7\nmod2 = 998244353\ninf = 10**18\n_ep = 10**(-12)\nalphabet = [chr(ord(\'a\') + i) for i in range(26)]\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == \'__main__\':\n ABC160()\n\n"""\n8\n1 2\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8\n"""\n\n# 40\n# 280\n# 840\n# 120\n# 120\n# 504\n# 72\n# 72\n\n', 'class treedp_rerooting():\n def __init__(self, N, V, MOD):\n self.N = N\n self.V = V\n self.mod = MOD\n self.rep = [0] * N\n self.children = [-1] * N\n self.A = [0] * N\n self.C = combination(N, MOD)\n return\n\n \n def dfs(self, s):\n size = 1\n nowchild = []\n cur = 1\n self.children[s] = 0\n for i in self.V[s]:\n if self.children[i] != -1:\n continue\n ns, nc = dfs(i)\n nowchild.append(ns)\n size += ns\n cur *= nc\n cur %= self.mod\n self.children[s] = size\n rest = size - 1\n for k in nowchild:\n cur *= self.C.comb(rest, k)\n rest -= k\n cur %= self.mod\n self.A[s] = cur\n return size, cur\n\n def dfs2(self, s, p=-1):\n cur = 1\n rest = self.N - 1\n for to in self.V[s]:\n cur *= self.A[to]\n cur %= mod\n for to in self.V[s]:\n cur *= self.C.comb(rest, children[to])\n rest -= self.children[to]\n cur %= self.mod\n self.rep[s] = rep\n\n n = len(V[s])\n L = [0] * self.N; R = [0] * self.N\n L2 = [0] * self.N; R2 = [0] * self.N\n\n for i, ne in enumerate(self.V[s]):\n L[i] = R[i] = self.A[ne] * self.C.inv[self.children[ne]] % self.mod\n L2[i] = R2[i] = self.children[ne]\n for i in range(1, n):\n L[i] *= L[i - 1]\n L[i] %= self.mod\n L2[i] += L2[i - 1]\n for i in range(1, n - 1)[::-1]:\n R[i] *= R[i + 1]\n R[i] %= self.mod\n R2[i] += R2[i + 1]\n for i, ne in enumerate(self.V[s]):\n if ne == p:\n continue\n self.A[s] = 1\n self.children[s] = 1\n if i > 0:\n self.A[s] *= L[i - 1]\n self.A[s] %= self.mod\n self.children[s] += L2[i - 1]\n if i + 1 < n:\n self.A[s] *= R[i + 1]\n self.A[s] %= self.mod\n self.children[s] += R2[i + 1]\n self.A[s] *= self.C.fac[self.N - self.children[ne] - 1]\n self.A[s] %= self.mod\n dfs2(ne, s)\n return\n\nclass combination():\n \n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1] * (n + 1)\n self.inv = [1] * (n + 1)\n for j in range(1, n + 1):\n self.fac[j] = self.fac[j - 1] * j % mod\n\n self.inv[n] = pow(self.fac[n], mod - 2, mod)\n for j in range(n - 1, -1, -1):\n self.inv[j] = self.inv[j + 1] * (j + 1) % mod\n\n def comb(self, n, r):\n if r > n or n < 0 or r < 0:\n return 0\n return self.fac[n] * self.inv[n - r] * self.inv[r] % self.mod\n\ndef ABC160():\n N = I()\n V = [[] for _ in range(N)]\n for _ in range(N - 1):\n a, b = LI()\n a -= 1; b -= 1\n V[a].append(b)\n V[b].append(a)\n dp_r = treedp_rerooting(N,V,mod)\n return\n dp_r.dfs(0)\n dp_r.dfs2(0)\n\n ans = dp_r.rep\n\n for v in ans:\n print(v)\n return\n\nimport sys,bisect,itertools,heapq,math,random\nfrom copy import deepcopy\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\n\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LSI(): return list(map(str,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nglobal mod,mod2,inf,alphabet,_ep\nmod = 10**9 + 7\nmod2 = 998244353\ninf = 10**18\n_ep = 10**(-12)\nalphabet = [chr(ord(\'a\') + i) for i in range(26)]\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == \'__main__\':\n ABC160()\n\n"""\n8\n1 2\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8\n"""\n\n# 40\n# 280\n# 840\n# 120\n# 120\n# 504\n# 72\n# 72\n\n', 'class treedp_rerooting():\n def __init__(self, N, V, MOD):\n self.N = N\n self.V = V\n self.mod = MOD\n self.rep = [0] * N\n self.children = [-1] * N\n self.A = [0] * N\n self.C = combination(N, MOD)\n return\n\n \n def dfs(self, s):\n size = 1\n nowchild = []\n cur = 1\n self.children[s] = 0\n for i in self.V[s]:\n if self.children[i] != -1:\n continue\n ns, nc = dfs(i)\n nowchild.append(ns)\n size += ns\n cur *= nc\n cur %= self.mod\n self.children[s] = size\n rest = size - 1\n for k in nowchild:\n cur *= self.C.comb(rest, k)\n rest -= k\n cur %= self.mod\n self.A[s] = cur\n return size, cur\n\n def dfs2(self, s, p=-1):\n cur = 1\n rest = self.N - 1\n for to in self.V[s]:\n cur *= self.A[to]\n cur %= mod\n for to in self.V[s]:\n cur *= self.C.comb(rest, children[to])\n rest -= self.children[to]\n cur %= self.mod\n self.rep[s] = rep\n\n n = len(V[s])\n L = [0] * self.N; R = [0] * self.N\n L2 = [0] * self.N; R2 = [0] * self.N\n\n for i, ne in enumerate(self.V[s]):\n L[i] = R[i] = self.A[ne] * self.C.inv[self.children[ne]] % self.mod\n L2[i] = R2[i] = self.children[ne]\n for i in range(1, n):\n L[i] *= L[i - 1]\n L[i] %= self.mod\n L2[i] += L2[i - 1]\n for i in range(1, n - 1)[::-1]:\n R[i] *= R[i + 1]\n R[i] %= self.mod\n R2[i] += R2[i + 1]\n for i, ne in enumerate(self.V[s]):\n if ne == p:\n continue\n self.A[s] = 1\n self.children[s] = 1\n if i > 0:\n self.A[s] *= L[i - 1]\n self.A[s] %= self.mod\n self.children[s] += L2[i - 1]\n if i + 1 < n:\n self.A[s] *= R[i + 1]\n self.A[s] %= self.mod\n self.children[s] += R2[i + 1]\n self.A[s] *= self.C.fac[self.N - self.children[ne] - 1]\n self.A[s] %= self.mod\n dfs2(ne, s)\n return\n\nclass combination():\n \n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1] * (n + 1)\n self.inv = [1] * (n + 1)\n for j in range(1, n + 1):\n self.fac[j] = self.fac[j - 1] * j % mod\n\n self.inv[n] = pow(self.fac[n], mod - 2, mod)\n for j in range(n - 1, -1, -1):\n self.inv[j] = self.inv[j + 1] * (j + 1) % mod\n\n def comb(self, n, r):\n if r > n or n < 0 or r < 0:\n return 0\n return self.fac[n] * self.inv[n - r] * self.inv[r] % self.mod\n\ndef ABC160():\n N = I()\n V = [[] for _ in range(N)]\n for _ in range(N - 1):\n a, b = LI()\n a -= 1; b -= 1\n V[a].append(b)\n V[b].append(a)\n dp_r = treedp_rerooting(N,V,mod)\n dp_r.dfs(0)\n dp_r.dfs2(0)\n\n ans = dp_r.rep\n\n for v in ans:\n print(v)\n return\n\nimport sys,bisect,itertools,heapq,math,random\nfrom copy import deepcopy\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\n\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LSI(): return list(map(str,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nglobal mod,mod2,inf,alphabet,_ep\nmod = 10**9 + 7\nmod2 = 998244353\ninf = 10**18\n_ep = 10**(-12)\nalphabet = [chr(ord(\'a\') + i) for i in range(26)]\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == \'__main__\':\n ABC160()\n\n"""\n8\n1 2\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8\n"""\n\n# 40\n# 280\n# 840\n# 120\n# 120\n# 504\n# 72\n# 72\n\n', 'def ABC67_B():\n N, K = LI()\n L = LI()\n L.sort(reverse=True)\n ans = sum(L[:K])\n print(ans)\n return\n\ndef ABC100_C():\n def factorization_2(n):\n arr = defaultdict(int)\n temp = n\n i = 2\n if temp % i == 0:\n cnt = 0\n while temp % i == 0:\n cnt += 1\n temp //= i\n arr[i] = cnt\n if temp != 1:\n arr[temp] = 1\n if arr == []:\n arr[n] = 1\n return arr[2]\n N = I()\n A = LI()\n ans = 0\n for a in A:\n ans += factorization_2(a)\n print(ans)\n return\n\ndef ARC68_C():\n X = I()\n ans = 0\n ans += 2*(X//11)\n rest = X%11\n if rest>0:\n ans += 1\n if rest>=7:\n ans += 1\n print(ans)\n return\n\ndef ABC49_C():\n S = SI()\n T = {"maerd","remaerd","esare","resare"}\n stack = ""\n for s in S[::-1]:\n stack += s\n if stack in T:\n stack = ""\n if stack:\n print("NO")\n else:\n print("YES")\n return\n\ndef ABC142_E():\n N, M = LI()\n A = [0]*M\n C = [[]for _ in range(M)]\n for i in range(M):\n A[i], b = LI()\n C[i] = LI()\n mask = 2**N\n dp = [[inf]*mask for _ in range(M+1)]\n dp[0][0] = 0\n for i in range(M):\n key = 0\n for j in C[i]:\n key += 2**(j-1)\n #print(key)\n for now in range(mask):\n dp[i + 1][now] = min(dp[i + 1][now], dp[i][now])\n if key|now==now:\n continue\n dp[i+1][now|key] = min(dp[i+1][now|key],dp[i][now]+A[i])\n if dp[M][mask-1]==inf:\n print(-1)\n else:\n ans = dp[M][mask-1]\n print(ans)\n #print(dp)\n return\n\ndef ABC160_F():\n class combination():\n \n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1] * (n + 1)\n self.inv = [1] * (n + 1)\n for j in range(1, n + 1):\n self.fac[j] = self.fac[j - 1] * j % mod\n\n self.inv[n] = pow(self.fac[n], mod - 2, mod)\n for j in range(n - 1, -1, -1):\n self.inv[j] = self.inv[j + 1] * (j + 1) % mod\n\n def comb(self, n, r):\n if r > n or n < 0 or r < 0:\n return 0\n return self.fac[n] * self.inv[n - r] * self.inv[r] % self.mod\n\n N = I()\n V = [[]for _ in range(N)]\n for _ in range(N-1):\n a, b = LI()\n a -= 1; b -= 1\n V[a].append(b)\n V[b].append(a)\n C = combination(N,mod)\n children = [-1] * N\n A = [0] * N\n rep = [0] * N\n \n def dfs(s):\n size = 1\n nowchild = []\n cur = 1\n children[s] = 0\n for i in V[s]:\n if children[i] != -1:\n continue\n ns, nc = dfs(i)\n nowchild.append(ns)\n size += ns\n cur *= nc\n cur %= mod\n children[s] = size\n rest = size - 1\n for k in nowchild:\n cur *= C.comb(rest, k)\n rest -= k\n cur %= mod\n A[s] = cur\n return size, cur\n\n def dfs2(s, p=-1):\n cur = 1\n rest = N - 1\n for to in V[s]:\n cur *= A[to]\n cur %= mod\n for to in V[s]:\n cur *= C.comb(rest, children[to])\n rest -= children[to]\n cur %= mod\n rep[s] = cur\n\n n = len(V[s])\n L = [0] * n; R = [0] * n\n L2 = [0] * n; R2 = [0] * n\n\n for i, ne in enumerate(V[s]):\n L[i] = R[i] = A[ne] * C.inv[children[ne]] % mod\n L2[i] = R2[i] = children[ne]\n for i in range(1, n):\n L[i] *= L[i - 1]\n L[i] %= mod\n L2[i] += L2[i - 1]\n for i in range(1, n - 1)[::-1]:\n R[i] *= R[i + 1]\n R[i] %= mod\n R2[i] += R2[i + 1]\n for i, ne in enumerate(V[s]):\n if ne == p:\n continue\n A[s] = 1\n children[s] = 1\n if i > 0:\n A[s] *= L[i - 1]\n A[s] %= mod\n children[s] += L2[i - 1]\n if i + 1 < n:\n A[s] *= R[i + 1]\n A[s] %= mod\n children[s] += R2[i + 1]\n A[s] *= C.fac[N - children[ne] - 1]\n A[s] %= mod\n dfs2(ne, s)\n return\n\n dfs(0)\n dfs2(0)\n\n for ans in rep:\n print(ans)\n return\n\nimport sys,bisect,itertools,heapq,math,random\nfrom copy import deepcopy\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LSI(): return list(map(str,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nglobal mod,mod2,inf,alphabet,_ep\nmod = 10**9 + 7\nmod2 = 998244353\ninf = 10**18\n_ep = 10**(-12)\nalphabet = [chr(ord(\'a\') + i) for i in range(26)]\n\nsys.setrecursionlimit(10**6)\n\nif __name__ == \'__main__\':\n ABC160_F()\n\n"""\n\n"""']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s140212333', 's577412951', 's648426711', 's832222397', 's998726565', 's447087715']
[76500.0, 74856.0, 74852.0, 74852.0, 74856.0, 116840.0]
[1108.0, 718.0, 696.0, 653.0, 717.0, 2980.0]
[3940, 3930, 3881, 3930, 3919, 5105]
p02728
u837673618
3,000
1,048,576
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. For each k=1, ..., N, solve the problem below: * Consider writing a number on each vertex in the tree in the following manner: * First, write 1 on Vertex k. * Then, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows: * Choose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random. * Find the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).
['from functools import *\nfrom collections import *\nimport sys\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.buffer.readline\n \nM = 10**9+7\nN = int(input())\n\n@lru_cache(maxsize=None)\ndef mod_inv(x):\n if x == 1:\n return 1\n return M // x * -mod_inv(M%x) % M\n\nweght = [0]*(N+1)\nsize = [0]*(N+1)\ndef calc_subtree(v):\n W = 1\n S = 1\n for child in Edge[v]:\n Edge[child].remove(v)\n w, s = calc_subtree(child)\n W = W * w % M\n S += s\n weight[v] = W * S % M\n size[v] = S\n return weight[v], size[v]\n\nans = [0]*(N+1)\ndef set_ans(v, a):\n ans[v] = a\n for child in Edge[v]:\n n = calc_subtree(child)[1]\n set_ans(child, ans[v] * n * mod_inv(N-n) % M)\n\nEdge = defaultdict(set)\nfact = N\nfor i in range(1, N):\n fact = fact * i % M\n a, b = map(int, input().split())\n Edge[a].add(b)\n Edge[b].add(a)\n\nset_ans(1, mod_inv(calc_subtree(1)[0]) * fact % M)\nfor i in range(1, N+1):\n print(ans[i])\n\n', 'from functools import *\nfrom itertools import *\nimport sys\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.buffer.readline\n \nM = 10**9+7\nN = int(input())\n\n@lru_cache(maxsize=None)\ndef mod_inv(x):\n return 1 if x == 1 else M // x * -mod_inv(M%x) % M\n\nWeight = [0]*(N+1)\nSize = [0]*(N+1)\ndef calc_subtree(v):\n W, S = 1, 1\n for child in Edge[v]:\n Edge[child].remove(v)\n calc_subtree(child)\n W = W * Weight[child] % M\n S += Size[child]\n Weight[v] = W * S % M\n Size[v] = S\n\nAns = [0]*(N+1)\ndef calc_ans(v, a):\n Ans[v] = a\n for child in Edge[v]:\n n = Size[child]\n calc_ans(child, a * n * mod_inv(N-n) % M)\n\nEdge = [set() for i in range(N+1)]\nfact = N\nfor i in range(1, N):\n fact = fact * i % M\n a, b = map(int, input().split())\n Edge[a].add(b)\n Edge[b].add(a)\n \ncalc_subtree(1)\ncalc_ans(1, mod_inv(Weight[1]) * fact % M)\n\nfor a in islice(Ans, 1, None):\n print(a)\n\n']
['Runtime Error', 'Accepted']
['s432994152', 's989044095']
[86144.0, 80336.0]
[770.0, 1401.0]
[902, 887]
p02728
u968404618
3,000
1,048,576
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. For each k=1, ..., N, solve the problem below: * Consider writing a number on each vertex in the tree in the following manner: * First, write 1 on Vertex k. * Then, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows: * Choose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random. * Find the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).
["import sys\n\n\ndef solve():\n input = lambda: sys.stdin.readline().rstrip()\n sys.setrecursionlimit(10 ** 7)\n mod = 10 ** 9 + 7\n\n def comb(n, r):\n if r > n: return 0\n return fac[n] * inv[r] * inv[n - r] % mod\n\n def dfs(v, Pa=-1):\n for u in to[v]:\n if u == Pa: continue\n dfs(u, v)\n size[v] += size[u]\n dp[v] *= dp[u] % mod\n dp[v] *= inv[size[u]] % mod\n dp[v] *= fact[size[v]] % mod\n size[v] += 1\n\n def bfs(v, Pa=-1, P_val=1, P_sz=0):\n ans[v] = P_val * dp[v] * comb(n - 1, P_sz) % mod\n for u in to[v]:\n if u == Pa: continue\n val = ans[v] * INV(dp[u] * comb(n - 1, size[u])) % mod\n bfs(u, v, val, n - size[u])\n\n n = int(input())\n to = [[] for _ in range(n)]\n for _ in range(n - 1):\n a, b = map(lambda x: int(x) - 1, input().split())\n to[a].append(b)\n to[b].append(a)\n\n fac = [1] * (n + 2)\n inv = [1] * (n + 2)\n\n for i in range(2, n + 1):\n fac[i] = fac[i - 1] * i % mod\n INV = lambda x: pow(x, mod - 2, mod)\n inv[n] = INV(fac[n])\n for i in range(n - 1, 1, -1):\n inv[i] = inv[i + 1] * (i + 1) % mod\n\n dp = [1] * n\n size = [0] * n\n ans = [0] * n\n\n dfs(0)\n bfs(0)\n print(*ans, sep='\\n')\n\n\nif __name__ == '__main__':\n solve()", "import sys\n\ndef solve():\n input = lambda: sys.stdin.readline().rstrip()\n sys.setrecursionlimit(10 ** 7)\n mod = 10 ** 9 + 7\n\n def comb(n, r):\n if r > n: return 0\n return fac[n] * inv[r] * inv[n - r] % mod\n\n def dfs(v, Pa=-1):\n for u in to[v]:\n if u == Pa: continue\n dfs(u, v)\n size[v] += size[u]\n dp[v] *= dp[u] % mod\n dp[v] *= inv[size[u]] % mod\n dp[v] *= fact[size[v]] % mod\n size[v] += 1\n\n def bfs(v, Pa=-1, P_val=1, P_sz=0):\n ans[v] = P_val * dp[v] * comb(n - 1, P_sz) % mod\n for u in to[v]:\n if u == Pa: continue\n val = ans[v] * INV(dp[u] * comb(n - 1, size[u])) % mod\n bfs(u, v, val, n - size[u])\n\n n = int(input())\n to = [[] for _ in range(n)]\n for _ in range(n - 1):\n a, b = map(lambda x: int(x) - 1, input().split())\n to[a].append(b)\n to[b].append(a)\n\n fac = [1] * (n + 2)\n inv = [1] * (n + 2)\n\n for i in range(2, n + 1):\n fac[i] = fac[i - 1] * i % mod\n INV = lambda x: pow(x, mod - 2, mod)\n inv[n] = INV(fac[n])\n for i in range(n - 1, 1, -1):\n inv[i] = inv[i + 1] * (i + 1) % mod\n\n dp = [1] * n\n size = [0] * n\n ans = [0] * n\n\n dfs(0)\n bfs(0)\n print(*ans, sep='\\n')\n\nif __name__ == '__main__':\n solve()\n", "import sys\ninput = lambda: sys.stdin.readline().rstrip()\nsys.setrecursionlimit(10**7)\nmod = 10**9+7\n\ndef comb(n, r):\n \u3000if n < r or n < 0 or r < 0: return 0\n if 2*r > n: comb(n, n-r)\n return fac[n] * inv[r] * inv[n-r] % mod\n\ndef dfs(v, Pa=-1):\n for u in to[v]:\n if u == Pa: continue\n dfs(u, v)\n size[v] += size[u]\n dp[v] *= dp[u] % mod\n dp[v] *= comb(size[v], size[u]) % mod\n size[v] += 1\n\ndef bfs(v, Pa=-1, P_val=1, P_sz=0):\n ans[v] = P_val * dp[v] * comb(n-1, P_sz) % mod\n for u in to[v]:\n if u == Pa: continue\n val = ans[v] * INV(dp[u]*comb(n-1, size[u])) % mod\n bfs(u, v, val, n-size[u])\n\nn = int(input())\nto = [[] for _ in range(n)]\nfor _ in range(n-1):\n a, b = map(lambda x : int(x)-1, input().split())\n to[a].append(b)\n to[b].append(a)\n\nfac = [1] * (n+2)\ninv = [1] * (n+2)\n\nfor i in range(2, n+1):\n fac[i] = fac[i-1] * i % mod\nINV = lambda x: pow(x, mod-2, mod)\ninv[n] = INV(fac[n])\nfor i in range(n-1, 1, -1):\n inv[i] = inv[i+1] * (i+1) % mod\n\ndp = [1] * n\nsize = [0] * n\nans = [0] * n\n\ndfs(0)\nbfs(0)\nprint(*ans, sep='\\n')", "import sys\n\ndef solve():\n input = lambda: sys.stdin.readline().rstrip()\n sys.setrecursionlimit(10 ** 7)\n mod = 10 ** 9 + 7\n\n def comb(n, r):\n if r > n: return 0\n return fac[n] * inv[r] * inv[n - r] % mod\n\n def dfs(v, Pa=-1):\n for u in to[v]:\n if u == Pa: continue\n dfs(u, v)\n size[v] += size[u]\n dp[v] *= dp[u] % mod\n dp[v] *= inv[size[u]] % mod\n dp[v] *= fac[size[v]] % mod\n size[v] += 1\n\n def bfs(v, Pa=-1, P_val=1, P_sz=0):\n ans[v] = P_val * dp[v] * comb(n - 1, P_sz) % mod\n for u in to[v]:\n if u == Pa: continue\n val = ans[v] * INV(dp[u] * comb(n - 1, size[u])) % mod\n bfs(u, v, val, n - size[u])\n\n n = int(input())\n to = [[] for _ in range(n)]\n for _ in range(n - 1):\n a, b = map(lambda x: int(x) - 1, input().split())\n to[a].append(b)\n to[b].append(a)\n\n fac = [1] * (n + 2)\n inv = [1] * (n + 2)\n\n for i in range(2, n + 1):\n fac[i] = fac[i - 1] * i % mod\n INV = lambda x: pow(x, mod - 2, mod)\n inv[n] = INV(fac[n])\n for i in range(n - 1, 1, -1):\n inv[i] = inv[i + 1] * (i + 1) % mod\n\n dp = [1] * n\n size = [0] * n\n ans = [0] * n\n\n dfs(0)\n bfs(0)\n print(*ans, sep='\\n')\n\nif __name__ == '__main__':\n solve()"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s117440027', 's517667015', 's913756424', 's115897981']
[72760.0, 72760.0, 2940.0, 82136.0]
[694.0, 709.0, 17.0, 2384.0]
[1351, 1350, 1121, 1348]
p02729
u004271495
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['"""\n"""\n\nfrom math import factorial\n\n\ndef int_as_array(num): return list(map(int, [y for y in str(num)]))\n\n\ndef array_as_int(arr): return int(\'\'.join(map(str, arr)))\n\n\ndef read_int(): return int(input())\n\n\ndef read_array(): return list(map(int, input().split(\' \')))\n\n\ndef array_to_string(arr, sep=\' \'): return sep.join(map(str, arr))\n\n\ndef matrix_to_string(arr, sep=\' \'): return \'[\\n\' + \'\\n\'.join(\n [sep.join(map(str, row)) for row in arr]) + \'\\n]\'\n\n\ndef combine(n, r):\n return (factorial(n) / factorial(n - r)) * (1 / r)\n\n\ndef solve(N, M):\n choose_evens = combine(N, 2)\n choose_odds = combine(M, 2)\n return choose_evens + choose_odds\n\n\nprint(\'input()\', input())\nN, M = read_array()\nprint(\'N, M\', N, M)\nsolve(N, M)\n', '"""\n"""\n\nfrom math import factorial\n\n\ndef int_as_array(num): return list(map(int, [y for y in str(num)]))\n\n\ndef array_as_int(arr): return int(\'\'.join(map(str, arr)))\n\n\ndef read_int(): return int(input())\n\n\ndef read_array(): return list(map(int, input().split(\' \')))\n\n\ndef array_to_string(arr, sep=\' \'): return sep.join(map(str, arr))\n\n\ndef matrix_to_string(arr, sep=\' \'): return \'[\\n\' + \'\\n\'.join(\n [sep.join(map(str, row)) for row in arr]) + \'\\n]\'\n\n\ndef combine(n, r):\n try:\n return (factorial(n) / factorial(n - r)) * (1 / r)\n except:\n return 0\n\n\ndef solve(N, M):\n choose_evens = combine(N, 2)\n choose_odds = combine(M, 2)\n return int(choose_evens + choose_odds)\n\n\nN, M = read_array()\nprint(solve(N, M))\n']
['Runtime Error', 'Accepted']
['s556960746', 's940249905']
[3064.0, 3064.0]
[19.0, 18.0]
[730, 738]
p02729
u004482945
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['n, m = map(int, input().split())\nprint(n*(n-1)/2 + m*(m-1)/2)', 'n, m = map(int, input().split())\nprint(int(n*(n-1)/2 + m*(m-1)/2))']
['Wrong Answer', 'Accepted']
['s635065061', 's415523650']
[2940.0, 2940.0]
[17.0, 18.0]
[61, 66]
p02729
u004823354
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['n,m = map(int,input().split())\nprint(n*(n-1)/2+m*(m-1)/2)', 'n,m = map(int,input().split())\nn=n*(n-1)\nm=m*(m-1)\nprint(n/2+m/2)', 'n, m = map(int, input().split())\nif n >= 2:\n a = n * (n - 1) / 2\nelse:\n a = 0\nif m >= 2:\n b = m * (m - 1) / 2\nelse:\n b = 0 \nprint(int(a + b))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s155876232', 's202758909', 's745079752']
[9152.0, 9156.0, 9032.0]
[29.0, 31.0, 24.0]
[57, 65, 156]
p02729
u007263493
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['n , m = map(int,input().split())\nprint(n*(n-1)/2 + m*(m-1)/2)', 'n , m = map(int,input().split())\nprint(n*(n-1)//2 + m*(m-1)//2)']
['Wrong Answer', 'Accepted']
['s441375051', 's294259658']
[2940.0, 2940.0]
[18.0, 17.0]
[61, 63]
p02729
u007738720
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['N,M=map(int,input().split())\nn=N*(N-1)/2\nm=M*(M-1)/2\nprint(n+m)', 'N,M=map(int,input().split())\nprint((N*(N-1)+M*(M-1))/2)', 'N,M=map(int,input().split())\nprint(N*(N-1)/2+M*(M-1)/2)', 'N,M=map(int,input().split())\nprint(int(N*(N-1)+M*(M-1))/2)', 'N,M=map(int,input().split())\nprint(int(N*(N-1)/2+M*(M-1)/2))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s068611730', 's177715970', 's393381413', 's975622559', 's321938537']
[2940.0, 3064.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 18.0, 17.0, 17.0]
[63, 55, 55, 58, 60]
p02729
u008911501
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['n=int(input())\nm=int(input())\nc=int((n*(n-1))//2)\nd=int((m*(m-1))//2)\nprint(c+d)\n', 'n=int(input())\nm=int(input())\nif n>1:\n c=int((n*(n-1))/2)\nelse:\n c=0\nif m>1:\n d=int((m*(m-1))/2)\nelse:\n d=0\nprint(c+d)\n', 'n=int(input())\nm=int(input())\nif n>1:\n c=int((n*(n-1))/2)\nelse:\n c=int(0)\nif m>1:\n d=int((m*(m-1))/2)\nelse:\n d=int(0)\nprint(c+d)\nreturn 0', 'n=int(input())\nm=int(input())\nif n>1:\n c=int((n*(n-1))/2)\nelse:\n c=int(input(0))\nif m>1:\n d=int((m*(m-1))/2)\nelse:\n d=int(input(0))\nprint(c+d)\n', 'n=int(input())\nm=int(input())\nc=0\nd=0\nif n>1:\n c=int((n*(n-1))/2)\nif m>1:\n d=int((m*(m-1))/2)\nprint(c+d)\n', 'n=int(input())\nm=int(input())\nif n>1:\n c=int((n*(n-1))/2)\nelse:\n c=int(0)\nif m>1:\n d=int((m*(m-1))/2)\nelse:\n d=int(0)\nprint(c+d)\n', 'n=int(input())\nm=int(input())\nprint((n*(n-1)+m*(m-1))//2)\n', 'n,m=map(int,input().split())\nprint((n*(n-1)+m*(m-1))//2)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s182940676', 's309387148', 's523311018', 's806334847', 's871639870', 's977970310', 's993489940', 's358717953']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 3060.0, 2940.0, 3064.0]
[17.0, 17.0, 17.0, 17.0, 17.0, 19.0, 18.0, 17.0]
[81, 131, 149, 155, 111, 141, 58, 57]
p02729
u011277545
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['N,M=map(int, input().split())\nA=N*(N-1)/2\nB=M*(M-1)/2\nprintint((A+B)', 'import math\n\nnum=int(input())\ntarget=list(map(int, input().split()))\ndef comb(N, r):\n return math.factorial(N) // (math.factorial(N - r) * math.factorial(r))\n\nfor i in range(num):\n A=target.copy()\n A.pop(i)\n B=[x for x in set(A) if A.count(x) > 1]\n out=0 \n for j in B:\n base = comb(A.count(j),2)\n out=out+base\n print(out)\n ', 'N,M=map(int, input().split())\nA=N*(N-1)/2\nB=M*(M-1)/2\nprint(A+B)\n', 'N,M=map(int, input().split())\nA=N*(N-1)/2\nB=M*(M-1)/2\nprint(int(A+B))\n']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s243084285', 's538188506', 's642123987', 's035294761']
[2940.0, 3064.0, 2940.0, 2940.0]
[17.0, 18.0, 17.0, 17.0]
[68, 365, 65, 70]
p02729
u012955130
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
["L = map(int, input())\n\nl = L/3\n\nl*l*l\n\nprint('{:.0f}'.format(l*l*l))", "import math\n\nN, M = map(int, input().split(' '))\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\ncnt = 0\n\nif N > 1:\n cnt += combinations_count(N, 2)\nif M > 1:\n cnt += combinations_count(M, 2)\n\nprint(cnt)"]
['Runtime Error', 'Accepted']
['s684907615', 's552577428']
[2940.0, 3060.0]
[18.0, 17.0]
[68, 268]
p02729
u016323272
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
["S = list(input())\nN = len(S)\n\nS1 = S[:(N-1)//2]\nS2 = S[((N+3)//2)-1:]\nS2.reverse()\n\nS3 = S[:(N-3)//4]\nS4 = S[(N+1)//4:(N-1)//2]\nS4.reverse()\n\nS5 = S[(N+1)//2:(3*N-1)//4]\nS6 = S[(3*N+3)//4:]\nS6.reverse()\n\nif S1 ==S2 and S3 ==S4 and S5 == S6:\n print('Yes')\nelse:\n print('No')\n ", 'N,M = map(int,input().split())\nc = N*(N-1)//2 + M*(M-1)//2\nprint(c)']
['Wrong Answer', 'Accepted']
['s032670020', 's702166773']
[3064.0, 2940.0]
[18.0, 17.0]
[346, 67]
p02729
u017624958
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['from math import factorial\n\ninputted = list(map(int, input().split()))\nN = inputted[0]\nM = inputted[1]\n\nnPk = lambda n, k: 0 if n - k <= 0 else factorial(n) / (factorial(k) * factorial(n - k))\n\nanswer = nPk(N, 2) + nPk(M, 2)\nanswer = int(answer)\n\nprint(answer)\n', 'from math import factorial\n\ninputted = list(map(int, input().split()))\nN = inputted[0]\nM = inputted[1]\n\nnPk = lambda n, k: factorial(n) / (factorial(k) * factorial(n - k))\n\nanswer = nPk(N, 2) + nPk(M, 2)\nanswer = int(answer)\n\nprint(answer)\n', 'from math import factorial\n\ninputted = list(map(int, input().split()))\nN = inputted[0]\nM = inputted[1]\n\nnPk = lambda n, k: 0 if n - k < 0 else factorial(n) / (factorial(k) * factorial(n - k))\n\nanswer = nPk(N, 2) + nPk(M, 2)\nanswer = int(answer)\n\nprint(answer)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s167652040', 's892148663', 's404344627']
[3060.0, 3060.0, 3060.0]
[17.0, 18.0, 18.0]
[262, 241, 261]
p02729
u018771977
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['#! env/bin/local python3\n# -*- coding: utf-8 -*-\n\nn, m = map(int, input().split())\n\npick_up_from_n = n * (n - 1) / 2\npick_up_from_m = m * (m - 1) / 2\n\nprint(pick_up_from_m + pick_up_from_n)', '#! env/bin/local python3\n# -*- coding: utf-8 -*-\n\nn, m = map(int, input().split())\n\npick_up_from_n = n * (n - 1) // 2\npick_up_from_m = m * (m - 1) // 2\n\nprint(pick_up_from_m + pick_up_from_n)']
['Wrong Answer', 'Accepted']
['s044888161', 's270203674']
[2940.0, 2940.0]
[17.0, 17.0]
[189, 191]
p02729
u024340351
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['import operator as op\nfrom functools import reduce\n\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer / denom\n \nN, M = map(int, input().split())\n\nif N < 2:\n\tif M < 2:\n\t\tprint(0)\n\telse:\n\t\tprint(ncr(M,2))\nelif M < 2:\n\tprint(ncr(N,2))\nelse:\n\tprint(int(ncr(N,2)+ncr(M,2)))', 'import operator as op\nfrom functools import reduce\n\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer / denom\n \nN, M = map(int, input().split())\n\nif N == 0:\n\tif M ==0:\n\t\tprint(0)\n\telse:\n\t\tprint(M)\nelif M == 0:\n\tprint(N)\nelse:\n\tprint(int(ncr(N,2)+ncr(M,2)))', 'import operator as op\nfrom functools import reduce\n\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(op.mul, range(n, n-r, -1), 1)\n denom = reduce(op.mul, range(1, r+1), 1)\n return numer / denom\n\nN, M = map(int, input().split())\nprint(int(ncr(N,2)+ncr(M,2)))', 'N, M = map(int, input().split())\n\nimport math\nprint(math.comb(N, 2)+math.comb(M, 2))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s544482498', 's803009431', 's863723769', 's054656668']
[3700.0, 3572.0, 3572.0, 9080.0]
[25.0, 22.0, 23.0, 32.0]
[365, 353, 269, 84]
p02729
u025287757
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['n, m = map(int, input().split())\nfrac = [1]\nfor i in range(max(n, m)):\n frac.append(frac[i]*(i+1)%p)\nmod = 10**9 + 7\n\ndef comb(n, k, mod):\n a=frac[n]\n b=frac[k]\n c=frac[n-k]\n return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod\nprint(comb(n, 2, mod) + comb(m, 2, mod))', 'n, m = map(int, input().split())\nfrac = [1]\nfor i in range(max(n, m)):\n frac.append(frac[i]*(i+1)%p)\nmod = 10***9 + 7\n\ndef comb(n, k, mod):\n a=frac[n]\n b=frac[k]\n c=frac[n-k]\n return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod\nprint(comb(n, 2, mod) + comb(m, 2, mod))', 'n, m = map(int, input().split())\nfrac = [1]\np = 10**9 + 7\nfor i in range(max(n, m)):\n frac.append(frac[i]*(i+1)%p)\n\n\ndef comb(n, k, mod):\n a=frac[n]\n b=frac[k]\n c=frac[n-k]\n return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod\nif n >= 2:\n a = comb(n, 2, p)\nelse:\n a = 0\nif m >= 2:\n b = comb(m, 2, p)\nelse:\n b = 0\nprint(a + b)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s381956691', 's535079255', 's412221991']
[3064.0, 2940.0, 3064.0]
[17.0, 17.0, 18.0]
[351, 352, 412]
p02729
u026862065
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['n, m = map(int, input().split())\nprint(n * (n - 1)/ 2 + m * (m - 1) / 2)\n', 'n, m = map(int, input().split())\nprint(int(n * (n - 1) / 2 + m * (m + 1) / 2))\n', 'n, m = map(int, input().split())\nprint(int(n * (n - 1) / 2 + m * (m - 1) / 2))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s278541146', 's530517844', 's435676518']
[2940.0, 3316.0, 3316.0]
[17.0, 19.0, 18.0]
[73, 79, 79]
p02729
u028014940
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['\nfrom math import factorial\n\nM, N = map(int, input().split())\n\ndef combinations_count(n, r):\n return factorial(n) // (factorial(n - r) * factorial(r))\n\nsum_n = combinations_count(M, 2) + combinations_count(N, 2)\nprint(sum_n)', '\nfrom math import factorial\n\nM, N = map(int, input().split())\n\ndef combinations_count(n, r):\n return factorial(n) // (factorial(n - r) * factorial(r))\n\nif M > 2 and N >2:\n sum_n = combinations_count(M, 2) + combinations_count(N, 2)\n\nelif M > 2:\n sum_n = combinations_count(M, 2)\n\nelif N > 2:\n sum_n = combinations_count(N, 2)\n\nelse:\n sum_n = 0\n\nprint(sum_n)', '\nfrom math import factorial\n\nM, N = map(int, input().split())\n\ndef combinations_count(n, r):\n return factorial(n) // (factorial(n - r) * factorial(r))\n\nif M > 1 and N > 1:\n sum_n = combinations_count(M, 2) + combinations_count(N, 2)\n\nelif M > 1:\n sum_n = combinations_count(M, 2)\n\nelif N > 1:\n sum_n = combinations_count(N, 2)\n\nelse:\n sum_n = 0\n\nprint(sum_n)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s095606972', 's779898175', 's619740203']
[2940.0, 3060.0, 3060.0]
[17.0, 17.0, 17.0]
[227, 372, 373]
p02729
u028489522
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['x = input().split\nn = int(x[0])\nm = int(x[1])\nif n == 0:\n print(m * (m -1) /2)\nelif m == 0:\n print(n * (n - 1) / 2)\nelse:\n k = m * (m -1) /2 + n * (n - 1) / 2\n print(k)', 'x = input().split()\nn = int(x[0])\nm = int(x[1])\nif n == 0:\n print(m * (m -1) /2)\nelif m == 0:\n print(n * (n - 1) / 2)\nelse:\n k = m * (m -1) /2 + n * (n - 1) / 2\n print(k)', 'x = input().split()\nn = int(x[0])\nm = int(x[1])\nif n == 0:\n print(int(m * (m -1) /2))\nelif m == 0:\n print(int(n * (n - 1) / 2))\nelse:\n k = m * (m -1) /2 + n * (n - 1) / 2\n print(int(k))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s572644634', 's650331544', 's423910991']
[3060.0, 3060.0, 3060.0]
[17.0, 17.0, 17.0]
[172, 174, 189]
p02729
u030856690
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['import math \ndef ncr(m,n):\n return((math.factorial(m))/((math.factorial(n))*(math.factorial(m-n))))\nnm=list(map(int,input().split()))\nif(nm[0]<2 and nm[1]>=2):\n print(ncr(nm[1],2))\nelif(nm[0]>=2 and nm[1]<2):\n print(ncr(nm[0],2))\nelif(nm[0]<2 and nm[1]<2):\n print(0)\nelse:\n print(int(ncr(nm[0],2)+ncr(nm[1],2)))', 'import math \ndef ncr(m,n):\n return((math.factorial(m))/((math.factorial(n))*(math.factorial(m-n))))\nnm=list(map(int,input().split()))\nif(nm[0]<2 and nm[1]>=2):\n print(int(ncr(nm[1],2)))\nelif(nm[0]>=2 and nm[1]<2):\n print(int(ncr(nm[0],2)))\nelif(nm[0]<2 and nm[1]<2):\n print(0)\nelse:\n print(int(ncr(nm[0],2)+ncr(nm[1],2)))\n']
['Wrong Answer', 'Accepted']
['s895034311', 's023827234']
[3064.0, 3064.0]
[17.0, 17.0]
[326, 337]
p02729
u031722966
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['def main():\n n, m = map(int, input().split())\n n -= 1\n m -= 1\n e = 0\n while n > 0:\n e += n\n print(n)\n n -= 1\n while m > 0:\n e += m\n m -= 1\n print(e)\n \nmain()', 'def main():\n n, m = map(int, input().split())\n n -= 1\n m -= 1\n e = 0\n while n > 0:\n e += n\n n -= 1\n while m > 0:\n e += m\n m -= 1\n print(e)\n \nmain()']
['Wrong Answer', 'Accepted']
['s456488677', 's206962530']
[3060.0, 2940.0]
[17.0, 18.0]
[213, 196]
p02729
u034128150
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['n, m = map(int, input().split())\nprint((n*(n-1) + m*(m-1))/2)\n', 'n, m = map(int, input().split())\nprint(n*(n-1) + m*(m-1))', 'n, m = map(int, input().split())\nprint((n*(n-1) + m*(m-1))//2)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s039402728', 's599053065', 's524201607']
[2940.0, 2940.0, 2940.0]
[18.0, 17.0, 17.0]
[62, 57, 63]
p02729
u034459102
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
["letters = input()\n\ndef kaibun_check(letters):\n count = 0\n if len(letters)%2 == 0 or len(letters)<1:\n return False\n for _ in range(len(letters)//2):\n count += 1\n if letters[count-1] != letters[-count]:\n return False\n return True\n\nif kaibun_check(letters) and kaibun_check(letters[:(len(letters)-1)//2]) and kaibun_check(letters[(len(letters)+3)//2-1:]):\n print('Yes')\nelse:\n print('No')\n", 'import math\nN, M= list(map(int, input().split()))\n\nnum = math.factorial(N)//math.factorial(max(N-2, 1))//2 + math.factorial(M)//math.factorial(max(M-2, 1))//2\nprint(num)']
['Wrong Answer', 'Accepted']
['s098282778', 's110680936']
[3060.0, 3060.0]
[18.0, 18.0]
[436, 306]
p02729
u036104576
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['N, M = map(int, input().split())\nx = N + M\nprint(x * (x - 1) // 2 - (N * (N - 1)//2) * (M * (M - 1)//2))', 'N, M = map(int, input().split())\nx = N + M\nprint(x * (x - 1) // 2 - N * M)']
['Wrong Answer', 'Accepted']
['s686905858', 's257322217']
[9084.0, 9168.0]
[28.0, 27.0]
[104, 74]
p02729
u036479746
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['N,M= map(int,input().split())\nprint(N*(N-1)/2+M*(M-1)/2)', 'N,M= map(int,input().split())\nprint(N*(N-1)/2+M*(M-1))', 'N,M= map(int,input().split())\nprint(N*(N-1)//2+M*(M-1)//2)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s480933406', 's563082899', 's526918490']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[56, 54, 58]
p02729
u037098269
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['N, M = map(int, input().split())\nprint((N*(N-1) + M*(M-1))/2)', 'N, M = map(int, input().split())\nprint(int((N*(N-1) + M*(M-1))/2))']
['Wrong Answer', 'Accepted']
['s047196124', 's951842325']
[2940.0, 2940.0]
[17.0, 17.0]
[61, 66]
p02729
u038887660
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['import collections\nn = int(input())\nli = list(map(int, input().split()))\ndef calc(a):\n return int(a*(a-1)*0.5)\nfor k in range(n):\n\tdic = collections.Counter(li)\n\tdic[li[k]] -=1\n\tdata2 = map(calc, list(dic.values()))\n\tprint(sum(data2))', 'n, m = map(int, input().split())\nif n <= 1:\n sn = 0\nelse:\n sn = int(0.5*(n)*(n-1))\nif m <= 1:\n sm = 0\nelse:\n sm = int(0.5*(m)*(m-1))\nprint(sn+sm)']
['Runtime Error', 'Accepted']
['s286358084', 's595329219']
[3316.0, 3060.0]
[22.0, 17.0]
[237, 157]
p02729
u039934639
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['N, M = map(int, input().split())\n\neven = N*(N-1)/2\nodd = M*(M-1)/2\n\nans = even + odd\n\nprint(ans)', "S = input()\nN = len(S)\n\nx = (N-1)/2\ny = (N+3)/2\n\na = S[:x]\nb = S[y:N]\n\nif a == reversed(a) and b == reversed(b):\n print('Yes')\nelse:\n print('No')", 'N, M = map(int, input().split())\n\neven = N*(N-1)/2\nodd = M*(M-1)/2\n\nans = even + odd\n\nprint(ans)', 'N, M = map(int, input().split())\n\neven = N*(N-1)/2\nodd = M*(M-1)/2\n\nans = even + add\n\nprint(ans)', 'N, M = map(int, input().split())\n\neven = N*(N-1)/2\nodd = M*(M-1)/2\n\nprint(even + odd)', 'N, M = map(int, input().split())\n\neven = N*(N-1)/2\nodd = M*(M-1)/2\n\nprint(int(even + odd))']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s352445351', 's388908236', 's487263420', 's768978437', 's897275151', 's103925987']
[2940.0, 3060.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0, 17.0, 17.0, 17.0]
[96, 147, 96, 96, 85, 90]
p02729
u041351774
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
["s=input();print('YNeos'[s.count(s[:len(s)//2])<2::2])", 'n, m = map(int, input().split())\nprint(int(n * (n - 1) / 2 + m * (m - 1) / 2))']
['Wrong Answer', 'Accepted']
['s166209191', 's878090919']
[2940.0, 2940.0]
[17.0, 17.0]
[53, 78]
p02729
u043062362
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
["str1 =str(input())\ns1 = str1.split(' ')\nm = int(s1[0])\nn = int(s1[1])\nx = (m*(m-1))/2\ny = (n*(n-1))/2\nprint(int((x+y))", "str1 =str(input())\ns1 = str1.split(' ')\nm = int(s1[0])\nn = int(s1[1])\nx = (m*(m+1))//2\ny = (n*(n+1))//2\nprint(x+y)", "str1 =str(input())\ns1 = str1.split(' ')\nm = int(s1[0])\nn = int(s1[1])\nx = (m*(m-1))/2\ny = (n*(n-1))/2\nprint(int(x+y))"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s855785534', 's880374304', 's026113859']
[2940.0, 3064.0, 3060.0]
[18.0, 18.0, 17.0]
[118, 114, 117]
p02729
u043623523
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['N,M=map(int,input().split())\n\nn=0\nm=0\n\nif N>1:\n n=(N*(N-1))/2\n\nif M>1:\n m=(M*(M-1))/2\n\nprint(n+m)', 'N,M=map(int,input().split())\n\n\n\nif N>=2:\n n=(N*(N-1))/2\n\nelse:\n n=0\n\nif M>=2:\n m=(M*(M-1))/2\n\nelse:\n m=0\n\nprint(n+m)', 'N,M=map(int,input().split())\nif N>=2:\n n=(N*(N-1))/2\nif M>=2:\n m=(M*(M-1))/2\na=n+m\nprint(a)', 'N,M=map(int,input().split())\n\ns=N*M\nm=N+M\n\nd=(m*(m-1))/2\n\nprint(d-s)', 'N,M=map(int,input().split())\n\n\nif 100>=N>=2:\n n=(N*(N-1))/2\n\nelse:\n n=0\n\nif 100>=M>=2:\n m=(M*(M-1))/2\nelse:\n m=0\n \nprint(n+m)', 'N,M=map(int,input().split())\n\nn=0\nm=0\n\nif N>=2:\n n=(N*(N-1))/2\n\nif M>=2:\n m=(M*(M-1))/2\n\nprint(n+m)', 'N,M=map(int,input().split())\n\ns=N*M\nm=N+M\n\nd=(m*(m-1))/2\n\nprint(int(d-s))']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s066372175', 's120416553', 's302313802', 's674084303', 's873731095', 's979869119', 's476273128']
[3060.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[18.0, 17.0, 18.0, 17.0, 17.0, 17.0, 17.0]
[103, 128, 97, 68, 140, 105, 73]
p02729
u044220565
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
["# coding: utf-8\nN = int(input())\nA = input().split()\nfor k in range(N):\n A_ = A.copy()\n del A_[k]\n ans = 0\n while len(A_) > 0:\n val = A_[0]\n counts = A_.count(val)\n ans += int(counts * (counts - 1) / 2)\n while True:\n try:\n A_.remove(val)\n except:\n break\n\n print('{}'.format(ans))", 'L = int(input())\nprint((L/3)**3)\n', '# coding: utf-8\nimport itertools\nA = [0]\nN, S = list(map(int, input().split()))\nA = A + list(map(int, input().split())) \nval = 0\nfor L in range(1, N+1):\n for R in range(L, N+1):\n A_ = A[L:R+1]\n lists = []\n for n in range(len(A_)):\n for comb in itertools.combinations(A_, n+1):\n lists.append(list(comb))\n for lis in lists:\n _sum = sum(lis)\n if _sum == S:\n val += 1\n if val == 998244353:\n val = 0\nprint(val)\n', "# coding: utf-8\nN = int(input())\nA = input().split()\nfor k in range(N):\n A_ = A.copy()\n del A_[k]\n ans = 0\n while len(A_) > 0:\n val = A_[0]\n counts = A_.count(val)\n ans += int(counts * (counts - 1) / 2)\n while True:\n try:\n A_.remove(val)\n except:\n break\n\n print('{}'.format(ans))", '# coding: utf-8\nimport sys\n#from operator import itemgetter\nsysread = sys.stdin.buffer.readline\nread = sys.stdin.buffer.read\n#from heapq import heappop, heappush\n#from collections import defaultdict\nsys.setrecursionlimit(10**7)\n#import math\n#from itertools import product#accumulate, combinations, product\n\n#import numpy as np\n#from copy import deepcopy\n#from collections import deque\ndef run():\n N, M = map(int, sysread().split())\n print(N*max(N-1,0)//2 + M*max(M-1, 0)//2)\nif __name__ == "__main__":\n run()\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s397821030', 's484256966', 's642917133', 's865850566', 's325699989']
[3060.0, 2940.0, 3188.0, 3060.0, 2940.0]
[17.0, 17.0, 19.0, 17.0, 18.0]
[320, 33, 462, 320, 549]
p02729
u047918169
2,000
1,048,576
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.
['n, m = [int(i) for i in input().split()]\nprint((n*(n-1)+m*(m-1))/2)', 'n,m=map(int,input().split());print((n*(n-1)+m*(m-1))//2)']
['Wrong Answer', 'Accepted']
['s880616124', 's308750130']
[2940.0, 2940.0]
[17.0, 17.0]
[67, 56]